net/nfb: ethernet enhancements
Subsystems (2)
cover net/nfb: ethernet enhancements
From: Martin Spinler <[email protected]>
This set includes minor enhancements to the Ethernet configuration and overall usage.
---
Depends-on: series-37261 ("net/nfb: rework to real multiport")
Martin Spinler (7):
net/nfb: use MAC address assigned to card
net/nfb: get correct link speed
net/nfb: support real link-up/down config
net/nfb: support setting RS-FEC mode
net/nfb: support setting Rx MTU
net/nfb: read total stats from macs
doc/nfb: update release notes for nfb driver
doc/guides/rel_notes/release_26_03.rst | 3 +- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 7 + drivers/net/nfb/nfb_ethdev.c | 228 +++++++++++++++++++++---- drivers/net/nfb/nfb_mdio.c | 42 +++++ drivers/net/nfb/nfb_mdio.h | 34 ++++ drivers/net/nfb/nfb_stats.c | 40 +++-- 7 files changed, 308 insertions(+), 47 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
Signature · 1 line
2.53.0
PATCH 1/7 net/nfb: use MAC address assigned to card
From: Martin Spinler <[email protected]>
Check for a specific MAC address assigned to a card.
If there is no assigned MAC address, then use a random MAC as fallback.
--- drivers/net/nfb/nfb_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/nfb/nfb_ethdev.c +9 -4
@@ -11,6 +11,7 @@#include <nfb/nfb.h> #include <nfb/ndp.h> +#include <netcope/eth.h> #include <netcope/rxmac.h> #include <netcope/txmac.h>
@@ -639,10 +640,14 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data) goto err_malloc_mac_addrs; } -rte_eth_random_addr (eth_addr_init.addr_bytes); - eth_addr_init.addr_bytes[0 ] = eth_addr.addr_bytes[0 ]; - eth_addr_init.addr_bytes[1 ] = eth_addr.addr_bytes[1 ]; - eth_addr_init.addr_bytes[2 ] = eth_addr.addr_bytes[2 ]; + ret =nc_ifc_get_default_mac (internals->nfb, ifc->id, eth_addr_init.addr_bytes, +sizeof (eth_addr_init.addr_bytes)); +if (ret !=0 ) { +rte_eth_random_addr (eth_addr_init.addr_bytes); + eth_addr_init.addr_bytes[0 ] = eth_addr.addr_bytes[0 ]; + eth_addr_init.addr_bytes[1 ] = eth_addr.addr_bytes[1 ]; + eth_addr_init.addr_bytes[2 ] = eth_addr.addr_bytes[2 ]; + }nfb_eth_mac_addr_set (dev, ð_addr_init);rte_ether_addr_copy (ð_addr_init, &data->mac_addrs[0 ]);
Signature · 1 line
2.53.0
PATCH 2/7 net/nfb: get correct link speed
In reply to [email protected]From: Martin Spinler <[email protected]>
Read link speed capabilities and actual link speed from the MDIO registers.
--- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 7 ++++ drivers/net/nfb/nfb_ethdev.c | 78 +++++++++++++++++++++++++++--------- drivers/net/nfb/nfb_mdio.c | 42 +++++++++++++++++++ drivers/net/nfb/nfb_mdio.h | 34 ++++++++++++++++ 5 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
drivers/net/nfb/meson.build +1 -0
@@ -21,6 +21,7 @@ sources = files( 'nfb_rxmode.c', 'nfb_stats.c', 'nfb_tx.c', + 'nfb_mdio.c', ) cflags += no_wvla_cflag
drivers/net/nfb/nfb.h +7 -0
@@ -11,6 +11,7 @@#include <nfb/ndp.h> #include <netcope/rxmac.h> #include <netcope/txmac.h> +#include <netcope/mdio_if_info.h> #include <netcope/info.h> extern int nfb_logtype;
@@ -50,6 +51,10 @@ extern int nfb_logtype;NFB_ARG_PORT "=<number>" \"" +struct eth_node { +struct mdio_if_info if_info;/**< MDIO interface handles */ +}; +/* * Handles obtained from the libnfb: each process must use own instance. * Stored inside dev->process_private.
@@ -57,8 +62,10 @@ extern int nfb_logtype;struct pmd_internals {uint16_t max_rxmac;/**< Count of valid rxmac items */ uint16_t max_txmac;/**< Count of valid txmac items */ +uint16_t max_eth;/**< Count of valid eth nodes */ struct nc_rxmac **rxmac;/**< Array of Rx MAC handles */ struct nc_txmac **txmac;/**< Array of Tx MAC handles */ +struct eth_node *eth_node;/**< Array of Eth nodes */ struct nfb_device *nfb;TAILQ_ENTRY (pmd_internals) eth_dev_list;/**< Item in list of all devices */
drivers/net/nfb/nfb_ethdev.c +58 -20
153 lines not on this page · raw message
drivers/net/nfb/nfb_mdio.c new file +42 -0
42 lines not on this page · raw message
drivers/net/nfb/nfb_mdio.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 CESNET, z.s.p.o. +*/ + +#include <stdint.h> +#include <rte_bitops.h> +#include <netcope/mdio_if_info.h> + + +#define NFB_MDIO_WIDTH (UINT16_WIDTH) +#define NFB_MDIO_BIT (nr) (UINT16_C(1) << (nr)) + +#define NFB_MDIO_DEV_PMA 1 + +#define NFB_MDIO_PMA_CTRL 0 +#define NFB_MDIO_PMA_CTRL_RESET NFB_MDIO_BIT(15) + +#define NFB_MDIO_PMA_SPEED_ABILITY 4 + +#define NFB_MDIO_PMA_RSFEC_CR 200 +#define NFB_MDIO_PMA_RSFEC_CR_ENABLE NFB_MDIO_BIT(2) + +static inline int nfb_mdio_if_read_pma (struct mdio_if_info *if_info,uint16_t addr) +{ +return if_info->mdio_read (if_info->dev, if_info->prtad,NFB_MDIO_DEV_PMA , addr); +} + +static inline int nfb_mdio_if_write_pma (struct mdio_if_info *if_info,uint16_t addr,uint16_t val) +{ +return if_info->mdio_write (if_info->dev, if_info->prtad,NFB_MDIO_DEV_PMA , addr, val); +} + +__rte_internal +void nfb_mdio_cl45_pma_get_speed_capa(struct mdio_if_info *if_info, uint32_t *capa);
Signature · 1 line
2.53.0
PATCH 3/7 net/nfb: support real link-up/down config
In reply to [email protected]From: Martin Spinler <[email protected]>
Use the standard PMA reset bit in the MDIO registers to configure of the link-up/link-down state.
--- drivers/net/nfb/nfb_ethdev.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-)
drivers/net/nfb/nfb_ethdev.c +29 -7
@@ -410,6 +410,29 @@ nfb_eth_link_update(struct rte_eth_dev *dev,return 0 ; } +static int +nfb_eth_dev_set_link (struct pmd_internals *intl,bool val) +{ +int reg; +struct mdio_if_info *if_info; + +if (!intl->max_eth) +return 0 ; + + if_info = &intl->eth_node[0 ].if_info; + + reg =nfb_mdio_if_read_pma (if_info,NFB_MDIO_PMA_CTRL ); +if (reg <0 ) +return reg; + +/* Update PMA Reset flag if necessary (Reset flag set means link down) */ +if ((reg &NFB_MDIO_PMA_CTRL_RESET ) != (val ?0 :NFB_MDIO_PMA_CTRL_RESET )) { + reg ^=NFB_MDIO_PMA_CTRL_RESET ; +return nfb_mdio_if_write_pma (if_info,NFB_MDIO_PMA_CTRL , reg); + } +return 0 ; +} +/** * DPDK callback to bring the link UP. *
@@ -422,17 +445,16 @@ nfb_eth_link_update(struct rte_eth_dev *dev,static int nfb_eth_dev_set_link_up (struct rte_eth_dev *dev) { -struct pmd_internals *internals = (struct pmd_internals *) - dev->process_private; - +struct pmd_internals *internals = dev->process_private;uint16_t i; +for (i =0 ; i < internals->max_rxmac; ++i)nc_rxmac_enable (internals->rxmac[i]);for (i =0 ; i < internals->max_txmac; ++i)nc_txmac_enable (internals->txmac[i]); -return 0 ; +return nfb_eth_dev_set_link (internals, true); }/**
@@ -447,17 +469,17 @@ nfb_eth_dev_set_link_up(struct rte_eth_dev *dev)static int nfb_eth_dev_set_link_down (struct rte_eth_dev *dev) { -struct pmd_internals *internals = (struct pmd_internals *) - dev->process_private; +struct pmd_internals *internals = dev->process_private;uint16_t i; +for (i =0 ; i < internals->max_rxmac; ++i)nc_rxmac_disable (internals->rxmac[i]);for (i =0 ; i < internals->max_txmac; ++i)nc_txmac_disable (internals->txmac[i]); -return 0 ; +return nfb_eth_dev_set_link (internals, false); } static uint64_t
Signature · 1 line
2.53.0
PATCH 4/7 net/nfb: support setting RS-FEC mode
In reply to [email protected]From: Martin Spinler <[email protected]>
Enable basic configuration of the RS-FEC link mode over MDIO.
--- drivers/net/nfb/nfb_ethdev.c | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/net/nfb/nfb_ethdev.c +62 -0
@@ -575,6 +575,66 @@ nfb_eth_fw_version_get(struct rte_eth_dev *dev, char *fw_version,return 0 ; } +static int +nfb_eth_fec_get (struct rte_eth_dev *dev,uint32_t *fec_capa) +{ +int reg; +struct pmd_internals *intl = dev->process_private; +struct mdio_if_info *if_info; + + *fec_capa =0 ; +if (!intl->max_eth) +return 0 ; + + if_info = &intl->eth_node[0 ].if_info; + + reg =nfb_mdio_if_read_pma (if_info,NFB_MDIO_PMA_RSFEC_CR ); +if (reg <0 ) +return -EIO ; + + *fec_capa = (reg &NFB_MDIO_PMA_RSFEC_CR_ENABLE ) ? +RTE_ETH_FEC_MODE_CAPA_MASK (RS ) : +RTE_ETH_FEC_MODE_CAPA_MASK (NOFEC ); + +return 0 ; +} + +static int +nfb_eth_fec_set (struct rte_eth_dev *dev,uint32_t fec_capa) +{ +int ret; +uint32_t fec_capa2 =0 ; +int reg; + +struct pmd_internals *intl = dev->process_private; +struct mdio_if_info *if_info; + +if (!intl->max_eth) +return 0 ; + + if_info = &intl->eth_node[0 ].if_info; + +if (fec_capa &RTE_ETH_FEC_MODE_CAPA_MASK (AUTO )) +return -EINVAL ; + + reg =nfb_mdio_if_read_pma (if_info,NFB_MDIO_PMA_RSFEC_CR ); +if (reg <0 ) +return -EIO ; + + reg = (fec_capa &RTE_ETH_FEC_MODE_CAPA_MASK (RS )) ? + (reg |NFB_MDIO_PMA_RSFEC_CR_ENABLE ) : + (reg & ~NFB_MDIO_PMA_RSFEC_CR_ENABLE ); +nfb_mdio_if_write_pma (if_info,NFB_MDIO_PMA_RSFEC_CR , reg); + ret =nfb_eth_fec_get (dev, &fec_capa2); +if (ret) +return ret; + +if (fec_capa != fec_capa2) +return -EINVAL ; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = nfb_eth_dev_start, .dev_stop = nfb_eth_dev_stop,
@@ -602,6 +662,8 @@ static const struct eth_dev_ops ops = { .mac_addr_add = nfb_eth_mac_addr_add, .mac_addr_remove = nfb_eth_mac_addr_remove, .fw_version_get = nfb_eth_fw_version_get, + .fec_get = nfb_eth_fec_get, + .fec_set = nfb_eth_fec_set, };/**
Signature · 1 line
2.53.0
PATCH 5/7 net/nfb: support setting Rx MTU
In reply to [email protected]From: Martin Spinler <[email protected]>
Enable configuration of the MTU on the Rx MAC assigned to the port.
--- drivers/net/nfb/nfb_ethdev.c | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/net/nfb/nfb_ethdev.c +39 -0
@@ -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,
Signature · 1 line
2.53.0
Re: [PATCH 5/7] net/nfb: support setting Rx MTU
drivers/net/nfb/nfb_ethdev.c nfb_eth_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) · line 567
Quoted 10 lines · On Fri, 6 Feb 2026 18:04:33 +0100 [email protected] wrote:
drivers/net/nfb/nfb_ethdev.c +10
-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 ; +
Since mtu is 16 bit value, you need to use uint32_t to avoid overflow.
Something like:
+ uint32_t frame_len = (uint32_t)mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+ if (frame_len > priv->frame_len_max_cap)
+ return -EINVAL;
+ for (i = 0; i < intl->max_rxmac; ++i)
+ nc_rxmac_set_frame_length(intl->rxmac[i], frame_len, RXMAC_FRAME_LENGTH_MAX);
Re: [PATCH 5/7] net/nfb: support setting Rx MTU
Review
Quoted 10 lines
Since mtu is 16 bit value, you need to use
uint32_tto avoid overflow.Something like:
(quoted diff) +5
-0+ uint32_t frame_len = (uint32_t)mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; + if (frame_len > priv->frame_len_max_cap) + return -EINVAL; + for (i = 0; i < intl->max_rxmac; ++i) + nc_rxmac_set_frame_length(intl->rxmac[i], frame_len, RXMAC_FRAME_LENGTH_MAX);
Thank you, this check is cleaner.
PATCH 6/7 net/nfb: read total stats from macs
In reply to [email protected]From: Martin Spinler <[email protected]>
Both the Rx and Tx MAC components in firmware provide basic statistics. Use these statistics instead of the sum of the per-queue counters.
--- drivers/net/nfb/nfb_stats.c | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-)
drivers/net/nfb/nfb_stats.c +25 -15
@@ -14,11 +14,11 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,uint16_t i;uint16_t nb_rx = dev->data->nb_rx_queues;uint16_t nb_tx = dev->data->nb_tx_queues; -uint64_t rx_total =0 ; -uint64_t tx_total =0 ; -uint64_t tx_err_total =0 ; -uint64_t rx_total_bytes =0 ; -uint64_t tx_total_bytes =0 ; + +int ret; +struct pmd_internals *internals = dev->process_private; +struct nc_rxmac_counters rx_cntrs; +struct nc_txmac_counters tx_cntrs;struct ndp_rx_queue *rx_queue;struct ndp_tx_queue *tx_queue;
@@ -29,8 +29,6 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, qstats->q_ipackets[i] = rx_queue->rx_pkts; qstats->q_ibytes[i] = rx_queue->rx_bytes; } - rx_total += rx_queue->rx_pkts; - rx_total_bytes += rx_queue->rx_bytes; }for (i =0 ; i < nb_tx; i++) {
@@ -39,16 +37,28 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, qstats->q_opackets[i] = tx_queue->tx_pkts; qstats->q_obytes[i] = tx_queue->tx_bytes; } - tx_total += tx_queue->tx_pkts; - tx_total_bytes += tx_queue->tx_bytes; - tx_err_total += tx_queue->err_pkts; } - stats->ipackets = rx_total; - stats->opackets = tx_total; - stats->ibytes = rx_total_bytes; - stats->obytes = tx_total_bytes; - stats->oerrors = tx_err_total; +for (i =0 ; i < internals->max_rxmac; i++) { + ret =nc_rxmac_read_counters (internals->rxmac[i], &rx_cntrs,NULL ); +if (ret) +return -EIO ; + + stats->ipackets += rx_cntrs.cnt_received; + stats->ibytes += rx_cntrs.cnt_octets; + stats->ierrors += rx_cntrs.cnt_drop - rx_cntrs.cnt_overflowed; + stats->imissed += rx_cntrs.cnt_overflowed; + } + +for (i =0 ; i < internals->max_txmac; i++) { + ret =nc_txmac_read_counters (internals->txmac[i], &tx_cntrs); +if (ret) +return -EIO ; + + stats->opackets += tx_cntrs.cnt_sent; + stats->obytes += tx_cntrs.cnt_octets; + stats->oerrors += tx_cntrs.cnt_drop; + }return 0 ; }
Signature · 1 line
2.53.0
PATCH 7/7 doc/nfb: update release notes for nfb driver
In reply to [email protected]From: Martin Spinler <[email protected]>
Update the release notes for the NFB driver with Link Up / Link Down, RS-FEC, Rx MTU configuration and link speed status features.
--- doc/guides/rel_notes/release_26_03.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_26_03.rst +2 -1
@@ -64,9 +64,10 @@ New Features * The timestamp value has been updated to make it usable. * The DPDK port now represents just one Ethernet port instead of all Ethernet ports on the NIC. * All ports are used by default, but a subset can be selected using the ``port`` argument. - * Report firmware version. + * Report firmware version and correct Ethernet link speed. * Common CESNET-NDK-based adapters have been added, including the FB2CGHH (Silicom Denmark) and XpressSX AGI-FH400G (Reflex CES). + * Added support for configuration of the RS-FEC mode, Link Up / Link Down state, and the Rx MTU. Removed Items
Signature · 1 line
2.53.0
Re: [PATCH 7/7] doc/nfb: update release notes for nfb driver
Quoted 15 lines · On Fri, 6 Feb 2026 18:04:35 +0100 [email protected] wrote:
From: Martin Spinler <[email protected]>
Update the release notes for the NFB driver with Link Up / Link Down, RS-FEC, Rx MTU configuration and link speed status features.
Signed-off-by Martin Spinler <[email protected]>--- doc/guides/rel_notes/release_26_03.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)doc/guides/rel_notes/release_26_03.rst +0
-0
doc/guides/rel_notes/release_26_03.rst New Features · line 71
Quoted 9 lines
doc/guides/rel_notes/release_26_03.rst +2
-1@@ -64,9 +64,10 @@ New Features * The timestamp value has been updated to make it usable. * The DPDK port now represents just one Ethernet port instead of all Ethernet ports on the NIC. * All ports are used by default, but a subset can be selected using the ``port`` argument. - * Report firmware version. + * Report firmware version and correct Ethernet link speed. * Common CESNET-NDK-based adapters have been added, including the FB2CGHH (Silicom Denmark) and XpressSX AGI-FH400G (Reflex CES). + * Added support for configuration of the RS-FEC mode, Link Up / Link Down state, and the Rx MTU.
Please just update each item as part of the matching patch. The Depends-on mechanism doesn't work well with current CI.
Quoted 17 lines · On Fri, 6 Feb 2026 18:04:28 +0100 [email protected] wrote:
From: Martin Spinler <[email protected]>
This set includes minor enhancements to the Ethernet configuration and overall usage.
---
Depends-on: series-37261 ("net/nfb: rework to real multiport")Martin Spinler (7):
net/nfb: use MAC address assigned to card
net/nfb: get correct link speed
net/nfb: support real link-up/down config
net/nfb: support setting RS-FEC mode
net/nfb: support setting Rx MTU
net/nfb: read total stats from macs
doc/nfb: update release notes for nfb driver
Quoted 11 lines
doc/guides/rel_notes/release_26_03.rst | 3 +- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 7 + drivers/net/nfb/nfb_ethdev.c | 228 +++++++++++++++++++++---- drivers/net/nfb/nfb_mdio.c | 42 +++++ drivers/net/nfb/nfb_mdio.h | 34 ++++ drivers/net/nfb/nfb_stats.c | 40 +++-- 7 files changed, 308 insertions(+), 47 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
The CI and I don't have hardware to do deep check so have to rely on my and AI review.
Bundle 1747 (Feature Additions - 7 patches)
3 Critical Issues:
Patch 2: MDIO resource leak on error path - opened handles not closed Patch 3: Missing NULL check before accessing eth_node[0] Patch 4: Same NULL check issue in FEC get/set functions
Quick Summary: The feature additions are mostly solid. The main issue is a consistent pattern of accessing eth_node[0] without verifying the pointer is non-NULL. One resource leak needs cleanup code added.
Detailed output:
# NFB Driver Review - Bundle 1747 (Feature Additions)
## Series: 7 patches adding MAC, link speed, FEC, MTU, and stats features
---
## PATCH 1/7: net/nfb: use MAC address assigned to card
**Subject**: net/nfb: use MAC address assigned to card (47 chars) ✓
### Summary
Retrieves MAC address from card firmware via nc_ifc_get_default_mac() instead of always generating random MAC with OUI prefix.
### Status: ✓ No errors found
This patch is clean. Falls back gracefully to random MAC generation if firmware MAC retrieval fails.
---
## PATCH 2/7: net/nfb: get correct link speed
**Subject**: net/nfb: get correct link speed (38 chars) ✓
### Summary
Adds MDIO infrastructure to read accurate link speed from PHY PMA registers instead of MAC status register. Introduces struct eth_node with MDIO interface info.
### Errors
**Error 1: Resource leak on error path**
```c
intl->eth_node[eth].if_info.dev = nc_mdio_open(intl->nfb, node, node_cp);
if (intl->eth_node[eth].if_info.dev) {
// ... set up interface info
eth++;
}
```Location: nfb_nc_eth_init(), loop at line ~126
If nc_mdio_open() succeeds for some iterations but then a later error occurs (e.g., memory allocation for subsequent MACs fails), the function jumps to error labels err_alloc_ethnode, err_alloc_txmac, or err_alloc_rxmac. None of these labels close the already-opened MDIO handles.
**Suggested fix**: Add cleanup loop before freeing eth_node:
```c
err_alloc_ethnode:
for (i = 0; i < eth; i++)
if (intl->eth_node[i].if_info.dev)
nc_mdio_close(intl->eth_node[i].if_info.dev);
free(intl->eth_node);
err_alloc_txmac:
free(intl->txmac);
err_alloc_rxmac:
free(intl->rxmac);
return ret;
```---
## PATCH 3/7: net/nfb: support real link-up/down config
**Subject**: net/nfb: support real link-up/down config (47 chars) ✓
### Summary
Implements actual PHY link control via MDIO PMA reset register (NFB_MDIO_PMA_CTRL) instead of just enabling/disabling MAC layer.
### Errors
**Error 1: Missing NULL check before array access**
```c
static int
nfb_eth_dev_set_link(struct pmd_internals *intl, bool val)
{
// ...
if (!intl->max_eth)
return 0;
if_info = &intl->eth_node[0].if_info; // <-- dereference without NULL check
```Location: nfb_eth_dev_set_link()
If intl->eth_node is NULL (allocation failed but not caught), this crashes. While initialization should guarantee that max_eth > 0 implies eth_node != NULL, defensive coding requires verification.
**Suggested fix**: Add NULL check:
```c
if (!intl->max_eth || !intl->eth_node)
return 0;
if_info = &intl->eth_node[0].if_info;
```---
## PATCH 4/7: net/nfb: support setting RS-FEC mode
**Subject**: net/nfb: support setting RS-FEC mode (44 chars) ✓
### Summary
Implements FEC (Forward Error Correction) get/set operations via MDIO PMA RS-FEC control register. Supports RS-FEC enable/disable; rejects AUTO mode.
### Errors
**Error 1: Same NULL check issue as Patch 3**
```c
static int
nfb_eth_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa)
{
// ...
if (!intl->max_eth)
return 0;
if_info = &intl->eth_node[0].if_info; // <-- dereference without NULL check
```Location: nfb_eth_fec_get() and nfb_eth_fec_set()
**Suggested fix**: Add NULL check in both functions:
```c
if (!intl->max_eth || !intl->eth_node)
return 0;
```---
## PATCH 5/7: net/nfb: support setting Rx MTU
**Subject**: net/nfb: support setting Rx MTU (38 chars) ✓
### Summary
Implements MTU setting by querying maximum frame length capability from all RX MACs, taking minimum, and configuring all MACs with requested MTU.
### Status: ✓ No errors found
The logic correctly handles the case of no RX MACs (if (!intl->max_rxmac) return 0), queries capability limits, validates against minimum capability, and applies MTU to all MACs.
One minor observation: status.frame_length_max_capable is initialized to 0, and the function checks frame_length_max_capable != 0 before rejecting MTU. This allows unlimited MTU if all MACs report 0 capability (meaning unlimited). This seems intentional.
---
## PATCH 6/7: net/nfb: read total stats from macs
**Subject**: net/nfb: read total stats from macs (41 chars) ✓
### Summary
Aggregates statistics from all MAC instances instead of reading from queues. Changes nfb_eth_stats_get() to sum across all RX/TX MACs.
### Status: ✓ No errors found
The aggregation logic is straightforward and correct. Iterates over all MACs and accumulates statistics into the stats structure.
---
## PATCH 7/7: doc/nfb: update release notes for nfb driver
**Subject**: doc/nfb: update release notes for nfb driver (52 chars) ✓
### Status: ✓ Not reviewed (documentation)
Documentation patch - should verify that release notes accurately describe all changes in the series.
---
## Summary - Bundle 1747
### Critical Issues: 3
1. **Patch 2/7**: Resource leak - MDIO handles not closed on error path in nfb_nc_eth_init()
2. **Patch 3/7**: Missing NULL check before accessing eth_node[0] in nfb_eth_dev_set_link()
3. **Patch 4/7**: Missing NULL check before accessing eth_node[0] in nfb_eth_fec_get() and nfb_eth_fec_set()
### All Patches: Format ✓
- Proper Signed-off-by tags ✓
- Subject lines within 60 chars ✓
- Commit message format correct ✓
---
## Recommended Actions
### Must Fix:
1. **Patch 2**: Add MDIO handle cleanup loop on error paths
2. **Patches 3-4**: Add NULL check for eth_node before accessing array element
### Pattern to Apply:
For all functions accessing intl->eth_node[0], use:
```c
if (!intl->max_eth || !intl->eth_node)
return 0; // or appropriate error code
```This defensive pattern prevents crashes if initialization invariants are violated.
Quoted 17 lines · On Fri, 6 Feb 2026 18:04:28 +0100 [email protected] wrote:
From: Martin Spinler <[email protected]>
This set includes minor enhancements to the Ethernet configuration and overall usage.
---
Depends-on: series-37261 ("net/nfb: rework to real multiport")Martin Spinler (7):
net/nfb: use MAC address assigned to card
net/nfb: get correct link speed
net/nfb: support real link-up/down config
net/nfb: support setting RS-FEC mode
net/nfb: support setting Rx MTU
net/nfb: read total stats from macs
doc/nfb: update release notes for nfb driver
Quoted 11 lines
doc/guides/rel_notes/release_26_03.rst | 3 +- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 7 + drivers/net/nfb/nfb_ethdev.c | 228 +++++++++++++++++++++---- drivers/net/nfb/nfb_mdio.c | 42 +++++ drivers/net/nfb/nfb_mdio.h | 34 ++++ drivers/net/nfb/nfb_stats.c | 40 +++-- 7 files changed, 308 insertions(+), 47 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
Less issues in this but AI did find some errors around checking values. AI is pickier than is fully required, just figured you might want to look at these. Since this patch depends on multiport
will defer this until that is updated.
The highest priority item is the unchecked MDIO read in nfb_mdio_cl45_pma_get_speed_capa() — a failed read gets silently interpreted as a capability bitmask, which could advertise nonsensical speeds to applications.
# Review: NFB PMD Enhancement Series (7 Patches)
**Series**: [PATCH 1/7] through [PATCH 7/7]
**Author**: Martin Spinler <[email protected]>
**Delegate**: Stephen Hemminger
This series adds hardware feature support to the NFB PMD, building on the multi-port architecture from the preceding series. It covers: card-assigned MAC addresses, MDIO-based link speed, PMA link up/down control, RS-FEC configuration, RX MTU setting, and MAC-counter-based statistics.
---
### Patch 2/7: net/nfb: get correct link speed
Introduces MDIO infrastructure (nfb_mdio.c / nfb_mdio.h), eth_node array in pmd_internals, and PMA register-based speed capability and link speed reporting.
**Error: nfb_mdio_cl45_pma_get_speed_capa() does not check for MDIO read failure**
```c
reg = nfb_mdio_if_read_pma(info, NFB_MDIO_PMA_SPEED_ABILITY);
for (i = 0; i < NFB_MDIO_WIDTH; i++) {
if (reg & NFB_MDIO_BIT(i))
*capa |= speed_ability[i];
}
```mdio_read can return negative values on error. A negative reg gets interpreted as a bitmask, producing garbage speed capability flags advertised to the application.
**Fix**: Check if (reg < 0) return; before the loop.
**Confidence**: ~85%.
**Warning: nfb_mdio.h missing include guard**
The header has no #ifndef _NFB_MDIO_H_ / #define _NFB_MDIO_H_ guard. Multiple or transitive inclusion could cause redefinition errors for the static inline functions and macros.
**Confidence**: ~80%.
**Warning: eth_node population loop lacks bounds check**
```c
intl->eth_node = calloc(ifc->eth_cnt, sizeof(*intl->eth_node));
// ...
eth = 0;
for (i = 0; i < mi->eth_cnt; i++) {
if (mi->eth[i].ifc != ifc->id)
continue;
// ... populate intl->eth_node[eth] ...
eth++;
}
```Allocated with ifc->eth_cnt elements. If the firmware map has more matching entries, eth overflows the allocation. Same pattern exists for rxm/txm in the base series, but this patch extends it to a third array.
**Confidence**: ~55%.
---
### Patch 3/7: net/nfb: support real link-up/down config
Adds PMA reset bit manipulation for link up/down.
**Warning: MACs left in inconsistent state on MDIO failure**
```c
for (i = 0; i < internals->max_rxmac; ++i)
nc_rxmac_enable(internals->rxmac[i]);
for (i = 0; i < internals->max_txmac; ++i)
nc_txmac_enable(internals->txmac[i]);
return nfb_eth_dev_set_link(internals, true);
```If the MDIO PMA write fails, the function returns an error but the MACs have already been enabled. The caller sees failure while the hardware is in a half-configured state (MACs enabled, PMA still in reset). The symmetric problem exists in set_link_down.
**Confidence**: ~65%.
---
### Patch 4/7: net/nfb: support setting RS-FEC mode
**Error: nfb_eth_fec_set() ignores MDIO write return value**
```c nfb_mdio_if_write_pma(if_info, NFB_MDIO_PMA_RSFEC_CR, reg); ret = nfb_eth_fec_get(dev, &fec_capa2); ```
The write return value is discarded. If the write fails, the code proceeds to read back and compare — which may coincidentally detect the failure, but the actual error code is lost and the user gets -EINVAL instead of -EIO.
**Fix**:
```c
ret = nfb_mdio_if_write_pma(if_info, NFB_MDIO_PMA_RSFEC_CR, reg);
if (ret < 0)
return -EIO;
```**Confidence**: ~75%.
---
### Patch 5/7: net/nfb: support setting Rx MTU
**Warning: uint16_t MTU addition can overflow**
```c mtu += RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; ```
mtu is uint16_t. Adding 18 bytes wraps around near UINT16_MAX. The driver sets max_rx_pktlen = (uint32_t)-1 in dev_info, so ethdev's validation won't reject unreasonably large MTU values.
**Fix**: Promote to uint32_t before the addition, or set a realistic max_rx_pktlen in dev_info_get.
**Confidence**: ~70%.
---
### Patch 6/7: net/nfb: read total stats from macs
**Warning: ierrors subtraction may underflow**
```c stats->ierrors += rx_cntrs.cnt_drop - rx_cntrs.cnt_overflowed; ```
If firmware counters are inconsistent and cnt_overflowed > cnt_drop, this produces a large wrapped unsigned value. A guard would be safer:
```c
if (rx_cntrs.cnt_drop >= rx_cntrs.cnt_overflowed)
stats->ierrors += rx_cntrs.cnt_drop - rx_cntrs.cnt_overflowed;
```**Confidence**: ~55%.
---
## Summary
| Severity | Patch | Finding | |----------|-------|---------| | **Error** | 2/7 | `nfb_mdio_cl45_pma_get_speed_capa()` doesn't check for negative MDIO read return — garbage speed capabilities on error | | **Error** | 4/7 | `nfb_eth_fec_set()` ignores MDIO write return value | | **Warning** | 2/7 | `nfb_mdio.h` missing include guard | | **Warning** | 2/7 | `eth_node` population loop lacks bounds check against allocated size | | **Warning** | 3/7 | `set_link_up`/`set_link_down` leaves MACs inconsistent if MDIO fails | | **Warning** | 5/7 | `uint16_t` MTU overflow; `max_rx_pktlen = (uint32_t)-1` lets it through | | **Warning** | 6/7 | `ierrors` subtraction can underflow |
Patches 1/7 and 7/7 have no issues.
v2 cover net/nfb: ethernet enhancements
In reply to [email protected]From: Martin Spinler <[email protected]>
This set includes minor enhancements to the Ethernet configuration and overall usage.
---
Depends-on: series-37385 ("net/nfb: rework to real multiport")
v2:
* P2/7: close MDIO handles in error path of nfb_nc_eth_init
* P2/7: add bounds check for eth_node population
* P2/7: add check for nfb_mdio_if_read_pma() return value
in nfb_mdio_cl45_pma_get_speed_capa()
* P2/7: add include guard to nfb_mdio.h
* P3/7: move nfb_eth_dev_set_link() (PMA configuration)
before MAC enable/disable call to avoid inconsistency on failure
* P4/7: add check for nfb_mdio_if_write_pma() return value
* P5/7: set dev_info->max_mtu
* P5/7: add frame_len_max_cap to struct pmd_priv; used in MTU configuration
* P5/7: extract nfb_mac_read_frame_len_max_cap() from nfb_eth_mtu_set()
* P5/7: check for MTU overflow
* P6/7: use direct value for stats->ierrors from rx_cntrs
* P7/7: remove this patch completely and distribute release notes update to matching patches
Martin Spinler (6):
net/nfb: use MAC address assigned to card
net/nfb: get correct link speed
net/nfb: support real link-up/down config
net/nfb: support setting RS-FEC mode
net/nfb: support setting Rx MTU
net/nfb: read total stats from macs
doc/guides/rel_notes/release_26_03.rst | 3 +- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 8 + drivers/net/nfb/nfb_ethdev.c | 247 +++++++++++++++++++++---- drivers/net/nfb/nfb_mdio.c | 44 +++++ drivers/net/nfb/nfb_mdio.h | 39 ++++ drivers/net/nfb/nfb_stats.c | 40 ++-- 7 files changed, 335 insertions(+), 47 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
Signature · 1 line
2.53.0
PATCH v2 1/6 net/nfb: use MAC address assigned to card
From: Martin Spinler <[email protected]>
Check for a specific MAC address assigned to a card.
If there is no assigned MAC address, then use a random MAC as fallback.
--- drivers/net/nfb/nfb_ethdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/nfb/nfb_ethdev.c +9 -4
@@ -11,6 +11,7 @@#include <nfb/nfb.h> #include <nfb/ndp.h> +#include <netcope/eth.h> #include <netcope/rxmac.h> #include <netcope/txmac.h>
@@ -665,10 +666,14 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data) goto err_malloc_mac_addrs; } -rte_eth_random_addr (eth_addr_init.addr_bytes); - eth_addr_init.addr_bytes[0 ] = eth_addr.addr_bytes[0 ]; - eth_addr_init.addr_bytes[1 ] = eth_addr.addr_bytes[1 ]; - eth_addr_init.addr_bytes[2 ] = eth_addr.addr_bytes[2 ]; + ret =nc_ifc_get_default_mac (internals->nfb, ifc->id, eth_addr_init.addr_bytes, +sizeof (eth_addr_init.addr_bytes)); +if (ret !=0 ) { +rte_eth_random_addr (eth_addr_init.addr_bytes); + eth_addr_init.addr_bytes[0 ] = eth_addr.addr_bytes[0 ]; + eth_addr_init.addr_bytes[1 ] = eth_addr.addr_bytes[1 ]; + eth_addr_init.addr_bytes[2 ] = eth_addr.addr_bytes[2 ]; + }nfb_eth_mac_addr_set (dev, ð_addr_init);rte_ether_addr_copy (ð_addr_init, &data->mac_addrs[0 ]);
Signature · 1 line
2.53.0
PATCH v2 2/6 net/nfb: get correct link speed
In reply to [email protected]From: Martin Spinler <[email protected]>
Read link speed capabilities and actual link speed from the MDIO registers.
--- doc/guides/rel_notes/release_26_03.rst | 2 +- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 7 +++ drivers/net/nfb/nfb_ethdev.c | 82 +++++++++++++++++++------- drivers/net/nfb/nfb_mdio.c | 44 ++++++++++++++ drivers/net/nfb/nfb_mdio.h | 39 ++++++++++++ 6 files changed, 153 insertions(+), 22 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
doc/guides/rel_notes/release_26_03.rst +1 -1
@@ -64,7 +64,7 @@ New Features * The timestamp value has been updated to make it usable. * The DPDK port now represents just one Ethernet port instead of all Ethernet ports on the NIC. * All ports are used by default, but a subset can be selected using the ``port`` argument. - * Report firmware version. + * Report firmware version and correct Ethernet link speed. * Common CESNET-NDK-based adapters have been added, including the FB2CGHH (Silicom Denmark) and XpressSX AGI-FH400G (Reflex CES).
drivers/net/nfb/meson.build +1 -0
@@ -21,6 +21,7 @@ sources = files( 'nfb_rxmode.c', 'nfb_stats.c', 'nfb_tx.c', + 'nfb_mdio.c', ) cflags += no_wvla_cflag
drivers/net/nfb/nfb.h +7 -0
@@ -11,6 +11,7 @@#include <nfb/ndp.h> #include <netcope/rxmac.h> #include <netcope/txmac.h> +#include <netcope/mdio_if_info.h> #include <netcope/info.h> extern int nfb_logtype;
@@ -50,6 +51,10 @@ extern int nfb_logtype;NFB_ARG_PORT "=<number>" \"" +struct eth_node { +struct mdio_if_info if_info;/**< MDIO interface handles */ +}; +/* * Handles obtained from the libnfb: each process must use own instance. * Stored inside dev->process_private.
@@ -57,8 +62,10 @@ extern int nfb_logtype;struct pmd_internals {uint16_t max_rxmac;/**< Count of valid rxmac items */ uint16_t max_txmac;/**< Count of valid txmac items */ +uint16_t max_eth;/**< Count of valid eth nodes */ struct nc_rxmac **rxmac;/**< Array of Rx MAC handles */ struct nc_txmac **txmac;/**< Array of Tx MAC handles */ +struct eth_node *eth_node;/**< Array of Eth nodes */ struct nfb_device *nfb;TAILQ_ENTRY (pmd_internals) eth_dev_list;/**< Item in list of all devices */
drivers/net/nfb/nfb_ethdev.c +61 -21
166 lines not on this page · raw message
drivers/net/nfb/nfb_mdio.c new file +44 -0
44 lines not on this page · raw message
drivers/net/nfb/nfb_mdio.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 CESNET, z.s.p.o. +*/ + +#ifndef _NFB_MDIO_H_ +#define _NFB_MDIO_H_ + +#include <stdint.h> +#include <rte_bitops.h> +#include <netcope/mdio_if_info.h> + + +#define NFB_MDIO_WIDTH (UINT16_WIDTH) +#define NFB_MDIO_BIT (nr) (UINT16_C(1) << (nr)) + +#define NFB_MDIO_DEV_PMA 1 + +#define NFB_MDIO_PMA_CTRL 0 +#define NFB_MDIO_PMA_CTRL_RESET NFB_MDIO_BIT(15) + +#define NFB_MDIO_PMA_SPEED_ABILITY 4 + +#define NFB_MDIO_PMA_RSFEC_CR 200 +#define NFB_MDIO_PMA_RSFEC_CR_ENABLE NFB_MDIO_BIT(2) + +static inline int nfb_mdio_if_read_pma (struct mdio_if_info *if_info,uint16_t addr) +{ +return if_info->mdio_read (if_info->dev, if_info->prtad,NFB_MDIO_DEV_PMA , addr); +} + +static inline int nfb_mdio_if_write_pma (struct mdio_if_info *if_info,uint16_t addr,uint16_t val) +{ +return if_info->mdio_write (if_info->dev, if_info->prtad,NFB_MDIO_DEV_PMA , addr, val); +} + +__rte_internal +void nfb_mdio_cl45_pma_get_speed_capa(struct mdio_if_info *if_info, uint32_t *capa); + +#endif /* _NFB_MDIO_H_ */
Signature · 1 line
2.53.0
PATCH v2 3/6 net/nfb: support real link-up/down config
In reply to [email protected]From: Martin Spinler <[email protected]>
Use the standard PMA reset bit in the MDIO registers to configure of the link-up/link-down state.
--- doc/guides/rel_notes/release_26_03.rst | 1 + drivers/net/nfb/nfb_ethdev.c | 42 +++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-)
doc/guides/rel_notes/release_26_03.rst +1 -0
@@ -67,6 +67,7 @@ New Features * Report firmware version and correct Ethernet link speed. * Common CESNET-NDK-based adapters have been added, including the FB2CGHH (Silicom Denmark) and XpressSX AGI-FH400G (Reflex CES). + * Added support for configuration of the Link Up / Link Down state. Removed Items
drivers/net/nfb/nfb_ethdev.c +37 -5
63 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 4/6 net/nfb: support setting RS-FEC mode
In reply to [email protected]From: Martin Spinler <[email protected]>
Enable basic configuration of the RS-FEC link mode over MDIO.
--- doc/guides/rel_notes/release_26_03.rst | 2 +- drivers/net/nfb/nfb_ethdev.c | 65 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_26_03.rst +1 -1
@@ -67,7 +67,7 @@ New Features * Report firmware version and correct Ethernet link speed. * Common CESNET-NDK-based adapters have been added, including the FB2CGHH (Silicom Denmark) and XpressSX AGI-FH400G (Reflex CES). - * Added support for configuration of the Link Up / Link Down state. + * Added support for configuration of the RS-FEC mode, Link Up / Link Down state. Removed Items
drivers/net/nfb/nfb_ethdev.c +65 -0
77 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 5/6 net/nfb: support setting Rx MTU
In reply to [email protected]From: Martin Spinler <[email protected]>
Enable configuration of the MTU on the Rx MAC assigned to the port. The max MTU value is also reported in dev_info.
--- doc/guides/rel_notes/release_26_03.rst | 4 +-- drivers/net/nfb/nfb.h | 1 + drivers/net/nfb/nfb_ethdev.c | 45 +++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-)
doc/guides/rel_notes/release_26_03.rst +2 -2
@@ -64,10 +64,10 @@ New Features * The timestamp value has been updated to make it usable. * The DPDK port now represents just one Ethernet port instead of all Ethernet ports on the NIC. * All ports are used by default, but a subset can be selected using the ``port`` argument. - * Report firmware version and correct Ethernet link speed. + * Report firmware version, correct Ethernet link speed and maximum capable MTU value. * Common CESNET-NDK-based adapters have been added, including the FB2CGHH (Silicom Denmark) and XpressSX AGI-FH400G (Reflex CES). - * Added support for configuration of the RS-FEC mode, Link Up / Link Down state. + * Added support for configuration of the RS-FEC mode, Link Up / Link Down state, and the Rx MTU. Removed Items
drivers/net/nfb/nfb.h +1 -0
@@ -84,6 +84,7 @@ struct pmd_priv {int *queue_map_rx;/** Mapping from DPDK TX queue index to firmware queue ID */ int *queue_map_tx; +uint16_t frame_len_max_cap;/**< Maximum length obtained from Rx MAC */ bool ready;/**< This structure is initialized for usage in secondary process */ };
drivers/net/nfb/nfb_ethdev.c +44 -1
87 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 6/6 net/nfb: read total stats from macs
In reply to [email protected]From: Martin Spinler <[email protected]>
Both the Rx and Tx MAC components in firmware provide basic statistics. Use these statistics instead of the sum of the per-queue counters.
--- drivers/net/nfb/nfb_stats.c | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-)
drivers/net/nfb/nfb_stats.c +25 -15
@@ -14,11 +14,11 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,uint16_t i;uint16_t nb_rx = dev->data->nb_rx_queues;uint16_t nb_tx = dev->data->nb_tx_queues; -uint64_t rx_total =0 ; -uint64_t tx_total =0 ; -uint64_t tx_err_total =0 ; -uint64_t rx_total_bytes =0 ; -uint64_t tx_total_bytes =0 ; + +int ret; +struct pmd_internals *internals = dev->process_private; +struct nc_rxmac_counters rx_cntrs; +struct nc_txmac_counters tx_cntrs;struct ndp_rx_queue *rx_queue;struct ndp_tx_queue *tx_queue;
@@ -29,8 +29,6 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, qstats->q_ipackets[i] = rx_queue->rx_pkts; qstats->q_ibytes[i] = rx_queue->rx_bytes; } - rx_total += rx_queue->rx_pkts; - rx_total_bytes += rx_queue->rx_bytes; }for (i =0 ; i < nb_tx; i++) {
@@ -39,16 +37,28 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, qstats->q_opackets[i] = tx_queue->tx_pkts; qstats->q_obytes[i] = tx_queue->tx_bytes; } - tx_total += tx_queue->tx_pkts; - tx_total_bytes += tx_queue->tx_bytes; - tx_err_total += tx_queue->err_pkts; } - stats->ipackets = rx_total; - stats->opackets = tx_total; - stats->ibytes = rx_total_bytes; - stats->obytes = tx_total_bytes; - stats->oerrors = tx_err_total; +for (i =0 ; i < internals->max_rxmac; i++) { + ret =nc_rxmac_read_counters (internals->rxmac[i], &rx_cntrs,NULL ); +if (ret) +return -EIO ; + + stats->ipackets += rx_cntrs.cnt_received; + stats->ibytes += rx_cntrs.cnt_octets; + stats->ierrors += rx_cntrs.cnt_erroneous; + stats->imissed += rx_cntrs.cnt_overflowed; + } + +for (i =0 ; i < internals->max_txmac; i++) { + ret =nc_txmac_read_counters (internals->txmac[i], &tx_cntrs); +if (ret) +return -EIO ; + + stats->opackets += tx_cntrs.cnt_sent; + stats->obytes += tx_cntrs.cnt_octets; + stats->oerrors += tx_cntrs.cnt_drop; + }return 0 ; }
Signature · 1 line
2.53.0
Stephen Hemminger
AppliedQuoted 33 lines · On Tue, 17 Feb 2026 12:03:18 +0100 [email protected] wrote:
From: Martin Spinler <[email protected]>
This set includes minor enhancements to the Ethernet configuration and overall usage.
---
Depends-on: series-37385 ("net/nfb: rework to real multiport")v2:
* P2/7: close MDIO handles in error path ofnfb_nc_eth_init
* P2/7: add bounds check foreth_nodepopulation
* P2/7: add check fornfb_mdio_if_read_pma()return valuein nfb_mdio_cl45_pma_get_speed_capa()* P2/7: add include guard to
nfb_mdio.h
* P3/7: movenfb_eth_dev_set_link()(PMA configuration)
before MAC enable/disable call to avoid inconsistency on failure
* P4/7: add check fornfb_mdio_if_write_pma()return value
* P5/7: setdev_info->max_mtu
* P5/7: addframe_len_max_capto structpmd_priv; used in MTU configuration
* P5/7: extractnfb_mac_read_frame_len_max_cap()fromnfb_eth_mtu_set()
* P5/7: check for MTU overflow
* P6/7: use direct value forstats->ierrorsfromrx_cntrs
* P7/7: remove this patch completely and distribute release notes update to matching patchesMartin Spinler (6):
net/nfb: use MAC address assigned to card
net/nfb: get correct link speed
net/nfb: support real link-up/down config
net/nfb: support setting RS-FEC mode
net/nfb: support setting Rx MTU
net/nfb: read total stats from macs
Quoted 11 lines
doc/guides/rel_notes/release_26_03.rst | 3 +- drivers/net/nfb/meson.build | 1 + drivers/net/nfb/nfb.h | 8 + drivers/net/nfb/nfb_ethdev.c | 247 +++++++++++++++++++++---- drivers/net/nfb/nfb_mdio.c | 44 +++++ drivers/net/nfb/nfb_mdio.h | 39 ++++ drivers/net/nfb/nfb_stats.c | 40 ++-- 7 files changed, 335 insertions(+), 47 deletions(-) create mode 100644 drivers/net/nfb/nfb_mdio.c create mode 100644 drivers/net/nfb/nfb_mdio.h
Queued all these to next-net with small change to avoid overflow when computing mtu.