net/qede: add new host ring type option
authorRasesh Mody <rasesh.mody@cavium.com>
Thu, 5 Jan 2017 07:03:57 +0000 (23:03 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:53 +0000 (19:40 +0100)
Add new option called external PBL (page base list) to ecore_chain_alloc
for future use. Mark chain as external if external PBL is provided.

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore_chain.h
drivers/net/qede/base/ecore_dev.c
drivers/net/qede/base/ecore_dev_api.h
drivers/net/qede/base/ecore_spq.c
drivers/net/qede/qede_if.h
drivers/net/qede/qede_rxtx.c

index 9ad1874..61e39b5 100644 (file)
@@ -54,6 +54,11 @@ struct ecore_chain_pbl_u32 {
        u32 cons_page_idx;
 };
 
+struct ecore_chain_ext_pbl {
+       dma_addr_t p_pbl_phys;
+       void *p_pbl_virt;
+};
+
 struct ecore_chain_pbl {
        /* Base address of a pre-allocated buffer for pbl */
        dma_addr_t p_phys_table;
@@ -69,6 +74,8 @@ struct ecore_chain_pbl {
                struct ecore_chain_pbl_u16 pbl16;
                struct ecore_chain_pbl_u32 pbl32;
        } u;
+
+       bool external;
 };
 
 struct ecore_chain_u16 {
@@ -570,7 +577,7 @@ ecore_chain_init_params(struct ecore_chain *p_chain, u32 page_cnt, u8 elem_size,
        p_chain->page_cnt = page_cnt;
        p_chain->capacity = p_chain->usable_per_page * page_cnt;
        p_chain->size = p_chain->elem_per_page * page_cnt;
-
+       p_chain->pbl.external = false;
        p_chain->pbl.p_phys_table = 0;
        p_chain->pbl.p_virt_table = OSAL_NULL;
        p_chain->pbl.pp_virt_addr_tbl = OSAL_NULL;
index f043808..f29b3cd 100644 (file)
@@ -3193,8 +3193,10 @@ static void ecore_chain_free_pbl(struct ecore_dev *p_dev,
        }
 
        pbl_size = page_cnt * ECORE_CHAIN_PBL_ENTRY_SIZE;
-       OSAL_DMA_FREE_COHERENT(p_dev, p_chain->pbl.p_virt_table,
-                              p_chain->pbl.p_phys_table, pbl_size);
+
+       if (!p_chain->pbl.external)
+               OSAL_DMA_FREE_COHERENT(p_dev, p_chain->pbl.p_virt_table,
+                                      p_chain->pbl.p_phys_table, pbl_size);
  out:
        OSAL_VFREE(p_dev, p_chain->pbl.pp_virt_addr_tbl);
 }
@@ -3294,8 +3296,10 @@ ecore_chain_alloc_single(struct ecore_dev *p_dev, struct ecore_chain *p_chain)
        return ECORE_SUCCESS;
 }
 
-static enum _ecore_status_t ecore_chain_alloc_pbl(struct ecore_dev *p_dev,
-                                                 struct ecore_chain *p_chain)
+static enum _ecore_status_t
+ecore_chain_alloc_pbl(struct ecore_dev *p_dev,
+                     struct ecore_chain *p_chain,
+                     struct ecore_chain_ext_pbl *ext_pbl)
 {
        void *p_virt = OSAL_NULL;
        u8 *p_pbl_virt = OSAL_NULL;
@@ -3319,7 +3323,15 @@ static enum _ecore_status_t ecore_chain_alloc_pbl(struct ecore_dev *p_dev,
         * should be saved to allow its freeing during the error flow.
         */
        size = page_cnt * ECORE_CHAIN_PBL_ENTRY_SIZE;
-       p_pbl_virt = OSAL_DMA_ALLOC_COHERENT(p_dev, &p_pbl_phys, size);
+
+       if (ext_pbl == OSAL_NULL) {
+               p_pbl_virt = OSAL_DMA_ALLOC_COHERENT(p_dev, &p_pbl_phys, size);
+       } else {
+               p_pbl_virt = ext_pbl->p_pbl_virt;
+               p_pbl_phys = ext_pbl->p_pbl_phys;
+               p_chain->pbl.external = true;
+       }
+
        ecore_chain_init_pbl_mem(p_chain, p_pbl_virt, p_pbl_phys,
                                 pp_virt_addr_tbl);
        if (!p_pbl_virt) {
@@ -3357,7 +3369,8 @@ enum _ecore_status_t ecore_chain_alloc(struct ecore_dev *p_dev,
                                       enum ecore_chain_mode mode,
                                       enum ecore_chain_cnt_type cnt_type,
                                       u32 num_elems, osal_size_t elem_size,
-                                      struct ecore_chain *p_chain)
+                                      struct ecore_chain *p_chain,
+                                      struct ecore_chain_ext_pbl *ext_pbl)
 {
        u32 page_cnt;
        enum _ecore_status_t rc = ECORE_SUCCESS;
@@ -3388,7 +3401,7 @@ enum _ecore_status_t ecore_chain_alloc(struct ecore_dev *p_dev,
                rc = ecore_chain_alloc_single(p_dev, p_chain);
                break;
        case ECORE_CHAIN_MODE_PBL:
-               rc = ecore_chain_alloc_pbl(p_dev, p_chain);
+               rc = ecore_chain_alloc_pbl(p_dev, p_chain, ext_pbl);
                break;
        }
        if (rc)
index cbddd24..0ec02b5 100644 (file)
@@ -370,7 +370,8 @@ ecore_chain_alloc(struct ecore_dev *p_dev,
                  enum ecore_chain_cnt_type cnt_type,
                  u32 num_elems,
                  osal_size_t elem_size,
-                 struct ecore_chain *p_chain);
+                 struct ecore_chain *p_chain,
+                 struct ecore_chain_ext_pbl *ext_pbl);
 
 /**
  * @brief ecore_chain_free - Free chain DMA memory
index 0d744dd..c524cab 100644 (file)
@@ -373,7 +373,8 @@ 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)) {
                DP_NOTICE(p_hwfn, true, "Failed to allocate eq chain\n");
                goto eq_allocate_fail;
        }
@@ -501,10 +502,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;
        }
@@ -956,7 +960,8 @@ 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)) {
                DP_NOTICE(p_hwfn, true, "Failed to allocate consq chain");
                goto consq_allocate_fail;
        }
index 2131fe2..4289d0b 100644 (file)
@@ -110,14 +110,16 @@ struct qed_common_ops {
                     uint32_t dp_module, uint8_t dp_level, bool is_vf);
        void (*set_id)(struct ecore_dev *edev,
                char name[], const char ver_str[]);
-       enum _ecore_status_t (*chain_alloc)(struct ecore_dev *edev,
-                                           enum ecore_chain_use_mode
-                                           intended_use,
-                                           enum ecore_chain_mode mode,
-                                           enum ecore_chain_cnt_type cnt_type,
-                                           uint32_t num_elems,
-                                           osal_size_t elem_size,
-                                           struct ecore_chain *p_chain);
+       enum _ecore_status_t
+               (*chain_alloc)(struct ecore_dev *edev,
+                              enum ecore_chain_use_mode
+                              intended_use,
+                              enum ecore_chain_mode mode,
+                              enum ecore_chain_cnt_type cnt_type,
+                              uint32_t num_elems,
+                              osal_size_t elem_size,
+                              struct ecore_chain *p_chain,
+                              struct ecore_chain_ext_pbl *ext_pbl);
 
        void (*chain_free)(struct ecore_dev *edev,
                           struct ecore_chain *p_chain);
index 2a8939a..814d384 100644 (file)
@@ -176,7 +176,8 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
                                            ECORE_CHAIN_CNT_TYPE_U16,
                                            rxq->nb_rx_desc,
                                            sizeof(struct eth_rx_bd),
-                                           &rxq->rx_bd_ring);
+                                           &rxq->rx_bd_ring,
+                                           NULL);
 
        if (rc != ECORE_SUCCESS) {
                DP_NOTICE(edev, false,
@@ -196,7 +197,8 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
                                            ECORE_CHAIN_CNT_TYPE_U16,
                                            rxq->nb_rx_desc,
                                            sizeof(union eth_rx_cqe),
-                                           &rxq->rx_comp_ring);
+                                           &rxq->rx_comp_ring,
+                                           NULL);
 
        if (rc != ECORE_SUCCESS) {
                DP_NOTICE(edev, false,
@@ -291,7 +293,8 @@ qede_tx_queue_setup(struct rte_eth_dev *dev,
                                            ECORE_CHAIN_CNT_TYPE_U16,
                                            txq->nb_tx_desc,
                                            sizeof(union eth_tx_bd_types),
-                                           &txq->tx_pbl);
+                                           &txq->tx_pbl,
+                                           NULL);
        if (rc != ECORE_SUCCESS) {
                DP_ERR(edev,
                       "Unable to allocate memory for txbd ring on socket %u",