[dpdk-dev] [PATCH 30/32] net/dpaa2: frame queue based dq storage alloc

Hemant Agrawal hemant.agrawal at nxp.com
Sun Dec 4 19:17:25 CET 2016


Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpio.c | 32 ++++++++++++++++++++++++++++++++
 drivers/net/dpaa2/base/dpaa2_hw_dpio.h |  8 ++++++++
 drivers/net/dpaa2/dpaa2_ethdev.c       |  7 +++----
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpio.c b/drivers/net/dpaa2/base/dpaa2_hw_dpio.c
index 3b8f87d..38fa858 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpio.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpio.c
@@ -479,3 +479,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/net/dpaa2/base/dpaa2_hw_dpio.h b/drivers/net/dpaa2/base/dpaa2_hw_dpio.h
index 8480ce3..ccf2428 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpio.h
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpio.h
@@ -65,4 +65,12 @@ int dpaa2_create_dpio_device(struct dpaa2_vfio_device *vdev,
 			     struct vfio_device_info *obj_info,
 			     int object_id);
 
+/* 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/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2603a08..1a25f07 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -51,6 +51,7 @@
 
 #include <base/dpaa2_hw_dpbp.h>
 #include <base/dpaa2_hw_dpni.h>
+#include <base/dpaa2_hw_dpio.h>
 
 /* DPDK Interfaces */
 #include <dpaa2_ethdev.h>
@@ -122,9 +123,7 @@
 
 		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);
+		dpaa2_alloc_dq_storage(dpaa2_q->q_storage);
 	}
 
 	for (i = 0; i < priv->nb_tx_queues; i++) {
@@ -148,7 +147,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;
 	}
-- 
1.9.1



More information about the dev mailing list