[ofa-general] Re: [PATCH V2] ibsim: Add a Node Description query drop error.

Sasha Khapyorsky sashak at voltaire.com
Sun Aug 3 10:09:46 PDT 2008


Hi Ira,

On 13:20 Thu 31 Jul     , Ira Weiny wrote:
> 
> Like this?

Not exactly. I meant possibility to specify any attribute to drop. Like
this.

Sasha

diff --git a/ibsim/sim.h b/ibsim/sim.h
index 936bb85..f989252 100644
--- a/ibsim/sim.h
+++ b/ibsim/sim.h
@@ -207,6 +207,7 @@ struct Port {
 	Node *remotenode;
 	int remoteport;
 	int errrate;
+	uint16_t errattr;
 	Node *node;
 	Portcounters portcounters;
 	uint16_t *pkey_tbl;
diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index a6aab9d..e1c2384 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -199,6 +199,7 @@ static int do_seterror(FILE * f, char *line)
 	char *nodeid = 0, name[NAMELEN], *sp, *orig = 0;
 	int portnum = -1;	// def - all ports
 	int numports, set = 0, rate = 0;
+	uint16_t attr = 0;
 
 	if (strsep(&s, "\""))
 		orig = strsep(&s, "\"");
@@ -240,6 +241,13 @@ static int do_seterror(FILE * f, char *line)
 	}
 
 	DEBUG("error rate is %d", rate);
+
+	strsep(&s, " \t");
+	if (s) {
+		attr = strtoul(s, 0, 0);
+		DEBUG("error attr is %u", attr);
+	}
+
 	numports = node->numports;
 
 	if (node->type == SWITCH_NODE)
@@ -250,12 +258,14 @@ static int do_seterror(FILE * f, char *line)
 	if (portnum >= 0) {
 		port = ports + node->portsbase + portnum;
 		port->errrate = rate;
+		port->errattr = attr;
 		return 1;
 	}
 
 	for (port = ports + node->portsbase, e = port + numports; port < e;
 	     port++) {
 		port->errrate = rate;
+		port->errattr = attr;
 		set++;
 	}
 
@@ -708,7 +718,8 @@ static int dump_help(FILE * f)
 	fprintf(f, "\tGuid \"nodeid\" : set GUID value for this node\n");
 	fprintf(f, "\tGuid \"nodeid\"[port] : set GUID value for this port\n");
 	fprintf(f,
-		"\tError \"nodeid\"[port] <error-rate>: set error rate for port/node\n");
+		"\tError \"nodeid\"[port] <error-rate> [attribute]: set error rate for"
+		"\n\t\t\tport/node, optionally for specified attribute\n");
 	fprintf(f,
 		"\tBaselid \"nodeid\"[port] <lid> [lmc] : change port's lid (lmc)\n");
 	fprintf(f, "\tVerbose [newlevel] - show/set simulator verbosity\n");
diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index b8ce2ab..b66c697 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -1188,7 +1188,8 @@ int process_packet(Client * cl, void *p, int size, Client ** dcl)
 		return sizeof(*r);	// forward only
 	}
 
-	if (port->errrate && (random() % 100) < port->errrate) {
+	if (port->errrate && (!port->errattr || port->errattr == rpc.attr.id) &&
+	    (random() % 100) < port->errrate) {
 		VERB("drop pkt due error rate %d", port->errrate);
 		goto _dropped;
 	}



More information about the general mailing list