net/nfp: reduce space reserved for layer 2 overhead
Checks
Commit Message
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
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.
@@ -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 */