[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 5 May 2020 12:50:43 +0200
From: Michal Kubecek <mkubecek@...e.cz>
To: Andrew Lunn <andrew@...n.ch>
Cc: David Miller <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Chris Healy <cphealy@...il.com>, michael@...le.cc
Subject: Re: [PATCH net-next v2 07/10] net: ethtool: Add helpers for
reporting test results
On Tue, May 05, 2020 at 02:18:18AM +0200, Andrew Lunn wrote:
> The PHY drivers can use these helpers for reporting the results. The
> results get translated into netlink attributes which are added to the
> pre-allocated skbuf.
>
> Signed-off-by: Andrew Lunn <andrew@...n.ch>
> ---
[...]
> diff --git a/net/ethtool/cabletest.c b/net/ethtool/cabletest.c
> index 4c888db33ef0..f500454a54eb 100644
> --- a/net/ethtool/cabletest.c
> +++ b/net/ethtool/cabletest.c
> @@ -114,3 +114,50 @@ void ethnl_cable_test_finished(struct phy_device *phydev)
> ethnl_multicast(phydev->skb, phydev->attached_dev);
> }
> EXPORT_SYMBOL_GPL(ethnl_cable_test_finished);
> +
> +int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u16 result)
Is there a reason to use u16 for result when the attribute is NLA_U8?
> +{
> + struct nlattr *nest;
> + int ret = -EMSGSIZE;
> +
> + nest = nla_nest_start(phydev->skb, ETHTOOL_A_CABLE_TEST_NTF_RESULT);
> + if (!nest)
> + return -EMSGSIZE;
> +
> + if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_RESULT_PAIR, pair))
> + goto err;
> + if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_RESULT_CODE, result))
> + goto err;
> +
> + nla_nest_end(phydev->skb, nest);
> + return 0;
> +
> +err:
> + nla_nest_cancel(phydev->skb, nest);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(ethnl_cable_test_result);
> +
> +int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm)
> +{
> + struct nlattr *nest;
> + int ret = -EMSGSIZE;
> +
> + nest = nla_nest_start(phydev->skb,
> + ETHTOOL_A_CABLE_TEST_NTF_FAULT_LENGTH);
> + if (!nest)
> + return -EMSGSIZE;
> +
> + if (nla_put_u8(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR, pair))
> + goto err;
> + if (nla_put_u16(phydev->skb, ETHTOOL_A_CABLE_FAULT_LENGTH_CM, cm))
> + goto err;
This should be nla_put_u32().
Michal
> +
> + nla_nest_end(phydev->skb, nest);
> + return 0;
> +
> +err:
> + nla_nest_cancel(phydev->skb, nest);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(ethnl_cable_test_fault_length);
> --
> 2.26.2
>
Powered by blists - more mailing lists