[ofa-general] [PATCH] ibportstate: add width option

Doron Shoham dorons at voltaire.com
Sun Sep 13 09:23:13 PDT 2009


ibportstate: add width option.
Similar to the speed option, this option can
explicitly set the port's LinkWidthEnable value.
It supports values from 0-15 and 255.

Signed-off-by: Doron Shoham <dorons at voltaire.com>
---
 infiniband-diags/man/ibportstate.8 |   11 +++++++----
 infiniband-diags/src/ibportstate.c |   17 ++++++++++++++++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/infiniband-diags/man/ibportstate.8 b/infiniband-diags/man/ibportstate.8
index 9b5e618..1dc3724 100644
--- a/infiniband-diags/man/ibportstate.8
+++ b/infiniband-diags/man/ibportstate.8
@@ -15,7 +15,7 @@ ibportstate allows the port state and port physical state of an IB port
 to be queried (in addition to link width and speed being validated
 relative to the peer port when the port queried is a switch port),
 or a switch port to be disabled, enabled, or reset. It
-also allows the link speed enabled on any IB port to be adjusted.
+also allows the link speed/width enabled on any IB port to be adjusted.
 
 .SH OPTIONS
 
@@ -23,16 +23,17 @@ also allows the link speed enabled on any IB port to be adjusted.
 .TP
 op
 Port operations allowed
- supported ops: enable, disable, reset, speed, query
+ supported ops: enable, disable, reset, speed, width, query
  Default is query
 .PP
  ops enable, disable, and reset are only allowed on switch ports
  (An error is indicated if attempted on CA or router ports)
- speed op is allowed on any port
+ speed/width ops are allowed on any port
  speed values are legal values for PortInfo:LinkSpeedEnabled
  (An error is indicated if PortInfo:LinkSpeedSupported does not support
   this setting)
- (NOTE: Speed changes are not effected until the port goes through
+ width values are legal values for PortInfo:LinkWidthEnabled
+ (NOTE: Speed/Width changes are not effected until the port goes through
   link renegotiation)
  query also validates port characteristics (link width and speed)
   based on the peer port. This checking is done when the port
@@ -108,6 +109,8 @@ ibportstate -D 0 1                      # (query) by direct route
 ibportstate 3 1 reset				# by lid
 .PP
 ibportstate 3 1 speed 1				# by lid
+.PP
+ibportstate 3 1 width 1				# by lid
 
 .SH AUTHOR
 .TP
diff --git a/infiniband-diags/src/ibportstate.c b/infiniband-diags/src/ibportstate.c
index 76e74f7..4ed8e82 100644
--- a/infiniband-diags/src/ibportstate.c
+++ b/infiniband-diags/src/ibportstate.c
@@ -216,13 +216,14 @@ int main(int argc, char **argv)
 	int selfport = 0;
 
 	char usage_args[] = "<dest dr_path|lid|guid> <portnum> [<op>]\n"
-	    "\nSupported ops: enable, disable, reset, speed, query";
+	    "\nSupported ops: enable, disable, reset, speed, width, query";
 	const char *usage_examples[] = {
 		"3 1 disable\t\t\t# by lid",
 		"-G 0x2C9000100D051 1 enable\t# by guid",
 		"-D 0 1\t\t\t# (query) by direct route",
 		"3 1 reset\t\t\t# by lid",
 		"3 1 speed 1\t\t\t# by lid",
+		"3 1 width 1\t\t\t# by lid",
 		NULL
 	};
 
@@ -263,6 +264,15 @@ int main(int argc, char **argv)
 			speed = strtoul(argv[3], 0, 0);
 			if (speed > 15)
 				IBERROR("invalid speed value %d", speed);
+		} else if (!strcmp(argv[2], "width")) {
+			if (argc < 4)
+				IBERROR
+				    ("width requires an additional parameter");
+			port_op = 5;
+			/* Parse width value */
+			width = strtoul(argv[3], 0, 0);
+			if (width > 15 && width != 255)
+				IBERROR("invalid width value %d", width);
 		}
 	}
 
@@ -298,6 +308,11 @@ int main(int argc, char **argv)
 				      speed);
 			mad_set_field(data, 0, IB_PORT_STATE_F, 0);
 			mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 0);
+		} else if (port_op == 5) {	/* Set width */
+			mad_set_field(data, 0, IB_PORT_LINK_WIDTH_ENABLED_F,
+				      width);
+			mad_set_field(data, 0, IB_PORT_STATE_F, 0);
+			mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 0);
 		}
 
 		err = set_port_info(&portid, data, portnum, port_op);
-- 
1.5.4




More information about the general mailing list