[Pkg-ofed-commits] r649 - in /branches/ofed-1.5lenny/ibsim/trunk: ./ debian/ ibs...

gmpc-guest at alioth.debian.org gmpc-guest at alioth.debian.org
Thu Feb 11 12:28:26 UTC 2010


Author: gmpc-guest
Date: Thu Feb 11 12:28:22 2010
New Revision: 649

URL: http://svn.debian.org/wsvn/pkg-ofed/?sc=1&rev=649
Log:
New upstream release

Modified:
    branches/ofed-1.5lenny/ibsim/trunk/debian/changelog
    branches/ofed-1.5lenny/ibsim/trunk/defs.mk
    branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec
    branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec.in
    branches/ofed-1.5lenny/ibsim/trunk/ibsim/ibsim.c
    branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim.h
    branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_cmd.c
    branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_mad.c
    branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_net.c
    branches/ofed-1.5lenny/ibsim/trunk/tests/mcast_storm.c
    branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.c
    branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.h
    branches/ofed-1.5lenny/ibsim/trunk/umad2sim/umad2sim.c

Modified: branches/ofed-1.5lenny/ibsim/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/debian/changelog?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/debian/changelog (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/debian/changelog Thu Feb 11 12:28:22 2010
@@ -1,3 +1,9 @@
+ibsim (0.5-0.1.g327c3d8-1) UNRELEASED; urgency=low
+
+  * New upstream release (OFED 1.5)
+
+ -- Guy Coates <gmpc at sanger.ac.uk>  Thu, 11 Feb 2010 12:27:29 +0000
+
 ibsim (0.5-1) unstable; urgency=low
 
   * Initial release (Closes: #539799)

Modified: branches/ofed-1.5lenny/ibsim/trunk/defs.mk
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/defs.mk?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/defs.mk (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/defs.mk Thu Feb 11 12:28:22 2010
@@ -13,15 +13,15 @@
 		$(prefix)/lib,$(prefix)/lib)))
 binpath:= $(if $(binpath),$(binpath),$(prefix)/bin)
 
-#IB_DEV_DIR:=$(HOME)/src/p
+#IB_DEV_DIR:=$(HOME)/src/m
 ifdef IB_DEV_DIR
- INCS:= $(foreach l, mad umad common, -I$(IB_DEV_DIR)/libib$(l)/include) \
+ INCS:= $(foreach l, mad umad, -I$(IB_DEV_DIR)/libib$(l)/include) \
   -I/usr/local/include
  LIBS:= \
-  $(foreach l, mad umad common, $(IB_DEV_DIR)/libib$(l)/.libs/libib$(l).so)
+  $(foreach l, mad umad, $(IB_DEV_DIR)/libib$(l)/.libs/libib$(l).so)
 else
  INCS:= -I$(dir $(libpath))/include
- LIBS:= -L$(libpath) -libmad -libumad -libcommon
+ LIBS:= -L$(libpath) -libmad -libumad
 endif
 
 CFLAGS += -Wall -g -fpic -I. -I../include $(INCS)

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec Thu Feb 11 12:28:22 2010
@@ -1,17 +1,17 @@
 
-%define RELEASE  1.ofed1.4
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
+%define RELEASE  0.1.g327c3d8
+%define rel %{?CUSTOM_RELEASE}%{!?CUSTOM_RELEASE:%RELEASE}
 
 Summary: InfiniBand fabric simulator for management
 Name: ibsim
 Version: 0.5
-Release: 1.ofed1.4
+Release: 0.1.g327c3d8
 License: GPLv2 or BSD
 Group: System Environment/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/ibsim-0.5.tar.gz
+Source: http://www.openfabrics.org/downloads/ibsim-0.5-0.1.g327c3d8.tar.gz
 Url: http://openfabrics.org/
-BuildRequires: libibmad-devel, libibcommon-devel, libibumad-devel
+BuildRequires: libibmad-devel, libibumad-devel
 
 %description
 ibsim provides simulation of infiniband fabric for using with OFA OpenSM, diagnostic and management tools.

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec.in
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec.in?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec.in (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim.spec.in Thu Feb 11 12:28:22 2010
@@ -1,6 +1,6 @@
 
 %define RELEASE @RELEASE@
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
+%define rel %{?CUSTOM_RELEASE}%{!?CUSTOM_RELEASE:%RELEASE}
 
 Summary: InfiniBand fabric simulator for management
 Name: ibsim
@@ -11,7 +11,7 @@
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Source: http://www.openfabrics.org/downloads/management/@TARBALL@
 Url: http://openfabrics.org/
-BuildRequires: libibmad-devel, libibcommon-devel, libibumad-devel
+BuildRequires: libibmad-devel, libibumad-devel
 
 %description
 ibsim provides simulation of infiniband fabric for using with OFA OpenSM, diagnostic and management tools.

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim/ibsim.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim/ibsim.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim/ibsim.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim/ibsim.c Thu Feb 11 12:28:22 2010
@@ -80,6 +80,7 @@
 static FILE *simout;
 static int listen_to_port = IBSIM_DEFAULT_SERVER_PORT;
 static int remote_mode = 0;
+static char* socket_basename;
 
 static size_t make_name(union name_t *name, uint32_t addr, unsigned short port,
 			const char *fmt, ...)
@@ -109,11 +110,10 @@
 
 static char *get_name(union name_t *name)
 {
-	if (remote_mode) {
+	if (remote_mode)
 		return inet_ntoa(name->name_i.sin_addr);
-	} else {
+	else
 		return name->name_u.sun_path + 1;
-	}
 }
 
 /**
@@ -237,7 +237,7 @@
 	}
 
 	size = make_name(&name, from->name_i.sin_addr.s_addr, id,
-			 "%s:in%d", SIM_BASENAME, id);
+			 "%s:in%d", socket_basename, id);
 
 	if (connect(cl->fd, (struct sockaddr *)&name, size) < 0)
 		IBPANIC("can't connect to in socket %s - fd %d client pid %d",
@@ -368,7 +368,6 @@
 	memcpy(ctl->data, port->pkey_tbl, size);
 	if (size < sizeof(ctl->data))
 		memset(ctl->data + size, 0, sizeof(ctl->data) - size);
-
 	return 0;
 }
 
@@ -606,7 +605,11 @@
 	fd_set rfds;
 	int i;
 
-	if (sim_init_conn(SIM_BASENAME) < 0)
+	socket_basename=getenv("IBSIM_SOCKNAME");
+	if(!socket_basename)
+		socket_basename = SIM_BASENAME;
+
+	if (sim_init_conn(socket_basename) < 0)
 		return -1;
 
 	while (!netstarted)
@@ -646,7 +649,7 @@
 			continue;
 		fprintf(out,
 			"Client %d: pid %d connected at \"%s\" port 0x%" PRIx64
-			", lid %d, qp %d %s\n", i, clients[i].pid,
+			", lid %u, qp %d %s\n", i, clients[i].pid,
 			clients[i].port->node->nodeid,
 			clients[i].port->portguid, clients[i].port->lid,
 			clients[i].qp, clients[i].issm ? "SM" : "");
@@ -715,6 +718,7 @@
 	extern void free_core(void);
 	char *outfname = 0, *netfile;
 	FILE *infile, *outfile;
+	int status;
 
 	static char const str_opts[] = "rf:dpvIsN:S:P:L:M:l:Vhu";
 	static const struct option long_opts[] = {
@@ -803,8 +807,9 @@
 		IBPANIC("not enough memory for core structure");
 
 	DEBUG("initializing net \"%s\"", netfile);
-	if (sim_init_net(netfile, outfile) < 0)
-		IBPANIC("sim_init failed");
+	status = sim_init_net(netfile, outfile);
+	if (status < 0)
+		IBPANIC("sim_init failed, status %d", status);
 
 	sim_init_console(outfile);
 

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim.h
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim.h?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim.h (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim.h Thu Feb 11 12:28:22 2010
@@ -35,7 +35,6 @@
 #ifndef __SIM_H__
 #define __SIM_H__
 
-#include <infiniband/common.h>
 #include <infiniband/mad.h>
 
 #define MAXNETNODES	2048
@@ -72,7 +71,7 @@
 #define MAXHOPS 16
 
 enum NODE_TYPES {
-	NO_NODE = 0,
+	NO_NODE,
 	HCA_NODE,
 	SWITCH_NODE,
 	ROUTER_NODE,
@@ -112,6 +111,7 @@
 	GS_PERF_RCV_BYTES_MASK = (1UL << 13),	// PORT_RCV_DATA
 	GS_PERF_XMT_PKTS_MASK = (1UL << 14),	// PORT_XMIT_PKTS
 	GS_PERF_RCV_PKTS_MASK = (1UL << 15),	// PORT_RCV_PKTS
+	GS_PERF_XMT_WAIT_MASK = (1UL << 16),	// PORT_XMIT_WAIT
 };
 
 enum GS_PC_EXT_SELECT_MASK {
@@ -142,6 +142,7 @@
 	GS_PERF_RCV_BYTES_LIMIT = 0xffffffff,
 	GS_PERF_XMT_PKTS_LIMIT = 0xffffffff,
 	GS_PERF_RCV_PKTS_LIMIT = 0xffffffff,
+	GS_PERF_XMT_WAIT_LIMIT = 0xffffffff,
 };
 
 typedef struct Port Port;
@@ -183,6 +184,7 @@
 	uint8_t errs_rcvconstraint;
 	uint16_t errs_rcvswitchrelay;
 	uint8_t errs_excessbufovrrun;
+	uint32_t xmt_wait;
 };
 
 struct Port {
@@ -198,8 +200,8 @@
 	int physstate;
 	int lmc;
 	int hoqlife;
+	uint8_t portinfo[64];
 	uint8_t op_vls;
-	uint8_t portinfo[64];
 
 	char remotenodeid[NODEIDLEN];
 	char remotealias[ALIASLEN + 1];
@@ -287,10 +289,10 @@
 
 // sim_mad.c
 int process_packet(Client * cl, void *p, int size, Client ** dcl);
-int send_trap(Port * port, int trapnum);
+int send_trap(Port * port, unsigned trapnum);
 
 extern Port *default_port;
-extern int simverb, modified;
+extern int simverb;
 extern int netstarted;
 
 #endif				/* __SIM_H__ */

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_cmd.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_cmd.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_cmd.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_cmd.c Thu Feb 11 12:28:22 2010
@@ -203,7 +203,8 @@
 			return -1;
 		}
 
-		rport = node_get_port(lport->previous_remotenode, lport->previous_remoteport);
+		rport = node_get_port(lport->previous_remotenode,
+				      lport->previous_remoteport);
 
 		if (link_ports(lport, rport) < 0)
 			return -fprintf(f,
@@ -220,7 +221,8 @@
 		if (!lport->previous_remotenode)
 			continue; 
 
-		rport = node_get_port(lport->previous_remotenode, lport->previous_remoteport);
+		rport = node_get_port(lport->previous_remotenode,
+				      lport->previous_remoteport);
 
 		if (link_ports(lport, rport) < 0)
 			continue;
@@ -541,7 +543,7 @@
 			PORTSTATE(port->state), PHYSSTATE(port->physstate),
 			comment);
 	else
-		fprintf(f, "\t lid %d lmc %d smlid %d %s %s %s/%s%s\n",
+		fprintf(f, "\t lid %u lmc %d smlid %u %s %s %s/%s%s\n",
 			port->lid, port->lmc, port->smlid,
 			PORTLINKWIDTH(port->linkwidth),
 			PORTLINKSPEED(port->linkspeed),
@@ -578,9 +580,8 @@
 			nports++;
 			dump_switch(f, node->sw);
 		}
-		for (i = 0; i < nports; i++) {
+		for (i = 0; i < nports; i++)
 			dump_port(f, ports + node->portsbase + i, node->type);
-		}
 		nnodes++;
 	}
 
@@ -714,7 +715,7 @@
 	node = fromport->node;
 	port = fromport;
 	portnum = port->portnum;
-	fprintf(f, "From node \"%s\" port %d lid %d\n", node->nodeid, portnum,
+	fprintf(f, "From node \"%s\" port %d lid %u\n", node->nodeid, portnum,
 		from);
 	while (maxhops--) {
 		if (port->state != 4)
@@ -749,7 +750,7 @@
 		fprintf(f, "no route found after %d hops\n", MAXHOPS);
 		return -1;
 	}
-	fprintf(f, "To node \"%s\" port %d lid %d\n", node->nodeid, portnum,
+	fprintf(f, "To node \"%s\" port %d lid %u\n", node->nodeid, portnum,
 		to);
 	return 0;
 
@@ -856,7 +857,7 @@
 		cmd_len++;
 
 	if (*line == '#')
-		fprintf(f, line);
+		fprintf(f, "%s", line);
 	else if (*line == '!')
 		r = sim_cmd_file(f, line);
 	else if (!strncasecmp(line, "Dump", cmd_len))

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_mad.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_mad.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_mad.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_mad.c Thu Feb 11 12:28:22 2010
@@ -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.
  *
@@ -58,7 +59,7 @@
 
 static Smpfn do_nodeinfo, do_nodedesc, do_switchinfo, do_portinfo,
     do_linearforwtbl, do_multicastforwtbl, do_portcounters, do_extcounters,
-    do_pkeytbl, do_sl2vl, do_vlarb, do_guidinfo, do_nothing;
+    do_pkeytbl, do_sl2vl, do_vlarb, do_guidinfo, do_cpi;
 
 static EncodeTrapfn encode_trap128;
 static EncodeTrapfn encode_trap144;
@@ -78,14 +79,13 @@
 
 			[IB_ATTR_LAST] 0,
 			},
-	[IB_PERFORMANCE_CLASS] {[CLASS_PORT_INFO] = do_nothing,
+	[IB_PERFORMANCE_CLASS] {[CLASS_PORT_INFO] = do_cpi,
 				[IB_GSI_PORT_SAMPLES_CONTROL] = 0,
 				[IB_GSI_PORT_SAMPLES_RESULT] = 0,
 				[IB_GSI_PORT_COUNTERS] = do_portcounters,
 				[IB_GSI_PORT_COUNTERS_EXT] = do_extcounters,
 
 				[IB_GSI_ATTR_LAST] 0,
-
 				},
 };
 
@@ -94,7 +94,6 @@
 	[TRAP_144] encode_trap144,
 
 	[TRAP_NUM_LAST] 0,
-
 };
 
 extern Node *nodes;
@@ -219,16 +218,25 @@
 	return 0;
 }
 
-static int do_nothing(Port * port, unsigned op, uint32_t mod, uint8_t * data)
-{
-	return 0;
+static int do_cpi(Port * port, unsigned op, uint32_t mod, uint8_t * data)
+{
+	int status = 0;
+
+	if (op != IB_MAD_METHOD_GET)
+		status = ERR_METHOD_UNSUPPORTED;
+	memset(data, 0, IB_SMP_DATA_SIZE);
+	mad_set_field(data, 0, IB_CPI_BASEVER_F, 1);
+	mad_set_field(data, 0, IB_CPI_CLASSVER_F, 1);
+	mad_set_field(data, 0, IB_CPI_CAPMASK_F, 0x300);
+	mad_set_field(data, 0, IB_CPI_RESP_TIME_VALUE_F, 0x12);
+	return status;
 }
 
 static int do_nodedesc(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 {
 	int status = 0;
 
-	if (op != 1)		// get
+	if (op != IB_MAD_METHOD_GET)
 		status = ERR_METHOD_UNSUPPORTED;
 	memcpy(data, port->node->nodedesc, IB_SMP_DATA_SIZE);
 
@@ -241,7 +249,7 @@
 	int status = 0;
 	uint64_t portguid = node->nodeguid + port->portnum;
 
-	if (op != IB_MAD_METHOD_GET)	// get
+	if (op != IB_MAD_METHOD_GET)
 		status = ERR_METHOD_UNSUPPORTED;
 	memcpy(data, node->nodeinfo, IB_SMP_DATA_SIZE);
 
@@ -261,7 +269,7 @@
 	if (!sw)		// not a Switch?
 		return ERR_ATTR_UNSUPPORTED;
 
-	if (op == 2) {		// Set
+	if (op == IB_MAD_METHOD_SET) {
 		if (mad_get_field(data, 0, IB_SW_STATE_CHANGE_F))
 			sw->portchange = 0;
 		sw->linearFDBtop =
@@ -327,11 +335,10 @@
 
 	sl2vl = port->sl2vl + 8 * n;
 
-	if (op == IB_MAD_METHOD_SET) {
+	if (op == IB_MAD_METHOD_SET)
 		memcpy(sl2vl, data, 8);
-	} else {
+	else
 		memcpy(data, sl2vl, 8);
-	}
 
 	return 0;
 }
@@ -366,10 +373,10 @@
 
 	size *= sizeof(*vlarb);
 
-	if (op == IB_MAD_METHOD_SET) {
+	if (op == IB_MAD_METHOD_SET)
 		memcpy(vlarb, data, size);
-	} else {
-		memset(data, 0, 64);
+	else {
+		memset(data, 0, IB_SMP_DATA_SIZE);
 		memcpy(data, vlarb, size);
 	}
 
@@ -385,7 +392,7 @@
 	if (op != IB_MAD_METHOD_GET)    // only get currently supported (non compliant)
 		status = ERR_METHOD_UNSUPPORTED;
 
-	memset(data, 0, 64);
+	memset(data, 0, IB_SMP_DATA_SIZE);
 	if (mod == 0) {
 		if (node->type == SWITCH_NODE)
 			mad_encode_field(data, IB_GUID_GUID0_F, &node->nodeguid);
@@ -413,7 +420,7 @@
 	DEBUG("in node %" PRIx64 " port %" PRIx64 ": port %" PRIx64 " (%d(%d))",
 	      node->nodeguid, port->portguid, p->portguid, p->portnum, portnum);
 
-	if (op == IB_MAD_METHOD_SET) {	// set
+	if (op == IB_MAD_METHOD_SET) {
 		unsigned val;
 		if (node->type != SWITCH_NODE && port->portnum != p->portnum)
 			return ERR_BAD_PARAM;	// on HCA or rtr can't "set" on other port
@@ -459,7 +466,7 @@
 			if (p->lid > 0 && p->lid < maxlinearcap
 			    && lids[p->lid] != p && lids[p->lid])
 				IBWARN
-				    ("Port %s:%d overwrite lid table entry for lid %d (was %s:%d)",
+				    ("Port %s:%d overwrite lid table entry for lid %u (was %s:%d)",
 				     node->nodeid, p->portnum, p->lid,
 				     lids[p->lid]->node->nodeid,
 				     lids[p->lid]->portnum);
@@ -473,6 +480,7 @@
 
 	update_portinfo(p);
 	memcpy(data, p->portinfo, IB_SMP_DATA_SIZE);
+	mad_set_field(data, 0, IB_PORT_LOCAL_PORT_F, port->portnum);
 
 	return 0;
 }
@@ -488,10 +496,9 @@
 	if (mod < 0 || mod > 767)
 		return ERR_BAD_PARAM;
 
-	if (op == IB_MAD_METHOD_SET) {	// Set
+	if (op == IB_MAD_METHOD_SET)
 		mad_get_array(data, 0, IB_LINEAR_FORW_TBL_F,
 			      sw->fdb + mod * 64);
-	}
 
 	mad_set_array(data, 0, IB_LINEAR_FORW_TBL_F, sw->fdb + mod * 64);
 
@@ -518,16 +525,15 @@
 	}
 
 	blockposition = (numBlock32 * NUMBEROFPORTMASK + numPortMsk) * 64;
-	if (op == IB_MAD_METHOD_SET) {	// Set
+	if (op == IB_MAD_METHOD_SET)
 		mad_get_array(data, 0, IB_MULTICAST_FORW_TBL_F,
 			      sw->mfdb + blockposition);
-	}
 	mad_set_array(data, 0, IB_MULTICAST_FORW_TBL_F,
 		      sw->mfdb + blockposition);
 	return 0;
 }
 
-static void pc_reset(Portcounters * pc, uint mask)
+static void pc_reset(Portcounters * pc, unsigned mask)
 {
 	if (mask & GS_PERF_ERR_SYM_MASK)
 		pc->errs_sym = 0;
@@ -561,6 +567,8 @@
 		pc->flow_xmt_pkts = 0;
 	if (mask & GS_PERF_RCV_PKTS_MASK)
 		pc->flow_rcv_pkts = 0;
+	if (mask & GS_PERF_XMT_WAIT_MASK)
+		pc->xmt_wait = 0;
 }
 
 static inline uint32_t addval(uint32_t val, uint32_t delta, uint32_t max)
@@ -603,7 +611,7 @@
 	uint32_t madsize_div_4 = 72;	//real data divided by 4
 
 	if (*srcport != destport) {
-		//PKT get out of port ..
+		//PKT got out of port ..
 		srcpc->flow_xmt_pkts =
 		    addval(srcpc->flow_xmt_pkts, 1, GS_PERF_XMT_PKTS_LIMIT);
 		srcpc->flow_xmt_bytes =
@@ -619,7 +627,7 @@
 			VERB("drop pkt due error rate %d", destport->errrate);
 			return 0;
 		}
-		//PKT get in to the port ..
+		//PKT got into the port ..
 		destpc->flow_rcv_pkts =
 		    addval(destpc->flow_rcv_pkts, 1, GS_PERF_RCV_PKTS_LIMIT);
 		destpc->flow_rcv_bytes =
@@ -635,6 +643,9 @@
 
 static void pc_sum(Portcounters * totals, Portcounters * pc)
 {
+	totals->xmt_wait =
+	    addval(totals->xmt_wait, pc->xmt_wait,
+		   GS_PERF_XMT_WAIT_LIMIT);
 	totals->flow_xmt_pkts =
 	    addval(totals->flow_xmt_pkts, pc->flow_xmt_pkts,
 		   GS_PERF_XMT_PKTS_LIMIT);
@@ -685,6 +696,7 @@
 
 static void pc_get(Portcounters * pc, uint8_t * data)
 {
+	mad_set_field(data, 0, IB_PC_XMT_WAIT_F, pc->xmt_wait);
 	mad_set_field(data, 0, IB_PC_XMT_PKTS_F, pc->flow_xmt_pkts);
 	mad_set_field(data, 0, IB_PC_XMT_BYTES_F, pc->flow_xmt_bytes);
 	mad_set_field(data, 0, IB_PC_RCV_PKTS_F, pc->flow_rcv_pkts);
@@ -710,7 +722,7 @@
 	Node *node = port->node;
 	int portnum = mad_get_field(data, 0, IB_PC_PORT_SELECT_F);
 	Portcounters totals;
-	uint mask;
+	unsigned mask, mask2;
 	Port *p;
 	int i;
 
@@ -725,6 +737,9 @@
 	      node->nodeguid, port->portguid, portnum);
 
 	mask = mad_get_field(data, 0, IB_PC_COUNTER_SELECT_F);
+	mask2 = mad_get_field(data, 0, IB_PC_COUNTER_SELECT2_F);
+	if (mask2)
+		mask |= GS_PERF_XMT_WAIT_MASK;
 
 	if (portnum != 0xff) {
 		if (!(p = node_get_port(node, portnum)))
@@ -740,13 +755,10 @@
 	memset(&totals, 0, sizeof totals);
 
 	for (i = 0; i <= node->numports; i++) {
-
 		if (!(p = node_get_port(node, i)))
 			return ERR_BAD_PARAM;
-
 		if (op == IB_MAD_METHOD_SET)
 			pc_reset(&p->portcounters, mask);
-
 		pc_sum(&totals, &p->portcounters);
 	}
 
@@ -766,7 +778,7 @@
 	ADDVAL64(total->ext_mcast_recv, pc->ext_mcast_recv);
 }
 
-static void pc_ext_reset(Portcounters * pc, uint mask)
+static void pc_ext_reset(Portcounters * pc, unsigned mask)
 {
 	if (mask & GS_PC_EXT_XMIT_DATA)
 		pc->ext_xmit_data = 0;
@@ -851,7 +863,7 @@
 	int i;
 
 	if (0 && lid != -1) {
-		sprintf(buf, "lid 0x%x", lid);
+		sprintf(buf, "lid %u", lid);
 		return buf;
 	}
 	for (i = 0; i < path->cnt + 1; i++) {
@@ -870,12 +882,12 @@
 {
 	int outport;
 
-	DEBUG("node 0x%" PRIx64 " lid %d", node->nodeguid, lid);
+	DEBUG("node 0x%" PRIx64 " lid %u", node->nodeguid, lid);
 	if (!node->sw)
 		return -1;
 
 	if (lid > node->sw->linearFDBtop || (outport = node->sw->fdb[lid]) < 0) {
-		IBWARN("sw guid %" PRIx64 ": bad lid %d", node->nodeguid, lid);
+		IBWARN("sw guid %" PRIx64 ": bad lid %u", node->nodeguid, lid);
 		return -1;
 	}
 
@@ -895,7 +907,7 @@
 
 static int is_port_lid(Port * port, int lid)
 {
-	DEBUG("port 0x%" PRIx64 " lid %d lmc %d target lid %d",
+	DEBUG("port 0x%" PRIx64 " lid %u lmc %d target lid %u",
 	      port->portguid, port->lid, port->lmc, lid);
 	if (lid < port->lid || lid > port->lid + (1 << port->lmc) - 1)
 		return 0;
@@ -929,7 +941,7 @@
 	Node *node = port->node;
 	Port *tport = port;
 
-	DEBUG("Node %" PRIx64 " port %" PRIx64 " (%d) lid %d",
+	DEBUG("Node %" PRIx64 " port %" PRIx64 " (%d) lid %u",
 	      node->nodeguid, port->portguid, port->portnum, lid);
 
 	if (lid == 0) {
@@ -955,7 +967,7 @@
 
 		if (portnum < 0 || portnum > node->numports) {
 			pc_add_error_rcvswitchrelay(port);
-			DEBUG("illegal lid %d (outport %d node %s ports %d)",
+			DEBUG("illegal lid %u (outport %d node %s ports %d)",
 			      lid, portnum, node->nodeid, node->numports);
 			return 0;
 		}
@@ -1108,9 +1120,7 @@
 	    direct_route_out_MAD(port, path);
 }
 
-int modified;
-
-Smpfn *get_handle_fn(ib_rpc_t rpc, int response)
+static Smpfn *get_handle_fn(ib_rpc_t rpc, int response)
 {
 	Smpfn *fn;
 
@@ -1120,14 +1130,14 @@
 	if (rpc.mgtclass == IB_SMI_CLASS || rpc.mgtclass == IB_SMI_DIRECT_CLASS) {
 		if (rpc.attr.id >= IB_ATTR_LAST
 		    || !(fn = attrs[rpc.mgtclass & 0xf][rpc.attr.id]))
-			return 0;	// not supported attribute ???
+			return 0;	// attribute/method not supported ???
 		return fn;
 	}
 
 	if (rpc.mgtclass == IB_PERFORMANCE_CLASS) {
 		if (rpc.attr.id >= IB_GSI_ATTR_LAST
 		    || !(fn = attrs[rpc.mgtclass & 0xf][rpc.attr.id]))
-			return 0;	// not supported attribute ???
+			return 0;	// attribute/method not supported ???
 		return fn;
 	}
 
@@ -1161,13 +1171,13 @@
 		return -1;
 
 	if (rpc.method == 0x7) {
-		IBWARN("got trap repress - drop");
+		IBWARN("lid %u got trap repress - dropping", ntohs(r->dlid));
 		*dcl = 0;
 		return 0;
 	}
 
 	if (!(port = route_MAD(cl->port, response, ntohs(r->dlid), &path))) {
-		IBWARN("routing failed: no route to dest lid %d path %s",
+		IBWARN("routing failed: no route to dest lid %u path %s",
 		       ntohs(r->dlid), pathstr(0, &path));
 		goto _dropped;
 	}
@@ -1198,9 +1208,6 @@
 	if ((status = fn(port, rpc.method, rpc.attr.mod, data)) < 0)
 		goto _dropped;
 
-	if (rpc.method == 2)
-		modified++;
-
 	reply_MAD(r->mad, &rpc, &path, status, data);
 
 	tlid = r->dlid;
@@ -1231,7 +1238,7 @@
 	if (port->node->type != SWITCH_NODE)
 		return -1;
 	if (!port->lid || !port->smlid) {
-		VERB("switch trap 128 for lid %d with smlid %d",
+		VERB("switch trap 128 for lid %u with smlid %u",
 		     port->lid, port->smlid);
 		return -1;
 	}
@@ -1251,7 +1258,7 @@
 static int encode_trap144(Port * port, char *data)
 {
 	if (!port->lid || !port->smlid) {
-		VERB("switch trap 144 for lid %d with smlid %d",
+		VERB("switch trap 144 for lid %u with smlid %u",
 		     port->lid, port->smlid);
 		return -1;
 	}
@@ -1281,27 +1288,28 @@
 	return 0;
 }
 
-int send_trap(Port * port, int trapnum)
+int send_trap(Port * port, unsigned trapnum)
 {
 	struct sim_request req;
 	Client *cl;
 	int ret, lid = port->lid;
 	char *data = req.mad + 64;	/* data offset */
-	EncodeTrapfn *encode_trapfn = encodetrap[trapnum];
+	EncodeTrapfn *encode_trapfn;
 	Port *destport;
 
-	if (!encode_trapfn) {
+	if (trapnum >= TRAP_NUM_LAST) {
 		IBWARN("trap number %d not supported", trapnum);
 		return -1;
 	}
 
+	encode_trapfn = encodetrap[trapnum];
 	memset(req.mad, 0, sizeof(req.mad));
 	encode_trap_header(req.mad);
 	if (encode_trapfn(port, data) < 0)
 		return -1;
 
 	if (!(destport = lid_route_MAD(port, port->smlid))) {
-		IBWARN("routing failed: no route to dest lid %d", port->smlid);
+		IBWARN("routing failed: no route to dest lid %u", port->smlid);
 		return -1;
 	}
 

Modified: branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_net.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_net.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_net.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/ibsim/sim_net.c Thu Feb 11 12:28:22 2010
@@ -67,7 +67,7 @@
 static const uint8_t smaport[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x48,
+	0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48,
 	0x00, 0x00, 0x0F, 0xF9, 0x00, 0x03, 0x03, 0x01,
 	0x14, 0x52, 0x00, 0x11, 0x10, 0x40, 0x00, 0x08,
 	0x08, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
@@ -80,7 +80,7 @@
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x02,
-	0x14, 0x52, 0x00, 0x11, 0x40, 0x40, 0x00, 0x08,
+	0x12, 0x52, 0x00, 0x11, 0x40, 0x40, 0x00, 0x08,
 	0x08, 0x04, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -100,9 +100,9 @@
 static const uint8_t hcaport[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x02, 0x00, 0x01, 0x00, 0x50, 0x02, 0x48,
+	0x00, 0x02, 0x00, 0x01, 0x00, 0x50, 0x00, 0x48,
 	0x00, 0x00, 0x0F, 0xF9, 0x01, 0x03, 0x03, 0x02,
-	0x14, 0x52, 0x00, 0x11, 0x40, 0x40, 0x00, 0x08,
+	0x12, 0x52, 0x00, 0x11, 0x40, 0x40, 0x00, 0x08,
 	0x08, 0x04, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -111,7 +111,7 @@
 static const uint8_t hcaport_down[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x02, 0x00, 0x01, 0x00, 0x10, 0x02, 0x48,
+	0x00, 0x02, 0x00, 0x01, 0x00, 0x10, 0x00, 0x48,
 	0x00, 0x00, 0x0F, 0xF9, 0x01, 0x03, 0x03, 0x01,
 	0x11, 0x22, 0x00, 0x11, 0x40, 0x40, 0x00, 0x08,
 	0x08, 0x04, 0xE9, 0x10, 0x00, 0x00, 0x00, 0x00,
@@ -322,6 +322,8 @@
 		guids[type]++;	// reserve single guid;
 	} else {
 		memcpy(nd->nodeinfo, hcanodeinfo, sizeof(nd->nodeinfo));
+		if (type == ROUTER_NODE)
+			mad_set_field(nd->nodeinfo, 0, IB_NODE_TYPE_F, ROUTER_NODE);
 		guids[type] += nodeports + 1;	// reserve guids;
 	}
 
@@ -403,7 +405,7 @@
 
 static int is_linkspeed_valid(int speed)
 {
-	/* speed is 2.5G, 5.0G, or 10.0 G */
+	/* speed is 2.5G, 5.0G, or 10.0G */
 	if (speed < 1 || speed > 7) {
 		IBWARN("bad speed %d - should be between 1 to 7", speed);
 		return 0;
@@ -1114,7 +1116,7 @@
 	rport->remoteport = lport->portnum;
 	set_portinfo(rport, rnode->type == SWITCH_NODE ? swport : hcaport);
 	memcpy(rport->remotenodeid, lnode->nodeid, sizeof(rport->remotenodeid));
-	lport->state = rport->state = 2;	// Initialilze
+	lport->state = rport->state = 2;	// Initialize
 	lport->physstate = rport->physstate = 5;	// LinkUP
 	if (lnode->sw)
 		lnode->sw->portchange = 1;

Modified: branches/ofed-1.5lenny/ibsim/trunk/tests/mcast_storm.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/tests/mcast_storm.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/tests/mcast_storm.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/tests/mcast_storm.c Thu Feb 11 12:28:22 2010
@@ -57,39 +57,76 @@
 	ib_portid_t dport;
 };
 
+struct mcmember_params {
+	uint32_t qkey;
+	uint16_t mlid;
+	uint8_t mtu;
+	uint8_t tclass;
+	uint16_t pkey;
+	uint8_t rate;
+	uint8_t sl;
+	uint32_t flow_label;
+	uint8_t hop_limit;
+	uint8_t scope;
+	uint8_t join_state;
+	uint8_t proxy_join;
+};
+
+static const struct mcmember_params mcmember_params_join = {
+	.join_state = 1,
+};
+
+static const struct mcmember_params mcmember_params_create = {
+	.qkey = 0x80010000,
+	.mtu = 4,
+	.tclass = 0,
+	.pkey = 0xffff,
+	.rate = 3,
+	.sl = 0,
+	.flow_label = 0,
+	.join_state = 1,
+};
+
 static ibmad_gid_t mgid_ipoib = {
 	0xff, 0x12, 0x40, 0x1b, 0xff, 0xff, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
 };
 
-uint64_t build_mcm_rec(uint8_t * data, ibmad_gid_t mgid, ibmad_gid_t port_gid,
-		       uint8_t join_state)
-{
-	memset(data, 0, IB_SA_DATA_SIZE);
+static int64_t add_rid(uint8_t *data, ibmad_gid_t mgid, ibmad_gid_t port_gid)
+{
 	mad_set_array(data, 0, IB_SA_MCM_MGID_F, mgid);
 	mad_set_array(data, 0, IB_SA_MCM_PORTGID_F, port_gid);
-	mad_set_field(data, 0, IB_SA_MCM_JOIN_STATE_F, join_state);
-
-	return IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
-	    IB_MCR_COMPMASK_JOIN_STATE;
-}
-
-uint64_t build_mcm_create_rec(uint8_t * data, ibmad_gid_t mgid,
-			      ibmad_gid_t port_gid, uint8_t join_state)
-{
-	uint64_t comp_mask = build_mcm_rec(data, mgid, port_gid, join_state);
-
-	mad_set_field(data, 0, IB_SA_MCM_QKEY_F, 0x80010000);
-	mad_set_field(data, 0, IB_SA_MCM_SL_F, 0);
-	mad_set_field(data, 0, IB_SA_MCM_MTU_F, 4);
-	mad_set_field(data, 0, IB_SA_MCM_RATE_F, 3);
-	mad_set_field(data, 0, IB_SA_MCM_TCLASS_F, 0);
-	mad_set_field(data, 0, IB_SA_MCM_PKEY_F, 0xffff);
-	mad_set_field(data, 0, IB_SA_MCM_FLOW_LABEL_F, 0);
-
-	return comp_mask | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_SL |
-	    IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_PKEY |
-	    IB_MCR_COMPMASK_TCLASS | IB_MCR_COMPMASK_FLOW;
+
+	return IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID;
+}
+
+static uint64_t build_mcm_rec(uint8_t * data, const struct mcmember_params *p)
+{
+#define SET_FIELD(val, mask, field) \
+	if (val) { \
+		mad_set_field(data, 0, field, val); \
+		comp_mask |= mask; \
+	}
+
+	uint64_t comp_mask = 0;
+
+	memset(data, 0, IB_SA_DATA_SIZE);
+
+	if (!p)
+		return comp_mask;
+
+	SET_FIELD(p->qkey, IB_MCR_COMPMASK_QKEY, IB_SA_MCM_QKEY_F);
+	SET_FIELD(p->mlid, IB_MCR_COMPMASK_MLID, IB_SA_MCM_MLID_F);
+	SET_FIELD(p->mtu, IB_MCR_COMPMASK_MTU, IB_SA_MCM_MTU_F);
+	SET_FIELD(p->tclass, IB_MCR_COMPMASK_TCLASS, IB_SA_MCM_TCLASS_F);
+	SET_FIELD(p->pkey, IB_MCR_COMPMASK_PKEY, IB_SA_MCM_PKEY_F);
+	SET_FIELD(p->rate, IB_MCR_COMPMASK_RATE, IB_SA_MCM_RATE_F);
+	SET_FIELD(p->sl, IB_MCR_COMPMASK_SL, IB_SA_MCM_SL_F);
+	SET_FIELD(p->flow_label, IB_MCR_COMPMASK_FLOW, IB_SA_MCM_FLOW_LABEL_F);
+	SET_FIELD(p->join_state, IB_MCR_COMPMASK_JOIN_STATE, IB_SA_MCM_JOIN_STATE_F);
+	SET_FIELD(p->proxy_join, IB_MCR_COMPMASK_PROXY, IB_SA_MCM_PROXY_JOIN_F);
+
+	return comp_mask;
 }
 
 static void build_mcm_rec_umad(void *umad, ib_portid_t * dport, int method,
@@ -155,46 +192,29 @@
 	return 1;
 }
 
-static int send_create(struct addr_data *a, uint8_t * umad, int len,
-		       ibmad_gid_t mgid, ibmad_gid_t port_gid)
-{
-	uint8_t data[IB_SA_DATA_SIZE];
-	uint64_t comp_mask;
-
-	comp_mask = build_mcm_create_rec(data, mgid, port_gid, 1);
+static int send_join(struct addr_data *a, uint8_t * umad, int len,
+		     ibmad_gid_t mgid, ibmad_gid_t port_gid,
+		     uint64_t comp_mask, uint8_t data[])
+{
+	comp_mask |= add_rid(data, mgid, port_gid);
 
 	return send_req(a, umad, len, IB_MAD_METHOD_SET, comp_mask, data);
 }
 
-static int send_join(struct addr_data *a, uint8_t * umad, int len,
-		     ibmad_gid_t mgid, ibmad_gid_t port_gid)
-{
-	uint8_t data[IB_SA_DATA_SIZE];
-	uint64_t comp_mask;
-
-	comp_mask = build_mcm_rec(data, mgid, port_gid, 1);
-
-	return send_req(a, umad, len, IB_MAD_METHOD_SET, comp_mask, data);
-}
-
 static int send_leave(struct addr_data *a, uint8_t * umad, int len,
-		      ibmad_gid_t mgid, ibmad_gid_t port_gid)
-{
-	uint8_t data[IB_SA_DATA_SIZE];
-	uint64_t comp_mask;
-
-	comp_mask = build_mcm_rec(data, mgid, port_gid, 1);
+		      ibmad_gid_t mgid, ibmad_gid_t port_gid,
+		      uint64_t comp_mask, uint8_t data[])
+{
+	comp_mask |= add_rid(data, mgid, port_gid);
 
 	return send_req(a, umad, len, IB_MAD_METHOD_DELETE, comp_mask, data);
 }
 
 static int send_query(struct addr_data *a, uint8_t * umad, int len,
-		      ibmad_gid_t mgid, ibmad_gid_t port_gid)
-{
-	uint8_t data[IB_SA_DATA_SIZE];
-	uint64_t comp_mask;
-
-	comp_mask = build_mcm_rec(data, mgid, port_gid, 1);
+		      ibmad_gid_t mgid, ibmad_gid_t port_gid,
+		      uint64_t comp_mask, uint8_t data[])
+{
+	comp_mask |= add_rid(data, mgid, port_gid);
 
 	return send_req(a, umad, len, IB_MAD_METHOD_GET, comp_mask, data);
 }
@@ -236,59 +256,31 @@
 }
 
 static int rereg_port(struct addr_data *a, uint8_t * umad, int len,
-		      ibmad_gid_t mgid, struct gid_list *list)
-{
-	if (send_leave(a, umad, len, mgid, list->gid))
+		      ibmad_gid_t mgid, struct gid_list *list,
+		      uint64_t comp_mask, uint8_t data[])
+{
+	if (send_leave(a, umad, len, mgid, list->gid, comp_mask, data))
 		return -1;
 
-	if (send_join(a, umad, len, mgid, list->gid))
+	if (send_join(a, umad, len, mgid, list->gid, comp_mask, data))
 		return -1;
+
 	list->trid = mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F);
 
 	return 0;
 }
 
-static int rereg_send_all(struct addr_data *a, ibmad_gid_t mgid,
-			  struct gid_list *list, unsigned cnt)
-{
-	uint8_t *umad;
-	int len = 256;
-	int i;
-
-	info("%s:... cnt = %u\n", __func__, cnt);
-
-	umad = calloc(1, len + umad_size());
-	if (!umad) {
-		err("cannot alloc mem for umad: %s\n", strerror(errno));
-		return -1;
-	}
-
-	for (i = 0; i < cnt; i++)
-		rereg_port(a, umad, len, mgid, &list[i]);
-
-	info("%s: sent %u requests\n", __func__, cnt * 2);
-
-	free(umad);
-
-	return 0;
-}
-
-static int rereg_recv_all(struct addr_data *a, ibmad_gid_t mgid,
-			  struct gid_list *list, unsigned cnt)
-{
-	uint8_t *umad, *mad;
-	int len = 256;
+static int rereg_recv_all(struct addr_data *a, void *umad, int len,
+			  ibmad_gid_t mgid,
+			  struct gid_list *list, unsigned cnt,
+			  uint64_t comp_mask, uint8_t data[])
+{
+	uint8_t *mad;
 	uint64_t trid;
 	unsigned n, method, status;
 	int i;
 
 	info("%s...\n", __func__);
-
-	umad = calloc(1, len + umad_size());
-	if (!umad) {
-		err("cannot alloc mem for umad: %s\n", strerror(errno));
-		return -1;
-	}
 
 	n = 0;
 	while (recv_res(a, umad, len) > 0) {
@@ -316,34 +308,30 @@
 			info("guid 0x%016" PRIx64
 			     ": method = %x status = %x. Resending\n",
 			     get_guid_ho(list[i].gid), method, status);
-			rereg_port(a, umad, len, mgid, &list[i]);
+			rereg_port(a, umad, len, mgid, &list[i],
+				   comp_mask, data);
 		}
 	}
 
 	info("%s: got %u responses\n", __func__, n);
 
-	free(umad);
 	return 0;
 }
 
-static int rereg_query_all(struct addr_data *a, ibmad_gid_t mgid,
-			   struct gid_list *list, unsigned cnt)
-{
-	uint8_t *umad, *mad;
-	int len = 256;
+static int rereg_query_all(struct addr_data *a, void *umad, int len,
+			   ibmad_gid_t mgid,
+			   struct gid_list *list, unsigned cnt,
+			   uint64_t comp_mask, uint8_t data[])
+{
+	uint8_t *mad;
 	unsigned method, status;
 	int i, ret;
 
 	info("%s...\n", __func__);
 
-	umad = calloc(1, len + umad_size());
-	if (!umad) {
-		err("cannot alloc mem for umad: %s\n", strerror(errno));
-		return -1;
-	}
-
 	for (i = 0; i < cnt; i++) {
-		ret = send_query(a, umad, len, mgid, list[i].gid);
+		ret = send_query(a, umad, len, mgid, list[i].gid,
+				 comp_mask, data);
 		if (ret < 0) {
 			err("%s: rereg_send failed.\n", __func__);
 			continue;
@@ -367,7 +355,6 @@
 
 	info("%s: %u queried.\n", __func__, cnt);
 
-	free(umad);
 	return 0;
 }
 
@@ -378,33 +365,18 @@
 	struct gid_list *gids;
 	unsigned mgids_size;
 	struct gid_list *mgids;
+	const struct mcmember_params *params;
 };
 
 #define MAX_CLIENTS 100
 
 static int run_port_rereg_test(struct addr_data *a, struct test_data *td)
 {
-	int cnt, i, size = td->gids_size;
-
-	for (cnt = size; cnt;) {
-		i = cnt > MAX_CLIENTS ? MAX_CLIENTS : cnt;
-		rereg_send_all(a, td->mgids[0].gid, td->gids + (size - cnt), i);
-		rereg_recv_all(a, td->mgids[0].gid, td->gids, size);
-		cnt -= i;
-	}
-
-	rereg_query_all(a, td->mgids[0].gid, td->gids, size);
-
-	return 0;
-}
-
-static int run_mcast_joins_test(struct addr_data *a, struct test_data *td)
-{
+	uint8_t data[256];
+	uint64_t comp_mask;
 	uint8_t *umad;
 	int len = 256;
-	unsigned i, j;
-
-	info("%s...\n", __func__);
+	int cnt, i, n, size = td->gids_size;
 
 	umad = calloc(1, len + umad_size());
 	if (!umad) {
@@ -412,27 +384,42 @@
 		return -1;
 	}
 
-	for (i = 0; i < td->gids_size; i++)
-		for (j = 0; j < td->mgids_size; j++)
-			if (send_create(a, umad, len,
-					td->mgids[j].gid, td->gids[i].gid))
-				return -1;
-
-	if (recv_all(a, umad, len) < 0)
-		return -1;
+	if (!td->params)
+		td->params = &mcmember_params_join;
+
+	comp_mask = build_mcm_rec(data, td->params);
+
+	for (cnt = size; cnt;) {
+		n = cnt > MAX_CLIENTS ? MAX_CLIENTS : cnt;
+		for (i = 0; i < n; i++) {
+			rereg_port(a, umad, len, td->mgids[0].gid,
+				   &td->gids[size - cnt + i], comp_mask, data);
+			info("%s: sent %u requests\n", __func__, n * 2);
+		}
+		rereg_recv_all(a, umad, len, td->mgids[0].gid, td->gids, size,
+			       comp_mask, data);
+		cnt -= i;
+	}
+
+	rereg_query_all(a, umad, len, td->mgids[0].gid, td->gids, size,
+			comp_mask, data);
 
 	free(umad);
 
 	return 0;
 }
 
-static int run_mcast_leave_test(struct addr_data *a, struct test_data *td)
-{
+static int run_mcast_member_test(struct addr_data *a, struct test_data *td,
+				 int (*func)(struct addr_data *a,
+					     uint8_t * umad, int len,
+					     ibmad_gid_t mgid, ibmad_gid_t gid,
+					     uint64_t comp_mask, uint8_t *data))
+{
+	uint8_t data[256];
+	uint64_t comp_mask;
 	uint8_t *umad;
 	int len = 256;
 	unsigned i, j;
-
-	info("%s...\n", __func__);
 
 	umad = calloc(1, len + umad_size());
 	if (!umad) {
@@ -440,10 +427,12 @@
 		return -1;
 	}
 
+	comp_mask = build_mcm_rec(data, td->params);
+
 	for (i = 0; i < td->gids_size; i++)
 		for (j = 0; j < td->mgids_size; j++)
-			if (send_leave(a, umad, len,
-				       td->mgids[j].gid, td->gids[i].gid))
+			if (func(a, umad, len, td->mgids[j].gid,
+				 td->gids[i].gid, comp_mask, data))
 				return -1;
 
 	if (recv_all(a, umad, len) < 0)
@@ -452,6 +441,20 @@
 	free(umad);
 
 	return 0;
+}
+
+static int run_mcast_joins_test(struct addr_data *a, struct test_data *td)
+{
+	if (!td->params)
+		td->params = &mcmember_params_create;
+	return run_mcast_member_test(a, td, send_join);
+}
+
+static int run_mcast_leave_test(struct addr_data *a, struct test_data *td)
+{
+	if (!td->params)
+		td->params = &mcmember_params_join;
+	return run_mcast_member_test(a, td, send_leave);
 }
 
 /* main stuff */
@@ -462,14 +465,15 @@
 	const char *description;
 };
 
-static int run_test(const struct test *t, struct test_data *td)
+static int run_test(const struct test *t, struct test_data *td,
+		    struct ibmad_port *mad_port)
 {
 	struct addr_data addr;
 	int ret;
 
 	info("Running \'%s\'...\n", t->name);
 
-	ib_resolve_smlid(&addr.dport, TMO);
+	ib_resolve_smlid_via(&addr.dport, TMO, mad_port);
 	if (!addr.dport.lid) {
 		/* dport.lid = 1; */
 		err("No SM. Exit.\n");
@@ -479,7 +483,7 @@
 	if (!addr.dport.qkey)
 		addr.dport.qkey = IB_DEFAULT_QP1_QKEY;
 
-	addr.port = madrpc_portid();
+	addr.port = mad_rpc_portid(mad_port);
 	addr.agent = umad_register(addr.port, IB_SA_CLASS, 2, 0, NULL);
 	addr.timeout = TMO;
 
@@ -531,12 +535,13 @@
 static int parse_gids_file(const char *guid_file, struct gid_list **gid_list)
 {
 	char line[256];
+	ibmad_gid_t gid;
 	FILE *f;
 	uint64_t guid, prefix;
 	struct gid_list *list = NULL;
-	char *e;
+	char *p, *e;
 	unsigned list_size = 0;
-	int i = 0;
+	int ret, i = 0;
 
 	f = fopen(guid_file, "r");
 	if (!f) {
@@ -546,12 +551,37 @@
 	}
 
 	while (fgets(line, sizeof(line), f)) {
-		guid = strtoull(line, &e, 0);
-		if (e && isxdigit(*e)) {
-			prefix = guid;
-			guid = strtoull(line, NULL, 0);
-		} else
-			prefix = DEFAULT_PREFIX;
+		p = line;
+
+		while (isspace(*p))
+			p++;
+		e = strchr(p, '\n');
+		if (e) {
+			while (isspace(*e))
+				*e-- = '\0';
+		}
+
+		ret = inet_pton(AF_INET6, p, gid);
+		if (ret <= 0) { /* parse as numeric */
+			char save_char = 0;
+			if (strlen(p) > 18) {
+				e = p + 18;
+				save_char = *e;
+				*e = '\0';
+			}
+			guid = strtoull(p, NULL, 0);
+			if (!save_char)
+				prefix = DEFAULT_PREFIX;
+			else {
+				if (isxdigit(save_char))
+					*e = save_char;
+				else if (save_char == ':')
+					e++;
+				prefix = guid;
+				guid = strtoull(e, NULL, 16);
+			}
+			make_gid(gid, prefix, guid);
+		}
 
 		if (i >= list_size) {
 			list_size += 256;
@@ -564,7 +594,7 @@
 			memset(&list[i], 0, 256 * sizeof(list[0]));
 		}
 
-		make_gid(list[i].gid, prefix, guid);
+		memcpy(list[i].gid, gid, 16);
 		i++;
 	}
 	fclose(f);
@@ -622,6 +652,16 @@
 		{"MGID", 1, 0, 'M'},
 		{"ipv4", 0, 0, 'i'},
 		{"increment", 1, 0, 'I'},
+		{"qkey", 1, 0, 'q'},
+		{"mlid", 1, 0, 'z'},
+		{"mtu", 1, 0, 'y'},
+		{"tclass", 1, 0, 't'},
+		{"pkey", 1, 0, 'p'},
+		{"rate", 1, 0, 'r'},
+		{"sl", 1, 0, 's'},
+		{"flowlabel", 1, 0, 'f'},
+		{"joinstate", 1, 0, 'j'},
+		{"proxy", 0, 0, 'x'},
 		{"version", 0, 0, 'V'},
 		{"verbose", 0, 0, 'v'},
 		{"help", 0, 0, 'h'},
@@ -636,10 +676,12 @@
 
 	char opt_str[256];
 	int mgmt_classes[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
+	struct mcmember_params params = {}, zero_params = {};
 	struct test_data tdata;
 	ibmad_gid_t gid, mgid = {};
 	uint64_t guid = 0;
 	const char *guid_file = NULL, *mgid_file = NULL;
+	struct ibmad_port *mad_port;
 	const struct test *t;
 	unsigned is_mgid = 0, is_ipv4 = 1, increment = 0;
 	int ret, ch;
@@ -674,6 +716,36 @@
 		case 'm':
 			mgid_file = optarg;
 			break;
+		case 'q':
+			params.qkey = strtoul(optarg, NULL, 0);
+			break;
+		case 'z':
+			params.mlid = strtoul(optarg, NULL, 0);
+			break;
+		case 'y':
+			params.mtu = strtoul(optarg, NULL, 0);
+			break;
+		case 't':
+			params.tclass = strtoul(optarg, NULL, 0);
+			break;
+		case 'p':
+			params.pkey = strtoul(optarg, NULL, 0);
+			break;
+		case 'r':
+			params.rate = strtoul(optarg, NULL, 0);
+			break;
+		case 's':
+			params.sl = strtoul(optarg, NULL, 0);
+			break;
+		case 'f':
+			params.flow_label = strtoul(optarg, NULL, 0);
+			break;
+		case 'j':
+			params.join_state = strtoul(optarg, NULL, 0);
+			break;
+		case 'x':
+			params.proxy_join = 1;
+			break;
 		case 'v':
 			break;
 		case 'V':
@@ -686,7 +758,11 @@
 		}
 	}
 
-	madrpc_init(NULL, 0, mgmt_classes, 2);
+	mad_port = mad_rpc_open_port(NULL, 0, mgmt_classes, 2);
+	if (!mad_port) {
+		err("Cannot open local port...\n");
+		exit(-1);
+	}
 
 	memset(&tdata, 0, sizeof(tdata));
 
@@ -698,7 +774,7 @@
 		guid = get_guid_ho(tdata.gids[0].gid);
 	} else {
 		ib_portid_t portid = {0};
-		if (ib_resolve_self(&portid, NULL, &gid) < 0) {
+		if (ib_resolve_self_via(&portid, NULL, &gid, mad_port) < 0) {
 			err("Cannot resolve self port...\n");
 			exit(1);
 		}
@@ -725,14 +801,17 @@
 		return ret;
 	tdata.mgids_size = ret;
 
+	if (memcmp(&params, &zero_params, sizeof(params)))
+		tdata.params = &params;
+
 	if (argc <= optind)
-		return run_test(&tests[0], &tdata);
+		return run_test(&tests[0], &tdata, mad_port);
 
 	do {
 		t = find_test(tests, argv[optind]);
 		if (!t)
 			usage(argv[0], long_opts, tests);
-		ret = run_test(t, &tdata);
+		ret = run_test(t, &tdata, mad_port);
 		if (ret)
 			break;
 	} while (argc > ++optind);
@@ -742,5 +821,7 @@
 	if (tdata.mgids)
 		free(tdata.mgids);
 
+	mad_rpc_close_port(mad_port);
+
 	return ret;
 }

Modified: branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.c Thu Feb 11 12:28:22 2010
@@ -45,7 +45,6 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 
-#include <infiniband/common.h>
 #include <infiniband/mad.h>
 
 #include <ibsim.h>
@@ -60,6 +59,7 @@
 #endif
 
 static unsigned int remote_mode = 0;
+static char* socket_basename;
 
 static int sim_ctl(struct sim_client *sc, int type, void *data, int len)
 {
@@ -143,11 +143,10 @@
 
 static char *get_name(union name_t *name)
 {
-	if (remote_mode) {
+	if (remote_mode)
 		return inet_ntoa(name->name_i.sin_addr);
-	} else {
+	else
 		return name->name_u.sun_path + 1;
-	}
 }
 
 static int sim_attach(int fd, union name_t *name, size_t size)
@@ -159,8 +158,7 @@
 		DEBUG("attempt to connect to %s (attempt %d)",
 		      get_name(name), retries);
 
-		if ((r =
-		     connect(fd, (struct sockaddr *)name, size)) >= 0)
+		if ((r = connect(fd, (struct sockaddr *)name, size)) >= 0)
 			break;
 
 		if (r < 0 && errno == ECONNREFUSED) {
@@ -202,7 +200,7 @@
 	return sim_ctl(sc, SIM_CTL_DISCONNECT, 0, 0);
 }
 
-static int sim_init(struct sim_client *sc, int qp, char *nodeid)
+static int sim_init(struct sim_client *sc, char *nodeid)
 {
 	union name_t name;
 	socklen_t size;
@@ -214,12 +212,15 @@
 
 	connect_port = getenv("IBSIM_SERVER_PORT");
 	connect_host = getenv("IBSIM_SERVER_NAME");
+	socket_basename = getenv("IBSIM_SOCKNAME");
+
+	if(!socket_basename)
+		socket_basename = SIM_BASENAME;
 
 	if (connect_host && *connect_host)
 		remote_mode = 1;
 
-	DEBUG("init client pid=%d, qp=%d nodeid=%s",
-	      pid, qp, nodeid ? nodeid : "none");
+	DEBUG("init client pid=%d, nodeid=%s", pid, nodeid ? nodeid : "none");
 
 	if ((fd = socket(remote_mode ? PF_INET : PF_LOCAL, SOCK_DGRAM, 0)) < 0)
 		IBPANIC("can't get socket (fd)");
@@ -227,7 +228,7 @@
 	if ((ctlfd = socket(remote_mode ? PF_INET : PF_LOCAL, SOCK_DGRAM, 0)) < 0)
 		IBPANIC("can't get socket (ctlfd)");
 
-	size = make_name(&name, NULL, 0, "%s:ctl%d", SIM_BASENAME, pid);
+	size = make_name(&name, NULL, 0, "%s:ctl%d", socket_basename, pid);
 
 	if (bind(ctlfd, (struct sockaddr *)&name, size) < 0)
 		IBPANIC("can't bind ctl socket");
@@ -236,13 +237,13 @@
 	      pid, ctlfd, get_name(&name));
 
 	port = connect_port ? atoi(connect_port) : IBSIM_DEFAULT_SERVER_PORT;
-	size = make_name(&name, connect_host, port, "%s:ctl", SIM_BASENAME);
+	size = make_name(&name, connect_host, port, "%s:ctl", socket_basename);
 
 	sim_attach(ctlfd, &name, size);
 
 	sc->fd_ctl = ctlfd;
 
-	size = make_name(&name, NULL, 0, "%s:in%d", SIM_BASENAME, pid);
+	size = make_name(&name, NULL, 0, "%s:in%d", socket_basename, pid);
 
 	if (bind(fd, (struct sockaddr *)&name, size) < 0)
 		IBPANIC("can't bind input socket");
@@ -253,13 +254,13 @@
 		IBPANIC("can't read data from bound socket");
 	port = ntohs(name.name_i.sin_port);
 
-	sc->clientid = sim_connect(sc, remote_mode ? port : pid, qp, nodeid);
+	sc->clientid = sim_connect(sc, remote_mode ? port : pid, 0, nodeid);
 	if (sc->clientid < 0)
 		IBPANIC("connect failed");
 
 	port = connect_port ? atoi(connect_port) : IBSIM_DEFAULT_SERVER_PORT;
 	size = make_name(&name, connect_host, port + sc->clientid + 1,
-			 "%s:out%d", SIM_BASENAME, sc->clientid);
+			 "%s:out%d", socket_basename, sc->clientid);
 
 	sim_attach(fd, &name, size);
 
@@ -280,19 +281,21 @@
 	return sim_ctl(sc, SIM_CTL_SET_ISSM, &issm, sizeof(int));
 }
 
-int sim_client_init(struct sim_client *sc, char *nodeid)
-{
-	if (!nodeid)
-		nodeid = getenv("SIM_HOST");
-	if (sim_init(sc, 0, nodeid) < 0)
-		return -1;
-	if (sim_ctl(sc, SIM_CTL_GET_VENDOR, &sc->vendor, sizeof(sc->vendor)) <
-	    0)
+int sim_client_init(struct sim_client *sc)
+{
+	char *nodeid;
+
+	nodeid = getenv("SIM_HOST");
+	if (sim_init(sc, nodeid) < 0)
+		return -1;
+	if (sim_ctl(sc, SIM_CTL_GET_VENDOR, &sc->vendor,
+		    sizeof(sc->vendor)) < 0)
 		goto _exit;
 	if (sim_ctl(sc, SIM_CTL_GET_NODEINFO, sc->nodeinfo,
 		    sizeof(sc->nodeinfo)) < 0)
 		goto _exit;
-	sc->portinfo[0] = 0;
+
+	sc->portinfo[0] = 0;	// portno requested
 	if (sim_ctl(sc, SIM_CTL_GET_PORTINFO, sc->portinfo,
 		    sizeof(sc->portinfo)) < 0)
 		goto _exit;
@@ -304,7 +307,7 @@
   _exit:
 	sim_disconnect(sc);
 	sc->fd_ctl = sc->fd_pktin = sc->fd_pktout = -1;
-	return 0;
+	return -1;
 }
 
 void sim_client_exit(struct sim_client *sc)

Modified: branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.h
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.h?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.h (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/umad2sim/sim_client.h Thu Feb 11 12:28:22 2010
@@ -47,7 +47,7 @@
 };
 
 extern int sim_client_set_sm(struct sim_client *sc, unsigned issm);
-extern int sim_client_init(struct sim_client *sc, char *nodeid);
+extern int sim_client_init(struct sim_client *sc);
 extern void sim_client_exit(struct sim_client *sc);
 
 #endif				/* _SIM_CLIENT_H_ */

Modified: branches/ofed-1.5lenny/ibsim/trunk/umad2sim/umad2sim.c
URL: http://svn.debian.org/wsvn/pkg-ofed/branches/ofed-1.5lenny/ibsim/trunk/umad2sim/umad2sim.c?rev=649&op=diff
==============================================================================
--- branches/ofed-1.5lenny/ibsim/trunk/umad2sim/umad2sim.c (original)
+++ branches/ofed-1.5lenny/ibsim/trunk/umad2sim/umad2sim.c Thu Feb 11 12:28:22 2010
@@ -50,11 +50,9 @@
 #include <dlfcn.h>
 #include <netinet/in.h>
 
-#include <infiniband/common.h>
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
 
-#include <ibsim.h>
 #include <sim_client.h>
 
 #ifdef UMAD2SIM_NOISY_DEBUG
@@ -96,9 +94,16 @@
 static int (*real_poll) (struct pollfd * pfds, nfds_t nfds, int timeout);
 static int (*real_ioctl) (int d, int request, ...);
 static DIR *(*real_opendir) (const char *dir);
+#if __GLIBC_PREREQ(2,10)
+static int (*real_scandir) (const char *dir, struct dirent *** namelist,
+			    int (*filter) (const struct dirent *),
+			    int (*compar) (const struct dirent **,
+					   const struct dirent **));
+#else
 static int (*real_scandir) (const char *dir, struct dirent *** namelist,
 			    int (*filter) (const struct dirent *),
 			    int (*compar) (const void *, const void *));
+#endif
 
 static char sysfs_infiniband_dir[] = SYS_INFINIBAND;
 static char sysfs_infiniband_mad_dir[] = IB_UMAD_ABI_DIR;
@@ -443,8 +448,8 @@
 	{ static int err_count;
 	if (++err_count == 15)
 		return -1;
-	if (mad_get_field(umad_get_mad(umad), 0, IB_MAD_METHOD_F) == 0x7) {
-		printf("Drop trap repress...\n");
+	if (mad_get_field(umad_get_mad(umad), 0, IB_MAD_METHOD_F) == IB_MAD_METHOD_TRAP_REPRESS) {
+		printf("Dropping trap repress...\n");
 		return  -1;
 	}
 	}
@@ -563,7 +568,7 @@
 	dev->num = num;
 	strncpy(dev->name, name, sizeof(dev->name) - 1);
 
-	if (sim_client_init(&dev->sim_client, NULL) < 0)
+	if (sim_client_init(&dev->sim_client) < 0)
 		goto _error;
 
 	dev->port = mad_get_field(&dev->sim_client.portinfo, 0,
@@ -696,9 +701,15 @@
 	return real_opendir(path);
 }
 
+#if __GLIBC_PREREQ(2,10)
+int scandir(const char *path, struct dirent ***namelist,
+	    int (*filter) (const struct dirent *),
+	    int (*compar) (const struct dirent **, const struct dirent **))
+#else
 int scandir(const char *path, struct dirent ***namelist,
 	    int (*filter) (const struct dirent *),
 	    int (*compar) (const void *, const void *))
+#endif
 {
 	char new_path[4096];
 
@@ -815,7 +826,7 @@
 		return real_ioctl(fd, request, arg);
 }
 
-int poll(struct pollfd *pfds, unsigned long nfds, int timeout)
+int poll(struct pollfd *pfds, nfds_t nfds, int timeout)
 {
 	int saved_fds[nfds];
 	unsigned i;
@@ -828,7 +839,8 @@
 			struct umad2sim_dev *dev = devices[pfds[i].fd - 1024];
 			saved_fds[i] = pfds[i].fd;
 			pfds[i].fd = dev->sim_client.fd_pktin;
-		}
+		} else
+			saved_fds[i] = 0;
 	}
 
 	ret = real_poll(pfds, nfds, timeout);




More information about the Pkg-ofed-commits mailing list