All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC iproute2-next 0/3] devlink: expose PF and VF representors as ports
@ 2019-03-01 18:35 Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 1/3] devlink: add support for PCIe port flavours Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-03-01 18:35 UTC (permalink / raw)
  To: jiri; +Cc: netdev, oss-drivers, Jakub Kicinski

Hi,

This set adds support for move port flavours, PCI subports and
port peers.

Example output after the series:

$ devlink port
pci/0000:05:00.0/0: type eth netdev enp5s0np0 flavour physical
pci/0000:05:00.0/10000: type eth netdev enp5s0npf0s0 flavour pci_pf pf 0 subport 0 peer_netdev enp5s0nn0
pci/0000:05:00.0/4: type eth netdev enp5s0np1 flavour physical
pci/0000:05:00.0/11000: type eth netdev enp5s0npf0s1 flavour pci_pf pf 0 subport 1 peer_netdev enp5s0nn1
 
Jakub Kicinski (3):
  devlink: add support for PCIe port flavours
  devlink: add support for PCIe subports
  devlink: add support for PCIe device peers

 devlink/devlink.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

-- 
2.19.2


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

* [RFC iproute2-next 1/3] devlink: add support for PCIe port flavours
  2019-03-01 18:35 [RFC iproute2-next 0/3] devlink: expose PF and VF representors as ports Jakub Kicinski
@ 2019-03-01 18:35 ` Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 2/3] devlink: add support for PCIe subports Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 3/3] devlink: add support for PCIe device peers Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-03-01 18:35 UTC (permalink / raw)
  To: jiri; +Cc: netdev, oss-drivers, Jakub Kicinski

Add support for decoding PCIe port flavours.  Example:

$ devlink port
pci/0000:82:00.0/0: type eth netdev p4p1 flavour physical
pci/0000:82:00.0/10000: type eth netdev eth0 flavour pcie_pf pf 0
pci/0000:82:00.0/10001: type eth netdev eth1 flavour pcie_vf pf 0 vf 0
pci/0000:82:00.0/10002: type eth netdev eth2 flavour pcie_vf pf 0 vf 1

$ devlink -jp port
{
    "port": {
        "pci/0000:82:00.0/0": {
            "type": "eth",
            "netdev": "p4p1",
            "flavour": "physical"
        },
        "pci/0000:82:00.0/10000": {
            "type": "eth",
            "netdev": "eth0",
            "flavour": "pci_pf",
            "pf": 0,
        },
        "pci/0000:82:00.0/10001": {
            "type": "eth",
            "netdev": "eth1",
            "flavour": "pci_vf",
            "pf": 0,
            "vf": 0
        },
        "pci/0000:82:00.0/10002": {
            "type": "eth",
            "netdev": "eth2",
            "flavour": "pci_vf",
            "pf": 0,
            "vf": 1
        }
    }
}

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 devlink/devlink.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index dc6e73fec20c..055b09808226 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -414,6 +414,8 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT] = MNL_TYPE_U64,
 	[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS] = MNL_TYPE_U64,
 	[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD] = MNL_TYPE_U64,
+	[DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = MNL_TYPE_U32,
+	[DEVLINK_ATTR_PORT_PCI_VF_NUMBER] = MNL_TYPE_U32,
 };
 
 static int attr_cb(const struct nlattr *attr, void *data)
@@ -2771,6 +2773,10 @@ 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 "pci_pf";
+	case DEVLINK_PORT_FLAVOUR_PCI_VF:
+		return "pci_vf";
 	default:
 		return "<unknown flavour>";
 	}
@@ -2809,6 +2815,13 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
 	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_PCI_PF_NUMBER])
+		pr_out_uint(dl, "pf",
+			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]));
+	if (tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER])
+		pr_out_uint(dl, "vf",
+			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]));
+
 	pr_out_port_handle_end(dl);
 }
 
-- 
2.19.2


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

* [RFC iproute2-next 2/3] devlink: add support for PCIe subports
  2019-03-01 18:35 [RFC iproute2-next 0/3] devlink: expose PF and VF representors as ports Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 1/3] devlink: add support for PCIe port flavours Jakub Kicinski
@ 2019-03-01 18:35 ` Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 3/3] devlink: add support for PCIe device peers Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-03-01 18:35 UTC (permalink / raw)
  To: jiri; +Cc: netdev, oss-drivers, Jakub Kicinski

Add support for reporting PCIe subports.  Example (bus 05 device has
subports, bus 82 has only one port per function):

$ devlink port
pci/0000:05:00.0/0: type eth netdev enp5s0np0 flavour physical
pci/0000:05:00.0/10000: type eth netdev enp5s0npf0s0 flavour pci_pf pf 0 subport 0
pci/0000:05:00.0/4: type eth netdev enp5s0np1 flavour physical
pci/0000:05:00.0/11000: type eth netdev enp5s0npf0s1 flavour pci_pf pf 0 subport 1
pci/0000:82:00.0/0: type eth netdev p4p1 flavour physical
pci/0000:82:00.0/10000: type eth netdev eth0 flavour pci_pf pf 0

$ devlink -jp port
{
    "port": {
        "pci/0000:05:00.0/0": {
            "type": "eth",
            "netdev": "enp5s0np0",
            "flavour": "physical"
        },
        "pci/0000:05:00.0/10000": {
            "type": "eth",
            "netdev": "enp5s0npf0s0",
            "flavour": "pci_pf",
            "pf": 0,
            "subport": 0
        },
        "pci/0000:05:00.0/4": {
            "type": "eth",
            "netdev": "enp5s0np1",
            "flavour": "physical"
        },
        "pci/0000:05:00.0/11000": {
            "type": "eth",
            "netdev": "enp5s0npf0s1",
            "flavour": "pci_pf",
            "pf": 0,
            "subport": 1
        },
        "pci/0000:82:00.0/0": {
            "type": "eth",
            "netdev": "p4p1",
            "flavour": "physical"
        },
        "pci/0000:82:00.0/10000": {
            "type": "eth",
            "netdev": "eth0",
            "flavour": "pci_pf",
            "pf": 0
        }
    }
}

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 devlink/devlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 055b09808226..c130305b94ff 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -416,6 +416,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD] = MNL_TYPE_U64,
 	[DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = MNL_TYPE_U32,
 	[DEVLINK_ATTR_PORT_PCI_VF_NUMBER] = MNL_TYPE_U32,
+	[DEVLINK_ATTR_PORT_PCI_SUBPORT] = MNL_TYPE_U32,
 };
 
 static int attr_cb(const struct nlattr *attr, void *data)
@@ -2821,7 +2822,9 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
 	if (tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER])
 		pr_out_uint(dl, "vf",
 			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]));
-
+	if (tb[DEVLINK_ATTR_PORT_PCI_SUBPORT])
+		pr_out_uint(dl, "subport",
+			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_PCI_SUBPORT]));
 	pr_out_port_handle_end(dl);
 }
 
-- 
2.19.2


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

* [RFC iproute2-next 3/3] devlink: add support for PCIe device peers
  2019-03-01 18:35 [RFC iproute2-next 0/3] devlink: expose PF and VF representors as ports Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 1/3] devlink: add support for PCIe port flavours Jakub Kicinski
  2019-03-01 18:35 ` [RFC iproute2-next 2/3] devlink: add support for PCIe subports Jakub Kicinski
@ 2019-03-01 18:35 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-03-01 18:35 UTC (permalink / raw)
  To: jiri; +Cc: netdev, oss-drivers, Jakub Kicinski

Print peer netdev information.

$ devlink port
pci/0000:82:00.0/0: type eth netdev p4p1 flavour physical
pci/0000:82:00.0/10000: type eth netdev eth1 flavour pci_pf pf 0 peer_netdev enp130s0

$ devlink -jp port
{
    "port": {
        "pci/0000:82:00.0/0": {
            "type": "eth",
            "netdev": "p4p1",
            "flavour": "physical"
        },
        "pci/0000:82:00.0/10000": {
            "type": "eth",
            "netdev": "eth1",
            "flavour": "pci_pf",
            "pf": 0,
            "peer": {
                "netdev": "enp130s0"
	    }
        }
    }
}

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 devlink/devlink.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index c130305b94ff..e4b66aa28f71 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -417,6 +417,8 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = MNL_TYPE_U32,
 	[DEVLINK_ATTR_PORT_PCI_VF_NUMBER] = MNL_TYPE_U32,
 	[DEVLINK_ATTR_PORT_PCI_SUBPORT] = MNL_TYPE_U32,
+	[DEVLINK_ATTR_PORT_PEER_NETDEV_NAME] = MNL_TYPE_STRING,
+	[DEVLINK_ATTR_PORT_PEER_IBDEV_NAME] = MNL_TYPE_STRING,
 };
 
 static int attr_cb(const struct nlattr *attr, void *data)
@@ -2783,6 +2785,36 @@ static const char *port_flavour_name(uint16_t flavour)
 	}
 }
 
+static void pr_out_port_peer(struct dl *dl, struct nlattr *peer)
+{
+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+	const char *netdev = NULL, *ibdev = NULL;
+
+	mnl_attr_parse_nested(peer, attr_cb, tb);
+
+	if (tb[DEVLINK_ATTR_PORT_PEER_NETDEV_NAME])
+		netdev = mnl_attr_get_str(tb[DEVLINK_ATTR_PORT_PEER_NETDEV_NAME]);
+	if (tb[DEVLINK_ATTR_PORT_PEER_IBDEV_NAME])
+		ibdev = mnl_attr_get_str(tb[DEVLINK_ATTR_PORT_PEER_IBDEV_NAME]);
+
+	if (dl->jw) {
+		jsonw_name(dl->jw, "peer");
+		jsonw_start_object(dl->jw);
+
+		if (netdev)
+			pr_out_str(dl, "netdev", netdev);
+		if (ibdev)
+			pr_out_str(dl, "ibdev", ibdev);
+
+		jsonw_end_object(dl->jw);
+	} else {
+		if (netdev)
+			pr_out_str(dl, "peer_netdev", netdev);
+		if (ibdev)
+			pr_out_str(dl, "peer_ibdev", ibdev);
+	}
+}
+
 static void pr_out_port(struct dl *dl, struct nlattr **tb)
 {
 	struct nlattr *pt_attr = tb[DEVLINK_ATTR_PORT_TYPE];
@@ -2825,6 +2857,8 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
 	if (tb[DEVLINK_ATTR_PORT_PCI_SUBPORT])
 		pr_out_uint(dl, "subport",
 			    mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_PCI_SUBPORT]));
+	if (tb[DEVLINK_ATTR_PORT_PEER])
+		pr_out_port_peer(dl, tb[DEVLINK_ATTR_PORT_PEER]);
 	pr_out_port_handle_end(dl);
 }
 
-- 
2.19.2


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 18:35 [RFC iproute2-next 0/3] devlink: expose PF and VF representors as ports Jakub Kicinski
2019-03-01 18:35 ` [RFC iproute2-next 1/3] devlink: add support for PCIe port flavours Jakub Kicinski
2019-03-01 18:35 ` [RFC iproute2-next 2/3] devlink: add support for PCIe subports Jakub Kicinski
2019-03-01 18:35 ` [RFC iproute2-next 3/3] devlink: add support for PCIe device peers Jakub Kicinski

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.