net/bnxt: get port and function info
authorVenkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Thu, 2 Jul 2020 23:27:53 +0000 (16:27 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:26 +0000 (23:38 +0200)
add helper functions to get port & function related information
like parif, physical port id & vport id.

Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/tf_ulp/bnxt_tf_common.h
drivers/net/bnxt/tf_ulp/ulp_port_db.h

index 2b87899..0bdf8f5 100644 (file)
@@ -855,6 +855,9 @@ extern const struct rte_flow_ops bnxt_flow_ops;
        } \
 } while (0)
 
+#define        BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)    \
+               ((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+
 extern int bnxt_logtype_driver;
 #define PMD_DRV_LOG_RAW(level, fmt, args...) \
        rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \
@@ -870,6 +873,11 @@ void bnxt_ulp_deinit(struct bnxt *bp);
 uint16_t bnxt_get_vnic_id(uint16_t port);
 uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif);
 uint16_t bnxt_get_fw_func_id(uint16_t port);
+uint16_t bnxt_get_parif(uint16_t port);
+uint16_t bnxt_get_phy_port_id(uint16_t port);
+uint16_t bnxt_get_vport(uint16_t port);
+enum bnxt_ulp_intf_type
+bnxt_get_interface_type(uint16_t port);
 
 void bnxt_cancel_fc_thread(struct bnxt *bp);
 void bnxt_flow_cnt_alarm_cb(void *arg);
index 03c3f5f..7edc9a7 100644 (file)
@@ -28,6 +28,7 @@
 #include "bnxt_vnic.h"
 #include "hsi_struct_def_dpdk.h"
 #include "bnxt_nvm_defs.h"
+#include "bnxt_tf_common.h"
 
 #define DRV_MODULE_NAME                "bnxt"
 static const char bnxt_version[] =
@@ -5100,6 +5101,63 @@ bnxt_get_fw_func_id(uint16_t port)
        return bp->fw_fid;
 }
 
+enum bnxt_ulp_intf_type
+bnxt_get_interface_type(uint16_t port)
+{
+       struct rte_eth_dev *eth_dev;
+       struct bnxt *bp;
+
+       eth_dev = &rte_eth_devices[port];
+       if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev))
+               return BNXT_ULP_INTF_TYPE_VF_REP;
+
+       bp = eth_dev->data->dev_private;
+       return BNXT_PF(bp) ? BNXT_ULP_INTF_TYPE_PF
+                          : BNXT_ULP_INTF_TYPE_VF;
+}
+
+uint16_t
+bnxt_get_phy_port_id(uint16_t port_id)
+{
+       struct bnxt_vf_representor *vfr;
+       struct rte_eth_dev *eth_dev;
+       struct bnxt *bp;
+
+       eth_dev = &rte_eth_devices[port_id];
+       if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+               vfr = eth_dev->data->dev_private;
+               eth_dev = vfr->parent_dev;
+       }
+
+       bp = eth_dev->data->dev_private;
+
+       return BNXT_PF(bp) ? bp->pf->port_id : bp->parent->port_id;
+}
+
+uint16_t
+bnxt_get_parif(uint16_t port_id)
+{
+       struct bnxt_vf_representor *vfr;
+       struct rte_eth_dev *eth_dev;
+       struct bnxt *bp;
+
+       eth_dev = &rte_eth_devices[port_id];
+       if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+               vfr = eth_dev->data->dev_private;
+               eth_dev = vfr->parent_dev;
+       }
+
+       bp = eth_dev->data->dev_private;
+
+       return BNXT_PF(bp) ? bp->fw_fid - 1 : bp->parent->fid - 1;
+}
+
+uint16_t
+bnxt_get_vport(uint16_t port_id)
+{
+       return (1 << bnxt_get_phy_port_id(port_id));
+}
+
 static void bnxt_alloc_error_recovery_info(struct bnxt *bp)
 {
        struct bnxt_error_recovery_info *info = bp->recovery_info;
index f417579..f772d49 100644 (file)
@@ -44,6 +44,16 @@ enum ulp_direction_type {
        ULP_DIR_EGRESS,
 };
 
+/* enumeration of the interface types */
+enum bnxt_ulp_intf_type {
+       BNXT_ULP_INTF_TYPE_INVALID = 0,
+       BNXT_ULP_INTF_TYPE_PF,
+       BNXT_ULP_INTF_TYPE_VF,
+       BNXT_ULP_INTF_TYPE_PF_REP,
+       BNXT_ULP_INTF_TYPE_VF_REP,
+       BNXT_ULP_INTF_TYPE_LAST
+};
+
 struct bnxt_ulp_mark_tbl *
 bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
 
index 929a5a5..604c438 100644 (file)
 
 #define BNXT_PORT_DB_MAX_INTF_LIST             256
 
-/* enumeration of the interface types */
-enum bnxt_ulp_intf_type {
-       BNXT_ULP_INTF_TYPE_INVALID = 0,
-       BNXT_ULP_INTF_TYPE_PF = 1,
-       BNXT_ULP_INTF_TYPE_VF,
-       BNXT_ULP_INTF_TYPE_PF_REP,
-       BNXT_ULP_INTF_TYPE_VF_REP,
-       BNXT_ULP_INTF_TYPE_LAST
-};
-
 /* Structure for the Port database resource information. */
 struct ulp_interface_info {
        enum bnxt_ulp_intf_type type;