Skip to contentSkip to conversation

kvargs: promote or remove experimental api

PATCH Superseded Olivier Matz 4 participants 19 messages Sep 24, 2021 – Sep 30, 2021

lore
Share & tools
lore
#0 lore raw

cover kvargs: promote or remove experimental api

This patchset promotes 2 functions rte_kvargs_parse_delim() and rte_kvargs_get() as stable.

It also replaces rte_kvargs_strcmp() by a new one rte_kvargs_get_with_value(), which is easier to use.

Olivier Matz (5):
kvargs: promote delimited parsing as stable
kvargs: promote get from key as stable
kvargs: new function to get from key and value
kvargs: remove experimental function to compare string
kvargs: fix comments style

 drivers/bus/auxiliary/auxiliary_params.c |  9 ++--
 drivers/bus/vdev/vdev_params.c           | 13 +-----
 lib/kvargs/rte_kvargs.c                  | 32 +++++++------
 lib/kvargs/rte_kvargs.h                  | 59 ++++++++++++------------
 lib/kvargs/version.map                   |  7 +--
 5 files changed, 57 insertions(+), 63 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/5 kvargs: promote delimited parsing as stable

This function is used by EAL to parse key/value strings separated with specified delimiters.

It was introduced in 2018 by commit 5d6af85ab00c ("kvargs: introduce a more flexible parsing function"), and can be promoted as stable.

---
 lib/kvargs/rte_kvargs.h | 1 -
 lib/kvargs/version.map  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
lib/kvargs/rte_kvargs.h +0 -1
index 12a8f90435..c30891c668 100644
@@ -98,7 +98,6 @@ struct rte_kvargs *rte_kvargs_parse(const char *args,
  *   - A pointer to an allocated rte_kvargs structure on success
  *   - NULL on error
  */
-__rte_experimental
 struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
 		const char *const valid_keys[],
 		const char *valid_ends);
lib/kvargs/version.map +1 -1
index a07166b4d2..75b13fcb78 100644
@@ -4,6 +4,7 @@ DPDK_22 {
 	rte_kvargs_count;
 	rte_kvargs_free;
 	rte_kvargs_parse;
+	rte_kvargs_parse_delim;
 	rte_kvargs_process;
 
 	local: *;
@@ -12,7 +13,6 @@ DPDK_22 {
 EXPERIMENTAL {
 	global:
 
-	rte_kvargs_parse_delim;
 	rte_kvargs_strcmp;
 
 	# added in 21.05
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/5 kvargs: promote get from key as stable

In reply to Olivier Matz

The function rte_kvargs_get() is used by eal and pci bus driver since its introduction in commit 3ab385063cb9 ("kvargs: add get by key") and commit d2a66ad79480 ("bus: add device arguments name parsing"), in dpdk 21.05.

Let's promote it as stable.

---
 lib/kvargs/rte_kvargs.h | 1 -
 lib/kvargs/version.map  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)
lib/kvargs/rte_kvargs.h +0 -1
index c30891c668..328f0d3cc6 100644
@@ -130,7 +130,6 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
  *   NULL if no key matches the input,
  *   a value associated with a matching key otherwise.
  */
-__rte_experimental
 const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key);
 
 /**
lib/kvargs/version.map +1 -2
index 75b13fcb78..236f35c02b 100644
@@ -3,6 +3,7 @@ DPDK_22 {
 
 	rte_kvargs_count;
 	rte_kvargs_free;
+	rte_kvargs_get;
 	rte_kvargs_parse;
 	rte_kvargs_parse_delim;
 	rte_kvargs_process;
@@ -15,6 +16,4 @@ EXPERIMENTAL {
 
 	rte_kvargs_strcmp;
 
-	# added in 21.05
-	rte_kvargs_get;
 };
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/5 kvargs: new function to get from key and value

In reply to Olivier Matz

A quite common scenario with kvargs is to lookup for a <key>=<value> in a kvlist. For instance, check if name=foo is present in name=toto,name=foo,name=bar. This is currently done in drivers/bus with rte_kvargs_process() + the rte_kvargs_strcmp() handler.

This approach is not straightforward, and can be replaced by this new function.

---
 drivers/bus/auxiliary/auxiliary_params.c |  9 ++++----
 drivers/bus/vdev/vdev_params.c           | 13 ++---------
 lib/kvargs/rte_kvargs.c                  | 23 +++++++++++++++----
 lib/kvargs/rte_kvargs.h                  | 29 +++++++++++++++++++++++-
 lib/kvargs/version.map                   |  2 ++
 5 files changed, 54 insertions(+), 22 deletions(-)
drivers/bus/auxiliary/auxiliary_params.c +4 -5
index cd3fa56cb4..a9c7853ed1 100644
@@ -25,13 +25,12 @@ auxiliary_dev_match(const struct rte_device *dev,
 	      const void *_kvlist)
 {
 	const struct rte_kvargs *kvlist = _kvlist;
-	int ret;
+	const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME];
 
-	ret = rte_kvargs_process(kvlist,
-			auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME],
-			rte_kvargs_strcmp, (void *)(uintptr_t)dev->name);
+	if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL)
+		return -1;
 
-	return ret != 0 ? -1 : 0;
+	return 0;
 }
 
 void *
drivers/bus/vdev/vdev_params.c +2 -11
index 6f74704d1c..37d95395e7 100644
@@ -26,19 +26,10 @@ static int
 vdev_dev_match(const struct rte_device *dev,
 	       const void *_kvlist)
 {
-	int ret;
 	const struct rte_kvargs *kvlist = _kvlist;
-	char *name;
+	const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME];
 
-	/* cannot pass const dev->name to rte_kvargs_process() */
-	name = strdup(dev->name);
-	if (name == NULL)
-		return -1;
-	ret = rte_kvargs_process(kvlist,
-		vdev_params_keys[RTE_VDEV_PARAM_NAME],
-		rte_kvargs_strcmp, name);
-	free(name);
-	if (ret != 0)
+	if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL)
 		return -1;
 
 	return 0;
lib/kvargs/rte_kvargs.c +18 -5
index 38e9d5c1ca..20abb23183 100644
@@ -204,21 +204,34 @@ rte_kvargs_free(struct rte_kvargs *kvlist)
 	free(kvlist);
 }
 
-/* Lookup a value in an rte_kvargs list by its key. */
+/* Lookup a value in an rte_kvargs list by its key and value. */
 const char *
-rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key)
+rte_kvargs_get_with_value(const struct rte_kvargs *kvlist, const char *key,
+			  const char *value)
 {
 	unsigned int i;
 
-	if (kvlist == NULL || key == NULL)
+	if (kvlist == NULL)
 		return NULL;
 	for (i = 0; i < kvlist->count; ++i) {
-		if (strcmp(kvlist->pairs[i].key, key) == 0)
-			return kvlist->pairs[i].value;
+		if (key != NULL && strcmp(kvlist->pairs[i].key, key) != 0)
+			continue;
+		if (value != NULL && strcmp(kvlist->pairs[i].value, value) != 0)
+			continue;
+		return kvlist->pairs[i].value;
 	}
 	return NULL;
 }
 
+/* Lookup a value in an rte_kvargs list by its key. */
+const char *
+rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key)
+{
+	if (kvlist == NULL || key == NULL)
+		return NULL;
+	return rte_kvargs_get_with_value(kvlist, key, NULL);
+}
+
 /*
  * Parse the arguments "key=value,key=value,..." string and return
  * an allocated structure that contains a key/value list. Also
lib/kvargs/rte_kvargs.h +28 -1
index 328f0d3cc6..e40df1bd2a 100644
@@ -116,7 +116,7 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
 /**
  * Get the value associated with a given key.
  *
- * If multiple key matches, the value of the first one is returned.
+ * If multiple keys match, the value of the first one is returned.
  *
  * The memory returned is allocated as part of the rte_kvargs structure,
  * it must never be modified.
@@ -132,6 +132,33 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
  */
 const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get the value associated with a given key and value.
+ *
+ * Find the first entry in the kvlist whose key and value match the
+ * ones passed as argument.
+ *
+ * The memory returned is allocated as part of the rte_kvargs structure,
+ * it must never be modified.
+ *
+ * @param kvlist
+ *   A list of rte_kvargs pair of 'key=value'.
+ * @param key
+ *   The matching key. If NULL, any key will match.
+ * @param value
+ *   The matching value. If NULL, any value will match.
+ *
+ * @return
+ *   NULL if no key matches the input,
+ *   a value associated with a matching key otherwise.
+ */
+__rte_experimental
+const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
+				      const char *key, const char *value);
+
 /**
  * Call a handler function for each key/value matching the key
  *
lib/kvargs/version.map +2 -0
index 236f35c02b..82879b7140 100644
@@ -16,4 +16,6 @@ EXPERIMENTAL {
 
 	rte_kvargs_strcmp;
 
+	# added in 21.11
+	rte_kvargs_get_with_value;
 };
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/5 kvargs: remove experimental function to compare string

In reply to Olivier Matz

The function was designed to be used as a handler for rte_kvargs_process() to compare the value string in a kvlist. For readability, its usages in DPDK have been replaced by rte_kvargs_get_with_value() in previous commit.

Remove this function, as it is not used anymore.

---
 lib/kvargs/rte_kvargs.c |  9 ---------
 lib/kvargs/rte_kvargs.h | 26 --------------------------
 2 files changed, 35 deletions(-)
lib/kvargs/rte_kvargs.c +0 -9
index 20abb23183..11f624ef14 100644
@@ -283,12 +283,3 @@ rte_kvargs_parse_delim(const char *args, const char * const valid_keys[],
 	free(copy);
 	return kvlist;
 }
-
-int
-rte_kvargs_strcmp(const char *key __rte_unused,
-		  const char *value, void *opaque)
-{
-	const char *str = opaque;
-
-	return -abs(strcmp(str, value));
-}
lib/kvargs/rte_kvargs.h +0 -26
index e40df1bd2a..3c1754c3d9 100644
@@ -197,32 +197,6 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist,
 unsigned rte_kvargs_count(const struct rte_kvargs *kvlist,
 	const char *key_match);
 
-/**
- * Generic kvarg handler for string comparison.
- *
- * This function can be used for a generic string comparison processing
- * on a list of kvargs.
- *
- * @param key
- *   kvarg pair key.
- *
- * @param value
- *   kvarg pair value.
- *
- * @param opaque
- *   Opaque pointer to a string.
- *
- * @return
- *   0 if the strings match.
- *   !0 otherwise or on error.
- *
- *   Unlike strcmp, comparison ordering is not kept.
- *   In order for rte_kvargs_process to stop processing on match error,
- *   a negative value is returned even if strcmp had returned a positive one.
- */
-__rte_experimental
-int rte_kvargs_strcmp(const char *key, const char *value, void *opaque);
-
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.30.2
#5 lore raw

Re: [dpdk-dev] [PATCH 4/5] kvargs: remove experimental function to compare string

Quoted 8 lines · Olivier Matz

The function was designed to be used as a handler for rte_kvargs_process() to compare the value string in a kvlist. For readability, its usages in DPDK have been replaced by rte_kvargs_get_with_value() in previous commit.

Remove this function, as it is not used anymore.

Self-nack, I forgot to remove the rte_kvargs_strcmp entry from version.map.

Will send a v2.

#6 lore raw

PATCH 5/5 kvargs: fix comments style

In reply to Olivier Matz

A '*' is missing at 2 places, add them.

Fixes e1a00536c8ed ("kvargs: add a new library to parse key/value arguments")
Fixes 3ab385063cb9 ("kvargs: add get by key")
---
 lib/kvargs/rte_kvargs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/kvargs/rte_kvargs.h +2 -2
index 3c1754c3d9..359a9f5b09 100644
@@ -125,7 +125,7 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
  *   A list of rte_kvargs pair of 'key=value'.
  * @param key
  *   The matching key.
-
+ *
  * @return
  *   NULL if no key matches the input,
  *   a value associated with a matching key otherwise.
@@ -190,7 +190,7 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist,
  *   The rte_kvargs structure
  * @param key_match
  *   The key that should match, or NULL to count all associations
-
+ *
  * @return
  *   The number of entries
  */
Signature · 1 line
2.30.2
Reviewed-by on the v1 series
#7 lore raw
In reply to Olivier Matz
Quoted 13 lines · Olivier Matz

This patchset promotes 2 functions rte_kvargs_parse_delim() and rte_kvargs_get() as stable.

It also replaces rte_kvargs_strcmp() by a new one rte_kvargs_get_with_value(), which is easier to use.

Olivier Matz (5):
kvargs: promote delimited parsing as stable
kvargs: promote get from key as stable
kvargs: new function to get from key and value
kvargs: remove experimental function to compare string
kvargs: fix comments style

Quoted 7 lines
 drivers/bus/auxiliary/auxiliary_params.c |  9 ++--
 drivers/bus/vdev/vdev_params.c           | 13 +-----
 lib/kvargs/rte_kvargs.c                  | 32 +++++++------
 lib/kvargs/rte_kvargs.h                  | 59 ++++++++++++------------
 lib/kvargs/version.map                   |  7 +--
 5 files changed, 57 insertions(+), 63 deletions(-)

The whole series looks good to me, the new function that match key and value directly looks more efficient, thanks!

#8 lore raw

v2 cover kvargs: promote or remove experimental api

In reply to Olivier Matz

This patchset promotes 2 functions rte_kvargs_parse_delim() and rte_kvargs_get() as stable.

It also replaces rte_kvargs_strcmp() by a new one rte_kvargs_get_with_value(), which is easier to use.

v2
* remove rte_kvargs_strcmp from version.map

Olivier Matz (5):
kvargs: promote delimited parsing as stable
kvargs: promote get from key as stable
kvargs: new function to get from key and value
kvargs: remove experimental function to compare string
kvargs: fix comments style

 drivers/bus/auxiliary/auxiliary_params.c |  9 ++--
 drivers/bus/vdev/vdev_params.c           | 13 +-----
 lib/kvargs/rte_kvargs.c                  | 32 +++++++------
 lib/kvargs/rte_kvargs.h                  | 59 ++++++++++++------------
 lib/kvargs/version.map                   |  9 ++--
 5 files changed, 57 insertions(+), 65 deletions(-)
Signature · 1 line
2.30.2
#9 lore raw

PATCH v2 1/5 kvargs: promote delimited parsing as stable

This function is used by EAL to parse key/value strings separated with specified delimiters.

It was introduced in 2018 by commit 5d6af85ab00c ("kvargs: introduce a more flexible parsing function"), and can be promoted as stable.

---
 lib/kvargs/rte_kvargs.h | 1 -
 lib/kvargs/version.map  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
lib/kvargs/rte_kvargs.h +0 -1
index 12a8f90435..c30891c668 100644
@@ -98,7 +98,6 @@ struct rte_kvargs *rte_kvargs_parse(const char *args,
  *   - A pointer to an allocated rte_kvargs structure on success
  *   - NULL on error
  */
-__rte_experimental
 struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
 		const char *const valid_keys[],
 		const char *valid_ends);
lib/kvargs/version.map +1 -1
index a07166b4d2..75b13fcb78 100644
@@ -4,6 +4,7 @@ DPDK_22 {
 	rte_kvargs_count;
 	rte_kvargs_free;
 	rte_kvargs_parse;
+	rte_kvargs_parse_delim;
 	rte_kvargs_process;
 
 	local: *;
@@ -12,7 +13,6 @@ DPDK_22 {
 EXPERIMENTAL {
 	global:
 
-	rte_kvargs_parse_delim;
 	rte_kvargs_strcmp;
 
 	# added in 21.05
Signature · 1 line
2.30.2
#10 lore raw

PATCH v2 2/5 kvargs: promote get from key as stable

In reply to Olivier Matz

The function rte_kvargs_get() is used by eal and pci bus driver since its introduction in commit 3ab385063cb9 ("kvargs: add get by key") and commit d2a66ad79480 ("bus: add device arguments name parsing"), in dpdk 21.05.

Let's promote it as stable.

---
 lib/kvargs/rte_kvargs.h | 1 -
 lib/kvargs/version.map  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)
lib/kvargs/rte_kvargs.h +0 -1
index c30891c668..328f0d3cc6 100644
@@ -130,7 +130,6 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
  *   NULL if no key matches the input,
  *   a value associated with a matching key otherwise.
  */
-__rte_experimental
 const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key);
 
 /**
lib/kvargs/version.map +1 -2
index 75b13fcb78..236f35c02b 100644
@@ -3,6 +3,7 @@ DPDK_22 {
 
 	rte_kvargs_count;
 	rte_kvargs_free;
+	rte_kvargs_get;
 	rte_kvargs_parse;
 	rte_kvargs_parse_delim;
 	rte_kvargs_process;
@@ -15,6 +16,4 @@ EXPERIMENTAL {
 
 	rte_kvargs_strcmp;
 
-	# added in 21.05
-	rte_kvargs_get;
 };
Signature · 1 line
2.30.2
#11 lore raw

PATCH v2 3/5 kvargs: new function to get from key and value

In reply to Olivier Matz

A quite common scenario with kvargs is to lookup for a <key>=<value> in a kvlist. For instance, check if name=foo is present in name=toto,name=foo,name=bar. This is currently done in drivers/bus with rte_kvargs_process() + the rte_kvargs_strcmp() handler.

This approach is not straightforward, and can be replaced by this new function.

---
 drivers/bus/auxiliary/auxiliary_params.c |  9 ++++----
 drivers/bus/vdev/vdev_params.c           | 13 ++---------
 lib/kvargs/rte_kvargs.c                  | 23 +++++++++++++++----
 lib/kvargs/rte_kvargs.h                  | 29 +++++++++++++++++++++++-
 lib/kvargs/version.map                   |  2 ++
 5 files changed, 54 insertions(+), 22 deletions(-)
drivers/bus/auxiliary/auxiliary_params.c +4 -5
index cd3fa56cb4..a9c7853ed1 100644
@@ -25,13 +25,12 @@ auxiliary_dev_match(const struct rte_device *dev,
 	      const void *_kvlist)
 {
 	const struct rte_kvargs *kvlist = _kvlist;
-	int ret;
+	const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME];
 
-	ret = rte_kvargs_process(kvlist,
-			auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME],
-			rte_kvargs_strcmp, (void *)(uintptr_t)dev->name);
+	if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL)
+		return -1;
 
-	return ret != 0 ? -1 : 0;
+	return 0;
 }
 
 void *
drivers/bus/vdev/vdev_params.c +2 -11
index 6f74704d1c..37d95395e7 100644
@@ -26,19 +26,10 @@ static int
 vdev_dev_match(const struct rte_device *dev,
 	       const void *_kvlist)
 {
-	int ret;
 	const struct rte_kvargs *kvlist = _kvlist;
-	char *name;
+	const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME];
 
-	/* cannot pass const dev->name to rte_kvargs_process() */
-	name = strdup(dev->name);
-	if (name == NULL)
-		return -1;
-	ret = rte_kvargs_process(kvlist,
-		vdev_params_keys[RTE_VDEV_PARAM_NAME],
-		rte_kvargs_strcmp, name);
-	free(name);
-	if (ret != 0)
+	if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL)
 		return -1;
 
 	return 0;
lib/kvargs/rte_kvargs.c +18 -5
index 38e9d5c1ca..20abb23183 100644
@@ -204,21 +204,34 @@ rte_kvargs_free(struct rte_kvargs *kvlist)
 	free(kvlist);
 }
 
-/* Lookup a value in an rte_kvargs list by its key. */
+/* Lookup a value in an rte_kvargs list by its key and value. */
 const char *
-rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key)
+rte_kvargs_get_with_value(const struct rte_kvargs *kvlist, const char *key,
+			  const char *value)
 {
 	unsigned int i;
 
-	if (kvlist == NULL || key == NULL)
+	if (kvlist == NULL)
 		return NULL;
 	for (i = 0; i < kvlist->count; ++i) {
-		if (strcmp(kvlist->pairs[i].key, key) == 0)
-			return kvlist->pairs[i].value;
+		if (key != NULL && strcmp(kvlist->pairs[i].key, key) != 0)
+			continue;
+		if (value != NULL && strcmp(kvlist->pairs[i].value, value) != 0)
+			continue;
+		return kvlist->pairs[i].value;
 	}
 	return NULL;
 }
 
+/* Lookup a value in an rte_kvargs list by its key. */
+const char *
+rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key)
+{
+	if (kvlist == NULL || key == NULL)
+		return NULL;
+	return rte_kvargs_get_with_value(kvlist, key, NULL);
+}
+
 /*
  * Parse the arguments "key=value,key=value,..." string and return
  * an allocated structure that contains a key/value list. Also
lib/kvargs/rte_kvargs.h +28 -1
index 328f0d3cc6..e40df1bd2a 100644
@@ -116,7 +116,7 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
 /**
  * Get the value associated with a given key.
  *
- * If multiple key matches, the value of the first one is returned.
+ * If multiple keys match, the value of the first one is returned.
  *
  * The memory returned is allocated as part of the rte_kvargs structure,
  * it must never be modified.
@@ -132,6 +132,33 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
  */
 const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get the value associated with a given key and value.
+ *
+ * Find the first entry in the kvlist whose key and value match the
+ * ones passed as argument.
+ *
+ * The memory returned is allocated as part of the rte_kvargs structure,
+ * it must never be modified.
+ *
+ * @param kvlist
+ *   A list of rte_kvargs pair of 'key=value'.
+ * @param key
+ *   The matching key. If NULL, any key will match.
+ * @param value
+ *   The matching value. If NULL, any value will match.
+ *
+ * @return
+ *   NULL if no key matches the input,
+ *   a value associated with a matching key otherwise.
+ */
+__rte_experimental
+const char *rte_kvargs_get_with_value(const struct rte_kvargs *kvlist,
+				      const char *key, const char *value);
+
 /**
  * Call a handler function for each key/value matching the key
  *
lib/kvargs/version.map +2 -0
index 236f35c02b..82879b7140 100644
@@ -16,4 +16,6 @@ EXPERIMENTAL {
 
 	rte_kvargs_strcmp;
 
+	# added in 21.11
+	rte_kvargs_get_with_value;
 };
Signature · 1 line
2.30.2
#12 lore raw

PATCH v2 4/5 kvargs: remove experimental function to compare string

In reply to Olivier Matz

The function was designed to be used as a handler for rte_kvargs_process() to compare the value string in a kvlist. For readability, its usages in DPDK have been replaced by rte_kvargs_get_with_value() in previous commit.

Remove this function, as it is not used anymore.

---
 lib/kvargs/rte_kvargs.c |  9 ---------
 lib/kvargs/rte_kvargs.h | 26 --------------------------
 lib/kvargs/version.map  |  2 --
 3 files changed, 37 deletions(-)
lib/kvargs/rte_kvargs.c +0 -9
index 20abb23183..11f624ef14 100644
@@ -283,12 +283,3 @@ rte_kvargs_parse_delim(const char *args, const char * const valid_keys[],
 	free(copy);
 	return kvlist;
 }
-
-int
-rte_kvargs_strcmp(const char *key __rte_unused,
-		  const char *value, void *opaque)
-{
-	const char *str = opaque;
-
-	return -abs(strcmp(str, value));
-}
lib/kvargs/rte_kvargs.h +0 -26
index e40df1bd2a..3c1754c3d9 100644
@@ -197,32 +197,6 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist,
 unsigned rte_kvargs_count(const struct rte_kvargs *kvlist,
 	const char *key_match);
 
-/**
- * Generic kvarg handler for string comparison.
- *
- * This function can be used for a generic string comparison processing
- * on a list of kvargs.
- *
- * @param key
- *   kvarg pair key.
- *
- * @param value
- *   kvarg pair value.
- *
- * @param opaque
- *   Opaque pointer to a string.
- *
- * @return
- *   0 if the strings match.
- *   !0 otherwise or on error.
- *
- *   Unlike strcmp, comparison ordering is not kept.
- *   In order for rte_kvargs_process to stop processing on match error,
- *   a negative value is returned even if strcmp had returned a positive one.
- */
-__rte_experimental
-int rte_kvargs_strcmp(const char *key, const char *value, void *opaque);
-
 #ifdef __cplusplus
 }
 #endif
lib/kvargs/version.map +0 -2
index 82879b7140..0d42cd58a8 100644
@@ -14,8 +14,6 @@ DPDK_22 {
 EXPERIMENTAL {
 	global:
 
-	rte_kvargs_strcmp;
-
 	# added in 21.11
 	rte_kvargs_get_with_value;
 };
Signature · 1 line
2.30.2
#13 lore raw

Re: [dpdk-dev] [PATCH v2 4/5] kvargs: remove experimental function to compare string

Quoted 9 lines · Olivier Matz

The function was designed to be used as a handler for rte_kvargs_process() to compare the value string in a kvlist. For readability, its usages in DPDK have been replaced by rte_kvargs_get_with_value() in previous commit.

Remove this function, as it is not used anymore.

Maybe a quick note could be added in the release note. Something like this:

* kvargs: The experimental function ``rte_kvargs_strcmp()`` has been removed. Its usages have been replaced by a new function ``rte_kvargs_get_with_value()``.

David, do you want me to send a v3 with this note?

Thanks,
Olivier

#14 lore raw

Re: [dpdk-dev] [PATCH v2 4/5] kvargs: remove experimental function to compare string

Quoted 12 lines · Olivier Matz
Quoted 9 lines · Olivier Matz

The function was designed to be used as a handler for rte_kvargs_process() to compare the value string in a kvlist. For readability, its usages in DPDK have been replaced by rte_kvargs_get_with_value() in previous commit.

Remove this function, as it is not used anymore.

Quoted 8 lines

Maybe a quick note could be added in the release note. Something like this:

* kvargs: The experimental function ``rte_kvargs_strcmp()`` has been removed. Its usages have been replaced by a new function ``rte_kvargs_get_with_value()``.

David, do you want me to send a v3 with this note?

Yes, a RN update for API changes is a good practice :-). No need to send v3, I'll add it and merge the series (soon).

Thanks Olivier.

Signature · 1 line
David Marchand
#15 lore raw

PATCH v2 5/5 kvargs: fix comments style

In reply to Olivier Matz

A '*' is missing at 2 places, add them.

Fixes e1a00536c8ed ("kvargs: add a new library to parse key/value arguments")
Fixes 3ab385063cb9 ("kvargs: add get by key")
---
 lib/kvargs/rte_kvargs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/kvargs/rte_kvargs.h +2 -2
index 3c1754c3d9..359a9f5b09 100644
@@ -125,7 +125,7 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
  *   A list of rte_kvargs pair of 'key=value'.
  * @param key
  *   The matching key.
-
+ *
  * @return
  *   NULL if no key matches the input,
  *   a value associated with a matching key otherwise.
@@ -190,7 +190,7 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist,
  *   The rte_kvargs structure
  * @param key_match
  *   The key that should match, or NULL to count all associations
-
+ *
  * @return
  *   The number of entries
  */
Signature · 1 line
2.30.2
Reviewed-by on the v2 series
#16 lore raw
In reply to Olivier Matz
Quoted 10 lines · Olivier Matz

This patchset promotes 2 functions rte_kvargs_parse_delim() and rte_kvargs_get() as stable.

It also replaces rte_kvargs_strcmp() by a new one rte_kvargs_get_with_value(), which is easier to use.

v2
* remove rte_kvargs_strcmp from version.map

Quoted 6 lines

Olivier Matz (5):
kvargs: promote delimited parsing as stable
kvargs: promote get from key as stable
kvargs: new function to get from key and value
kvargs: remove experimental function to compare string
kvargs: fix comments style

Thanks, for the series,

Signature · 1 line
David Marchand
Acked-by
#17 lore raw
Quoted 18 lines · David Marchand
Quoted 10 lines · Olivier Matz

This patchset promotes 2 functions rte_kvargs_parse_delim() and rte_kvargs_get() as stable.

It also replaces rte_kvargs_strcmp() by a new one rte_kvargs_get_with_value(), which is easier to use.

v2
* remove rte_kvargs_strcmp from version.map

Quoted 6 lines

Olivier Matz (5):
kvargs: promote delimited parsing as stable
kvargs: promote get from key as stable
kvargs: new function to get from key and value
kvargs: remove experimental function to compare string
kvargs: fix comments style

Quoted 3 lines

Thanks, for the series,

#18 lore raw
Quoted 19 lines · Ray
Quoted 18 lines · David Marchand
Quoted 16 lines · Olivier Matz

This patchset promotes 2 functions rte_kvargs_parse_delim() and rte_kvargs_get() as stable.

It also replaces rte_kvargs_strcmp() by a new one rte_kvargs_get_with_value(), which is easier to use.

v2
* remove rte_kvargs_strcmp from version.map

Olivier Matz (5):
kvargs: promote delimited parsing as stable
kvargs: promote get from key as stable
kvargs: new function to get from key and value
kvargs: remove experimental function to compare string
kvargs: fix comments style

Quoted 4 lines
Quoted 2 lines

Thanks, for the series,

Added RN update and applied as discussed.
Thanks.

Signature · 1 line
David Marchand