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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
Signed-off-by: Taehee Yoo <ap420073@xxxxxxxxx>
---

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)
+{
+	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];
-- 
2.34.1





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux