Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2522415lqt; Mon, 22 Apr 2024 13:11:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVrCt6sQxWny0hK1KcegEZJRqWJdOTS/eVdqtETLZ6iYtwC+bq3w7lki2c6xZ5hc+zZ6gNro2hxm5Ek10R7hhDrIpWCyzT/zybSgDTVbg== X-Google-Smtp-Source: AGHT+IHx9DkbClbleZSZnGiPvxUry/zLVAzNzhySzrSKS+DI1UmZFX7OXUN6A76hWA+J18cr52U6 X-Received: by 2002:a05:6870:890a:b0:235:453b:be89 with SMTP id i10-20020a056870890a00b00235453bbe89mr15817767oao.44.1713816675177; Mon, 22 Apr 2024 13:11:15 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bs15-20020ac86f0f000000b00439da178278si1447051qtb.741.2024.04.22.13.11.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 13:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=u8DUaG7l; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-153985-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153985-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C82611C2110E for ; Mon, 22 Apr 2024 20:11:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE254155722; Mon, 22 Apr 2024 20:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u8DUaG7l" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB2EE15532F; Mon, 22 Apr 2024 20:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713816663; cv=none; b=lHRUhfJHVpOnmDruaC+zHN5f64NpTtzOvokSVALsindgmzwAmG95+m4BZZd88HzwCAPTPtFTyjlsDqOFiX5qqQvDWvUCwYFg4IjYJsmUoKaGkUI5mf6T0AMjor/yWJsKwW6u1u8YQAyPPKjk2te+qbo/z3L/3Uf7w1ofSS5el/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713816663; c=relaxed/simple; bh=8OXJv3D3XB9FIg16Ygxe6dGNkOlCc0SqV2Syf7zCGNw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l16S0gIREC4XHH53I1uTted6UXY/N54IxjuoV6LBPKeqWT84oDSw9klmtQDyCbJwGWH/gblACf17Pl9Gm37oZ5R2wpqIzT0iBDFzJGR1RSz/xdA3JL0u+MtZKT/pKkKQUvdGIV2tpPCRjB8PcfpCtwgtJSVX7U0jIFXhVj8yBNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u8DUaG7l; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0279DC116B1; Mon, 22 Apr 2024 20:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713816663; bh=8OXJv3D3XB9FIg16Ygxe6dGNkOlCc0SqV2Syf7zCGNw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u8DUaG7l8cWyh+/TFEZenyVAA06XGzbUh+z4QnSZy/SyPW5buJ/voty+9FGtneeKy oat9XU1D4hCku43EV76z1zlYbnKkvV2RRdLhH4+07d2JN6jwQVBH1ye0hxnOtnmI8N FvOl9zJX+AOVDQ6IAyTmRp4tuvYDY8Fz/9Imw9qoBDzJZhlIkBypeUuB910of2od/p OcZSRna5KKmpXistUZzmtTsJ6WY3JIgZXl42fhqqHArdu2Uv+aiIJll7fDZSqTk+mu eVLEeoBOXQ9CZF0zme8afvDh18EaEsahon1VcjzPND/52FRf6ir7kza0MiZ7IOfw+e Ti12kNzspTF4Q== Date: Mon, 22 Apr 2024 21:10:55 +0100 From: Simon Horman To: Kory Maincent Cc: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Radu Pirea , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Willem de Bruijn , Jonathan Corbet , Horatiu Vultur , UNGLinuxDriver@microchip.com, Vladimir Oltean , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maxime Chevallier , Rahul Rameshbabu Subject: Re: [PATCH net-next v11 12/13] net: ethtool: tsinfo: Add support for hwtstamp provider and get/set hwtstamp config Message-ID: <20240422201055.GG42092@kernel.org> References: <20240422-feature_ptp_netnext-v11-0-f14441f2a1d8@bootlin.com> <20240422-feature_ptp_netnext-v11-12-f14441f2a1d8@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240422-feature_ptp_netnext-v11-12-f14441f2a1d8@bootlin.com> On Mon, Apr 22, 2024 at 02:50:27PM +0200, Kory Maincent wrote: > Enhance 'get' command to retrieve tsinfo of hwtstamp providers within a > network topology and read current hwtstamp configuration. > > Introduce support for ETHTOOL_MSG_TSINFO_SET ethtool netlink socket to > configure hwtstamp of a PHC provider. Note that simultaneous hwtstamp > isn't supported; configuring a new one disables the previous setting. > > Also, add support for a specific dump command to retrieve all hwtstamp > providers within the network topology, with added functionality for > filtered dump to target a single interface. > > Signed-off-by: Kory Maincent Hi Kory, Some minor feedback from my side. > diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h > index 23b43f59fcfb..f901394507b3 100644 > --- a/include/linux/ptp_clock_kernel.h > +++ b/include/linux/ptp_clock_kernel.h > @@ -426,6 +426,43 @@ struct ptp_clock *ptp_clock_get_by_index(struct device *dev, int index); > > void ptp_clock_put(struct device *dev, struct ptp_clock *ptp); > > +/** > + * netdev_ptp_clock_find() - obtain the next PTP clock in the netdev > + * topology > + * > + * @dev: Pointer of the net device > + * @indexp: Pointer of ptp clock index start point > + */ Recently -Wall was added to the kernel CI ./scripts/kernel-doc -none test, which means that Kernel docs are now expected to document return values. It would be nice to add them for new code. > + > +struct ptp_clock *netdev_ptp_clock_find(struct net_device *dev, > + unsigned long *indexp); .. > diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c .. > -const struct nla_policy ethnl_tsinfo_get_policy[] = { > +const struct nla_policy > +ethnl_tsinfo_hwtstamp_provider_policy[ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER_MAX + 1] = { ethnl_tsinfo_hwtstamp_provider_policy seems to only be used in this file, so it should be static. > + [ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER_INDEX] = > + NLA_POLICY_MIN(NLA_S32, 0), > + [ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER_QUALIFIER] = > + NLA_POLICY_MAX(NLA_U32, HWTSTAMP_PROVIDER_QUALIFIER_CNT - 1) > +}; > + > +const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_MAX + 1] = { > [ETHTOOL_A_TSINFO_HEADER] = > NLA_POLICY_NESTED(ethnl_header_policy_stats), > + [ETHTOOL_A_TSINFO_GHWTSTAMP] = > + NLA_POLICY_MAX(NLA_U8, 1), > + [ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER_NEST] = > + NLA_POLICY_NESTED(ethnl_tsinfo_hwtstamp_provider_policy), > }; .. > +static int ethnl_tsinfo_dump_one_ptp(struct sk_buff *skb, struct net_device *dev, > + struct netlink_callback *cb, > + struct ptp_clock *ptp) > +{ > + struct ethnl_tsinfo_dump_ctx *ctx = (void *)cb->ctx; > + struct tsinfo_reply_data *reply_data; > + struct tsinfo_req_info *req_info; > + void *ehdr; > + int ret; > + > + reply_data = ctx->reply_data; > + req_info = ctx->req_info; > + req_info->hwtst.index = ptp_clock_index(ptp); > + > + for (; ctx->pos_phcqualifier < HWTSTAMP_PROVIDER_QUALIFIER_CNT; > + ctx->pos_phcqualifier++) { > + if (!netdev_support_hwtstamp_qualifier(dev, > + ctx->pos_phcqualifier)) > + continue; > + > + ehdr = ethnl_dump_put(skb, cb, > + ETHTOOL_MSG_TSINFO_GET_REPLY); > + if (!ehdr) > + return -EMSGSIZE; > + > + memset(reply_data, 0, sizeof(*reply_data)); > + reply_data->base.dev = dev; > + req_info->hwtst.qualifier = ctx->pos_phcqualifier; > + ret = tsinfo_prepare_data(&req_info->base, > + &reply_data->base, > + genl_info_dump(cb)); > + if (ret < 0) > + break; > + > + ret = ethnl_fill_reply_header(skb, dev, > + ETHTOOL_A_TSINFO_HEADER); > + if (ret < 0) > + break; > + > + ret = tsinfo_fill_reply(skb, &req_info->base, > + &reply_data->base); > + if (ret < 0) > + break; > + } > + > + reply_data->base.dev = NULL; > + if (ret < 0) > + genlmsg_cancel(skb, ehdr); > + else > + genlmsg_end(skb, ehdr); I suppose it can't occur, but if the for loop iterates zero times, then ret and ehdr will be uninitialised here. Flagged by Smatch. > + return ret; > +} ..