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

Ira Weiny weiny2 at llnl.gov
Mon Aug 4 14:05:37 PDT 2008


On Sun, 3 Aug 2008 20:09:46 +0300
Sasha Khapyorsky <sashak at voltaire.com> wrote:

> 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

This did not quite work (had to add an exception in pc_updated).  Here is a
revised version with some additions to the help message for ease of use.

Ira


>From 4d1fb5b5ba24584e27d09e51e29745f986f84a32 Mon Sep 17 00:00:00 2001
From: Sasha Khapyorsky <sashak at voltaire.com>
Date: Sun, 3 Aug 2008 20:09:46 +0300
Subject: [PATCH] ibsim: Add a Node Description query drop error.

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

Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 ibsim/sim.h     |    1 +
 ibsim/sim_cmd.c |   24 ++++++++++++++++++++++--
 ibsim/sim_mad.c |    7 +++++--
 3 files changed, 28 insertions(+), 4 deletions(-)

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..6bf1e29 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++;
 	}
 
@@ -415,8 +425,11 @@ static void dump_switch(FILE * f, Switch * sw)
 
 static void dump_comment(Port * port, char *comment)
 {
+	int n = 0;
 	if (port->errrate)
-		sprintf(comment, "\t# err_rate %d", port->errrate);
+		n += sprintf(comment, "\t# err_rate %d", port->errrate);
+	if (port->errattr)
+		n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
 }
 
 static void dump_port(FILE * f, Port * port, int type)
@@ -708,7 +721,14 @@ 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 ID\n"
+		"\t\t\tSome common attribute IDs:\n"
+		"\t\t\t\tNodeDescription : 16\n"
+		"\t\t\t\tNodeInfo        : 17\n"
+		"\t\t\t\tSwitchInfo      : 18\n"
+		"\t\t\t\tPortInfo        : 19\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..0ac2c1e 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -612,7 +612,9 @@ static int pc_updated(Port ** srcport, Port * destport)
 		ADDVAL64(destpc->ext_xmit_data, madsize_div_4);
 		ADDVAL64(destpc->ext_xmit_pkts, 1);
 
-		if (destport->errrate && (random() % 100) < destport->errrate) {
+		if (destport->errrate &&
+		    !destport->errattr &&
+		    (random() % 100) < destport->errrate) {
 			pc_add_error_errs_rcv(destport);
 			VERB("drop pkt due error rate %d", destport->errrate);
 			return 0;
@@ -1188,7 +1190,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;
 	}
-- 
1.5.4.5





More information about the general mailing list