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 D320AA0A02 for ; Mon, 17 May 2021 18:13:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CCE72410F1; Mon, 17 May 2021 18:13:53 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id E8F6340041 for ; Mon, 17 May 2021 18:13:52 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifsO-0007zX-NR; Mon, 17 May 2021 16:13:52 +0000 From: Christian Ehrhardt To: "Min Hu (Connor)" Cc: dpdk stable Date: Mon, 17 May 2021 18:08:32 +0200 Message-Id: <20210517161039.3132619-83-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: fix MTU config complexity' has been queued to stable release 19.11.9 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.9 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/19/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/ceeb684478b742219a37a4c795b64c12b13f8fd1 Thanks. Christian Ehrhardt --- >From ceeb684478b742219a37a4c795b64c12b13f8fd1 Mon Sep 17 00:00:00 2001 From: "Min Hu (Connor)" Date: Thu, 1 Apr 2021 21:38:03 +0800 Subject: [PATCH] net/hns3: fix MTU config complexity [ 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) --- 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 98bc37d294..505bf116eb 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2279,6 +2279,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) { @@ -2290,8 +2325,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; int ret; /* @@ -2338,28 +2371,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.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:32.741143298 +0200 +++ 0083-net-hns3-fix-MTU-config-complexity.patch 2021-05-17 17:40:29.251810107 +0200 @@ -1 +1 @@ -From d81d78eb86d50732ba98a8b255d19c2f6292521c Mon Sep 17 00:00:00 2001 +From ceeb684478b742219a37a4c795b64c12b13f8fd1 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d81d78eb86d50732ba98a8b255d19c2f6292521c ] + @@ -10 +11,0 @@ -Cc: stable@dpdk.org @@ -18 +19 @@ -index 9c718082b0..b07996928b 100644 +index 98bc37d294..505bf116eb 100644 @@ -21 +22 @@ -@@ -2372,6 +2372,41 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) +@@ -2279,6 +2279,41 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) @@ -63 +64 @@ -@@ -2382,8 +2417,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) +@@ -2290,8 +2325,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) @@ -69 +69,0 @@ - bool gro_en; @@ -72 +72,2 @@ -@@ -2431,28 +2464,9 @@ hns3_dev_configure(struct rte_eth_dev *dev) + /* +@@ -2338,28 +2371,9 @@ hns3_dev_configure(struct rte_eth_dev *dev)