net/bnxt: get IDs for port representor endpoint
authorSomnath Kotur <somnath.kotur@broadcom.com>
Thu, 2 Jul 2020 23:27:50 +0000 (16:27 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:26 +0000 (23:38 +0200)
Use 'first_vf_id' and the 'vf_id' that is input as part of adding
a representor to obtain the PCI function ID(FID) of the VF(VFR endpoint).
Use the FID as an input to FUNC_QCFG HWRM cmd to obtain the default
vnic ID of the VF.
Along with getting the default vNIC ID by supplying the FW FID of
the VF-rep endpoint to HWRM_FUNC_QCFG, obtain and store it's
function svif.

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_hwrm.c
drivers/net/bnxt/bnxt_hwrm.h
drivers/net/bnxt/bnxt_reps.c

index 443d9fe..7afbd5c 100644 (file)
@@ -784,6 +784,9 @@ struct bnxt {
 struct bnxt_vf_representor {
        uint16_t                switch_domain_id;
        uint16_t                vf_id;
+       uint16_t                fw_fid;
+       uint16_t                dflt_vnic_id;
+       uint16_t                svif;
        uint16_t                tx_cfa_action;
        uint16_t                rx_cfa_code;
        /* Private data store of associated PF/Trusted VF */
index 945bc90..ed42e58 100644 (file)
@@ -3094,6 +3094,33 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
        return rc;
 }
 
+int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
+                                uint16_t *vnic_id, uint16_t *svif)
+{
+       struct hwrm_func_qcfg_input req = {0};
+       struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+       uint16_t svif_info;
+       int rc = 0;
+
+       HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
+       req.fid = rte_cpu_to_le_16(fid);
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+
+       if (vnic_id)
+               *vnic_id = rte_le_to_cpu_16(resp->dflt_vnic_id);
+
+       svif_info = rte_le_to_cpu_16(resp->svif_info);
+       if (svif && (svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_VALID))
+               *svif = svif_info & HWRM_FUNC_QCFG_OUTPUT_SVIF_INFO_SVIF_MASK;
+
+       HWRM_UNLOCK();
+
+       return rc;
+}
+
 int bnxt_hwrm_port_mac_qcfg(struct bnxt *bp)
 {
        struct hwrm_port_mac_qcfg_input req = {0};
index 58b414d..8d19998 100644 (file)
@@ -270,4 +270,8 @@ int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
                                 enum bnxt_flow_dir dir,
                                 uint16_t cntr,
                                 uint16_t num_entries);
+int bnxt_hwrm_get_dflt_vnic_id(struct bnxt *bp, uint16_t fid,
+                              uint16_t *vnic_id);
+int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
+                                uint16_t *vnic_id, uint16_t *svif);
 #endif
index b318c5a..bdbce6e 100644 (file)
@@ -150,6 +150,7 @@ int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params)
                                 (struct bnxt_vf_representor *)params;
        struct rte_eth_link *link;
        struct bnxt *parent_bp;
+       int rc = 0;
 
        vf_rep_bp->vf_id = rep_params->vf_id;
        vf_rep_bp->switch_domain_id = rep_params->switch_domain_id;
@@ -179,6 +180,17 @@ int bnxt_vf_representor_init(struct rte_eth_dev *eth_dev, void *params)
        eth_dev->data->dev_link.link_status = link->link_status;
        eth_dev->data->dev_link.link_autoneg = link->link_autoneg;
 
+       vf_rep_bp->fw_fid = rep_params->vf_id + parent_bp->first_vf_id;
+       PMD_DRV_LOG(INFO, "vf_rep->fw_fid = %d\n", vf_rep_bp->fw_fid);
+       rc = bnxt_hwrm_get_dflt_vnic_svif(parent_bp, vf_rep_bp->fw_fid,
+                                         &vf_rep_bp->dflt_vnic_id,
+                                         &vf_rep_bp->svif);
+       if (rc)
+               PMD_DRV_LOG(ERR, "Failed to get default vnic id of VF\n");
+       else
+               PMD_DRV_LOG(INFO, "vf_rep->dflt_vnic_id = %d\n",
+                           vf_rep_bp->dflt_vnic_id);
+
        PMD_DRV_LOG(INFO, "calling bnxt_print_link_info\n");
        bnxt_print_link_info(eth_dev);