aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVincenzo Maffione <vmaffione@FreeBSD.org>2019-03-20 10:36:58 +0000
committerVincenzo Maffione <vmaffione@FreeBSD.org>2019-03-20 10:36:58 +0000
commit5e874d26a272608d3931d4ada2a76ef273da2dcb (patch)
tree5f2b021532335f0728c6c6aca6e130664639e755 /tests
parentb8c431f9c032f1c14ef36e272efeaac6e09f638b (diff)
Notes
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/netmap/ctrl-api-test.c90
1 files changed, 68 insertions, 22 deletions
diff --git a/tests/sys/netmap/ctrl-api-test.c b/tests/sys/netmap/ctrl-api-test.c
index e7ea8f7113b7..fac6595e0cc8 100644
--- a/tests/sys/netmap/ctrl-api-test.c
+++ b/tests/sys/netmap/ctrl-api-test.c
@@ -146,12 +146,12 @@ struct TestContext {
uint32_t nr_hdr_len; /* for PORT_HDR_SET and PORT_HDR_GET */
uint32_t nr_first_cpu_id; /* vale polling */
uint32_t nr_num_polling_cpus; /* vale polling */
+ uint32_t sync_kloop_mode; /* sync-kloop */
int fd; /* netmap file descriptor */
void *csb; /* CSB entries (atok and ktoa) */
struct nmreq_option *nr_opt; /* list of options */
sem_t *sem; /* for thread synchronization */
- struct nmport_d *nmport; /* nmport descriptor from libnetmap */
};
static struct TestContext ctx_;
@@ -352,8 +352,11 @@ niocregif(struct TestContext *ctx, int netmap_api)
/* The 11 ABI is the one right before the introduction of the new NIOCCTRL
* ABI. The 11 ABI is useful to perform tests with legacy applications
- * (which use the 11 ABI) and new kernel (which uses 12, or higher). */
-#define NETMAP_API_NIOCREGIF 11
+ * (which use the 11 ABI) and new kernel (which uses 12, or higher).
+ * However, version 14 introduced a change in the layout of struct netmap_if,
+ * so that binary backward compatibility to 11 is not supported anymore.
+ */
+#define NETMAP_API_NIOCREGIF 14
static int
legacy_regif_default(struct TestContext *ctx)
@@ -1113,7 +1116,7 @@ bad_extmem_option(struct TestContext *ctx)
pools_info_fill(&pools_info);
/* Request a large ring size, to make sure that the kernel
* rejects our request. */
- pools_info.nr_ring_pool_objsize = (1 << 16);
+ pools_info.nr_ring_pool_objsize = (1 << 20);
return _extmem_option(ctx, &pools_info) < 0 ? 0 : -1;
}
@@ -1140,6 +1143,10 @@ duplicate_extmem_options(struct TestContext *ctx)
save1 = e1;
save2 = e2;
+ strncpy(ctx->ifname_ext, "vale0:0", sizeof(ctx->ifname_ext));
+ ctx->nr_tx_slots = 16;
+ ctx->nr_rx_slots = 16;
+
ret = port_register_hwall(ctx);
if (ret >= 0) {
printf("duplicate option not detected\n");
@@ -1322,51 +1329,58 @@ sync_kloop(struct TestContext *ctx)
static int
sync_kloop_eventfds(struct TestContext *ctx)
{
- struct nmreq_opt_sync_kloop_eventfds *opt = NULL;
- struct nmreq_option save;
+ struct nmreq_opt_sync_kloop_eventfds *evopt = NULL;
+ struct nmreq_opt_sync_kloop_mode modeopt;
+ struct nmreq_option evsave;
int num_entries;
size_t opt_size;
int ret, i;
+ memset(&modeopt, 0, sizeof(modeopt));
+ modeopt.nro_opt.nro_reqtype = NETMAP_REQ_OPT_SYNC_KLOOP_MODE;
+ modeopt.mode = ctx->sync_kloop_mode;
+ push_option(&modeopt.nro_opt, ctx);
+
num_entries = num_registered_rings(ctx);
- opt_size = sizeof(*opt) + num_entries * sizeof(opt->eventfds[0]);
- opt = calloc(1, opt_size);
- opt->nro_opt.nro_next = 0;
- opt->nro_opt.nro_reqtype = NETMAP_REQ_OPT_SYNC_KLOOP_EVENTFDS;
- opt->nro_opt.nro_status = 0;
- opt->nro_opt.nro_size = opt_size;
+ opt_size = sizeof(*evopt) + num_entries * sizeof(evopt->eventfds[0]);
+ evopt = calloc(1, opt_size);
+ evopt->nro_opt.nro_next = 0;
+ evopt->nro_opt.nro_reqtype = NETMAP_REQ_OPT_SYNC_KLOOP_EVENTFDS;
+ evopt->nro_opt.nro_status = 0;
+ evopt->nro_opt.nro_size = opt_size;
for (i = 0; i < num_entries; i++) {
int efd = eventfd(0, 0);
- opt->eventfds[i].ioeventfd = efd;
+ evopt->eventfds[i].ioeventfd = efd;
efd = eventfd(0, 0);
- opt->eventfds[i].irqfd = efd;
+ evopt->eventfds[i].irqfd = efd;
}
- push_option(&opt->nro_opt, ctx);
- save = opt->nro_opt;
+ push_option(&evopt->nro_opt, ctx);
+ evsave = evopt->nro_opt;
ret = sync_kloop_start_stop(ctx);
if (ret != 0) {
- free(opt);
+ free(evopt);
clear_options(ctx);
return ret;
}
#ifdef __linux__
- save.nro_status = 0;
+ evsave.nro_status = 0;
#else /* !__linux__ */
- save.nro_status = EOPNOTSUPP;
+ evsave.nro_status = EOPNOTSUPP;
#endif /* !__linux__ */
- ret = checkoption(&opt->nro_opt, &save);
- free(opt);
+ ret = checkoption(&evopt->nro_opt, &evsave);
+ free(evopt);
clear_options(ctx);
return ret;
}
static int
-sync_kloop_eventfds_all(struct TestContext *ctx)
+sync_kloop_eventfds_all_mode(struct TestContext *ctx,
+ uint32_t sync_kloop_mode)
{
int ret;
@@ -1375,10 +1389,18 @@ sync_kloop_eventfds_all(struct TestContext *ctx)
return ret;
}
+ ctx->sync_kloop_mode = sync_kloop_mode;
+
return sync_kloop_eventfds(ctx);
}
static int
+sync_kloop_eventfds_all(struct TestContext *ctx)
+{
+ return sync_kloop_eventfds_all_mode(ctx, 0);
+}
+
+static int
sync_kloop_eventfds_all_tx(struct TestContext *ctx)
{
struct nmreq_opt_csb opt;
@@ -1399,6 +1421,27 @@ sync_kloop_eventfds_all_tx(struct TestContext *ctx)
}
static int
+sync_kloop_eventfds_all_direct(struct TestContext *ctx)
+{
+ return sync_kloop_eventfds_all_mode(ctx,
+ NM_OPT_SYNC_KLOOP_DIRECT_TX | NM_OPT_SYNC_KLOOP_DIRECT_RX);
+}
+
+static int
+sync_kloop_eventfds_all_direct_tx(struct TestContext *ctx)
+{
+ return sync_kloop_eventfds_all_mode(ctx,
+ NM_OPT_SYNC_KLOOP_DIRECT_TX);
+}
+
+static int
+sync_kloop_eventfds_all_direct_rx(struct TestContext *ctx)
+{
+ return sync_kloop_eventfds_all_mode(ctx,
+ NM_OPT_SYNC_KLOOP_DIRECT_RX);
+}
+
+static int
sync_kloop_nocsb(struct TestContext *ctx)
{
int ret;
@@ -1677,6 +1720,9 @@ static struct mytest tests[] = {
decltest(sync_kloop),
decltest(sync_kloop_eventfds_all),
decltest(sync_kloop_eventfds_all_tx),
+ decltest(sync_kloop_eventfds_all_direct),
+ decltest(sync_kloop_eventfds_all_direct_tx),
+ decltest(sync_kloop_eventfds_all_direct_rx),
decltest(sync_kloop_nocsb),
decltest(sync_kloop_csb_enable),
decltest(sync_kloop_conflict),