net/nfp: reduce space reserved for layer 2 overhead

Message ID 20231028062651.1843217-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: reduce space reserved for layer 2 overhead |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Chaoyong He Oct. 28, 2023, 6:26 a.m. UTC
  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(-)
  

Comments

Ferruh Yigit Nov. 1, 2023, noon UTC | #1
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.
  

Patch

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 */