net/bnxt: support conditional execution of mapper tables
[dpdk.git] / drivers / net / bnxt / bnxt_hwrm.c
index c1798b5..2605ef0 100644 (file)
@@ -1330,6 +1330,28 @@ static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
        return rc;
 }
 
+int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp)
+{
+       int rc = 0;
+       struct hwrm_port_phy_qcaps_input req = {0};
+       struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
+
+       if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp))
+               return 0;
+
+       HWRM_PREP(&req, HWRM_PORT_PHY_QCAPS, BNXT_USE_CHIMP_MB);
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+
+       bp->port_cnt = resp->port_cnt;
+
+       HWRM_UNLOCK();
+
+       return 0;
+}
+
 static bool bnxt_find_lossy_profile(struct bnxt *bp)
 {
        int i = 0;
@@ -2788,13 +2810,18 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed)
                ETH_LINK_SPEED_40G | ETH_LINK_SPEED_50G | \
                ETH_LINK_SPEED_100G | ETH_LINK_SPEED_200G)
 
-static int bnxt_valid_link_speed(uint32_t link_speed, uint16_t port_id)
+static int bnxt_validate_link_speed(struct bnxt *bp)
 {
+       uint32_t link_speed = bp->eth_dev->data->dev_conf.link_speeds;
+       uint16_t port_id = bp->eth_dev->data->port_id;
+       uint32_t link_speed_capa;
        uint32_t one_speed;
 
        if (link_speed == ETH_LINK_SPEED_AUTONEG)
                return 0;
 
+       link_speed_capa = bnxt_get_speed_capabilities(bp);
+
        if (link_speed & ETH_LINK_SPEED_FIXED) {
                one_speed = link_speed & ~ETH_LINK_SPEED_FIXED;
 
@@ -2804,14 +2831,14 @@ static int bnxt_valid_link_speed(uint32_t link_speed, uint16_t port_id)
                                link_speed, port_id);
                        return -EINVAL;
                }
-               if ((one_speed & BNXT_SUPPORTED_SPEEDS) != one_speed) {
+               if ((one_speed & link_speed_capa) != one_speed) {
                        PMD_DRV_LOG(ERR,
                                "Unsupported advertised speed (%u) for port %u\n",
                                link_speed, port_id);
                        return -EINVAL;
                }
        } else {
-               if (!(link_speed & BNXT_SUPPORTED_SPEEDS)) {
+               if (!(link_speed & link_speed_capa)) {
                        PMD_DRV_LOG(ERR,
                                "Unsupported advertised speeds (%u) for port %u\n",
                                link_speed, port_id);
@@ -2957,8 +2984,7 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
        if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp))
                return 0;
 
-       rc = bnxt_valid_link_speed(dev_conf->link_speeds,
-                       bp->eth_dev->data->port_id);
+       rc = bnxt_validate_link_speed(bp);
        if (rc)
                goto error;
 
@@ -3090,6 +3116,75 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
        return rc;
 }
 
+int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp)
+{
+       struct hwrm_func_qcfg_input req = {0};
+       struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+       int rc;
+
+       if (!BNXT_VF_IS_TRUSTED(bp))
+               return 0;
+
+       if (!bp->parent)
+               return -EINVAL;
+
+       bp->parent->fid = BNXT_PF_FID_INVALID;
+
+       HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
+
+       req.fid = rte_cpu_to_le_16(0xfffe); /* Request parent PF information. */
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+
+       memcpy(bp->parent->mac_addr, resp->mac_address, RTE_ETHER_ADDR_LEN);
+       bp->parent->vnic = rte_le_to_cpu_16(resp->dflt_vnic_id);
+       bp->parent->fid = rte_le_to_cpu_16(resp->fid);
+       bp->parent->port_id = rte_le_to_cpu_16(resp->port_id);
+
+       /* FIXME: Temporary workaround - remove when firmware issue is fixed. */
+       if (bp->parent->vnic == 0) {
+               PMD_DRV_LOG(ERR, "Error: parent VNIC unavailable.\n");
+               /* Use hard-coded values appropriate for current Wh+ fw. */
+               if (bp->parent->fid == 2)
+                       bp->parent->vnic = 0x100;
+               else
+                       bp->parent->vnic = 1;
+       }
+
+       HWRM_UNLOCK();
+
+       return 0;
+}
+
+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};
@@ -5411,3 +5506,30 @@ int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp,
 
        return 0;
 }
+
+#ifdef RTE_LIBRTE_BNXT_PMD_SYSTEM
+int
+bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num)
+{
+       struct hwrm_oem_cmd_input req = {0};
+       struct hwrm_oem_cmd_output *resp = bp->hwrm_cmd_resp_addr;
+       struct bnxt_dmabuf_info oem_data;
+       int rc = 0;
+
+       HWRM_PREP(&req, HWRM_OEM_CMD, BNXT_USE_CHIMP_MB);
+       req.IANA = 0x14e4;
+
+       memset(&oem_data, 0, sizeof(struct bnxt_dmabuf_info));
+       oem_data.entry_num = (entry_num);
+       memcpy(&req.oem_data[0], &oem_data, sizeof(struct bnxt_dmabuf_info));
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+       HWRM_CHECK_RESULT();
+
+       bp->dmabuf.entry_num = entry_num;
+
+       HWRM_UNLOCK();
+
+       return rc;
+}
+#endif /* RTE_LIBRTE_BNXT_PMD_SYSTEM */