net/bnxt: refactor init/uninit
[dpdk.git] / drivers / net / bnxt / bnxt_hwrm.c
index cee2656..4d8ca9e 100644 (file)
@@ -64,6 +64,9 @@ static void bnxt_hwrm_set_pg_attr(struct bnxt_ring_mem_info *rmem,
                                  uint8_t *pg_attr,
                                  uint64_t *pg_dir)
 {
+       if (rmem->nr_pages == 0)
+               return;
+
        if (rmem->nr_pages > 1) {
                *pg_attr = 1;
                *pg_dir = rte_cpu_to_le_64(rmem->pg_tbl_map);
@@ -860,6 +863,9 @@ int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
        if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_OUTERMOST_RSS_CAP)
                bp->vnic_cap_flags |= BNXT_VNIC_CAP_OUTER_RSS;
 
+       if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RX_CMPL_V2_CAP)
+               bp->vnic_cap_flags |= BNXT_VNIC_CAP_RX_CMPL_V2;
+
        bp->max_tpa_v2 = rte_le_to_cpu_16(resp->max_aggs_supported);
 
        HWRM_UNLOCK();
@@ -1096,10 +1102,11 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
        else
                HWRM_CHECK_RESULT();
 
-       PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d\n",
+       PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d.%d\n",
                resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
                resp->hwrm_intf_upd_8b, resp->hwrm_fw_maj_8b,
-               resp->hwrm_fw_min_8b, resp->hwrm_fw_bld_8b);
+               resp->hwrm_fw_min_8b, resp->hwrm_fw_bld_8b,
+               resp->hwrm_fw_rsvd_8b);
        bp->fw_ver = (resp->hwrm_fw_maj_8b << 24) |
                     (resp->hwrm_fw_min_8b << 16) |
                     (resp->hwrm_fw_bld_8b << 8) |
@@ -1129,6 +1136,9 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
                PMD_DRV_LOG(ERR, "Unsupported request length\n");
                rc = -EINVAL;
        }
+
+       bp->chip_num = rte_le_to_cpu_16(resp->chip_num);
+
        bp->max_req_len = rte_le_to_cpu_16(resp->max_req_win_len);
        bp->hwrm_max_ext_req_len = rte_le_to_cpu_16(resp->max_ext_req_len);
        if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN)
@@ -1958,6 +1968,11 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
                        rte_cpu_to_le_16(cpr->cp_ring_struct->fw_ring_id);
                enables = HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_RX_RING_ID |
                          HWRM_VNIC_CFG_INPUT_ENABLES_DEFAULT_CMPL_RING_ID;
+               if (bp->vnic_cap_flags & BNXT_VNIC_CAP_RX_CMPL_V2) {
+                       enables |= HWRM_VNIC_CFG_INPUT_ENABLES_RX_CSUM_V2_MODE;
+                       req.rx_csum_v2_mode =
+                               HWRM_VNIC_CFG_INPUT_RX_CSUM_V2_MODE_ALL_OK;
+               }
                goto config_mru;
        }
 
@@ -2601,8 +2616,8 @@ bnxt_free_all_hwrm_rings(struct bnxt *bp)
                        memset(txr->tx_buf_ring, 0,
                                        txr->tx_ring_struct->ring_size *
                                        sizeof(*txr->tx_buf_ring));
-                       txr->tx_prod = 0;
-                       txr->tx_cons = 0;
+                       txr->tx_raw_prod = 0;
+                       txr->tx_raw_cons = 0;
                }
                if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) {
                        bnxt_free_cp_ring(bp, cpr);
@@ -3207,6 +3222,9 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
                break;
        }
 
+       bp->legacy_db_size =
+               rte_le_to_cpu_16(resp->legacy_l2_db_size_kb) * 1024;
+
        HWRM_UNLOCK();
 
        return rc;
@@ -3456,6 +3474,35 @@ static int bnxt_update_max_resources(struct bnxt *bp,
        return 0;
 }
 
+/* Update the PF resource values based on how many resources
+ * got allocated to it.
+ */
+static int bnxt_update_max_resources_pf_only(struct bnxt *bp)
+{
+       struct hwrm_func_qcfg_input req = {0};
+       struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+       int rc;
+
+       /* Get the actual allocated values now */
+       HWRM_PREP(&req, HWRM_FUNC_QCFG, BNXT_USE_CHIMP_MB);
+       req.fid = rte_cpu_to_le_16(0xffff);
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+       HWRM_CHECK_RESULT();
+
+       bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->alloc_rsscos_ctx);
+       bp->max_stat_ctx = rte_le_to_cpu_16(resp->alloc_stat_ctx);
+       bp->max_cp_rings = rte_le_to_cpu_16(resp->alloc_cmpl_rings);
+       bp->max_tx_rings = rte_le_to_cpu_16(resp->alloc_tx_rings);
+       bp->max_rx_rings = rte_le_to_cpu_16(resp->alloc_rx_rings);
+       bp->max_l2_ctx = rte_le_to_cpu_16(resp->alloc_l2_ctx);
+       bp->max_ring_grps = rte_le_to_cpu_16(resp->alloc_hw_ring_grps);
+       bp->max_vnics = rte_le_to_cpu_16(resp->alloc_vnics);
+
+       HWRM_UNLOCK();
+
+       return 0;
+}
+
 int bnxt_hwrm_func_qcfg_current_vf_vlan(struct bnxt *bp, int vf)
 {
        struct hwrm_func_qcfg_input req = {0};
@@ -3555,8 +3602,13 @@ int bnxt_hwrm_allocate_pf_only(struct bnxt *bp)
                  HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE);
        bp->pf->func_cfg_flags |=
                HWRM_FUNC_CFG_INPUT_FLAGS_STD_TX_RING_MODE_DISABLE;
+
        rc = bnxt_hwrm_pf_func_cfg(bp, &pf_resc);
-       rc = __bnxt_hwrm_func_qcaps(bp);
+       if (rc)
+               return rc;
+
+       rc = bnxt_update_max_resources_pf_only(bp);
+
        return rc;
 }
 
@@ -5786,3 +5838,35 @@ int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep_bp)
                    rep_bp->vf_id);
        return rc;
 }
+
+int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp)
+{
+       struct hwrm_cfa_adv_flow_mgnt_qcaps_output *resp =
+                                       bp->hwrm_cmd_resp_addr;
+       struct hwrm_cfa_adv_flow_mgnt_qcaps_input req = {0};
+       uint32_t flags = 0;
+       int rc = 0;
+
+       if (!(bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT))
+               return 0;
+
+       if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) {
+               PMD_DRV_LOG(DEBUG,
+                           "Not a PF or trusted VF. Command not supported\n");
+               return 0;
+       }
+
+       HWRM_PREP(&req, HWRM_CFA_ADV_FLOW_MGNT_QCAPS, BNXT_USE_CHIMP_MB);
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+       flags = rte_le_to_cpu_32(resp->flags);
+       HWRM_UNLOCK();
+
+       if (flags & HWRM_CFA_ADV_FLOW_MGNT_QCAPS_RFS_RING_TBL_IDX_V2_SUPPORTED)
+               bp->flags |= BNXT_FLAG_FLOW_CFA_RFS_RING_TBL_IDX_V2;
+       else
+               bp->flags |= BNXT_FLAG_RFS_NEEDS_VNIC;
+
+       return rc;
+}