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

Ira Weiny weiny2 at llnl.gov
Thu Jul 31 13:20:53 PDT 2008


On Thu, 31 Jul 2008 21:03:23 +0300
Sasha Khapyorsky <sashak at voltaire.com> wrote:

> Hi Ira,
> 
> On 17:40 Wed 30 Jul     , Ira Weiny wrote:
> > I added this to ibsim to test the patch I am sending next:
> > 
> > [PATCH] OpenSM: Add a Node Description check on light sweep to ensure that the ND has been found for each node.
> > 
> > Thanks,
> > Ira
> > 
> > 
> > From ec95833fd08204cb67c9803b488c6ef7e9a30792 Mon Sep 17 00:00:00 2001
> > From: Ira K. Weiny <weiny2 at llnl.gov>
> > Date: Wed, 30 Jul 2008 16:16:11 -0700
> > Subject: [PATCH] ibsim: Add a Node Description query drop error.
> 
> Maybe it could be useful to extend existing 'Error' command by adding
> attribute there, so user will be able to define drop rate per node, port
> and/or attribute?
> 

Like this?
Ira


>From 0fc07721a55a82feaa304ebe15e9a236d4954f02 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Wed, 30 Jul 2008 16:16:11 -0700
Subject: [PATCH] Add a Node Description query drop error.


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 ibsim/sim.h     |    1 +
 ibsim/sim_cmd.c |   46 ++++++++++++++++++++++++++++++++++++----------
 ibsim/sim_mad.c |    8 ++++++++
 3 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/ibsim/sim.h b/ibsim/sim.h
index 936bb85..3cd253f 100644
--- a/ibsim/sim.h
+++ b/ibsim/sim.h
@@ -207,6 +207,7 @@ struct Port {
 	Node *remotenode;
 	int remoteport;
 	int errrate;
+	int nddrop;
 	Node *node;
 	Portcounters portcounters;
 	uint16_t *pkey_tbl;
diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index a6aab9d..0df87bd 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -191,6 +191,15 @@ static void port_change_lid(Port * port, int lid, int lmc)
 		port->remotenode->sw->portchange = 1;
 }
 
+#define TOGGLE_NDDROP(portptr) \
+		if (portptr->nddrop) \
+			portptr->nddrop = 0; \
+		else \
+			portptr->nddrop = 1; \
+		printf("Node Description Drop: %s port %d == %d\n", \
+			port->node->nodedesc, port->portnum, \
+			port->nddrop)
+
 static int do_seterror(FILE * f, char *line)
 {
 	Port *port, *e;
@@ -198,7 +207,7 @@ static int do_seterror(FILE * f, char *line)
 	char *s = line;
 	char *nodeid = 0, name[NAMELEN], *sp, *orig = 0;
 	int portnum = -1;	// def - all ports
-	int numports, set = 0, rate = 0;
+	int numports, set = 0, rate = 0, nddrop = -1;
 
 	if (strsep(&s, "\""))
 		orig = strsep(&s, "\"");
@@ -231,12 +240,18 @@ static int do_seterror(FILE * f, char *line)
 		return -1;
 	}
 
-	rate = strtoul(s, 0, 0);
-
-	if (rate > 100) {
-		fprintf(f, "# error rate must be in [0..100] range (%d)\n",
-			rate);
-		return -1;
+	/* Check for specific error requests */
+	if (strcmp(s, "nddrop")) {
+		nddrop = 1;
+		rate = -1;
+	} else {
+		rate = strtoul(s, 0, 0);
+		if (rate > 100) {
+			fprintf(f, "# error rate must be in [0..100] range (%d)\n",
+				rate);
+			return -1;
+		}
+		nddrop = -1;
 	}
 
 	DEBUG("error rate is %d", rate);
@@ -249,13 +264,21 @@ static int do_seterror(FILE * f, char *line)
 
 	if (portnum >= 0) {
 		port = ports + node->portsbase + portnum;
-		port->errrate = rate;
+		if (nddrop) {
+			TOGGLE_NDDROP(port);
+		} else {
+			port->errrate = rate;
+		}
 		return 1;
 	}
 
 	for (port = ports + node->portsbase, e = port + numports; port < e;
 	     port++) {
-		port->errrate = rate;
+		if (nddrop) {
+			TOGGLE_NDDROP(port);
+		} else {
+			port->errrate = rate;
+		}
 		set++;
 	}
 
@@ -708,7 +731,10 @@ 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>|nddrop]: set errors for port/node\n");
+	fprintf(f, "\t\t\t<error-rate> sets a random rate for all packets\n");
+	fprintf(f,
+		"\t\t\t\"nddrop\" Toggles the dropping of Node Description packets only\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..ac3321e 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -1188,6 +1188,14 @@ int process_packet(Client * cl, void *p, int size, Client ** dcl)
 		return sizeof(*r);	// forward only
 	}
 
+	/* check for node desc drop. */
+	if ((rpc.mgtclass == IB_SMI_CLASS || rpc.mgtclass == IB_SMI_DIRECT_CLASS) &&
+			rpc.attr.id == IB_ATTR_NODE_DESC &&
+			port->nddrop) {
+		VERB("drop pkt due to nddrop flag %d", port->nddrop);
+		goto _dropped;
+	}
+
 	if (port->errrate && (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