[5/8] net/nfp: add new data field into representor port structure

Message ID 20240905062511.2710102-6-chaoyong.he@corigine.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series fix the representor port link status and speed |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Sept. 5, 2024, 6:25 a.m. UTC
From: Qin Ke <qin.ke@corigine.com>

Add a new data field 'idx' into 'nfp_flower_representor' structure
to indicate the sequential physical port number of representor
devices, also initialize it for all representor ports.

Signed-off-by: Qin Ke <qin.ke@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_representor.c | 4 ++++
 drivers/net/nfp/flower/nfp_flower_representor.h | 2 ++
 2 files changed, 6 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 872b8a6db4..e7593313e2 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -649,6 +649,7 @@  nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
 	}
 
 	/* 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;
@@ -822,6 +823,7 @@  nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 
 	/* 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);
@@ -854,6 +856,7 @@  nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 		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(&eth_port->mac_addr, &flower_repr.mac_addr);
@@ -887,6 +890,7 @@  nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 				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);
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 70ca7b97db..4211ddf798 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -23,6 +23,8 @@  struct nfp_flower_representor {
 
 	struct rte_eth_xstat *repr_xstats_base;
 	uint8_t *mac_stats;
+	/** Sequential physical port number, only valid for repr of physical port */
+	uint8_t idx;
 };
 
 int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,