public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] infiniband-diags/ibnetdiscover.c: Changes for extended link speeds
@ 2011-08-16 13:44 Hal Rosenstock
       [not found] ` <4E4A744C.8060008-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Hal Rosenstock @ 2011-08-16 13:44 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org


Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
diff --git a/src/ibnetdiscover.c b/src/ibnetdiscover.c
index 59304b6..0966217 100644
--- a/src/ibnetdiscover.c
+++ b/src/ibnetdiscover.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2004-2009 Voltaire Inc.  All rights reserved.
  * Copyright (c) 2007 Xsigo Systems Inc.  All rights reserved.
  * Copyright (c) 2008 Lawrence Livermore National Lab.  All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -99,6 +100,22 @@ char *dump_linkspeed_compat(uint32_t speed)
 	return ("???");
 }
 
+char *dump_linkspeedext_compat(uint32_t espeed, uint32_t speed)
+{
+	switch (espeed) {
+	case 0:
+		return dump_linkspeed_compat(speed);
+		break;
+	case 1:
+		return ("FDR");
+		break;
+	case 2:
+		return ("EDR");
+		break;
+	}
+	return ("???");
+}
+
 char *dump_linkwidth_compat(uint32_t width)
 {
 	switch (width) {
@@ -341,6 +358,7 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
 					IB_PORT_LINK_WIDTH_ACTIVE_F);
 	uint32_t ispeed = mad_get_field(port->info, 0,
 					IB_PORT_LINK_SPEED_ACTIVE_F);
+	uint32_t cap_mask, espeed;
 
 	DEBUG("port %p:%d remoteport %p\n", port, port->portnum,
 	      port->remoteport);
@@ -355,6 +373,13 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
 				       port->remoteport->node->nodedesc);
 
 	ext_port_str = out_ext_port(port->remoteport, group);
+	cap_mask = mad_get_field(port->node->ports[0]->info, 0,
+				 IB_PORT_CAPMASK_F);
+	if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
+		espeed = mad_get_field(port->info, 0,
+				       IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+	else
+		espeed = 0;
 	fprintf(f, "\t%s[%d]%s",
 		node_name(port->remoteport->node), port->remoteport->portnum,
 		ext_port_str ? ext_port_str : "");
@@ -365,7 +390,10 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
 		port->remoteport->node->type == IB_NODE_SWITCH ?
 		port->remoteport->node->smalid :
 		port->remoteport->base_lid,
-		dump_linkwidth_compat(iwidth), dump_linkspeed_compat(ispeed));
+		dump_linkwidth_compat(iwidth),
+		(ispeed != 4 && !espeed) ?
+			dump_linkspeed_compat(ispeed) :
+			dump_linkspeedext_compat(espeed, ispeed));
 
 	if (full_info)
 		fprintf(f, " s=%d w=%d", ispeed, iwidth);
@@ -387,6 +415,7 @@ void out_ca_port(ibnd_port_t * port, int group, char *out_prefix)
 					IB_PORT_LINK_WIDTH_ACTIVE_F);
 	uint32_t ispeed = mad_get_field(port->info, 0,
 					IB_PORT_LINK_SPEED_ACTIVE_F);
+	uint32_t cap_mask, espeed;
 
 	fprintf(f, "%s[%d]", out_prefix ? out_prefix : "", port->portnum);
 	if (port->node->type != IB_NODE_SWITCH)
@@ -403,12 +432,22 @@ void out_ca_port(ibnd_port_t * port, int group, char *out_prefix)
 				       port->remoteport->node->guid,
 				       port->remoteport->node->nodedesc);
 
+	cap_mask = mad_get_field(port->info, 0, IB_PORT_CAPMASK_F);
+	if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
+		espeed = mad_get_field(port->info, 0,
+				       IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+	else
+		espeed = 0;
+
 	fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s",
 		port->base_lid, port->lmc, rem_nodename,
 		port->remoteport->node->type == IB_NODE_SWITCH ?
 		port->remoteport->node->smalid :
 		port->remoteport->base_lid,
-		dump_linkwidth_compat(iwidth), dump_linkspeed_compat(ispeed));
+		dump_linkwidth_compat(iwidth),
+		(ispeed != 4 && !espeed) ?
+			dump_linkspeed_compat(ispeed) :
+			dump_linkspeedext_compat(espeed, ispeed));
 
 	if (full_info)
 		fprintf(f, " s=%d w=%d", ispeed, iwidth);
@@ -632,13 +671,24 @@ void dump_ports_report(ibnd_node_t * node, void *user_data)
 	/* for each port */
 	for (p = node->numports, port = node->ports[p]; p > 0;
 	     port = node->ports[--p]) {
-		uint32_t iwidth, ispeed;
+		uint32_t iwidth, ispeed, espeed, cap_mask;
+		uint8_t *info;
 		if (port == NULL)
 			continue;
 		iwidth =
 		    mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
 		ispeed =
 		    mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
+		if (port->node->type == IB_NODE_SWITCH)
+			info = (uint8_t *)&port->node->ports[0]->info;
+		else
+			info = (uint8_t *)&port->info;
+		cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+		if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
+			espeed = mad_get_field(port->info, 0,
+					       IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+		else
+			espeed = 0;
 		nodename = remap_node_name(node_name_map,
 					   port->node->guid,
 					   port->node->nodedesc);
@@ -648,7 +698,9 @@ void dump_ports_report(ibnd_node_t * node, void *user_data)
 			IB_NODE_SWITCH ? node->smalid : port->base_lid,
 			port->portnum, port->guid,
 			dump_linkwidth_compat(iwidth),
-			dump_linkspeed_compat(ispeed));
+			(ispeed != 4 && !espeed) ?
+				dump_linkspeed_compat(ispeed) :
+				dump_linkspeedext_compat(espeed, ispeed));
 		if (port->remoteport) {
 			rem_nodename = remap_node_name(node_name_map,
 					      port->remoteport->node->guid,
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] infiniband-diags/ibnetdiscover.c: Changes for extended link speeds
       [not found] ` <4E4A744C.8060008-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2011-08-18 18:23   ` Ira Weiny
  0 siblings, 0 replies; 2+ messages in thread
From: Ira Weiny @ 2011-08-18 18:23 UTC (permalink / raw)
  To: Hal Rosenstock; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Tue, 16 Aug 2011 06:44:44 -0700
Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org> wrote:

> 
> Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Thanks applied,
Ira

> ---
> diff --git a/src/ibnetdiscover.c b/src/ibnetdiscover.c
> index 59304b6..0966217 100644
> --- a/src/ibnetdiscover.c
> +++ b/src/ibnetdiscover.c
> @@ -2,6 +2,7 @@
>   * Copyright (c) 2004-2009 Voltaire Inc.  All rights reserved.
>   * Copyright (c) 2007 Xsigo Systems Inc.  All rights reserved.
>   * Copyright (c) 2008 Lawrence Livermore National Lab.  All rights reserved.
> + * Copyright (c) 2010,2011 Mellanox Technologies LTD.  All rights reserved.
>   *
>   * This software is available to you under a choice of one of two
>   * licenses.  You may choose to be licensed under the terms of the GNU
> @@ -99,6 +100,22 @@ char *dump_linkspeed_compat(uint32_t speed)
>  	return ("???");
>  }
>  
> +char *dump_linkspeedext_compat(uint32_t espeed, uint32_t speed)
> +{
> +	switch (espeed) {
> +	case 0:
> +		return dump_linkspeed_compat(speed);
> +		break;
> +	case 1:
> +		return ("FDR");
> +		break;
> +	case 2:
> +		return ("EDR");
> +		break;
> +	}
> +	return ("???");
> +}
> +
>  char *dump_linkwidth_compat(uint32_t width)
>  {
>  	switch (width) {
> @@ -341,6 +358,7 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
>  					IB_PORT_LINK_WIDTH_ACTIVE_F);
>  	uint32_t ispeed = mad_get_field(port->info, 0,
>  					IB_PORT_LINK_SPEED_ACTIVE_F);
> +	uint32_t cap_mask, espeed;
>  
>  	DEBUG("port %p:%d remoteport %p\n", port, port->portnum,
>  	      port->remoteport);
> @@ -355,6 +373,13 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
>  				       port->remoteport->node->nodedesc);
>  
>  	ext_port_str = out_ext_port(port->remoteport, group);
> +	cap_mask = mad_get_field(port->node->ports[0]->info, 0,
> +				 IB_PORT_CAPMASK_F);
> +	if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
> +		espeed = mad_get_field(port->info, 0,
> +				       IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
> +	else
> +		espeed = 0;
>  	fprintf(f, "\t%s[%d]%s",
>  		node_name(port->remoteport->node), port->remoteport->portnum,
>  		ext_port_str ? ext_port_str : "");
> @@ -365,7 +390,10 @@ void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
>  		port->remoteport->node->type == IB_NODE_SWITCH ?
>  		port->remoteport->node->smalid :
>  		port->remoteport->base_lid,
> -		dump_linkwidth_compat(iwidth), dump_linkspeed_compat(ispeed));
> +		dump_linkwidth_compat(iwidth),
> +		(ispeed != 4 && !espeed) ?
> +			dump_linkspeed_compat(ispeed) :
> +			dump_linkspeedext_compat(espeed, ispeed));
>  
>  	if (full_info)
>  		fprintf(f, " s=%d w=%d", ispeed, iwidth);
> @@ -387,6 +415,7 @@ void out_ca_port(ibnd_port_t * port, int group, char *out_prefix)
>  					IB_PORT_LINK_WIDTH_ACTIVE_F);
>  	uint32_t ispeed = mad_get_field(port->info, 0,
>  					IB_PORT_LINK_SPEED_ACTIVE_F);
> +	uint32_t cap_mask, espeed;
>  
>  	fprintf(f, "%s[%d]", out_prefix ? out_prefix : "", port->portnum);
>  	if (port->node->type != IB_NODE_SWITCH)
> @@ -403,12 +432,22 @@ void out_ca_port(ibnd_port_t * port, int group, char *out_prefix)
>  				       port->remoteport->node->guid,
>  				       port->remoteport->node->nodedesc);
>  
> +	cap_mask = mad_get_field(port->info, 0, IB_PORT_CAPMASK_F);
> +	if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
> +		espeed = mad_get_field(port->info, 0,
> +				       IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
> +	else
> +		espeed = 0;
> +
>  	fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s",
>  		port->base_lid, port->lmc, rem_nodename,
>  		port->remoteport->node->type == IB_NODE_SWITCH ?
>  		port->remoteport->node->smalid :
>  		port->remoteport->base_lid,
> -		dump_linkwidth_compat(iwidth), dump_linkspeed_compat(ispeed));
> +		dump_linkwidth_compat(iwidth),
> +		(ispeed != 4 && !espeed) ?
> +			dump_linkspeed_compat(ispeed) :
> +			dump_linkspeedext_compat(espeed, ispeed));
>  
>  	if (full_info)
>  		fprintf(f, " s=%d w=%d", ispeed, iwidth);
> @@ -632,13 +671,24 @@ void dump_ports_report(ibnd_node_t * node, void *user_data)
>  	/* for each port */
>  	for (p = node->numports, port = node->ports[p]; p > 0;
>  	     port = node->ports[--p]) {
> -		uint32_t iwidth, ispeed;
> +		uint32_t iwidth, ispeed, espeed, cap_mask;
> +		uint8_t *info;
>  		if (port == NULL)
>  			continue;
>  		iwidth =
>  		    mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
>  		ispeed =
>  		    mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
> +		if (port->node->type == IB_NODE_SWITCH)
> +			info = (uint8_t *)&port->node->ports[0]->info;
> +		else
> +			info = (uint8_t *)&port->info;
> +		cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
> +		if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
> +			espeed = mad_get_field(port->info, 0,
> +					       IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
> +		else
> +			espeed = 0;
>  		nodename = remap_node_name(node_name_map,
>  					   port->node->guid,
>  					   port->node->nodedesc);
> @@ -648,7 +698,9 @@ void dump_ports_report(ibnd_node_t * node, void *user_data)
>  			IB_NODE_SWITCH ? node->smalid : port->base_lid,
>  			port->portnum, port->guid,
>  			dump_linkwidth_compat(iwidth),
> -			dump_linkspeed_compat(ispeed));
> +			(ispeed != 4 && !espeed) ?
> +				dump_linkspeed_compat(ispeed) :
> +				dump_linkspeedext_compat(espeed, ispeed));
>  		if (port->remoteport) {
>  			rem_nodename = remap_node_name(node_name_map,
>  					      port->remoteport->node->guid,


-- 
Ira Weiny
Math Programmer/Computer Scientist
Lawrence Livermore National Lab
925-423-8008
weiny2-i2BcT+NCU+M@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2011-08-18 18:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16 13:44 [PATCH 2/2] infiniband-diags/ibnetdiscover.c: Changes for extended link speeds Hal Rosenstock
     [not found] ` <4E4A744C.8060008-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2011-08-18 18:23   ` Ira Weiny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox