From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 16ABBA0547 for ; Mon, 8 Feb 2021 12:15:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DDB51606C3; Mon, 8 Feb 2021 12:15:03 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id C42F440147 for ; Mon, 8 Feb 2021 12:15:00 +0100 (CET) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l94VQ-0001Ac-Jp; Mon, 08 Feb 2021 11:15:00 +0000 From: Christian Ehrhardt To: Huisong Li Cc: Lijun Ou , dpdk stable Date: Mon, 8 Feb 2021 12:14:24 +0100 Message-Id: <20210208111429.1875789-12-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208111429.1875789-1-christian.ehrhardt@canonical.com> References: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> <20210208111429.1875789-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: validate requested maximum Rx frame length' has been queued to stable release 19.11.7 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.7 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/10/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/d00bf9bf70cfcc925ecf115ff316d1ebc591b22b Thanks. Christian Ehrhardt --- >From d00bf9bf70cfcc925ecf115ff316d1ebc591b22b Mon Sep 17 00:00:00 2001 From: Huisong Li 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 Signed-off-by: Lijun Ou --- 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 33b3ccc865..66be58dc26 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2290,6 +2290,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; int ret; @@ -2342,12 +2343,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 09a8d31ff4..c936114075 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -690,6 +690,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; int ret; @@ -736,12 +737,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.30.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-08 12:04:29.993383198 +0100 +++ 0012-net-hns3-validate-requested-maximum-Rx-frame-length.patch 2021-02-08 12:04:29.551496794 +0100 @@ -1 +1 @@ -From b8a67b10ee616e4635d3f6f8c8c25d0fdb987b6c Mon Sep 17 00:00:00 2001 +From d00bf9bf70cfcc925ecf115ff316d1ebc591b22b Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit b8a67b10ee616e4635d3f6f8c8c25d0fdb987b6c ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -23 +24 @@ -index a7ae8f81d8..dbd48deb3a 100644 +index 33b3ccc865..66be58dc26 100644 @@ -26 +27 @@ -@@ -2343,6 +2343,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) +@@ -2290,6 +2290,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) @@ -32 +32,0 @@ - bool gro_en; @@ -34 +34,2 @@ -@@ -2396,12 +2397,18 @@ hns3_dev_configure(struct rte_eth_dev *dev) + +@@ -2342,12 +2343,18 @@ hns3_dev_configure(struct rte_eth_dev *dev) @@ -60 +61 @@ -index a607bd3a91..3f9f328170 100644 +index 09a8d31ff4..c936114075 100644 @@ -63 +64 @@ -@@ -778,6 +778,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) +@@ -690,6 +690,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) @@ -69 +69,0 @@ - bool gro_en; @@ -71 +71,2 @@ -@@ -825,12 +826,18 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) + +@@ -736,12 +737,18 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)