Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp732569rwl; Thu, 5 Jan 2023 03:54:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXsI2B8WRuszNsZdHknqAmzyIrHGQrzSKBP48We7i28v7b/tW8AHKIxWnVFs/Xm6CR+PdH4m X-Received: by 2002:a05:6a20:7d9a:b0:af:9539:a2c0 with SMTP id v26-20020a056a207d9a00b000af9539a2c0mr77993943pzj.26.1672919669244; Thu, 05 Jan 2023 03:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672919669; cv=none; d=google.com; s=arc-20160816; b=Hosmo0KBmUy5qJvJARKUbUW0p+fULHx9zoyNG8YDRjnw2OfeALVXmV+Yzzd5UY/utp VXTIyVyQNaqHB85pIxFxKu4y6z4tDSH3JkRnYtMbwUnPu6q8C1Rs10WZ8Pke7U79d09q T+BZKA45ZftH/CWp/hwE/Iuftzw9Vm5LhQgKbhvbXmA/hBgk0a9c1HTZjo0VLmnUZ0Bf KCJRH03X3zQ0mFD+xtMco0IKp0xshY+RNO9AlObQ/YfxXhi1sQfxocSq6TAsETZRZ4DH We4RsPWtNyJ/OSTtpcv0S/wMjLlozJjoLvUgbeo/LRBIkrp2MNQy/RJUYWqDhI5RjP9I G2Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1LL4PmBB1pvqQG5tOhMu+jjeyKAtVmuz5IqwO930qQU=; b=Qg/uztLO7cbx2QwnJ5+rruqIZ8jOHb4dDufCH0/nyYJ4Uv2OxstTLXd+0zNS1tH87F cB5SbqJm1jsYmM3uITHYvShat5hrkH7KwsxjJmVpOV+gZGLXhFoIhHph/X6N2g8Zrp6C yRHAuDreQ7XvLmT6+tzIiuoAc2KB1RtSp9knCwWVK0kfk6v2YBpGgWj/4Vk1CBm3hK8W pS+3J+yNDiWClNrFvkRpOI1N9i7afG5nAme7+sGiFFiTN0YIIEokw5LwbvB7m/0D2AYB hEh4UN/mgQOr9VcJSxjNJcB0EN+ZlMcshDX7BGG8A+UFaRiO3+4KYiaX/UEuj4kzSUYL QJnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QBsTEvPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020a170903110500b001868ef35f09si40920861plh.258.2023.01.05.03.54.19; Thu, 05 Jan 2023 03:54:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QBsTEvPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbjAEKrb (ORCPT + 55 others); Thu, 5 Jan 2023 05:47:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbjAEKrR (ORCPT ); Thu, 5 Jan 2023 05:47:17 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D07E950054; Thu, 5 Jan 2023 02:47:16 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id jo4so89170002ejb.7; Thu, 05 Jan 2023 02:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1LL4PmBB1pvqQG5tOhMu+jjeyKAtVmuz5IqwO930qQU=; b=QBsTEvPO+m09NOsi5gTFe7aqT7oPRZbnlKzfg/LIrZtl+r3bBd1XM/AVhNXEMXBLIx JuA1o/Xe6J8KPFdXWKpjZ1eRfVqh6ld0S/BhRA8OqBG1NfGbj/Hr86Vrvfbh2UBF6YDJ U3oznAWuhyYmTr3SPTqUmhm2YwLJ5cEAtKExeLyuzaG2Rj/CSaF6paZMRR2rWxJu3Zko UYR96R+O4itXF4HVwhVLmEYB53ZF5QVvxtb2dtx/4JFYXLzBOQ7yJqFIuCEgRZr73prS vW9KAfzkGtqBHJ3MIxHxRdn+IwNbL26a82gRTA1LfnsXFYfa558VLoREhsQ1+Cfc9nFt 8zSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1LL4PmBB1pvqQG5tOhMu+jjeyKAtVmuz5IqwO930qQU=; b=lAI0qraa4Ftx1TVn3bW+YAQJgZ4s5gLp7zJwXLaN8+4p7CjsVVOO1X84+4kMUCc6fo eNCnPedGlmNBuxYL05HyUIISVpNLal5L3qse7miOMrRB41oCW2iVFzgg+1sacfH3uxux Pzi4/2jifcDPTkuGAo6iVGpkSisNdnsRM4IJGdUe0rQYHSCU9/PVgZdQ+Z5OPDCjKwf9 PqhST2pCZiASL/PYXsdHlpR7Aw7Obdi6UKChLR2sLyNXxrP/CHlNnXGZtbBQeBtGvvGo rSx5WcX30/kPNw8piIzrb+eAIeBMymSfZNG3uc42y812iMcAIa1rkIOhq6yFKx1pZKhc g51Q== X-Gm-Message-State: AFqh2krjbWnd+ynhuTEzgMyajUCCKls4lcRybQMC07YfoGMfrqHQXMQZ 4C8nPE2IO+kM/DNSPPKA7PEHMhSFL8Bpx8+0 X-Received: by 2002:a17:907:6d0b:b0:83f:1f64:c1e with SMTP id sa11-20020a1709076d0b00b0083f1f640c1emr48651653ejc.47.1672915635162; Thu, 05 Jan 2023 02:47:15 -0800 (PST) Received: from gvm01 (net-5-89-66-224.cust.vodafonedsl.it. [5.89.66.224]) by smtp.gmail.com with ESMTPSA id u18-20020a1709061db200b007c073be0127sm16050618ejh.202.2023.01.05.02.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 02:47:14 -0800 (PST) Date: Thu, 5 Jan 2023 11:47:20 +0100 From: Piergiorgio Beruto To: Leon Romanovsky Cc: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: Re: [PATCH net-next 1/5] net/ethtool: add netlink interface for the PLCA RS Message-ID: References: <76d0a77273e4b4e7c1d22a897c4af9109a8edc51.1672840325.git.piergiorgio.beruto@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Leon for your review. Please, see my comments below. On Thu, Jan 05, 2023 at 10:55:14AM +0200, Leon Romanovsky wrote: > On Wed, Jan 04, 2023 at 03:05:44PM +0100, Piergiorgio Beruto wrote: > > Add support for configuring the PLCA Reconciliation Sublayer on > > multi-drop PHYs that support IEEE802.3cg-2019 Clause 148 (e.g., > > 10BASE-T1S). This patch adds the appropriate netlink interface > > to ethtool. > > > > Signed-off-by: Piergiorgio Beruto > > --- > > Documentation/networking/ethtool-netlink.rst | 138 ++++++++++ > > MAINTAINERS | 6 + > > include/linux/ethtool.h | 12 + > > include/linux/phy.h | 57 ++++ > > include/uapi/linux/ethtool_netlink.h | 25 ++ > > net/ethtool/Makefile | 2 +- > > net/ethtool/netlink.c | 29 ++ > > net/ethtool/netlink.h | 6 + > > net/ethtool/plca.c | 276 +++++++++++++++++++ > > 9 files changed, 550 insertions(+), 1 deletion(-) > > create mode 100644 net/ethtool/plca.c > > <...> > > > --- /dev/null > > +++ b/net/ethtool/plca.c > > @@ -0,0 +1,276 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > + > > +#include > > +#include > > + > > +#include "netlink.h" > > +#include "common.h" > > + > > +struct plca_req_info { > > + struct ethnl_req_info base; > > +}; > > + > > +struct plca_reply_data { > > + struct ethnl_reply_data base; > > + struct phy_plca_cfg plca_cfg; > > + struct phy_plca_status plca_st; > > +}; > > + > > +// Helpers ------------------------------------------------------------------ // > > + > > +#define PLCA_REPDATA(__reply_base) \ > > + container_of(__reply_base, struct plca_reply_data, base) > > + > > +static inline void plca_update_sint(int *dst, const struct nlattr *attr, > > + bool *mod) > > No inline function in *.c files. Fixed, thanks. > > > +{ > > + if (attr) { > > + *dst = nla_get_u32(attr); > > + *mod = true; > > + } > > Success oriented approach, please > if (!attr) > return; Fixed. > > > +} > > + > > +// PLCA get configuration message ------------------------------------------- // > > + > > +const struct nla_policy ethnl_plca_get_cfg_policy[] = { > > + [ETHTOOL_A_PLCA_HEADER] = > > + NLA_POLICY_NESTED(ethnl_header_policy), > > +}; > > + > > +static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base, > > + struct ethnl_reply_data *reply_base, > > + struct genl_info *info) > > +{ > > + struct plca_reply_data *data = PLCA_REPDATA(reply_base); > > + struct net_device *dev = reply_base->dev; > > + const struct ethtool_phy_ops *ops; > > + int ret; > > + > > + // check that the PHY device is available and connected > > + if (!dev->phydev) { > > + ret = -EOPNOTSUPP; > > + goto out; > > + } > > + > > + // note: rtnl_lock is held already by ethnl_default_doit > > + ops = ethtool_phy_ops; > > + if (!ops || !ops->get_plca_cfg) { > > + ret = -EOPNOTSUPP; > > + goto out; > > + } > > + > > + ret = ethnl_ops_begin(dev); > > + if (ret < 0) > > + goto out; > > I see that many places in the code used this ret > 0 check, but it looks > like the right check is if (ret). Thanks. I've fixed those, although I copied this code from similar files (like cable test). Maybe we should check these out as well? > > Thanks Thanks! Piergiorgio