AF_XDP-interaction: Add option for selecting batch pkts size

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
Jesper Dangaard Brouer
2022-01-18 14:01:57 +01:00
parent 86b76f564f
commit 1a8a2b9188
3 changed files with 21 additions and 3 deletions

View File

@@ -303,6 +303,9 @@ static const struct option_wrapper long_options[] = {
{{"interval", required_argument, NULL, 'i' },
"Periodic TX-cyclic interval wakeup period in usec", "<usec>"},
{{"batch-pkts", required_argument, NULL, 'b' },
"Periodic TX-cyclic batch send pkts", "<pkts>"},
{{0, 0, NULL, 0 }, NULL, false}
};
@@ -1237,8 +1240,8 @@ static void tx_cyclic_and_rx_process(struct config *cfg,
struct timespec now, next, next_adj, interval, now_prev;
struct wakeup_stat stat = { .min = DEFAULT_INTERVAL, .max = -0xFFFF };
struct wakeup_stat stat_adj = { .min = DEFAULT_INTERVAL, .max = -0xFFFF };
int batch_nr = 4;
struct xdp_desc tx_pkts[batch_nr];
struct xdp_desc tx_pkts[BATCH_PKTS_MAX];
int batch_nr = cfg->batch_pkts;
int tx_nr;
int period = cfg->interval;
@@ -1475,6 +1478,7 @@ int main(int argc, char **argv)
.opt_tx_dmac = default_tx_dmac,
.opt_tx_smac = default_tx_smac,
.interval = DEFAULT_INTERVAL,
.batch_pkts = BATCH_PKTS_DEFAULT,
};
pthread_t stats_poll_thread;
struct xsk_umem_info *umem;

View File

@@ -31,8 +31,12 @@ struct config {
struct ether_addr opt_tx_smac;
struct ether_addr opt_tx_dmac;
__u64 interval;
__u32 batch_pkts;
};
#define BATCH_PKTS_MAX 64
#define BATCH_PKTS_DEFAULT 4
/* Defined in common_params.o */
extern int verbose;
extern int debug;

View File

@@ -97,7 +97,8 @@ void parse_cmdline_args(int argc, char **argv,
}
/* Parse commands line args */
while ((opt = getopt_long(argc, argv, "hd:r:L:R:BASNFUMQ:G:H:czqp:ti:",
while ((opt = getopt_long(argc, argv,
"hd:r:L:R:BASNFUMQ:G:H:czqp:ti:b:",
long_options, &longindex)) != -1) {
switch (opt) {
case 'd':
@@ -146,6 +147,15 @@ void parse_cmdline_args(int argc, char **argv,
goto error;
}
break;
case 'b':
cfg->batch_pkts = atoi(optarg);
if (cfg->batch_pkts > BATCH_PKTS_MAX) {
fprintf(stderr, "ERROR: "
" batch (%u) pkts limited to %u\n",
cfg->batch_pkts, BATCH_PKTS_MAX);
goto error;
}
break;
case 'B':
cfg->opt_busy_poll = true;
break;