[dpdk-stable] patch 'net/hns3: validate requested maximum Rx frame length' has been queued to stable release 20.11.1

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Feb 9 11:35:19 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/11/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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/62ac98640b29e7f519c6a97fc694e012a5dcc22d

Thanks.

Luca Boccassi

---
>From 62ac98640b29e7f519c6a97fc694e012a5dcc22d Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong at huawei.com>
Date: Wed, 3 Feb 2021 20:23:57 +0800
Subject: [PATCH] net/hns3: validate requested maximum Rx frame length

[ upstream commit b8a67b10ee616e4635d3f6f8c8c25d0fdb987b6c ]

When jumbo frame is enabled, the MTU size needs to be modified
based on 'max_rx_pkt_len'. Driver needs to check the validity
of 'max_rx_pkt_len'. And it should be in the range of
HNS3_DEFAULT_FRAME_LEN and HNS3_MAX_FRAME_LEN. Otherwise, it may
cause that the MTU size is inconsistent with jumbo frame offload.

Fixes: 19a3ca4c99cf ("net/hns3: add start/stop and configure operations")

Signed-off-by: Huisong Li <lihuisong at huawei.com>
Signed-off-by: Lijun Ou <oulijun at huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    | 19 +++++++++++++------
 drivers/net/hns3/hns3_ethdev_vf.c | 19 +++++++++++++------
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index fc41af626b..8f0e5a3c81 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2313,6 +2313,7 @@ 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;
@@ -2371,12 +2372,18 @@ hns3_dev_configure(struct rte_eth_dev *dev)
 	 * according to the maximum RX packet length.
 	 */
 	if (conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
-		/*
-		 * Security of max_rx_pkt_len is guaranteed in dpdk frame.
-		 * Maximum value of max_rx_pkt_len is HNS3_MAX_FRAME_LEN, so it
-		 * can safely assign to "uint16_t" type variable.
-		 */
-		mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(conf->rxmode.max_rx_pkt_len);
+		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;
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 22ee2f4000..9c84740d7b 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -779,6 +779,7 @@ hns3vf_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;
@@ -831,12 +832,18 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
 	 * according to the maximum RX packet length.
 	 */
 	if (conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
-		/*
-		 * Security of max_rx_pkt_len is guaranteed in dpdk frame.
-		 * Maximum value of max_rx_pkt_len is HNS3_MAX_FRAME_LEN, so it
-		 * can safely assign to "uint16_t" type variable.
-		 */
-		mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(conf->rxmode.max_rx_pkt_len);
+		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 = hns3vf_dev_mtu_set(dev, mtu);
 		if (ret)
 			goto cfg_err;
-- 
2.29.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-02-09 10:34:58.767300678 +0000
+++ 0021-net-hns3-validate-requested-maximum-Rx-frame-length.patch	2021-02-09 10:34:57.922584236 +0000
@@ -1 +1 @@
-From b8a67b10ee616e4635d3f6f8c8c25d0fdb987b6c Mon Sep 17 00:00:00 2001
+From 62ac98640b29e7f519c6a97fc694e012a5dcc22d Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit b8a67b10ee616e4635d3f6f8c8c25d0fdb987b6c ]
+
@@ -13 +14,0 @@
-Cc: stable at dpdk.org
@@ -23 +24 @@
-index a7ae8f81d8..dbd48deb3a 100644
+index fc41af626b..8f0e5a3c81 100644
@@ -26 +27 @@
-@@ -2343,6 +2343,7 @@ hns3_dev_configure(struct rte_eth_dev *dev)
+@@ -2313,6 +2313,7 @@ hns3_dev_configure(struct rte_eth_dev *dev)
@@ -34 +35 @@
-@@ -2396,12 +2397,18 @@ hns3_dev_configure(struct rte_eth_dev *dev)
+@@ -2371,12 +2372,18 @@ hns3_dev_configure(struct rte_eth_dev *dev)
@@ -60 +61 @@
-index a607bd3a91..3f9f328170 100644
+index 22ee2f4000..9c84740d7b 100644
@@ -63 +64 @@
-@@ -778,6 +778,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
+@@ -779,6 +779,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
@@ -71 +72 @@
-@@ -825,12 +826,18 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
+@@ -831,12 +832,18 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)


More information about the stable mailing list