devlink: add port flavours/number/split_subport
Subsystems (3)
Jiri Pirko
maintainercover devlink: add port flavours/number/split_subport
From: Jiri Pirko <[email protected]>
Jiri Pirko (2):
devlink: introduce support for showing port flavours
devlink: introduce support for showing port number and split subport
number
devlink/devlink.c | 26 ++++++++++++++++++++++++++ include/uapi/linux/devlink.h | 14 ++++++++++++++ 2 files changed, 40 insertions(+)
Signature · 1 line
2.14.3
Jiri Pirko
maintainerPATCH 1/2 devlink: introduce support for showing port flavours
From: Jiri Pirko <[email protected]>
--- devlink/devlink.c | 20 ++++++++++++++++++++ include/uapi/linux/devlink.h | 12 ++++++++++++ 2 files changed, 32 insertions(+)
devlink/devlink.c +20 -0
@@ -1693,6 +1693,20 @@ static const char *port_type_name(uint32_t type) } } +static const char *port_flavour_name (uint16_t flavour) +{ +switch (flavour) { +case DEVLINK_PORT_FLAVOUR_PHYSICAL : +return "physical" ; +case DEVLINK_PORT_FLAVOUR_CPU : +return "cpu" ; +case DEVLINK_PORT_FLAVOUR_DSA : +return "dsa" ; +default : +return "<unknown flavour>" ; + } +} +static void pr_out_port (struct dl *dl,struct nlattr **tb) {struct nlattr *pt_attr = tb[DEVLINK_ATTR_PORT_TYPE ];
@@ -1717,6 +1731,12 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)if (tb[DEVLINK_ATTR_PORT_IBDEV_NAME ])pr_out_str (dl,"ibdev" ,mnl_attr_get_str (tb[DEVLINK_ATTR_PORT_IBDEV_NAME ])); +if (tb[DEVLINK_ATTR_PORT_FLAVOUR ]) { +uint16_t port_flavour = +mnl_attr_get_u16 (tb[DEVLINK_ATTR_PORT_FLAVOUR ]); + +pr_out_str (dl,"flavour" ,port_flavour_name (port_flavour)); + }if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP ])pr_out_uint (dl,"split_group" ,mnl_attr_get_u32 (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP ]));
include/uapi/linux/devlink.h +12 -0
@@ -132,6 +132,16 @@ enum devlink_eswitch_encap_mode { DEVLINK_ESWITCH_ENCAP_MODE_BASIC, }; +enum devlink_port_flavour { +DEVLINK_PORT_FLAVOUR_PHYSICAL ,/* Any kind of a port physically +* facing the user. +*/ +DEVLINK_PORT_FLAVOUR_CPU ,/* CPU port */ +DEVLINK_PORT_FLAVOUR_DSA ,/* Distributed switch architecture +* interconnect port. +*/ +}; +enum devlink_attr {/* don't change the order or add anything between, this is ABI! */ DEVLINK_ATTR_UNSPEC ,
@@ -224,6 +234,8 @@ enum devlink_attr {DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID ,/* u64 */ DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS ,/* u64 */ +DEVLINK_ATTR_PORT_FLAVOUR ,/* u16 */ +/* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX,
Signature · 1 line
2.14.3
David Ahern
AppliedRe: [patch iproute2/net-next 1/2] devlink: introduce support for showing port flavours
Quoted 9 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Signed-off-by Jiri Pirko <[email protected]>--- devlink/devlink.c | 20 ++++++++++++++++++++ include/uapi/linux/devlink.h | 12 ++++++++++++ 2 files changed, 32 insertions(+)
applied to iproute2-next
Jiri Pirko
maintainerPATCH 2/2 devlink: introduce support for showing port number and split subport number
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
--- devlink/devlink.c | 6 ++++++ include/uapi/linux/devlink.h | 2 ++ 2 files changed, 8 insertions(+)
devlink/devlink.c +6 -0
@@ -1737,9 +1737,15 @@ 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 ]) +pr_out_uint (dl,"number" , +mnl_attr_get_u32 (tb[DEVLINK_ATTR_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 ])); +if (tb[DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER ]) +pr_out_uint (dl,"subport" , +mnl_attr_get_u32 (tb[DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER ]));pr_out_port_handle_end (dl); }
include/uapi/linux/devlink.h +2 -0
@@ -235,6 +235,8 @@ enum devlink_attr {DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS ,/* u64 */ DEVLINK_ATTR_PORT_FLAVOUR ,/* u16 */ +DEVLINK_ATTR_PORT_NUMBER ,/* u32 */ + DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, /* u32 *//* add new attributes above here, update the policy in devlink.c */
Signature · 1 line
2.14.3
Re: [patch iproute2/net-next 2/2] devlink: introduce support for showing port number and split subport number
Quoted 13 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Signed-off-by Jiri Pirko <[email protected]>--- devlink/devlink.c | 6 ++++++ include/uapi/linux/devlink.h | 2 ++ 2 files changed, 8 insertions(+)devlink/devlink.c +0
-0
devlink/devlink.c static void pr_out_port(struct dl *dl, struct nlattr **tb) · line 1742
Quoted 6 lines
devlink/devlink.c +3
-0@@ -1737,9 +1737,15 @@ 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 ]) +pr_out_uint (dl,"number" , +mnl_attr_get_u32 (tb[DEVLINK_ATTR_PORT_NUMBER ]));
"number" is a label means nothing. "port" is more descriptive.
# ./devlink port pci/0000:03:00.0/1: type eth netdev swp17 flavour physical number 17 pci/0000:03:00.0/3: type eth netdev swp18 flavour physical number 18 pci/0000:03:00.0/5: type eth netdev swp19 flavour physical number 19 pci/0000:03:00.0/7: type eth netdev swp20 flavour physical number 20 pci/0000:03:00.0/9: type eth netdev swp21 flavour physical number 21 ... pci/0000:03:00.0/61: type eth netdev swp1s0 flavour physical number 1 split_group 1 subport 0 pci/0000:03:00.0/62: type eth netdev swp1s1 flavour physical number 1 split_group 1 subport 1
Jiri Pirko
maintainerRe: [patch iproute2/net-next 2/2] devlink: introduce support for showing port number and split subport number
Quoted 15 lines · Wed, May 23, 2018 at 10:05:49PM CEST, [email protected] wrote:
Quoted 14 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Signed-off-by Jiri Pirko <[email protected]>--- devlink/devlink.c | 6 ++++++ include/uapi/linux/devlink.h | 2 ++ 2 files changed, 8 insertions(+)devlink/devlink.c +0
-0@@ -1737,9 +1737,15 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
Quoted 7 lines
devlink/devlink.c static void pr_out_port(struct dl *dl, struct nlattr **tb) · line 1742
Quoted 5 lines
devlink/devlink.c +3
-0pr_out_str (dl,"flavour" ,port_flavour_name (port_flavour)); } +if (tb[DEVLINK_ATTR_PORT_NUMBER ]) +pr_out_uint (dl,"number" , +mnl_attr_get_u32 (tb[DEVLINK_ATTR_PORT_NUMBER ]));"number" is a label means nothing. "port" is more descriptive.
That attribute name is "port_number". As the other attributes are named "port_something", and the "something" is printed out here, the "number" is consistent with it. Each line represents a port with a list of attributes.
Quoted 13 lines
# ./devlink port pci/0000:03:00.0/1: type eth netdev swp17 flavour physical number 17 pci/0000:03:00.0/3: type eth netdev swp18 flavour physical number 18 pci/0000:03:00.0/5: type eth netdev swp19 flavour physical number 19 pci/0000:03:00.0/7: type eth netdev swp20 flavour physical number 20 pci/0000:03:00.0/9: type eth netdev swp21 flavour physical number 21 ... pci/0000:03:00.0/61: type eth netdev swp1s0 flavour physical number 1 split_group 1 subport 0 pci/0000:03:00.0/62: type eth netdev swp1s1 flavour physical number 1 split_group 1 subport 1
Re: [patch iproute2/net-next 2/2] devlink: introduce support for showing port number and split subport number
Quoted 24 lines · Jiri Pirko
Quoted 15 lines · Wed, May 23, 2018 at 10:05:49PM CEST, [email protected] wrote:
Quoted 14 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Signed-off-by Jiri Pirko <[email protected]>--- devlink/devlink.c | 6 ++++++ include/uapi/linux/devlink.h | 2 ++ 2 files changed, 8 insertions(+)devlink/devlink.c +0
-0@@ -1737,9 +1737,15 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)Quoted 7 lines
devlink/devlink.c static void pr_out_port(struct dl *dl, struct nlattr **tb) · line 1742
Quoted 5 lines
devlink/devlink.c +3
-0pr_out_str (dl,"flavour" ,port_flavour_name (port_flavour)); } +if (tb[DEVLINK_ATTR_PORT_NUMBER ]) +pr_out_uint (dl,"number" , +mnl_attr_get_u32 (tb[DEVLINK_ATTR_PORT_NUMBER ]));"number" is a label means nothing. "port" is more descriptive.
Quoted 4 lines
That attribute name is "
port_number". As the other attributes are named "port_something", and the "something" is printed out here, the "number" is consistent with it. Each line represents a port with a list of attributes.
The name of the attribute is not relevant here. That's an API that very few people will see. I am looking at this from a user perspective and the word "number" followed by a number is not clear.
Quoted 14 lines
Quoted 14 lines
# ./devlink port pci/0000:03:00.0/1: type eth netdev swp17 flavour physical number 17 pci/0000:03:00.0/3: type eth netdev swp18 flavour physical number 18 pci/0000:03:00.0/5: type eth netdev swp19 flavour physical number 19 pci/0000:03:00.0/7: type eth netdev swp20 flavour physical number 20 pci/0000:03:00.0/9: type eth netdev swp21 flavour physical number 21 ... pci/0000:03:00.0/61: type eth netdev swp1s0 flavour physical number 1 split_group 1 subport 0 pci/0000:03:00.0/62: type eth netdev swp1s1 flavour physical number 1 split_group 1 subport 1