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 F074FA0547 for ; Tue, 9 Feb 2021 11:36:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E412140147; Tue, 9 Feb 2021 11:36:41 +0100 (CET) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mails.dpdk.org (Postfix) with ESMTP id 7CE7040147 for ; Tue, 9 Feb 2021 11:36:40 +0100 (CET) Received: by mail-wr1-f47.google.com with SMTP id q7so20929383wre.13 for ; Tue, 09 Feb 2021 02:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f6KQONzsGW8AdVSPzzCUNSEn5kMfbOAoS/0MvX8nuzM=; b=at/Iolk9y8gYpv17l8SG+zG1N5ZVjvg4lw07eXm+P5kQLvd6SkmfQlVJNUnXFTk4mI oliUn4H2ZK67oyTtgyjSzo3OpHYINBJHxiQHwZjInIZY3iZ158X7I3zD9OXOm8PPMZOt RRe/yAlZmoARU+e9zNZaICq0erZDum1SkRyIZ1p9/xedvOHQQkkRI+CT7PJKsyWyr9ba lAx3OIDd1/O1gCw9R+3x5W1aBu3/0X49vSKyt0rgUX7nEdo13gYglkWmLwU/3PjdHN0a nn8W71ET89YQd1jhtpOG6Y6gIW6G+roDiM/+FAYndWjZZtNQ6uf9yPMmA3lDqtLGzS33 ohYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f6KQONzsGW8AdVSPzzCUNSEn5kMfbOAoS/0MvX8nuzM=; b=Ji7VTfwHb/KJH9BBfVPMDAUUVM30QUDodLJgvQvCDqIN6UBuCbWRdV48ohz78527ta /18YOIiyYS/bqeHnB+2hqrn6dUB706wpCEwIXopelEOKIiBQyMKXsT0QtmWBoBrl5fZW gVL/Q4IoF436PWjMjqwcJ4ESv7IB5WRiUWpYCrK92qsIZTBe779w+To3qfHJEDVgFkQd 4Q+5VjC40pG8ir03iyU0ie1mKFqg5cN0lAVjTN+ByCCW8+V2hiZcbmA8ghLHkt5tKBHD 9rtUtS1CEYXUCftYknUgPh0Ecbc40IbkVoVmIY23ZRiQjT2t6wWWK2CMHx6OMAOVdesE Ov3w== X-Gm-Message-State: AOAM533A/K7zK+F+6bwLbw0XI+lR56lMp/R8OaMgi48220VMg84trOaL iRq2FPh+XTKf6bFJkq+Fj7g= X-Google-Smtp-Source: ABdhPJxrc1n7G2dyLTSYoXfJhYwlo60VigfDM3KHgo117pHxdePkrjX7Rim6Jy0bgRigU84MlHBC+g== X-Received: by 2002:a5d:5908:: with SMTP id v8mr25702401wrd.113.1612867000289; Tue, 09 Feb 2021 02:36:40 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id a17sm37091913wrx.63.2021.02.09.02.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 02:36:39 -0800 (PST) From: luca.boccassi@gmail.com To: Huisong Li Cc: Lijun Ou , dpdk stable Date: Tue, 9 Feb 2021 10:35:19 +0000 Message-Id: <20210209103529.466775-21-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210209103529.466775-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> <20210209103529.466775-1-luca.boccassi@gmail.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 20.11.1 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 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 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 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@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)