netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Oleksij Rempel <o.rempel@pengutronix.de>
Subject: Re: [PATCH net-next 1/5] net/ethtool: add netlink interface for the PLCA RS
Date: Thu, 5 Jan 2023 11:47:20 +0100	[thread overview]
Message-ID: <Y7aquABWDDmPeRAV@gvm01> (raw)
In-Reply-To: <Y7aQcgR4C9Lg/+yK@unreal>

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 <piergiorgio.beruto@gmail.com>
> > ---
> >  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 <linux/phy.h>
> > +#include <linux/ethtool_netlink.h>
> > +
> > +#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

  reply	other threads:[~2023-01-05 10:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 14:05 [PATCH net-next 0/5] add PLCA RS support and onsemi NCN26000 Piergiorgio Beruto
2023-01-04 14:05 ` [PATCH net-next 1/5] net/ethtool: add netlink interface for the PLCA RS Piergiorgio Beruto
2023-01-05  8:55   ` Leon Romanovsky
2023-01-05 10:47     ` Piergiorgio Beruto [this message]
2023-01-05 11:01       ` Leon Romanovsky
2023-01-04 14:06 ` [PATCH net-next 2/5] drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY Piergiorgio Beruto
2023-01-04 14:06 ` [PATCH net-next 3/5] drivers/net/phy: add connection between ethtool and phylib for PLCA Piergiorgio Beruto
2023-01-05  9:03   ` Leon Romanovsky
2023-01-05 10:49     ` Piergiorgio Beruto
2023-01-05 10:59       ` Leon Romanovsky
2023-01-04 14:06 ` [PATCH net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration Piergiorgio Beruto
2023-01-04 14:07 ` [PATCH net-next 5/5] drivers/net/phy: add driver for the onsemi NCN26000 10BASE-T1S PHY Piergiorgio Beruto
2023-01-05  9:05   ` Leon Romanovsky
2023-01-05 10:49     ` Piergiorgio Beruto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7aquABWDDmPeRAV@gvm01 \
    --to=piergiorgio.beruto@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).