[PATCH 5/7] net/nfb: support setting Rx MTU
spinler at cesnet.cz
spinler at cesnet.cz
Fri Feb 6 18:04:33 CET 2026
From: Martin Spinler <spinler at cesnet.cz>
Enable configuration of the MTU on the Rx MAC assigned to the port.
Signed-off-by: Martin Spinler <spinler at cesnet.cz>
---
drivers/net/nfb/nfb_ethdev.c | 39 ++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index b927d006e7..b4bd98e08c 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -49,6 +49,7 @@ static struct nfb_pmd_internals_head nfb_eth_dev_list =
TAILQ_HEAD_INITIALIZER(nfb_eth_dev_list);
static int nfb_eth_dev_uninit(struct rte_eth_dev *dev);
+static int nfb_eth_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
static int
nfb_mdio_read(void *priv, int prtad, int devad, uint16_t addr)
@@ -255,6 +256,10 @@ nfb_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
int ret;
struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
+ ret = nfb_eth_mtu_set(dev, dev_conf->rxmode.mtu);
+ if (ret)
+ goto err_mtu_set;
+
if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
ret = rte_mbuf_dyn_rx_timestamp_register
(&nfb_timestamp_dynfield_offset,
@@ -269,6 +274,7 @@ nfb_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
return 0;
err_ts_register:
+err_mtu_set:
nfb_eth_dev_uninit(dev);
return ret;
}
@@ -549,6 +555,38 @@ nfb_eth_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
nc_rxmac_set_mac(internals->rxmac[i], index, 0, 0);
}
+static int
+nfb_eth_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+ unsigned int i;
+ struct nc_rxmac_status status;
+ struct pmd_internals *intl = dev->process_private;
+ uint16_t frame_length_max_capable;
+
+ mtu += RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+
+ if (!intl->max_rxmac)
+ return 0;
+
+ status.frame_length_max_capable = 0;
+ nc_rxmac_read_status(intl->rxmac[0], &status);
+ frame_length_max_capable = status.frame_length_max_capable;
+
+ for (i = 1; i < intl->max_rxmac; ++i) {
+ nc_rxmac_read_status(intl->rxmac[i], &status);
+ if (frame_length_max_capable > status.frame_length_max_capable)
+ frame_length_max_capable = status.frame_length_max_capable;
+ }
+
+ if (frame_length_max_capable < mtu && frame_length_max_capable != 0)
+ return -EINVAL;
+
+ for (i = 0; i < intl->max_rxmac; ++i)
+ nc_rxmac_set_frame_length(intl->rxmac[i], mtu, RXMAC_FRAME_LENGTH_MAX);
+
+ return 0;
+}
+
static int
nfb_eth_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
size_t fw_size)
@@ -661,6 +699,7 @@ static const struct eth_dev_ops ops = {
.mac_addr_set = nfb_eth_mac_addr_set,
.mac_addr_add = nfb_eth_mac_addr_add,
.mac_addr_remove = nfb_eth_mac_addr_remove,
+ .mtu_set = nfb_eth_mtu_set,
.fw_version_get = nfb_eth_fw_version_get,
.fec_get = nfb_eth_fec_get,
.fec_set = nfb_eth_fec_set,
--
2.53.0
More information about the dev
mailing list