Skip to content

Commit

Permalink
linux-gen: queue: implement odp_queue_destroy_multi() function
Browse files Browse the repository at this point in the history
Implement new odp_queue_destroy_multi() function for destroying multiple
queues with a single call.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
  • Loading branch information
MatiasElo committed Oct 20, 2023
1 parent 978e1f6 commit 319bb59
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct {
odp_bool_t share_param, odp_queue_t queue[],
int num);
int (*queue_destroy)(odp_queue_t queue);
int (*queue_destroy_multi)(odp_queue_t queue[], int num);
odp_queue_t (*queue_lookup)(const char *name);
int (*queue_capability)(odp_queue_capability_t *capa);
int (*queue_context_set)(odp_queue_t queue, void *context,
Expand Down
18 changes: 18 additions & 0 deletions platform/linux-generic/odp_queue_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,23 @@ static int queue_destroy(odp_queue_t handle)
return 0;
}

static int queue_destroy_multi(odp_queue_t handle[], int num)
{
int i;

_ODP_ASSERT(handle != NULL);
_ODP_ASSERT(num > 0);

for (i = 0; i < num; i++) {
int ret = queue_destroy(handle[i]);

if (ret)
return (i == 0) ? ret : i;
}

return i;
}

static int queue_context_set(odp_queue_t handle, void *context,
uint32_t len ODP_UNUSED)
{
Expand Down Expand Up @@ -1246,6 +1263,7 @@ _odp_queue_api_fn_t _odp_queue_basic_api = {
.queue_create = queue_create,
.queue_create_multi = queue_create_multi,
.queue_destroy = queue_destroy,
.queue_destroy_multi = queue_destroy_multi,
.queue_lookup = queue_lookup,
.queue_capability = queue_capability,
.queue_context_set = queue_context_set,
Expand Down
5 changes: 5 additions & 0 deletions platform/linux-generic/odp_queue_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ int odp_queue_destroy(odp_queue_t queue)
return _odp_queue_api->queue_destroy(queue);
}

int odp_queue_destroy_multi(odp_queue_t queue[], int num)
{
return _odp_queue_api->queue_destroy_multi(queue, num);
}

odp_queue_t odp_queue_lookup(const char *name)
{
return _odp_queue_api->queue_lookup(name);
Expand Down
18 changes: 18 additions & 0 deletions platform/linux-generic/odp_queue_scalable.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,23 @@ static int queue_destroy(odp_queue_t handle)
return 0;
}

static int queue_destroy_multi(odp_queue_t handle[], int num)
{
int i;

_ODP_ASSERT(handle != NULL);
_ODP_ASSERT(num > 0);

for (i = 0; i < num; i++) {
int ret = queue_destroy(handle[i]);

if (ret)
return (i == 0) ? ret : i;
}

return i;
}

static int queue_context_set(odp_queue_t handle, void *context,
uint32_t len ODP_UNUSED)
{
Expand Down Expand Up @@ -1162,6 +1179,7 @@ _odp_queue_api_fn_t _odp_queue_scalable_api = {
.queue_create = queue_create,
.queue_create_multi = queue_create_multi,
.queue_destroy = queue_destroy,
.queue_destroy_multi = queue_destroy_multi,
.queue_lookup = queue_lookup,
.queue_capability = queue_capability,
.queue_context_set = queue_context_set,
Expand Down

0 comments on commit 319bb59

Please sign in to comment.