Re: [PATCH v6 net-next 6/7] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support

From: Vladimir Oltean
Date: Thu Nov 30 2023 - 08:22:37 EST


On Thu, Nov 30, 2023 at 01:49:03PM +0200, Roger Quadros wrote:
> Thanks for the debug instructions. Indeed lldpad tries to enable MM TX and the
> network drivers set_mm() hook gets called and returns success but still
> lldpad sees some error.
>
> I've also confirmed that ethnl_set_mm() runs successfully and returns 1.
> I suppose something is going wrong in user-space with libnl?
>
> Nov 21 11:50:02 am62xx lldpad[708]: eth0: Link partner preemption capability supported
> Nov 21 11:50:02 am62xx lldpad[708]: eth0: Link partner preemption capability not enabled
> Nov 21 11:50:02 am62xx lldpad[708]: eth0: Link partner preemption capability not active
> Nov 21 11:50:02 am62xx lldpad[708]: eth0: Link partner minimum fragment size: 124 octets
> Nov 21 11:50:02 am62xx lldpad[708]: eth0: initiating MM verification with a retry interval of 134 ms...
> Nov 21 11:50:02 am62xx lldpad[708]: ethtool: kernel reports: integer out of range
>
>
> full debug log is below.

Ah, you got confused. Openlldp issues multiple ETHTOOL_MSG_MM_SET
netlink messages. What you observe is that one of them succeeds, and
then another one returns -ERANGE before even calling the driver's
set_mm() method.

And that comes from here in net/ethtool/mm.c:

149 const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1] = {
150 » [ETHTOOL_A_MM_HEADER]» » = NLA_POLICY_NESTED(ethnl_header_policy),
151 » [ETHTOOL_A_MM_VERIFY_ENABLED]» = NLA_POLICY_MAX(NLA_U8, 1),
152 » [ETHTOOL_A_MM_VERIFY_TIME]» = NLA_POLICY_RANGE(NLA_U32, 1, 128), // <---- here
153 » [ETHTOOL_A_MM_TX_ENABLED]» = NLA_POLICY_MAX(NLA_U8, 1),
154 » [ETHTOOL_A_MM_PMAC_ENABLED]» = NLA_POLICY_MAX(NLA_U8, 1),
155 » [ETHTOOL_A_MM_TX_MIN_FRAG_SIZE]»= NLA_POLICY_RANGE(NLA_U32, 60, 252),
156 };

You are reporting in .get_mm() a maximum verify time which is larger
than the core ethtool is willing to accept in a further .set_mm() call.
And openlldp will try to max out on the verify time. Hence the -ERANGE.

The range I chose for the policy comes from 802.3-2018 clause 30.14.1.6,
which says that the aMACMergeVerifyTime variable has a range between 1
and 128 ms inclusive.