Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp564138rwl; Thu, 5 Jan 2023 01:04:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXJfBk+f6hrpuM4XgXunQg6oh//IhypEFeCMo7nT2Wtm+iZeWgGc/Z3lRUPh6XbfMMt9vS X-Received: by 2002:a05:6402:e83:b0:463:c4f5:ad1f with SMTP id h3-20020a0564020e8300b00463c4f5ad1fmr47599902eda.11.1672909488649; Thu, 05 Jan 2023 01:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672909488; cv=none; d=google.com; s=arc-20160816; b=ye+/U6e2PcyTq9GRRTXHELUKJsdkJAUeTCtu0kkGDciO666Fl3ZNh2qXhjYTzmpODN UZfpMUv8pqlWSpkr2xl8sINGGusJKIVH2AorJOCKEY4Nym8aeCCHFDoEcUWgJpm3VxJ1 4z5oTOeA1jNecazGrMFajN8Du2Jle185c87gvVM28LGF49KPjONDF6mFk8iG6eCHgZxE Ktu0NSQbL4zF3CwyEGPRQlqYhebiMovd/xWHm91i1zq5F2a/NQmRflEnVE7PSIm1zz/7 gbziZ9xA/7YrNSmb3Xh8OZeIR6N3WdET0iNFuynNPkfK+3DM6UAJKBFWwuBG1N3YPqwd ECqQ== 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=xwXlYS3iDDyPrGpOA9qpfaKBnhlwwyRvVrGsQ0TmDZg=; b=dMOGLuIk5lUSKTM6thA/ZeFmKvvg0/Hk2kzzrwOwSUT/wrNnAgg7rz4MrZHX46CDoD 5byRCXi75zl/ruvbasIti1AqnKpdJ6/4BxbL1Y3i7G6Empnxw/DRnJdvVnW5TWoG0/ay y6/C67rC/K6gBZx+zJzal593bdYmz75Ei5g+bN/3pQSXk9DhMgeufCoMqohCCMlYJ6jj oQTBGrhHgSUF6yxsme0qGU+DJADlm8nlwjs/wiq5rFW+Kdz0QItj7Nwkgy0N1UFs7m0s BUeJJWc828Jf09FVmAC7w8EWgnA0sy9O4qLRbJW+hAN4hx+XmuRSMieE4v9H67dozoG/ +jVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TchCyc1K; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz18-20020a0564021d5200b0048ef339fc63si5572363edb.294.2023.01.05.01.04.35; Thu, 05 Jan 2023 01:04:48 -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=@kernel.org header.s=k20201202 header.b=TchCyc1K; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231429AbjAEIza (ORCPT + 55 others); Thu, 5 Jan 2023 03:55:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbjAEIzW (ORCPT ); Thu, 5 Jan 2023 03:55:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 844DC395EB; Thu, 5 Jan 2023 00:55:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7646561912; Thu, 5 Jan 2023 08:55:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5001CC433EF; Thu, 5 Jan 2023 08:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672908918; bh=qFhnm17Gb688TaduxHaHJISkIUd0KIcIGpXe2ATD8ys=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TchCyc1KrjVfN4RqhAaAo5PE2RtHafbaWMP0Abcfht9ZvhERBLFydm5aCn8ssDfCz 8hmKxxSl7Pci66dNfgXNjg5ATm1Ro1JB1l/ava/Vr10YESaCbMHiioF4vBuvYBt4QG w2417kIjV3BkmX2h6lSqeXd8KbPwm5vk6ZFvkxXlAg0p4CchTw0kY8v2NiMdsBCbEq DI99lqwn+SXzLr8+ld+AVkeLnvfixyAQt3nQmx3t6aCVhggZHhXiL3LCJ4QgFgj68b 58mfzOxBaJG9rCPLydsJ5s8/6IQihT+snwetyF+fR1n6SFmd0UNxV1oG32pB108q+J HOuGuBiBRLBTg== Date: Thu, 5 Jan 2023 10:55:14 +0200 From: Leon Romanovsky To: Piergiorgio Beruto 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: <76d0a77273e4b4e7c1d22a897c4af9109a8edc51.1672840325.git.piergiorgio.beruto@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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. > +{ > + if (attr) { > + *dst = nla_get_u32(attr); > + *mod = true; > + } Success oriented approach, please if (!attr) return; > +} > + > +// 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