Skip to content

Commit

Permalink
test: packet_gen: allow tx drops
Browse files Browse the repository at this point in the history
Modify packet_gen application to continue transmitting packets even if TX
drops occur. TX drops are recorded in statistics.

Signed-off-by: Matias Elo <[email protected]>
Reviewed-by: Petri Savolainen <[email protected]>
  • Loading branch information
MatiasElo committed Jun 14, 2024
1 parent a2ebaaf commit ce0dfcf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/performance/odp_packet_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,8 @@ static inline uint32_t form_burst(odp_packet_t out_pkt[], uint32_t burst_size, u
return i;
}

static inline uint32_t send_burst(odp_pktout_queue_t pktout, odp_packet_t pkt[],
uint32_t num, int tx_mode, uint64_t *drop_bytes)
static inline int send_burst(odp_pktout_queue_t pktout, odp_packet_t pkt[],
uint32_t num, int tx_mode, uint64_t *drop_bytes)
{
int ret;
uint32_t sent;
Expand All @@ -1928,7 +1928,7 @@ static inline uint32_t send_burst(odp_pktout_queue_t pktout, odp_packet_t pkt[],

*drop_bytes = bytes;

return sent;
return ret;
}

static int tx_thread(void *arg)
Expand Down Expand Up @@ -2024,7 +2024,8 @@ static int tx_thread(void *arg)

/* Send bursts to each pktio */
for (i = 0; i < num_pktio; i++) {
uint32_t num, sent;
uint32_t num;
int sent;
uint64_t total_bytes, drop_bytes;
odp_packet_t pkt[burst_size];

Expand All @@ -2043,15 +2044,15 @@ static int tx_thread(void *arg)

sent = send_burst(pktout[i], pkt, num, tx_mode, &drop_bytes);

if (odp_unlikely(sent == 0)) {
if (odp_unlikely(sent < 0)) {
ret = -1;
tx_drops += burst_size;
break;
}

tx_bytes += total_bytes - drop_bytes;
tx_packets += sent;
if (odp_unlikely(sent < burst_size))
if (odp_unlikely(sent < (int)burst_size))
tx_drops += burst_size - sent;

if (odp_unlikely(periodic_stat))
Expand Down

0 comments on commit ce0dfcf

Please sign in to comment.