diff mbox series

[iproute2-next] ip link: Add support to get SR-IOV VF node GUID and port GUID

Message ID 20191114133126.238128-2-leon@kernel.org
State Changes Requested
Delegated to: stephen hemminger
Headers show
Series [iproute2-next] ip link: Add support to get SR-IOV VF node GUID and port GUID | expand

Commit Message

Leon Romanovsky Nov. 14, 2019, 1:31 p.m. UTC
From: Danit Goldberg <danitg@mellanox.com>

Extend iplink to show VF GUIDs (IFLA_VF_IB_NODE_GUID, IFLA_VF_IB_PORT_GUID),
giving the ability for user-space application to print GUID values.
This ability is added to the one of setting new node GUID and port GUID values.

Suitable ip link command:
- ip link show <device>

For example:
- ip link set ib4 vf 0 node_guid 22:44:33:00:33:11:00:33
- ip link set ib4 vf 0 port_guid 10:21:33:12:00:11:22:10
- ip link show ib4
ib4: <BROADCAST,MULTICAST> mtu 4092 qdisc noop state DOWN mode DEFAULT group default qlen 256
link/infiniband 00:00:0a:2d:fe:80:00:00:00:00:00:00:ec:0d:9a:03:00:44:36:8d brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff
vf 0     link/infiniband 00:00:0a:2d:fe:80:00:00:00:00:00:00:ec:0d:9a:03:00:44:36:8d brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff,
spoof checking off, NODE_GUID 22:44:33:00:33:11:00:33, PORT_GUID 10:21:33:12:00:11:22:10, link-state disable, trust off, query_rss off

Signed-off-by: Danit Goldberg <danitg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 ip/ipaddress.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

David Ahern Nov. 14, 2019, 8:35 p.m. UTC | #1
On 11/14/19 6:31 AM, Leon Romanovsky wrote:
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index b72eb7a1..ed72d0bd 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -484,6 +484,29 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
>  				   vf_spoofchk->setting);
>  	}
>  
> +#define GUID_STR_LEN 24
> +	if (vf[IFLA_VF_IB_NODE_GUID]) {
> +		char buf[GUID_STR_LEN];

buf should be declared with SPRINT_BUF; see other users of ll_addr_n2a.
And, print_vfinfo already has b1 declared so you do not need a new one;
just change buf to b1.


> +		struct ifla_vf_guid *guid = RTA_DATA(vf[IFLA_VF_IB_NODE_GUID]);
> +		uint64_t node_guid = ntohll(guid->guid);
> +
> +		print_string(PRINT_ANY, "node guid", ", NODE_GUID %s",
> +				ll_addr_n2a((const unsigned char *)&node_guid,
> +					 RTA_PAYLOAD(vf[IFLA_VF_IB_NODE_GUID]),
> +					 ARPHRD_INFINIBAND,
> +					 buf, sizeof(buf)));
> +	}
> +	if (vf[IFLA_VF_IB_PORT_GUID]) {
> +		char buf[GUID_STR_LEN];
> +		struct ifla_vf_guid *guid = RTA_DATA(vf[IFLA_VF_IB_PORT_GUID]);
> +		uint64_t port_guid = ntohll(guid->guid);
> +
> +		print_string(PRINT_ANY, "port guid", ", PORT_GUID %s",
> +				ll_addr_n2a((const unsigned char *)&port_guid,
> +					 RTA_PAYLOAD(vf[IFLA_VF_IB_PORT_GUID]),
> +					 ARPHRD_INFINIBAND,
> +					 buf, sizeof(buf)));
> +	}
>  	if (vf[IFLA_VF_LINK_STATE]) {
>  		struct ifla_vf_link_state *vf_linkstate =
>  			RTA_DATA(vf[IFLA_VF_LINK_STATE]);
>
Leon Romanovsky Nov. 15, 2019, 3:24 p.m. UTC | #2
On Thu, Nov 14, 2019 at 01:35:11PM -0700, David Ahern wrote:
> On 11/14/19 6:31 AM, Leon Romanovsky wrote:
> > diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> > index b72eb7a1..ed72d0bd 100644
> > --- a/ip/ipaddress.c
> > +++ b/ip/ipaddress.c
> > @@ -484,6 +484,29 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
> >  				   vf_spoofchk->setting);
> >  	}
> >
> > +#define GUID_STR_LEN 24
> > +	if (vf[IFLA_VF_IB_NODE_GUID]) {
> > +		char buf[GUID_STR_LEN];
>
> buf should be declared with SPRINT_BUF; see other users of ll_addr_n2a.
> And, print_vfinfo already has b1 declared so you do not need a new one;
> just change buf to b1.

Thanks, I posted v1.
https://lore.kernel.org/linux-rdma/20191115152155.246821-1-leon@kernel.org
diff mbox series

Patch

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index b72eb7a1..ed72d0bd 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -484,6 +484,29 @@  static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
 				   vf_spoofchk->setting);
 	}
 
+#define GUID_STR_LEN 24
+	if (vf[IFLA_VF_IB_NODE_GUID]) {
+		char buf[GUID_STR_LEN];
+		struct ifla_vf_guid *guid = RTA_DATA(vf[IFLA_VF_IB_NODE_GUID]);
+		uint64_t node_guid = ntohll(guid->guid);
+
+		print_string(PRINT_ANY, "node guid", ", NODE_GUID %s",
+				ll_addr_n2a((const unsigned char *)&node_guid,
+					 RTA_PAYLOAD(vf[IFLA_VF_IB_NODE_GUID]),
+					 ARPHRD_INFINIBAND,
+					 buf, sizeof(buf)));
+	}
+	if (vf[IFLA_VF_IB_PORT_GUID]) {
+		char buf[GUID_STR_LEN];
+		struct ifla_vf_guid *guid = RTA_DATA(vf[IFLA_VF_IB_PORT_GUID]);
+		uint64_t port_guid = ntohll(guid->guid);
+
+		print_string(PRINT_ANY, "port guid", ", PORT_GUID %s",
+				ll_addr_n2a((const unsigned char *)&port_guid,
+					 RTA_PAYLOAD(vf[IFLA_VF_IB_PORT_GUID]),
+					 ARPHRD_INFINIBAND,
+					 buf, sizeof(buf)));
+	}
 	if (vf[IFLA_VF_LINK_STATE]) {
 		struct ifla_vf_link_state *vf_linkstate =
 			RTA_DATA(vf[IFLA_VF_LINK_STATE]);