[dpdk-stable] patch 'net/hns3: fix HW buffer size on MTU update' has been queued to stable release 20.11.2

Xueming Li xuemingl at nvidia.com
Mon May 10 17:59:36 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/3997b852411f2022478b2b32e1916f9a555a68b8

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 3997b852411f2022478b2b32e1916f9a555a68b8 Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang at huawei.com>
Date: Thu, 4 Mar 2021 15:44:50 +0800
Subject: [PATCH] net/hns3: fix HW buffer size on MTU update
Cc: Luca Boccassi <bluca at debian.org>

[ upstream commit 25fb790f7868f8eee96f7f051a834dec01b8a369 ]

After MTU changed, the buffer used to store packets in HW should be
reallocated. And buffer size is allocated based on the maximum frame
size in the PF struct. However, the value of maximum frame size  is
not updated in time when MTU is changed. This would lead to a packet
loss for not enough buffer.

This patch update the maximum frame size before reallocating the HW
buffer. And a rollback operation is added to avoid the side effects
of buffer reallocation failures.

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

Signed-off-by: Chengchang Tang <tangchengchang at huawei.com>
Signed-off-by: Lijun Ou <oulijun at huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index ba7d6e38a2..8f4ce58c0b 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2435,17 +2435,33 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps)
 static int
 hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
 {
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+	uint16_t original_mps = hns->pf.mps;
+	int err;
 	int ret;
 
 	ret = hns3_set_mac_mtu(hw, mps);
 	if (ret) {
-		hns3_err(hw, "Failed to set mtu, ret = %d", ret);
+		hns3_err(hw, "failed to set mtu, ret = %d", ret);
 		return ret;
 	}
 
+	hns->pf.mps = mps;
 	ret = hns3_buffer_alloc(hw);
-	if (ret)
-		hns3_err(hw, "Failed to allocate buffer, ret = %d", ret);
+	if (ret) {
+		hns3_err(hw, "failed to allocate buffer, ret = %d", ret);
+		goto rollback;
+	}
+
+	return 0;
+
+rollback:
+	err = hns3_set_mac_mtu(hw, original_mps);
+	if (err) {
+		hns3_err(hw, "fail to rollback MTU, err = %d", err);
+		return ret;
+	}
+	hns->pf.mps = original_mps;
 
 	return ret;
 }
@@ -2480,7 +2496,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 			 dev->data->port_id, mtu, ret);
 		return ret;
 	}
-	hns->pf.mps = (uint16_t)frame_size;
+
 	if (is_jumbo_frame)
 		dev->data->dev_conf.rxmode.offloads |=
 						DEV_RX_OFFLOAD_JUMBO_FRAME;
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-05-10 23:59:27.408646500 +0800
+++ 0028-net-hns3-fix-HW-buffer-size-on-MTU-update.patch	2021-05-10 23:59:26.350000000 +0800
@@ -1 +1 @@
-From 25fb790f7868f8eee96f7f051a834dec01b8a369 Mon Sep 17 00:00:00 2001
+From 3997b852411f2022478b2b32e1916f9a555a68b8 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Luca Boccassi <bluca at debian.org>
+
+[ upstream commit 25fb790f7868f8eee96f7f051a834dec01b8a369 ]
@@ -18 +20,0 @@
-Cc: stable at dpdk.org
@@ -27 +29 @@
-index b3fd331fe4..21c3c59cdd 100644
+index ba7d6e38a2..8f4ce58c0b 100644
@@ -30 +32 @@
-@@ -2460,17 +2460,33 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps)
+@@ -2435,17 +2435,33 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps)
@@ -67 +69 @@
-@@ -2505,7 +2521,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+@@ -2480,7 +2496,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)


More information about the stable mailing list