[ofa-general] [PATCH] infiniband_diags/ibportstate.c perform reset in a single mad

Eli Dorfman (Voltaire) dorfman.eli at gmail.com
Mon Jun 8 03:03:01 PDT 2009


perform reset in a single mad

Perform reset by changing physical state to polling instead of
disable and enable.
This ensures that reset a port will not disconnect it (assuming negotiation succeeds).
Only disable operation is not allowed on HCA ports since it will irreversibly
disconnect it though this may also happen on a switch ingress port.

Signed-off-by: Eli Dorfman <elid at voltaire.com>
---
 infiniband-diags/src/ibportstate.c |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/infiniband-diags/src/ibportstate.c b/infiniband-diags/src/ibportstate.c
index d19a2e5..93738c0 100644
--- a/infiniband-diags/src/ibportstate.c
+++ b/infiniband-diags/src/ibportstate.c
@@ -233,6 +233,9 @@ int main(int argc, char **argv)
 				ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[0]);
 
+	if (argc > 1)
+		portnum = strtol(argv[1], 0, 0);
+
 	/* First, make sure it is a switch port if it is a "set" */
 	if (argc >= 3) {
 		if (!strcmp(argv[2], "enable"))
@@ -258,13 +261,10 @@ int main(int argc, char **argv)
 	if (err) {		/* not switch */
 		if (port_op == 0)	/* query op */
 			is_switch = 0;
-		else if (port_op != 4)	/* other than speed op */
-			IBERROR("smp query nodeinfo: Node type not switch");
+		else if (port_op == 2)	/* disable */
+			IBERROR("Node type not switch - disable not allowed");
 	}
 
-	if (argc-1 > 0)
-		portnum = strtol(argv[1], 0, 0);
-
 	if (port_op)
 		printf("Initial PortInfo:\n");
 	else
@@ -275,11 +275,11 @@ int main(int argc, char **argv)
 
 	/* Only if one of the "set" options is chosen */
 	if (port_op) {
-		if (port_op == 1) {		/* Enable port */
+		if ((port_op == 1) || (port_op == 3)) {		/* Enable or Reset port */
 			mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2);	/* Polling */
 			mad_set_field(data, 0, IB_PORT_STATE_F, 0);             /* No Change */
-		}
-		else if ((port_op == 2) || (port_op == 3)) { /* Disable port */
+		} else if (port_op == 2) { /* Disable port */
+			printf("Disable may be irreversible\n");
 			mad_set_field(data, 0, IB_PORT_STATE_F, 1);             /* Down */
 			mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 3);        /* Disabled */
 		} else if (port_op == 4) {	/* Set speed */
@@ -291,14 +291,6 @@ int main(int argc, char **argv)
 		err = set_port_info(&portid, data, portnum, port_op);
 		if (err < 0)
 			IBERROR("smp set portinfo failed");
-
-		if (port_op == 3) {	/* Reset port - so also enable */
-			mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2);	/* Polling */
-			mad_set_field(data, 0, IB_PORT_STATE_F, 0);             /* No Change */
-			err = set_port_info(&portid, data, portnum, port_op);
-			if (err < 0)
-				IBERROR("smp set portinfo failed");
-		}
 	} else {	/* query op */
 		/* only compare peer port if switch port */
 		if (is_switch) {
-- 
1.5.5




More information about the general mailing list