Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D22F2C47247 for ; Tue, 5 May 2020 10:50:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB2E7206A5 for ; Tue, 5 May 2020 10:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728711AbgEEKuq (ORCPT ); Tue, 5 May 2020 06:50:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:50104 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725766AbgEEKup (ORCPT ); Tue, 5 May 2020 06:50:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 541A0ACF2; Tue, 5 May 2020 10:50:46 +0000 (UTC) Received: by lion.mk-sys.cz (Postfix, from userid 1000) id 9F35E602B9; Tue, 5 May 2020 12:50:43 +0200 (CEST) Date: Tue, 5 May 2020 12:50:43 +0200 From: Michal Kubecek To: Andrew Lunn Cc: David Miller , netdev , Florian Fainelli , Heiner Kallweit , Chris Healy , michael@walle.cc Subject: Re: [PATCH net-next v2 07/10] net: ethtool: Add helpers for reporting test results Message-ID: <20200505105043.GK8237@lion.mk-sys.cz> References: <20200505001821.208534-1-andrew@lunn.ch> <20200505001821.208534-8-andrew@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505001821.208534-8-andrew@lunn.ch> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 > --- [...] > 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 >