[PATCH v1 1/2] net/cpfl: fix function type on MMG device
Soumyadeep Hore
soumyadeep.hore at intel.com
Thu Nov 19 08:31:46 CET 2026
The MMG control plane encodes the LAN PF and VF function types as
0 and 2, the reverse of the MEV values. The driver always used the
MEV values, so the vport map lookup in cpfl_get_vsi_id() missed on
MMG and flow rules failed with "vport id not exist".
Select the PF and VF function type based on the device ID.
Also use the PF function type and clear vf_id when adding a PF
representor vport to the vport map, so the hash key is fully
initialized and matches the other lookups.
Fixes: 06c585cb0dee ("net/cpfl: add MMG device ID")
Fixes: 7b9395cb7dfe ("net/cpfl: update CP channel API")
Cc: stable at dpdk.org
Signed-off-by: Soumyadeep Hore <soumyadeep.hore at intel.com>
---
drivers/net/intel/cpfl/cpfl_ethdev.h | 17 ++++++++++++++-
drivers/net/intel/cpfl/cpfl_representor.c | 26 ++++++++++++-----------
2 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/drivers/net/intel/cpfl/cpfl_ethdev.h b/drivers/net/intel/cpfl/cpfl_ethdev.h
index 49a0979f2c..791b8b584f 100644
--- a/drivers/net/intel/cpfl/cpfl_ethdev.h
+++ b/drivers/net/intel/cpfl/cpfl_ethdev.h
@@ -334,6 +334,21 @@ cpfl_get_port_id(struct cpfl_itf *itf)
return CPFL_INVALID_HW_ID;
}
+/* MMG control plane swaps the PF and VF function type values */
+static inline uint8_t
+cpfl_func_type_pf(const struct cpfl_adapter_ext *adapter)
+{
+ return adapter->base.hw.device_id == CPFL_DEV_ID_MMG ?
+ CPCHNL2_FTYPE_LAN_VF : CPCHNL2_FTYPE_LAN_PF;
+}
+
+static inline uint8_t
+cpfl_func_type_vf(const struct cpfl_adapter_ext *adapter)
+{
+ return adapter->base.hw.device_id == CPFL_DEV_ID_MMG ?
+ CPCHNL2_FTYPE_LAN_PF : CPCHNL2_FTYPE_LAN_VF;
+}
+
static inline uint16_t
cpfl_get_vsi_id(struct cpfl_itf *itf)
{
@@ -354,7 +369,7 @@ cpfl_get_vsi_id(struct cpfl_itf *itf)
if (!idpf_is_vf_device(&itf->adapter->base.hw)) {
vport_id = ((struct cpfl_vport *)itf)->base.vport_id;
- vport_identity.func_type = CPCHNL2_FTYPE_LAN_PF;
+ vport_identity.func_type = cpfl_func_type_pf(itf->adapter);
/* host: CPFL_HOST0_CPF_ID, acc: CPFL_ACC_CPF_ID */
vport_identity.pf_id = (itf->adapter->host_id == CPFL_HOST_ID_ACC) ?
CPFL_ACC_CPF_ID : CPFL_HOST0_CPF_ID;
diff --git a/drivers/net/intel/cpfl/cpfl_representor.c b/drivers/net/intel/cpfl/cpfl_representor.c
index bb28c0b989..4bb4d9e418 100644
--- a/drivers/net/intel/cpfl/cpfl_representor.c
+++ b/drivers/net/intel/cpfl/cpfl_representor.c
@@ -349,12 +349,12 @@ cpfl_repr_link_update(struct rte_eth_dev *ethdev,
if (wait_to_complete) {
if (repr->repr_id.type == RTE_ETH_REPRESENTOR_PF) {
/* PF */
- vi.func_type = CPCHNL2_FTYPE_LAN_PF;
+ vi.func_type = cpfl_func_type_pf(adapter);
vi.pf_id = cpfl_func_id_get(repr->repr_id.host_id, repr->repr_id.pf_id);
vi.vf_id = 0;
} else {
/* VF */
- vi.func_type = CPCHNL2_FTYPE_LAN_VF;
+ vi.func_type = cpfl_func_type_vf(adapter);
vi.pf_id = CPFL_HOST0_APF;
vi.vf_id = repr->repr_id.vf_id;
}
@@ -450,20 +450,21 @@ cpfl_repr_init(struct rte_eth_dev *eth_dev, void *init_param)
}
static bool
-cpfl_match_repr_with_vport(const struct cpfl_repr_id *repr_id,
+cpfl_match_repr_with_vport(const struct cpfl_adapter_ext *adapter,
+ const struct cpfl_repr_id *repr_id,
struct cpchnl2_vport_info *info)
{
int func_id;
if (repr_id->type == RTE_ETH_REPRESENTOR_PF &&
- info->func_type == CPCHNL2_FTYPE_LAN_PF) {
+ info->func_type == cpfl_func_type_pf(adapter)) {
func_id = cpfl_func_id_get(repr_id->host_id, repr_id->pf_id);
if (func_id < 0 || func_id != info->pf_id)
return false;
else
return true;
} else if (repr_id->type == RTE_ETH_REPRESENTOR_VF &&
- info->func_type == CPCHNL2_FTYPE_LAN_VF) {
+ info->func_type == cpfl_func_type_vf(adapter)) {
if (repr_id->vf_id == info->vf_id)
return true;
}
@@ -481,12 +482,12 @@ cpfl_repr_vport_list_query(struct cpfl_adapter_ext *adapter,
if (repr_id->type == RTE_ETH_REPRESENTOR_PF) {
/* PF */
- vi.func_type = CPCHNL2_FTYPE_LAN_PF;
+ vi.func_type = cpfl_func_type_pf(adapter);
vi.pf_id = cpfl_func_id_get(repr_id->host_id, repr_id->pf_id);
vi.vf_id = 0;
} else {
/* VF */
- vi.func_type = CPCHNL2_FTYPE_LAN_VF;
+ vi.func_type = cpfl_func_type_vf(adapter);
vi.pf_id = CPFL_HOST0_APF;
vi.vf_id = repr_id->vf_id;
}
@@ -507,12 +508,12 @@ cpfl_repr_vport_info_query(struct cpfl_adapter_ext *adapter,
if (repr_id->type == RTE_ETH_REPRESENTOR_PF) {
/* PF */
- vi.func_type = CPCHNL2_FTYPE_LAN_PF;
+ vi.func_type = cpfl_func_type_pf(adapter);
vi.pf_id = cpfl_func_id_get(repr_id->host_id, repr_id->pf_id);
vi.vf_id = 0;
} else {
/* VF */
- vi.func_type = CPCHNL2_FTYPE_LAN_VF;
+ vi.func_type = cpfl_func_type_vf(adapter);
vi.pf_id = CPFL_HOST0_APF;
vi.vf_id = repr_id->vf_id;
}
@@ -533,11 +534,12 @@ cpfl_repr_vport_map_update(struct cpfl_adapter_ext *adapter,
vi.vport_id = vport_id;
if (repr_id->type == RTE_ETH_REPRESENTOR_PF) {
/* PF */
- vi.func_type = CPCHNL2_FTYPE_LAN_VF;
+ vi.func_type = cpfl_func_type_pf(adapter);
vi.pf_id = cpfl_func_id_get(repr_id->host_id, repr_id->pf_id);
+ vi.vf_id = 0;
} else {
/* VF */
- vi.func_type = CPCHNL2_FTYPE_LAN_VF;
+ vi.func_type = cpfl_func_type_vf(adapter);
vi.pf_id = CPFL_HOST0_APF;
vi.vf_id = repr_id->vf_id;
}
@@ -632,7 +634,7 @@ cpfl_repr_create(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapte
(const void **)&vp_id, (void **)&vi, &iter_iter) >= 0) {
struct cpfl_repr_param param;
- if (!cpfl_match_repr_with_vport(repr_id, &vi->vport.info))
+ if (!cpfl_match_repr_with_vport(adapter, repr_id, &vi->vport.info))
continue;
param.adapter = adapter;
--
2.43.0
More information about the dev
mailing list