* [PATCH 1/9] net/nfp: extract the function to allocate the PHY
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:32 ` [PATCH 2/9] net/nfp: extract the function to initialize the PF Chaoyong He
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
Extract the helper function to allocate the PHY representor port.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 86 ++++++++++++-------
1 file changed, 53 insertions(+), 33 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index f6557525c0..af5f7fa4af 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -798,26 +798,71 @@ nfp_flower_repr_priv_init(struct nfp_app_fw_flower *app_fw_flower,
}
}
+static int
+nfp_flower_phy_repr_alloc(struct nfp_net_hw_priv *hw_priv,
+ struct nfp_flower_representor *flower_repr,
+ const char *pci_name)
+{
+ int i;
+ int ret;
+ uint8_t id;
+ struct nfp_pf_dev *pf_dev;
+ struct nfp_repr_init repr_init;
+ struct nfp_eth_table_port *eth_port;
+ struct nfp_app_fw_flower *app_fw_flower;
+
+ pf_dev = hw_priv->pf_dev;
+ repr_init.hw_priv = hw_priv;
+ app_fw_flower = flower_repr->app_fw_flower;
+ for (i = 0; i < app_fw_flower->num_phyport_reprs; i++) {
+ id = nfp_function_id_get(pf_dev, i);
+ eth_port = &pf_dev->nfp_eth_table->ports[id];
+ flower_repr->repr_type = NFP_REPR_TYPE_PHYS_PORT;
+ flower_repr->port_id = nfp_flower_get_phys_port_id(eth_port->index);
+ flower_repr->nfp_idx = eth_port->index;
+ flower_repr->vf_id = i + 1;
+
+ /* Copy the real mac of the interface to the representor struct */
+ rte_ether_addr_copy(ð_port->mac_addr, &flower_repr->mac_addr);
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_p%d", pci_name, id);
+
+ /*
+ * Create a eth_dev for this representor.
+ * This will also allocate private memory for the device.
+ */
+ repr_init.flower_repr = flower_repr;
+ ret = rte_eth_dev_create(&pf_dev->pci_dev->device, flower_repr->name,
+ sizeof(struct nfp_flower_representor),
+ NULL, NULL, nfp_flower_repr_init, &repr_init);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Could not create eth_dev for repr.");
+ break;
+ }
+ }
+
+ if (i < app_fw_flower->num_phyport_reprs)
+ return -EIO;
+
+ return 0;
+}
+
static int
nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_net_hw_priv *hw_priv)
{
int i;
int ret;
- uint8_t id;
const char *pci_name;
struct nfp_pf_dev *pf_dev;
struct rte_pci_device *pci_dev;
struct nfp_repr_init repr_init;
- struct nfp_eth_table *nfp_eth_table;
- struct nfp_eth_table_port *eth_port;
struct nfp_flower_representor flower_repr = {
.switch_domain_id = app_fw_flower->switch_domain_id,
.app_fw_flower = app_fw_flower,
};
pf_dev = hw_priv->pf_dev;
- nfp_eth_table = pf_dev->nfp_eth_table;
repr_init.hw_priv = hw_priv;
/* Send a NFP_FLOWER_CMSG_TYPE_MAC_REPR cmsg to hardware */
@@ -855,36 +900,11 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
}
/* Create a rte_eth_dev for every phyport representor */
- for (i = 0; i < app_fw_flower->num_phyport_reprs; i++) {
- id = nfp_function_id_get(pf_dev, i);
- eth_port = &nfp_eth_table->ports[id];
- flower_repr.repr_type = NFP_REPR_TYPE_PHYS_PORT;
- flower_repr.port_id = nfp_flower_get_phys_port_id(eth_port->index);
- flower_repr.nfp_idx = eth_port->index;
- flower_repr.vf_id = i + 1;
- flower_repr.idx = id;
-
- /* Copy the real mac of the interface to the representor struct */
- rte_ether_addr_copy(ð_port->mac_addr, &flower_repr.mac_addr);
- snprintf(flower_repr.name, sizeof(flower_repr.name),
- "%s_repr_p%d", pci_name, id);
-
- /*
- * Create a eth_dev for this representor.
- * This will also allocate private memory for the device.
- */
- repr_init.flower_repr = &flower_repr;
- ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name,
- sizeof(struct nfp_flower_representor),
- NULL, NULL, nfp_flower_repr_init, &repr_init);
- if (ret != 0) {
- PMD_INIT_LOG(ERR, "Could not create eth_dev for repr.");
- break;
- }
- }
-
- if (i < app_fw_flower->num_phyport_reprs)
+ ret = nfp_flower_phy_repr_alloc(hw_priv, &flower_repr, pci_name);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init the phy repr.");
goto repr_free;
+ }
/*
* Now allocate eth_dev's for VF representors.
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/9] net/nfp: extract the function to initialize the PF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
2024-10-21 6:32 ` [PATCH 1/9] net/nfp: extract the function to allocate the PHY Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:32 ` [PATCH 3/9] net/nfp: extract the function to allocate PF Chaoyong He
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
Extract the helper function to initialize the basic information
of the PF representor port.
The logic of check VF is updated because of changing the order
of some logics in the initialization function.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 114 +++++++++++-------
drivers/net/nfp/nfp_net_common.c | 2 +-
2 files changed, 71 insertions(+), 45 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index af5f7fa4af..f76e780840 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -389,6 +389,12 @@ nfp_flower_repr_close_queue(struct rte_eth_dev *eth_dev,
}
}
+static void
+nfp_flower_repr_base_uninit(struct nfp_flower_representor *repr)
+{
+ rte_free(repr->repr_xstats_base);
+}
+
static int
nfp_flower_repr_uninit(struct rte_eth_dev *eth_dev)
{
@@ -396,7 +402,7 @@ nfp_flower_repr_uninit(struct rte_eth_dev *eth_dev)
struct nfp_flower_representor *repr;
repr = eth_dev->data->dev_private;
- rte_free(repr->repr_xstats_base);
+ nfp_flower_repr_base_uninit(repr);
rte_free(repr->ring);
if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT) {
@@ -616,6 +622,63 @@ nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev,
return 0;
}
+static int
+nfp_flower_repr_base_init(struct rte_eth_dev *eth_dev,
+ struct nfp_flower_representor *repr,
+ struct nfp_repr_init *repr_init)
+{
+ int ret;
+ struct nfp_flower_representor *init_repr_data;
+
+ /* Cast the input representor data to the correct struct here */
+ init_repr_data = repr_init->flower_repr;
+
+ /* Copy data here from the input representor template */
+ repr->vf_id = init_repr_data->vf_id;
+ repr->switch_domain_id = init_repr_data->switch_domain_id;
+ repr->port_id = init_repr_data->port_id;
+ repr->nfp_idx = init_repr_data->nfp_idx;
+ repr->repr_type = init_repr_data->repr_type;
+ repr->app_fw_flower = init_repr_data->app_fw_flower;
+
+ snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
+
+ /* This backer port is that of the eth_device created for the PF vNIC */
+ eth_dev->data->backer_port_id = 0;
+
+ /* Allocating memory for mac addr */
+ eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
+ if (eth_dev->data->mac_addrs == NULL) {
+ PMD_INIT_LOG(ERR, "Failed to allocate memory for repr MAC.");
+ return -ENOMEM;
+ }
+
+ rte_ether_addr_copy(&init_repr_data->mac_addr, &repr->mac_addr);
+ rte_ether_addr_copy(&init_repr_data->mac_addr, eth_dev->data->mac_addrs);
+
+ /* Send reify message to hardware to inform it about the new repr */
+ ret = nfp_flower_cmsg_repr_reify(init_repr_data->app_fw_flower, repr);
+ if (ret != 0) {
+ PMD_INIT_LOG(WARNING, "Failed to send repr reify message.");
+ goto mac_cleanup;
+ }
+
+ /* Allocate memory for extended statistics counters */
+ repr->repr_xstats_base = rte_zmalloc("rte_eth_xstat",
+ sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
+ if (repr->repr_xstats_base == NULL) {
+ PMD_INIT_LOG(ERR, "No memory for xstats base on device %s!", repr->name);
+ ret = -ENOMEM;
+ goto mac_cleanup;
+ }
+
+ return 0;
+
+mac_cleanup:
+ rte_free(eth_dev->data->mac_addrs);
+ return ret;
+}
+
static int
nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
void *init_params)
@@ -654,50 +717,24 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
return -ENOMEM;
}
- /* Copy data here from the input representor template */
- repr->idx = init_repr_data->idx;
- repr->vf_id = init_repr_data->vf_id;
- repr->switch_domain_id = init_repr_data->switch_domain_id;
- repr->port_id = init_repr_data->port_id;
- repr->nfp_idx = init_repr_data->nfp_idx;
- repr->repr_type = init_repr_data->repr_type;
- repr->app_fw_flower = init_repr_data->app_fw_flower;
-
- strlcpy(repr->name, init_repr_data->name, sizeof(repr->name));
-
eth_dev->dev_ops = &nfp_flower_repr_dev_ops;
eth_dev->rx_pkt_burst = nfp_flower_repr_rx_burst;
eth_dev->tx_pkt_burst = nfp_flower_repr_tx_burst;
eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+ ret = nfp_flower_repr_base_init(eth_dev, repr, repr_init);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Flower repr base init failed.");
+ goto ring_cleanup;
+ }
+
if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT)
eth_dev->data->representor_id = repr->vf_id;
else
eth_dev->data->representor_id = repr->vf_id +
app_fw_flower->num_phyport_reprs + 1;
- /* This backer port is that of the eth_device created for the PF vNIC */
- eth_dev->data->backer_port_id = 0;
-
- /* Allocating memory for mac addr */
- eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
- if (eth_dev->data->mac_addrs == NULL) {
- PMD_INIT_LOG(ERR, "Failed to allocate memory for repr MAC.");
- ret = -ENOMEM;
- goto ring_cleanup;
- }
-
- rte_ether_addr_copy(&init_repr_data->mac_addr, &repr->mac_addr);
- rte_ether_addr_copy(&init_repr_data->mac_addr, eth_dev->data->mac_addrs);
-
- /* Send reify message to hardware to inform it about the new repr */
- ret = nfp_flower_cmsg_repr_reify(app_fw_flower, repr);
- if (ret != 0) {
- PMD_INIT_LOG(WARNING, "Failed to send repr reify message.");
- goto mac_cleanup;
- }
-
/* Add repr to correct array */
if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT) {
index = NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(repr->port_id);
@@ -712,19 +749,8 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
(repr->nfp_idx * NFP_MAC_STATS_SIZE);
}
- /* Allocate memory for extended statistics counters */
- repr->repr_xstats_base = rte_zmalloc("rte_eth_xstat",
- sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
- if (repr->repr_xstats_base == NULL) {
- PMD_INIT_LOG(ERR, "No memory for xstats base on device %s!", repr->name);
- ret = -ENOMEM;
- goto mac_cleanup;
- }
-
return 0;
-mac_cleanup:
- rte_free(eth_dev->data->mac_addrs);
ring_cleanup:
rte_free(repr->ring);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 766583d597..ccfb4b39f1 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1039,7 +1039,7 @@ nfp_net_xstats_size(const struct rte_eth_dev *dev)
if (rte_eth_dev_is_repr(dev)) {
repr = dev->data->dev_private;
- if (repr->mac_stats == NULL)
+ if (nfp_flower_repr_is_vf(repr))
vf_flag = true;
} else {
hw = dev->data->dev_private;
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/9] net/nfp: extract the function to allocate PF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
2024-10-21 6:32 ` [PATCH 1/9] net/nfp: extract the function to allocate the PHY Chaoyong He
2024-10-21 6:32 ` [PATCH 2/9] net/nfp: extract the function to initialize the PF Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:32 ` [PATCH 4/9] net/nfp: extract the function to allocate the VF Chaoyong He
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
Extract the helper function to allocate the PF representor port.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 58 ++++++++++++-------
1 file changed, 38 insertions(+), 20 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index f76e780840..2045076b4b 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -873,6 +873,41 @@ nfp_flower_phy_repr_alloc(struct nfp_net_hw_priv *hw_priv,
return 0;
}
+static int
+nfp_flower_pf_repr_alloc(struct nfp_net_hw_priv *hw_priv,
+ struct nfp_flower_representor *flower_repr,
+ const char *pci_name)
+{
+ int ret;
+ struct nfp_pf_dev *pf_dev;
+
+ pf_dev = hw_priv->pf_dev;
+
+ /* Create a rte_eth_dev for PF vNIC representor */
+ flower_repr->repr_type = NFP_REPR_TYPE_PF;
+
+ /* PF vNIC reprs get a random MAC address */
+ rte_eth_random_addr(flower_repr->mac_addr.addr_bytes);
+
+ if (pf_dev->multi_pf.enabled)
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_pf%d", pci_name, pf_dev->multi_pf.function_id);
+ else
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_pf", pci_name);
+
+ /* Create a eth_dev for this representor */
+ ret = rte_eth_dev_create(&pf_dev->pci_dev->device, flower_repr->name,
+ sizeof(struct nfp_flower_representor),
+ NULL, NULL, nfp_flower_pf_repr_init, flower_repr);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init the pf repr.");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int
nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_net_hw_priv *hw_priv)
@@ -898,31 +933,14 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
return ret;
}
- /* Create a rte_eth_dev for PF vNIC representor */
- flower_repr.repr_type = NFP_REPR_TYPE_PF;
- flower_repr.idx = 0;
-
- /* PF vNIC reprs get a random MAC address */
- rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
-
pci_dev = pf_dev->pci_dev;
pci_name = strchr(pci_dev->name, ':') + 1;
- if (pf_dev->multi_pf.enabled)
- snprintf(flower_repr.name, sizeof(flower_repr.name),
- "%s_repr_pf%d", pci_name, pf_dev->multi_pf.function_id);
- else
- snprintf(flower_repr.name, sizeof(flower_repr.name),
- "%s_repr_pf", pci_name);
-
- /* Create a eth_dev for this representor */
- ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name,
- sizeof(struct nfp_flower_representor),
- NULL, NULL, nfp_flower_pf_repr_init, &flower_repr);
+ ret = nfp_flower_pf_repr_alloc(hw_priv, &flower_repr, pci_name);
if (ret != 0) {
- PMD_INIT_LOG(ERR, "Failed to init the pf repr.");
- return -EINVAL;
+ PMD_INIT_LOG(ERR, "Could not alloc pf repr.");
+ return ret;
}
/* Create a rte_eth_dev for every phyport representor */
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/9] net/nfp: extract the function to allocate the VF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (2 preceding siblings ...)
2024-10-21 6:32 ` [PATCH 3/9] net/nfp: extract the function to allocate PF Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:32 ` [PATCH 5/9] net/nfp: revise the number of PF representor port Chaoyong He
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
Extract the helper function to allocate the VF representor ports.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 85 +++++++++++--------
1 file changed, 49 insertions(+), 36 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 2045076b4b..d49f02fc75 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -873,6 +873,49 @@ nfp_flower_phy_repr_alloc(struct nfp_net_hw_priv *hw_priv,
return 0;
}
+static int
+nfp_flower_vf_repr_alloc(struct nfp_net_hw_priv *hw_priv,
+ struct nfp_flower_representor *flower_repr,
+ const char *pci_name)
+{
+ int i;
+ int ret;
+ struct nfp_pf_dev *pf_dev;
+ struct nfp_repr_init repr_init;
+ struct nfp_app_fw_flower *app_fw_flower;
+
+ pf_dev = hw_priv->pf_dev;
+ repr_init.hw_priv = hw_priv;
+ app_fw_flower = flower_repr->app_fw_flower;
+ for (i = 0; i < app_fw_flower->num_vf_reprs; i++) {
+ flower_repr->repr_type = NFP_REPR_TYPE_VF;
+ flower_repr->port_id = nfp_get_pcie_port_id(pf_dev->cpp,
+ NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF, i + pf_dev->vf_base_id, 0);
+ flower_repr->nfp_idx = 0;
+ flower_repr->vf_id = i;
+
+ /* VF reprs get a random MAC address */
+ rte_eth_random_addr(flower_repr->mac_addr.addr_bytes);
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_vf%d", pci_name, i);
+
+ repr_init.flower_repr = flower_repr;
+ /* This will also allocate private memory for the device */
+ ret = rte_eth_dev_create(&pf_dev->pci_dev->device, flower_repr->name,
+ sizeof(struct nfp_flower_representor),
+ NULL, NULL, nfp_flower_repr_init, &repr_init);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Could not create eth_dev for repr.");
+ break;
+ }
+ }
+
+ if (i < app_fw_flower->num_vf_reprs)
+ return -EIO;
+
+ return 0;
+}
+
static int
nfp_flower_pf_repr_alloc(struct nfp_net_hw_priv *hw_priv,
struct nfp_flower_representor *flower_repr,
@@ -912,30 +955,21 @@ static int
nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_net_hw_priv *hw_priv)
{
- int i;
int ret;
const char *pci_name;
- struct nfp_pf_dev *pf_dev;
- struct rte_pci_device *pci_dev;
- struct nfp_repr_init repr_init;
struct nfp_flower_representor flower_repr = {
.switch_domain_id = app_fw_flower->switch_domain_id,
.app_fw_flower = app_fw_flower,
};
- pf_dev = hw_priv->pf_dev;
- repr_init.hw_priv = hw_priv;
-
/* Send a NFP_FLOWER_CMSG_TYPE_MAC_REPR cmsg to hardware */
- ret = nfp_flower_cmsg_mac_repr(app_fw_flower, pf_dev);
+ ret = nfp_flower_cmsg_mac_repr(app_fw_flower, hw_priv->pf_dev);
if (ret != 0) {
PMD_INIT_LOG(ERR, "Could not send mac repr cmsgs.");
return ret;
}
- pci_dev = pf_dev->pci_dev;
-
- pci_name = strchr(pci_dev->name, ':') + 1;
+ pci_name = strchr(hw_priv->pf_dev->pci_dev->name, ':') + 1;
ret = nfp_flower_pf_repr_alloc(hw_priv, &flower_repr, pci_name);
if (ret != 0) {
@@ -954,32 +988,11 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
* Now allocate eth_dev's for VF representors.
* Also send reify messages.
*/
- for (i = 0; i < app_fw_flower->num_vf_reprs; i++) {
- flower_repr.repr_type = NFP_REPR_TYPE_VF;
- flower_repr.port_id = nfp_get_pcie_port_id(pf_dev->cpp,
- NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF, i + pf_dev->vf_base_id, 0);
- flower_repr.nfp_idx = 0;
- flower_repr.vf_id = i;
- flower_repr.idx = 0;
-
- /* VF reprs get a random MAC address */
- rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
- snprintf(flower_repr.name, sizeof(flower_repr.name),
- "%s_repr_vf%d", pci_name, i);
-
- repr_init.flower_repr = &flower_repr;
- /* This will also allocate private memory for the device */
- ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name,
- sizeof(struct nfp_flower_representor),
- NULL, NULL, nfp_flower_repr_init, &repr_init);
- if (ret != 0) {
- PMD_INIT_LOG(ERR, "Could not create eth_dev for repr.");
- break;
- }
- }
-
- if (i < app_fw_flower->num_vf_reprs)
+ ret = nfp_flower_vf_repr_alloc(hw_priv, &flower_repr, pci_name);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init the vf repr.");
goto repr_free;
+ }
nfp_flower_repr_priv_init(app_fw_flower, hw_priv);
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/9] net/nfp: revise the number of PF representor port
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (3 preceding siblings ...)
2024-10-21 6:32 ` [PATCH 4/9] net/nfp: extract the function to allocate the VF Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:32 ` [PATCH 6/9] net/nfp: initialize the representor port of the multiple PF Chaoyong He
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
When using the multiple PF firmware, there is no need to
create the PF representor port anymore.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_representor.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index d49f02fc75..f769123174 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -1009,6 +1009,7 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_net_hw_priv *hw_priv)
{
int ret;
+ uint8_t num_pf_reprs;
struct nfp_pf_dev *pf_dev;
struct rte_pci_device *pci_dev;
struct rte_eth_devargs eth_da = {
@@ -1037,8 +1038,13 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
return 0;
}
- /* There always exist phy repr */
- if (eth_da.nb_representor_ports < pf_dev->total_phyports + 1) {
+ /* Calculate the number of pf repr */
+ if (pf_dev->multi_pf.enabled)
+ num_pf_reprs = 0;
+ else
+ num_pf_reprs = 1;
+
+ if (eth_da.nb_representor_ports < pf_dev->total_phyports + num_pf_reprs) {
PMD_INIT_LOG(ERR, "Should also create repr port for phy port and PF vNIC.");
return -ERANGE;
}
@@ -1052,7 +1058,7 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
/* Fill in flower app with repr counts */
app_fw_flower->num_phyport_reprs = pf_dev->total_phyports;
app_fw_flower->num_vf_reprs = eth_da.nb_representor_ports -
- pf_dev->total_phyports - 1;
+ pf_dev->total_phyports - num_pf_reprs;
if (pf_dev->max_vfs != 0 && pf_dev->sriov_vf < app_fw_flower->num_vf_reprs) {
PMD_INIT_LOG(ERR, "The VF repr nums %d is bigger than VF nums %d.",
app_fw_flower->num_vf_reprs, pf_dev->sriov_vf);
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 6/9] net/nfp: initialize the representor port of the multiple PF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (4 preceding siblings ...)
2024-10-21 6:32 ` [PATCH 5/9] net/nfp: revise the number of PF representor port Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:32 ` [PATCH 7/9] net/nfp: ignore useless message for " Chaoyong He
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
When using multiple PF firmware, add the process of initialize
the representor port and revise the corresponding logic in the
close function.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 80 ++++++++++++++++---
1 file changed, 69 insertions(+), 11 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index f769123174..c096862a0f 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -373,9 +373,15 @@ static void
nfp_flower_repr_close_queue(struct rte_eth_dev *eth_dev,
enum nfp_repr_type repr_type)
{
+ struct nfp_net_hw_priv *hw_priv;
+
switch (repr_type) {
case NFP_REPR_TYPE_PHYS_PORT:
- nfp_flower_repr_free_queue(eth_dev);
+ hw_priv = eth_dev->process_private;
+ if (hw_priv->pf_dev->multi_pf.enabled)
+ nfp_flower_pf_repr_close_queue(eth_dev);
+ else
+ nfp_flower_repr_free_queue(eth_dev);
break;
case NFP_REPR_TYPE_PF:
nfp_flower_pf_repr_close_queue(eth_dev);
@@ -757,6 +763,51 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
return ret;
}
+static int
+nfp_flower_multiple_pf_repr_init(struct rte_eth_dev *eth_dev,
+ void *init_params)
+{
+ int ret;
+ uint16_t index;
+ struct nfp_repr_init *repr_init;
+ struct nfp_net_hw_priv *hw_priv;
+ struct nfp_flower_representor *repr;
+ struct nfp_app_fw_flower *app_fw_flower;
+
+ /* Cast the input representor data to the correct struct here */
+ repr_init = init_params;
+ app_fw_flower = repr_init->flower_repr->app_fw_flower;
+
+ /* Memory has been allocated in the eth_dev_create() function */
+ repr = eth_dev->data->dev_private;
+ hw_priv = repr_init->hw_priv;
+
+ eth_dev->dev_ops = &nfp_flower_pf_repr_dev_ops;
+ eth_dev->rx_pkt_burst = nfp_net_recv_pkts;
+ eth_dev->tx_pkt_burst = nfp_flower_pf_xmit_pkts;
+ eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
+ RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
+
+ ret = nfp_flower_repr_base_init(eth_dev, repr, repr_init);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "Flower multiple PF repr base init failed.");
+ return -ENOMEM;
+ }
+
+ eth_dev->data->representor_id = repr->vf_id;
+
+ /* Add repr to correct array */
+ index = NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(repr->port_id);
+ app_fw_flower->phy_reprs[index] = repr;
+
+ repr->mac_stats = hw_priv->pf_dev->mac_stats_bar +
+ (repr->nfp_idx * NFP_MAC_STATS_SIZE);
+
+ app_fw_flower->pf_ethdev = eth_dev;
+
+ return 0;
+}
+
static void
nfp_flower_repr_free_all(struct nfp_app_fw_flower *app_fw_flower)
{
@@ -833,6 +884,7 @@ nfp_flower_phy_repr_alloc(struct nfp_net_hw_priv *hw_priv,
int ret;
uint8_t id;
struct nfp_pf_dev *pf_dev;
+ ethdev_init_t ethdev_init;
struct nfp_repr_init repr_init;
struct nfp_eth_table_port *eth_port;
struct nfp_app_fw_flower *app_fw_flower;
@@ -846,21 +898,29 @@ nfp_flower_phy_repr_alloc(struct nfp_net_hw_priv *hw_priv,
flower_repr->repr_type = NFP_REPR_TYPE_PHYS_PORT;
flower_repr->port_id = nfp_flower_get_phys_port_id(eth_port->index);
flower_repr->nfp_idx = eth_port->index;
- flower_repr->vf_id = i + 1;
/* Copy the real mac of the interface to the representor struct */
rte_ether_addr_copy(ð_port->mac_addr, &flower_repr->mac_addr);
- snprintf(flower_repr->name, sizeof(flower_repr->name),
- "%s_repr_p%d", pci_name, id);
/*
* Create a eth_dev for this representor.
* This will also allocate private memory for the device.
*/
repr_init.flower_repr = flower_repr;
+ if (pf_dev->multi_pf.enabled) {
+ repr_init.flower_repr->vf_id = i;
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_p", pci_name);
+ ethdev_init = nfp_flower_multiple_pf_repr_init;
+ } else {
+ repr_init.flower_repr->vf_id = i + 1;
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_p%d", pci_name, id);
+ ethdev_init = nfp_flower_repr_init;
+ }
ret = rte_eth_dev_create(&pf_dev->pci_dev->device, flower_repr->name,
sizeof(struct nfp_flower_representor),
- NULL, NULL, nfp_flower_repr_init, &repr_init);
+ NULL, NULL, ethdev_init, &repr_init);
if (ret != 0) {
PMD_INIT_LOG(ERR, "Could not create eth_dev for repr.");
break;
@@ -925,6 +985,8 @@ nfp_flower_pf_repr_alloc(struct nfp_net_hw_priv *hw_priv,
struct nfp_pf_dev *pf_dev;
pf_dev = hw_priv->pf_dev;
+ if (pf_dev->multi_pf.enabled)
+ return 0;
/* Create a rte_eth_dev for PF vNIC representor */
flower_repr->repr_type = NFP_REPR_TYPE_PF;
@@ -932,12 +994,8 @@ nfp_flower_pf_repr_alloc(struct nfp_net_hw_priv *hw_priv,
/* PF vNIC reprs get a random MAC address */
rte_eth_random_addr(flower_repr->mac_addr.addr_bytes);
- if (pf_dev->multi_pf.enabled)
- snprintf(flower_repr->name, sizeof(flower_repr->name),
- "%s_repr_pf%d", pci_name, pf_dev->multi_pf.function_id);
- else
- snprintf(flower_repr->name, sizeof(flower_repr->name),
- "%s_repr_pf", pci_name);
+ snprintf(flower_repr->name, sizeof(flower_repr->name),
+ "%s_repr_pf", pci_name);
/* Create a eth_dev for this representor */
ret = rte_eth_dev_create(&pf_dev->pci_dev->device, flower_repr->name,
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 7/9] net/nfp: ignore useless message for multiple PF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (5 preceding siblings ...)
2024-10-21 6:32 ` [PATCH 6/9] net/nfp: initialize the representor port of the multiple PF Chaoyong He
@ 2024-10-21 6:32 ` Chaoyong He
2024-10-21 6:33 ` [PATCH 8/9] net/nfp: add the new operations " Chaoyong He
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:32 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
When using the multiple PF firmware, there is no PF representor port,
so we also need not care about the corresponding control messages anymore.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_ctrl.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 3bf8b1f399..92887ce1be 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -436,10 +436,14 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
break;
case NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT:
index = NFP_FLOWER_CMSG_PORT_VNIC_OFFSET(port, hw_priv->pf_dev->vf_base_id);
- if (NFP_FLOWER_CMSG_PORT_VNIC_TYPE(port) == NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF)
- repr = app_fw_flower->vf_reprs[index];
- else
+ if (NFP_FLOWER_CMSG_PORT_VNIC_TYPE(port) == NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF) {
+ repr = app_fw_flower->vf_reprs[index];
+ } else {
+ if (hw_priv->pf_dev->multi_pf.enabled)
+ return 0;
+
repr = app_fw_flower->pf_repr;
+ }
break;
default:
PMD_DRV_LOG(ERR, "Ctrl msg for unknown port %#x.", port);
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 8/9] net/nfp: add the new operations for multiple PF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (6 preceding siblings ...)
2024-10-21 6:32 ` [PATCH 7/9] net/nfp: ignore useless message for " Chaoyong He
@ 2024-10-21 6:33 ` Chaoyong He
2024-10-21 6:33 ` [PATCH 9/9] net/nfp: update the Tx and Rx function " Chaoyong He
2024-10-29 23:34 ` [PATCH 0/9] support multiple PF flower firmware Ferruh Yigit
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:33 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
When using the multiple PF firmware, add the new
operations and update the port start and stop
function.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 21 ++++++++++++
drivers/net/nfp/flower/nfp_flower.h | 1 +
.../net/nfp/flower/nfp_flower_representor.c | 34 ++++++++++++++++++-
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index fd0a454432..df7a150a99 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -23,6 +23,20 @@
#define CTRL_VNIC_NB_DESC 512
+int
+nfp_flower_pf_stop(struct rte_eth_dev *dev)
+{
+ struct nfp_net_hw_priv *hw_priv;
+ struct nfp_flower_representor *repr;
+
+ repr = dev->data->dev_private;
+ hw_priv = dev->process_private;
+ nfp_flower_cmsg_port_mod(repr->app_fw_flower, repr->port_id, false);
+ (void)nfp_eth_set_configured(hw_priv->pf_dev->cpp, repr->nfp_idx, 0);
+
+ return nfp_net_stop(dev);
+}
+
int
nfp_flower_pf_start(struct rte_eth_dev *dev)
{
@@ -34,6 +48,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
struct nfp_net_hw *net_hw;
struct rte_eth_conf *dev_conf;
struct rte_eth_rxmode *rxmode;
+ struct nfp_net_hw_priv *hw_priv;
struct nfp_flower_representor *repr;
repr = dev->data->dev_private;
@@ -84,6 +99,12 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
return -EIO;
}
+ hw_priv = dev->process_private;
+ if (hw_priv->pf_dev->multi_pf.enabled) {
+ (void)nfp_eth_set_configured(hw_priv->pf_dev->cpp, repr->nfp_idx, 1);
+ nfp_flower_cmsg_port_mod(repr->app_fw_flower, repr->port_id, true);
+ }
+
for (i = 0; i < dev->data->nb_rx_queues; i++)
dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
for (i = 0; i < dev->data->nb_tx_queues; i++)
diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index 1dc868fb68..a257366656 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -116,6 +116,7 @@ bool nfp_flower_pf_dispatch_pkts(struct nfp_net_rxq *rxq,
uint16_t nfp_flower_pf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
int nfp_flower_pf_start(struct rte_eth_dev *dev);
+int nfp_flower_pf_stop(struct rte_eth_dev *dev);
uint32_t nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower,
struct rte_mbuf *mbuf, uint32_t port_id);
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index c096862a0f..6e957b125f 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -523,6 +523,38 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = {
.fw_version_get = nfp_net_firmware_version_get,
};
+static const struct eth_dev_ops nfp_flower_multiple_pf_repr_dev_ops = {
+ .dev_infos_get = nfp_flower_repr_dev_infos_get,
+
+ .dev_start = nfp_flower_pf_start,
+ .dev_configure = nfp_net_configure,
+ .dev_stop = nfp_flower_pf_stop,
+ .dev_close = nfp_flower_repr_dev_close,
+
+ .rx_queue_setup = nfp_net_rx_queue_setup,
+ .tx_queue_setup = nfp_net_tx_queue_setup,
+
+ .link_update = nfp_flower_repr_link_update,
+
+ .stats_get = nfp_flower_repr_stats_get,
+ .stats_reset = nfp_flower_repr_stats_reset,
+
+ .promiscuous_enable = nfp_net_promisc_enable,
+ .promiscuous_disable = nfp_net_promisc_disable,
+
+ .mac_addr_set = nfp_flower_repr_mac_addr_set,
+ .fw_version_get = nfp_net_firmware_version_get,
+
+ .flow_ops_get = nfp_flow_ops_get,
+ .mtr_ops_get = nfp_net_mtr_ops_get,
+
+ .xstats_get = nfp_net_xstats_get,
+ .xstats_reset = nfp_net_xstats_reset,
+ .xstats_get_names = nfp_net_xstats_get_names,
+ .xstats_get_by_id = nfp_net_xstats_get_by_id,
+ .xstats_get_names_by_id = nfp_net_xstats_get_names_by_id,
+};
+
static const struct eth_dev_ops nfp_flower_repr_dev_ops = {
.dev_infos_get = nfp_flower_repr_dev_infos_get,
@@ -782,7 +814,7 @@ nfp_flower_multiple_pf_repr_init(struct rte_eth_dev *eth_dev,
repr = eth_dev->data->dev_private;
hw_priv = repr_init->hw_priv;
- eth_dev->dev_ops = &nfp_flower_pf_repr_dev_ops;
+ eth_dev->dev_ops = &nfp_flower_multiple_pf_repr_dev_ops;
eth_dev->rx_pkt_burst = nfp_net_recv_pkts;
eth_dev->tx_pkt_burst = nfp_flower_pf_xmit_pkts;
eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 9/9] net/nfp: update the Tx and Rx function for multiple PF
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (7 preceding siblings ...)
2024-10-21 6:33 ` [PATCH 8/9] net/nfp: add the new operations " Chaoyong He
@ 2024-10-21 6:33 ` Chaoyong He
2024-10-29 23:34 ` [PATCH 0/9] support multiple PF flower firmware Ferruh Yigit
9 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-10-21 6:33 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Peng Zhang, Chaoyong He, Long Wu
From: Peng Zhang <peng.zhang@corigine.com>
Update the Tx function and Rx function for multiple PF and simplify the
Rx function to enhance the performance.
In the RX function, the packets are processed according the firmware type.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 70 +++++++++++++++++++
drivers/net/nfp/flower/nfp_flower.h | 6 ++
drivers/net/nfp/flower/nfp_flower_cmsg.h | 7 ++
.../net/nfp/flower/nfp_flower_representor.c | 4 +-
drivers/net/nfp/nfp_ethdev.c | 6 ++
drivers/net/nfp/nfp_ethdev_vf.c | 6 ++
drivers/net/nfp/nfp_net_common.c | 48 +++++++++++++
drivers/net/nfp/nfp_net_common.h | 4 ++
drivers/net/nfp/nfp_rxtx.c | 14 ++--
9 files changed, 158 insertions(+), 7 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index df7a150a99..f087d0dfdc 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -215,6 +215,76 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
return app_fw_flower->nfd_func.pf_xmit_t(tx_queue, tx_pkts, nb_pkts);
}
+uint16_t
+nfp_flower_multiple_pf_recv_pkts(void *rx_queue,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts)
+{
+ int i;
+ uint16_t recv;
+ uint32_t data_len;
+ struct nfp_net_rxq *rxq;
+ struct rte_eth_dev *repr_dev;
+ struct nfp_flower_representor *repr;
+
+ recv = nfp_net_recv_pkts(rx_queue, rx_pkts, nb_pkts);
+ if (recv != 0) {
+ /* Grab a handle to the representor struct */
+ rxq = rx_queue;
+ repr_dev = &rte_eth_devices[rxq->port_id];
+ repr = repr_dev->data->dev_private;
+
+ data_len = 0;
+ for (i = 0; i < recv; i++)
+ data_len += rx_pkts[i]->data_len;
+
+ repr->repr_stats.ipackets += recv;
+ repr->repr_stats.q_ipackets[rxq->qidx] += recv;
+ repr->repr_stats.q_ibytes[rxq->qidx] += data_len;
+ }
+
+ return recv;
+}
+
+uint16_t
+nfp_flower_multiple_pf_xmit_pkts(void *tx_queue,
+ struct rte_mbuf **tx_pkts,
+ uint16_t nb_pkts)
+{
+ int i;
+ uint16_t sent;
+ uint32_t data_len;
+ struct nfp_net_txq *txq;
+ struct rte_eth_dev *repr_dev;
+ struct nfp_flower_representor *repr;
+
+ txq = tx_queue;
+ if (unlikely(txq == NULL)) {
+ PMD_TX_LOG(ERR, "TX Bad queue.");
+ return 0;
+ }
+
+ /* Grab a handle to the representor struct */
+ repr_dev = &rte_eth_devices[txq->port_id];
+ repr = repr_dev->data->dev_private;
+ for (i = 0; i < nb_pkts; i++)
+ nfp_flower_pkt_add_metadata(repr->app_fw_flower,
+ tx_pkts[i], repr->port_id);
+
+ sent = nfp_flower_pf_xmit_pkts(tx_queue, tx_pkts, nb_pkts);
+ if (sent != 0) {
+ data_len = 0;
+ for (i = 0; i < sent; i++)
+ data_len += tx_pkts[i]->data_len;
+
+ repr->repr_stats.opackets += sent;
+ repr->repr_stats.q_opackets[txq->qidx] += sent;
+ repr->repr_stats.q_obytes[txq->qidx] += data_len;
+ }
+
+ return sent;
+}
+
static int
nfp_flower_init_vnic_common(struct nfp_net_hw_priv *hw_priv,
struct nfp_net_hw *hw,
diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index a257366656..7b919a939b 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -115,6 +115,12 @@ bool nfp_flower_pf_dispatch_pkts(struct nfp_net_rxq *rxq,
uint32_t port_id);
uint16_t nfp_flower_pf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
+uint16_t nfp_flower_multiple_pf_xmit_pkts(void *tx_queue,
+ struct rte_mbuf **tx_pkts,
+ uint16_t nb_pkts);
+uint16_t nfp_flower_multiple_pf_recv_pkts(void *rx_queue,
+ struct rte_mbuf **tx_pkts,
+ uint16_t nb_pkts);
int nfp_flower_pf_start(struct rte_eth_dev *dev);
int nfp_flower_pf_stop(struct rte_eth_dev *dev);
uint32_t nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower,
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index eda047a404..a7866e8382 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -1045,4 +1045,11 @@ int nfp_flower_cmsg_qos_delete(struct nfp_app_fw_flower *app_fw_flower,
int nfp_flower_cmsg_qos_stats(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_cfg_head *head);
+static inline bool
+nfp_flower_port_is_phy_port(uint32_t port_id)
+{
+ return (NFP_FLOWER_CMSG_PORT_TYPE(port_id) ==
+ NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT);
+}
+
#endif /* __NFP_CMSG_H__ */
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 6e957b125f..1f1b462b41 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -815,8 +815,8 @@ nfp_flower_multiple_pf_repr_init(struct rte_eth_dev *eth_dev,
hw_priv = repr_init->hw_priv;
eth_dev->dev_ops = &nfp_flower_multiple_pf_repr_dev_ops;
- eth_dev->rx_pkt_burst = nfp_net_recv_pkts;
- eth_dev->tx_pkt_burst = nfp_flower_pf_xmit_pkts;
+ eth_dev->rx_pkt_burst = nfp_flower_multiple_pf_recv_pkts;
+ eth_dev->tx_pkt_burst = nfp_flower_multiple_pf_xmit_pkts;
eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |
RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index c261e575bc..b41dbee4ff 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -2530,6 +2530,12 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
hw_priv->is_pf = true;
+ if (!nfp_net_recv_pkt_meta_check_register(hw_priv)) {
+ PMD_INIT_LOG(ERR, "PF register meta check function failed.");
+ ret = -EIO;
+ goto hw_priv_free;
+ }
+
/*
* PF initialization has been done at this point. Call app specific
* init code now.
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 4941c915e7..36b98dc0c2 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -316,6 +316,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
hw_priv->dev_info = dev_info;
hw_priv->pf_dev = pf_dev;
+ if (!nfp_net_recv_pkt_meta_check_register(hw_priv)) {
+ PMD_INIT_LOG(ERR, "VF register meta check function failed.");
+ err = -EINVAL;
+ goto hw_priv_free;
+ }
+
eth_dev->process_private = hw_priv;
/* For secondary processes, the primary has done all the work */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index ccfb4b39f1..4ad6c532ee 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -9,6 +9,7 @@
#include <rte_alarm.h>
+#include "flower/nfp_flower_cmsg.h"
#include "flower/nfp_flower_representor.h"
#include "nfd3/nfp_nfd3.h"
#include "nfdk/nfp_nfdk.h"
@@ -2877,3 +2878,50 @@ nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw,
return 0;
}
+
+static inline bool
+nfp_net_meta_has_no_port_type(__rte_unused struct nfp_net_meta_parsed *meta)
+{
+ return true;
+}
+
+static inline bool
+nfp_net_meta_is_not_pf_port(__rte_unused struct nfp_net_meta_parsed *meta)
+{
+ return false;
+}
+
+static inline bool
+nfp_net_meta_is_pf_port(struct nfp_net_meta_parsed *meta)
+{
+ return nfp_flower_port_is_phy_port(meta->port_id);
+}
+
+bool
+nfp_net_recv_pkt_meta_check_register(struct nfp_net_hw_priv *hw_priv)
+{
+ struct nfp_pf_dev *pf_dev;
+
+ pf_dev = hw_priv->pf_dev;
+ if (!hw_priv->is_pf) {
+ pf_dev->recv_pkt_meta_check_t = nfp_net_meta_has_no_port_type;
+ return true;
+ }
+
+ switch (pf_dev->app_fw_id) {
+ case NFP_APP_FW_CORE_NIC:
+ pf_dev->recv_pkt_meta_check_t = nfp_net_meta_has_no_port_type;
+ break;
+ case NFP_APP_FW_FLOWER_NIC:
+ if (pf_dev->multi_pf.enabled)
+ pf_dev->recv_pkt_meta_check_t = nfp_net_meta_is_pf_port;
+ else
+ pf_dev->recv_pkt_meta_check_t = nfp_net_meta_is_not_pf_port;
+ break;
+ default:
+ PMD_INIT_LOG(ERR, "Unsupported Firmware loaded.");
+ return false;
+ }
+
+ return true;
+}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 64b8a38918..a9581827f9 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -169,6 +169,9 @@ struct nfp_pf_dev {
/** Record the speed uptade */
bool speed_updated;
+
+ /** Function pointer used to check the metadata of recv pkts. */
+ bool (*recv_pkt_meta_check_t)(struct nfp_net_meta_parsed *meta);
};
#define NFP_NET_ETH_FLOW_LIMIT 8
@@ -389,6 +392,7 @@ bool nfp_net_version_check(struct nfp_hw *hw,
void nfp_net_ctrl_bar_size_set(struct nfp_pf_dev *pf_dev);
void nfp_net_notify_port_speed(struct nfp_net_hw *hw,
struct rte_eth_link *link);
+bool nfp_net_recv_pkt_meta_check_register(struct nfp_net_hw_priv *hw_priv);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index c7812a6dee..35fb637b21 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -416,6 +416,7 @@ nfp_net_recv_pkts(void *rx_queue,
struct nfp_net_hw *hw;
struct rte_mbuf *new_mb;
struct nfp_net_rxq *rxq;
+ struct nfp_pf_dev *pf_dev;
struct nfp_net_dp_buf *rxb;
struct nfp_net_rx_desc *rxds;
uint16_t avail_multiplexed = 0;
@@ -431,6 +432,7 @@ nfp_net_recv_pkts(void *rx_queue,
}
hw = rxq->hw;
+ pf_dev = rxq->hw_priv->pf_dev;
while (avail + avail_multiplexed < nb_pkts) {
rxb = &rxq->rxbufs[rxq->rd_p];
@@ -519,13 +521,15 @@ nfp_net_recv_pkts(void *rx_queue,
if (unlikely(rxq->rd_p == rxq->rx_count)) /* Wrapping */
rxq->rd_p = 0;
- if (((meta.flags >> NFP_NET_META_PORTID) & 0x1) == 0) {
+ if (pf_dev->recv_pkt_meta_check_t(&meta)) {
rx_pkts[avail++] = mb;
- } else if (nfp_flower_pf_dispatch_pkts(rxq, mb, meta.port_id)) {
- avail_multiplexed++;
} else {
- rte_pktmbuf_free(mb);
- break;
+ if (nfp_flower_pf_dispatch_pkts(rxq, mb, meta.port_id)) {
+ avail_multiplexed++;
+ } else {
+ rte_pktmbuf_free(mb);
+ break;
+ }
}
}
--
2.39.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/9] support multiple PF flower firmware
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
` (8 preceding siblings ...)
2024-10-21 6:33 ` [PATCH 9/9] net/nfp: update the Tx and Rx function " Chaoyong He
@ 2024-10-29 23:34 ` Ferruh Yigit
9 siblings, 0 replies; 11+ messages in thread
From: Ferruh Yigit @ 2024-10-29 23:34 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers
On 10/21/2024 7:32 AM, Chaoyong He wrote:
> This patch series add support of the multiple PF flower firmware.
>
> Peng Zhang (9):
> net/nfp: extract the function to allocate the PHY
> net/nfp: extract the function to initialize the PF
> net/nfp: extract the function to allocate PF
> net/nfp: extract the function to allocate the VF
> net/nfp: revise the number of PF representor port
> net/nfp: initialize the representor port of the multiple PF
> net/nfp: ignore useless message for multiple PF
> net/nfp: add the new operations for multiple PF
> net/nfp: update the Tx and Rx function for multiple PF
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread