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 <j...@mellanox.com>
Signed-off-by: Parav Pandit <pa...@mellanox.com>
---
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

Reply via email to