[dpdk-dev] [PATCH v2 01/18] eal: prepend busname on legacy device declaration
Gaetan Rivet
gaetan.rivet at 6wind.com
Thu Oct 12 10:21:08 CEST 2017
Legacy device options (-b, -w, --vdev) need to prepend their bus name to
user parameters for backward compatibility.
Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
---
lib/librte_eal/common/eal_common_options.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 630c9d2..d57cb5d 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -143,13 +143,16 @@ static int mem_parsed;
static int core_parsed;
static int
-eal_option_device_add(enum rte_devtype type, const char *optarg)
+eal_option_device_add(enum rte_devtype type,
+ const char *busname, const char *optarg)
{
struct device_option *devopt;
size_t optlen;
int ret;
optlen = strlen(optarg) + 1;
+ if (busname != NULL)
+ optlen += strlen(optarg) + 1;
devopt = calloc(1, sizeof(*devopt) + optlen);
if (devopt == NULL) {
RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
@@ -157,7 +160,11 @@ eal_option_device_add(enum rte_devtype type, const char *optarg)
}
devopt->type = type;
- ret = snprintf(devopt->arg, optlen, "%s", optarg);
+ if (busname != NULL)
+ ret = snprintf(devopt->arg, optlen, "%s:%s",
+ busname, optarg);
+ else
+ ret = snprintf(devopt->arg, optlen, "%s", optarg);
if (ret < 0) {
RTE_LOG(ERR, EAL, "Unable to copy device option\n");
free(devopt);
@@ -1003,7 +1010,7 @@ eal_parse_common_option(int opt, const char *optarg,
if (rte_bus_probe_mode_set("pci", RTE_BUS_PROBE_BLACKLIST) < 0)
return -1;
if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
- optarg) < 0) {
+ "pci", optarg) < 0) {
return -1;
}
break;
@@ -1012,7 +1019,7 @@ eal_parse_common_option(int opt, const char *optarg,
if (rte_bus_probe_mode_set("pci", RTE_BUS_PROBE_WHITELIST) < 0)
return -1;
if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
- optarg) < 0) {
+ "pci", optarg) < 0) {
return -1;
}
break;
@@ -1122,7 +1129,7 @@ eal_parse_common_option(int opt, const char *optarg,
case OPT_VDEV_NUM:
if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
- optarg) < 0) {
+ "vdev", optarg) < 0) {
return -1;
}
break;
--
2.1.4
More information about the dev
mailing list