ibtracert.c: Remove checking the port 0 state for BasePort0 switches
PATCH 1/1 ibtracert.c: Remove checking the port 0 state for BasePort0 switches
From: Dan Ben Yosef <danby-VPRAkNaXOzVWk0Htik3J/[email protected]>
The port 0 state check is needed only for HCA/Routers and EnhancedPort0 switches.
For BasePort0 switches, the PortState field in the PortInfo attribute for port0 is undefined (not used).
--- src/ibtracert.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-)
src/ibtracert.c +40 -7
@@ -92,6 +92,7 @@ struct Switch {int mccap;int linearFDBtop;int fdb_base; +int enhsp0;int8_t fdb[64 ];char switchinfo[64 ]; };
@@ -114,6 +115,17 @@ struct Node {Node *nodesdist[MAXHOPS ];uint64_t target_portguid; +static int is_route_inactive_port0 (Node * node,Port * port,Switch * sw) +{ +int res =0 ; +/* not active for HCA and for enhanced port0 Switches */ +if (port->state !=4 && + (node->type !=IB_NODE_SWITCH || + (node->type ==IB_NODE_SWITCH && sw->enhsp0))) + res =1 ; +return res; +} +static int get_node (Node * node,Port * port,ib_portid_t * portid) {void *pi = port->portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;
@@ -164,6 +176,7 @@ static int switch_lookup(Switch * sw, ib_portid_t * portid, int lid)mad_decode_field (si,IB_SW_LINEAR_FDB_CAP_F , &sw->linearcap);mad_decode_field (si,IB_SW_LINEAR_FDB_TOP_F , &sw->linearFDBtop); +mad_decode_field (si,IB_SW_ENHANCED_PORT0_F , &sw->enhsp0);if (lid >= sw->linearcap && lid > sw->linearFDBtop)return -1 ;
@@ -248,7 +261,7 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump)Port *port, fromport, toport, nextport;Switch sw;int maxhops =MAXHOPS ; -int portnum, outport; +int portnum, outport =255 , next_sw_outport =255 ;memset (&fromnode,0 ,sizeof (Node));memset (&tonode,0 ,sizeof (Node));
@@ -274,20 +287,28 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) portnum = port->portnum;dump_endnode (dump,"From" , node, port); +if (node->type ==IB_NODE_SWITCH ) { + next_sw_outport =switch_lookup (&sw, from, to->lid); +if (next_sw_outport <0 || next_sw_outport > node->numports) { +/* needed to print the port in badtbl */ + outport = next_sw_outport; + goto badtbl; + } + }while (maxhops--) { -if (port->state !=4 ) +/* checking if the port state isn't active. +* The "sw" argument is only relevant when the port is a +* switch port for HCAs this argument is ignored */ +if (is_route_inactive_port0 (node, port, &sw)) goto badport;if (sameport (port, &toport))break ;/* found */ - outport = portnum;if (node->type ==IB_NODE_SWITCH ) {DEBUG ("switch node" ); -if ((outport =switch_lookup (&sw, from, to->lid)) <0 || - outport > node->numports) - goto badtbl; + outport = next_sw_outport;if (extend_dpath (&from->drpath, outport) <0 ) goto badpath;
@@ -307,6 +328,7 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) (node->type == IB_NODE_ROUTER)) {int ca_src =0 ; + outport = portnum;DEBUG ("ca or router node" );if (!sameport (port, &fromport)) {IBWARN
@@ -335,8 +357,19 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) nextport.portnum = from->drpath.p[from->drpath.cnt +1 ]; } +/* only if the next node is a switch, get switch info */ +if (nextnode.type ==IB_NODE_SWITCH ) { + next_sw_outport =switch_lookup (&sw, from, to->lid); +if (next_sw_outport <0 || + next_sw_outport > nextnode.numports) { +/* needed to print the port in badtbl */ + outport = next_sw_outport; + goto badtbl; + } + } + port = &nextport; -if (port->state !=4 ) +if (is_route_inactive_port0 (&nextnode, port, &sw)) goto badoutport; node = &nextnode; portnum = port->portnum;
Signature · 6 lines
1.7.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 54BE514B.5030904-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Sorry for the delay.
Quoted 34 lines
-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Hal Rosenstock
Sent: Tuesday, January 20, 2015 5:00 AM
To: Weiny, Ira
Cc: Dan Ben-Yosef; linux-rdma ([email protected])
Subject: [PATCH infiniband-diags]ibtracert.c: Remove checking the port 0 state for BasePort0 switchesFrom: Dan Ben Yosef <danby-VPRAkNaXOzVWk0Htik3J/[email protected]>
The port 0 state check is needed only for HCA/Routers and EnhancedPort0 switches.
For BasePort0 switches, the PortState field in the PortInfo attribute for port0 is undefined (not used).
--- src/ibtracert.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-)src/ibtracert.c +1
-0@@ -92,6 +92,7 @@ struct Switch {int mccap;int linearFDBtop;int fdb_base; +int enhsp0;int8_t fdb[64 ];char switchinfo[64 ]; };
src/ibtracert.c struct Node { · line 119
Quoted 5 lines
src/ibtracert.c +2
-0@@ -114,6 +115,17 @@ struct Node {Node *nodesdist[MAXHOPS ];uint64_t target_portguid; +static int is_route_inactive_port0 (Node * node,Port * port,Switch * +sw) {
I would prefer this function be named something like:
port_inactive_not_bsp0
The current name is confusing as to what the logic is.
src/ibtracert.c struct Node { · line 122
Quoted 3 lines
src/ibtracert.c +3
-0+int res =0 ; +/* not active for HCA and for enhanced port0 Switches */ + if (port->state != 4 &&
Please use #defines here even though the original code did not.
Quoted 38 lines
src/ibtracert.c +7
-0+ (node->type != IB_NODE_SWITCH || + (node->type == IB_NODE_SWITCH && sw->enhsp0))) + res =1 ; +return res; +} +static int get_node (Node * node,Port * port,ib_portid_t * portid) {void *pi = port->portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;@@ -164,6 +176,7 @@ static int switch_lookup(Switch * sw, ib_portid_t * portid, int lid)mad_decode_field (si,IB_SW_LINEAR_FDB_CAP_F , &sw->linearcap);mad_decode_field (si,IB_SW_LINEAR_FDB_TOP_F , &sw- >linearFDBtop); +mad_decode_field (si,IB_SW_ENHANCED_PORT0_F , &sw->enhsp0);src/ibtracert.c +1
-1if (lid >= sw->linearcap && lid > sw->linearFDBtop)return -1 ;@@ -248,7 +261,7 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) Port *port, fromport, toport, nextport;Switch sw;int maxhops =MAXHOPS ; -int portnum, outport; +int portnum, outport =255 , next_sw_outport =255 ;memset (&fromnode,0 ,sizeof (Node));src/ibtracert.c +4
-0memset (&tonode,0 ,sizeof (Node));@@ -274,20 +287,28 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) portnum = port->portnum;dump_endnode (dump,"From" , node, port); +if (node->type ==IB_NODE_SWITCH ) { + next_sw_outport =switch_lookup (&sw, from, to->lid); +if (next_sw_outport <0 || next_sw_outport > node->numports) { +/* needed to print the port in badtbl */
src/ibtracert.c static int find_route(ib_portid_t * from, ib_portid_t * · line 304
Quoted 10 lines
src/ibtracert.c +7
-1+ outport = next_sw_outport; + goto badtbl; + } + }while (maxhops--) { -if (port->state !=4 ) +/* checking if the port state isn't active. +* The "sw" argument is only relevant when the port is a +* switch port for HCAs this argument is ignored */
This comment should go above the function signature and be enhanced to clarify that it is checking for port state inactive except for BSP0 which has no state.
Ira
Quoted 50 lines
src/ibtracert.c +2
-4+if (is_route_inactive_port0 (node, port, &sw)) goto badport;if (sameport (port, &toport))break ;/* found */ - outport = portnum;if (node->type ==IB_NODE_SWITCH ) {DEBUG ("switch node" ); -if ((outport =switch_lookup (&sw, from, to->lid)) <0 || - outport > node->numports) - goto badtbl; + outport = next_sw_outport;src/ibtracert.c +1
-0if (extend_dpath (&from->drpath, outport) <0 ) goto badpath;@@ -307,6 +328,7 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) (node->type == IB_NODE_ROUTER)) {int ca_src =0 ; + outport = portnum;DEBUG ("ca or router node" );if (!sameport (port, &fromport)) {src/ibtracert.c +12
-1IBWARN @@ -335,8 +357,19 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) nextport.portnum = from->drpath.p[from->drpath.cnt +1 ]; } +/* only if the next node is a switch, get switch info */ +if (nextnode.type ==IB_NODE_SWITCH ) { + next_sw_outport =switch_lookup (&sw, from, to->lid); +if (next_sw_outport <0 || + next_sw_outport > nextnode.numports) { +/* needed to print the port in badtbl */ + outport = next_sw_outport; + goto badtbl; + } + } + port = &nextport; -if (port->state !=4 ) +if (is_route_inactive_port0 (&nextnode, port, &sw)) goto badoutport; node = &nextnode;portnum =
port->portnum;
--
1.7.8.2
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 2807E5FD2F6FDA4886F6618EAC48510E0CC0D7F9-8k97q/[email protected]
Quoted 39 lines · Ira
Sorry for the delay.
Quoted 37 lines
-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Hal Rosenstock
Sent: Tuesday, January 20, 2015 5:00 AM
To: Weiny, Ira
Cc: Dan Ben-Yosef; linux-rdma ([email protected])
Subject: [PATCH infiniband-diags]ibtracert.c: Remove checking the port 0 state for BasePort0 switchesFrom: Dan Ben Yosef <danby-VPRAkNaXOzVWk0Htik3J/[email protected]>
The port 0 state check is needed only for HCA/Routers and EnhancedPort0 switches.
For BasePort0 switches, the PortState field in the PortInfo attribute for port0 is undefined (not used).
--- src/ibtracert.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-)src/ibtracert.c +1
-0@@ -92,6 +92,7 @@ struct Switch {int mccap;int linearFDBtop;int fdb_base; +int enhsp0;int8_t fdb[64 ];char switchinfo[64 ]; };@@ -114,6 +115,17 @@ struct Node {Node *nodesdist[MAXHOPS ];uint64_t target_portguid;
Quoted 8 lines
src/ibtracert.c struct Node { · line 119
Quoted 2 lines
src/ibtracert.c +2
-0+static int is_route_inactive_port0 (Node * node,Port * port,Switch * +sw) {I would prefer this function be named something like:
port_inactive_not_bsp0The current name is confusing as to what the logic is.
How about is_port_inactive ?
Quoted 5 lines
src/ibtracert.c struct Node { · line 122
Quoted 3 lines
src/ibtracert.c +3
-0+int res =0 ; +/* not active for HCA and for enhanced port0 Switches */ + if (port->state != 4 &&Please use #defines here even though the original code did not.
This is an issue throughout infiniband-diags. I think it should be addressed by separate patch(es) for this.
Quoted 43 lines
Quoted 43 lines
src/ibtracert.c +7
-0+ (node->type != IB_NODE_SWITCH || + (node->type == IB_NODE_SWITCH && sw->enhsp0))) + res =1 ; +return res; +} +static int get_node (Node * node,Port * port,ib_portid_t * portid) {void *pi = port->portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;@@ -164,6 +176,7 @@ static int switch_lookup(Switch * sw, ib_portid_t * portid, int lid)mad_decode_field (si,IB_SW_LINEAR_FDB_CAP_F , &sw->linearcap);mad_decode_field (si,IB_SW_LINEAR_FDB_TOP_F , &sw- > linearFDBtop); +mad_decode_field (si,IB_SW_ENHANCED_PORT0_F , &sw->enhsp0);src/ibtracert.c +1
-1if (lid >= sw->linearcap && lid > sw->linearFDBtop)return -1 ;@@ -248,7 +261,7 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) Port *port, fromport, toport, nextport;Switch sw;int maxhops =MAXHOPS ; -int portnum, outport; +int portnum, outport =255 , next_sw_outport =255 ;memset (&fromnode,0 ,sizeof (Node));src/ibtracert.c +8
-0memset (&tonode,0 ,sizeof (Node));@@ -274,20 +287,28 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) portnum = port->portnum;dump_endnode (dump,"From" , node, port); +if (node->type ==IB_NODE_SWITCH ) { + next_sw_outport =switch_lookup (&sw, from, to->lid); +if (next_sw_outport <0 || next_sw_outport > node->numports) { +/* needed to print the port in badtbl */ + outport = next_sw_outport; + goto badtbl; + } + }
Quoted 7 lines
src/ibtracert.c static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) · line 302
Quoted 5 lines
src/ibtracert.c +3
-1while (maxhops--) { -if (port->state !=4 ) +/* checking if the port state isn't active. +* The "sw" argument is only relevant when the port is a +* switch port for HCAs this argument is ignored */ This comment should go above the function signature and be enhanced to clarify that it is checking for port state inactive except for BSP0 which has no state.
Will do that in next version of the patch.
-- Hal
Quoted 54 lines
Ira
Quoted 50 lines
src/ibtracert.c +2
-4+if (is_route_inactive_port0 (node, port, &sw)) goto badport;if (sameport (port, &toport))break ;/* found */ - outport = portnum;if (node->type ==IB_NODE_SWITCH ) {DEBUG ("switch node" ); -if ((outport =switch_lookup (&sw, from, to->lid)) <0 || - outport > node->numports) - goto badtbl; + outport = next_sw_outport;src/ibtracert.c +1
-0if (extend_dpath (&from->drpath, outport) <0 ) goto badpath;@@ -307,6 +328,7 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) (node->type == IB_NODE_ROUTER)) {int ca_src =0 ; + outport = portnum;DEBUG ("ca or router node" );if (!sameport (port, &fromport)) {src/ibtracert.c +12
-1IBWARN @@ -335,8 +357,19 @@ static int find_route(ib_portid_t * from, ib_portid_t * to, int dump) nextport.portnum = from->drpath.p[from->drpath.cnt +1 ]; } +/* only if the next node is a switch, get switch info */ +if (nextnode.type ==IB_NODE_SWITCH ) { + next_sw_outport =switch_lookup (&sw, from, to->lid); +if (next_sw_outport <0 || + next_sw_outport > nextnode.numports) { +/* needed to print the port in badtbl */ + outport = next_sw_outport; + goto badtbl; + } + } + port = &nextport; -if (port->state !=4 ) +if (is_route_inactive_port0 (&nextnode, port, &sw)) goto badoutport; node = &nextnode;portnum =
port->portnum;
--
1.7.8.2
Quoted 5 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 54C96586.3080309-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Quoted 7 lines
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +3
-0+static int is_route_inactive_port0(Node * node, Port * port, Switch +* +sw) {I would prefer this function be named something like:
Quoted 5 lines
Quoted 3 lines
port_inactive_not_bsp0The current name is confusing as to what the logic is.
How about
is_port_inactive?
That is fine.
Quoted 9 lines
Quoted 6 lines
src/ibtracert.c struct Node { · line 122
Quoted 4 lines
src/ibtracert.c +3
-0+int res =0 ; +/* not active for HCA and for enhanced port0 Switches */ + if (port->state != 4 &&Please use #defines here even though the original code did not.
This is an issue throughout infiniband-diags. I think it should be addressed by separate patch(es) for this.
I would rather see us do the right thing going forward. This saves work trying to find all these majic numbers later.
Ira
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html