From: spinler@cesnet.cz
To: dev@dpdk.org
Cc: Martin Spinler <spinler@cesnet.cz>
Subject: [PATCH v3 5/8] net/nfb: init only MACs associated with device
Date: Wed, 21 Jan 2026 18:03:30 +0100 [thread overview]
Message-ID: <20260121170333.272985-6-spinler@cesnet.cz> (raw)
In-Reply-To: <20260121170333.272985-1-spinler@cesnet.cz>
From: Martin Spinler <spinler@cesnet.cz>
Use information obtained from the new manner of creating NFB ethdevs
and initialize only RxMACs / TxMACs associated with actual ethdev.
This enables separated management and configuration of interface ports.
Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
drivers/net/nfb/nfb.h | 8 +-
drivers/net/nfb/nfb_ethdev.c | 141 +++++++++++++++++++----------------
2 files changed, 80 insertions(+), 69 deletions(-)
diff --git a/drivers/net/nfb/nfb.h b/drivers/net/nfb/nfb.h
index 605ea8e875..cfbc50251f 100644
--- a/drivers/net/nfb/nfb.h
+++ b/drivers/net/nfb/nfb.h
@@ -36,10 +36,6 @@ extern int nfb_logtype;
#define RTE_ETH_NDP_MAX_RX_QUEUES 32
#define RTE_ETH_NDP_MAX_TX_QUEUES 32
-/* Max index of rx/tx dmas */
-#define RTE_MAX_NC_RXMAC 256
-#define RTE_MAX_NC_TXMAC 256
-
#define RTE_NFB_DRIVER_NAME net_nfb
/* Device arguments */
@@ -56,8 +52,8 @@ extern int nfb_logtype;
struct pmd_internals {
uint16_t max_rxmac;
uint16_t max_txmac;
- struct nc_rxmac *rxmac[RTE_MAX_NC_RXMAC];
- struct nc_txmac *txmac[RTE_MAX_NC_TXMAC];
+ struct nc_rxmac **rxmac;
+ struct nc_txmac **txmac;
struct nfb_device *nfb;
TAILQ_ENTRY(pmd_internals) eth_dev_list;
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index f7c50ea3c4..59e5a51b58 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -44,81 +44,94 @@ static const struct rte_ether_addr eth_addr = {
};
/**
- * Open all RX DMA queues
+ * Open RX MAC components associated with current ifc
*
- * @param dev
- * Pointer to nfb device.
- * @param[out] rxmac
- * Pointer to output array of nc_rxmac
- * @param[out] max_rxmac
- * Pointer to output max index of rxmac
+ * @param priv
+ * Pointer to driver private structure
+ * @param params
+ * Pointer to init parameters structure
*/
-static void
-nfb_nc_rxmac_init(struct nfb_device *nfb,
- struct nc_rxmac *rxmac[RTE_MAX_NC_RXMAC],
- uint16_t *max_rxmac)
+static int
+nfb_nc_rxmac_init(struct pmd_internals *priv, struct nfb_init_params *params)
{
- *max_rxmac = 0;
- while ((rxmac[*max_rxmac] = nc_rxmac_open_index(nfb, *max_rxmac)))
- ++(*max_rxmac);
+ int i, j;
+ struct nc_ifc_info *ifc = params->ifc_info;
+ struct nc_ifc_map_info *mi = ¶ms->map_info;
+
+ priv->rxmac = rte_calloc("NFB RxMAC", ifc->eth_cnt, sizeof(*priv->rxmac), 0);
+ if (ifc->eth_cnt && priv->rxmac == NULL)
+ return -ENOMEM;
+
+ for (i = 0, j = 0; i < mi->eth_cnt && j < ifc->eth_cnt; i++) {
+ if (mi->eth[i].ifc != ifc->id)
+ continue;
+ priv->rxmac[j] = nc_rxmac_open(priv->nfb, mi->eth[i].node_rxmac);
+ if (priv->rxmac[j])
+ j++;
+ }
+
+ priv->max_rxmac = j;
+ return 0;
}
/**
- * Open all TX DMA queues
+ * Open TX MAC components associated with current ifc
*
- * @param dev
- * Pointer to nfb device.
- * @param[out] txmac
- * Pointer to output array of nc_txmac
- * @param[out] max_rxmac
- * Pointer to output max index of txmac
+ * @param priv
+ * Pointer to driver private structure
+ * @param params
+ * Pointer to init parameters structure
*/
-static void
-nfb_nc_txmac_init(struct nfb_device *nfb,
- struct nc_txmac *txmac[RTE_MAX_NC_TXMAC],
- uint16_t *max_txmac)
+static int
+nfb_nc_txmac_init(struct pmd_internals *priv, struct nfb_init_params *params)
{
- *max_txmac = 0;
- while ((txmac[*max_txmac] = nc_txmac_open_index(nfb, *max_txmac)))
- ++(*max_txmac);
+ int i, j;
+ struct nc_ifc_info *ifc = params->ifc_info;
+ struct nc_ifc_map_info *mi = ¶ms->map_info;
+
+ priv->txmac = rte_calloc("NFB TxMAC", ifc->eth_cnt, sizeof(*priv->txmac), 0);
+ if (ifc->eth_cnt && priv->txmac == NULL)
+ return -ENOMEM;
+
+ for (i = 0, j = 0; i < mi->eth_cnt && j < ifc->eth_cnt; i++) {
+ if (mi->eth[i].ifc != ifc->id)
+ continue;
+ priv->txmac[j] = nc_txmac_open(priv->nfb, mi->eth[i].node_txmac);
+ if (priv->txmac[j])
+ j++;
+ }
+
+ priv->max_txmac = j;
+ return 0;
}
/**
- * Close all RX DMA queues
- *
- * @param rxmac
- * Pointer to array of nc_rxmac
- * @param max_rxmac
- * Maximum index of rxmac
+ * Close all RX MAC components
+ * @param priv
+ * Pointer to driver private structure
*/
static void
-nfb_nc_rxmac_deinit(struct nc_rxmac *rxmac[RTE_MAX_NC_RXMAC],
- uint16_t max_rxmac)
+nfb_nc_rxmac_deinit(struct pmd_internals *priv)
{
uint16_t i;
- for (i = 0; i < max_rxmac; i++) {
- nc_rxmac_close(rxmac[i]);
- rxmac[i] = NULL;
- }
+ for (i = 0; i < priv->max_rxmac; i++)
+ nc_rxmac_close(priv->rxmac[i]);
+
+ rte_free(priv->rxmac);
}
/**
- * Close all TX DMA queues
- *
- * @param txmac
- * Pointer to array of nc_txmac
- * @param max_txmac
- * Maximum index of txmac
+ * Close all TX MAC components
+ * @param priv
+ * Pointer to driver private structure
*/
static void
-nfb_nc_txmac_deinit(struct nc_txmac *txmac[RTE_MAX_NC_TXMAC],
- uint16_t max_txmac)
+nfb_nc_txmac_deinit(struct pmd_internals *priv)
{
uint16_t i;
- for (i = 0; i < max_txmac; i++) {
- nc_txmac_close(txmac[i]);
- txmac[i] = NULL;
- }
+ for (i = 0; i < priv->max_txmac; i++)
+ nc_txmac_close(priv->txmac[i]);
+ rte_free(priv->txmac);
}
/**
@@ -335,7 +348,7 @@ nfb_eth_link_update(struct rte_eth_dev *dev,
link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
link.link_autoneg = RTE_ETH_LINK_SPEED_FIXED;
- if (internals->rxmac[0] != NULL) {
+ if (internals->max_rxmac) {
nc_rxmac_read_status(internals->rxmac[0], &status);
switch (status.speed) {
@@ -559,12 +572,12 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data)
max_rx_queues = ifc->rxq_cnt;
max_tx_queues = ifc->txq_cnt;
- nfb_nc_rxmac_init(internals->nfb,
- internals->rxmac,
- &internals->max_rxmac);
- nfb_nc_txmac_init(internals->nfb,
- internals->txmac,
- &internals->max_txmac);
+ ret = nfb_nc_rxmac_init(internals, params);
+ if (ret)
+ goto err_rxmac_init;
+ ret = nfb_nc_txmac_init(internals, params);
+ if (ret)
+ goto err_txmac_init;
/* Set rx, tx burst functions */
dev->rx_pkt_burst = nfb_eth_ndp_rx;
@@ -630,8 +643,10 @@ nfb_eth_dev_init(struct rte_eth_dev *dev, void *init_data)
err_malloc_mac_addrs:
rte_free(priv->queue_map_rx);
err_alloc_queue_map:
- nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
- nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
+ nfb_nc_txmac_deinit(internals);
+err_txmac_init:
+ nfb_nc_rxmac_deinit(internals);
+err_rxmac_init:
nfb_close(internals->nfb);
err_nfb_open:
@@ -660,8 +675,8 @@ nfb_eth_dev_uninit(struct rte_eth_dev *dev)
TAILQ_REMOVE(&nfb_eth_dev_list, internals, eth_dev_list);
- nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
- nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
+ nfb_nc_rxmac_deinit(internals);
+ nfb_nc_txmac_deinit(internals);
nfb_close(internals->nfb);
rte_free(internals);
--
2.52.0
next prev parent reply other threads:[~2026-01-21 17:04 UTC|newest]
Thread overview: 131+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 15:16 [PATCH 0/8] net/nfb: rework to real multiport spinler
2026-01-15 15:16 ` [PATCH 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-16 17:34 ` Stephen Hemminger
2026-01-20 15:16 ` Martin Spinler
2026-01-15 15:16 ` [PATCH 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-15 15:16 ` [PATCH 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-15 15:16 ` [PATCH 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-16 17:36 ` Stephen Hemminger
2026-01-20 15:16 ` Martin Spinler
2026-01-16 17:36 ` Stephen Hemminger
2026-01-16 17:37 ` Stephen Hemminger
2026-01-15 15:16 ` [PATCH 5/8] net/nfb: init only MACs associated with device spinler
2026-01-15 15:16 ` [PATCH 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-15 15:16 ` [PATCH 7/8] net/nfb: report firmware version spinler
2026-01-15 15:16 ` [PATCH 8/8] doc/nfb: cleanup and update guide spinler
2026-01-16 5:50 ` [PATCH 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-16 16:44 ` [PATCH v2 " spinler
2026-01-16 16:44 ` [PATCH v2 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-16 16:44 ` [PATCH v2 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-16 16:44 ` [PATCH v2 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-16 16:44 ` [PATCH v2 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-16 16:44 ` [PATCH v2 5/8] net/nfb: init only MACs associated with device spinler
2026-01-16 16:44 ` [PATCH v2 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-16 16:44 ` [PATCH v2 7/8] net/nfb: report firmware version spinler
2026-01-16 16:44 ` [PATCH v2 8/8] doc/nfb: cleanup and update guide spinler
2026-01-20 2:25 ` [PATCH v2 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-20 15:16 ` Martin Spinler
2026-01-21 17:03 ` [PATCH v3 " spinler
2026-01-21 17:03 ` [PATCH v3 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-21 17:03 ` [PATCH v3 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-21 17:03 ` [PATCH v3 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-21 17:40 ` Stephen Hemminger
2026-01-21 17:03 ` [PATCH v3 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-21 17:03 ` spinler [this message]
2026-01-21 17:03 ` [PATCH v3 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-21 17:03 ` [PATCH v3 7/8] net/nfb: report firmware version spinler
2026-01-21 17:03 ` [PATCH v3 8/8] doc/nfb: cleanup and update guide spinler
2026-01-21 17:41 ` Stephen Hemminger
2026-01-21 17:42 ` [PATCH v3 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-22 7:27 ` [PATCH v4 " spinler
2026-01-22 7:27 ` [PATCH v4 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-22 7:27 ` [PATCH v4 2/8] net/nfb: create ethdev for every eth port/channel spinler
2026-01-22 7:27 ` [PATCH v4 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-22 7:27 ` [PATCH v4 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-22 7:27 ` [PATCH v4 5/8] net/nfb: init only MACs associated with device spinler
2026-01-22 7:27 ` [PATCH v4 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-22 7:27 ` [PATCH v4 7/8] net/nfb: report firmware version spinler
2026-01-22 7:27 ` [PATCH v4 8/8] doc/nfb: cleanup and update guide spinler
2026-01-23 1:00 ` [PATCH v4 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-01-23 1:01 ` Stephen Hemminger
2026-01-23 1:14 ` Stephen Hemminger
2026-01-23 17:34 ` Martin Spinler
2026-01-23 17:22 ` [PATCH v5 " spinler
2026-01-23 17:22 ` [PATCH v5 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-01-23 17:22 ` [PATCH v5 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-01-27 0:37 ` Stephen Hemminger
2026-01-27 8:12 ` Martin Spinler
2026-01-27 14:09 ` Stephen Hemminger
2026-01-23 17:22 ` [PATCH v5 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-01-23 17:22 ` [PATCH v5 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-01-23 17:22 ` [PATCH v5 5/8] net/nfb: init only MACs associated with device spinler
2026-01-23 17:22 ` [PATCH v5 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-01-23 17:22 ` [PATCH v5 7/8] net/nfb: report firmware version spinler
2026-01-23 17:22 ` [PATCH v5 8/8] doc/nfb: cleanup and update guide spinler
2026-01-24 19:10 ` [REVIEW] " Stephen Hemminger
2026-01-24 19:19 ` [PATCH v5 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-02 15:34 ` [PATCH v6 " spinler
2026-02-02 15:34 ` [PATCH v6 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-02 17:50 ` Stephen Hemminger
2026-02-02 15:34 ` [PATCH v6 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-02 15:34 ` [PATCH v6 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-02 15:34 ` [PATCH v6 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-02 15:34 ` [PATCH v6 5/8] net/nfb: init only MACs associated with device spinler
2026-02-02 15:34 ` [PATCH v6 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-02 15:34 ` [PATCH v6 7/8] net/nfb: report firmware version spinler
2026-02-02 15:34 ` [PATCH v6 8/8] doc/nfb: cleanup and update guide spinler
2026-02-02 17:42 ` [REVIEW] " Stephen Hemminger
2026-02-02 17:51 ` Stephen Hemminger
2026-02-02 17:52 ` Stephen Hemminger
2026-02-02 17:54 ` Stephen Hemminger
2026-02-02 17:54 ` Stephen Hemminger
2026-02-04 12:31 ` [PATCH v7 0/8] net/nfb: rework to real multiport spinler
2026-02-04 12:31 ` [PATCH v7 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-04 12:31 ` [PATCH v7 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-04 12:31 ` [PATCH v7 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-04 12:31 ` [PATCH v7 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-04 12:31 ` [PATCH v7 5/8] net/nfb: init only MACs associated with device spinler
2026-02-04 12:31 ` [PATCH v7 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-04 12:31 ` [PATCH v7 7/8] net/nfb: report firmware version spinler
2026-02-04 12:31 ` [PATCH v7 8/8] doc/nfb: cleanup and update guide spinler
2026-02-10 0:35 ` [PATCH v7 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-13 18:53 ` Martin Špinler
2026-02-12 18:35 ` Stephen Hemminger
2026-02-13 18:53 ` Martin Špinler
2026-02-13 18:53 ` [PATCH v8 " spinler
2026-02-13 18:53 ` [PATCH v8 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-13 18:53 ` [PATCH v8 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-13 19:33 ` Stephen Hemminger
2026-02-13 18:53 ` [PATCH v8 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-13 18:53 ` [PATCH v8 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-13 18:53 ` [PATCH v8 5/8] net/nfb: init only MACs associated with device spinler
2026-02-13 18:53 ` [PATCH v8 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-13 18:53 ` [PATCH v8 7/8] net/nfb: report firmware version spinler
2026-02-13 18:53 ` [PATCH v8 8/8] doc/nfb: cleanup and update guide spinler
2026-02-13 19:39 ` [PATCH v8 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-13 20:13 ` Martin Špinler
2026-02-16 16:24 ` [PATCH v9 " spinler
2026-02-16 16:24 ` [PATCH v9 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-16 16:25 ` [PATCH v9 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-16 16:25 ` [PATCH v9 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-16 16:25 ` [PATCH v9 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-16 16:25 ` [PATCH v9 5/8] net/nfb: init only MACs associated with device spinler
2026-02-16 16:25 ` [PATCH v9 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-16 16:25 ` [PATCH v9 7/8] net/nfb: report firmware version spinler
2026-02-16 16:25 ` [PATCH v9 8/8] doc/nfb: cleanup and update guide spinler
2026-02-16 22:11 ` [PATCH v9 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-17 7:09 ` Martin Spinler
2026-02-17 7:10 ` [PATCH v10 " spinler
2026-02-17 7:10 ` [PATCH v10 1/8] net/nfb: prepare for indirect queue mapping scheme spinler
2026-02-17 7:10 ` [PATCH v10 2/8] net/nfb: create one ethdev per ethernet port spinler
2026-02-17 7:10 ` [PATCH v10 3/8] net/nfb: add vdev as alternative device probe method spinler
2026-02-17 7:10 ` [PATCH v10 4/8] net/nfb: add device argument "port" to limit used ports spinler
2026-02-17 7:10 ` [PATCH v10 5/8] net/nfb: init only MACs associated with device spinler
2026-02-17 7:10 ` [PATCH v10 6/8] net/nfb: add compatible cards to driver PCI ID table spinler
2026-02-17 7:10 ` [PATCH v10 7/8] net/nfb: report firmware version spinler
2026-02-17 7:10 ` [PATCH v10 8/8] doc/nfb: cleanup and update guide spinler
2026-03-13 16:48 ` Thomas Monjalon
2026-02-17 14:58 ` [PATCH v10 0/8] net/nfb: rework to real multiport Stephen Hemminger
2026-02-17 15:05 ` Martin Spinler
2026-02-17 15:22 ` Martin Spinler
2026-02-19 0:12 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260121170333.272985-6-spinler@cesnet.cz \
--to=spinler@cesnet.cz \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox