From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com,
ferruh.yigit@intel.com, arybchenko@solarflare.com,
olivier.matz@6wind.com, remy.horton@intel.com,
bruce.richardson@intel.com
Subject: [dpdk-dev] [PATCH v2 2/4] ethdev: move representor parsing functions
Date: Wed, 10 Oct 2018 21:23:28 +0200 [thread overview]
Message-ID: <20181010192330.21105-3-thomas@monjalon.net> (raw)
In-Reply-To: <20181010192330.21105-1-thomas@monjalon.net>
The functions for representor devargs parsing were static
in the file rte_ethdev.c.
In order to reuse them in the file rte_class_eth.c,
they are moved to the files ethdev_private.c/.h.
A log is fixed by adding a missing line feed.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
lib/librte_ethdev/ethdev_private.c | 82 ++++++++++++++++++++++++++++
lib/librte_ethdev/ethdev_private.h | 6 +++
lib/librte_ethdev/rte_ethdev.c | 85 ------------------------------
3 files changed, 88 insertions(+), 85 deletions(-)
diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c
index acc787dba..162a502fe 100644
--- a/lib/librte_ethdev/ethdev_private.c
+++ b/lib/librte_ethdev/ethdev_private.c
@@ -3,6 +3,7 @@
*/
#include "rte_ethdev.h"
+#include "rte_ethdev_driver.h"
#include "ethdev_private.h"
uint16_t
@@ -37,3 +38,84 @@ eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp,
return NULL;
}
+int
+rte_eth_devargs_parse_list(char *str, rte_eth_devargs_callback_t callback,
+ void *data)
+{
+ char *str_start;
+ int state;
+ int result;
+
+ if (*str != '[')
+ /* Single element, not a list */
+ return callback(str, data);
+
+ /* Sanity check, then strip the brackets */
+ str_start = &str[strlen(str) - 1];
+ if (*str_start != ']') {
+ RTE_LOG(ERR, EAL, "(%s): List does not end with ']'\n", str);
+ return -EINVAL;
+ }
+ str++;
+ *str_start = '\0';
+
+ /* Process list elements */
+ state = 0;
+ while (1) {
+ if (state == 0) {
+ if (*str == '\0')
+ break;
+ if (*str != ',') {
+ str_start = str;
+ state = 1;
+ }
+ } else if (state == 1) {
+ if (*str == ',' || *str == '\0') {
+ if (str > str_start) {
+ /* Non-empty string fragment */
+ *str = '\0';
+ result = callback(str_start, data);
+ if (result < 0)
+ return result;
+ }
+ state = 0;
+ }
+ }
+ str++;
+ }
+ return 0;
+}
+
+static int
+rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list,
+ const uint16_t max_list)
+{
+ uint16_t lo, hi, val;
+ int result;
+
+ result = sscanf(str, "%hu-%hu", &lo, &hi);
+ if (result == 1) {
+ if (*len_list >= max_list)
+ return -ENOMEM;
+ list[(*len_list)++] = lo;
+ } else if (result == 2) {
+ if (lo >= hi || lo > RTE_MAX_ETHPORTS || hi > RTE_MAX_ETHPORTS)
+ return -EINVAL;
+ for (val = lo; val <= hi; val++) {
+ if (*len_list >= max_list)
+ return -ENOMEM;
+ list[(*len_list)++] = val;
+ }
+ } else
+ return -EINVAL;
+ return 0;
+}
+
+int
+rte_eth_devargs_parse_representor_ports(char *str, void *data)
+{
+ struct rte_eth_devargs *eth_da = data;
+
+ return rte_eth_devargs_process_range(str, eth_da->representor_ports,
+ ð_da->nb_representor_ports, RTE_MAX_ETHPORTS);
+}
diff --git a/lib/librte_ethdev/ethdev_private.h b/lib/librte_ethdev/ethdev_private.h
index e67cf6831..7b787bf97 100644
--- a/lib/librte_ethdev/ethdev_private.h
+++ b/lib/librte_ethdev/ethdev_private.h
@@ -25,6 +25,12 @@ struct rte_eth_dev *
eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp,
const void *data);
+/* Parse devargs value for representor parameter. */
+typedef int (*rte_eth_devargs_callback_t)(char *str, void *data);
+int rte_eth_devargs_parse_list(char *str, rte_eth_devargs_callback_t callback,
+ void *data);
+int rte_eth_devargs_parse_representor_ports(char *str, void *data);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 9ac802f3f..3062dc711 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -4309,8 +4309,6 @@ rte_eth_switch_domain_free(uint16_t domain_id)
return 0;
}
-typedef int (*rte_eth_devargs_callback_t)(char *str, void *data);
-
static int
rte_eth_devargs_tokenise(struct rte_kvargs *arglist, const char *str_in)
{
@@ -4375,89 +4373,6 @@ rte_eth_devargs_tokenise(struct rte_kvargs *arglist, const char *str_in)
}
}
-static int
-rte_eth_devargs_parse_list(char *str, rte_eth_devargs_callback_t callback,
- void *data)
-{
- char *str_start;
- int state;
- int result;
-
- if (*str != '[')
- /* Single element, not a list */
- return callback(str, data);
-
- /* Sanity check, then strip the brackets */
- str_start = &str[strlen(str) - 1];
- if (*str_start != ']') {
- RTE_LOG(ERR, EAL, "(%s): List does not end with ']'", str);
- return -EINVAL;
- }
- str++;
- *str_start = '\0';
-
- /* Process list elements */
- state = 0;
- while (1) {
- if (state == 0) {
- if (*str == '\0')
- break;
- if (*str != ',') {
- str_start = str;
- state = 1;
- }
- } else if (state == 1) {
- if (*str == ',' || *str == '\0') {
- if (str > str_start) {
- /* Non-empty string fragment */
- *str = '\0';
- result = callback(str_start, data);
- if (result < 0)
- return result;
- }
- state = 0;
- }
- }
- str++;
- }
- return 0;
-}
-
-static int
-rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list,
- const uint16_t max_list)
-{
- uint16_t lo, hi, val;
- int result;
-
- result = sscanf(str, "%hu-%hu", &lo, &hi);
- if (result == 1) {
- if (*len_list >= max_list)
- return -ENOMEM;
- list[(*len_list)++] = lo;
- } else if (result == 2) {
- if (lo >= hi || lo > RTE_MAX_ETHPORTS || hi > RTE_MAX_ETHPORTS)
- return -EINVAL;
- for (val = lo; val <= hi; val++) {
- if (*len_list >= max_list)
- return -ENOMEM;
- list[(*len_list)++] = val;
- }
- } else
- return -EINVAL;
- return 0;
-}
-
-
-static int
-rte_eth_devargs_parse_representor_ports(char *str, void *data)
-{
- struct rte_eth_devargs *eth_da = data;
-
- return rte_eth_devargs_process_range(str, eth_da->representor_ports,
- ð_da->nb_representor_ports, RTE_MAX_ETHPORTS);
-}
-
int __rte_experimental
rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)
{
--
2.19.0
next prev parent reply other threads:[~2018-10-10 19:23 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 2:18 [dpdk-dev] [PATCH 0/4] support more ethdev iterator filters Thomas Monjalon
2018-10-09 2:18 ` [dpdk-dev] [PATCH 1/4] kvargs: support list value Thomas Monjalon
2018-10-09 14:14 ` Gaëtan Rivet
2018-10-09 14:31 ` Thomas Monjalon
2018-10-09 15:11 ` Stephen Hemminger
2018-10-09 17:11 ` Thomas Monjalon
2018-10-10 13:12 ` Remy Horton
2018-10-09 2:18 ` [dpdk-dev] [PATCH 2/4] mk: remove broken check Thomas Monjalon
2018-10-09 11:43 ` Neil Horman
2018-10-09 11:53 ` Thomas Monjalon
2018-10-09 18:11 ` Neil Horman
2018-10-09 2:18 ` [dpdk-dev] [PATCH 3/4] ethdev: move representor parsing functions Thomas Monjalon
2018-10-09 9:06 ` Andrew Rybchenko
2018-10-09 12:38 ` Remy Horton
2018-10-09 13:25 ` Thomas Monjalon
2018-10-09 2:18 ` [dpdk-dev] [PATCH 4/4] ethdev: support representor id for iterating ports Thomas Monjalon
2018-10-09 9:14 ` Andrew Rybchenko
2018-10-10 19:23 ` [dpdk-dev] [PATCH v2 0/4] support more ethdev iterator filters Thomas Monjalon
2018-10-10 19:23 ` [dpdk-dev] [PATCH v2 1/4] kvargs: support list value Thomas Monjalon
2018-10-10 19:23 ` Thomas Monjalon [this message]
2018-10-10 19:23 ` [dpdk-dev] [PATCH v2 3/4] ethdev: support representor id as iterator filter Thomas Monjalon
2018-10-10 19:23 ` [dpdk-dev] [PATCH v2 4/4] ethdev: support MAC address " Thomas Monjalon
2018-10-22 13:15 ` [dpdk-dev] [PATCH v3 0/4] support more ethdev iterator filters Thomas Monjalon
2018-10-22 13:15 ` [dpdk-dev] [PATCH v3 1/4] kvargs: support list value Thomas Monjalon
2018-10-22 13:15 ` [dpdk-dev] [PATCH v3 2/4] ethdev: move representor parsing functions Thomas Monjalon
2018-10-22 13:15 ` [dpdk-dev] [PATCH v3 3/4] ethdev: support representor id as iterator filter Thomas Monjalon
2018-10-22 13:15 ` [dpdk-dev] [PATCH v3 4/4] ethdev: support MAC address " Thomas Monjalon
2018-10-22 13:37 ` Andrew Rybchenko
2018-10-22 14:02 ` Thomas Monjalon
2018-10-22 14:18 ` Andrew Rybchenko
2018-10-22 21:24 ` Ananyev, Konstantin
2018-10-23 7:20 ` Thomas Monjalon
2018-10-23 8:33 ` Ananyev, Konstantin
2018-10-23 8:53 ` Thomas Monjalon
2018-10-23 21:45 ` Ananyev, Konstantin
2018-10-22 14:25 ` Andrew Rybchenko
2018-10-24 8:27 ` [dpdk-dev] [PATCH v3 0/4] support more ethdev iterator filters 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=20181010192330.21105-3-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=arybchenko@solarflare.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=gaetan.rivet@6wind.com \
--cc=olivier.matz@6wind.com \
--cc=ophirmu@mellanox.com \
--cc=remy.horton@intel.com \
/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).