[Pkg-ofed-commits] [ibsim] 03/09: New upstream version 0.7
Ana Beatriz Guerrero López
ana at moszumanska.debian.org
Sun Oct 23 19:57:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
ana pushed a commit to branch master
in repository ibsim.
commit 9d709a5c39c560904390306295849f3dff6a84f2
Author: Ana Beatriz Guerrero Lopez <ana at debian.org>
Date: Sun Oct 23 21:34:18 2016 +0200
New upstream version 0.7
---
ibsim.spec | 6 +++---
ibsim/ibsim.c | 2 +-
ibsim/sim.h | 5 ++---
ibsim/sim_cmd.c | 55 +++++++++++++++++++++++++++++++++++++++----------------
ibsim/sim_mad.c | 9 ++++-----
ibsim/sim_net.c | 5 +++--
6 files changed, 52 insertions(+), 30 deletions(-)
diff --git a/ibsim.spec b/ibsim.spec
index b65142a..029e8a3 100644
--- a/ibsim.spec
+++ b/ibsim.spec
@@ -1,15 +1,15 @@
-%define RELEASE 1
+%define RELEASE 0.7
%define rel %{?CUSTOM_RELEASE}%{!?CUSTOM_RELEASE:%RELEASE}
Summary: InfiniBand fabric simulator for management
Name: ibsim
-Version: 0.6
+Version: 0.7
Release: %rel%{?dist}
License: GPLv2 or BSD
Group: System Environment/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/management/ibsim-0.6.tar.gz
+Source: http://www.openfabrics.org/downloads/management/ibsim-0.7.tar.gz
Url: http://openfabrics.org/
BuildRequires: libibmad-devel, libibumad-devel
diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c
index bc24f99..debf591 100644
--- a/ibsim/ibsim.c
+++ b/ibsim/ibsim.c
@@ -55,7 +55,7 @@
#include <ibsim.h>
#include "sim.h"
-#define IBSIM_VERSION "0.6"
+#define IBSIM_VERSION "0.7"
#undef DEBUG
#define PDEBUG if (parsedebug) IBWARN
diff --git a/ibsim/sim.h b/ibsim/sim.h
index daeecec..6b33a2c 100644
--- a/ibsim/sim.h
+++ b/ibsim/sim.h
@@ -45,9 +45,7 @@
#define MAXLINEARCAP (30*1024)
#define MAXMCASTCAP 1024
#define LASTBLOCK32 (MAXMCASTCAP/32-1)
-// NUMBEROFPORTMASK means that 32port switches could only be build
-#define NUMBEROFPORTMASK 2
-#define LASTPORTMASK (NUMBEROFPORTMASK-1)
+#define MCASTMASKSIZE 16
// linkwidth == 4X - must be one width only 1,2 or 8
#define LINKWIDTH_1x 1
#define LINKWIDTH_4x 2
@@ -318,6 +316,7 @@ struct Switch {
int linearFDBtop;
int portchange;
int lifetime;
+ int numportmask;
uint8_t switchinfo[64];
Node *node;
uint8_t *fdb;
diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index 4822a0b..3783641 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -873,7 +873,7 @@ static int parse_vl_num(char *attr, char *field, int *vl)
static int do_perf_counter_set(FILE *f, char *line)
{
- char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *val_error;
+ char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr;
Node *node;
int portnum, vl;
uint64_t value;
@@ -897,13 +897,15 @@ static int do_perf_counter_set(FILE *f, char *line)
return -1;
}
- if (sp) {
- portnum = strtoul(sp, 0, 0);
- if (portnum < 1 || portnum > node->numports) {
- fprintf(f, "# bad port number %d at nodeid \"%s\"\n",
- portnum, nodeid);
- return -1;
- }
+ if (sp == NULL) {
+ fprintf(f, "# port number not found in command\n");
+ return -1;
+ }
+
+ portnum = strtoul(sp, &end_ptr, 0);
+ if (end_ptr == sp) {
+ fprintf(f, "# port number not found in command\n");
+ return -1;
}
if (!(p = node_get_port(node, portnum))) {
@@ -911,9 +913,11 @@ static int do_perf_counter_set(FILE *f, char *line)
return -1;
}
- if (s && *s)
- while (isspace(*s))
- s++;
+ while (*s != '\0' && !isspace(*s))
+ s++;
+ while (*s != '\0' && isspace(*s))
+ s++;
+
attr = strsep(&s, ".");
if(s == NULL)
goto format_error;
@@ -934,14 +938,33 @@ static int do_perf_counter_set(FILE *f, char *line)
field_trim--;
*(field_trim + 1) = 0;
+#ifndef ULLONG_MAX
+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
+# define ULLONG_MAX 18446744073709551615ULL
+#endif
+
errno = 0;
- value = strtoull(s, &val_error, 0);
+ value = strtoull(s, &end_ptr, 0);
if((value == 0 || value == ULLONG_MAX) && errno != 0) {
- fprintf(f, "# value is not valid integer\n");
+ fprintf(f, "# value '%s' is out of range [%d,%llu]\n", s, 0, ULLONG_MAX);
+ return -1;
+ }
+ if(end_ptr == s || end_ptr == NULL || *end_ptr !='\0') {
+ fprintf(f, "# value '%s' is not valid integer\n", s);
return -1;
}
- if(*val_error) {
- fprintf(f, "# value %s is not valid integer\n", s);
+
+ if (portnum < 0 || portnum > node->numports
+ || (node->type != SWITCH_NODE && portnum == 0)) {
+ fprintf(f, "# bad port number %d at nodeid \"%s\"\n",
+ portnum, nodeid);
+ return -1;
+ }
+
+ if (node->type == SWITCH_NODE
+ && portnum == 0
+ && !mad_get_field(node->sw->switchinfo, 0, IB_SW_ENHANCED_PORT0_F)) {
+ fprintf(f, "# Can't set performance counters of base switch port 0\n");
return -1;
}
@@ -1089,7 +1112,7 @@ static int do_perf_counter_set(FILE *f, char *line)
fprintf(f, "# attribute %s not found\n", attr);
return -1;
}
- fprintf(f, "%s.%s has been set to %"PRIu64"\n", attr, field, value);
+ fprintf(f, "%s[%d] %s.%s has been set to %"PRIu64"\n", node->nodeid, p->portnum, attr, field, value);
return 0;
field_not_found:
fprintf(f, "# field %s cannot be found in attribute %s\n", field, attr);
diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index 223d507..d7c21a2 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -532,18 +532,17 @@ static int do_multicastforwtbl(Port * port, unsigned op, uint32_t mod,
int blockposition;
Switch *sw = port->node->sw;
-
if (!sw) // not a Switch?
return ERR_ATTR_UNSUPPORTED;
VERB("requested : Block32 %d PortMask %d", numBlock32, numPortMsk);
- if (numBlock32 > LASTBLOCK32 || numPortMsk > LASTPORTMASK) {
+ if (numBlock32 > LASTBLOCK32 || numPortMsk >= sw->numportmask) {
int8_t zeroblock[64] = { 0 };
mad_set_array(data, 0, IB_MULTICAST_FORW_TBL_F, zeroblock);
return 0;
}
- blockposition = (numBlock32 * NUMBEROFPORTMASK + numPortMsk) * 64;
+ blockposition = (numBlock32 * sw->numportmask + numPortMsk) * 64;
if (op == IB_MAD_METHOD_SET)
mad_get_array(data, 0, IB_MULTICAST_FORW_TBL_F,
sw->mfdb + blockposition);
@@ -636,8 +635,8 @@ static int pc_updated(Port ** srcport, Port * destport)
srcpc->flow_xmt_bytes =
addval(srcpc->flow_xmt_bytes, madsize_div_4,
GS_PERF_XMT_BYTES_LIMIT);
- ADDVAL64(destpc->ext_xmit_data, madsize_div_4);
- ADDVAL64(destpc->ext_xmit_pkts, 1);
+ ADDVAL64(srcpc->ext_xmit_data, madsize_div_4);
+ ADDVAL64(srcpc->ext_xmit_pkts, 1);
if (destport->errrate &&
!destport->errattr &&
diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index 10820ba..fe4687a 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -245,6 +245,7 @@ static Switch *new_switch(Node * nd, int set_esp0)
sw->node = nd;
sw->linearcap = maxlinearcap; // assume identical val for all switches
sw->multicastcap = maxmcastcap; // assume identical val for all switches
+ sw->numportmask = (nd->numports + MCASTMASKSIZE) / MCASTMASKSIZE;
memcpy(sw->switchinfo, switchinfo, sizeof(sw->switchinfo));
mad_set_field(sw->switchinfo, 0, IB_SW_LINEAR_FDB_CAP_F, sw->linearcap);
mad_set_field(sw->switchinfo, 0, IB_SW_MCAST_FDB_CAP_F,
@@ -253,13 +254,13 @@ static Switch *new_switch(Node * nd, int set_esp0)
mad_set_field(sw->switchinfo, 0, IB_SW_ENHANCED_PORT0_F,
set_esp0 > 0);
sw->fdb = malloc(maxlinearcap*sizeof(sw->fdb[0]));
- sw->mfdb = malloc(maxmcastcap*NUMBEROFPORTMASK*sizeof(uint16_t));
+ sw->mfdb = malloc(maxmcastcap * sw->numportmask * sizeof(uint16_t));
if (!sw->fdb || !sw->mfdb) {
IBPANIC("new_switch: no mem: %m");
return NULL;
}
memset(sw->fdb, 0xff, maxlinearcap*sizeof(sw->fdb[0]));
- memset(sw->mfdb, 0, maxmcastcap*NUMBEROFPORTMASK*sizeof(uint16_t));
+ memset(sw->mfdb, 0, maxmcastcap * sw->numportmask * sizeof(uint16_t));
return sw;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ofed/ibsim.git
More information about the Pkg-ofed-commits
mailing list