From: Jie Liu <[email protected]>

sxe2_func_caps_get() never assigns adapter->pf_idx from the device
capabilities, leaving it at its zero-initialized value. Switchdev
requests and representor setup that use pf_idx then report the wrong
PF index on multi-PF configurations.

Restore the pf_idx and port_idx assignments in sxe2_func_caps_get()
and drop the now-redundant port_idx assignment from
sxe2_drv_dev_caps_set().

Cc: [email protected]
Cc: [email protected]
Signed-off-by: Jie Liu <[email protected]>
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sxe2/sxe2_ethdev.c b/drivers/net/sxe2/sxe2_ethdev.c
index 5d8cfca6cf..2e14c372f8 100644
--- a/drivers/net/sxe2/sxe2_ethdev.c
+++ b/drivers/net/sxe2/sxe2_ethdev.c
@@ -1284,8 +1284,6 @@ void sxe2_eth_uinit(struct rte_eth_dev *dev __rte_unused)
 static void sxe2_drv_dev_caps_set(struct sxe2_adapter *adapter,
                        struct sxe2_drv_dev_caps_resp *dev_caps)
 {
-       adapter->port_idx = dev_caps->port_idx;
-
        adapter->cap_flags = 0;
 
        if (dev_caps->cap_flags & SXE2_DEV_CAPS_OFFLOAD_L2)
@@ -1344,6 +1342,8 @@ static int32_t sxe2_func_caps_get(struct sxe2_adapter 
*adapter)
                goto l_end;
 
        adapter->dev_type = dev_caps.dev_type;
+       adapter->port_idx = dev_caps.port_idx;
+       adapter->pf_idx = dev_caps.pf_idx;
 
        sxe2_drv_dev_caps_set(adapter,  &dev_caps);
 
-- 
2.52.0

Reply via email to