]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: Introduce PCI PF and VF port flavour and attribute
authorParav Pandit <parav@mellanox.com>
Wed, 10 Jul 2019 12:39:52 +0000 (07:39 -0500)
committerDavid Ahern <dsahern@gmail.com>
Wed, 10 Jul 2019 20:57:19 +0000 (13:57 -0700)
Introduce PCI PF and VF port flavour and port attributes such as PF
number and VF number.

$ devlink port show
pci/0000:05:00.0/0: type eth netdev eth0 flavour pcipf pfnum 0
pci/0000:05:00.0/1: type eth netdev eth1 flavour pcivf pfnum 0 vfnum 0
pci/0000:05:00.0/2: type eth netdev eth2 flavour pcivf pfnum 0 vfnum 1

Signed-off-by: Parav Pandit <parav@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
devlink/devlink.c

index ac8c0fb149b6d2cfddf4a0481ef0856591762eb3..d8197ea3a478d1f5b870696279619df6868ffa90 100644 (file)
@@ -2794,11 +2794,29 @@ static const char *port_flavour_name(uint16_t flavour)
                return "cpu";
        case DEVLINK_PORT_FLAVOUR_DSA:
                return "dsa";
+       case DEVLINK_PORT_FLAVOUR_PCI_PF:
+               return "pcipf";
+       case DEVLINK_PORT_FLAVOUR_PCI_VF:
+               return "pcivf";
        default:
                return "<unknown flavour>";
        }
 }
 
+static void pr_out_port_pfvf_num(struct dl *dl, struct nlattr **tb)
+{
+       uint16_t fn_num;
+
+       if (tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]) {
+               fn_num = mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]);
+               pr_out_uint(dl, "pfnum", fn_num);
+       }
+       if (tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]) {
+               fn_num = mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]);
+               pr_out_uint(dl, "vfnum", fn_num);
+       }
+}
+
 static void pr_out_port(struct dl *dl, struct nlattr **tb)
 {
        struct nlattr *pt_attr = tb[DEVLINK_ATTR_PORT_TYPE];
@@ -2828,6 +2846,15 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
                                mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_FLAVOUR]);
 
                pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
+
+               switch (port_flavour) {
+               case DEVLINK_PORT_FLAVOUR_PCI_PF:
+               case DEVLINK_PORT_FLAVOUR_PCI_VF:
+                       pr_out_port_pfvf_num(dl, tb);
+                       break;
+               default:
+                       break;
+               }
        }
        if (tb[DEVLINK_ATTR_PORT_NUMBER]) {
                uint32_t port_number;