net/liquidio: add API to setup Rx queue
[dpdk.git] / drivers / net / qede / base / ecore_dev.c
index f7a36c9..da9cdc9 100644 (file)
@@ -70,28 +70,26 @@ static u32 ecore_hw_bar_size(struct ecore_hwfn *p_hwfn, enum BAR_ID bar_id)
        }
 
        val = ecore_rd(p_hwfn, p_hwfn->p_main_ptt, bar_reg);
+       if (val)
+               return 1 << (val + 15);
 
        /* The above registers were updated in the past only in CMT mode. Since
         * they were found to be useful MFW started updating them from 8.7.7.0.
         * In older MFW versions they are set to 0 which means disabled.
         */
-       if (!val) {
-               if (p_hwfn->p_dev->num_hwfns > 1) {
-                       DP_NOTICE(p_hwfn, false,
-                                 "BAR size not configured. Assuming BAR size");
-                       DP_NOTICE(p_hwfn, false,
-                                 "of 256kB for GRC and 512kB for DB\n");
-                       return BAR_ID_0 ? 256 * 1024 : 512 * 1024;
-               } else {
-                       DP_NOTICE(p_hwfn, false,
-                                 "BAR size not configured. Assuming BAR size");
-                       DP_NOTICE(p_hwfn, false,
-                                 "of 512kB for GRC and 512kB for DB\n");
-                       return 512 * 1024;
-               }
+       if (p_hwfn->p_dev->num_hwfns > 1) {
+               DP_NOTICE(p_hwfn, false,
+                         "BAR size not configured. Assuming BAR size of 256kB"
+                         " for GRC and 512kB for DB\n");
+               val = BAR_ID_0 ? 256 * 1024 : 512 * 1024;
+       } else {
+               DP_NOTICE(p_hwfn, false,
+                         "BAR size not configured. Assuming BAR size of 512kB"
+                         " for GRC and 512kB for DB\n");
+               val = 512 * 1024;
        }
 
-       return 1 << (val + 15);
+       return val;
 }
 
 void ecore_init_dp(struct ecore_dev *p_dev,
@@ -138,13 +136,9 @@ static void ecore_qm_info_free(struct ecore_hwfn *p_hwfn)
        struct ecore_qm_info *qm_info = &p_hwfn->qm_info;
 
        OSAL_FREE(p_hwfn->p_dev, qm_info->qm_pq_params);
-       qm_info->qm_pq_params = OSAL_NULL;
        OSAL_FREE(p_hwfn->p_dev, qm_info->qm_vport_params);
-       qm_info->qm_vport_params = OSAL_NULL;
        OSAL_FREE(p_hwfn->p_dev, qm_info->qm_port_params);
-       qm_info->qm_port_params = OSAL_NULL;
        OSAL_FREE(p_hwfn->p_dev, qm_info->wfq_data);
-       qm_info->wfq_data = OSAL_NULL;
 }
 
 void ecore_resc_free(struct ecore_dev *p_dev)
@@ -155,7 +149,6 @@ void ecore_resc_free(struct ecore_dev *p_dev)
                return;
 
        OSAL_FREE(p_dev, p_dev->fw_data);
-       p_dev->fw_data = OSAL_NULL;
 
        OSAL_FREE(p_dev, p_dev->reset_stats);
 
@@ -163,9 +156,7 @@ void ecore_resc_free(struct ecore_dev *p_dev)
                struct ecore_hwfn *p_hwfn = &p_dev->hwfns[i];
 
                OSAL_FREE(p_dev, p_hwfn->p_tx_cids);
-               p_hwfn->p_tx_cids = OSAL_NULL;
                OSAL_FREE(p_dev, p_hwfn->p_rx_cids);
-               p_hwfn->p_rx_cids = OSAL_NULL;
        }
 
        for_each_hwfn(p_dev, i) {
@@ -650,19 +641,20 @@ enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev)
                                    ecore_cxt_get_proto_cid_count(
                                                p_hwfn,
                                                PROTOCOLID_ROCE,
-                                               0);
+                                               OSAL_NULL);
                                num_cons *= 2;
                        } else {
                                num_cons = ecore_cxt_get_proto_cid_count(
                                                p_hwfn,
                                                PROTOCOLID_IWARP,
-                                               0);
+                                               OSAL_NULL);
                        }
                        n_eqes += num_cons + 2 * MAX_NUM_VFS_BB;
                } else if (p_hwfn->hw_info.personality == ECORE_PCI_ISCSI) {
                        num_cons =
                            ecore_cxt_get_proto_cid_count(p_hwfn,
-                                                         PROTOCOLID_ISCSI, 0);
+                                                         PROTOCOLID_ISCSI,
+                                                         OSAL_NULL);
                        n_eqes += 2 * num_cons;
                }
 
@@ -670,8 +662,7 @@ enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev)
                        DP_ERR(p_hwfn, "Cannot allocate 0x%x EQ elements."
                                       "The maximum of a u16 chain is 0x%x\n",
                               n_eqes, 0xFFFF);
-                       rc = ECORE_INVAL;
-                       goto alloc_err;
+                       goto alloc_no_mem;
                }
 
                p_eq = ecore_eq_alloc(p_hwfn, (u16)n_eqes);
@@ -798,10 +789,9 @@ enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
 
        DP_VERBOSE(p_hwfn, ECORE_MSG_IOV,
                   "Sending final cleanup for PFVF[%d] [Command %08x\n]",
-                  id, OSAL_CPU_TO_LE32(command));
+                  id, command);
 
-       ecore_wr(p_hwfn, p_ptt, XSDM_REG_OPERATION_GEN,
-                OSAL_CPU_TO_LE32(command));
+       ecore_wr(p_hwfn, p_ptt, XSDM_REG_OPERATION_GEN, command);
 
        /* Poll until completion */
        while (!REG_RD(p_hwfn, addr) && count--)
@@ -2067,6 +2057,7 @@ static void get_function_id(struct ecore_hwfn *p_hwfn)
 static void ecore_hw_set_feat(struct ecore_hwfn *p_hwfn)
 {
        u32 *feat_num = p_hwfn->hw_info.feat_num;
+       struct ecore_sb_cnt_info sb_cnt_info;
        int num_features = 1;
 
        /* L2 Queues require each: 1 status block. 1 L2 queue */
@@ -2075,11 +2066,21 @@ static void ecore_hw_set_feat(struct ecore_hwfn *p_hwfn)
                       RESC_NUM(p_hwfn, ECORE_SB) / num_features,
                       RESC_NUM(p_hwfn, ECORE_L2_QUEUE));
 
+       OSAL_MEM_ZERO(&sb_cnt_info, sizeof(sb_cnt_info));
+       ecore_int_get_num_sbs(p_hwfn, &sb_cnt_info);
+       feat_num[ECORE_VF_L2_QUE] =
+               OSAL_MIN_T(u32,
+                          RESC_NUM(p_hwfn, ECORE_L2_QUEUE) -
+                          FEAT_NUM(p_hwfn, ECORE_PF_L2_QUE),
+                          sb_cnt_info.sb_iov_cnt);
+
        DP_VERBOSE(p_hwfn, ECORE_MSG_PROBE,
-                  "#PF_L2_QUEUES=%d #ROCE_CNQ=%d #SBS=%d num_features=%d\n",
-                  feat_num[ECORE_PF_L2_QUE],
-                  feat_num[ECORE_RDMA_CNQ],
-                  RESC_NUM(p_hwfn, ECORE_SB), num_features);
+                  "#PF_L2_QUEUES=%d VF_L2_QUEUES=%d #ROCE_CNQ=%d #SBS=%d num_features=%d\n",
+                  (int)FEAT_NUM(p_hwfn, ECORE_PF_L2_QUE),
+                  (int)FEAT_NUM(p_hwfn, ECORE_VF_L2_QUE),
+                  (int)FEAT_NUM(p_hwfn, ECORE_RDMA_CNQ),
+                  RESC_NUM(p_hwfn, ECORE_SB),
+                  num_features);
 }
 
 static enum resource_id_enum
@@ -2308,12 +2309,11 @@ static enum _ecore_status_t ecore_hw_set_resc_info(struct ecore_hwfn *p_hwfn,
        *p_resc_start = resc_info.offset;
 
        if (*p_resc_num != dflt_resc_num || *p_resc_start != dflt_resc_start) {
-               DP_NOTICE(p_hwfn, false,
-                         "Resource %d [%s]: MFW allocation [num %d, start %d]"
-                         " differs from default values [num %d, start %d]%s\n",
-                         res_id, ecore_hw_get_resc_name(res_id), *p_resc_num,
-                         *p_resc_start, dflt_resc_num, dflt_resc_start,
-                         drv_resc_alloc ? " - Applying default values" : "");
+               DP_INFO(p_hwfn,
+                       "Resource %d [%s]: MFW allocation [num %d, start %d] differs from default values [num %d, start %d]%s\n",
+                       res_id, ecore_hw_get_resc_name(res_id), *p_resc_num,
+                       *p_resc_start, dflt_resc_num, dflt_resc_start,
+                       drv_resc_alloc ? " - Applying default values" : "");
                if (drv_resc_alloc) {
                        *p_resc_num = dflt_resc_num;
                        *p_resc_start = dflt_resc_start;
@@ -2342,12 +2342,7 @@ static enum _ecore_status_t ecore_hw_get_resc(struct ecore_hwfn *p_hwfn,
 #endif
 
        for (res_id = 0; res_id < ECORE_MAX_RESC; res_id++) {
-               /* @@@TMP for AH:
-                * Force the driver's default resource allocation in case there
-                * is a diff with the MFW allocation value.
-                */
-               rc = ecore_hw_set_resc_info(p_hwfn, res_id,
-                                           b_ah || drv_resc_alloc);
+               rc = ecore_hw_set_resc_info(p_hwfn, res_id, drv_resc_alloc);
                if (rc != ECORE_SUCCESS)
                        return rc;
        }
@@ -2407,7 +2402,7 @@ static enum _ecore_status_t ecore_hw_get_resc(struct ecore_hwfn *p_hwfn,
 static enum _ecore_status_t ecore_hw_get_nvm_info(struct ecore_hwfn *p_hwfn,
                                                  struct ecore_ptt *p_ptt)
 {
-       u32 nvm_cfg1_offset, mf_mode, addr, generic_cont0, core_cfg;
+       u32 nvm_cfg1_offset, mf_mode, addr, generic_cont0, core_cfg, dcbx_mode;
        u32 port_cfg_addr, link_temp, nvm_cfg_addr, device_capabilities;
        struct ecore_mcp_link_params *link;
 
@@ -2471,6 +2466,28 @@ static enum _ecore_status_t ecore_hw_get_nvm_info(struct ecore_hwfn *p_hwfn,
                break;
        }
 
+       /* Read DCBX configuration */
+       port_cfg_addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
+                       OFFSETOF(struct nvm_cfg1, port[MFW_PORT(p_hwfn)]);
+       dcbx_mode = ecore_rd(p_hwfn, p_ptt,
+                            port_cfg_addr +
+                            OFFSETOF(struct nvm_cfg1_port, generic_cont0));
+       dcbx_mode = (dcbx_mode & NVM_CFG1_PORT_DCBX_MODE_MASK)
+               >> NVM_CFG1_PORT_DCBX_MODE_OFFSET;
+       switch (dcbx_mode) {
+       case NVM_CFG1_PORT_DCBX_MODE_DYNAMIC:
+               p_hwfn->hw_info.dcbx_mode = ECORE_DCBX_VERSION_DYNAMIC;
+               break;
+       case NVM_CFG1_PORT_DCBX_MODE_CEE:
+               p_hwfn->hw_info.dcbx_mode = ECORE_DCBX_VERSION_CEE;
+               break;
+       case NVM_CFG1_PORT_DCBX_MODE_IEEE:
+               p_hwfn->hw_info.dcbx_mode = ECORE_DCBX_VERSION_IEEE;
+               break;
+       default:
+               p_hwfn->hw_info.dcbx_mode = ECORE_DCBX_VERSION_DISABLED;
+       }
+
        /* Read default link configuration */
        link = &p_hwfn->mcp_info->link_input;
        port_cfg_addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
@@ -2785,11 +2802,14 @@ ecore_get_hw_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
                ecore_mcp_cmd_port_init(p_hwfn, p_ptt);
        }
 
-       if (personality != ECORE_PCI_DEFAULT)
+       if (personality != ECORE_PCI_DEFAULT) {
                p_hwfn->hw_info.personality = personality;
-       else if (ecore_mcp_is_init(p_hwfn))
-               p_hwfn->hw_info.personality =
-                   p_hwfn->mcp_info->func_info.protocol;
+       } else if (ecore_mcp_is_init(p_hwfn)) {
+               enum ecore_pci_personality protocol;
+
+               protocol = p_hwfn->mcp_info->func_info.protocol;
+               p_hwfn->hw_info.personality = protocol;
+       }
 
 #ifndef ASIC_ONLY
        /* To overcome ILT lack for emulation, until at least until we'll have
@@ -2882,9 +2902,9 @@ static enum _ecore_status_t ecore_get_dev_info(struct ecore_dev *p_dev)
                                           MISCS_REG_CHIP_METAL);
        MASK_FIELD(CHIP_METAL, p_dev->chip_metal);
        DP_INFO(p_dev->hwfns,
-               "Chip details - %s%d, Num: %04x Rev: %04x Bond id: %04x Metal: %04x\n",
+               "Chip details - %s %c%d, Num: %04x Rev: %04x Bond id: %04x Metal: %04x\n",
                ECORE_IS_BB(p_dev) ? "BB" : "AH",
-               CHIP_REV_IS_A0(p_dev) ? 0 : 1,
+               'A' + p_dev->chip_rev, (int)p_dev->chip_metal,
                p_dev->chip_num, p_dev->chip_rev, p_dev->chip_bond_id,
                p_dev->chip_metal);