DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com,
	James Hershaw <james.hershaw@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH] net/nfp: reduce space reserved for layer 2 overhead
Date: Sat, 28 Oct 2023 14:26:51 +0800	[thread overview]
Message-ID: <20231028062651.1843217-1-chaoyong.he@corigine.com> (raw)

From: James Hershaw <james.hershaw@corigine.com>

Reduce the space reserved for layer 2 overhead by defining
NFP_ETH_OVERHEAD.

Previously, the overhead was not explicitly defined, only the
NFP_FRAME_SIZE_MAX value and the maximum layer 3 MTU was read from
hardware, which is set by firmware.

This resulted in a massive overhead, 516 Bytes in most cases, and while
this can hold useful metadata in some cases, for the most part is not
necessary. As such the overhead is explicitly defined in line with other
net PMDs and the maximum frame size is calculated based on this and the
layer 3 MTU read from firmware.

Signed-off-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_net_common.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index ac97e3bed5..c7371ac32a 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -22,9 +22,9 @@
 #define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
 #define NFP_NET_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
 
-/* Maximum supported NFP frame size (MTU + layer 2 headers) */
-#define NFP_FRAME_SIZE_MAX        10048
 #define DEFAULT_FLBUF_SIZE        9216
+#define NFP_ETH_OVERHEAD \
+	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN * 2)
 
 enum nfp_xstat_group {
 	NFP_XSTAT_GROUP_NET,
@@ -274,9 +274,9 @@ nfp_net_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Checking MTU set */
-	if (rxmode->mtu > NFP_FRAME_SIZE_MAX) {
-		PMD_DRV_LOG(ERR, "MTU (%u) larger than NFP_FRAME_SIZE_MAX (%u)",
-				rxmode->mtu, NFP_FRAME_SIZE_MAX);
+	if (rxmode->mtu > hw->max_mtu + NFP_ETH_OVERHEAD) {
+		PMD_DRV_LOG(ERR, "MTU (%u) larger than the maximum possible frame size (%u)",
+				rxmode->mtu, hw->max_mtu + NFP_ETH_OVERHEAD);
 		return -ERANGE;
 	}
 
@@ -1023,16 +1023,13 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
 	dev_info->max_tx_queues = (uint16_t)hw->max_tx_queues;
 	dev_info->min_rx_bufsize = RTE_ETHER_MIN_MTU;
-
-	/**
-	 * The maximum rx packet length (max_rx_pktlen) is set to the
-	 * maximum supported frame size that the NFP can handle. This
-	 * includes layer 2 headers, CRC and other metadata that can
-	 * optionally be used.
+	/*
+	 * The maximum rx packet length is set to the maximum layer 3 MTU,
+	 * plus layer 2, CRC and VLAN headers.
 	 * The maximum layer 3 MTU (max_mtu) is read from hardware,
 	 * which was set by the firmware loaded onto the card.
 	 */
-	dev_info->max_rx_pktlen = NFP_FRAME_SIZE_MAX;
+	dev_info->max_rx_pktlen = hw->max_mtu + NFP_ETH_OVERHEAD;
 	dev_info->max_mtu = hw->max_mtu;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 	/* Next should change when PF support is implemented */
-- 
2.39.1


             reply	other threads:[~2023-10-28  6:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-28  6:26 Chaoyong He [this message]
2023-11-01 12:00 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231028062651.1843217-1-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=james.hershaw@corigine.com \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).