lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190701182738.24763-1-parav@mellanox.com>
Date:   Mon,  1 Jul 2019 13:27:38 -0500
From:   Parav Pandit <parav@...lanox.com>
To:     netdev@...r.kernel.org
Cc:     saeedm@...lanox.com, jakub.kicinski@...ronome.com,
        jiri@...lanox.com, Parav Pandit <parav@...lanox.com>
Subject: [PATCH] devlink: Introduce PCI PF and VF port flavour and attribute

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

Acked-by: Jiri Pirko <jiri@...lanox.com>
Signed-off-by: Parav Pandit <parav@...lanox.com>
---
 devlink/devlink.c            | 23 +++++++++++++++++++++++
 include/uapi/linux/devlink.h | 11 +++++++++++
 2 files changed, 34 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 559f624e..15493426 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -2771,6 +2771,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 "pcipf";
+	case DEVLINK_PORT_FLAVOUR_PCI_VF:
+		return "pcivf";
 	default:
 		return "<unknown flavour>";
 	}
@@ -2803,8 +2807,27 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
 	if (tb[DEVLINK_ATTR_PORT_FLAVOUR]) {
 		uint16_t port_flavour =
 				mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_FLAVOUR]);
+		uint16_t pf_vf;
 
 		pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
+		if (port_flavour == DEVLINK_PORT_FLAVOUR_PCI_PF) {
+			if (tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]) {
+				pf_vf = mnl_attr_get_u16(
+					tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]);
+				pr_out_uint(dl, "pfnum", pf_vf);
+			}
+		} else if (port_flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) {
+			if (tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]) {
+				pf_vf = mnl_attr_get_u16(
+					tb[DEVLINK_ATTR_PORT_PCI_PF_NUMBER]);
+				pr_out_uint(dl, "pfnum", pf_vf);
+			}
+			if (tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]) {
+				pf_vf = mnl_attr_get_u16(
+					tb[DEVLINK_ATTR_PORT_PCI_VF_NUMBER]);
+				pr_out_uint(dl, "vfnum", pf_vf);
+			}
+		}
 	}
 	if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
 		pr_out_uint(dl, "split_group",
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 6544824a..fc195cbd 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -169,6 +169,14 @@ enum devlink_port_flavour {
 	DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture
 				   * interconnect port.
 				   */
+	DEVLINK_PORT_FLAVOUR_PCI_PF, /* Represents eswitch port for
+				      * the PCI PF. It is an internal
+				      * port that faces the PCI PF.
+				      */
+	DEVLINK_PORT_FLAVOUR_PCI_VF, /* Represents eswitch port
+				      * for the PCI VF. It is an internal
+				      * port that faces the PCI VF.
+				      */
 };
 
 enum devlink_param_cmode {
@@ -337,6 +345,9 @@ enum devlink_attr {
 	DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE,	/* u64 */
 	DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL,	/* u64 */
 
+	DEVLINK_ATTR_PORT_PCI_PF_NUMBER,	/* u16 */
+	DEVLINK_ATTR_PORT_PCI_VF_NUMBER,	/* u16 */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
-- 
2.19.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ