Skip to content

Commit

Permalink
linux-gen: traffic_mngr: store input_work_queue inside tm_system_t
Browse files Browse the repository at this point in the history
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information
MatiasElo authored and muvarov committed Dec 3, 2018
1 parent 23102db commit b1812f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion platform/linux-generic/include/odp_traffic_mngr_internal.h
Expand Up @@ -377,7 +377,7 @@ struct tm_system_s {
void *trace_buffer;
uint32_t next_queue_num;
tm_queue_obj_t *queue_num_tbl[ODP_TM_MAX_TM_QUEUES];
input_work_queue_t *input_work_queue;
input_work_queue_t input_work_queue;
tm_queue_cnts_t priority_queue_cnts;
tm_queue_cnts_t total_queue_cnts;
pkt_desc_t egress_pkt_desc;
Expand Down
25 changes: 8 additions & 17 deletions platform/linux-generic/odp_traffic_mngr.c
Expand Up @@ -304,15 +304,11 @@ static void free_dynamic_tbl_entry(dynamic_tbl_t *dynamic_tbl,
}
}

static input_work_queue_t *input_work_queue_create(void)
static void input_work_queue_init(input_work_queue_t *input_work_queue)
{
input_work_queue_t *input_work_queue;

input_work_queue = malloc(sizeof(input_work_queue_t));
memset(input_work_queue, 0, sizeof(input_work_queue_t));
odp_atomic_init_u64(&input_work_queue->queue_cnt, 0);
odp_ticketlock_init(&input_work_queue->lock);
return input_work_queue;
}

static void input_work_queue_destroy(input_work_queue_t *input_work_queue)
Expand All @@ -322,7 +318,7 @@ static void input_work_queue_destroy(input_work_queue_t *input_work_queue)
* stopped new tm_enq() (et al) calls from succeeding.
*/
odp_ticketlock_lock(&input_work_queue->lock);
free(input_work_queue);
memset(input_work_queue, 0, sizeof(input_work_queue_t));
}

static int input_work_queue_append(tm_system_t *tm_system,
Expand All @@ -332,7 +328,7 @@ static int input_work_queue_append(tm_system_t *tm_system,
input_work_item_t *entry_ptr;
uint32_t queue_cnt, tail_idx;

input_work_queue = tm_system->input_work_queue;
input_work_queue = &tm_system->input_work_queue;
queue_cnt = odp_atomic_load_u64(&input_work_queue->queue_cnt);
if (INPUT_WORK_RING_SIZE <= queue_cnt) {
input_work_queue->enqueue_fail_cnt++;
Expand Down Expand Up @@ -2373,7 +2369,7 @@ static void *tm_system_thread(void *arg)

tm_system = tm_group->first_tm_system;
_odp_int_timer_wheel = tm_system->_odp_int_timer_wheel;
input_work_queue = tm_system->input_work_queue;
input_work_queue = &tm_system->input_work_queue;

/* Wait here until we have seen the first enqueue operation. */
odp_barrier_wait(&tm_group->tm_group_barrier);
Expand Down Expand Up @@ -2427,7 +2423,7 @@ static void *tm_system_thread(void *arg)
/* Advance to the next tm_system in the tm_system_group. */
tm_system = tm_system->next;
_odp_int_timer_wheel = tm_system->_odp_int_timer_wheel;
input_work_queue = tm_system->input_work_queue;
input_work_queue = &tm_system->input_work_queue;
}

odp_barrier_wait(&tm_system->tm_system_destroy_barrier);
Expand Down Expand Up @@ -2897,10 +2893,7 @@ odp_tm_t odp_tm_create(const char *name,
== _ODP_INT_TIMER_WHEEL_INVALID;
}

if (create_fail == 0) {
tm_system->input_work_queue = input_work_queue_create();
create_fail |= !tm_system->input_work_queue;
}
input_work_queue_init(&tm_system->input_work_queue);

if (create_fail == 0) {
/* Pass any odp_groups or hints to tm_group_attach here. */
Expand All @@ -2911,8 +2904,6 @@ odp_tm_t odp_tm_create(const char *name,

if (create_fail) {
_odp_int_name_tbl_delete(name_tbl_id);
if (tm_system->input_work_queue)
input_work_queue_destroy(tm_system->input_work_queue);

if (tm_system->_odp_int_sorted_pool
!= _ODP_INT_SORTED_POOL_INVALID)
Expand Down Expand Up @@ -2980,7 +2971,7 @@ int odp_tm_destroy(odp_tm_t odp_tm)
* allocated by this group. */
_odp_tm_group_remove(tm_system->odp_tm_group, odp_tm);

input_work_queue_destroy(tm_system->input_work_queue);
input_work_queue_destroy(&tm_system->input_work_queue);
_odp_sorted_pool_destroy(tm_system->_odp_int_sorted_pool);
_odp_queue_pool_destroy(tm_system->_odp_int_queue_pool);
_odp_timer_wheel_destroy(tm_system->_odp_int_timer_wheel);
Expand Down Expand Up @@ -4600,7 +4591,7 @@ void odp_tm_stats_print(odp_tm_t odp_tm)
uint32_t queue_num, max_queue_num;

tm_system = GET_TM_SYSTEM(odp_tm);
input_work_queue = tm_system->input_work_queue;
input_work_queue = &tm_system->input_work_queue;

ODP_PRINT("odp_tm_stats_print - tm_system=0x%" PRIX64 " tm_idx=%u\n",
odp_tm, tm_system->tm_idx);
Expand Down

0 comments on commit b1812f1

Please sign in to comment.