All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: support new representors' naming format
@ 2019-02-28 15:25 Dekel Peled
  2019-03-03  7:43 ` [PATCH v2] " Dekel Peled
  0 siblings, 1 reply; 9+ messages in thread
From: Dekel Peled @ 2019-02-28 15:25 UTC (permalink / raw)
  To: yskoh, shahafs; +Cc: dev, orika, dekelp

Kernel update [1] introduce new format of representors names.
This patch updates MLX5 PMD to support the new format, while
maintaining support of the existing format.

[1] upstream kernel commit c12ecc230564
"net/mlx5e: Move to use common phys port names for vport representors"
http://l-gerrit.mtl.labs.mlnx:8080/#/c/upstream/linux/+/160883/

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_ethdev.c | 14 +++++++++++++-
 drivers/net/mlx5/mlx5_nl.c     | 20 +++++++++++++++-----
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 795c9c7..664f485 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1359,7 +1359,8 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	bool port_name_set = false;
 	bool port_switch_id_set = false;
 	bool device_dir = false;
-	char c;
+	char c, pf_c1, pf_c2, vf_c1, vf_c2;
+	int32_t pf_num;
 
 	if (!if_indextoname(ifindex, ifname)) {
 		rte_errno = errno;
@@ -1375,9 +1376,20 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 
 	file = fopen(phys_port_name, "rb");
 	if (file != NULL) {
+		/* Check for port-name as a number (support kernel ver < 5.0 */
 		port_name_set =
 			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
 			c == '\n';
+		if (!port_name_set) {
+			/*
+			 * Check for port-name as a string of the form pf0vf0
+			 * (support kernel ver >= 5.0)
+			 */
+			port_name_set = (fscanf(file, "%c%c%d%c%c%d%c", &pf_c1,
+						&pf_c2, &pf_num, &vf_c1, &vf_c2,
+						&data.port_name, &c) == 7) &&
+					c == '\n';
+		}
 		fclose(file);
 	}
 	file = fopen(phys_switch_id, "rb");
diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
index 0bf6845..cc7b4b8 100644
--- a/drivers/net/mlx5/mlx5_nl.c
+++ b/drivers/net/mlx5/mlx5_nl.c
@@ -849,7 +849,7 @@ struct mlx5_nl_ifindex_data {
 	while (off < nh->nlmsg_len) {
 		struct rtattr *ra = (void *)((uintptr_t)nh + off);
 		void *payload = RTA_DATA(ra);
-		char *end;
+		char *end, *vf_str;
 		unsigned int i;
 
 		if (ra->rta_len > nh->nlmsg_len - off)
@@ -861,10 +861,20 @@ struct mlx5_nl_ifindex_data {
 		case IFLA_PHYS_PORT_NAME:
 			errno = 0;
 			info.port_name = strtol(payload, &end, 0);
-			if (errno ||
-			    (size_t)(end - (char *)payload) != strlen(payload))
-				goto error;
-			port_name_set = true;
+			if (errno || ((size_t)(end - (char *)payload) !=
+				      strlen(payload))) {
+				vf_str = strstr(payload, "vf");
+				if (vf_str) {
+					errno = 0;
+					info.port_name = strtol(vf_str + 2,
+								&end, 0);
+					port_name_set = true;
+				}
+				if (errno)
+					goto error;
+			} else {
+				port_name_set = true;
+			}
 			break;
 		case IFLA_PHYS_SWITCH_ID:
 			info.switch_id = 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2] net/mlx5: support new representors' naming format
  2019-02-28 15:25 [PATCH] net/mlx5: support new representors' naming format Dekel Peled
@ 2019-03-03  7:43 ` Dekel Peled
  2019-03-07  8:57   ` Shahaf Shuler
  2019-03-10 15:21   ` [PATCH v3] net/mlx5: support new representor " Dekel Peled
  0 siblings, 2 replies; 9+ messages in thread
From: Dekel Peled @ 2019-03-03  7:43 UTC (permalink / raw)
  To: yskoh, shahafs; +Cc: dev, orika, dekelp

Kernel update [1] introduce new format of representors names.
This patch implements RFC [2], updating MLX5 PMD to support the new
format, while maintaining support of the existing format.

[1] https://github.com/torvalds/linux/commit/c12ecc2
[2] http://mails.dpdk.org/archives/dev/2019-March/125676.html

---
v2: Use public link to kernel patch, add link to RFC.
---

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_ethdev.c | 14 +++++++++++++-
 drivers/net/mlx5/mlx5_nl.c     | 20 +++++++++++++++-----
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 795c9c7..664f485 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1359,7 +1359,8 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	bool port_name_set = false;
 	bool port_switch_id_set = false;
 	bool device_dir = false;
-	char c;
+	char c, pf_c1, pf_c2, vf_c1, vf_c2;
+	int32_t pf_num;
 
 	if (!if_indextoname(ifindex, ifname)) {
 		rte_errno = errno;
@@ -1375,9 +1376,20 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 
 	file = fopen(phys_port_name, "rb");
 	if (file != NULL) {
+		/* Check for port-name as a number (support kernel ver < 5.0 */
 		port_name_set =
 			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
 			c == '\n';
+		if (!port_name_set) {
+			/*
+			 * Check for port-name as a string of the form pf0vf0
+			 * (support kernel ver >= 5.0)
+			 */
+			port_name_set = (fscanf(file, "%c%c%d%c%c%d%c", &pf_c1,
+						&pf_c2, &pf_num, &vf_c1, &vf_c2,
+						&data.port_name, &c) == 7) &&
+					c == '\n';
+		}
 		fclose(file);
 	}
 	file = fopen(phys_switch_id, "rb");
diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
index 0bf6845..cc7b4b8 100644
--- a/drivers/net/mlx5/mlx5_nl.c
+++ b/drivers/net/mlx5/mlx5_nl.c
@@ -849,7 +849,7 @@ struct mlx5_nl_ifindex_data {
 	while (off < nh->nlmsg_len) {
 		struct rtattr *ra = (void *)((uintptr_t)nh + off);
 		void *payload = RTA_DATA(ra);
-		char *end;
+		char *end, *vf_str;
 		unsigned int i;
 
 		if (ra->rta_len > nh->nlmsg_len - off)
@@ -861,10 +861,20 @@ struct mlx5_nl_ifindex_data {
 		case IFLA_PHYS_PORT_NAME:
 			errno = 0;
 			info.port_name = strtol(payload, &end, 0);
-			if (errno ||
-			    (size_t)(end - (char *)payload) != strlen(payload))
-				goto error;
-			port_name_set = true;
+			if (errno || ((size_t)(end - (char *)payload) !=
+				      strlen(payload))) {
+				vf_str = strstr(payload, "vf");
+				if (vf_str) {
+					errno = 0;
+					info.port_name = strtol(vf_str + 2,
+								&end, 0);
+					port_name_set = true;
+				}
+				if (errno)
+					goto error;
+			} else {
+				port_name_set = true;
+			}
 			break;
 		case IFLA_PHYS_SWITCH_ID:
 			info.switch_id = 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] net/mlx5: support new representors' naming format
  2019-03-03  7:43 ` [PATCH v2] " Dekel Peled
@ 2019-03-07  8:57   ` Shahaf Shuler
  2019-03-10 14:55     ` Dekel Peled
  2019-03-10 15:21   ` [PATCH v3] net/mlx5: support new representor " Dekel Peled
  1 sibling, 1 reply; 9+ messages in thread
From: Shahaf Shuler @ 2019-03-07  8:57 UTC (permalink / raw)
  To: Dekel Peled, Yongseok Koh; +Cc: dev, Ori Kam, Dekel Peled

Sunday, March 3, 2019 9:44 AM, Dekel Peled:
> Subject: [dpdk-dev] [PATCH v2] net/mlx5: support new representors'
> naming format

Representors' -> representor 

> 
> Kernel update [1] introduce new format of representors names.
> This patch implements RFC [2], updating MLX5 PMD to support the new
> format, while maintaining support of the existing format.

As a high level comment, I would expect to have some function called translate_phys_port_name to translate the netlink/sysfs output to the representor number.
This function should be called from both sysfs and netlink routines. 

> 
> [1]
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> hub.com%2Ftorvalds%2Flinux%2Fcommit%2Fc12ecc2&amp;data=02%7C01%
> 7Cshahafs%40mellanox.com%7C98910a4923c64d7af0cc08d69fac0de0%7Ca65
> 2971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636871958646189312&amp;
> sdata=vMvheEzZJEWRTtSK7z2qjJSxR2o50KnLOGATBAVfueM%3D&amp;reser
> ved=0
> [2]
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail
> s.dpdk.org%2Farchives%2Fdev%2F2019-
> March%2F125676.html&amp;data=02%7C01%7Cshahafs%40mellanox.com%7
> C98910a4923c64d7af0cc08d69fac0de0%7Ca652971c7d2e4d9ba6a4d149256f46
> 1b%7C0%7C0%7C636871958646189312&amp;sdata=UWxPP9SXclFAz23dtBHU
> eIF7v9ZRqbEU4nXUsirDr%2Bg%3D&amp;reserved=0
> 
> ---
> v2: Use public link to kernel patch, add link to RFC.
> ---
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_ethdev.c | 14 +++++++++++++-
>  drivers/net/mlx5/mlx5_nl.c     | 20 +++++++++++++++-----
>  2 files changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index 795c9c7..664f485 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -1359,7 +1359,8 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev,
> char *fw_ver, size_t fw_size)
>  	bool port_name_set = false;
>  	bool port_switch_id_set = false;
>  	bool device_dir = false;
> -	char c;
> +	char c, pf_c1, pf_c2, vf_c1, vf_c2;
> +	int32_t pf_num;
> 
>  	if (!if_indextoname(ifindex, ifname)) {
>  		rte_errno = errno;
> @@ -1375,9 +1376,20 @@ int mlx5_fw_version_get(struct rte_eth_dev
> *dev, char *fw_ver, size_t fw_size)
> 
>  	file = fopen(phys_port_name, "rb");
>  	if (file != NULL) {
> +		/* Check for port-name as a number (support kernel ver <
> 5.0 */

Logically it should be the other way around.
First check for new kernel, if not, fall back to older one. 

>  		port_name_set =
>  			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
>  			c == '\n';
> +		if (!port_name_set) {
> +			/*
> +			 * Check for port-name as a string of the form pf0vf0
> +			 * (support kernel ver >= 5.0)

According to the kernel commit, naming of type p0 or p1 (for the uplink vport). Will it work w/ below fscanf? 

> +			 */
> +			port_name_set = (fscanf(file, "%c%c%d%c%c%d%c",
> &pf_c1,
> +						&pf_c2, &pf_num, &vf_c1,
> &vf_c2,
> +						&data.port_name, &c) == 7)
> &&
> +					c == '\n';
> +		}


>  		fclose(file);
>  	}
>  	file = fopen(phys_switch_id, "rb");
> diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c index
> 0bf6845..cc7b4b8 100644
> --- a/drivers/net/mlx5/mlx5_nl.c
> +++ b/drivers/net/mlx5/mlx5_nl.c
> @@ -849,7 +849,7 @@ struct mlx5_nl_ifindex_data {
>  	while (off < nh->nlmsg_len) {
>  		struct rtattr *ra = (void *)((uintptr_t)nh + off);
>  		void *payload = RTA_DATA(ra);
> -		char *end;
> +		char *end, *vf_str;
>  		unsigned int i;
> 
>  		if (ra->rta_len > nh->nlmsg_len - off) @@ -861,10 +861,20
> @@ struct mlx5_nl_ifindex_data {
>  		case IFLA_PHYS_PORT_NAME:
>  			errno = 0;
>  			info.port_name = strtol(payload, &end, 0);

Again, the logic should be first try the new naming and fallback to old ones. 

> -			if (errno ||
> -			    (size_t)(end - (char *)payload) != strlen(payload))
> -				goto error;
> -			port_name_set = true;
> +			if (errno || ((size_t)(end - (char *)payload) !=
> +				      strlen(payload))) {
> +				vf_str = strstr(payload, "vf");
> +				if (vf_str) {
> +					errno = 0;
> +					info.port_name = strtol(vf_str + 2,
> +								&end, 0);

Again, true also in case port name is p0? 

> +					port_name_set = true;
> +				}
> +				if (errno)
> +					goto error;
> +			} else {
> +				port_name_set = true;
> +			}
>  			break;
>  		case IFLA_PHYS_SWITCH_ID:
>  			info.switch_id = 0;
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] net/mlx5: support new representors' naming format
  2019-03-07  8:57   ` Shahaf Shuler
@ 2019-03-10 14:55     ` Dekel Peled
  0 siblings, 0 replies; 9+ messages in thread
From: Dekel Peled @ 2019-03-10 14:55 UTC (permalink / raw)
  To: Shahaf Shuler, Yongseok Koh; +Cc: dev, Ori Kam

Thanks, PSB.

> -----Original Message-----
> From: Shahaf Shuler
> Sent: Thursday, March 7, 2019 10:58 AM
> To: Dekel Peled <dekelp@mellanox.com>; Yongseok Koh
> <yskoh@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: RE: [dpdk-dev] [PATCH v2] net/mlx5: support new representors'
> naming format
> 
> Sunday, March 3, 2019 9:44 AM, Dekel Peled:
> > Subject: [dpdk-dev] [PATCH v2] net/mlx5: support new representors'
> > naming format
> 
> Representors' -> representor
I'll amend it.

> 
> >
> > Kernel update [1] introduce new format of representors names.
> > This patch implements RFC [2], updating MLX5 PMD to support the new
> > format, while maintaining support of the existing format.
> 
> As a high level comment, I would expect to have some function called
> translate_phys_port_name to translate the netlink/sysfs output to the
> representor number.
> This function should be called from both sysfs and netlink routines.
I'll add it.

> 
> >
> > [1]
> >
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> >
> hub.com%2Ftorvalds%2Flinux%2Fcommit%2Fc12ecc2&amp;data=02%7C01%
> >
> 7Cshahafs%40mellanox.com%7C98910a4923c64d7af0cc08d69fac0de0%7Ca65
> >
> 2971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636871958646189312&amp;
> >
> sdata=vMvheEzZJEWRTtSK7z2qjJSxR2o50KnLOGATBAVfueM%3D&amp;reser
> > ved=0
> > [2]
> >
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail
> > s.dpdk.org%2Farchives%2Fdev%2F2019-
> >
> March%2F125676.html&amp;data=02%7C01%7Cshahafs%40mellanox.com%7
> >
> C98910a4923c64d7af0cc08d69fac0de0%7Ca652971c7d2e4d9ba6a4d149256f46
> >
> 1b%7C0%7C0%7C636871958646189312&amp;sdata=UWxPP9SXclFAz23dtBHU
> > eIF7v9ZRqbEU4nXUsirDr%2Bg%3D&amp;reserved=0
> >
> > ---
> > v2: Use public link to kernel patch, add link to RFC.
> > ---
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > ---
> >  drivers/net/mlx5/mlx5_ethdev.c | 14 +++++++++++++-
> >  drivers/net/mlx5/mlx5_nl.c     | 20 +++++++++++++++-----
> >  2 files changed, 28 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> > b/drivers/net/mlx5/mlx5_ethdev.c index 795c9c7..664f485 100644
> > --- a/drivers/net/mlx5/mlx5_ethdev.c
> > +++ b/drivers/net/mlx5/mlx5_ethdev.c
> > @@ -1359,7 +1359,8 @@ int mlx5_fw_version_get(struct rte_eth_dev
> *dev,
> > char *fw_ver, size_t fw_size)
> >  	bool port_name_set = false;
> >  	bool port_switch_id_set = false;
> >  	bool device_dir = false;
> > -	char c;
> > +	char c, pf_c1, pf_c2, vf_c1, vf_c2;
> > +	int32_t pf_num;
> >
> >  	if (!if_indextoname(ifindex, ifname)) {
> >  		rte_errno = errno;
> > @@ -1375,9 +1376,20 @@ int mlx5_fw_version_get(struct rte_eth_dev
> > *dev, char *fw_ver, size_t fw_size)
> >
> >  	file = fopen(phys_port_name, "rb");
> >  	if (file != NULL) {
> > +		/* Check for port-name as a number (support kernel ver <
> > 5.0 */
> 
> Logically it should be the other way around.
> First check for new kernel, if not, fall back to older one.
I'll reorder.

> 
> >  		port_name_set =
> >  			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
> >  			c == '\n';
> > +		if (!port_name_set) {
> > +			/*
> > +			 * Check for port-name as a string of the form pf0vf0
> > +			 * (support kernel ver >= 5.0)
> 
> According to the kernel commit, naming of type p0 or p1 (for the uplink
> vport). Will it work w/ below fscanf?
I don't need this name, only the representors names.
e.g. pf0vf0 will result in name "0". P0 will also result in name "0" but it is not valid.

> 
> > +			 */
> > +			port_name_set = (fscanf(file, "%c%c%d%c%c%d%c",
> > &pf_c1,
> > +						&pf_c2, &pf_num, &vf_c1,
> > &vf_c2,
> > +						&data.port_name, &c) == 7)
> > &&
> > +					c == '\n';
> > +		}
> 
> 
> >  		fclose(file);
> >  	}
> >  	file = fopen(phys_switch_id, "rb");
> > diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
> > index
> > 0bf6845..cc7b4b8 100644
> > --- a/drivers/net/mlx5/mlx5_nl.c
> > +++ b/drivers/net/mlx5/mlx5_nl.c
> > @@ -849,7 +849,7 @@ struct mlx5_nl_ifindex_data {
> >  	while (off < nh->nlmsg_len) {
> >  		struct rtattr *ra = (void *)((uintptr_t)nh + off);
> >  		void *payload = RTA_DATA(ra);
> > -		char *end;
> > +		char *end, *vf_str;
> >  		unsigned int i;
> >
> >  		if (ra->rta_len > nh->nlmsg_len - off) @@ -861,10 +861,20
> @@ struct
> > mlx5_nl_ifindex_data {
> >  		case IFLA_PHYS_PORT_NAME:
> >  			errno = 0;
> >  			info.port_name = strtol(payload, &end, 0);
> 
> Again, the logic should be first try the new naming and fallback to old ones.
I'll reorder.

> 
> > -			if (errno ||
> > -			    (size_t)(end - (char *)payload) != strlen(payload))
> > -				goto error;
> > -			port_name_set = true;
> > +			if (errno || ((size_t)(end - (char *)payload) !=
> > +				      strlen(payload))) {
> > +				vf_str = strstr(payload, "vf");
> > +				if (vf_str) {
> > +					errno = 0;
> > +					info.port_name = strtol(vf_str + 2,
> > +								&end, 0);
> 
> Again, true also in case port name is p0?
See comment above.

> 
> > +					port_name_set = true;
> > +				}
> > +				if (errno)
> > +					goto error;
> > +			} else {
> > +				port_name_set = true;
> > +			}
> >  			break;
> >  		case IFLA_PHYS_SWITCH_ID:
> >  			info.switch_id = 0;
> > --
> > 1.8.3.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] net/mlx5: support new representor naming format
  2019-03-03  7:43 ` [PATCH v2] " Dekel Peled
  2019-03-07  8:57   ` Shahaf Shuler
@ 2019-03-10 15:21   ` Dekel Peled
  2019-03-10 16:06     ` [PATCH v4] " Dekel Peled
  1 sibling, 1 reply; 9+ messages in thread
From: Dekel Peled @ 2019-03-10 15:21 UTC (permalink / raw)
  To: yskoh, shahafs; +Cc: dev, orika, dekelp

Kernel update [1] introduce new format of representors names.
This patch implements RFC [2], updating MLX5 PMD to support the new
format, while maintaining support of the existing format.

[1] https://github.com/torvalds/linux/commit/c12ecc2
[2] http://mails.dpdk.org/archives/dev/2019-March/125676.html

Signed-off-by: Dekel Peled <dekelp@mellanox.com>

---
v3: Add utility function with common logic, call it from sysfs and nl.
v2: Use public link to kernel patch, add link to RFC.
---
---
 drivers/net/mlx5/mlx5.h        |  1 +
 drivers/net/mlx5/mlx5_ethdev.c | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/net/mlx5/mlx5_nl.c     |  9 +++------
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 5384453..f997e71 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -300,6 +300,7 @@ unsigned int mlx5_dev_to_port_id(const struct rte_device *dev,
 				 unsigned int port_list_n);
 int mlx5_sysfs_switch_info(unsigned int ifindex,
 			   struct mlx5_switch_info *info);
+bool mlx5_translate_port_name(const char *port_name_in, int32_t *port_name_out);
 
 /* mlx5_mac.c */
 
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 795c9c7..433a723 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1353,6 +1353,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
 {
 	char ifname[IF_NAMESIZE];
+	char port_name[IF_NAMESIZE];
 	FILE *file;
 	DIR *dir;
 	struct mlx5_switch_info data = { .master = 0, };
@@ -1375,10 +1376,10 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 
 	file = fopen(phys_port_name, "rb");
 	if (file != NULL) {
-		port_name_set =
-			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
-			c == '\n';
+		fscanf(file, "%s", port_name);
 		fclose(file);
+		port_name_set = mlx5_translate_port_name(port_name,
+							 &data.port_name);
 	}
 	file = fopen(phys_switch_id, "rb");
 	if (file == NULL) {
@@ -1399,3 +1400,35 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	*info = data;
 	return 0;
 }
+
+/**
+ * Extract port name, as a number, from sysfs or netlink information.
+ *
+ * @param[in] port_name_in
+ *   String representing the port name.
+ * @param[out] port_name_out
+ *   Port name as a number.
+ *
+ * @return
+ *   true on success, false otherwise.
+ */
+bool
+mlx5_translate_port_name(const char *port_name_in, int32_t *port_name_out)
+{
+	char pf_c1, pf_c2, vf_c1, vf_c2;
+	int32_t pf_num;
+	bool port_name_set = false;
+
+	/*
+	 * Check for port-name as a string of the form pf0vf0
+	 * (support kernel ver >= 5.0)
+	 */
+	port_name_set =	(sscanf(port_name_in, "%c%c%d%c%c%d", &pf_c1, &pf_c2,
+				&pf_num, &vf_c1, &vf_c2, port_name_out) == 6);
+	if (!port_name_set) {
+		/* Check for port-name as a number (support kernel ver < 5.0 */
+		port_name_set =
+			(sscanf(port_name_in, "%d", port_name_out) == 1);
+	}
+	return port_name_set;
+}
diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
index 0bf6845..f89e522 100644
--- a/drivers/net/mlx5/mlx5_nl.c
+++ b/drivers/net/mlx5/mlx5_nl.c
@@ -849,7 +849,6 @@ struct mlx5_nl_ifindex_data {
 	while (off < nh->nlmsg_len) {
 		struct rtattr *ra = (void *)((uintptr_t)nh + off);
 		void *payload = RTA_DATA(ra);
-		char *end;
 		unsigned int i;
 
 		if (ra->rta_len > nh->nlmsg_len - off)
@@ -860,11 +859,9 @@ struct mlx5_nl_ifindex_data {
 			break;
 		case IFLA_PHYS_PORT_NAME:
 			errno = 0;
-			info.port_name = strtol(payload, &end, 0);
-			if (errno ||
-			    (size_t)(end - (char *)payload) != strlen(payload))
-				goto error;
-			port_name_set = true;
+			port_name_set =
+				mlx5_translate_port_name((char *)payload,
+							 &info.port_name);
 			break;
 		case IFLA_PHYS_SWITCH_ID:
 			info.switch_id = 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4] net/mlx5: support new representor naming format
  2019-03-10 15:21   ` [PATCH v3] net/mlx5: support new representor " Dekel Peled
@ 2019-03-10 16:06     ` Dekel Peled
  2019-03-17  6:23       ` [PATCH v5] " Dekel Peled
  0 siblings, 1 reply; 9+ messages in thread
From: Dekel Peled @ 2019-03-10 16:06 UTC (permalink / raw)
  To: yskoh, shahafs; +Cc: dev, orika, dekelp

Kernel update [1] introduce new format of representors names.
This patch implements RFC [2], updating MLX5 PMD to support the new
format, while maintaining support of the existing format.

[1] https://github.com/torvalds/linux/commit/c12ecc2
[2] http://mails.dpdk.org/archives/dev/2019-March/125676.html

Signed-off-by: Dekel Peled <dekelp@mellanox.com>

---
v4: Remove redundant clear of errno.
v3: Add utility function with common logic, call it from sysfs and nl.
v2: Use public link to kernel patch, add link to RFC.
---
---
 drivers/net/mlx5/mlx5.h        |  1 +
 drivers/net/mlx5/mlx5_ethdev.c | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/net/mlx5/mlx5_nl.c     | 10 +++-------
 3 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 5384453..f997e71 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -300,6 +300,7 @@ unsigned int mlx5_dev_to_port_id(const struct rte_device *dev,
 				 unsigned int port_list_n);
 int mlx5_sysfs_switch_info(unsigned int ifindex,
 			   struct mlx5_switch_info *info);
+bool mlx5_translate_port_name(const char *port_name_in, int32_t *port_name_out);
 
 /* mlx5_mac.c */
 
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 795c9c7..433a723 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1353,6 +1353,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
 {
 	char ifname[IF_NAMESIZE];
+	char port_name[IF_NAMESIZE];
 	FILE *file;
 	DIR *dir;
 	struct mlx5_switch_info data = { .master = 0, };
@@ -1375,10 +1376,10 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 
 	file = fopen(phys_port_name, "rb");
 	if (file != NULL) {
-		port_name_set =
-			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
-			c == '\n';
+		fscanf(file, "%s", port_name);
 		fclose(file);
+		port_name_set = mlx5_translate_port_name(port_name,
+							 &data.port_name);
 	}
 	file = fopen(phys_switch_id, "rb");
 	if (file == NULL) {
@@ -1399,3 +1400,35 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	*info = data;
 	return 0;
 }
+
+/**
+ * Extract port name, as a number, from sysfs or netlink information.
+ *
+ * @param[in] port_name_in
+ *   String representing the port name.
+ * @param[out] port_name_out
+ *   Port name as a number.
+ *
+ * @return
+ *   true on success, false otherwise.
+ */
+bool
+mlx5_translate_port_name(const char *port_name_in, int32_t *port_name_out)
+{
+	char pf_c1, pf_c2, vf_c1, vf_c2;
+	int32_t pf_num;
+	bool port_name_set = false;
+
+	/*
+	 * Check for port-name as a string of the form pf0vf0
+	 * (support kernel ver >= 5.0)
+	 */
+	port_name_set =	(sscanf(port_name_in, "%c%c%d%c%c%d", &pf_c1, &pf_c2,
+				&pf_num, &vf_c1, &vf_c2, port_name_out) == 6);
+	if (!port_name_set) {
+		/* Check for port-name as a number (support kernel ver < 5.0 */
+		port_name_set =
+			(sscanf(port_name_in, "%d", port_name_out) == 1);
+	}
+	return port_name_set;
+}
diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
index 0bf6845..5fb34e6 100644
--- a/drivers/net/mlx5/mlx5_nl.c
+++ b/drivers/net/mlx5/mlx5_nl.c
@@ -849,7 +849,6 @@ struct mlx5_nl_ifindex_data {
 	while (off < nh->nlmsg_len) {
 		struct rtattr *ra = (void *)((uintptr_t)nh + off);
 		void *payload = RTA_DATA(ra);
-		char *end;
 		unsigned int i;
 
 		if (ra->rta_len > nh->nlmsg_len - off)
@@ -859,12 +858,9 @@ struct mlx5_nl_ifindex_data {
 			num_vf_set = true;
 			break;
 		case IFLA_PHYS_PORT_NAME:
-			errno = 0;
-			info.port_name = strtol(payload, &end, 0);
-			if (errno ||
-			    (size_t)(end - (char *)payload) != strlen(payload))
-				goto error;
-			port_name_set = true;
+			port_name_set =
+				mlx5_translate_port_name((char *)payload,
+							 &info.port_name);
 			break;
 		case IFLA_PHYS_SWITCH_ID:
 			info.switch_id = 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v5] net/mlx5: support new representor naming format
  2019-03-10 16:06     ` [PATCH v4] " Dekel Peled
@ 2019-03-17  6:23       ` Dekel Peled
  2019-03-18  6:29         ` Slava Ovsiienko
  0 siblings, 1 reply; 9+ messages in thread
From: Dekel Peled @ 2019-03-17  6:23 UTC (permalink / raw)
  To: yskoh, shahafs; +Cc: dev, orika, dekelp

Kernel update [1] introduce new format of representors names.
This patch implements RFC [2], updating MLX5 PMD to support the new
format, while maintaining support of the existing format.

[1] https://github.com/torvalds/linux/commit/c12ecc2
[2] http://mails.dpdk.org/archives/dev/2019-March/125676.html

Signed-off-by: Dekel Peled <dekelp@mellanox.com>

---
v5: Add flag to indicate if rep. port name is in new format.
v4: Remove redundant clear of errno.
v3: Add utility function with common logic, call it from sysfs and nl.
v2: Use public link to kernel patch, add link to RFC.
---
---
 drivers/net/mlx5/mlx5.h        |  3 +++
 drivers/net/mlx5/mlx5_ethdev.c | 54 ++++++++++++++++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_nl.c     | 11 ++++-----
 3 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 5384453..88ffb19 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -60,6 +60,7 @@ enum {
 struct mlx5_switch_info {
 	uint32_t master:1; /**< Master device. */
 	uint32_t representor:1; /**< Representor device. */
+	uint32_t port_name_new:1; /**< Rep. port name is in new format. */
 	int32_t port_name; /**< Representor port name. */
 	uint64_t switch_id; /**< Switch identifier. */
 };
@@ -300,6 +301,8 @@ unsigned int mlx5_dev_to_port_id(const struct rte_device *dev,
 				 unsigned int port_list_n);
 int mlx5_sysfs_switch_info(unsigned int ifindex,
 			   struct mlx5_switch_info *info);
+bool mlx5_translate_port_name(const char *port_name_in,
+			      struct mlx5_switch_info *port_info_out);
 
 /* mlx5_mac.c */
 
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 795c9c7..428a465 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1353,9 +1353,16 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)
 {
 	char ifname[IF_NAMESIZE];
+	char port_name[IF_NAMESIZE];
 	FILE *file;
 	DIR *dir;
-	struct mlx5_switch_info data = { .master = 0, };
+	struct mlx5_switch_info data = {
+		.master = 0,
+		.representor = 0,
+		.port_name_new = 0,
+		.port_name = 0,
+		.switch_id = 0,
+	};
 	bool port_name_set = false;
 	bool port_switch_id_set = false;
 	bool device_dir = false;
@@ -1375,10 +1382,9 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 
 	file = fopen(phys_port_name, "rb");
 	if (file != NULL) {
-		port_name_set =
-			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
-			c == '\n';
+		fscanf(file, "%s", port_name);
 		fclose(file);
+		port_name_set = mlx5_translate_port_name(port_name, &data);
 	}
 	file = fopen(phys_switch_id, "rb");
 	if (file == NULL) {
@@ -1399,3 +1405,43 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	*info = data;
 	return 0;
 }
+
+/**
+ * Extract port name, as a number, from sysfs or netlink information.
+ *
+ * @param[in] port_name_in
+ *   String representing the port name.
+ * @param[out] port_info_out
+ *   Port information, including port name as a number.
+ *
+ * @return
+ *   true on success, false otherwise.
+ */
+bool
+mlx5_translate_port_name(const char *port_name_in,
+			 struct mlx5_switch_info *port_info_out)
+{
+	char pf_c1, pf_c2, vf_c1, vf_c2;
+	char *end;
+	int32_t pf_num;
+	bool port_name_set = false;
+
+	/*
+	 * Check for port-name as a string of the form pf0vf0
+	 * (support kernel ver >= 5.0)
+	 */
+	port_name_set =	(sscanf(port_name_in, "%c%c%d%c%c%d", &pf_c1, &pf_c2,
+				&pf_num, &vf_c1, &vf_c2,
+				&port_info_out->port_name) == 6);
+	if (port_name_set) {
+		port_info_out->port_name_new = 1;
+	} else {
+		/* Check for port-name as a number (support kernel ver < 5.0 */
+		errno = 0;
+		port_info_out->port_name = strtol(port_name_in, &end, 0);
+		if (!errno &&
+		    (size_t)(end - port_name_in) == strlen(port_name_in))
+			port_name_set = true;
+	}
+	return port_name_set;
+}
diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
index 0bf6845..cb34de3 100644
--- a/drivers/net/mlx5/mlx5_nl.c
+++ b/drivers/net/mlx5/mlx5_nl.c
@@ -836,6 +836,7 @@ struct mlx5_nl_ifindex_data {
 	struct mlx5_switch_info info = {
 		.master = 0,
 		.representor = 0,
+		.port_name_new = 0,
 		.port_name = 0,
 		.switch_id = 0,
 	};
@@ -849,7 +850,6 @@ struct mlx5_nl_ifindex_data {
 	while (off < nh->nlmsg_len) {
 		struct rtattr *ra = (void *)((uintptr_t)nh + off);
 		void *payload = RTA_DATA(ra);
-		char *end;
 		unsigned int i;
 
 		if (ra->rta_len > nh->nlmsg_len - off)
@@ -859,12 +859,9 @@ struct mlx5_nl_ifindex_data {
 			num_vf_set = true;
 			break;
 		case IFLA_PHYS_PORT_NAME:
-			errno = 0;
-			info.port_name = strtol(payload, &end, 0);
-			if (errno ||
-			    (size_t)(end - (char *)payload) != strlen(payload))
-				goto error;
-			port_name_set = true;
+			port_name_set =
+				mlx5_translate_port_name((char *)payload,
+							 &info);
 			break;
 		case IFLA_PHYS_SWITCH_ID:
 			info.switch_id = 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v5] net/mlx5: support new representor naming format
  2019-03-17  6:23       ` [PATCH v5] " Dekel Peled
@ 2019-03-18  6:29         ` Slava Ovsiienko
  2019-03-18  6:59           ` Shahaf Shuler
  0 siblings, 1 reply; 9+ messages in thread
From: Slava Ovsiienko @ 2019-03-18  6:29 UTC (permalink / raw)
  To: Dekel Peled, Yongseok Koh, Shahaf Shuler; +Cc: dev, Ori Kam, Dekel Peled

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Sunday, March 17, 2019 8:23
> To: Yongseok Koh <yskoh@mellanox.com>; Shahaf Shuler
> <shahafs@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH v5] net/mlx5: support new representor naming
> format
> 
> Kernel update [1] introduce new format of representors names.
> This patch implements RFC [2], updating MLX5 PMD to support the new
> format, while maintaining support of the existing format.
> 
> [1]
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub
> .com%2Ftorvalds%2Flinux%2Fcommit%2Fc12ecc2&amp;data=02%7C01%7Cvi
> acheslavo%40mellanox.com%7C17dec02b64014892fa4a08d6aaa12e04%7Ca
> 652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636884006586825444&a
> mp;sdata=YFOOhRcJ2qb19nRUA9aRUqHP8HChHLX7VP1tlWZ5OLk%3D&amp;
> reserved=0
> [2]
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmails.d
> pdk.org%2Farchives%2Fdev%2F2019-
> March%2F125676.html&amp;data=02%7C01%7Cviacheslavo%40mellanox.co
> m%7C17dec02b64014892fa4a08d6aaa12e04%7Ca652971c7d2e4d9ba6a4d14
> 9256f461b%7C0%7C0%7C636884006586825444&amp;sdata=EWWcj5GANyC
> 5nKdNaCuqUeRZmXIEgH4HHRbc52h5cto%3D&amp;reserved=0
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> 
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
> v5: Add flag to indicate if rep. port name is in new format.
> v4: Remove redundant clear of errno.
> v3: Add utility function with common logic, call it from sysfs and nl.
> v2: Use public link to kernel patch, add link to RFC.
> ---
> ---
>  drivers/net/mlx5/mlx5.h        |  3 +++
>  drivers/net/mlx5/mlx5_ethdev.c | 54
> ++++++++++++++++++++++++++++++++++++++----
>  drivers/net/mlx5/mlx5_nl.c     | 11 ++++-----
>  3 files changed, 57 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> 5384453..88ffb19 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -60,6 +60,7 @@ enum {
>  struct mlx5_switch_info {
>  	uint32_t master:1; /**< Master device. */
>  	uint32_t representor:1; /**< Representor device. */
> +	uint32_t port_name_new:1; /**< Rep. port name is in new format.
> */
>  	int32_t port_name; /**< Representor port name. */
>  	uint64_t switch_id; /**< Switch identifier. */  }; @@ -300,6 +301,8
> @@ unsigned int mlx5_dev_to_port_id(const struct rte_device *dev,
>  				 unsigned int port_list_n);
>  int mlx5_sysfs_switch_info(unsigned int ifindex,
>  			   struct mlx5_switch_info *info);
> +bool mlx5_translate_port_name(const char *port_name_in,
> +			      struct mlx5_switch_info *port_info_out);
> 
>  /* mlx5_mac.c */
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index 795c9c7..428a465 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -1353,9 +1353,16 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev,
> char *fw_ver, size_t fw_size)  mlx5_sysfs_switch_info(unsigned int ifindex,
> struct mlx5_switch_info *info)  {
>  	char ifname[IF_NAMESIZE];
> +	char port_name[IF_NAMESIZE];
>  	FILE *file;
>  	DIR *dir;
> -	struct mlx5_switch_info data = { .master = 0, };
> +	struct mlx5_switch_info data = {
> +		.master = 0,
> +		.representor = 0,
> +		.port_name_new = 0,
> +		.port_name = 0,
> +		.switch_id = 0,
> +	};
>  	bool port_name_set = false;
>  	bool port_switch_id_set = false;
>  	bool device_dir = false;
> @@ -1375,10 +1382,9 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev,
> char *fw_ver, size_t fw_size)
> 
>  	file = fopen(phys_port_name, "rb");
>  	if (file != NULL) {
> -		port_name_set =
> -			fscanf(file, "%d%c", &data.port_name, &c) == 2 &&
> -			c == '\n';
> +		fscanf(file, "%s", port_name);
>  		fclose(file);
> +		port_name_set = mlx5_translate_port_name(port_name,
> &data);
>  	}
>  	file = fopen(phys_switch_id, "rb");
>  	if (file == NULL) {
> @@ -1399,3 +1405,43 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev,
> char *fw_ver, size_t fw_size)
>  	*info = data;
>  	return 0;
>  }
> +
> +/**
> + * Extract port name, as a number, from sysfs or netlink information.
> + *
> + * @param[in] port_name_in
> + *   String representing the port name.
> + * @param[out] port_info_out
> + *   Port information, including port name as a number.
> + *
> + * @return
> + *   true on success, false otherwise.
> + */
> +bool
> +mlx5_translate_port_name(const char *port_name_in,
> +			 struct mlx5_switch_info *port_info_out) {
> +	char pf_c1, pf_c2, vf_c1, vf_c2;
> +	char *end;
> +	int32_t pf_num;
> +	bool port_name_set = false;
> +
> +	/*
> +	 * Check for port-name as a string of the form pf0vf0
> +	 * (support kernel ver >= 5.0)
> +	 */
> +	port_name_set =	(sscanf(port_name_in, "%c%c%d%c%c%d",
> &pf_c1, &pf_c2,
> +				&pf_num, &vf_c1, &vf_c2,
> +				&port_info_out->port_name) == 6);
> +	if (port_name_set) {
> +		port_info_out->port_name_new = 1;
> +	} else {
> +		/* Check for port-name as a number (support kernel ver <
> 5.0 */
> +		errno = 0;
> +		port_info_out->port_name = strtol(port_name_in, &end, 0);
> +		if (!errno &&
> +		    (size_t)(end - port_name_in) == strlen(port_name_in))
> +			port_name_set = true;
> +	}
> +	return port_name_set;
> +}
> diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c index
> 0bf6845..cb34de3 100644
> --- a/drivers/net/mlx5/mlx5_nl.c
> +++ b/drivers/net/mlx5/mlx5_nl.c
> @@ -836,6 +836,7 @@ struct mlx5_nl_ifindex_data {
>  	struct mlx5_switch_info info = {
>  		.master = 0,
>  		.representor = 0,
> +		.port_name_new = 0,
>  		.port_name = 0,
>  		.switch_id = 0,
>  	};
> @@ -849,7 +850,6 @@ struct mlx5_nl_ifindex_data {
>  	while (off < nh->nlmsg_len) {
>  		struct rtattr *ra = (void *)((uintptr_t)nh + off);
>  		void *payload = RTA_DATA(ra);
> -		char *end;
>  		unsigned int i;
> 
>  		if (ra->rta_len > nh->nlmsg_len - off) @@ -859,12 +859,9 @@
> struct mlx5_nl_ifindex_data {
>  			num_vf_set = true;
>  			break;
>  		case IFLA_PHYS_PORT_NAME:
> -			errno = 0;
> -			info.port_name = strtol(payload, &end, 0);
> -			if (errno ||
> -			    (size_t)(end - (char *)payload) != strlen(payload))
> -				goto error;
> -			port_name_set = true;
> +			port_name_set =
> +				mlx5_translate_port_name((char *)payload,
> +							 &info);
>  			break;
>  		case IFLA_PHYS_SWITCH_ID:
>  			info.switch_id = 0;
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v5] net/mlx5: support new representor naming format
  2019-03-18  6:29         ` Slava Ovsiienko
@ 2019-03-18  6:59           ` Shahaf Shuler
  0 siblings, 0 replies; 9+ messages in thread
From: Shahaf Shuler @ 2019-03-18  6:59 UTC (permalink / raw)
  To: Slava Ovsiienko, Dekel Peled, Yongseok Koh; +Cc: dev, Ori Kam, Dekel Peled

Monday, March 18, 2019 8:29 AM, Slava Ovsiienko
> Subject: RE: [dpdk-dev] [PATCH v5] net/mlx5: support new representor
> naming format
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> > Sent: Sunday, March 17, 2019 8:23
> > To: Yongseok Koh <yskoh@mellanox.com>; Shahaf Shuler
> > <shahafs@mellanox.com>
> > Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> > <dekelp@mellanox.com>
> > Subject: [dpdk-dev] [PATCH v5] net/mlx5: support new representor
> > naming format
> >
> > Kernel update [1] introduce new format of representors names.
> > This patch implements RFC [2], updating MLX5 PMD to support the new
> > format, while maintaining support of the existing format.
> >
> > [1]
> > https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> > ub
> .com%2Ftorvalds%2Flinux%2Fcommit%2Fc12ecc2&amp;data=02%7C01%7Cvi
> > acheslavo%40mellanox.com%7C17dec02b64014892fa4a08d6aaa12e04%7Ca
> > 652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636884006586825444&a
> >
> mp;sdata=YFOOhRcJ2qb19nRUA9aRUqHP8HChHLX7VP1tlWZ5OLk%3D&amp;
> > reserved=0
> > [2]
> >
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmails
> > .d
> > pdk.org%2Farchives%2Fdev%2F2019-
> >
> March%2F125676.html&amp;data=02%7C01%7Cviacheslavo%40mellanox.co
> > m%7C17dec02b64014892fa4a08d6aaa12e04%7Ca652971c7d2e4d9ba6a4d14
> > 9256f461b%7C0%7C0%7C636884006586825444&amp;sdata=EWWcj5GANyC
> > 5nKdNaCuqUeRZmXIEgH4HHRbc52h5cto%3D&amp;reserved=0
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> >
> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

Applied to next-net-mlx, thanks. 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-03-18  6:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 15:25 [PATCH] net/mlx5: support new representors' naming format Dekel Peled
2019-03-03  7:43 ` [PATCH v2] " Dekel Peled
2019-03-07  8:57   ` Shahaf Shuler
2019-03-10 14:55     ` Dekel Peled
2019-03-10 15:21   ` [PATCH v3] net/mlx5: support new representor " Dekel Peled
2019-03-10 16:06     ` [PATCH v4] " Dekel Peled
2019-03-17  6:23       ` [PATCH v5] " Dekel Peled
2019-03-18  6:29         ` Slava Ovsiienko
2019-03-18  6:59           ` Shahaf Shuler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.