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 D8801A0524 for ; Fri, 5 Feb 2021 12:32:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2C4440682; Fri, 5 Feb 2021 12:32:45 +0100 (CET) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mails.dpdk.org (Postfix) with ESMTP id A67A940682 for ; Fri, 5 Feb 2021 12:32:44 +0100 (CET) Received: by mail-wm1-f46.google.com with SMTP id 190so5756876wmz.0 for ; Fri, 05 Feb 2021 03:32:44 -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=HRmPJQu8Or59JW1SF4btgqgT0jciOh2ptP6EcVxan5Q=; b=URhqYzARfEa9x6iRfFztqoiYtTOXPbxkBHZFnqlRyQzudsqV4WSZBEJURwkL/s3xU5 Swt3ZnsgfGcgTrIoSP7indikZ0rSqoiS3TkwEifxwNGphm+ltiXEpfixpdpJz+2YL+bs rOtgF8HwTtX2Y/tC4oWvpPkCp7wYOq2iho0SZJQck7itS0gOUzyne0ORXCzuoEUFt/gK q90pPWI8izh5CRfP0zTQACI7hHkuwt9T9kso23P7qqS0tc4R0I+05wwXEbvIpMPc7zJm k8RsmNJDnfVuxHXb4c2kacVIDwjew76USjpj3OwlwqCVuenIz4NlZHXGirXWdvhRWfIA Sluw== 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=HRmPJQu8Or59JW1SF4btgqgT0jciOh2ptP6EcVxan5Q=; b=tAz5PTTnyGNb82WVeGwLwjtsrtXzFYvFAGsAyQz5PygDJUfK3Gk1LdI0Y5eE4nvO1u wNhG8wHAmC6iQF0rqEWkueYUiiW3eqklRuqHSNJpAw0h+8hf64S4pDBBoDCUjDlhxvwF QWD/yCg9z4yVX+CekZNHlxaTVfMX90WCGu+eQ+QUPM126l/499CtXaXLyNdjHnvSskML hyTSQByA29UyBFpnyJYrGIOipFf0qEWUHfd0R9lhY/mGDqXywv+m2msrytFp9jSLc+gN OsXYdBpSZ/+p0Ml5Wag/FOvibfMGL9ISYr3tW8gdkUJeV1qiv41F2INaaLfODhlArO4L PswA== X-Gm-Message-State: AOAM533CkEAKzpMRlLk+KJq2YUFGdxf4bXlCeim7NGd0b7lkSeTQoIo1 30KH3z+O+mYrTXExxWeqL80= X-Google-Smtp-Source: ABdhPJy5Xf318VlHs3XNDuySqUc/kiG/mVqxamq+ymN4roeDXO61YyJLmLLDlHWHpRhKeUvV/rzCsQ== X-Received: by 2002:a05:600c:3212:: with SMTP id r18mr1542742wmp.132.1612524764407; Fri, 05 Feb 2021 03:32:44 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id h23sm9054002wmb.41.2021.02.05.03.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:32:43 -0800 (PST) From: luca.boccassi@gmail.com To: Steve Yang Cc: Ferruh Yigit , dpdk stable Date: Fri, 5 Feb 2021 11:17:09 +0000 Message-Id: <20210205111920.1272063-143-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'ethdev: fix max Rx packet length check' 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/07/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/be78a4db33176cc20cea883d2702972ac60aa8b4 Thanks. Luca Boccassi --- >From be78a4db33176cc20cea883d2702972ac60aa8b4 Mon Sep 17 00:00:00 2001 From: Steve Yang Date: Mon, 18 Jan 2021 07:04:07 +0000 Subject: [PATCH] ethdev: fix max Rx packet length check [ upstream commit bf0f90d92d3010431c9187ed9a2b412030cded4e ] Ethdev is using default Ethernet overhead to decide if provided 'max_rx_pkt_len' value is bigger than max (non jumbo) MTU value, and limits it to MAX if it is. Since the application/driver used Ethernet overhead is different than the ethdev one, check result is wrong. If the driver is using Ethernet overhead bigger than the default one, the provided 'max_rx_pkt_len' is trimmed down, and in the driver when correct Ethernet overhead is used to convert back, the resulting MTU is less than the intended one, causing some packets to be dropped. Like, app -> max_rx_pkt_len = 1500/*mtu*/ + 22/*overhead*/ = 1522 ethdev -> 1522 > 1518/*MAX*/; max_rx_pkt_len = 1518 driver -> MTU = 1518 - 22 = 1496 Packets with size 1497-1500 are dropped although intention is to be able to send/receive them. The fix is to make ethdev use the correct Ethernet overhead for port, instead of default one. Fixes: 59d0ecdbf0e1 ("ethdev: MTU accessors") Signed-off-by: Steve Yang Reviewed-by: Ferruh Yigit --- lib/librte_ethdev/rte_ethdev.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 17ddacc78d..71e1e9a6db 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1292,8 +1292,10 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; struct rte_eth_conf orig_conf; + uint16_t overhead_len; int diag; int ret; + uint16_t old_mtu; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -1319,10 +1321,20 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf)); + /* Backup mtu for rollback */ + old_mtu = dev->data->mtu; + ret = rte_eth_dev_info_get(port_id, &dev_info); if (ret != 0) goto rollback; + /* Get the real Ethernet overhead length */ + if (dev_info.max_mtu != UINT16_MAX && + dev_info.max_rx_pktlen > dev_info.max_mtu) + overhead_len = dev_info.max_rx_pktlen - dev_info.max_mtu; + else + overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; + /* If number of queues specified by application for both Rx and Tx is * zero, use driver preferred values. This cannot be done individually * as it is valid for either Tx or Rx (but not both) to be zero. @@ -1409,12 +1421,17 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, ret = -EINVAL; goto rollback; } + + /* Scale the MTU size to adapt max_rx_pkt_len */ + dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len - + overhead_len; } else { - if (dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_LEN || - dev_conf->rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN) + uint16_t pktlen = dev_conf->rxmode.max_rx_pkt_len; + if (pktlen < RTE_ETHER_MIN_MTU + overhead_len || + pktlen > RTE_ETHER_MTU + overhead_len) /* Use default value */ dev->data->dev_conf.rxmode.max_rx_pkt_len = - RTE_ETHER_MAX_LEN; + RTE_ETHER_MTU + overhead_len; } /* @@ -1549,6 +1566,8 @@ reset_queues: eth_dev_tx_queue_config(dev, 0); rollback: memcpy(&dev->data->dev_conf, &orig_conf, sizeof(dev->data->dev_conf)); + if (old_mtu != dev->data->mtu) + dev->data->mtu = old_mtu; rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, ret); return ret; -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:35.689108179 +0000 +++ 0143-ethdev-fix-max-Rx-packet-length-check.patch 2021-02-05 11:18:29.030695376 +0000 @@ -1 +1 @@ -From bf0f90d92d3010431c9187ed9a2b412030cded4e Mon Sep 17 00:00:00 2001 +From be78a4db33176cc20cea883d2702972ac60aa8b4 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit bf0f90d92d3010431c9187ed9a2b412030cded4e ] + @@ -29 +30,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index e19dbd838b..9fe1c9d769 100644 +index 17ddacc78d..71e1e9a6db 100644