Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2019 18:46:22 +0000 (UTC)
From:      Vincenzo Maffione <vmaffione@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r348516 - stable/12/tests/sys/netmap
Message-ID:  <201906021846.x52IkM19015065@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vmaffione
Date: Sun Jun  2 18:46:21 2019
New Revision: 348516
URL: https://svnweb.freebsd.org/changeset/base/348516

Log:
  MFC r346184
  
  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.

Modified:
  stable/12/tests/sys/netmap/ctrl-api-test.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/netmap/ctrl-api-test.c
==============================================================================
--- stable/12/tests/sys/netmap/ctrl-api-test.c	Sun Jun  2 16:44:50 2019	(r348515)
+++ stable/12/tests/sys/netmap/ctrl-api-test.c	Sun Jun  2 18:46:21 2019	(r348516)
@@ -50,20 +50,16 @@
 
 #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)
 {
 	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,7 +470,7 @@ 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;
@@ -470,6 +478,25 @@ port_register_single_ring_couple(struct TestContext *c
 }
 
 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)
 {
 	ctx->nr_mode = NR_REG_ALL_NIC;
@@ -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),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906021846.x52IkM19015065>