[dpdk-dev,PATCHv4,33/33] drivers/common/dpaa2: frame queue based dq storage alloc

Message ID 1484679174-4174-34-git-send-email-hemant.agrawal@nxp.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show

Checks

Context Check Description
ci/Intel compilation fail apply patch file failure
ci/checkpatch success coding style OK

Commit Message

Hemant Agrawal Jan. 17, 2017, 6:52 p.m.
This patch adds generic functions for allowing dq storage
for the frame queues.
As the frame queues are common resource for different drivers
this is helpful.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c       | 32 ++++++++++++++++++++++++++
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h       |  7 ++++++
 drivers/bus/fslmc/rte_pmd_fslmcbus_version.map |  2 ++
 drivers/net/dpaa2/dpaa2_ethdev.c               |  8 +++----
 4 files changed, 45 insertions(+), 4 deletions(-)

Patch

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index d7de0d5..55b5ad7 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -407,3 +407,35 @@  static inline struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
 
 	return 0;
 }
+
+void
+dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage)
+{
+	int i = 0;
+
+	for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
+		if (q_storage->dq_storage[i])
+			rte_free(q_storage->dq_storage[i]);
+	}
+}
+
+int
+dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage)
+{
+	int i = 0;
+
+	for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
+		q_storage->dq_storage[i] = rte_malloc(NULL,
+			DPAA2_DQRR_RING_SIZE * sizeof(struct qbman_result),
+			RTE_CACHE_LINE_SIZE);
+		if (!q_storage->dq_storage[i])
+			goto fail;
+	}
+	return 0;
+fail:
+	i -= 1;
+	while (i >= 0)
+		rte_free(q_storage->dq_storage[i]);
+
+	return -1;
+}
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
index b1a1b8f..f2e1168 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
@@ -59,5 +59,12 @@  struct dpaa2_io_portal_t {
 /* Affine additional DPIO portal to current crypto processing thread */
 int dpaa2_affine_qbman_swp_sec(void);
 
+/* allocate memory for FQ - dq storage */
+int
+dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage);
+
+/* free memory for FQ- dq storage */
+void
+dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage);
 
 #endif /* _DPAA2_HW_DPIO_H_ */
diff --git a/drivers/bus/fslmc/rte_pmd_fslmcbus_version.map b/drivers/bus/fslmc/rte_pmd_fslmcbus_version.map
index 17befc7..bccdc75 100644
--- a/drivers/bus/fslmc/rte_pmd_fslmcbus_version.map
+++ b/drivers/bus/fslmc/rte_pmd_fslmcbus_version.map
@@ -4,7 +4,9 @@  DPDK_17.02 {
         dpaa2_affine_qbman_swp;
         dpaa2_affine_qbman_swp_sec;
         dpaa2_alloc_dpbp_dev;
+        dpaa2_alloc_dq_storage;
         dpaa2_free_dpbp_dev;
+        dpaa2_free_dq_storage;
         dpbp_disable;
         dpbp_enable;
         dpbp_get_attributes;
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 183b5b1..695ee61 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -49,6 +49,7 @@ 
 #include <fslmc_vfio.h>
 #include <dpaa2_hw_pvt.h>
 #include <dpaa2_hw_mempool.h>
+#include <dpaa2_hw_dpio.h>
 
 #include "dpaa2_ethdev.h"
 
@@ -170,9 +171,8 @@ 
 
 		memset(dpaa2_q->q_storage, 0,
 		       sizeof(struct queue_storage_info_t));
-		dpaa2_q->q_storage->dq_storage[0] = rte_malloc(NULL,
-			DPAA2_DQRR_RING_SIZE * sizeof(struct qbman_result),
-			RTE_CACHE_LINE_SIZE);
+		if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage))
+			goto fail;
 	}
 
 	for (i = 0; i < priv->nb_tx_queues; i++) {
@@ -196,7 +196,7 @@ 
 	mc_q = priv->rx_vq[0];
 	while (i >= 0) {
 		dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
-		rte_free(dpaa2_q->q_storage->dq_storage[0]);
+		dpaa2_free_dq_storage(dpaa2_q->q_storage);
 		rte_free(dpaa2_q->q_storage);
 		priv->rx_vq[i--] = NULL;
 	}