Imported Upstream version 16.11
[deb_dpdk.git] / drivers / net / qede / base / ecore_sp_commands.c
index e9ac898..b3736a8 100644 (file)
@@ -21,6 +21,7 @@
 #include "ecore_int.h"
 #include "ecore_hw.h"
 #include "ecore_dcbx.h"
+#include "ecore_sriov.h"
 
 enum _ecore_status_t ecore_sp_init_request(struct ecore_hwfn *p_hwfn,
                                           struct ecore_spq_entry **pp_ent,
@@ -32,6 +33,9 @@ enum _ecore_status_t ecore_sp_init_request(struct ecore_hwfn *p_hwfn,
        struct ecore_spq_entry *p_ent = OSAL_NULL;
        enum _ecore_status_t rc = ECORE_NOTIMPL;
 
+       if (!pp_ent)
+               return ECORE_INVAL;
+
        /* Get an SPQ entry */
        rc = ecore_spq_get_entry(p_hwfn, pp_ent);
        if (rc != ECORE_SUCCESS)
@@ -95,6 +99,8 @@ static enum tunnel_clss ecore_tunn_get_clss_type(u8 type)
                return TUNNEL_CLSS_INNER_MAC_VLAN;
        case ECORE_TUNN_CLSS_INNER_MAC_VNI:
                return TUNNEL_CLSS_INNER_MAC_VNI;
+       case ECORE_TUNN_CLSS_MAC_VLAN_DUAL_STAGE:
+               return TUNNEL_CLSS_MAC_VLAN_DUAL_STAGE;
        default:
                return TUNNEL_CLSS_MAC_VLAN;
        }
@@ -323,11 +329,11 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
                                       bool allow_npar_tx_switch)
 {
        struct pf_start_ramrod_data *p_ramrod = OSAL_NULL;
-       struct ecore_spq_entry *p_ent = OSAL_NULL;
        u16 sb = ecore_int_get_sp_sb_id(p_hwfn);
        u8 sb_index = p_hwfn->p_eq->eq_sb_index;
-       enum _ecore_status_t rc = ECORE_NOTIMPL;
+       struct ecore_spq_entry *p_ent = OSAL_NULL;
        struct ecore_sp_init_data init_data;
+       enum _ecore_status_t rc = ECORE_NOTIMPL;
        u8 page_cnt;
 
        /* update initial eq producer */
@@ -351,7 +357,6 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
        p_ramrod->event_ring_sb_id = OSAL_CPU_TO_LE16(sb);
        p_ramrod->event_ring_sb_index = sb_index;
        p_ramrod->path_id = ECORE_PATH_ID(p_hwfn);
-       p_ramrod->outer_tag = p_hwfn->hw_info.ovlan;
 
        /* For easier debugging */
        p_ramrod->dont_log_ramrods = 0;
@@ -370,6 +375,7 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
                          "Unsupported MF mode, init as DEFAULT\n");
                p_ramrod->mf_mode = MF_NPAR;
        }
+       p_ramrod->outer_tag = p_hwfn->hw_info.ovlan;
 
        /* Place EQ address in RAMROD */
        DMA_REGPAIR_LE(p_ramrod->event_ring_pbl_addr,
@@ -391,12 +397,21 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
                break;
        default:
                DP_NOTICE(p_hwfn, true, "Unknown personality %d\n",
-                         p_hwfn->hw_info.personality);
+                        p_hwfn->hw_info.personality);
                p_ramrod->personality = PERSONALITY_ETH;
        }
 
-       p_ramrod->base_vf_id = (u8)p_hwfn->hw_info.first_vf_in_pf;
-       p_ramrod->num_vfs = (u8)p_hwfn->p_dev->sriov_info.total_vfs;
+       if (p_hwfn->p_dev->p_iov_info) {
+               struct ecore_hw_sriov_info *p_iov = p_hwfn->p_dev->p_iov_info;
+
+               p_ramrod->base_vf_id = (u8)p_iov->first_vf_in_pf;
+               p_ramrod->num_vfs = (u8)p_iov->total_vfs;
+       }
+       /* @@@TBD - update also the "ROCE_VER_KEY" entries when the FW RoCE HSI
+        * version is available.
+        */
+       p_ramrod->hsi_fp_ver.major_ver_arr[ETH_VER_KEY] = ETH_HSI_VER_MAJOR;
+       p_ramrod->hsi_fp_ver.minor_ver_arr[ETH_VER_KEY] = ETH_HSI_VER_MINOR;
 
        DP_VERBOSE(p_hwfn, ECORE_MSG_SPQ,
                   "Setting event_ring_sb [id %04x index %02x], outer_tag [%d]\n",
@@ -416,8 +431,8 @@ enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
 enum _ecore_status_t ecore_sp_pf_update(struct ecore_hwfn *p_hwfn)
 {
        struct ecore_spq_entry *p_ent = OSAL_NULL;
-       enum _ecore_status_t rc = ECORE_NOTIMPL;
        struct ecore_sp_init_data init_data;
+       enum _ecore_status_t rc = ECORE_NOTIMPL;
 
        /* Get SPQ entry */
        OSAL_MEMSET(&init_data, 0, sizeof(init_data));
@@ -437,6 +452,49 @@ enum _ecore_status_t ecore_sp_pf_update(struct ecore_hwfn *p_hwfn)
        return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
 }
 
+enum _ecore_status_t ecore_sp_rl_update(struct ecore_hwfn *p_hwfn,
+                                       struct ecore_rl_update_params *params)
+{
+       struct ecore_spq_entry *p_ent = OSAL_NULL;
+       enum _ecore_status_t rc = ECORE_NOTIMPL;
+       struct rl_update_ramrod_data *rl_update;
+       struct ecore_sp_init_data init_data;
+
+       /* Get SPQ entry */
+       OSAL_MEMSET(&init_data, 0, sizeof(init_data));
+       init_data.cid = ecore_spq_get_cid(p_hwfn);
+       init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
+       init_data.comp_mode = ECORE_SPQ_MODE_EBLOCK;
+
+       rc = ecore_sp_init_request(p_hwfn, &p_ent,
+                                  COMMON_RAMROD_RL_UPDATE, PROTOCOLID_COMMON,
+                                  &init_data);
+       if (rc != ECORE_SUCCESS)
+               return rc;
+
+       rl_update = &p_ent->ramrod.rl_update;
+
+       rl_update->qcn_update_param_flg = params->qcn_update_param_flg;
+       rl_update->dcqcn_update_param_flg = params->dcqcn_update_param_flg;
+       rl_update->rl_init_flg = params->rl_init_flg;
+       rl_update->rl_start_flg = params->rl_start_flg;
+       rl_update->rl_stop_flg = params->rl_stop_flg;
+       rl_update->rl_id_first = params->rl_id_first;
+       rl_update->rl_id_last = params->rl_id_last;
+       rl_update->rl_dc_qcn_flg = params->rl_dc_qcn_flg;
+       rl_update->rl_bc_rate = OSAL_CPU_TO_LE32(params->rl_bc_rate);
+       rl_update->rl_max_rate = OSAL_CPU_TO_LE16(params->rl_max_rate);
+       rl_update->rl_r_ai = OSAL_CPU_TO_LE16(params->rl_r_ai);
+       rl_update->rl_r_hai = OSAL_CPU_TO_LE16(params->rl_r_hai);
+       rl_update->dcqcn_g = OSAL_CPU_TO_LE16(params->dcqcn_g);
+       rl_update->dcqcn_k_us = OSAL_CPU_TO_LE32(params->dcqcn_k_us);
+       rl_update->dcqcn_timeuot_us = OSAL_CPU_TO_LE32(
+               params->dcqcn_timeuot_us);
+       rl_update->qcn_timeuot_us = OSAL_CPU_TO_LE32(params->qcn_timeuot_us);
+
+       return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
+}
+
 /* Set pf update ramrod command params */
 enum _ecore_status_t
 ecore_sp_pf_update_tunn_cfg(struct ecore_hwfn *p_hwfn,
@@ -445,8 +503,8 @@ ecore_sp_pf_update_tunn_cfg(struct ecore_hwfn *p_hwfn,
                            struct ecore_spq_comp_cb *p_comp_data)
 {
        struct ecore_spq_entry *p_ent = OSAL_NULL;
-       enum _ecore_status_t rc = ECORE_NOTIMPL;
        struct ecore_sp_init_data init_data;
+       enum _ecore_status_t rc = ECORE_NOTIMPL;
 
        /* Get SPQ entry */
        OSAL_MEMSET(&init_data, 0, sizeof(init_data));
@@ -465,28 +523,27 @@ ecore_sp_pf_update_tunn_cfg(struct ecore_hwfn *p_hwfn,
                                        &p_ent->ramrod.pf_update.tunnel_config);
 
        rc = ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
+       if (rc != ECORE_SUCCESS)
+               return rc;
 
-       if ((rc == ECORE_SUCCESS) && p_tunn) {
-               if (p_tunn->update_vxlan_udp_port)
-                       ecore_set_vxlan_dest_port(p_hwfn, p_hwfn->p_main_ptt,
-                                                 p_tunn->vxlan_udp_port);
-               if (p_tunn->update_geneve_udp_port)
-                       ecore_set_geneve_dest_port(p_hwfn, p_hwfn->p_main_ptt,
-                                                  p_tunn->geneve_udp_port);
+       if (p_tunn->update_vxlan_udp_port)
+               ecore_set_vxlan_dest_port(p_hwfn, p_hwfn->p_main_ptt,
+                                         p_tunn->vxlan_udp_port);
+       if (p_tunn->update_geneve_udp_port)
+               ecore_set_geneve_dest_port(p_hwfn, p_hwfn->p_main_ptt,
+                                          p_tunn->geneve_udp_port);
 
-               ecore_set_hw_tunn_mode(p_hwfn, p_hwfn->p_main_ptt,
-                                      p_tunn->tunn_mode);
-               p_hwfn->p_dev->tunn_mode = p_tunn->tunn_mode;
-       }
+       ecore_set_hw_tunn_mode(p_hwfn, p_hwfn->p_main_ptt, p_tunn->tunn_mode);
+       p_hwfn->p_dev->tunn_mode = p_tunn->tunn_mode;
 
        return rc;
 }
 
 enum _ecore_status_t ecore_sp_pf_stop(struct ecore_hwfn *p_hwfn)
 {
-       enum _ecore_status_t rc = ECORE_NOTIMPL;
        struct ecore_spq_entry *p_ent = OSAL_NULL;
        struct ecore_sp_init_data init_data;
+       enum _ecore_status_t rc = ECORE_NOTIMPL;
 
        /* Get SPQ entry */
        OSAL_MEMSET(&init_data, 0, sizeof(init_data));
@@ -506,8 +563,8 @@ enum _ecore_status_t ecore_sp_pf_stop(struct ecore_hwfn *p_hwfn)
 enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn)
 {
        struct ecore_spq_entry *p_ent = OSAL_NULL;
-       enum _ecore_status_t rc = ECORE_NOTIMPL;
        struct ecore_sp_init_data init_data;
+       enum _ecore_status_t rc = ECORE_NOTIMPL;
 
        /* Get SPQ entry */
        OSAL_MEMSET(&init_data, 0, sizeof(init_data));