DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
Cc: <dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>
Subject: [PATCH v5 2/2] test/devargs: add eth devargs parse cases
Date: Thu, 1 Feb 2024 15:32:19 +0530	[thread overview]
Message-ID: <20240201100219.26677-3-hkalra@marvell.com> (raw)
In-Reply-To: <20240201100219.26677-1-hkalra@marvell.com>

Adding new eth devargs parsing test cases which can demonstrate
valid and invalid usage of devargs patterns.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 app/test/test_devargs.c | 107 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c
index f977d44448..4166b2bea2 100644
--- a/app/test/test_devargs.c
+++ b/app/test/test_devargs.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <ethdev_driver.h>
 #include <rte_common.h>
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
@@ -201,6 +202,106 @@ test_invalid_devargs(void)
 	return fail;
 }
 
+struct devargs_parse_case {
+	const char *devargs;
+	uint8_t devargs_count;
+};
+
+static int
+test_valid_devargs_parsing(void)
+{
+	static const struct devargs_parse_case list[] = {
+		/* Single representors patterns */
+		{"representor=1", 1},
+		{"representor=[1,2,3]", 1},
+		{"representor=[0-3,5,7]", 1},
+		{"representor=vf[0-1]", 1},
+		{"representor=sf[0-1]", 1},
+		{"representor=pf1vf[0-1]", 1},
+		{"representor=pf[0-1]vf[1-2]", 1},
+		{"representor=pf[0-1]sf[1-2]", 1},
+		{"representor=c0pf[0-1]", 1},
+		{"representor=sf[1,2]vf[2]", 1},  /* Only SF ports will be represented */
+		{"representor=vf2sf[1-2]", 1},    /* Only VF ports will be represented */
+		{"representor=c[0-1]pf[0-1]vf[1-2]", 1},
+		/* Single devarg inside multiple representor pattern */
+		{"representor=[c[0-1]pf[0-1]vf[1-2]]", 1},
+		/* Multiple representors patterns */
+		{"representor=[vf0,3]", 2},
+		{"representor=[vf0,vf1]", 2},
+		{"representor=[vf[0],vf[1]]", 2},
+		{"representor=[vf[0,1],3]", 2},
+		{"representor=[vf[0,1],[3]]", 2},
+		{"representor=[pf1vf[0-1],3]", 2},
+		{"representor=[pf1vf[0-1],pf[0-1]]", 2},
+		{"representor=[pf1,pf3,pf1vf[0-1],vf[0],vf[1],vf0,vf1,vf2]", 8},
+		{"representor=[1,3,5,pf1,pf2,pf3,pf1vf[0-1],vf[0],vf[1],vf0,vf1,vf2]", 12},
+		{"representor=[[1,3,5],pf1,pf2,pf3,pf1vf[0-1],vf[0],vf[1],vf0,vf1,vf2]", 10},
+		{"representor=[c[0,2-4]pf[1,6]vf[0-1],vf[0],vf4,[3-5,7],pf1vf[0-1,6],pf[2,4,6]]", 6}
+	};
+	struct rte_eth_devargs eth_da[RTE_MAX_ETHPORTS];
+	uint32_t i;
+	int ret;
+	int fail = 0;
+
+	for (i = 0; i < RTE_DIM(list); i++) {
+		memset(eth_da, 0, RTE_MAX_ETHPORTS * sizeof(*eth_da));
+		ret = rte_eth_devargs_parse(list[i].devargs, eth_da, RTE_MAX_ETHPORTS);
+		if (ret <= 0) {
+			printf("rte_devargs_parse(%s) returned %d (but should not)\n",
+			       list[i].devargs, ret);
+			fail = ret;
+			break;
+		}
+
+		/* Check the return value, count should be equivalent to no of devargs. */
+		if (ret != list[i].devargs_count) {
+			printf("Devargs returned count %d != expected count %d\n", ret,
+			       list[i].devargs_count);
+			fail = -1;
+			break;
+		}
+	}
+	return fail;
+}
+
+static int
+test_invalid_devargs_parsing(void)
+{
+	static const char * const list[] = {
+		"representor=1,2,3,4",			/* Out [] missing */
+		"representor=[1 2 3]",			/* , missing */
+		"representor=c[1,2]",			/* Only controller no valid */
+		"representor=c0vf[0-1]",		/* Controller with vf alone not valid */
+		"representor=c0sf[0-1]",		/* Controller with sf alone not valid */
+		"representor=vf[0-1],vf3",		/* Out [] missing */
+		"representor=[[vf0,3]]",		/* Double [] is invalid */
+		"representor=pfvf[1-2]",		/* No PF index provided */
+		"representor=pf1[vf[1-2]]",		/* Additional [] across vf */
+		"representor=c0[pf1vf[1-2]]",		/* Additional [] across pfvf */
+		"representor=c0[pf1[vf[1-2]]]",		/* Additional [] across pfvf */
+		"representor=[pf1vf[0-1], pf[0-1]]",	/* Space between two devargs is invalid */
+		"representor=[pf1vf[0-1], 3]",		/* Space between two devargs is invalid */
+		"representor=pf1vf[1-2],representor=1", /* Multiple representor keys */
+	};
+	struct rte_eth_devargs eth_da[RTE_MAX_ETHPORTS];
+	uint32_t i;
+	int ret;
+	int fail = 0;
+
+	for (i = 0; i < RTE_DIM(list); i++) {
+		memset(eth_da, 0, RTE_MAX_ETHPORTS * sizeof(*eth_da));
+		ret = rte_eth_devargs_parse(list[i], eth_da, RTE_MAX_ETHPORTS);
+		if (ret > 0) {
+			printf("rte_devargs_parse(%s) returned %d (but should not)\n",
+			       list[i], ret);
+			fail = ret;
+			break;
+		}
+	}
+	return fail;
+}
+
 static int
 test_devargs(void)
 {
@@ -210,6 +311,12 @@ test_devargs(void)
 	printf("== test invalid case ==\n");
 	if (test_invalid_devargs() < 0)
 		return -1;
+	printf("== test devargs parsing valid case ==\n");
+	if (test_valid_devargs_parsing() < 0)
+		return -1;
+	printf("== test devargs parsing invalid case ==\n");
+	if (test_invalid_devargs_parsing() < 0)
+		return -1;
 	return 0;
 }
 
-- 
2.18.0


  parent reply	other threads:[~2024-02-01 10:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11  6:44 [PATCH 0/2] multiple representors in one device Harman Kalra
2024-01-11  6:44 ` [PATCH 1/2] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-12  7:25   ` Andrew Rybchenko
2024-01-12  9:37     ` [EXT] " Harman Kalra
2024-01-12 12:42   ` David Marchand
2024-01-15 16:01     ` [EXT] " Harman Kalra
2024-01-11  6:44 ` [PATCH 2/2] doc: multiple representors in one device Harman Kalra
2024-01-12  7:26   ` Andrew Rybchenko
2024-01-15 16:01     ` [EXT] " Harman Kalra
2024-01-15 15:57 ` [PATCH v2 0/1] " Harman Kalra
2024-01-15 15:57   ` [PATCH v2 1/1] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-16  9:55 ` [PATCH v3 0/1] multiple representors in one device Harman Kalra
2024-01-16  9:55   ` [PATCH v3 1/1] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-17  8:47     ` Andrew Rybchenko
2024-01-21 19:30       ` [EXT] " Harman Kalra
2024-01-21 19:19 ` [PATCH v4 0/1] multiple representors in one device Harman Kalra
2024-01-21 19:19   ` [PATCH v4 1/1] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-22  1:13     ` Chaoyong He
2024-01-22  9:07       ` Harman Kalra
2024-01-22 10:10         ` Chaoyong He
2024-01-25  5:28     ` Harman Kalra
2024-01-26 13:43     ` Ferruh Yigit
2024-01-29 18:20       ` [EXT] " Harman Kalra
2024-01-30 23:09         ` Ferruh Yigit
2024-02-01 10:10           ` Harman Kalra
2024-02-01 10:02 ` [PATCH v5 0/2] multiple representors in one device Harman Kalra
2024-02-01 10:02   ` [PATCH v5 1/2] ethdev: parsing multiple representor devargs string Harman Kalra
2024-02-01 10:02   ` Harman Kalra [this message]
2024-02-01 18:35   ` [PATCH v5 0/2] multiple representors in one device Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240201100219.26677-3-hkalra@marvell.com \
    --to=hkalra@marvell.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).