[dpdk-dev,v2,01/18] eal: prepend busname on legacy device declaration

Message ID cba136f9cce981cadedfa1ae39fbd6a8e71786b9.1507796100.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Gaëtan Rivet Oct. 12, 2017, 8:21 a.m. UTC
  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@6wind.com>
---
 lib/librte_eal/common/eal_common_options.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
  

Comments

Shreyansh Jain Dec. 11, 2017, 1:57 p.m. UTC | #1
One very quick comment:

On Thursday 12 October 2017 01:51 PM, Gaetan Rivet wrote:
> 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@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;

I think you want "optlen += strlen(busname) + 1";

>   	devopt = calloc(1, sizeof(*devopt) + optlen);
>   	if (devopt == NULL) {
>   		RTE_LOG(ERR, EAL, "Unable to allocate device option\n");

[...]
  

Patch

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;