mirror of
https://github.com/opnsense/src.git
synced 2026-04-15 14:29:58 -04:00
netmap: add test cases for multiple host rings
Extend the netmap unit tests with new test cases for the multiple-host-rings feature introduced by r345269. MFC after: 1 week
This commit is contained in:
parent
20a6a3a7a7
commit
4f6858e8a9
1 changed files with 53 additions and 24 deletions
|
|
@ -50,12 +50,6 @@
|
|||
|
||||
#ifdef __FreeBSD__
|
||||
#include "freebsd_test_suite/macros.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/eventfd.h>
|
||||
#else
|
||||
|
||||
static int
|
||||
eventfd(int x __unused, int y __unused)
|
||||
|
|
@ -63,7 +57,9 @@ eventfd(int x __unused, int y __unused)
|
|||
errno = ENODEV;
|
||||
return -1;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
#else /* __linux__ */
|
||||
#include <sys/eventfd.h>
|
||||
#endif
|
||||
|
||||
static int
|
||||
exec_command(int argc, const char *const argv[])
|
||||
|
|
@ -144,6 +140,8 @@ struct TestContext {
|
|||
uint32_t nr_rx_slots; /* slots in rx rings */
|
||||
uint16_t nr_tx_rings; /* number of tx rings */
|
||||
uint16_t nr_rx_rings; /* number of rx rings */
|
||||
uint16_t nr_host_tx_rings; /* number of host tx rings */
|
||||
uint16_t nr_host_rx_rings; /* number of host rx rings */
|
||||
uint16_t nr_mem_id; /* id of the memory allocator */
|
||||
uint16_t nr_ringid; /* ring(s) we care about */
|
||||
uint32_t nr_mode; /* specify NR_REG_* modes */
|
||||
|
|
@ -242,6 +240,8 @@ port_register(struct TestContext *ctx)
|
|||
req.nr_tx_slots = ctx->nr_tx_slots;
|
||||
req.nr_rx_slots = ctx->nr_rx_slots;
|
||||
req.nr_tx_rings = ctx->nr_tx_rings;
|
||||
req.nr_host_tx_rings = ctx->nr_host_tx_rings;
|
||||
req.nr_host_rx_rings = ctx->nr_host_rx_rings;
|
||||
req.nr_rx_rings = ctx->nr_rx_rings;
|
||||
req.nr_extra_bufs = ctx->nr_extra_bufs;
|
||||
ret = ioctl(ctx->fd, NIOCCTRL, &hdr);
|
||||
|
|
@ -255,23 +255,29 @@ port_register(struct TestContext *ctx)
|
|||
printf("nr_rx_slots %u\n", req.nr_rx_slots);
|
||||
printf("nr_tx_rings %u\n", req.nr_tx_rings);
|
||||
printf("nr_rx_rings %u\n", req.nr_rx_rings);
|
||||
printf("nr_host_tx_rings %u\n", req.nr_host_tx_rings);
|
||||
printf("nr_host_rx_rings %u\n", req.nr_host_rx_rings);
|
||||
printf("nr_mem_id %u\n", req.nr_mem_id);
|
||||
printf("nr_extra_bufs %u\n", req.nr_extra_bufs);
|
||||
|
||||
success = req.nr_memsize && (ctx->nr_mode == req.nr_mode) &&
|
||||
(ctx->nr_ringid == req.nr_ringid) &&
|
||||
(ctx->nr_flags == req.nr_flags) &&
|
||||
((!ctx->nr_tx_slots && req.nr_tx_slots) ||
|
||||
(ctx->nr_tx_slots == req.nr_tx_slots)) &&
|
||||
((!ctx->nr_rx_slots && req.nr_rx_slots) ||
|
||||
(ctx->nr_rx_slots == req.nr_rx_slots)) &&
|
||||
((!ctx->nr_tx_rings && req.nr_tx_rings) ||
|
||||
(ctx->nr_tx_rings == req.nr_tx_rings)) &&
|
||||
((!ctx->nr_rx_rings && req.nr_rx_rings) ||
|
||||
(ctx->nr_rx_rings == req.nr_rx_rings)) &&
|
||||
((!ctx->nr_mem_id && req.nr_mem_id) ||
|
||||
(ctx->nr_mem_id == req.nr_mem_id)) &&
|
||||
(ctx->nr_extra_bufs == req.nr_extra_bufs);
|
||||
(ctx->nr_ringid == req.nr_ringid) &&
|
||||
(ctx->nr_flags == req.nr_flags) &&
|
||||
((!ctx->nr_tx_slots && req.nr_tx_slots) ||
|
||||
(ctx->nr_tx_slots == req.nr_tx_slots)) &&
|
||||
((!ctx->nr_rx_slots && req.nr_rx_slots) ||
|
||||
(ctx->nr_rx_slots == req.nr_rx_slots)) &&
|
||||
((!ctx->nr_tx_rings && req.nr_tx_rings) ||
|
||||
(ctx->nr_tx_rings == req.nr_tx_rings)) &&
|
||||
((!ctx->nr_rx_rings && req.nr_rx_rings) ||
|
||||
(ctx->nr_rx_rings == req.nr_rx_rings)) &&
|
||||
((!ctx->nr_host_tx_rings && req.nr_host_tx_rings) ||
|
||||
(ctx->nr_host_tx_rings == req.nr_host_tx_rings)) &&
|
||||
((!ctx->nr_host_rx_rings && req.nr_host_rx_rings) ||
|
||||
(ctx->nr_host_rx_rings == req.nr_host_rx_rings)) &&
|
||||
((!ctx->nr_mem_id && req.nr_mem_id) ||
|
||||
(ctx->nr_mem_id == req.nr_mem_id)) &&
|
||||
(ctx->nr_extra_bufs == req.nr_extra_bufs);
|
||||
if (!success) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -281,6 +287,8 @@ port_register(struct TestContext *ctx)
|
|||
ctx->nr_rx_slots = req.nr_rx_slots;
|
||||
ctx->nr_tx_rings = req.nr_tx_rings;
|
||||
ctx->nr_rx_rings = req.nr_rx_rings;
|
||||
ctx->nr_host_tx_rings = req.nr_host_tx_rings;
|
||||
ctx->nr_host_rx_rings = req.nr_host_rx_rings;
|
||||
ctx->nr_mem_id = req.nr_mem_id;
|
||||
ctx->nr_extra_bufs = req.nr_extra_bufs;
|
||||
|
||||
|
|
@ -448,7 +456,7 @@ port_register_hwall_host(struct TestContext *ctx)
|
|||
}
|
||||
|
||||
static int
|
||||
port_register_host(struct TestContext *ctx)
|
||||
port_register_hostall(struct TestContext *ctx)
|
||||
{
|
||||
ctx->nr_mode = NR_REG_SW;
|
||||
return port_register(ctx);
|
||||
|
|
@ -462,13 +470,32 @@ port_register_hwall(struct TestContext *ctx)
|
|||
}
|
||||
|
||||
static int
|
||||
port_register_single_ring_couple(struct TestContext *ctx)
|
||||
port_register_single_hw_pair(struct TestContext *ctx)
|
||||
{
|
||||
ctx->nr_mode = NR_REG_ONE_NIC;
|
||||
ctx->nr_ringid = 0;
|
||||
return port_register(ctx);
|
||||
}
|
||||
|
||||
static int
|
||||
port_register_single_host_pair(struct TestContext *ctx)
|
||||
{
|
||||
ctx->nr_mode = NR_REG_ONE_SW;
|
||||
ctx->nr_host_tx_rings = 2;
|
||||
ctx->nr_host_rx_rings = 2;
|
||||
ctx->nr_ringid = 1;
|
||||
return port_register(ctx);
|
||||
}
|
||||
|
||||
static int
|
||||
port_register_hostall_many(struct TestContext *ctx)
|
||||
{
|
||||
ctx->nr_mode = NR_REG_SW;
|
||||
ctx->nr_host_tx_rings = 5;
|
||||
ctx->nr_host_rx_rings = 4;
|
||||
return port_register(ctx);
|
||||
}
|
||||
|
||||
static int
|
||||
port_register_hwall_tx(struct TestContext *ctx)
|
||||
{
|
||||
|
|
@ -1701,8 +1728,10 @@ static struct mytest tests[] = {
|
|||
decltest(port_info_get),
|
||||
decltest(port_register_hwall_host),
|
||||
decltest(port_register_hwall),
|
||||
decltest(port_register_host),
|
||||
decltest(port_register_single_ring_couple),
|
||||
decltest(port_register_hostall),
|
||||
decltest(port_register_single_hw_pair),
|
||||
decltest(port_register_single_host_pair),
|
||||
decltest(port_register_hostall_many),
|
||||
decltest(vale_attach_detach),
|
||||
decltest(vale_attach_detach_host_rings),
|
||||
decltest(vale_ephemeral_port_hdr_manipulation),
|
||||
|
|
|
|||
Loading…
Reference in a new issue