All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Huazhong Tan <tanhuazhong@huawei.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
	<huangdaode@huawei.com>, <linuxarm@huawei.com>,
	<dledford@redhat.com>, <jgg@ziepe.ca>, <netanel@amazon.com>,
	<akiyano@amazon.com>, <thomas.lendacky@amd.com>,
	<irusskikh@marvell.com>, <michael.chan@broadcom.com>,
	<edwin.peer@broadcom.com>, <rohitm@chelsio.com>,
	<jesse.brandeburg@intel.com>, <jacob.e.keller@intel.com>,
	<ioana.ciornei@nxp.com>, <vladimir.oltean@nxp.com>,
	<sgoutham@marvell.com>, <sbhatta@marvell.com>,
	<saeedm@nvidia.com>, <ecree.xilinx@gmail.com>,
	<grygorii.strashko@ti.com>, <merez@codeaurora.org>,
	<kvalo@codeaurora.org>, <linux-wireless@vger.kernel.org>
Subject: Re: [RFC net-next 1/4] ethtool: extend coalesce API
Date: Wed, 26 May 2021 16:56:33 -0700	[thread overview]
Message-ID: <20210526165633.3f7982c9@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <1622021262-8881-2-git-send-email-tanhuazhong@huawei.com>

On Wed, 26 May 2021 17:27:39 +0800 Huazhong Tan wrote:
> @@ -606,8 +611,12 @@ struct ethtool_ops {
>  			      struct ethtool_eeprom *, u8 *);
>  	int	(*set_eeprom)(struct net_device *,
>  			      struct ethtool_eeprom *, u8 *);
> -	int	(*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
> -	int	(*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
> +	int	(*get_coalesce)(struct net_device *,
> +				struct netlink_ext_ack *,

ext_ack is commonly the last argument AFAIR.

> +				struct kernel_ethtool_coalesce *);

Seeing all the driver changes I can't say I'm a huge fan of 
the encapsulation. We end up with a local variable for the "base"
structure, e.g.:

 static int wil_ethtoolops_set_coalesce(struct net_device *ndev,
-				       struct ethtool_coalesce *cp)
+				       struct netlink_ext_ack *extack,
+				       struct kernel_ethtool_coalesce *cp)
 {
+	struct ethtool_coalesce *coal_base = &cp->base;
 	struct wil6210_priv *wil = ndev_to_wil(ndev);
 	struct wireless_dev *wdev = ndev->ieee80211_ptr;

so why not leave the base alone and pass the new members in a separate
structure?

> +	int	(*set_coalesce)(struct net_device *,
> +				struct netlink_ext_ack *,
> +				struct kernel_ethtool_coalesce *);
>  	void	(*get_ringparam)(struct net_device *,
>  				 struct ethtool_ringparam *);
>  	int	(*set_ringparam)(struct net_device *,

>  static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
>  						   void __user *useraddr)
>  {
> -	struct ethtool_coalesce coalesce;
> +	struct kernel_ethtool_coalesce coalesce;
>  	int ret;
>  
>  	if (!dev->ethtool_ops->set_coalesce)
>  		return -EOPNOTSUPP;
>  
> -	if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
> +	if (copy_from_user(&coalesce.base, useraddr, sizeof(coalesce.base)))
>  		return -EFAULT;
>  
>  	if (!ethtool_set_coalesce_supported(dev, &coalesce))
>  		return -EOPNOTSUPP;
>  
> -	ret = dev->ethtool_ops->set_coalesce(dev, &coalesce);
> +	ret = dev->ethtool_ops->set_coalesce(dev, NULL, &coalesce);
>  	if (!ret)
>  		ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF, NULL);
>  	return ret;

Should IOCTL overwrite the settings it doesn't know about with 0 
or preserve the existing values?

  reply	other threads:[~2021-05-26 23:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  9:27 [RFC net-next 0/4] ethtool: extend coalesce uAPI Huazhong Tan
2021-05-26  9:27 ` [RFC net-next 1/4] ethtool: extend coalesce API Huazhong Tan
2021-05-26 23:56   ` Jakub Kicinski [this message]
2021-05-27  1:39     ` Huazhong Tan
2021-05-26  9:27 ` [RFC net-next 2/4] ethtool: extend coalesce setting uAPI with CQE mode Huazhong Tan
2021-05-27  0:00   ` Jakub Kicinski
2021-05-27  2:00     ` Huazhong Tan
2021-05-27 17:37       ` Jakub Kicinski
2021-05-26  9:27 ` [RFC net-next 3/4] net: hns3: add support for EQE/CQE mode configuration Huazhong Tan
2021-05-26  9:27 ` [RFC net-next 4/4] net: hns3: add ethtool support for CQE/EQE " Huazhong Tan

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=20210526165633.3f7982c9@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=akiyano@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=ecree.xilinx@gmail.com \
    --cc=edwin.peer@broadcom.com \
    --cc=grygorii.strashko@ti.com \
    --cc=huangdaode@huawei.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=irusskikh@marvell.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jgg@ziepe.ca \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=merez@codeaurora.org \
    --cc=michael.chan@broadcom.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=rohitm@chelsio.com \
    --cc=saeedm@nvidia.com \
    --cc=salil.mehta@huawei.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=tanhuazhong@huawei.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=yisen.zhuang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.