net/bnxt: provide switch info if VFR are configured
authorSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Fri, 11 Sep 2020 01:55:59 +0000 (18:55 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 18 Sep 2020 16:55:12 +0000 (18:55 +0200)
Some applications need switch_info of the device to be returned
as a part of eth_dev_info_get(). The offload logic in such
applications could use this info. Pass this info to the when VF
representors are configured.

Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure")
Cc: stable@dpdk.org
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_reps.c
drivers/net/bnxt/bnxt_reps.h

index 2a106fe..7c27e24 100644 (file)
@@ -908,6 +908,14 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
        dev_info->tx_desc_lim.nb_min = BNXT_MIN_RING_DESC;
        dev_info->tx_desc_lim.nb_max = BNXT_MAX_TX_RING_DESC;
 
+       if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
+               dev_info->switch_info.name = eth_dev->device->name;
+               dev_info->switch_info.domain_id = bp->switch_domain_id;
+               dev_info->switch_info.port_id =
+                               BNXT_PF(bp) ? BNXT_SWITCH_PORT_ID_PF :
+                                   BNXT_SWITCH_PORT_ID_TRUSTED_VF;
+       }
+
        /* *INDENT-ON* */
 
        /*
index ef5bd06..7350c09 100644 (file)
@@ -500,6 +500,11 @@ int bnxt_vf_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
        dev_info->tx_offload_capa = BNXT_DEV_TX_OFFLOAD_SUPPORT;
        dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT;
 
+       dev_info->switch_info.name = eth_dev->device->name;
+       dev_info->switch_info.domain_id = rep_bp->switch_domain_id;
+       dev_info->switch_info.port_id =
+                       rep_bp->vf_id & BNXT_SWITCH_PORT_ID_VF_MASK;
+
        return 0;
 }
 
index d877b08..3239e03 100644 (file)
 #define BNXT_MAX_CFA_CODE               65536
 #define BNXT_VF_IDX_INVALID             0xffff
 
+/* Switchdev Port ID Mapping (Per switch domain id).
+ * Lower 15 bits map the VFs (VF_ID). Upper bit maps the PF.
+ */
+#define        BNXT_SWITCH_PORT_ID_PF          0x8000
+#define        BNXT_SWITCH_PORT_ID_TRUSTED_VF  0x0
+#define BNXT_SWITCH_PORT_ID_VF_MASK    0x7FFF
+
 uint16_t
 bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf);
 int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params);