All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC net-next 0/2] add ethtool ops support for fresh device features
@ 2022-03-15  3:21 Jie Wang
  2022-03-15  3:21 ` [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get " Jie Wang
  2022-03-15  3:21 ` [RFC net-next 2/2] net: hns3: add ethtool set/get device features support for hns3 driver Jie Wang
  0 siblings, 2 replies; 12+ messages in thread
From: Jie Wang @ 2022-03-15  3:21 UTC (permalink / raw)
  To: mkubecek, davem, kuba, wangjie125
  Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng,
	linyunsheng, tanhuazhong, salil.mehta, chenhao288

As Jakub Kicinski comment in patch:
https://lore.kernel.org/netdev/20220125195508.585b0c40@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net/
, there are no ethtool command similar to ethtool -k for features contained
entirely to the driver. Fresh device features such as tx push need this
kind of command to set/get feature attributes.

So this patch adds new ethtool command support for new features belongs to 
the driver. The second patch adds hns3 support for this new command to 
configure tx push feature. This command can be easily reused by other 
features.

Comments are welcomed and i'm still testing this command.

Jie Wang (2):
  net: ethtool: add ethtool ability to set/get fresh device features
  net: hns3: add ethtool set/get device features support for hns3 driver

 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  1 +
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 77 +++++++++++++++++++
 include/linux/ethtool.h                       |  4 +
 include/uapi/linux/ethtool.h                  | 27 +++++++
 net/ethtool/ioctl.c                           | 43 +++++++++++
 5 files changed, 152 insertions(+)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15  3:21 [RFC net-next 0/2] add ethtool ops support for fresh device features Jie Wang
@ 2022-03-15  3:21 ` Jie Wang
  2022-03-15 19:15   ` Jakub Kicinski
  2022-03-15 19:18   ` Michal Kubecek
  2022-03-15  3:21 ` [RFC net-next 2/2] net: hns3: add ethtool set/get device features support for hns3 driver Jie Wang
  1 sibling, 2 replies; 12+ messages in thread
From: Jie Wang @ 2022-03-15  3:21 UTC (permalink / raw)
  To: mkubecek, davem, kuba, wangjie125
  Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng,
	linyunsheng, tanhuazhong, salil.mehta, chenhao288

As tx push is a standard feature for NICs, but netdev_feature which is
controlled by ethtool -K has reached the maximum specification.

so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
drivers. The message processing functions and function hooks in struct
ethtool_ops are also added.

set-devfeatures/show-devfeatures option(s) are designed to provide set
and get function.
set cmd:
root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
get cmd:
root@wj: ethtool --show-devfeatures eth4

Signed-off-by: Jie Wang <wangjie125@huawei.com>
---
 include/linux/ethtool.h      |  4 ++++
 include/uapi/linux/ethtool.h | 27 ++++++++++++++++++++++
 net/ethtool/ioctl.c          | 43 ++++++++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 11efc45de66a..1a34bb074720 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -750,6 +750,10 @@ struct ethtool_ops {
 	int	(*set_module_power_mode)(struct net_device *dev,
 					 const struct ethtool_module_power_mode_params *params,
 					 struct netlink_ext_ack *extack);
+	int	(*get_devfeatures)(struct net_device *dev,
+				   struct ethtool_dev_features *dev_feat);
+	int	(*set_devfeatures)(struct net_device *dev,
+				   struct ethtool_dev_features *dev_feat);
 };
 
 int ethtool_check_ops(const struct ethtool_ops *ops);
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 7bc4b8def12c..319d7b2c6acb 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1490,6 +1490,31 @@ enum ethtool_fec_config_bits {
 #define ETHTOOL_FEC_BASER		(1 << ETHTOOL_FEC_BASER_BIT)
 #define ETHTOOL_FEC_LLRS		(1 << ETHTOOL_FEC_LLRS_BIT)
 
+/**
+ * struct ethtool_dev_features - device feature configurations
+ * @cmd: Command number = %ETHTOOL_GDEVFEAT or %ETHTOOL_SDEVFEAT
+ * @type: feature configuration type.
+ * @data: feature configuration value.
+ */
+struct ethtool_dev_features {
+	__u32 cmd;
+	__u32 type;
+	__u32 data;
+};
+
+/**
+ * enum ethtool_dev_features_type - flags definition of ethtool_dev_features
+ * @ETHTOOL_DEV_TX_PUSH: nic tx push mode set bit.
+ */
+enum ethtool_dev_features_type {
+	ETHTOOL_DEV_TX_PUSH,
+	/*
+	 * Add your fresh feature type above and remember to update
+	 * feat_line[] in ethtool.c
+	 */
+	ETHTOOL_DEV_FEATURE_COUNT,
+};
+
 /* CMDs currently supported */
 #define ETHTOOL_GSET		0x00000001 /* DEPRECATED, Get settings.
 					    * Please use ETHTOOL_GLINKSETTINGS
@@ -1584,6 +1609,8 @@ enum ethtool_fec_config_bits {
 #define ETHTOOL_PHY_STUNABLE	0x0000004f /* Set PHY tunable configuration */
 #define ETHTOOL_GFECPARAM	0x00000050 /* Get FEC settings */
 #define ETHTOOL_SFECPARAM	0x00000051 /* Set FEC settings */
+#define ETHTOOL_GDEVFEAT	0x00000052 /* Get device features */
+#define ETHTOOL_SDEVFEAT	0x00000053 /* Set device features */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 326e14ee05db..efac23352eb9 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -2722,6 +2722,42 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
 	return dev->ethtool_ops->set_fecparam(dev, &fecparam);
 }
 
+static int ethtool_get_devfeatures(struct net_device *dev,
+				   void __user *useraddr)
+{
+	struct ethtool_dev_features dev_feat;
+	int ret;
+
+	if (!dev->ethtool_ops->get_devfeatures)
+		return -EOPNOTSUPP;
+
+	if (copy_from_user(&dev_feat, useraddr, sizeof(dev_feat)))
+		return -EFAULT;
+
+	ret = dev->ethtool_ops->get_devfeatures(dev, &dev_feat);
+	if (ret)
+		return ret;
+
+	if (copy_to_user(useraddr, &dev_feat, sizeof(dev_feat)))
+		return -EFAULT;
+
+	return 0;
+}
+
+static int ethtool_set_devfeatures(struct net_device *dev,
+				   void __user *useraddr)
+{
+	struct ethtool_dev_features dev_feat;
+
+	if (!dev->ethtool_ops->set_devfeatures)
+		return -EOPNOTSUPP;
+
+	if (copy_from_user(&dev_feat, useraddr, sizeof(dev_feat)))
+		return -EFAULT;
+
+	return dev->ethtool_ops->set_devfeatures(dev, &dev_feat);
+}
+
 /* The main entry point in this file.  Called from net/core/dev_ioctl.c */
 
 static int
@@ -2781,6 +2817,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
 	case ETHTOOL_PHY_GTUNABLE:
 	case ETHTOOL_GLINKSETTINGS:
 	case ETHTOOL_GFECPARAM:
+	case ETHTOOL_GDEVFEAT:
 		break;
 	default:
 		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
@@ -3008,6 +3045,12 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
 	case ETHTOOL_SFECPARAM:
 		rc = ethtool_set_fecparam(dev, useraddr);
 		break;
+	case ETHTOOL_GDEVFEAT:
+		rc = ethtool_get_devfeatures(dev, useraddr);
+		break;
+	case ETHTOOL_SDEVFEAT:
+		rc = ethtool_set_devfeatures(dev, useraddr);
+		break;
 	default:
 		rc = -EOPNOTSUPP;
 	}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [RFC net-next 2/2] net: hns3: add ethtool set/get device features support for hns3 driver
  2022-03-15  3:21 [RFC net-next 0/2] add ethtool ops support for fresh device features Jie Wang
  2022-03-15  3:21 ` [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get " Jie Wang
@ 2022-03-15  3:21 ` Jie Wang
  1 sibling, 0 replies; 12+ messages in thread
From: Jie Wang @ 2022-03-15  3:21 UTC (permalink / raw)
  To: mkubecek, davem, kuba, wangjie125
  Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng,
	linyunsheng, tanhuazhong, salil.mehta, chenhao288

This patch implements hns3 set_devfeatures/get_devfeatures hooks defined
in struct ethtool_ops.

Signed-off-by: Jie Wang <wangjie125@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  1 +
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 77 +++++++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 9298fbecb31a..9ae5b3318dc4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -817,6 +817,7 @@ struct hnae3_roce_private_info {
 
 enum hnae3_pflag {
 	HNAE3_PFLAG_LIMIT_PROMISC,
+	HNAE3_PFLAG_PUSH_ENABLE,
 	HNAE3_PFLAG_MAX
 };
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index c06c39ece80d..7ad141aed3aa 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1925,6 +1925,79 @@ static int hns3_get_link_ext_state(struct net_device *netdev,
 	return -ENODATA;
 }
 
+static int hns3_set_tx_push(struct net_device *netdev,
+			    struct ethtool_dev_features *dev_feat)
+{
+	struct hns3_nic_priv *priv = netdev_priv(netdev);
+	struct hnae3_handle *h = hns3_get_handle(netdev);
+	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+
+	if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps))
+		return -EOPNOTSUPP;
+
+	if (dev_feat->data)
+		set_bit(HNAE3_PFLAG_PUSH_ENABLE, &priv->state);
+	else
+		clear_bit(HNAE3_PFLAG_PUSH_ENABLE, &priv->state);
+
+	return 0;
+}
+
+static int hns3_set_devfeatures(struct net_device *netdev,
+				struct ethtool_dev_features *dev_feat)
+{
+	struct set_proto {
+		u64 type;
+		int (*set_func)(struct net_device *dev,
+				struct ethtool_dev_features *feat);
+	} set_arr[] = {
+		{ ETHTOOL_DEV_TX_PUSH, hns3_set_tx_push },
+	};
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(set_arr); ++i) {
+		if (set_arr[i].type == dev_feat->type && set_arr[i].set_func)
+			return set_arr[i].set_func(netdev, dev_feat);
+	}
+
+	return -EINVAL;
+}
+
+static int hns3_get_tx_push(struct net_device *netdev,
+			    struct ethtool_dev_features *dev_feat)
+{
+	struct hns3_nic_priv *priv = netdev_priv(netdev);
+	struct hnae3_handle *h = hns3_get_handle(netdev);
+	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+
+	if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps))
+		return -EOPNOTSUPP;
+
+	dev_feat->data = test_bit(HNAE3_PFLAG_PUSH_ENABLE, &priv->state);
+
+	return 0;
+}
+
+static int hns3_get_devfeatures(struct net_device *netdev,
+				struct ethtool_dev_features *dev_feat)
+{
+	struct get_proto {
+		u32 type;
+		int (*get_func)(struct net_device *netdev,
+				struct ethtool_dev_features *feat);
+	} get_arr[] = {
+		{ ETHTOOL_DEV_TX_PUSH, hns3_get_tx_push },
+	};
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(get_arr); ++i) {
+		if (get_arr[i].type == dev_feat->type && get_arr[i].get_func)
+			return get_arr[i].get_func(netdev, dev_feat);
+	}
+
+	return -EINVAL;
+}
+
 static const struct ethtool_ops hns3vf_ethtool_ops = {
 	.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
 	.supported_ring_params = HNS3_ETHTOOL_RING,
@@ -1955,6 +2028,8 @@ static const struct ethtool_ops hns3vf_ethtool_ops = {
 	.get_tunable = hns3_get_tunable,
 	.set_tunable = hns3_set_tunable,
 	.reset = hns3_set_reset,
+	.get_devfeatures = hns3_get_devfeatures,
+	.set_devfeatures = hns3_set_devfeatures,
 };
 
 static const struct ethtool_ops hns3_ethtool_ops = {
@@ -1999,6 +2074,8 @@ static const struct ethtool_ops hns3_ethtool_ops = {
 	.set_tunable = hns3_set_tunable,
 	.reset = hns3_set_reset,
 	.get_link_ext_state = hns3_get_link_ext_state,
+	.get_devfeatures = hns3_get_devfeatures,
+	.set_devfeatures = hns3_set_devfeatures,
 };
 
 void hns3_ethtool_set_ops(struct net_device *netdev)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15  3:21 ` [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get " Jie Wang
@ 2022-03-15 19:15   ` Jakub Kicinski
  2022-03-15 19:56     ` Michal Kubecek
  2022-03-15 20:03     ` Roopa Prabhu
  2022-03-15 19:18   ` Michal Kubecek
  1 sibling, 2 replies; 12+ messages in thread
From: Jakub Kicinski @ 2022-03-15 19:15 UTC (permalink / raw)
  To: Jie Wang
  Cc: mkubecek, davem, netdev, huangguangbin2, lipeng321, shenjian15,
	moyufeng, linyunsheng, tanhuazhong, salil.mehta, chenhao288

On Tue, 15 Mar 2022 11:21:07 +0800 Jie Wang wrote:
> As tx push is a standard feature for NICs, but netdev_feature which is
> controlled by ethtool -K has reached the maximum specification.
> 
> so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
> 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
> drivers. The message processing functions and function hooks in struct
> ethtool_ops are also added.
> 
> set-devfeatures/show-devfeatures option(s) are designed to provide set
> and get function.
> set cmd:
> root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
> get cmd:
> root@wj: ethtool --show-devfeatures eth4

I'd be curious to hear more opinions on whether we want to create a new
command or use another method for setting this bit, and on the concept
of "devfeatures" in general.

One immediate feedback is that we're not adding any more commands to
the ioctl API. You'll need to implement it in the netlink version of
the ethtool API.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15  3:21 ` [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get " Jie Wang
  2022-03-15 19:15   ` Jakub Kicinski
@ 2022-03-15 19:18   ` Michal Kubecek
  2022-03-18  6:28     ` wangjie (L)
  1 sibling, 1 reply; 12+ messages in thread
From: Michal Kubecek @ 2022-03-15 19:18 UTC (permalink / raw)
  To: Jie Wang
  Cc: davem, kuba, netdev, huangguangbin2, lipeng321, shenjian15,
	moyufeng, linyunsheng, tanhuazhong, salil.mehta, chenhao288

[-- Attachment #1: Type: text/plain, Size: 5588 bytes --]

On Tue, Mar 15, 2022 at 11:21:07AM +0800, Jie Wang wrote:
> As tx push is a standard feature for NICs, but netdev_feature which is
> controlled by ethtool -K has reached the maximum specification.
> 
> so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
> 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
> drivers. The message processing functions and function hooks in struct
> ethtool_ops are also added.
> 
> set-devfeatures/show-devfeatures option(s) are designed to provide set
> and get function.
> set cmd:
> root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
> get cmd:
> root@wj: ethtool --show-devfeatures eth4
> 
> Signed-off-by: Jie Wang <wangjie125@huawei.com>

The consensus is that no new commands should be added to the ioctl
interface. Please implement this via netlink.

Michal

> ---
>  include/linux/ethtool.h      |  4 ++++
>  include/uapi/linux/ethtool.h | 27 ++++++++++++++++++++++
>  net/ethtool/ioctl.c          | 43 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 74 insertions(+)
> 
> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
> index 11efc45de66a..1a34bb074720 100644
> --- a/include/linux/ethtool.h
> +++ b/include/linux/ethtool.h
> @@ -750,6 +750,10 @@ struct ethtool_ops {
>  	int	(*set_module_power_mode)(struct net_device *dev,
>  					 const struct ethtool_module_power_mode_params *params,
>  					 struct netlink_ext_ack *extack);
> +	int	(*get_devfeatures)(struct net_device *dev,
> +				   struct ethtool_dev_features *dev_feat);
> +	int	(*set_devfeatures)(struct net_device *dev,
> +				   struct ethtool_dev_features *dev_feat);
>  };
>  
>  int ethtool_check_ops(const struct ethtool_ops *ops);
> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
> index 7bc4b8def12c..319d7b2c6acb 100644
> --- a/include/uapi/linux/ethtool.h
> +++ b/include/uapi/linux/ethtool.h
> @@ -1490,6 +1490,31 @@ enum ethtool_fec_config_bits {
>  #define ETHTOOL_FEC_BASER		(1 << ETHTOOL_FEC_BASER_BIT)
>  #define ETHTOOL_FEC_LLRS		(1 << ETHTOOL_FEC_LLRS_BIT)
>  
> +/**
> + * struct ethtool_dev_features - device feature configurations
> + * @cmd: Command number = %ETHTOOL_GDEVFEAT or %ETHTOOL_SDEVFEAT
> + * @type: feature configuration type.
> + * @data: feature configuration value.
> + */
> +struct ethtool_dev_features {
> +	__u32 cmd;
> +	__u32 type;
> +	__u32 data;
> +};
> +
> +/**
> + * enum ethtool_dev_features_type - flags definition of ethtool_dev_features
> + * @ETHTOOL_DEV_TX_PUSH: nic tx push mode set bit.
> + */
> +enum ethtool_dev_features_type {
> +	ETHTOOL_DEV_TX_PUSH,
> +	/*
> +	 * Add your fresh feature type above and remember to update
> +	 * feat_line[] in ethtool.c
> +	 */
> +	ETHTOOL_DEV_FEATURE_COUNT,
> +};
> +
>  /* CMDs currently supported */
>  #define ETHTOOL_GSET		0x00000001 /* DEPRECATED, Get settings.
>  					    * Please use ETHTOOL_GLINKSETTINGS
> @@ -1584,6 +1609,8 @@ enum ethtool_fec_config_bits {
>  #define ETHTOOL_PHY_STUNABLE	0x0000004f /* Set PHY tunable configuration */
>  #define ETHTOOL_GFECPARAM	0x00000050 /* Get FEC settings */
>  #define ETHTOOL_SFECPARAM	0x00000051 /* Set FEC settings */
> +#define ETHTOOL_GDEVFEAT	0x00000052 /* Get device features */
> +#define ETHTOOL_SDEVFEAT	0x00000053 /* Set device features */
>  
>  /* compatibility with older code */
>  #define SPARC_ETH_GSET		ETHTOOL_GSET
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 326e14ee05db..efac23352eb9 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -2722,6 +2722,42 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
>  	return dev->ethtool_ops->set_fecparam(dev, &fecparam);
>  }
>  
> +static int ethtool_get_devfeatures(struct net_device *dev,
> +				   void __user *useraddr)
> +{
> +	struct ethtool_dev_features dev_feat;
> +	int ret;
> +
> +	if (!dev->ethtool_ops->get_devfeatures)
> +		return -EOPNOTSUPP;
> +
> +	if (copy_from_user(&dev_feat, useraddr, sizeof(dev_feat)))
> +		return -EFAULT;
> +
> +	ret = dev->ethtool_ops->get_devfeatures(dev, &dev_feat);
> +	if (ret)
> +		return ret;
> +
> +	if (copy_to_user(useraddr, &dev_feat, sizeof(dev_feat)))
> +		return -EFAULT;
> +
> +	return 0;
> +}
> +
> +static int ethtool_set_devfeatures(struct net_device *dev,
> +				   void __user *useraddr)
> +{
> +	struct ethtool_dev_features dev_feat;
> +
> +	if (!dev->ethtool_ops->set_devfeatures)
> +		return -EOPNOTSUPP;
> +
> +	if (copy_from_user(&dev_feat, useraddr, sizeof(dev_feat)))
> +		return -EFAULT;
> +
> +	return dev->ethtool_ops->set_devfeatures(dev, &dev_feat);
> +}
> +
>  /* The main entry point in this file.  Called from net/core/dev_ioctl.c */
>  
>  static int
> @@ -2781,6 +2817,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
>  	case ETHTOOL_PHY_GTUNABLE:
>  	case ETHTOOL_GLINKSETTINGS:
>  	case ETHTOOL_GFECPARAM:
> +	case ETHTOOL_GDEVFEAT:
>  		break;
>  	default:
>  		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> @@ -3008,6 +3045,12 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
>  	case ETHTOOL_SFECPARAM:
>  		rc = ethtool_set_fecparam(dev, useraddr);
>  		break;
> +	case ETHTOOL_GDEVFEAT:
> +		rc = ethtool_get_devfeatures(dev, useraddr);
> +		break;
> +	case ETHTOOL_SDEVFEAT:
> +		rc = ethtool_set_devfeatures(dev, useraddr);
> +		break;
>  	default:
>  		rc = -EOPNOTSUPP;
>  	}
> -- 
> 2.33.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15 19:15   ` Jakub Kicinski
@ 2022-03-15 19:56     ` Michal Kubecek
  2022-03-16  1:45       ` Jakub Kicinski
  2022-03-15 20:03     ` Roopa Prabhu
  1 sibling, 1 reply; 12+ messages in thread
From: Michal Kubecek @ 2022-03-15 19:56 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jie Wang, davem, netdev, huangguangbin2, lipeng321, shenjian15,
	moyufeng, linyunsheng, tanhuazhong, salil.mehta, chenhao288

[-- Attachment #1: Type: text/plain, Size: 1974 bytes --]

On Tue, Mar 15, 2022 at 12:15:29PM -0700, Jakub Kicinski wrote:
> On Tue, 15 Mar 2022 11:21:07 +0800 Jie Wang wrote:
> > As tx push is a standard feature for NICs, but netdev_feature which is
> > controlled by ethtool -K has reached the maximum specification.
> > 
> > so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
> > 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
> > drivers. The message processing functions and function hooks in struct
> > ethtool_ops are also added.
> > 
> > set-devfeatures/show-devfeatures option(s) are designed to provide set
> > and get function.
> > set cmd:
> > root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
> > get cmd:
> > root@wj: ethtool --show-devfeatures eth4
> 
> I'd be curious to hear more opinions on whether we want to create a new
> command or use another method for setting this bit, and on the concept
> of "devfeatures" in general.

IMHO it depends a lot on what exactly "belong entirely to the driver"
means. If it means driver specific features, using a private flag would
seem more appropriate for this particular feature and then we can
discuss if we want some generalization of private flags for other types
of driver/device specific parameters (integers etc.). Personally, I'm
afraid that it would encourage driver developers to go this easier way
instead of trying to come with universal and future proof interfaces.

If this is supposed to gather universal features supported by multiple
drivers and devices, I suggest grouping it with existing parameters
handled as tunables in ioctl API. Or perhaps we could keep using the
name "tunables" and just handle them like any other command parameters
encoded as netlink attributes in the API.

Michal


> 
> One immediate feedback is that we're not adding any more commands to
> the ioctl API. You'll need to implement it in the netlink version of
> the ethtool API.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15 19:15   ` Jakub Kicinski
  2022-03-15 19:56     ` Michal Kubecek
@ 2022-03-15 20:03     ` Roopa Prabhu
  2022-03-16  1:40       ` Jakub Kicinski
  1 sibling, 1 reply; 12+ messages in thread
From: Roopa Prabhu @ 2022-03-15 20:03 UTC (permalink / raw)
  To: Jakub Kicinski, Jie Wang
  Cc: mkubecek, davem, netdev, huangguangbin2, lipeng321, shenjian15,
	moyufeng, linyunsheng, tanhuazhong, salil.mehta, chenhao288


On 3/15/22 12:15, Jakub Kicinski wrote:
> On Tue, 15 Mar 2022 11:21:07 +0800 Jie Wang wrote:
>> As tx push is a standard feature for NICs, but netdev_feature which is
>> controlled by ethtool -K has reached the maximum specification.
>>
>> so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
>> 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
>> drivers. The message processing functions and function hooks in struct
>> ethtool_ops are also added.
>>
>> set-devfeatures/show-devfeatures option(s) are designed to provide set
>> and get function.
>> set cmd:
>> root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
>> get cmd:
>> root@wj: ethtool --show-devfeatures eth4
> I'd be curious to hear more opinions on whether we want to create a new
> command or use another method for setting this bit, and on the concept
> of "devfeatures" in general.
>
> One immediate feedback is that we're not adding any more commands to
> the ioctl API. You'll need to implement it in the netlink version of
> the ethtool API.

+1,  it would have been nice if we did not have to expose the change in 
api for features via  a new option.

harder for user to track which features need new option.

ie, if possible, it would be better to internally transition new 
features to new api.

(i have not looked yet if moving to netlink will make the above point moot)



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15 20:03     ` Roopa Prabhu
@ 2022-03-16  1:40       ` Jakub Kicinski
  0 siblings, 0 replies; 12+ messages in thread
From: Jakub Kicinski @ 2022-03-16  1:40 UTC (permalink / raw)
  To: Roopa Prabhu
  Cc: Jie Wang, mkubecek, davem, netdev, huangguangbin2, lipeng321,
	shenjian15, moyufeng, linyunsheng, tanhuazhong, salil.mehta,
	chenhao288

On Tue, 15 Mar 2022 13:03:00 -0700 Roopa Prabhu wrote:
> > I'd be curious to hear more opinions on whether we want to create a new
> > command or use another method for setting this bit, and on the concept
> > of "devfeatures" in general.
> >
> > One immediate feedback is that we're not adding any more commands to
> > the ioctl API. You'll need to implement it in the netlink version of
> > the ethtool API.  
> 
> +1,  it would have been nice if we did not have to expose the change in 
> api for features via  a new option.
> 
> harder for user to track which features need new option.
> 
> ie, if possible, it would be better to internally transition new 
> features to new api.
> 
> (i have not looked yet if moving to netlink will make the above point moot)

The slight wrinkle on the usual feature API is that it's out of bits
and the work on moving it to bitmap has stalled :S

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15 19:56     ` Michal Kubecek
@ 2022-03-16  1:45       ` Jakub Kicinski
  2022-03-21  6:17         ` wangjie (L)
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Kicinski @ 2022-03-16  1:45 UTC (permalink / raw)
  To: Michal Kubecek
  Cc: Jie Wang, davem, netdev, huangguangbin2, lipeng321, shenjian15,
	moyufeng, linyunsheng, tanhuazhong, salil.mehta, chenhao288

On Tue, 15 Mar 2022 20:56:06 +0100 Michal Kubecek wrote:
> On Tue, Mar 15, 2022 at 12:15:29PM -0700, Jakub Kicinski wrote:
> > On Tue, 15 Mar 2022 11:21:07 +0800 Jie Wang wrote:  
> > > As tx push is a standard feature for NICs, but netdev_feature which is
> > > controlled by ethtool -K has reached the maximum specification.
> > > 
> > > so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
> > > 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
> > > drivers. The message processing functions and function hooks in struct
> > > ethtool_ops are also added.
> > > 
> > > set-devfeatures/show-devfeatures option(s) are designed to provide set
> > > and get function.
> > > set cmd:
> > > root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
> > > get cmd:
> > > root@wj: ethtool --show-devfeatures eth4  
> > 
> > I'd be curious to hear more opinions on whether we want to create a new
> > command or use another method for setting this bit, and on the concept
> > of "devfeatures" in general.  
> 
> IMHO it depends a lot on what exactly "belong entirely to the driver"
> means. If it means driver specific features, using a private flag would
> seem more appropriate for this particular feature and then we can
> discuss if we want some generalization of private flags for other types
> of driver/device specific parameters (integers etc.). Personally, I'm
> afraid that it would encourage driver developers to go this easier way
> instead of trying to come with universal and future proof interfaces.

The "belong entirely to the driver" meant that the stack does not need
to be aware of it. That's the justification for not putting it in
netdev features, which the stack also peeks at, at times.

> If this is supposed to gather universal features supported by multiple
> drivers and devices, I suggest grouping it with existing parameters
> handled as tunables in ioctl API. Or perhaps we could keep using the
> name "tunables" and just handle them like any other command parameters
> encoded as netlink attributes in the API.

Let's throw tunables into the hell fire where they belong, lest they
spawn a monster in the image of devlink params.

How about we put it in SET_RINGS? It's a ring param after all 
(the feature controls use of a fast path descriptor push which 
skips the usual in-memory ring).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-15 19:18   ` Michal Kubecek
@ 2022-03-18  6:28     ` wangjie (L)
  0 siblings, 0 replies; 12+ messages in thread
From: wangjie (L) @ 2022-03-18  6:28 UTC (permalink / raw)
  To: Michal Kubecek
  Cc: davem, kuba, netdev, huangguangbin2, lipeng321, shenjian15,
	moyufeng, linyunsheng, tanhuazhong, salil.mehta, chenhao288



On 2022/3/16 3:18, Michal Kubecek wrote:
> On Tue, Mar 15, 2022 at 11:21:07AM +0800, Jie Wang wrote:
>> As tx push is a standard feature for NICs, but netdev_feature which is
>> controlled by ethtool -K has reached the maximum specification.
>>
>> so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
>> 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
>> drivers. The message processing functions and function hooks in struct
>> ethtool_ops are also added.
>>
>> set-devfeatures/show-devfeatures option(s) are designed to provide set
>> and get function.
>> set cmd:
>> root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
>> get cmd:
>> root@wj: ethtool --show-devfeatures eth4
>>
>> Signed-off-by: Jie Wang <wangjie125@huawei.com>
>
> The consensus is that no new commands should be added to the ioctl
> interface. Please implement this via netlink.
>
> Michal
>
OK, thanks.
>> ---
>>  include/linux/ethtool.h      |  4 ++++
>>  include/uapi/linux/ethtool.h | 27 ++++++++++++++++++++++
>>  net/ethtool/ioctl.c          | 43 ++++++++++++++++++++++++++++++++++++
>>  3 files changed, 74 insertions(+)
>>
>> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
>> index 11efc45de66a..1a34bb074720 100644
>> --- a/include/linux/ethtool.h
>> +++ b/include/linux/ethtool.h
>> @@ -750,6 +750,10 @@ struct ethtool_ops {
>>  	int	(*set_module_power_mode)(struct net_device *dev,
>>  					 const struct ethtool_module_power_mode_params *params,
>>  					 struct netlink_ext_ack *extack);
>> +	int	(*get_devfeatures)(struct net_device *dev,
>> +				   struct ethtool_dev_features *dev_feat);
>> +	int	(*set_devfeatures)(struct net_device *dev,
>> +				   struct ethtool_dev_features *dev_feat);
>>  };
>>
>>  int ethtool_check_ops(const struct ethtool_ops *ops);
>> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
>> index 7bc4b8def12c..319d7b2c6acb 100644
>> --- a/include/uapi/linux/ethtool.h
>> +++ b/include/uapi/linux/ethtool.h
>> @@ -1490,6 +1490,31 @@ enum ethtool_fec_config_bits {
>>  #define ETHTOOL_FEC_BASER		(1 << ETHTOOL_FEC_BASER_BIT)
>>  #define ETHTOOL_FEC_LLRS		(1 << ETHTOOL_FEC_LLRS_BIT)
>>
>> +/**
>> + * struct ethtool_dev_features - device feature configurations
>> + * @cmd: Command number = %ETHTOOL_GDEVFEAT or %ETHTOOL_SDEVFEAT
>> + * @type: feature configuration type.
>> + * @data: feature configuration value.
>> + */
>> +struct ethtool_dev_features {
>> +	__u32 cmd;
>> +	__u32 type;
>> +	__u32 data;
>> +};
>> +
>> +/**
>> + * enum ethtool_dev_features_type - flags definition of ethtool_dev_features
>> + * @ETHTOOL_DEV_TX_PUSH: nic tx push mode set bit.
>> + */
>> +enum ethtool_dev_features_type {
>> +	ETHTOOL_DEV_TX_PUSH,
>> +	/*
>> +	 * Add your fresh feature type above and remember to update
>> +	 * feat_line[] in ethtool.c
>> +	 */
>> +	ETHTOOL_DEV_FEATURE_COUNT,
>> +};
>> +
>>  /* CMDs currently supported */
>>  #define ETHTOOL_GSET		0x00000001 /* DEPRECATED, Get settings.
>>  					    * Please use ETHTOOL_GLINKSETTINGS
>> @@ -1584,6 +1609,8 @@ enum ethtool_fec_config_bits {
>>  #define ETHTOOL_PHY_STUNABLE	0x0000004f /* Set PHY tunable configuration */
>>  #define ETHTOOL_GFECPARAM	0x00000050 /* Get FEC settings */
>>  #define ETHTOOL_SFECPARAM	0x00000051 /* Set FEC settings */
>> +#define ETHTOOL_GDEVFEAT	0x00000052 /* Get device features */
>> +#define ETHTOOL_SDEVFEAT	0x00000053 /* Set device features */
>>
>>  /* compatibility with older code */
>>  #define SPARC_ETH_GSET		ETHTOOL_GSET
>> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
>> index 326e14ee05db..efac23352eb9 100644
>> --- a/net/ethtool/ioctl.c
>> +++ b/net/ethtool/ioctl.c
>> @@ -2722,6 +2722,42 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
>>  	return dev->ethtool_ops->set_fecparam(dev, &fecparam);
>>  }
>>
>> +static int ethtool_get_devfeatures(struct net_device *dev,
>> +				   void __user *useraddr)
>> +{
>> +	struct ethtool_dev_features dev_feat;
>> +	int ret;
>> +
>> +	if (!dev->ethtool_ops->get_devfeatures)
>> +		return -EOPNOTSUPP;
>> +
>> +	if (copy_from_user(&dev_feat, useraddr, sizeof(dev_feat)))
>> +		return -EFAULT;
>> +
>> +	ret = dev->ethtool_ops->get_devfeatures(dev, &dev_feat);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (copy_to_user(useraddr, &dev_feat, sizeof(dev_feat)))
>> +		return -EFAULT;
>> +
>> +	return 0;
>> +}
>> +
>> +static int ethtool_set_devfeatures(struct net_device *dev,
>> +				   void __user *useraddr)
>> +{
>> +	struct ethtool_dev_features dev_feat;
>> +
>> +	if (!dev->ethtool_ops->set_devfeatures)
>> +		return -EOPNOTSUPP;
>> +
>> +	if (copy_from_user(&dev_feat, useraddr, sizeof(dev_feat)))
>> +		return -EFAULT;
>> +
>> +	return dev->ethtool_ops->set_devfeatures(dev, &dev_feat);
>> +}
>> +
>>  /* The main entry point in this file.  Called from net/core/dev_ioctl.c */
>>
>>  static int
>> @@ -2781,6 +2817,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
>>  	case ETHTOOL_PHY_GTUNABLE:
>>  	case ETHTOOL_GLINKSETTINGS:
>>  	case ETHTOOL_GFECPARAM:
>> +	case ETHTOOL_GDEVFEAT:
>>  		break;
>>  	default:
>>  		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
>> @@ -3008,6 +3045,12 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
>>  	case ETHTOOL_SFECPARAM:
>>  		rc = ethtool_set_fecparam(dev, useraddr);
>>  		break;
>> +	case ETHTOOL_GDEVFEAT:
>> +		rc = ethtool_get_devfeatures(dev, useraddr);
>> +		break;
>> +	case ETHTOOL_SDEVFEAT:
>> +		rc = ethtool_set_devfeatures(dev, useraddr);
>> +		break;
>>  	default:
>>  		rc = -EOPNOTSUPP;
>>  	}
>> --
>> 2.33.0
>>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-16  1:45       ` Jakub Kicinski
@ 2022-03-21  6:17         ` wangjie (L)
  2022-03-21 18:20           ` Jakub Kicinski
  0 siblings, 1 reply; 12+ messages in thread
From: wangjie (L) @ 2022-03-21  6:17 UTC (permalink / raw)
  To: Jakub Kicinski, Michal Kubecek
  Cc: davem, netdev, huangguangbin2, lipeng321, shenjian15, moyufeng,
	linyunsheng, tanhuazhong, salil.mehta, chenhao288



On 2022/3/16 9:45, Jakub Kicinski wrote:
> On Tue, 15 Mar 2022 20:56:06 +0100 Michal Kubecek wrote:
>> On Tue, Mar 15, 2022 at 12:15:29PM -0700, Jakub Kicinski wrote:
>>> On Tue, 15 Mar 2022 11:21:07 +0800 Jie Wang wrote:
>>>> As tx push is a standard feature for NICs, but netdev_feature which is
>>>> controlled by ethtool -K has reached the maximum specification.
>>>>
>>>> so this patch adds a pair of new ethtool messages:'ETHTOOL_GDEVFEAT' and
>>>> 'ETHTOOL_SDEVFEAT' to be used to set/get features contained entirely to
>>>> drivers. The message processing functions and function hooks in struct
>>>> ethtool_ops are also added.
>>>>
>>>> set-devfeatures/show-devfeatures option(s) are designed to provide set
>>>> and get function.
>>>> set cmd:
>>>> root@wj: ethtool --set-devfeatures eth4 tx-push [on | off]
>>>> get cmd:
>>>> root@wj: ethtool --show-devfeatures eth4
>>>
>>> I'd be curious to hear more opinions on whether we want to create a new
>>> command or use another method for setting this bit, and on the concept
>>> of "devfeatures" in general.
>>
>> IMHO it depends a lot on what exactly "belong entirely to the driver"
>> means. If it means driver specific features, using a private flag would
>> seem more appropriate for this particular feature and then we can
>> discuss if we want some generalization of private flags for other types
>> of driver/device specific parameters (integers etc.). Personally, I'm
>> afraid that it would encourage driver developers to go this easier way
>> instead of trying to come with universal and future proof interfaces.
>
> The "belong entirely to the driver" meant that the stack does not need
> to be aware of it. That's the justification for not putting it in
> netdev features, which the stack also peeks at, at times.
>
>> If this is supposed to gather universal features supported by multiple
>> drivers and devices, I suggest grouping it with existing parameters
>> handled as tunables in ioctl API. Or perhaps we could keep using the
>> name "tunables" and just handle them like any other command parameters
>> encoded as netlink attributes in the API.
>
> Let's throw tunables into the hell fire where they belong, lest they
> spawn a monster in the image of devlink params.
>
> How about we put it in SET_RINGS? It's a ring param after all
> (the feature controls use of a fast path descriptor push which
> skips the usual in-memory ring).
>
I think SET_RINGS is OK for tx push, but next new device feature would
still have this problem. As far as I know, features such as promisc,
tx push are driver features. So should I still work on the new devfeature
command netlink version for these standard driver features?

It would be nice to have clear rules about which command does new feature
need to be added to.
> .
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get fresh device features
  2022-03-21  6:17         ` wangjie (L)
@ 2022-03-21 18:20           ` Jakub Kicinski
  0 siblings, 0 replies; 12+ messages in thread
From: Jakub Kicinski @ 2022-03-21 18:20 UTC (permalink / raw)
  To: wangjie (L)
  Cc: Michal Kubecek, davem, netdev, huangguangbin2, lipeng321,
	shenjian15, moyufeng, linyunsheng, tanhuazhong, salil.mehta,
	chenhao288

On Mon, 21 Mar 2022 14:17:16 +0800 wangjie (L) wrote:
> I think SET_RINGS is OK for tx push, but next new device feature would
> still have this problem. As far as I know, features such as promisc,
> tx push are driver features. So should I still work on the new devfeature
> command netlink version for these standard driver features?

No.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-21 18:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15  3:21 [RFC net-next 0/2] add ethtool ops support for fresh device features Jie Wang
2022-03-15  3:21 ` [RFC net-next 1/2] net: ethtool: add ethtool ability to set/get " Jie Wang
2022-03-15 19:15   ` Jakub Kicinski
2022-03-15 19:56     ` Michal Kubecek
2022-03-16  1:45       ` Jakub Kicinski
2022-03-21  6:17         ` wangjie (L)
2022-03-21 18:20           ` Jakub Kicinski
2022-03-15 20:03     ` Roopa Prabhu
2022-03-16  1:40       ` Jakub Kicinski
2022-03-15 19:18   ` Michal Kubecek
2022-03-18  6:28     ` wangjie (L)
2022-03-15  3:21 ` [RFC net-next 2/2] net: hns3: add ethtool set/get device features support for hns3 driver Jie Wang

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.