diff mbox series

[net-next,v4,6/8] net: ethtool: add ring parameter filtering

Message ID 20241022162359.2713094-7-ap420073@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: implement device memory TCP for bnxt | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; GEN HAS DIFF 2 files changed, 38 insertions(+);
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success Errors and warnings before: 157 (+1) this patch: 157 (+1)
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 27 this patch: 27
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 46 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-23--12-00 (tests: 777)

Commit Message

Taehee Yoo Oct. 22, 2024, 4:23 p.m. UTC
While the devmem is running, the tcp-data-split and
header-data-split-thresh configuration should not be changed.
If user tries to change tcp-data-split and threshold value while the
devmem is running, it fails and shows extack message.

Tested-by: Stanislav Fomichev <sdf@fomichev.me>
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---

v4:
 - Add netdev_devmem_enabled() helper.
 - Add Test tag from Stanislav.

v3:
 - Patch added

 include/net/netdev_rx_queue.h | 14 ++++++++++++++
 net/ethtool/common.h          |  1 +
 net/ethtool/rings.c           | 13 +++++++++++++
 3 files changed, 28 insertions(+)

Comments

Mina Almasry Nov. 1, 2024, 2:35 p.m. UTC | #1
On Tue, Oct 22, 2024 at 9:25 AM Taehee Yoo <ap420073@gmail.com> wrote:
>
> While the devmem is running, the tcp-data-split and
> header-data-split-thresh configuration should not be changed.
> If user tries to change tcp-data-split and threshold value while the
> devmem is running, it fails and shows extack message.
>
> Tested-by: Stanislav Fomichev <sdf@fomichev.me>
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> ---
>
> v4:
>  - Add netdev_devmem_enabled() helper.
>  - Add Test tag from Stanislav.
>
> v3:
>  - Patch added
>
>  include/net/netdev_rx_queue.h | 14 ++++++++++++++
>  net/ethtool/common.h          |  1 +
>  net/ethtool/rings.c           | 13 +++++++++++++
>  3 files changed, 28 insertions(+)
>
> diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h
> index 596836abf7bf..7fbb64ce8d89 100644
> --- a/include/net/netdev_rx_queue.h
> +++ b/include/net/netdev_rx_queue.h
> @@ -55,6 +55,20 @@ get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
>         return index;
>  }
>
> +static inline bool netdev_devmem_enabled(struct net_device *dev)

Mega nit: netdev_memory_provider_enabled().

This is actually not devmem specific, and there is already an io_uring
provider in the works.

But, also, we already have dev_get_min_mp_channel_count() defined in
linux/netdevice.h. Lets re-use that one instead of adding another
helper that does almost the same thing. Sorry, I should have
remembered we already have this helper in the last iteration.

Other than that, looks fine to me.

> +{
> +       struct netdev_rx_queue *queue;
> +       int i;
> +
> +       for (i = 0; i < dev->real_num_rx_queues; i++) {
> +               queue = __netif_get_rx_queue(dev, i);
> +               if (queue->mp_params.mp_priv)
> +                       return true;
> +       }
> +
> +       return false;
> +}
> +
>  int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
>
>  #endif
> diff --git a/net/ethtool/common.h b/net/ethtool/common.h
> index 4a2de3ce7354..5b8e5847ba3c 100644
> --- a/net/ethtool/common.h
> +++ b/net/ethtool/common.h
> @@ -5,6 +5,7 @@
>
>  #include <linux/netdevice.h>
>  #include <linux/ethtool.h>
> +#include <net/netdev_rx_queue.h>
>
>  #define ETHTOOL_DEV_FEATURE_WORDS      DIV_ROUND_UP(NETDEV_FEATURE_COUNT, 32)
>
> diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c
> index e1fd82a91014..ca313c301081 100644
> --- a/net/ethtool/rings.c
> +++ b/net/ethtool/rings.c
> @@ -258,6 +258,19 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
>                 return -ERANGE;
>         }
>
> +       if (netdev_devmem_enabled(dev)) {
> +               if (kernel_ringparam.tcp_data_split !=
> +                   ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
> +                       NL_SET_ERR_MSG(info->extack,
> +                                      "tcp-data-split should be enabled while devmem is running");

Maybe: "can't disable tcp-data-split while device has memory provider enabled"

> +                       return -EINVAL;
> +               } else if (kernel_ringparam.hds_thresh) {
> +                       NL_SET_ERR_MSG(info->extack,
> +                                      "header-data-split-thresh should be zero while devmem is running");

Maybe: "can't set non-zero hds_thresh while device is memory provider enabled".
Taehee Yoo Nov. 1, 2024, 6:08 p.m. UTC | #2
On Fri, Nov 1, 2024 at 11:35 PM Mina Almasry <almasrymina@google.com> wrote:
>
> On Tue, Oct 22, 2024 at 9:25 AM Taehee Yoo <ap420073@gmail.com> wrote:
> >
> > While the devmem is running, the tcp-data-split and
> > header-data-split-thresh configuration should not be changed.
> > If user tries to change tcp-data-split and threshold value while the
> > devmem is running, it fails and shows extack message.
> >
> > Tested-by: Stanislav Fomichev <sdf@fomichev.me>
> > Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> > ---
> >
> > v4:
> >  - Add netdev_devmem_enabled() helper.
> >  - Add Test tag from Stanislav.
> >
> > v3:
> >  - Patch added
> >
> >  include/net/netdev_rx_queue.h | 14 ++++++++++++++
> >  net/ethtool/common.h          |  1 +
> >  net/ethtool/rings.c           | 13 +++++++++++++
> >  3 files changed, 28 insertions(+)
> >
> > diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h
> > index 596836abf7bf..7fbb64ce8d89 100644
> > --- a/include/net/netdev_rx_queue.h
> > +++ b/include/net/netdev_rx_queue.h
> > @@ -55,6 +55,20 @@ get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
> >         return index;
> >  }
> >
> > +static inline bool netdev_devmem_enabled(struct net_device *dev)
>
> Mega nit: netdev_memory_provider_enabled().
>
> This is actually not devmem specific, and there is already an io_uring
> provider in the works.
>
> But, also, we already have dev_get_min_mp_channel_count() defined in
> linux/netdevice.h. Lets re-use that one instead of adding another
> helper that does almost the same thing. Sorry, I should have
> remembered we already have this helper in the last iteration.

Ah, I didn't catch it too.
I will use dev_get_min_mp_channel_count() instead.
Thanks a lot!

>
> Other than that, looks fine to me.
>
> > +{
> > +       struct netdev_rx_queue *queue;
> > +       int i;
> > +
> > +       for (i = 0; i < dev->real_num_rx_queues; i++) {
> > +               queue = __netif_get_rx_queue(dev, i);
> > +               if (queue->mp_params.mp_priv)
> > +                       return true;
> > +       }
> > +
> > +       return false;
> > +}
> > +
> >  int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
> >
> >  #endif
> > diff --git a/net/ethtool/common.h b/net/ethtool/common.h
> > index 4a2de3ce7354..5b8e5847ba3c 100644
> > --- a/net/ethtool/common.h
> > +++ b/net/ethtool/common.h
> > @@ -5,6 +5,7 @@
> >
> >  #include <linux/netdevice.h>
> >  #include <linux/ethtool.h>
> > +#include <net/netdev_rx_queue.h>
> >
> >  #define ETHTOOL_DEV_FEATURE_WORDS      DIV_ROUND_UP(NETDEV_FEATURE_COUNT, 32)
> >
> > diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c
> > index e1fd82a91014..ca313c301081 100644
> > --- a/net/ethtool/rings.c
> > +++ b/net/ethtool/rings.c
> > @@ -258,6 +258,19 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
> >                 return -ERANGE;
> >         }
> >
> > +       if (netdev_devmem_enabled(dev)) {
> > +               if (kernel_ringparam.tcp_data_split !=
> > +                   ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
> > +                       NL_SET_ERR_MSG(info->extack,
> > +                                      "tcp-data-split should be enabled while devmem is running");
>
> Maybe: "can't disable tcp-data-split while device has memory provider enabled"

Thanks! I will use it!

>
> > +                       return -EINVAL;
> > +               } else if (kernel_ringparam.hds_thresh) {
> > +                       NL_SET_ERR_MSG(info->extack,
> > +                                      "header-data-split-thresh should be zero while devmem is running");
>
> Maybe: "can't set non-zero hds_thresh while device is memory provider enabled".

Thanks, I will use it too.

Thanks a lot!
Taehee Yoo

>
>
> --
> Thanks,
> Mina
diff mbox series

Patch

diff --git a/include/net/netdev_rx_queue.h b/include/net/netdev_rx_queue.h
index 596836abf7bf..7fbb64ce8d89 100644
--- a/include/net/netdev_rx_queue.h
+++ b/include/net/netdev_rx_queue.h
@@ -55,6 +55,20 @@  get_netdev_rx_queue_index(struct netdev_rx_queue *queue)
 	return index;
 }
 
+static inline bool netdev_devmem_enabled(struct net_device *dev)
+{
+	struct netdev_rx_queue *queue;
+	int i;
+
+	for (i = 0; i < dev->real_num_rx_queues; i++) {
+		queue = __netif_get_rx_queue(dev, i);
+		if (queue->mp_params.mp_priv)
+			return true;
+	}
+
+	return false;
+}
+
 int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq);
 
 #endif
diff --git a/net/ethtool/common.h b/net/ethtool/common.h
index 4a2de3ce7354..5b8e5847ba3c 100644
--- a/net/ethtool/common.h
+++ b/net/ethtool/common.h
@@ -5,6 +5,7 @@ 
 
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
+#include <net/netdev_rx_queue.h>
 
 #define ETHTOOL_DEV_FEATURE_WORDS	DIV_ROUND_UP(NETDEV_FEATURE_COUNT, 32)
 
diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c
index e1fd82a91014..ca313c301081 100644
--- a/net/ethtool/rings.c
+++ b/net/ethtool/rings.c
@@ -258,6 +258,19 @@  ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
 		return -ERANGE;
 	}
 
+	if (netdev_devmem_enabled(dev)) {
+		if (kernel_ringparam.tcp_data_split !=
+		    ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
+			NL_SET_ERR_MSG(info->extack,
+				       "tcp-data-split should be enabled while devmem is running");
+			return -EINVAL;
+		} else if (kernel_ringparam.hds_thresh) {
+			NL_SET_ERR_MSG(info->extack,
+				       "header-data-split-thresh should be zero while devmem is running");
+			return -EINVAL;
+		}
+	}
+
 	/* ensure new ring parameters are within limits */
 	if (ringparam.rx_pending > ringparam.rx_max_pending)
 		err_attr = tb[ETHTOOL_A_RINGS_RX];