DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 03/11] kvargs: remove driver name in arguments
Date: Tue, 28 Jan 2014 17:06:36 +0100	[thread overview]
Message-ID: <1390925204-10800-4-git-send-email-olivier.matz@6wind.com> (raw)
In-Reply-To: <1390925204-10800-1-git-send-email-olivier.matz@6wind.com>

Now that rte_kvargs is a generic library, there is no need to have an argument
for the driver name in rte_kvargs_tokenize() and rte_kvargs_parse()
prototypes. This argument was only used to log the driver name in case of
error. Instead, we can add a log in init function of pmd_pcap and pmd_ring.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_kvargs/rte_kvargs.c     | 13 ++++++-------
 lib/librte_kvargs/rte_kvargs.h     |  4 +---
 lib/librte_pmd_pcap/rte_eth_pcap.c |  4 +++-
 lib/librte_pmd_ring/rte_eth_ring.c |  2 ++
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index 7a950d6..935698c 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -91,8 +91,7 @@ rte_kvargs_add_pair(struct rte_kvargs *kvlist, char *key, char *val)
  * strtok() is used so the params string will be copied to be modified.
  */
 static int
-rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *name,
-	const char *params)
+rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
 {
 	unsigned i, count;
 	char *args;
@@ -101,7 +100,7 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *name,
 
 	/* If params are empty, nothing to do */
 	if (params == NULL || params[0] == 0) {
-		RTE_LOG(ERR, PMD, "Couldn't parse %s device, empty arguments\n", name);
+		RTE_LOG(ERR, PMD, "Cannot parse empty arguments\n");
 		return -1;
 	}
 
@@ -110,7 +109,7 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *name,
 	 */
 	args = strdup(params);
 	if(args == NULL){
-		RTE_LOG(ERR, PMD, "Couldn't parse %s device \n", name);
+		RTE_LOG(ERR, PMD, "Cannot parse arguments: not enough memory\n");
 		return -1;
 	}
 
@@ -127,7 +126,8 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *name,
 		if (pair[0] == NULL || pair[1] == NULL || pair[0][0] == 0
 				|| pair[1][0] == 0) {
 			RTE_LOG(ERR, PMD,
-					"Couldn't parse %s device, wrong key or value \n", name);
+				"Cannot parse arguments: wrong key or value\n"
+				"params=<%s>\n", params);
 			goto error;
 		}
 
@@ -230,14 +230,13 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
  */
 int
 rte_kvargs_parse(struct rte_kvargs *kvlist,
-		const char *name,
 		const char *args,
 		const char *valid_keys[])
 {
 
 	int ret;
 
-	ret = rte_kvargs_tokenize(kvlist, name, args);
+	ret = rte_kvargs_tokenize(kvlist, args);
 	if (ret < 0)
 		return ret;
 
diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h
index 19485b1..804ea1d 100644
--- a/lib/librte_kvargs/rte_kvargs.h
+++ b/lib/librte_kvargs/rte_kvargs.h
@@ -100,8 +100,6 @@ int rte_kvargs_init(struct rte_kvargs *kvlist);
  *
  * @param kvlist
  *   The rte_kvargs structure
- * @param name
- *   The name of the driver
  * @param args
  *   The input string containing the key/value associations
  * @param valid_keys
@@ -112,7 +110,7 @@ int rte_kvargs_init(struct rte_kvargs *kvlist);
  *   - 0 on success
  *   - Negative on error
  */
-int rte_kvargs_parse(struct rte_kvargs *kvlist, const char *name,
+int rte_kvargs_parse(struct rte_kvargs *kvlist,
 	const char *args, const char *valid_keys[]);
 
 /**
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c
index e47afcb..2006b35 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -706,6 +706,8 @@ rte_pmd_pcap_init(const char *name, const char *params)
 	struct rx_pcaps pcaps;
 	struct tx_pcaps dumpers;
 
+	RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name);
+
 	rte_kvargs_init(&kvlist);
 
 	numa_node = rte_socket_id();
@@ -714,7 +716,7 @@ rte_pmd_pcap_init(const char *name, const char *params)
 	start_cycles = rte_get_timer_cycles();
 	hz = rte_get_timer_hz();
 
-	if (rte_kvargs_parse(&kvlist, name, params, valid_arguments) < 0)
+	if (rte_kvargs_parse(&kvlist, params, valid_arguments) < 0)
 		return -1;
 
 	/*
diff --git a/lib/librte_pmd_ring/rte_eth_ring.c b/lib/librte_pmd_ring/rte_eth_ring.c
index fa3ff72..abef2e8 100644
--- a/lib/librte_pmd_ring/rte_eth_ring.c
+++ b/lib/librte_pmd_ring/rte_eth_ring.c
@@ -384,6 +384,8 @@ rte_eth_ring_pair_attach(const char *name, const unsigned numa_node)
 int
 rte_pmd_ring_init(const char *name, const char *params)
 {
+	RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
+
 	if (params == NULL)
 		eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
 	else {
-- 
1.8.4.rc3

  parent reply	other threads:[~2014-01-28 16:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 16:06 [dpdk-dev] [PATCH 00/11] add rte_kvargs library: a key/value args parser Olivier Matz
2014-01-28 16:06 ` [dpdk-dev] [PATCH 01/11] kvargs: add a new library to parse key/value arguments Olivier Matz
2014-01-29 15:45   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 02/11] kvargs: use the new library in pmd_pcap Olivier Matz
2014-01-29 15:46   ` Richardson, Bruce
2014-01-28 16:06 ` Olivier Matz [this message]
2014-01-29 15:47   ` [dpdk-dev] [PATCH 03/11] kvargs: remove driver name in arguments Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 04/11] kvargs: remove useless size field Olivier Matz
2014-01-29 17:14   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 05/11] kvargs: rework API to fix memory leak Olivier Matz
2014-01-30 11:22   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 06/11] kvargs: simpler parsing and allow duplicated keys Olivier Matz
2014-01-29 17:17   ` Richardson, Bruce
2014-01-29 22:17     ` Olivier MATZ
2014-01-30 11:23   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 07/11] kvargs: be strict when matching a key Olivier Matz
2014-01-30 11:23   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 08/11] kvargs: add const attribute in handler parameters Olivier Matz
2014-01-30 11:24   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 09/11] kvargs: add the key in handler pameters Olivier Matz
2014-01-30 11:34   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 10/11] kvargs: make the NULL key to match all entries Olivier Matz
2014-01-30 11:34   ` Richardson, Bruce
2014-01-28 16:06 ` [dpdk-dev] [PATCH 11/11] kvargs: add test case in app/test Olivier Matz
2014-01-30 11:35   ` Richardson, Bruce
2014-02-04 14:53 ` [dpdk-dev] [PATCH 00/11] add rte_kvargs library: a key/value args parser Thomas Monjalon

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=1390925204-10800-4-git-send-email-olivier.matz@6wind.com \
    --to=olivier.matz@6wind.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).