net/nfp: make sure MTU is never larger than mbuf size
Setting a MTU larger than mbuf size is not supported by the device but
not prohibited by the driver. This change adds a restriction to the
driver to prevent setting an MTU that is too large.
While at it define the minimum MTU in the device information to describe
the complete supported MTU range.
Fixes: d4a27a3
("nfp: add basic features")
Cc: stable@dpdk.org
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Walter Heymans <walter.heymans@corigine.com>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
parent
d04fb3b55c
commit
417be15e5f
@ -176,6 +176,13 @@ nfp_net_configure(struct rte_eth_dev *dev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Checking MTU set */
|
||||
if (rxmode->mtu > hw->flbufsz) {
|
||||
PMD_INIT_LOG(INFO, "MTU (%u) larger then current mbufsize (%u) not supported",
|
||||
rxmode->mtu, hw->flbufsz);
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -702,6 +709,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
|
||||
*/
|
||||
dev_info->max_rx_pktlen = NFP_FRAME_SIZE_MAX;
|
||||
dev_info->max_mtu = hw->max_mtu;
|
||||
dev_info->min_mtu = RTE_ETHER_MIN_MTU;
|
||||
/* Next should change when PF support is implemented */
|
||||
dev_info->max_mac_addrs = 1;
|
||||
|
||||
@ -961,6 +969,13 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* MTU larger then current mbufsize not supported */
|
||||
if (mtu > hw->flbufsz) {
|
||||
PMD_DRV_LOG(ERR, "MTU (%u) larger then current mbufsize (%u) not supported",
|
||||
mtu, hw->flbufsz);
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
/* writing to configuration space */
|
||||
nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user