]> git.droids-corp.org - dpdk.git/blobdiff - drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
net/dpaa2: improve the error handling in dev init
[dpdk.git] / drivers / bus / fslmc / portal / dpaa2_hw_dpio.c
index eaf35e96ebaf1cf129694f56f2671e833e04f243..a1a58b9ce9c600a683cbd8934c5b591c94b434e0 100644 (file)
@@ -411,3 +411,35 @@ dpaa2_create_dpio_device(struct fslmc_vfio_device *vdev,
 
        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;
+}