From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hemant Agrawal Subject: [PATCHv2 34/34] drivers/common/dpaa2: frame queue based dq storage alloc Date: Tue, 20 Dec 2016 02:24:13 +0530 Message-ID: <1482180853-18823-35-git-send-email-hemant.agrawal@nxp.com> References: <1480875447-23680-1-git-send-email-hemant.agrawal@nxp.com> <1482180853-18823-1-git-send-email-hemant.agrawal@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , , , Hemant Agrawal To: Return-path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0083.outbound.protection.outlook.com [104.47.32.83]) by dpdk.org (Postfix) with ESMTP id DCF9DFACB for ; Mon, 19 Dec 2016 16:22:32 +0100 (CET) In-Reply-To: <1482180853-18823-1-git-send-email-hemant.agrawal@nxp.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/common/dpaa2/dpio/dpaa2_hw_dpio.c | 32 +++++++++++++++++++++++++++++++ drivers/common/dpaa2/dpio/dpaa2_hw_dpio.h | 10 +++++++++- drivers/net/dpaa2/dpaa2_ethdev.c | 8 ++++---- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/drivers/common/dpaa2/dpio/dpaa2_hw_dpio.c b/drivers/common/dpaa2/dpio/dpaa2_hw_dpio.c index d7de0d5..55b5ad7 100644 --- a/drivers/common/dpaa2/dpio/dpaa2_hw_dpio.c +++ b/drivers/common/dpaa2/dpio/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/common/dpaa2/dpio/dpaa2_hw_dpio.h b/drivers/common/dpaa2/dpio/dpaa2_hw_dpio.h index b160c0f..4d871c1 100644 --- a/drivers/common/dpaa2/dpio/dpaa2_hw_dpio.h +++ b/drivers/common/dpaa2/dpio/dpaa2_hw_dpio.h @@ -64,4 +64,12 @@ int dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev, struct vfio_device_info *obj_info, int object_id); -#endif /* _FSLMC_DPIO_H_ */ +/* 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 3a90e7c..43ae4cb 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -49,6 +49,7 @@ #include #include #include +#include #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; } -- 1.9.1