diff mbox series

[net-next,1/2] ethtool: add support to set/get completion event size

Message ID 1645109346-27600-2-git-send-email-sbhatta@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Add ethtool support for completion event size | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2061 this patch: 2061
netdev/cc_maintainers warning 6 maintainers not CCed: chenhao288@hisilicon.com linux-doc@vger.kernel.org corbet@lwn.net idosch@nvidia.com huangguangbin2@huawei.com hkallweit1@gmail.com
netdev/build_clang success Errors and warnings before: 588 this patch: 588
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2140 this patch: 2140
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/kdoc fail Errors and warnings before: 0 this patch: 1
netdev/source_inline success Was 0 now: 0

Commit Message

Subbaraya Sundeep Feb. 17, 2022, 2:49 p.m. UTC
Add support to set completion event size via ethtool -G
parameter and get it via ethtool -g parameter.

~ # ./ethtool -G eth0 ce-size 512
~ # ./ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX:             1048576
RX Mini:        n/a
RX Jumbo:       n/a
TX:             1048576
Current hardware settings:
RX:             256
RX Mini:        n/a
RX Jumbo:       n/a
TX:             4096
RX Buf Len:             2048
CE Size:                128

Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
---
 Documentation/networking/ethtool-netlink.rst |  2 ++
 include/linux/ethtool.h                      |  3 +++
 include/uapi/linux/ethtool_netlink.h         |  1 +
 net/ethtool/netlink.h                        |  2 +-
 net/ethtool/rings.c                          | 19 +++++++++++++++++--
 5 files changed, 24 insertions(+), 3 deletions(-)

Comments

Jakub Kicinski Feb. 17, 2022, 5:02 p.m. UTC | #1
On Thu, 17 Feb 2022 20:19:05 +0530 Subbaraya Sundeep wrote:
> Add support to set completion event size via ethtool -G
> parameter and get it via ethtool -g parameter.

> @@ -83,6 +85,7 @@ struct kernel_ethtool_ringparam {
>   */
>  enum ethtool_supported_ring_param {
>  	ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0),
> +	ETHTOOL_RING_USE_CE_SIZE    = BIT(1),
>  };

include/linux/ethtool.h:90: warning: Enum value 'ETHTOOL_RING_USE_CE_SIZE' not described in enum 'ethtool_supported_ring_param'
sundeep subbaraya Feb. 18, 2022, 8:10 a.m. UTC | #2
Hi Jakub,

On Thu, Feb 17, 2022 at 10:32 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 17 Feb 2022 20:19:05 +0530 Subbaraya Sundeep wrote:
> > Add support to set completion event size via ethtool -G
> > parameter and get it via ethtool -g parameter.
>
> > @@ -83,6 +85,7 @@ struct kernel_ethtool_ringparam {
> >   */
> >  enum ethtool_supported_ring_param {
> >       ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0),
> > +     ETHTOOL_RING_USE_CE_SIZE    = BIT(1),
> >  };
>
> include/linux/ethtool.h:90: warning: Enum value 'ETHTOOL_RING_USE_CE_SIZE' not described in enum 'ethtool_supported_ring_param'

compiled for ARM64, x86 and with COMPILE_TEST, W=1 but I did not see
any problem.
Please let me know what I am missing here.

Thanks,
Sundeep
sundeep subbaraya Feb. 18, 2022, 11:04 a.m. UTC | #3
Hi,

On Fri, Feb 18, 2022 at 1:40 PM sundeep subbaraya
<sundeep.lkml@gmail.com> wrote:
>
> Hi Jakub,
>
> On Thu, Feb 17, 2022 at 10:32 PM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Thu, 17 Feb 2022 20:19:05 +0530 Subbaraya Sundeep wrote:
> > > Add support to set completion event size via ethtool -G
> > > parameter and get it via ethtool -g parameter.
> >
> > > @@ -83,6 +85,7 @@ struct kernel_ethtool_ringparam {
> > >   */
> > >  enum ethtool_supported_ring_param {
> > >       ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0),
> > > +     ETHTOOL_RING_USE_CE_SIZE    = BIT(1),
> > >  };
> >
> > include/linux/ethtool.h:90: warning: Enum value 'ETHTOOL_RING_USE_CE_SIZE' not described in enum 'ethtool_supported_ring_param'
>
> compiled for ARM64, x86 and with COMPILE_TEST, W=1 but I did not see
> any problem.
> Please let me know what I am missing here.
>
Got it. It is a kdoc warning. Sorry for the noise.

Sundeep

> Thanks,
> Sundeep
diff mbox series

Patch

diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst
index cae28af..e159805 100644
--- a/Documentation/networking/ethtool-netlink.rst
+++ b/Documentation/networking/ethtool-netlink.rst
@@ -861,6 +861,7 @@  Kernel response contents:
   ``ETHTOOL_A_RINGS_TX``                u32     size of TX ring
   ``ETHTOOL_A_RINGS_RX_BUF_LEN``        u32     size of buffers on the ring
   ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT``    u8      TCP header / data split
+  ``ETHTOOL_A_RINGS_CE_SIZE``           u32     TX/RX completion event size
   ====================================  ======  ===========================
 
 ``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with
@@ -885,6 +886,7 @@  Request contents:
   ``ETHTOOL_A_RINGS_RX_JUMBO``          u32     size of RX jumbo ring
   ``ETHTOOL_A_RINGS_TX``                u32     size of TX ring
   ``ETHTOOL_A_RINGS_RX_BUF_LEN``        u32     size of buffers on the ring
+  ``ETHTOOL_A_RINGS_CE_SIZE``           u32     TX/RX completion event size
   ====================================  ======  ===========================
 
 Kernel checks that requested ring sizes do not exceed limits reported by
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index e0853f4..e3979aa 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -71,10 +71,12 @@  enum {
  * struct kernel_ethtool_ringparam - RX/TX ring configuration
  * @rx_buf_len: Current length of buffers on the rx ring.
  * @tcp_data_split: Scatter packet headers and data to separate buffers
+ * @ce_size: Size of TX/RX completion event
  */
 struct kernel_ethtool_ringparam {
 	u32	rx_buf_len;
 	u8	tcp_data_split;
+	u32	ce_size;
 };
 
 /**
@@ -83,6 +85,7 @@  struct kernel_ethtool_ringparam {
  */
 enum ethtool_supported_ring_param {
 	ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0),
+	ETHTOOL_RING_USE_CE_SIZE    = BIT(1),
 };
 
 #define __ETH_RSS_HASH_BIT(bit)	((u32)1 << (bit))
diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index 417d428..15fed00 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -337,6 +337,7 @@  enum {
 	ETHTOOL_A_RINGS_TX,				/* u32 */
 	ETHTOOL_A_RINGS_RX_BUF_LEN,                     /* u32 */
 	ETHTOOL_A_RINGS_TCP_DATA_SPLIT,			/* u8 */
+	ETHTOOL_A_RINGS_CE_SIZE,			/* u32 */
 
 	/* add new constants above here */
 	__ETHTOOL_A_RINGS_CNT,
diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 75856db..b7fac61 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -363,7 +363,7 @@  extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANT
 extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1];
 extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1];
 extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1];
-extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_RX_BUF_LEN + 1];
+extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_CE_SIZE + 1];
 extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1];
 extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1];
 extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1];
diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c
index 18a5035..2778368 100644
--- a/net/ethtool/rings.c
+++ b/net/ethtool/rings.c
@@ -54,7 +54,8 @@  static int rings_reply_size(const struct ethnl_req_info *req_base,
 	       nla_total_size(sizeof(u32)) +	/* _RINGS_RX_JUMBO */
 	       nla_total_size(sizeof(u32)) +	/* _RINGS_TX */
 	       nla_total_size(sizeof(u32)) +	/* _RINGS_RX_BUF_LEN */
-	       nla_total_size(sizeof(u8));	/* _RINGS_TCP_DATA_SPLIT */
+	       nla_total_size(sizeof(u8))  +	/* _RINGS_TCP_DATA_SPLIT */
+	       nla_total_size(sizeof(u32));	/* _RINGS_CE_SIZE */
 }
 
 static int rings_fill_reply(struct sk_buff *skb,
@@ -91,7 +92,9 @@  static int rings_fill_reply(struct sk_buff *skb,
 	     (nla_put_u32(skb, ETHTOOL_A_RINGS_RX_BUF_LEN, kr->rx_buf_len))) ||
 	    (kr->tcp_data_split &&
 	     (nla_put_u8(skb, ETHTOOL_A_RINGS_TCP_DATA_SPLIT,
-			 kr->tcp_data_split))))
+			 kr->tcp_data_split))) ||
+	    (kr->ce_size &&
+	     (nla_put_u32(skb, ETHTOOL_A_RINGS_CE_SIZE, kr->ce_size))))
 		return -EMSGSIZE;
 
 	return 0;
@@ -119,6 +122,7 @@  const struct nla_policy ethnl_rings_set_policy[] = {
 	[ETHTOOL_A_RINGS_RX_JUMBO]		= { .type = NLA_U32 },
 	[ETHTOOL_A_RINGS_TX]			= { .type = NLA_U32 },
 	[ETHTOOL_A_RINGS_RX_BUF_LEN]            = NLA_POLICY_MIN(NLA_U32, 1),
+	[ETHTOOL_A_RINGS_CE_SIZE]		= NLA_POLICY_MIN(NLA_U32, 1),
 };
 
 int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info)
@@ -159,6 +163,8 @@  int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info)
 	ethnl_update_u32(&ringparam.tx_pending, tb[ETHTOOL_A_RINGS_TX], &mod);
 	ethnl_update_u32(&kernel_ringparam.rx_buf_len,
 			 tb[ETHTOOL_A_RINGS_RX_BUF_LEN], &mod);
+	ethnl_update_u32(&kernel_ringparam.ce_size,
+			 tb[ETHTOOL_A_RINGS_CE_SIZE], &mod);
 	ret = 0;
 	if (!mod)
 		goto out_ops;
@@ -190,6 +196,15 @@  int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info)
 		goto out_ops;
 	}
 
+	if (kernel_ringparam.ce_size &&
+	    !(ops->supported_ring_params & ETHTOOL_RING_USE_CE_SIZE)) {
+		ret = -EOPNOTSUPP;
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[ETHTOOL_A_RINGS_CE_SIZE],
+				    "setting ce size not supported");
+		goto out_ops;
+	}
+
 	ret = dev->ethtool_ops->set_ringparam(dev, &ringparam,
 					      &kernel_ringparam, info->extack);
 	if (ret < 0)