[openib-general] [PATCH 1 of 7] branch 1.0, libibverbs: upgrade to version 1.0.3
Jack Morgenstein
jackm at mellanox.co.il
Thu Mar 30 06:51:20 PST 2006
upgrade libibverbs to version 1.0.3 on branch
Index: include/infiniband/verbs.h
===================================================================
--- include/infiniband/verbs.h (.../branches/1.0/src/userspace/libibverbs)
(revision 6101)
+++ include/infiniband/verbs.h (.../trunk/src/userspace/libibverbs) (revision
6101)
@@ -293,6 +293,19 @@ struct ibv_global_route {
uint8_t traffic_class;
};
+enum ibv_rate {
+ IBV_RATE_MAX = 0,
+ IBV_RATE_2_5_GBPS = 2,
+ IBV_RATE_5_GBPS = 5,
+ IBV_RATE_10_GBPS = 3,
+ IBV_RATE_20_GBPS = 6,
+ IBV_RATE_30_GBPS = 4,
+ IBV_RATE_40_GBPS = 7,
+ IBV_RATE_60_GBPS = 8,
+ IBV_RATE_80_GBPS = 9,
+ IBV_RATE_120_GBPS = 10
+};
+
struct ibv_ah_attr {
struct ibv_global_route grh;
uint16_t dlid;
@@ -782,7 +795,13 @@ static inline int ibv_poll_cq(struct ibv
}
/**
- * ibv_req_notify_cq - Request completion notification on a CQ.
+ * ibv_req_notify_cq - Request completion notification on a CQ. An
+ * event will be added to the completion channel associated with the
+ * CQ when an entry is added to the CQ.
+ * @cq: The completion queue to request notification for.
+ * @solicited_only: If non-zero, an event will be generated only for
+ * the next solicited CQ entry. If zero, any CQ entry, solicited or
+ * not, will generate an event.
*/
static inline int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only)
{
Index: configure.in
===================================================================
--- configure.in (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ configure.in (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -1,11 +1,11 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
-AC_INIT(libibverbs, 1.0, openib-general at openib.org)
+AC_INIT(libibverbs, 1.0.3, openib-general at openib.org)
AC_CONFIG_SRCDIR([src/ibverbs.h])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libibverbs, 1.0)
+AM_INIT_AUTOMAKE(libibverbs, 1.0.3)
AM_PROG_LIBTOOL
Index: src/device.c
===================================================================
--- src/device.c (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ src/device.c (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -42,6 +42,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h>
#include <alloca.h>
#include <infiniband/arch.h>
Index: src/verbs.c
===================================================================
--- src/verbs.c (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ src/verbs.c (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -40,6 +40,7 @@
#include <stdio.h>
#include <netinet/in.h>
#include <unistd.h>
+#include <stdlib.h>
#include <errno.h>
#include "ibverbs.h"
@@ -60,44 +61,62 @@ int ibv_query_gid(struct ibv_context *co
int index, union ibv_gid *gid)
{
char *attr_name;
- char attr[sizeof "0000:0000:0000:0000:0000:0000:0000:0000\0"];
+ struct sysfs_attribute *attr;
uint16_t val;
int i;
+ int ret = -1;
asprintf(&attr_name, "%s/ports/%d/gids/%d",
context->device->ibdev->path, port_num, index);
- if (sysfs_read_attribute_value(attr_name, attr, sizeof attr))
+ attr = sysfs_open_attribute(attr_name);
+ if (!attr)
return -1;
+ if (sysfs_read_attribute(attr))
+ goto out;
+
for (i = 0; i < 8; ++i) {
- if (sscanf(attr + i * 5, "%hx", &val) != 1)
- return -1;
+ if (sscanf(attr->value + i * 5, "%hx", &val) != 1)
+ goto out;
gid->raw[i * 2 ] = val >> 8;
gid->raw[i * 2 + 1] = val & 0xff;
}
- return 0;
+ ret = 0;
+
+out:
+ sysfs_close_attribute(attr);
+ return ret;
}
int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
int index, uint16_t *pkey)
{
char *attr_name;
- char attr[sizeof "0x0000\0"];
+ struct sysfs_attribute *attr;
uint16_t val;
+ int ret = -1;
asprintf(&attr_name, "%s/ports/%d/pkeys/%d",
context->device->ibdev->path, port_num, index);
- if (sysfs_read_attribute_value(attr_name, attr, sizeof attr))
+ attr = sysfs_open_attribute(attr_name);
+ if (!attr)
return -1;
- if (sscanf(attr, "%hx", &val) != 1)
- return -1;
+ if (sysfs_read_attribute(attr))
+ goto out;
+
+ if (sscanf(attr->value, "%hx", &val) != 1)
+ goto out;
*pkey = htons(val);
- return 0;
+ ret = 0;
+
+out:
+ sysfs_close_attribute(attr);
+ return ret;
}
struct ibv_pd *ibv_alloc_pd(struct ibv_context *context)
Index: src/init.c
===================================================================
--- src/init.c (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ src/init.c (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -64,8 +64,11 @@ static void load_driver(char *so_path)
struct ibv_driver *driver;
dlhandle = dlopen(so_path, RTLD_NOW);
- if (!dlhandle)
+ if (!dlhandle) {
+ fprintf(stderr, PFX "Warning: couldn't load driver %s: %s\n",
+ so_path, dlerror());
return;
+ }
dlerror();
init_func = dlsym(dlhandle, "openib_driver_init");
@@ -111,6 +114,8 @@ static void find_drivers(char *dir)
for (i = 0; i < so_glob.gl_pathc; ++i)
load_driver(so_glob.gl_pathv[i]);
+
+ globfree(&so_glob);
}
static struct ibv_device *init_drivers(struct sysfs_class_device *verbs_dev)
@@ -160,7 +165,8 @@ static struct ibv_device *init_drivers(s
static int check_abi_version(void)
{
char path[256];
- char val[16];
+ struct sysfs_attribute *attr;
+ int ret = -1;
if (sysfs_get_mnt_path(path, sizeof path)) {
fprintf(stderr, PFX "Fatal: couldn't find sysfs mount.\n");
@@ -169,22 +175,30 @@ static int check_abi_version(void)
strncat(path, "/class/infiniband_verbs/abi_version", sizeof path);
- if (sysfs_read_attribute_value(path, val, sizeof val)) {
- fprintf(stderr, PFX "Fatal: couldn't read uverbs ABI version.\n");
+ attr = sysfs_open_attribute(path);
+ if (!attr)
return -1;
+
+ if (sysfs_read_attribute(attr)) {
+ fprintf(stderr, PFX "Fatal: couldn't read uverbs ABI version.\n");
+ goto out;
}
- abi_ver = strtol(val, NULL, 10);
+ abi_ver = strtol(attr->value, NULL, 10);
if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION ||
abi_ver > IB_USER_VERBS_MAX_ABI_VERSION) {
fprintf(stderr, PFX "Fatal: kernel ABI version %d "
"doesn't match library version %d.\n",
abi_ver, IB_USER_VERBS_MAX_ABI_VERSION);
- return -1;
+ goto out;
}
- return 0;
+ ret = 0;
+
+out:
+ sysfs_close_attribute(attr);
+ return ret;
}
Index: src/cmd.c
===================================================================
--- src/cmd.c (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ src/cmd.c (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -40,6 +40,7 @@
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
#include <errno.h>
#include <alloca.h>
Index: src/memory.c
===================================================================
--- src/memory.c (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ src/memory.c (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -38,6 +38,7 @@
#include <sys/mman.h>
#include <unistd.h>
+#include <stdlib.h>
#include <stdint.h>
#include "ibverbs.h"
Index: Makefile.am
===================================================================
--- Makefile.am (.../branches/1.0/src/userspace/libibverbs) (revision 6101)
+++ Makefile.am (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -57,7 +57,7 @@ EXTRA_DIST = include/infiniband/driver.h
include/infiniband/opcode.h include/infiniband/verbs.h
include/infiniband/marshall.h \
include/infiniband/sa-kern-abi.h include/infiniband/sa.h \
src/ibverbs.h examples/pingpong.h \
- src/libibverbs.map libibverbs.spec.in $(man_MANS) $(DEBIAN)
+ src/libibverbs.map libibverbs.spec.in $(man_MANS)
dist-hook: libibverbs.spec
cp libibverbs.spec $(distdir)
Index: examples/asyncwatch.c
===================================================================
--- examples/asyncwatch.c (.../branches/1.0/src/userspace/libibverbs)
(revision 6101)
+++ examples/asyncwatch.c (.../trunk/src/userspace/libibverbs) (revision 6101)
@@ -42,6 +42,38 @@
#include <infiniband/verbs.h>
+static const char *event_name_str(enum ibv_event_type event_type)
+{
+ switch (event_type) {
+ case IBV_EVENT_DEVICE_FATAL:
+ return "IBV_EVENT_DEVICE_FATAL";
+ case IBV_EVENT_PORT_ACTIVE:
+ return "IBV_EVENT_PORT_ACTIVE";
+ case IBV_EVENT_PORT_ERR:
+ return "IBV_EVENT_PORT_ERR";
+ case IBV_EVENT_LID_CHANGE:
+ return "IBV_EVENT_LID_CHANGE";
+ case IBV_EVENT_PKEY_CHANGE:
+ return "IBV_EVENT_PKEY_CHANGE";
+ case IBV_EVENT_SM_CHANGE:
+ return "IBV_EVENT_SM_CHANGE";
+
+ case IBV_EVENT_CQ_ERR:
+ case IBV_EVENT_QP_FATAL:
+ case IBV_EVENT_QP_REQ_ERR:
+ case IBV_EVENT_QP_ACCESS_ERR:
+ case IBV_EVENT_COMM_EST:
+ case IBV_EVENT_SQ_DRAINED:
+ case IBV_EVENT_PATH_MIG:
+ case IBV_EVENT_PATH_MIG_ERR:
+ case IBV_EVENT_SRQ_ERR:
+ case IBV_EVENT_SRQ_LIMIT_REACHED:
+ case IBV_EVENT_QP_LAST_WQE_REACHED:
+ default:
+ return "unexpected";
+ }
+}
+
int main(int argc, char *argv[])
{
struct ibv_device **dev_list;
@@ -73,8 +105,9 @@ int main(int argc, char *argv[])
if (ibv_get_async_event(context, &event))
return 1;
- printf(" event_type %d, port %d\n", event.event_type,
- event.element.port_num);
+ printf(" event_type %s (%d), port %d\n",
+ event_name_str(event.event_type),
+ event.event_type, event.element.port_num);
ibv_ack_async_event(&event);
}
More information about the general
mailing list