Imported Upstream version 17.05
[deb_dpdk.git] / drivers / net / qede / base / ecore_spq.c
index 0d744dd..3c1d05b 100644 (file)
@@ -173,11 +173,10 @@ ecore_spq_fill_entry(struct ecore_hwfn *p_hwfn, struct ecore_spq_entry *p_ent)
 static void ecore_spq_hw_initialize(struct ecore_hwfn *p_hwfn,
                                    struct ecore_spq *p_spq)
 {
-       u16 pq;
        struct ecore_cxt_info cxt_info;
        struct core_conn_context *p_cxt;
-       union ecore_qm_pq_params pq_params;
        enum _ecore_status_t rc;
+       u16 physical_q;
 
        cxt_info.iid = p_spq->cid;
 
@@ -191,23 +190,26 @@ static void ecore_spq_hw_initialize(struct ecore_hwfn *p_hwfn,
 
        p_cxt = cxt_info.p_cxt;
 
-       SET_FIELD(p_cxt->xstorm_ag_context.flags10,
-                 XSTORM_CORE_CONN_AG_CTX_DQ_CF_EN, 1);
-       SET_FIELD(p_cxt->xstorm_ag_context.flags1,
-                 XSTORM_CORE_CONN_AG_CTX_DQ_CF_ACTIVE, 1);
-       /* SET_FIELD(p_cxt->xstorm_ag_context.flags10,
-        *           XSTORM_CORE_CONN_AG_CTX_SLOW_PATH_EN, 1);
-        */
-       SET_FIELD(p_cxt->xstorm_ag_context.flags9,
-                 XSTORM_CORE_CONN_AG_CTX_CONSOLID_PROD_CF_EN, 1);
+       /* @@@TBD we zero the context until we have ilt_reset implemented. */
+       OSAL_MEM_ZERO(p_cxt, sizeof(*p_cxt));
+
+       if (ECORE_IS_BB(p_hwfn->p_dev) || ECORE_IS_AH(p_hwfn->p_dev)) {
+               SET_FIELD(p_cxt->xstorm_ag_context.flags10,
+                         E4_XSTORM_CORE_CONN_AG_CTX_DQ_CF_EN, 1);
+               SET_FIELD(p_cxt->xstorm_ag_context.flags1,
+                         E4_XSTORM_CORE_CONN_AG_CTX_DQ_CF_ACTIVE, 1);
+               /* SET_FIELD(p_cxt->xstorm_ag_context.flags10,
+                *        E4_XSTORM_CORE_CONN_AG_CTX_SLOW_PATH_EN, 1);
+                */
+               SET_FIELD(p_cxt->xstorm_ag_context.flags9,
+                         E4_XSTORM_CORE_CONN_AG_CTX_CONSOLID_PROD_CF_EN, 1);
+       }
 
        /* CDU validation - FIXME currently disabled */
 
        /* QM physical queue */
-       OSAL_MEMSET(&pq_params, 0, sizeof(pq_params));
-       pq_params.core.tc = LB_TC;
-       pq = ecore_get_qm_pq(p_hwfn, PROTOCOLID_CORE, &pq_params);
-       p_cxt->xstorm_ag_context.physical_q0 = OSAL_CPU_TO_LE16(pq);
+       physical_q = ecore_get_cm_pq_idx(p_hwfn, PQ_FLAGS_LB);
+       p_cxt->xstorm_ag_context.physical_q0 = OSAL_CPU_TO_LE16(physical_q);
 
        p_cxt->xstorm_st_context.spq_base_lo =
            DMA_LO_LE(p_spq->chain.p_phys_addr);
@@ -248,7 +250,8 @@ static enum _ecore_status_t ecore_spq_hw_post(struct ecore_hwfn *p_hwfn,
        /* make sure the SPQE is updated before the doorbell */
        OSAL_WMB(p_hwfn->p_dev);
 
-       DOORBELL(p_hwfn, DB_ADDR(p_spq->cid, DQ_DEMS_LEGACY), *(u32 *)&db);
+       DOORBELL(p_hwfn, DB_ADDR(p_spq->cid, DQ_DEMS_LEGACY),
+                *(u32 *)&db);
 
        /* make sure doorbell is rang */
        OSAL_WMB(p_hwfn->p_dev);
@@ -355,7 +358,7 @@ enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn,
        return rc;
 }
 
-struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem)
+enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem)
 {
        struct ecore_eq *p_eq;
 
@@ -364,7 +367,7 @@ struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem)
        if (!p_eq) {
                DP_NOTICE(p_hwfn, true,
                          "Failed to allocate `struct ecore_eq'\n");
-               return OSAL_NULL;
+               return ECORE_NOMEM;
        }
 
        /* Allocate and initialize EQ chain*/
@@ -373,34 +376,38 @@ struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem)
                              ECORE_CHAIN_MODE_PBL,
                              ECORE_CHAIN_CNT_TYPE_U16,
                              num_elem,
-                             sizeof(union event_ring_element), &p_eq->chain)) {
+                             sizeof(union event_ring_element),
+                             &p_eq->chain, OSAL_NULL) != ECORE_SUCCESS) {
                DP_NOTICE(p_hwfn, true, "Failed to allocate eq chain\n");
                goto eq_allocate_fail;
        }
 
        /* register EQ completion on the SP SB */
-       ecore_int_register_cb(p_hwfn,
-                             ecore_eq_completion,
+       ecore_int_register_cb(p_hwfn, ecore_eq_completion,
                              p_eq, &p_eq->eq_sb_index, &p_eq->p_fw_cons);
 
-       return p_eq;
+       p_hwfn->p_eq = p_eq;
+       return ECORE_SUCCESS;
 
 eq_allocate_fail:
-       ecore_eq_free(p_hwfn, p_eq);
-       return OSAL_NULL;
+       OSAL_FREE(p_hwfn->p_dev, p_eq);
+       return ECORE_NOMEM;
 }
 
-void ecore_eq_setup(struct ecore_hwfn *p_hwfn, struct ecore_eq *p_eq)
+void ecore_eq_setup(struct ecore_hwfn *p_hwfn)
 {
-       ecore_chain_reset(&p_eq->chain);
+       ecore_chain_reset(&p_hwfn->p_eq->chain);
 }
 
-void ecore_eq_free(struct ecore_hwfn *p_hwfn, struct ecore_eq *p_eq)
+void ecore_eq_free(struct ecore_hwfn *p_hwfn)
 {
-       if (!p_eq)
+       if (!p_hwfn->p_eq)
                return;
-       ecore_chain_free(p_hwfn->p_dev, &p_eq->chain);
-       OSAL_FREE(p_hwfn->p_dev, p_eq);
+
+       ecore_chain_free(p_hwfn->p_dev, &p_hwfn->p_eq->chain);
+
+       OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_eq);
+       p_hwfn->p_eq = OSAL_NULL;
 }
 
 /***************************************************************************
@@ -501,10 +508,13 @@ enum _ecore_status_t ecore_spq_alloc(struct ecore_hwfn *p_hwfn)
        }
 
        /* SPQ ring  */
-       if (ecore_chain_alloc(p_hwfn->p_dev, ECORE_CHAIN_USE_TO_PRODUCE,
-                       ECORE_CHAIN_MODE_SINGLE, ECORE_CHAIN_CNT_TYPE_U16, 0,
-                       /* N/A when the mode is SINGLE */
-                       sizeof(struct slow_path_element), &p_spq->chain)) {
+       if (ecore_chain_alloc(p_hwfn->p_dev,
+                             ECORE_CHAIN_USE_TO_PRODUCE,
+                             ECORE_CHAIN_MODE_SINGLE,
+                             ECORE_CHAIN_CNT_TYPE_U16,
+                             0, /* N/A when the mode is SINGLE */
+                             sizeof(struct slow_path_element),
+                             &p_spq->chain, OSAL_NULL)) {
                DP_NOTICE(p_hwfn, true, "Failed to allocate spq chain\n");
                goto spq_allocate_fail;
        }
@@ -920,6 +930,9 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
        if (found->comp_cb.function)
                found->comp_cb.function(p_hwfn, found->comp_cb.cookie, p_data,
                                        fw_return_code);
+       else
+               DP_VERBOSE(p_hwfn, ECORE_MSG_SPQ,
+                          "Got a completion without a callback function\n");
 
        if ((found->comp_mode != ECORE_SPQ_MODE_EBLOCK) ||
            (found->queue == &p_spq->unlimited_pending))
@@ -937,7 +950,7 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
        return rc;
 }
 
-struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn)
+enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn)
 {
        struct ecore_consq *p_consq;
 
@@ -947,7 +960,7 @@ struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn)
        if (!p_consq) {
                DP_NOTICE(p_hwfn, true,
                          "Failed to allocate `struct ecore_consq'\n");
-               return OSAL_NULL;
+               return ECORE_NOMEM;
        }
 
        /* Allocate and initialize EQ chain */
@@ -956,27 +969,30 @@ struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn)
                              ECORE_CHAIN_MODE_PBL,
                              ECORE_CHAIN_CNT_TYPE_U16,
                              ECORE_CHAIN_PAGE_SIZE / 0x80,
-                             0x80, &p_consq->chain)) {
+                             0x80,
+                             &p_consq->chain, OSAL_NULL) != ECORE_SUCCESS) {
                DP_NOTICE(p_hwfn, true, "Failed to allocate consq chain");
                goto consq_allocate_fail;
        }
 
-       return p_consq;
+       p_hwfn->p_consq = p_consq;
+       return ECORE_SUCCESS;
 
 consq_allocate_fail:
-       ecore_consq_free(p_hwfn, p_consq);
-       return OSAL_NULL;
+       OSAL_FREE(p_hwfn->p_dev, p_consq);
+       return ECORE_NOMEM;
 }
 
-void ecore_consq_setup(struct ecore_hwfn *p_hwfn, struct ecore_consq *p_consq)
+void ecore_consq_setup(struct ecore_hwfn *p_hwfn)
 {
-       ecore_chain_reset(&p_consq->chain);
+       ecore_chain_reset(&p_hwfn->p_consq->chain);
 }
 
-void ecore_consq_free(struct ecore_hwfn *p_hwfn, struct ecore_consq *p_consq)
+void ecore_consq_free(struct ecore_hwfn *p_hwfn)
 {
-       if (!p_consq)
+       if (!p_hwfn->p_consq)
                return;
-       ecore_chain_free(p_hwfn->p_dev, &p_consq->chain);
-       OSAL_FREE(p_hwfn->p_dev, p_consq);
+
+       ecore_chain_free(p_hwfn->p_dev, &p_hwfn->p_consq->chain);
+       OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_consq);
 }