[PATCH v2 1/6] net/nfb: use MAC address assigned to card

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

Check for a specific MAC address assigned to a card.
If there is no assigned MAC address, then use a random MAC as fallback.

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
drivers/net/nfb/nfb_ethdev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 9737ccc65b..b99785cc22 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -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, &eth_addr_init);
rte_ether_addr_copy(&eth_addr_init, &data->mac_addrs[0]);
--
2.53.0