[PATCH v2 3/6] net/nfb: support real link-up/down config

spinler
2026-02-17T11:03:47Z

Use the standard PMA reset bit in the MDIO registers
to configure of the link-up/link-down state.

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
doc/guides/rel_notes/release_26_03.rst | 1 +
drivers/net/nfb/nfb_ethdev.c | 42 +++++++++++++++++++++++---
2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_03.rst b/doc/guides/rel_notes/release_26_03.rst
index d408551955..8a7e1010fb 100644
--- a/doc/guides/rel_notes/release_26_03.rst
+++ b/doc/guides/rel_notes/release_26_03.rst
@@ -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
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 9b173c0f89..abb108a280 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -426,6 +426,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.
*
@@ -438,10 +461,14 @@ 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;
-
+ int ret;
+ struct pmd_internals *internals = dev->process_private;
uint16_t i;
+
+ ret = nfb_eth_dev_set_link(internals, true);
+ if (ret)
+ return ret;
+
for (i = 0; i < internals->max_rxmac; ++i)
nc_rxmac_enable(internals->rxmac[i]);

@@ -463,10 +490,15 @@ 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;
+ int ret;
+ struct pmd_internals *internals = dev->process_private;

uint16_t i;
+
+ ret = nfb_eth_dev_set_link(internals, false);
+ if (ret)
+ return ret;
+
for (i = 0; i < internals->max_rxmac; ++i)
nc_rxmac_disable(internals->rxmac[i]);

--
2.53.0