net/qede/base: move DMAE to HSI
[dpdk.git] / drivers / net / qede / base / ecore_dev.c
index cf454b1..2c135af 100644 (file)
@@ -935,7 +935,7 @@ out:
        return rc;
 }
 
-struct ecore_llh_filter_e4_details {
+struct ecore_llh_filter_details {
        u64 value;
        u32 mode;
        u32 protocol_type;
@@ -944,13 +944,13 @@ struct ecore_llh_filter_e4_details {
 };
 
 static enum _ecore_status_t
-ecore_llh_access_filter_e4(struct ecore_hwfn *p_hwfn,
-                          struct ecore_ptt *p_ptt, u8 abs_ppfid, u8 filter_idx,
-                          struct ecore_llh_filter_e4_details *p_details,
-                          bool b_write_access)
+ecore_llh_access_filter(struct ecore_hwfn *p_hwfn,
+                       struct ecore_ptt *p_ptt, u8 abs_ppfid, u8 filter_idx,
+                       struct ecore_llh_filter_details *p_details,
+                       bool b_write_access)
 {
        u8 pfid = ECORE_PFID_BY_PPFID(p_hwfn, abs_ppfid);
-       struct ecore_dmae_params params;
+       struct dmae_params params;
        enum _ecore_status_t rc;
        u32 addr;
 
@@ -973,15 +973,15 @@ ecore_llh_access_filter_e4(struct ecore_hwfn *p_hwfn,
        OSAL_MEMSET(&params, 0, sizeof(params));
 
        if (b_write_access) {
-               params.flags = ECORE_DMAE_FLAG_PF_DST;
-               params.dst_pfid = pfid;
+               SET_FIELD(params.flags, DMAE_PARAMS_DST_PF_VALID, 0x1);
+               params.dst_pf_id = pfid;
                rc = ecore_dmae_host2grc(p_hwfn, p_ptt,
                                         (u64)(osal_uintptr_t)&p_details->value,
                                         addr, 2 /* size_in_dwords */, &params);
        } else {
-               params.flags = ECORE_DMAE_FLAG_PF_SRC |
-                              ECORE_DMAE_FLAG_COMPLETION_DST;
-               params.src_pfid = pfid;
+               SET_FIELD(params.flags, DMAE_PARAMS_SRC_PF_VALID, 0x1);
+               SET_FIELD(params.flags, DMAE_PARAMS_COMPLETION_DST, 0x1);
+               params.src_pf_id = pfid;
                rc = ecore_dmae_grc2host(p_hwfn, p_ptt, addr,
                                         (u64)(osal_uintptr_t)&p_details->value,
                                         2 /* size_in_dwords */, &params);
@@ -1008,7 +1008,7 @@ ecore_llh_access_filter_e4(struct ecore_hwfn *p_hwfn,
                                                          abs_ppfid, addr);
 
        /* Filter header select */
-       addr = NIG_REG_LLH_FUNC_FILTER_HDR_SEL_BB_K2 + filter_idx * 0x4;
+       addr = NIG_REG_LLH_FUNC_FILTER_HDR_SEL + filter_idx * 0x4;
        if (b_write_access)
                ecore_ppfid_wr(p_hwfn, p_ptt, abs_ppfid, addr,
                               p_details->hdr_sel);
@@ -1035,7 +1035,7 @@ ecore_llh_add_filter_e4(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
                        u8 abs_ppfid, u8 filter_idx, u8 filter_prot_type,
                        u32 high, u32 low)
 {
-       struct ecore_llh_filter_e4_details filter_details;
+       struct ecore_llh_filter_details filter_details;
 
        filter_details.enable = 1;
        filter_details.value = ((u64)high << 32) | low;
@@ -1048,22 +1048,22 @@ ecore_llh_add_filter_e4(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
                              1 : /* protocol-based classification */
                              0;  /* MAC-address based classification */
 
-       return ecore_llh_access_filter_e4(p_hwfn, p_ptt, abs_ppfid, filter_idx,
-                                         &filter_details,
-                                         true /* write access */);
+       return ecore_llh_access_filter(p_hwfn, p_ptt, abs_ppfid, filter_idx,
+                               &filter_details,
+                               true /* write access */);
 }
 
 static enum _ecore_status_t
 ecore_llh_remove_filter_e4(struct ecore_hwfn *p_hwfn,
                           struct ecore_ptt *p_ptt, u8 abs_ppfid, u8 filter_idx)
 {
-       struct ecore_llh_filter_e4_details filter_details;
+       struct ecore_llh_filter_details filter_details;
 
        OSAL_MEMSET(&filter_details, 0, sizeof(filter_details));
 
-       return ecore_llh_access_filter_e4(p_hwfn, p_ptt, abs_ppfid, filter_idx,
-                                         &filter_details,
-                                         true /* write access */);
+       return ecore_llh_access_filter(p_hwfn, p_ptt, abs_ppfid, filter_idx,
+                                      &filter_details,
+                                      true /* write access */);
 }
 
 static enum _ecore_status_t
@@ -1468,7 +1468,7 @@ static enum _ecore_status_t
 ecore_llh_dump_ppfid_e4(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
                        u8 ppfid)
 {
-       struct ecore_llh_filter_e4_details filter_details;
+       struct ecore_llh_filter_details filter_details;
        u8 abs_ppfid, filter_idx;
        u32 addr;
        enum _ecore_status_t rc;
@@ -1486,9 +1486,9 @@ ecore_llh_dump_ppfid_e4(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
        for (filter_idx = 0; filter_idx < NIG_REG_LLH_FUNC_FILTER_EN_SIZE;
             filter_idx++) {
                OSAL_MEMSET(&filter_details, 0, sizeof(filter_details));
-               rc =  ecore_llh_access_filter_e4(p_hwfn, p_ptt, abs_ppfid,
-                                                filter_idx, &filter_details,
-                                                false /* read access */);
+               rc =  ecore_llh_access_filter(p_hwfn, p_ptt, abs_ppfid,
+                                             filter_idx, &filter_details,
+                                             false /* read access */);
                if (rc != ECORE_SUCCESS)
                        return rc;
 
@@ -1862,7 +1862,7 @@ static void ecore_init_qm_port_params(struct ecore_hwfn *p_hwfn)
 
                p_qm_port->active = 1;
                p_qm_port->active_phys_tcs = active_phys_tcs;
-               p_qm_port->num_pbf_cmd_lines = PBF_MAX_CMD_LINES_E4 / num_ports;
+               p_qm_port->num_pbf_cmd_lines = PBF_MAX_CMD_LINES / num_ports;
                p_qm_port->num_btb_blocks = BTB_MAX_BLOCKS / num_ports;
        }
 }
@@ -2291,18 +2291,21 @@ enum _ecore_status_t ecore_qm_reconf(struct ecore_hwfn *p_hwfn,
 {
        struct ecore_qm_info *qm_info = &p_hwfn->qm_info;
        bool b_rc;
-       enum _ecore_status_t rc;
+       enum _ecore_status_t rc = ECORE_SUCCESS;
+
+       /* multiple flows can issue qm reconf. Need to lock */
+       OSAL_SPIN_LOCK(&qm_lock);
 
        /* initialize ecore's qm data structure */
        ecore_init_qm_info(p_hwfn);
 
        /* stop PF's qm queues */
-       OSAL_SPIN_LOCK(&qm_lock);
        b_rc = ecore_send_qm_stop_cmd(p_hwfn, p_ptt, false, true,
                                      qm_info->start_pq, qm_info->num_pqs);
-       OSAL_SPIN_UNLOCK(&qm_lock);
-       if (!b_rc)
-               return ECORE_INVAL;
+       if (!b_rc) {
+               rc = ECORE_INVAL;
+               goto unlock;
+       }
 
        /* clear the QM_PF runtime phase leftovers from previous init */
        ecore_init_clear_rt_data(p_hwfn);
@@ -2313,18 +2316,17 @@ enum _ecore_status_t ecore_qm_reconf(struct ecore_hwfn *p_hwfn,
        /* activate init tool on runtime array */
        rc = ecore_init_run(p_hwfn, p_ptt, PHASE_QM_PF, p_hwfn->rel_pf_id,
                            p_hwfn->hw_info.hw_mode);
-       if (rc != ECORE_SUCCESS)
-               return rc;
 
        /* start PF's qm queues */
-       OSAL_SPIN_LOCK(&qm_lock);
        b_rc = ecore_send_qm_stop_cmd(p_hwfn, p_ptt, true, true,
                                      qm_info->start_pq, qm_info->num_pqs);
-       OSAL_SPIN_UNLOCK(&qm_lock);
        if (!b_rc)
-               return ECORE_INVAL;
+               rc = ECORE_INVAL;
 
-       return ECORE_SUCCESS;
+unlock:
+       OSAL_SPIN_UNLOCK(&qm_lock);
+
+       return rc;
 }
 
 static enum _ecore_status_t ecore_alloc_qm_data(struct ecore_hwfn *p_hwfn)
@@ -2728,10 +2730,8 @@ static enum _ecore_status_t ecore_hw_init_chip(struct ecore_hwfn *p_hwfn,
 
        ecore_wr(p_hwfn, p_ptt, MISCS_REG_RESET_PL_HV + 4, pl_hv);
 
-       if (CHIP_REV_IS_EMUL(p_dev) &&
-           (ECORE_IS_AH(p_dev)))
-               ecore_wr(p_hwfn, p_ptt, MISCS_REG_RESET_PL_HV_2_K2_E5,
-                        0x3ffffff);
+       if (ECORE_IS_AH(p_dev))
+               ecore_wr(p_hwfn, p_ptt, MISCS_REG_RESET_PL_HV_2_K2, 0x3ffffff);
 
        /* initialize port mode to 4x10G_E (10G with 4x10 SERDES) */
        /* CNIG_REG_NW_PORT_MODE is same for A0 and B0 */
@@ -3015,49 +3015,59 @@ static void ecore_emul_link_init_bb(struct ecore_hwfn *p_hwfn,
        ecore_wr_nw_port(p_hwfn, p_ptt, XLPORT_ENABLE_REG, 0xf, 1, port);
 }
 
-static void ecore_emul_link_init_ah_e5(struct ecore_hwfn *p_hwfn,
+static void ecore_emul_link_init_ah(struct ecore_hwfn *p_hwfn,
                                       struct ecore_ptt *p_ptt)
 {
+       u32 mac_base, mac_config_val = 0xa853;
        u8 port = p_hwfn->port_id;
-       u32 mac_base = NWM_REG_MAC0_K2_E5 + (port << 2) * NWM_REG_MAC0_SIZE;
 
-       DP_INFO(p_hwfn->p_dev, "Configurating Emulation Link %02x\n", port);
-
-       ecore_wr(p_hwfn, p_ptt, CNIG_REG_NIG_PORT0_CONF_K2_E5 + (port << 2),
-                (1 << CNIG_REG_NIG_PORT0_CONF_NIG_PORT_ENABLE_0_K2_E5_SHIFT) |
+       ecore_wr(p_hwfn, p_ptt, CNIG_REG_NIG_PORT0_CONF_K2 + (port << 2),
+                (1 << CNIG_REG_NIG_PORT0_CONF_NIG_PORT_ENABLE_0_K2_SHIFT) |
                 (port <<
-                 CNIG_REG_NIG_PORT0_CONF_NIG_PORT_NWM_PORT_MAP_0_K2_E5_SHIFT) |
-                (0 << CNIG_REG_NIG_PORT0_CONF_NIG_PORT_RATE_0_K2_E5_SHIFT));
+                 CNIG_REG_NIG_PORT0_CONF_NIG_PORT_NWM_PORT_MAP_0_K2_SHIFT) |
+                (0 << CNIG_REG_NIG_PORT0_CONF_NIG_PORT_RATE_0_K2_SHIFT));
 
-       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_XIF_MODE_K2_E5,
-                1 << ETH_MAC_REG_XIF_MODE_XGMII_K2_E5_SHIFT);
+       mac_base = NWM_REG_MAC0_K2 + (port << 2) * NWM_REG_MAC0_SIZE;
 
-       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_FRM_LENGTH_K2_E5,
-                9018 << ETH_MAC_REG_FRM_LENGTH_FRM_LENGTH_K2_E5_SHIFT);
+       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_XIF_MODE_K2,
+                1 << ETH_MAC_REG_XIF_MODE_XGMII_K2_SHIFT);
 
-       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_TX_IPG_LENGTH_K2_E5,
-                0xc << ETH_MAC_REG_TX_IPG_LENGTH_TXIPG_K2_E5_SHIFT);
+       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_FRM_LENGTH_K2,
+                9018 << ETH_MAC_REG_FRM_LENGTH_FRM_LENGTH_K2_SHIFT);
 
-       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_RX_FIFO_SECTIONS_K2_E5,
-                8 << ETH_MAC_REG_RX_FIFO_SECTIONS_RX_SECTION_FULL_K2_E5_SHIFT);
+       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_TX_IPG_LENGTH_K2,
+                0xc << ETH_MAC_REG_TX_IPG_LENGTH_TXIPG_K2_SHIFT);
 
-       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_TX_FIFO_SECTIONS_K2_E5,
+       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_RX_FIFO_SECTIONS_K2,
+                8 << ETH_MAC_REG_RX_FIFO_SECTIONS_RX_SECTION_FULL_K2_SHIFT);
+
+       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_TX_FIFO_SECTIONS_K2,
                 (0xA <<
-                 ETH_MAC_REG_TX_FIFO_SECTIONS_TX_SECTION_EMPTY_K2_E5_SHIFT) |
+                 ETH_MAC_REG_TX_FIFO_SECTIONS_TX_SECTION_EMPTY_K2_SHIFT) |
                 (8 <<
-                 ETH_MAC_REG_TX_FIFO_SECTIONS_TX_SECTION_FULL_K2_E5_SHIFT));
+                 ETH_MAC_REG_TX_FIFO_SECTIONS_TX_SECTION_FULL_K2_SHIFT));
 
-       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_COMMAND_CONFIG_K2_E5,
-                0xa853);
+       /* Strip the CRC field from the frame */
+       mac_config_val &= ~ETH_MAC_REG_COMMAND_CONFIG_CRC_FWD_K2;
+       ecore_wr(p_hwfn, p_ptt, mac_base + ETH_MAC_REG_COMMAND_CONFIG_K2,
+                mac_config_val);
 }
 
 static void ecore_emul_link_init(struct ecore_hwfn *p_hwfn,
                                 struct ecore_ptt *p_ptt)
 {
-       if (ECORE_IS_AH(p_hwfn->p_dev))
-               ecore_emul_link_init_ah_e5(p_hwfn, p_ptt);
-       else /* BB */
+       u8 port = ECORE_IS_BB(p_hwfn->p_dev) ? p_hwfn->port_id * 2
+                                            : p_hwfn->port_id;
+
+       DP_INFO(p_hwfn->p_dev, "Emulation: Configuring Link [port %02x]\n",
+               port);
+
+       if (ECORE_IS_BB(p_hwfn->p_dev))
                ecore_emul_link_init_bb(p_hwfn, p_ptt);
+       else
+               ecore_emul_link_init_ah(p_hwfn, p_ptt);
+
+       return;
 }
 
 static void ecore_link_init_bb(struct ecore_hwfn *p_hwfn,
@@ -3429,6 +3439,14 @@ ecore_hw_init_pf(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
        if (rc != ECORE_SUCCESS)
                return rc;
 
+       /* Use the leading hwfn since in CMT only NIG #0 is operational */
+       if (IS_LEAD_HWFN(p_hwfn)) {
+               rc = ecore_llh_hw_init_pf(p_hwfn, p_ptt,
+                                       p_params->avoid_eng_affin);
+               if (rc)
+                       return rc;
+       }
+
        if (p_params->b_hw_start) {
                /* enable interrupts */
                rc = ecore_int_igu_enable(p_hwfn, p_ptt, p_params->int_mode);
@@ -4180,13 +4198,13 @@ static void ecore_hw_hwfn_prepare(struct ecore_hwfn *p_hwfn)
        /* clear indirect access */
        if (ECORE_IS_AH(p_hwfn->p_dev)) {
                ecore_wr(p_hwfn, p_hwfn->p_main_ptt,
-                        PGLUE_B_REG_PGL_ADDR_E8_F0_K2_E5, 0);
+                        PGLUE_B_REG_PGL_ADDR_E8_F0_K2, 0);
                ecore_wr(p_hwfn, p_hwfn->p_main_ptt,
-                        PGLUE_B_REG_PGL_ADDR_EC_F0_K2_E5, 0);
+                        PGLUE_B_REG_PGL_ADDR_EC_F0_K2, 0);
                ecore_wr(p_hwfn, p_hwfn->p_main_ptt,
-                        PGLUE_B_REG_PGL_ADDR_F0_F0_K2_E5, 0);
+                        PGLUE_B_REG_PGL_ADDR_F0_F0_K2, 0);
                ecore_wr(p_hwfn, p_hwfn->p_main_ptt,
-                        PGLUE_B_REG_PGL_ADDR_F4_F0_K2_E5, 0);
+                        PGLUE_B_REG_PGL_ADDR_F4_F0_K2, 0);
        } else {
                ecore_wr(p_hwfn, p_hwfn->p_main_ptt,
                         PGLUE_B_REG_PGL_ADDR_88_F0_BB, 0);
@@ -5168,7 +5186,7 @@ static void ecore_hw_info_port_num_ah_e5(struct ecore_hwfn *p_hwfn,
 #endif
                for (i = 0; i < MAX_NUM_PORTS_K2; i++) {
                        port = ecore_rd(p_hwfn, p_ptt,
-                                       CNIG_REG_NIG_PORT0_CONF_K2_E5 +
+                                       CNIG_REG_NIG_PORT0_CONF_K2 +
                                        (i * 4));
                        if (port & 1)
                                p_dev->num_ports_in_engine++;
@@ -5602,13 +5620,13 @@ ecore_hw_prepare_single(struct ecore_hwfn *p_hwfn, void OSAL_IOMEM *p_regview,
        if (CHIP_REV_IS_FPGA(p_dev)) {
                DP_NOTICE(p_hwfn, false,
                          "FPGA: workaround; Prevent DMAE parities\n");
-               ecore_wr(p_hwfn, p_hwfn->p_main_ptt, PCIE_REG_PRTY_MASK_K2_E5,
+               ecore_wr(p_hwfn, p_hwfn->p_main_ptt, PCIE_REG_PRTY_MASK_K2,
                         7);
 
                DP_NOTICE(p_hwfn, false,
                          "FPGA: workaround: Set VF bar0 size\n");
                ecore_wr(p_hwfn, p_hwfn->p_main_ptt,
-                        PGLUE_B_REG_VF_BAR0_SIZE_K2_E5, 4);
+                        PGLUE_B_REG_VF_BAR0_SIZE_K2, 4);
        }
 #endif