Skip to contentSkip to conversation

ibsim/sim_cmd.c: Only relink port if remote port is currently linked

PATCH Hal Rosenstock 1 participant 2 messages Sep 29, 2009 2 messages not in the archive InfiniBand

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20090929215338.GA17846@me

#2 lore raw

Hi Sasha,

Quoted 10 lines · Sasha Khapyorsky

Hi Hal,

Quoted 6 lines · Hal Rosenstock

When multiple switches are unlinked and then a switch is relinked, it should behave like a cable pull or power down of switch so it depends on the state of the remote peer port (as to linked or not). This is not represented in the IB port/port physical state and is additional state.

Quoted 4 lines

I'm not sure that I understand what this patch tries to achieve - I cannot see any changes related to port physical state handling. I can only see that you try to prevent linking with previously unlinked ports, and it is not clear for me why. Could you explain?

The failure scenario is to unlink 2 connected switches and then relink the first one. It then relinks the second one even though it still should be unlinked.

Quoted 5 lines
Quoted 5 lines

---

Quoted 12 lines

ibsim/sim.h struct Port { · line 214

Quoted 9 lines
ibsim/sim.h +1 -0
index bf85875..52eb73b 100644
@@ -210,6 +211,7 @@ struct Port {
       int remoteport;
       Node *previous_remotenode;
       int previous_remoteport;
+     int unlinked;

Do you really need this flag? Existence of non NULL previous_remotenode pointer should be good indication.

That's how I started (using previous_remotenode) but it didn't work correctly for all cases. It worked with the simple case above (unlink 2 switches and relink the first). It didn't work with a 3 switch case.

-- Hal

Quoted 128 lines
Quoted 15 lines
ibsim/sim.h +0 -0
       int errrate;
       uint16_t errattr;
       Node *node;
ibsim/sim_cmd.c +1 -0
index cb6e639..d27ab0f 100644
@@ -1,5 +1,6 @@
  /*
   * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
   *
   * This file is part of ibsim.
   *

ibsim/sim_cmd.c static int do_link(FILE * f, char *line) · line 154

Quoted 8 lines
ibsim/sim_cmd.c +5 -0
@@ -146,12 +147,18 @@ static int do_link(FILE * f, char *line)
 
       rport = node_get_port(rnode, rportnum);
 
+     if (rport->unlinked) {
+             lport->unlinked = 0;
+             return -1;
+     }
+

Why?

Quoted 20 lines
ibsim/sim_cmd.c +1 -0
       if (link_ports(lport, rport) < 0)
               return -fprintf(f,
                               "# can't link: local/remote port are already connected\n");
 
       lport->previous_remotenode = NULL;
       rport->previous_remotenode = NULL;
+     lport->unlinked = 0;
 
       return 0;
  }
@@ -194,7 +201,7 @@ static int do_relink(FILE * f, char *line)

              numports++;     // To make the for-loop below run up to last port else
              lportnum--;

ibsim/sim_cmd.c +1 -1
-
+

      if (lportnum >= 0) {
              lport = ports + lnode->portsbase + lportnum;

ibsim/sim_cmd.c static int do_relink(FILE * f, char *line) · line 220

Quoted 8 lines
ibsim/sim_cmd.c +5 -0
@@ -206,12 +213,18 @@ static int do_relink(FILE * f, char *line)
               rport = node_get_port(lport->previous_remotenode,
                                     lport->previous_remoteport);
 
+             if (rport->unlinked) {
+                     lport->unlinked = 0;
+                     return -1;
+             }
+

Why?

Quoted 11 lines
ibsim/sim_cmd.c +1 -0
               if (link_ports(lport, rport) < 0)
                       return -fprintf(f,
                                       "# can't link: local/remote port are already connected\n");
 
               lport->previous_remotenode = NULL;
               rport->previous_remotenode = NULL;
+             lport->unlinked = 0;
 
               return 1;
       }

ibsim/sim_cmd.c static int do_relink(FILE * f, char *line) · line 244

Quoted 8 lines
ibsim/sim_cmd.c +5 -0
@@ -224,11 +237,17 @@ static int do_relink(FILE * f, char *line)
               rport = node_get_port(lport->previous_remotenode,
                                     lport->previous_remoteport);
 
+             if (rport->unlinked) {
+                     lport->unlinked = 0;
+                     continue;
+             }
+

Ditto.

Sasha

Quoted 47 lines
ibsim/sim_cmd.c +6 -1
               if (link_ports(lport, rport) < 0)
                       continue;
 
               lport->previous_remotenode = NULL;
               rport->previous_remotenode = NULL;
+             lport->unlinked = 0;
 
               relinked++;
       }
@@ -246,6 +265,7 @@ static void unlink_port(Node * lnode, Port * lport, Node * rnode, int rportnum)
       lport->previous_remoteport = lport->remoteport;
       rport->previous_remotenode = rport->remotenode;
       rport->previous_remoteport = rport->remoteport;
+     lport->unlinked = 1;
 
       lport->remotenode = rport->remotenode = 0;
       lport->remoteport = rport->remoteport = 0;
@@ -406,6 +426,7 @@ static int do_unlink(FILE * f, char *line, int clear)
       if (portnum >= 0) {
               port = ports + node->portsbase + portnum;
               if (!clear && !port->remotenode) {
+                     port->unlinked = 1;
                       fprintf(f, "# port %d at nodeid \"%s\" is not linked\n",
                               portnum, nodeid);
                       return -1;
@@ -420,8 +441,10 @@ static int do_unlink(FILE * f, char *line, int clear)
 
       for (port = ports + node->portsbase, e = port + numports; port < e;
            port++) {
-             if (!clear && !port->remotenode)
+             if (!clear && !port->remotenode) {
+                     port->unlinked = 1;
                       continue;
+             }
               if (port->remotenode)
                       unlink_port(node, port, port->remotenode,
                                   port->remoteport);
ibsim/sim_net.c +1 -0
index 8a5d281..0092068 100644
@@ -492,6 +492,7 @@ static void init_ports(Node * node, int type, int maxports)
               port->linkwidth = LINKWIDTH_4x;
               port->linkspeedena = netspeed;
               port->linkspeed = LINKSPEED_SDR;
+             port->unlinked = 0;
 
Quoted 9 lines

ibsim/sim_net.c static void init_ports(Node * node, int type, int maxports) · line 498

Quoted 2 lines
ibsim/sim_net.c +0 -0
               size = (type == SWITCH_NODE && i) ? sw_pkey_size : ca_pkey_size;
               if (size) {

_______________________________________________
general mailing list [email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

--
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

#3 lore raw
In reply to a message not in the archive

Hi again Sasha,

In my previous post, I missed answering some of your (implied) questions.

Quoted 4 lines · Sasha Khapyorsky

Hi Hal,

Quoted 1 line · Hal Rosenstock
Quoted 8 lines
Quoted 5 lines

When multiple switches are unlinked and then a switch is relinked, it should behave like a cable pull or power down of switch so it depends on the state of the remote peer port (as to linked or not). This is not represented in the IB port/port physical state and is additional state.

I'm not sure that I understand what this patch tries to achieve - I cannot see any changes related to port physical state handling.

Right; that's because there is none. My point was that this condition (e.g. simulated power off switch) cannot be represented in IB port state or port physical state.

Quoted 1 line

I can only see that you try to prevent linking with previously unlinked ports,

Yes.

-- Hal

Quoted 147 lines

and it is not clear for me why. Could you explain?

ibsim/sim.h struct Port { · line 214

Quoted 13 lines

---

ibsim/sim.h +1 -0
index bf85875..52eb73b 100644
@@ -210,6 +211,7 @@ struct Port {
       int remoteport;
       Node *previous_remotenode;
       int previous_remoteport;
+     int unlinked;

Do you really need this flag? Existence of non NULL previous_remotenode pointer should be good indication.

Quoted 15 lines
ibsim/sim.h +0 -0
       int errrate;
       uint16_t errattr;
       Node *node;
ibsim/sim_cmd.c +1 -0
index cb6e639..d27ab0f 100644
@@ -1,5 +1,6 @@
  /*
   * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
   *
   * This file is part of ibsim.
   *

ibsim/sim_cmd.c static int do_link(FILE * f, char *line) · line 154

Quoted 8 lines
ibsim/sim_cmd.c +5 -0
@@ -146,12 +147,18 @@ static int do_link(FILE * f, char *line)
 
       rport = node_get_port(rnode, rportnum);
 
+     if (rport->unlinked) {
+             lport->unlinked = 0;
+             return -1;
+     }
+

Why?

Quoted 20 lines
ibsim/sim_cmd.c +1 -0
       if (link_ports(lport, rport) < 0)
               return -fprintf(f,
                               "# can't link: local/remote port are already connected\n");
 
       lport->previous_remotenode = NULL;
       rport->previous_remotenode = NULL;
+     lport->unlinked = 0;
 
       return 0;
  }
@@ -194,7 +201,7 @@ static int do_relink(FILE * f, char *line)

              numports++;     // To make the for-loop below run up to last port else
              lportnum--;

ibsim/sim_cmd.c +1 -1
-
+

      if (lportnum >= 0) {
              lport = ports + lnode->portsbase + lportnum;

ibsim/sim_cmd.c static int do_relink(FILE * f, char *line) · line 220

Quoted 8 lines
ibsim/sim_cmd.c +5 -0
@@ -206,12 +213,18 @@ static int do_relink(FILE * f, char *line)
               rport = node_get_port(lport->previous_remotenode,
                                     lport->previous_remoteport);
 
+             if (rport->unlinked) {
+                     lport->unlinked = 0;
+                     return -1;
+             }
+

Why?

Quoted 11 lines
ibsim/sim_cmd.c +1 -0
               if (link_ports(lport, rport) < 0)
                       return -fprintf(f,
                                       "# can't link: local/remote port are already connected\n");
 
               lport->previous_remotenode = NULL;
               rport->previous_remotenode = NULL;
+             lport->unlinked = 0;
 
               return 1;
       }

ibsim/sim_cmd.c static int do_relink(FILE * f, char *line) · line 244

Quoted 8 lines
ibsim/sim_cmd.c +5 -0
@@ -224,11 +237,17 @@ static int do_relink(FILE * f, char *line)
               rport = node_get_port(lport->previous_remotenode,
                                     lport->previous_remoteport);
 
+             if (rport->unlinked) {
+                     lport->unlinked = 0;
+                     continue;
+             }
+

Ditto.

Sasha

Quoted 47 lines
ibsim/sim_cmd.c +6 -1
               if (link_ports(lport, rport) < 0)
                       continue;
 
               lport->previous_remotenode = NULL;
               rport->previous_remotenode = NULL;
+             lport->unlinked = 0;
 
               relinked++;
       }
@@ -246,6 +265,7 @@ static void unlink_port(Node * lnode, Port * lport, Node * rnode, int rportnum)
       lport->previous_remoteport = lport->remoteport;
       rport->previous_remotenode = rport->remotenode;
       rport->previous_remoteport = rport->remoteport;
+     lport->unlinked = 1;
 
       lport->remotenode = rport->remotenode = 0;
       lport->remoteport = rport->remoteport = 0;
@@ -406,6 +426,7 @@ static int do_unlink(FILE * f, char *line, int clear)
       if (portnum >= 0) {
               port = ports + node->portsbase + portnum;
               if (!clear && !port->remotenode) {
+                     port->unlinked = 1;
                       fprintf(f, "# port %d at nodeid \"%s\" is not linked\n",
                               portnum, nodeid);
                       return -1;
@@ -420,8 +441,10 @@ static int do_unlink(FILE * f, char *line, int clear)
 
       for (port = ports + node->portsbase, e = port + numports; port < e;
            port++) {
-             if (!clear && !port->remotenode)
+             if (!clear && !port->remotenode) {
+                     port->unlinked = 1;
                       continue;
+             }
               if (port->remotenode)
                       unlink_port(node, port, port->remotenode,
                                   port->remoteport);
ibsim/sim_net.c +1 -0
index 8a5d281..0092068 100644
@@ -492,6 +492,7 @@ static void init_ports(Node * node, int type, int maxports)
               port->linkwidth = LINKWIDTH_4x;
               port->linkspeedena = netspeed;
               port->linkspeed = LINKSPEED_SDR;
+             port->unlinked = 0;
 
Quoted 9 lines

ibsim/sim_net.c static void init_ports(Node * node, int type, int maxports) · line 498

Quoted 2 lines
ibsim/sim_net.c +0 -0
               size = (type == SWITCH_NODE && i) ? sw_pkey_size : ca_pkey_size;
               if (size) {

_______________________________________________
general mailing list [email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

--
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