Skip to content

Commit

Permalink
test: performance: use new ODP_PKTIO_MAX_INDEX define
Browse files Browse the repository at this point in the history
Replace MAX_PKTIO_INDEXES with ODP_PKTIO_MAX_INDEX API define, which value
is quaranteed to be >= odp_pktio_max_index() and odp_pktio_index().

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
  • Loading branch information
MatiasElo committed Oct 20, 2023
1 parent 26c2f2f commit 85072b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
9 changes: 1 addition & 8 deletions test/performance/odp_dmafwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ enum {
#define MAX_OUT_QS 32U
#define MAX_BURST 32U
#define MAX_WORKERS (ODP_THREAD_COUNT_MAX - 1)
#define MAX_PKTIO_INDEXES 1024U

#define MIN(a, b) (((a) <= (b)) ? (a) : (b))
#define MAX(a, b) (((a) >= (b)) ? (a) : (b))
Expand Down Expand Up @@ -126,7 +125,7 @@ typedef void (*pkt_fn_t)(odp_packet_t pkts[], int num, pktio_t *pktio, init_fn_t
typedef void (*drain_fn_t)(thread_config_t *config);

typedef struct prog_config_s {
uint8_t pktio_idx_map[MAX_PKTIO_INDEXES];
uint8_t pktio_idx_map[ODP_PKTIO_MAX_INDEX + 1];
odph_thread_t thread_tbl[MAX_WORKERS];
thread_config_t thread_config[MAX_WORKERS];
pktio_t pktios[MAX_IFS];
Expand Down Expand Up @@ -298,7 +297,6 @@ static odp_bool_t get_stash_capa(odp_stash_capability_t *stash_capa, odp_stash_t

static parse_result_t check_options(prog_config_t *config)
{
const unsigned int idx = odp_pktio_max_index();
odp_dma_capability_t dma_capa;
uint32_t burst_size;
odp_stash_capability_t stash_capa;
Expand All @@ -312,11 +310,6 @@ static parse_result_t check_options(prog_config_t *config)
return PRS_NOK;
}

if (idx >= MAX_PKTIO_INDEXES) {
ODPH_ERR("Invalid packet I/O maximum index: %u (max: %u)\n", idx,
MAX_PKTIO_INDEXES);
}

if (config->copy_type != SW_COPY && config->copy_type != DMA_COPY_EV &&
config->copy_type != DMA_COPY_POLL) {
ODPH_ERR("Invalid copy type: %u\n", config->copy_type);
Expand Down
17 changes: 6 additions & 11 deletions test/performance/odp_l2fwd.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
* Copyright (c) 2019-2022, Nokia
* Copyright (c) 2019-2023, Nokia
* Copyright (c) 2020-2021, Marvell
* All rights reserved.
*
Expand Down Expand Up @@ -42,9 +42,6 @@
/* Maximum number of pktio interfaces */
#define MAX_PKTIOS 8

/* Maximum pktio index table size */
#define MAX_PKTIO_INDEXES 1024

/* Default vector size */
#define DEFAULT_VEC_SIZE MAX_PKT_BURST

Expand Down Expand Up @@ -200,7 +197,7 @@ typedef struct {
/* Destination port lookup table.
* Table index is pktio_index of the API. This is used by the sched
* mode. */
uint8_t dst_port_from_idx[MAX_PKTIO_INDEXES];
uint8_t dst_port_from_idx[ODP_PKTIO_MAX_INDEX + 1];
/* Break workers loop if set to 1 */
odp_atomic_u32_t exit_threads;

Expand Down Expand Up @@ -1411,8 +1408,10 @@ static void init_port_lookup_tbl(void)
int pktio_idx = odp_pktio_index(pktio);
int dst_port = find_dest_port(rx_idx);

if (pktio_idx < 0 || pktio_idx >= MAX_PKTIO_INDEXES) {
ODPH_ERR("Bad pktio index %i\n", pktio_idx);
if (pktio_idx < 0) {
ODPH_ERR("Reading pktio (%s) index failed: %i\n",
gbl_args->appl.if_names[rx_idx], pktio_idx);

exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -2216,10 +2215,6 @@ int main(int argc, char *argv[])
}
}

if (odp_pktio_max_index() >= MAX_PKTIO_INDEXES)
ODPH_DBG("Warning: max pktio index (%u) is too large\n",
odp_pktio_max_index());

bind_workers();

odp_schedule_config_init(&sched_config);
Expand Down
11 changes: 3 additions & 8 deletions test/performance/odp_packet_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ ODP_STATIC_ASSERT(MAX_WORKERS >= 2, "Too few threads");
#define RAND_16BIT_WORDS 128
/* Max retries to generate random data */
#define MAX_RAND_RETRIES 1000
/* Maximum pktio index table size */
#define MAX_PKTIO_INDEXES 1024

/* Used don't free */
#define TX_MODE_DF 0
Expand Down Expand Up @@ -174,7 +172,7 @@ typedef struct test_global_t {
} pktio[MAX_PKTIOS];

/* Interface lookup table. Table index is pktio_index of the API. */
uint8_t if_from_pktio_idx[MAX_PKTIO_INDEXES];
uint8_t if_from_pktio_idx[ODP_PKTIO_MAX_INDEX + 1];

uint32_t num_tx_pkt;
uint32_t num_bins;
Expand Down Expand Up @@ -883,9 +881,6 @@ static int open_pktios(test_global_t *global)

global->pool = pool;

if (odp_pktio_max_index() >= MAX_PKTIO_INDEXES)
ODPH_ERR("Warning: max pktio index (%u) is too large\n", odp_pktio_max_index());

odp_pktio_param_init(&pktio_param);

if (test_options->direct_rx)
Expand Down Expand Up @@ -913,8 +908,8 @@ static int open_pktios(test_global_t *global)
odp_pktio_print(pktio);

pktio_idx = odp_pktio_index(pktio);
if (pktio_idx < 0 || pktio_idx >= MAX_PKTIO_INDEXES) {
ODPH_ERR("Error (%s): Bad pktio index: %i\n", name, pktio_idx);
if (pktio_idx < 0) {
ODPH_ERR("Error (%s): Reading pktio index failed: %i\n", name, pktio_idx);
return -1;
}
global->if_from_pktio_idx[pktio_idx] = i;
Expand Down
2 changes: 1 addition & 1 deletion test/performance/odp_sched_pktio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define DEBUG_PRINT 0
#define MAX_WORKERS 64
#define MAX_PKTIOS 32
#define MAX_PKTIOS (ODP_PKTIO_MAX_INDEX + 1)
#define MAX_PKTIO_NAME 31
#define MAX_PKTIO_QUEUES MAX_WORKERS
#define MAX_PIPE_STAGES 64
Expand Down

0 comments on commit 85072b6

Please sign in to comment.