[dpdk-stable] patch 'net/hns3: fix MTU config complexity' has been queued to stable release 20.11.2

Xueming Li xuemingl at nvidia.com
Mon May 10 18:01:26 CEST 2021


Hi,

FYI, your patch has been queued to stable release 20.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/fdd1a587627de72b4366222437191b0fda56f9c1

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From fdd1a587627de72b4366222437191b0fda56f9c1 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29 at huawei.com>
Date: Thu, 1 Apr 2021 21:38:03 +0800
Subject: [PATCH] net/hns3: fix MTU config complexity
Cc: Luca Boccassi <bluca at debian.org>

[ upstream commit d81d78eb86d50732ba98a8b255d19c2f6292521c ]

This patch fixed cyclomatic complexity about MTU
in device configure process.

Fixes: 1f5ca0b460cd ("net/hns3: support some device operations")

Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 62 +++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 24 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index ba26230829..a4c6440768 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2302,6 +2302,41 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)
 	return 0;
 }
 
+static int
+hns3_refresh_mtu(struct rte_eth_dev *dev, struct rte_eth_conf *conf)
+{
+	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
+	uint32_t max_rx_pkt_len;
+	uint16_t mtu;
+	int ret;
+
+	if (!(conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME))
+		return 0;
+
+	/*
+	 * If jumbo frames are enabled, MTU needs to be refreshed
+	 * according to the maximum RX packet length.
+	 */
+	max_rx_pkt_len = conf->rxmode.max_rx_pkt_len;
+	if (max_rx_pkt_len > HNS3_MAX_FRAME_LEN ||
+	    max_rx_pkt_len <= HNS3_DEFAULT_FRAME_LEN) {
+		hns3_err(hw, "maximum Rx packet length must be greater than %u "
+			 "and no more than %u when jumbo frame enabled.",
+			 (uint16_t)HNS3_DEFAULT_FRAME_LEN,
+			 (uint16_t)HNS3_MAX_FRAME_LEN);
+		return -EINVAL;
+	}
+
+	mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(max_rx_pkt_len);
+	ret = hns3_dev_mtu_set(dev, mtu);
+	if (ret)
+		return ret;
+	dev->data->mtu = mtu;
+
+	return 0;
+}
+
 static int
 hns3_dev_configure(struct rte_eth_dev *dev)
 {
@@ -2313,8 +2348,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
 	uint16_t nb_rx_q = dev->data->nb_rx_queues;
 	uint16_t nb_tx_q = dev->data->nb_tx_queues;
 	struct rte_eth_rss_conf rss_conf;
-	uint32_t max_rx_pkt_len;
-	uint16_t mtu;
 	bool gro_en;
 	int ret;
 
@@ -2367,28 +2400,9 @@ hns3_dev_configure(struct rte_eth_dev *dev)
 			goto cfg_err;
 	}
 
-	/*
-	 * If jumbo frames are enabled, MTU needs to be refreshed
-	 * according to the maximum RX packet length.
-	 */
-	if (conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
-		max_rx_pkt_len = conf->rxmode.max_rx_pkt_len;
-		if (max_rx_pkt_len > HNS3_MAX_FRAME_LEN ||
-		    max_rx_pkt_len <= HNS3_DEFAULT_FRAME_LEN) {
-			hns3_err(hw, "maximum Rx packet length must be greater "
-				 "than %u and less than %u when jumbo frame enabled.",
-				 (uint16_t)HNS3_DEFAULT_FRAME_LEN,
-				 (uint16_t)HNS3_MAX_FRAME_LEN);
-			ret = -EINVAL;
-			goto cfg_err;
-		}
-
-		mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(max_rx_pkt_len);
-		ret = hns3_dev_mtu_set(dev, mtu);
-		if (ret)
-			goto cfg_err;
-		dev->data->mtu = mtu;
-	}
+	ret = hns3_refresh_mtu(dev, conf);
+	if (ret)
+		goto cfg_err;
 
 	ret = hns3_dev_configure_vlan(dev);
 	if (ret)
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-05-10 23:59:30.130931400 +0800
+++ 0138-net-hns3-fix-MTU-config-complexity.patch	2021-05-10 23:59:26.530000000 +0800
@@ -1 +1 @@
-From d81d78eb86d50732ba98a8b255d19c2f6292521c Mon Sep 17 00:00:00 2001
+From fdd1a587627de72b4366222437191b0fda56f9c1 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Luca Boccassi <bluca at debian.org>
+
+[ upstream commit d81d78eb86d50732ba98a8b255d19c2f6292521c ]
@@ -10 +12,0 @@
-Cc: stable at dpdk.org
@@ -18 +20 @@
-index 9c718082b0..b07996928b 100644
+index ba26230829..a4c6440768 100644
@@ -21 +23 @@
-@@ -2372,6 +2372,41 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)
+@@ -2302,6 +2302,41 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)
@@ -63 +65 @@
-@@ -2382,8 +2417,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
+@@ -2313,8 +2348,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
@@ -72 +74 @@
-@@ -2431,28 +2464,9 @@ hns3_dev_configure(struct rte_eth_dev *dev)
+@@ -2367,28 +2400,9 @@ hns3_dev_configure(struct rte_eth_dev *dev)


More information about the stable mailing list