From: James Hershaw <james.hers...@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.hers...@corigine.com> Reviewed-by: Chaoyong He <chaoyong...@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