bus/fslmc: update TAILQ usages in dpaa2 objects
This patch updates the usages of malloc and TAILQ in dpbp and dpio objects. Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
This commit is contained in:
parent
23d6a87ee2
commit
0ccb1bef96
@ -53,8 +53,9 @@
|
||||
#include "portal/dpaa2_hw_pvt.h"
|
||||
#include "portal/dpaa2_hw_dpio.h"
|
||||
|
||||
TAILQ_HEAD(dpbp_device_list, dpaa2_dpbp_dev);
|
||||
static struct dpbp_device_list *dpbp_dev_list; /*!< DPBP device list */
|
||||
TAILQ_HEAD(dpbp_dev_list, dpaa2_dpbp_dev);
|
||||
static struct dpbp_dev_list dpbp_dev_list
|
||||
= TAILQ_HEAD_INITIALIZER(dpbp_dev_list); /*!< DPBP device list */
|
||||
|
||||
int
|
||||
dpaa2_create_dpbp_device(
|
||||
@ -63,19 +64,8 @@ dpaa2_create_dpbp_device(
|
||||
struct dpaa2_dpbp_dev *dpbp_node;
|
||||
int ret;
|
||||
|
||||
if (!dpbp_dev_list) {
|
||||
dpbp_dev_list = malloc(sizeof(struct dpbp_device_list));
|
||||
if (!dpbp_dev_list) {
|
||||
PMD_INIT_LOG(ERR, "Memory alloc failed in DPBP list\n");
|
||||
return -1;
|
||||
}
|
||||
/* Initialize the DPBP List */
|
||||
TAILQ_INIT(dpbp_dev_list);
|
||||
}
|
||||
|
||||
/* Allocate DPAA2 dpbp handle */
|
||||
dpbp_node = (struct dpaa2_dpbp_dev *)
|
||||
malloc(sizeof(struct dpaa2_dpbp_dev));
|
||||
dpbp_node = rte_malloc(NULL, sizeof(struct dpaa2_dpbp_dev), 0);
|
||||
if (!dpbp_node) {
|
||||
PMD_INIT_LOG(ERR, "Memory allocation failed for DPBP Device");
|
||||
return -1;
|
||||
@ -88,7 +78,7 @@ dpaa2_create_dpbp_device(
|
||||
if (ret) {
|
||||
PMD_INIT_LOG(ERR, "Resource alloc failure with err code: %d",
|
||||
ret);
|
||||
free(dpbp_node);
|
||||
rte_free(dpbp_node);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -98,14 +88,14 @@ dpaa2_create_dpbp_device(
|
||||
PMD_INIT_LOG(ERR, "Failure cleaning dpbp device with"
|
||||
" error code %d\n", ret);
|
||||
dpbp_close(&dpbp_node->dpbp, CMD_PRI_LOW, dpbp_node->token);
|
||||
free(dpbp_node);
|
||||
rte_free(dpbp_node);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dpbp_node->dpbp_id = dpbp_id;
|
||||
rte_atomic16_init(&dpbp_node->in_use);
|
||||
|
||||
TAILQ_INSERT_HEAD(dpbp_dev_list, dpbp_node, next);
|
||||
TAILQ_INSERT_TAIL(&dpbp_dev_list, dpbp_node, next);
|
||||
|
||||
PMD_INIT_LOG(DEBUG, "Buffer pool resource initialized %d", dpbp_id);
|
||||
|
||||
@ -117,7 +107,7 @@ struct dpaa2_dpbp_dev *dpaa2_alloc_dpbp_dev(void)
|
||||
struct dpaa2_dpbp_dev *dpbp_dev = NULL;
|
||||
|
||||
/* Get DPBP dev handle from list using index */
|
||||
TAILQ_FOREACH(dpbp_dev, dpbp_dev_list, next) {
|
||||
TAILQ_FOREACH(dpbp_dev, &dpbp_dev_list, next) {
|
||||
if (dpbp_dev && rte_atomic16_test_and_set(&dpbp_dev->in_use))
|
||||
break;
|
||||
}
|
||||
@ -130,7 +120,7 @@ void dpaa2_free_dpbp_dev(struct dpaa2_dpbp_dev *dpbp)
|
||||
struct dpaa2_dpbp_dev *dpbp_dev = NULL;
|
||||
|
||||
/* Match DPBP handle and mark it free */
|
||||
TAILQ_FOREACH(dpbp_dev, dpbp_dev_list, next) {
|
||||
TAILQ_FOREACH(dpbp_dev, &dpbp_dev_list, next) {
|
||||
if (dpbp_dev == dpbp) {
|
||||
rte_atomic16_dec(&dpbp_dev->in_use);
|
||||
return;
|
||||
|
@ -69,8 +69,9 @@ RTE_DEFINE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io);
|
||||
|
||||
struct swp_active_dqs rte_global_active_dqs_list[NUM_MAX_SWP];
|
||||
|
||||
TAILQ_HEAD(dpio_device_list, dpaa2_dpio_dev);
|
||||
static struct dpio_device_list *dpio_dev_list; /*!< DPIO device list */
|
||||
TAILQ_HEAD(dpio_dev_list, dpaa2_dpio_dev);
|
||||
static struct dpio_dev_list dpio_dev_list
|
||||
= TAILQ_HEAD_INITIALIZER(dpio_dev_list); /*!< DPIO device list */
|
||||
static uint32_t io_space_count;
|
||||
|
||||
/*Stashing Macros default for LS208x*/
|
||||
@ -214,7 +215,7 @@ static inline struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
|
||||
int ret;
|
||||
|
||||
/* Get DPIO dev handle from list using index */
|
||||
TAILQ_FOREACH(dpio_dev, dpio_dev_list, next) {
|
||||
TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
|
||||
if (dpio_dev && rte_atomic16_test_and_set(&dpio_dev->ref_count))
|
||||
break;
|
||||
}
|
||||
@ -336,18 +337,8 @@ dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!dpio_dev_list) {
|
||||
dpio_dev_list = malloc(sizeof(struct dpio_device_list));
|
||||
if (!dpio_dev_list) {
|
||||
PMD_INIT_LOG(ERR, "Memory alloc failed in DPIO list\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize the DPIO List */
|
||||
TAILQ_INIT(dpio_dev_list);
|
||||
}
|
||||
|
||||
dpio_dev = malloc(sizeof(struct dpaa2_dpio_dev));
|
||||
dpio_dev = rte_malloc(NULL, sizeof(struct dpaa2_dpio_dev),
|
||||
RTE_CACHE_LINE_SIZE);
|
||||
if (!dpio_dev) {
|
||||
PMD_INIT_LOG(ERR, "Memory allocation failed for DPIO Device\n");
|
||||
return -1;
|
||||
@ -364,7 +355,7 @@ dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
|
||||
reg_info.index = 0;
|
||||
if (ioctl(dpio_dev->vfio_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {
|
||||
PMD_INIT_LOG(ERR, "vfio: error getting region info\n");
|
||||
free(dpio_dev);
|
||||
rte_free(dpio_dev);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -381,14 +372,14 @@ dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
|
||||
if (vfio_dmamap_mem_region(dpio_dev->qbman_portal_ce_paddr,
|
||||
reg_info.offset, reg_info.size)) {
|
||||
PMD_INIT_LOG(ERR, "DMAMAP for Portal CE area failed.\n");
|
||||
free(dpio_dev);
|
||||
rte_free(dpio_dev);
|
||||
return -1;
|
||||
}
|
||||
|
||||
reg_info.index = 1;
|
||||
if (ioctl(dpio_dev->vfio_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {
|
||||
PMD_INIT_LOG(ERR, "vfio: error getting region info\n");
|
||||
free(dpio_dev);
|
||||
rte_free(dpio_dev);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -403,13 +394,14 @@ dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
|
||||
PMD_INIT_LOG(ERR,
|
||||
"Fail to configure the dpio qbman portal for %d\n",
|
||||
dpio_dev->hw_id);
|
||||
free(dpio_dev);
|
||||
rte_free(dpio_dev);
|
||||
return -1;
|
||||
}
|
||||
|
||||
io_space_count++;
|
||||
dpio_dev->index = io_space_count;
|
||||
TAILQ_INSERT_HEAD(dpio_dev_list, dpio_dev, next);
|
||||
TAILQ_INSERT_TAIL(&dpio_dev_list, dpio_dev, next);
|
||||
PMD_INIT_LOG(DEBUG, "DPAA2:Added [dpio-%d]", object_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user