# \[PATCH net-next iproute2\] devlink: Show devlink port number

- Subsystems: THE REST
- Maintainers: Linus Torvalds
- Status: REVIEWED: 1 (0M) (Jiri Pirko)
- Reviewed.
- 1 review trailer.
- List: netdev
- 5 messages, 2 authors
- Page: https://ratatoskr.run/netdev/2019/07/11142021/t

## \[PATCH net-next iproute2\] devlink: Show devlink port number

- From: Parav Pandit \<hidden\>
- Date: 2019-07-09 16:34:00 
- Message: https://ratatoskr.run/netdev/2019/07/11142021.md

```text
Show devlink port number whenever kernel reports that attribute.

An example output for a physical port.
$ devlink port show
pci/0000:06:00.1/65535: type eth netdev eth1_p1 flavour physical port 1

Acked-by: Jiri Pirko <redacted>
Signed-off-by: Parav Pandit <redacted>
---
 devlink/devlink.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 559f624e..dba74e04 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -2806,6 +2806,11 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
 
 		pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
 	}
+	if (tb[DEVLINK_ATTR_PORT_NUMBER]) {
+		uint32_t port_number =
+			mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_NUMBER]);
+		pr_out_uint(dl, "port", port_number);
+	}
 	if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
 		pr_out_uint(dl, "split_group",
 			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));
-- 
2.19.2

```

## Re: \[PATCH net-next iproute2\] devlink: Show devlink port number

- From: David Ahern \<hidden\>
- Date: 2019-07-09 17:11:28 
- Message: https://ratatoskr.run/netdev/2019/07/11142024.md

```text
On 7/9/19 10:33 AM, Parav Pandit wrote:
> @@ -2806,6 +2806,11 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
>  
>  		pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
>  	}
> +	if (tb[DEVLINK_ATTR_PORT_NUMBER]) {
> +		uint32_t port_number =
> +			mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_NUMBER]);

declare and assign separately; nothing is gained when it is split across
lines like that.

> +		pr_out_uint(dl, "port", port_number);
> +	}
>  	if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
>  		pr_out_uint(dl, "split_group",
>  			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));

```

## RE: \[PATCH net-next iproute2\] devlink: Show devlink port number

- From: Parav Pandit \<hidden\>
- Date: 2019-07-09 17:21:44 
- Message: https://ratatoskr.run/netdev/2019/07/11142026.md

```text


> -----Original Message-----
> From: David Ahern <redacted>
> Sent: Tuesday, July 9, 2019 10:41 PM
> To: Parav Pandit <redacted>; <redacted>
> Cc: stephen@networkplumber.org; Jiri Pirko <redacted>;
> dsahern@kernel.org
> Subject: Re: [PATCH net-next iproute2] devlink: Show devlink port number
> 
> On 7/9/19 10:33 AM, Parav Pandit wrote:
> > @@ -2806,6 +2806,11 @@ static void pr_out_port(struct dl *dl, struct
> > nlattr **tb)
> >
> >  		pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
> >  	}
> > +	if (tb[DEVLINK_ATTR_PORT_NUMBER]) {
> > +		uint32_t port_number =
> > +
> 	mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_NUMBER]);
> 
> declare and assign separately; nothing is gained when it is split across lines
> like that.
>
Ok. I was misled by an example of port_flavour which assigns and declare in same line.
Sending v1.
 
> > +		pr_out_uint(dl, "port", port_number);
> > +	}
> >  	if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
> >  		pr_out_uint(dl, "split_group",
> >
> mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));

```

## \[PATCH net-next iproute2 v1\] devlink: Show devlink port number

- From: Parav Pandit \<hidden\>
- Date: 2019-07-09 17:27:01 
- Message: https://ratatoskr.run/netdev/2019/07/11142027.md

```text
Show devlink port number whenever kernel reports that attribute.

An example output for a physical port.
$ devlink port show
pci/0000:06:00.1/65535: type eth netdev eth1_p1 flavour physical port 1

Acked-by: Jiri Pirko <redacted>
Signed-off-by: Parav Pandit <redacted>
---
Changelog:
v0->v1:
 - Declare and assign port_number as two different lines.
---
 devlink/devlink.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 559f624e..c5491877 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -2806,6 +2806,12 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
 
 		pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
 	}
+	if (tb[DEVLINK_ATTR_PORT_NUMBER]) {
+		uint32_t port_number;
+
+		port_number = mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_NUMBER]);
+		pr_out_uint(dl, "port", port_number);
+	}
 	if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
 		pr_out_uint(dl, "split_group",
 			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));
-- 
2.19.2

```

## Re: \[PATCH net-next iproute2 v1\] devlink: Show devlink port number

- From: David Ahern \<hidden\>
- Date: 2019-07-09 22:34:02 
- Message: https://ratatoskr.run/netdev/2019/07/11142082.md

```text
On 7/9/19 11:26 AM, Parav Pandit wrote:
> Show devlink port number whenever kernel reports that attribute.
> 
> An example output for a physical port.
> $ devlink port show
> pci/0000:06:00.1/65535: type eth netdev eth1_p1 flavour physical port 1
> 
> Acked-by: Jiri Pirko <redacted>
> Signed-off-by: Parav Pandit <redacted>
> ---
> Changelog:
> v0->v1:
>  - Declare and assign port_number as two different lines.
> ---
>  devlink/devlink.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

applied to iproute2-next. Thanks


```
