DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/nfp: reduce space reserved for layer 2 overhead
@ 2023-10-28  6:26 Chaoyong He
  2023-11-01 12:00 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Chaoyong He @ 2023-10-28  6:26 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, James Hershaw, Chaoyong He

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/nfp: reduce space reserved for layer 2 overhead
  2023-10-28  6:26 [PATCH] net/nfp: reduce space reserved for layer 2 overhead Chaoyong He
@ 2023-11-01 12:00 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2023-11-01 12:00 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, James Hershaw

On 10/28/2023 7:26 AM, Chaoyong He wrote:
> 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>>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-01 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-28  6:26 [PATCH] net/nfp: reduce space reserved for layer 2 overhead Chaoyong He
2023-11-01 12:00 ` Ferruh Yigit

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).