+++ /dev/null
-Bottom: b2b2b839d978bb240b0641dff8459eaee9553d17
-Top: e043d9f812f335b0a3519b14883777c97d69bd63
-Author: Sean Hefty <sean.hefty@intel.com>
-Date: 2012-09-27 15:34:31 -0700
-
-Refresh of verbs-ext
-
----
-
-diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
-index 5af0d7f..f22f287 100644
---- a/include/infiniband/driver.h
-+++ b/include/infiniband/driver.h
-@@ -55,9 +55,11 @@
-
- typedef struct ibv_device *(*ibv_driver_init_func)(const char *uverbs_sys_path,
- int abi_version);
-+typedef struct verbs_device *(*verbs_driver_init_func)(const char *uverbs_sys_path,
-+ int abi_version);
-
- void ibv_register_driver(const char *name, ibv_driver_init_func init_func);
--void verbs_register_driver(const char *name, ibv_driver_init_func init_func);
-+void verbs_register_driver(const char *name, verbs_driver_init_func init_func);
- int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
- size_t cmd_size, struct ibv_get_context_resp *resp,
- size_t resp_size);
-diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
-index a2577d8..cd7f916 100644
---- a/include/infiniband/verbs.h
-+++ b/include/infiniband/verbs.h
-@@ -742,16 +742,15 @@ struct verbs_context {
- static inline struct verbs_context *verbs_get_ctx(
- const struct ibv_context *ctx)
- {
-- if (ctx->abi_compat != ((uint8_t *)NULL)-1)
-- return NULL;
--
-- return container_of(ctx, struct verbs_context, context);
-+ return (ctx->abi_compat != ((uint8_t *) NULL) - 1) ?
-+ NULL : container_of(ctx, struct verbs_context, context);
- }
-
- static inline struct verbs_device *verbs_get_device(
- const struct ibv_device *dev)
- {
-- return container_of(dev, struct verbs_device, device);
-+ return (dev->ops.alloc_context) ?
-+ NULL : container_of(dev, struct verbs_device, device);
- }
-
- /**
-diff --git a/src/device.c b/src/device.c
-index 9e43138..15f8c54 100644
---- a/src/device.c
-+++ b/src/device.c
-@@ -124,8 +124,9 @@ default_symver(__ibv_get_device_guid, ibv_get_device_guid);
-
- struct ibv_context *__ibv_open_device(struct ibv_device *device)
- {
-+ struct verbs_device *verbs_device = verbs_get_device(device);
- char *devpath;
-- int cmd_fd;
-+ int cmd_fd, ret;
- struct ibv_context *context;
- struct verbs_context *context_ex;
-
-@@ -142,38 +143,32 @@ struct ibv_context *__ibv_open_device(struct ibv_device *device)
- if (cmd_fd < 0)
- return NULL;
-
-- context = device->ops.alloc_context(device, cmd_fd);
-- if (!context)
-- goto err;
-- if (context == (struct ibv_context *)(((uint8_t *)NULL)-1)) {
-- /* New provider that supports verbs extension was detected */
-- struct verbs_device *verbs_device =
-- verbs_get_device(device);
-- int ret;
--
-+ if (!verbs_device) {
-+ context = device->ops.alloc_context(device, cmd_fd);
-+ if (!context)
-+ goto err;
-+ } else {
- /* Library now allocates the context */
- context_ex = calloc(1, sizeof(*context_ex) +
-- verbs_device->size_of_context);
--
-+ verbs_device->size_of_context);
- if (!context_ex) {
- errno = ENOMEM;
- goto err;
- }
-- context = &context_ex->context;
-- /* Init new verbs_context */
-- context_ex->context.abi_compat = ((uint8_t *)NULL)-1;
-+
-+ context_ex->context.abi_compat = ((uint8_t *) NULL) - 1;
- context_ex->sz = sizeof(*context_ex);
-
-- /* Call provider to initialize its calls first */
-- ret = verbs_device->init_context(verbs_device,
-- &context_ex->context, cmd_fd);
-+ context = &context_ex->context;
-+ ret = verbs_device->init_context(verbs_device, context; cmd_fd);
- if (ret)
- goto verbs_err;
-+
- /* initialize *all* library ops to either lib calls or
-- * directly to provider calls.
-- context_ex-> lib_new_func1= __verbs_new_func1;
-- context_ex-> lib_new_func2= __verbs_new_func2;
-- */
-+ * directly to provider calls.
-+ * context_ex->lib_new_func1 = __verbs_new_func1;
-+ * context_ex->lib_new_func2 = __verbs_new_func2;
-+ */
- }
-
- context->device = device;
-@@ -186,7 +181,6 @@ verbs_err:
- free(context_ex);
- err:
- close(cmd_fd);
--
- return NULL;
- }
- default_symver(__ibv_open_device, ibv_open_device);
-@@ -200,9 +194,7 @@ int __ibv_close_device(struct ibv_context *context)
-
- context_ex = verbs_get_ctx(context);
- if (context_ex) {
-- struct verbs_device *verbs_device =
-- verbs_get_device(context->device);
-- /* Provider supports verbs extension */
-+ struct verbs_device *verbs_device = verbs_get_device(context->device);
- verbs_device->uninit_context(verbs_device, context);
- free(context_ex);
- } else
-diff --git a/src/init.c b/src/init.c
-index a1b0905..d6cd84a 100644
---- a/src/init.c
-+++ b/src/init.c
-@@ -70,6 +70,7 @@ struct ibv_driver_name {
- struct ibv_driver {
- const char *name;
- ibv_driver_init_func init_func;
-+ verbs_driver_init_func verbs_init_func;
- struct ibv_driver *next;
- };
-
-@@ -153,7 +154,8 @@ static int find_sysfs_devs(void)
- return ret;
- }
-
--void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
-+static void register_driver(const char *name, ibv_driver_init_func init_func,
-+ verbs_driver_init_func verbs_init_func)
- {
- struct ibv_driver *driver;
-
-@@ -163,9 +165,10 @@ void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
- return;
- }
-
-- driver->name = name;
-- driver->init_func = init_func;
-- driver->next = NULL;
-+ driver->name = name;
-+ driver->init_func = init_func;
-+ driver->verbs_init_func = verbs_init_func;
-+ driver->next = NULL;
-
- if (tail_driver)
- tail_driver->next = driver;
-@@ -174,12 +177,17 @@ void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
- tail_driver = driver;
- }
-
-+void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
-+{
-+ register_driver(name, init_func, NULL);
-+}
-+
- /* New registration symbol with same functionality - used by providers to
- * validate that library supports verbs extension.
- */
--void verbs_register_driver(const char *name, ibv_driver_init_func init_func)
-+void verbs_register_driver(const char *name, verbs_driver_init_func init_func)
- {
-- ibv_register_driver(name, init_func);
-+ register_driver(name, NULL, init_func);
- }
-
- static void load_driver(const char *name)
-@@ -341,12 +349,23 @@ out:
- static struct ibv_device *try_driver(struct ibv_driver *driver,
- struct ibv_sysfs_dev *sysfs_dev)
- {
-+ struct verbs_device *vdev;
- struct ibv_device *dev;
- char value[8];
-
-- dev = driver->init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
-- if (!dev)
-- return NULL;
-+ if (driver->init_func) {
-+ dev = driver->init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
-+ if (!dev)
-+ return NULL;
-+ } else {
-+ vdev = driver->verbs_init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
-+ if (!vdev)
-+ return NULL;
-+
-+ dev = &vdev->device;
-+ dev->ops.alloc_context = NULL;
-+ dev->ops.free_context = NULL;
-+ }
-
- if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "node_type", value, sizeof value) < 0) {
- fprintf(stderr, PFX "Warning: no node_type attr under %s.\n",
Bottom: 3441ce7abc8e145f2eb9ef7110fe2a69010bd8f6
-Top: b2b2b839d978bb240b0641dff8459eaee9553d17
+Top: e043d9f812f335b0a3519b14883777c97d69bd63
Author: Yishai Hadas <yishaih@mellanox.com>
Date: 2012-08-26 16:43:30 +0300
---
diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
-index 9a81416..5af0d7f 100644
+index 9a81416..f22f287 100644
--- a/include/infiniband/driver.h
+++ b/include/infiniband/driver.h
-@@ -57,6 +57,7 @@ typedef struct ibv_device *(*ibv_driver_init_func)(const char *uverbs_sys_path,
+@@ -55,8 +55,11 @@
+
+ typedef struct ibv_device *(*ibv_driver_init_func)(const char *uverbs_sys_path,
int abi_version);
++typedef struct verbs_device *(*verbs_driver_init_func)(const char *uverbs_sys_path,
++ int abi_version);
void ibv_register_driver(const char *name, ibv_driver_init_func init_func);
-+void verbs_register_driver(const char *name, ibv_driver_init_func init_func);
++void verbs_register_driver(const char *name, verbs_driver_init_func init_func);
int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
size_t cmd_size, struct ibv_get_context_resp *resp,
size_t resp_size);
diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
-index 6acfc81..a2577d8 100644
+index 6acfc81..cd7f916 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -38,6 +38,7 @@
struct ibv_context_ops {
int (*query_device)(struct ibv_context *context,
struct ibv_device_attr *device_attr);
-@@ -702,6 +727,33 @@ struct ibv_context {
+@@ -702,6 +727,32 @@ struct ibv_context {
void *abi_compat;
};
+static inline struct verbs_context *verbs_get_ctx(
+ const struct ibv_context *ctx)
+{
-+ if (ctx->abi_compat != ((uint8_t *)NULL)-1)
-+ return NULL;
-+
-+ return container_of(ctx, struct verbs_context, context);
++ return (ctx->abi_compat != ((uint8_t *) NULL) - 1) ?
++ NULL : container_of(ctx, struct verbs_context, context);
+}
+
+static inline struct verbs_device *verbs_get_device(
+ const struct ibv_device *dev)
+{
-+ return container_of(dev, struct verbs_device, device);
++ return (dev->ops.alloc_context) ?
++ NULL : container_of(dev, struct verbs_device, device);
+}
+
/**
IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
diff --git a/src/device.c b/src/device.c
-index 5798895..9e43138 100644
+index 5798895..15f8c54 100644
--- a/src/device.c
+++ b/src/device.c
-@@ -127,6 +127,7 @@ struct ibv_context *__ibv_open_device(struct ibv_device *device)
+@@ -124,9 +124,11 @@ default_symver(__ibv_get_device_guid, ibv_get_device_guid);
+
+ struct ibv_context *__ibv_open_device(struct ibv_device *device)
+ {
++ struct verbs_device *verbs_device = verbs_get_device(device);
char *devpath;
- int cmd_fd;
+- int cmd_fd;
++ int cmd_fd, ret;
struct ibv_context *context;
+ struct verbs_context *context_ex;
if (asprintf(&devpath, "/dev/infiniband/%s", device->dev_name) < 0)
return NULL;
-@@ -144,6 +145,36 @@ struct ibv_context *__ibv_open_device(struct ibv_device *device)
- context = device->ops.alloc_context(device, cmd_fd);
- if (!context)
- goto err;
-+ if (context == (struct ibv_context *)(((uint8_t *)NULL)-1)) {
-+ /* New provider that supports verbs extension was detected */
-+ struct verbs_device *verbs_device =
-+ verbs_get_device(device);
-+ int ret;
-+
+@@ -141,9 +143,33 @@ struct ibv_context *__ibv_open_device(struct ibv_device *device)
+ if (cmd_fd < 0)
+ return NULL;
+
+- context = device->ops.alloc_context(device, cmd_fd);
+- if (!context)
+- goto err;
++ if (!verbs_device) {
++ context = device->ops.alloc_context(device, cmd_fd);
++ if (!context)
++ goto err;
++ } else {
+ /* Library now allocates the context */
+ context_ex = calloc(1, sizeof(*context_ex) +
-+ verbs_device->size_of_context);
-+
++ verbs_device->size_of_context);
+ if (!context_ex) {
+ errno = ENOMEM;
+ goto err;
+ }
-+ context = &context_ex->context;
-+ /* Init new verbs_context */
-+ context_ex->context.abi_compat = ((uint8_t *)NULL)-1;
++
++ context_ex->context.abi_compat = ((uint8_t *) NULL) - 1;
+ context_ex->sz = sizeof(*context_ex);
+
-+ /* Call provider to initialize its calls first */
-+ ret = verbs_device->init_context(verbs_device,
-+ &context_ex->context, cmd_fd);
++ context = &context_ex->context;
++ ret = verbs_device->init_context(verbs_device, context; cmd_fd);
+ if (ret)
+ goto verbs_err;
++
+ /* initialize *all* library ops to either lib calls or
-+ * directly to provider calls.
-+ context_ex-> lib_new_func1= __verbs_new_func1;
-+ context_ex-> lib_new_func2= __verbs_new_func2;
-+ */
++ * directly to provider calls.
++ * context_ex->lib_new_func1 = __verbs_new_func1;
++ * context_ex->lib_new_func2 = __verbs_new_func2;
++ */
+ }
context->device = device;
context->cmd_fd = cmd_fd;
-@@ -151,6 +182,8 @@ struct ibv_context *__ibv_open_device(struct ibv_device *device)
+@@ -151,9 +177,10 @@ struct ibv_context *__ibv_open_device(struct ibv_device *device)
return context;
+ free(context_ex);
err:
close(cmd_fd);
-
-@@ -163,14 +196,17 @@ int __ibv_close_device(struct ibv_context *context)
+-
+ return NULL;
+ }
+ default_symver(__ibv_open_device, ibv_open_device);
+@@ -163,14 +190,15 @@ int __ibv_close_device(struct ibv_context *context)
int async_fd = context->async_fd;
int cmd_fd = context->cmd_fd;
int cq_fd = -1;
+
+ context_ex = verbs_get_ctx(context);
+ if (context_ex) {
-+ struct verbs_device *verbs_device =
-+ verbs_get_device(context->device);
-+ /* Provider supports verbs extension */
++ struct verbs_device *verbs_device = verbs_get_device(context->device);
+ verbs_device->uninit_context(verbs_device, context);
+ free(context_ex);
+ } else
close(async_fd);
close(cmd_fd);
diff --git a/src/init.c b/src/init.c
-index 8d6786e..a1b0905 100644
+index 8d6786e..d6cd84a 100644
--- a/src/init.c
+++ b/src/init.c
-@@ -174,6 +174,14 @@ void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
+@@ -70,6 +70,7 @@ struct ibv_driver_name {
+ struct ibv_driver {
+ const char *name;
+ ibv_driver_init_func init_func;
++ verbs_driver_init_func verbs_init_func;
+ struct ibv_driver *next;
+ };
+
+@@ -153,7 +154,8 @@ static int find_sysfs_devs(void)
+ return ret;
+ }
+
+-void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
++static void register_driver(const char *name, ibv_driver_init_func init_func,
++ verbs_driver_init_func verbs_init_func)
+ {
+ struct ibv_driver *driver;
+
+@@ -163,9 +165,10 @@ void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
+ return;
+ }
+
+- driver->name = name;
+- driver->init_func = init_func;
+- driver->next = NULL;
++ driver->name = name;
++ driver->init_func = init_func;
++ driver->verbs_init_func = verbs_init_func;
++ driver->next = NULL;
+
+ if (tail_driver)
+ tail_driver->next = driver;
+@@ -174,6 +177,19 @@ void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
tail_driver = driver;
}
++void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
++{
++ register_driver(name, init_func, NULL);
++}
++
+/* New registration symbol with same functionality - used by providers to
+ * validate that library supports verbs extension.
+ */
-+void verbs_register_driver(const char *name, ibv_driver_init_func init_func)
++void verbs_register_driver(const char *name, verbs_driver_init_func init_func)
+{
-+ ibv_register_driver(name, init_func);
++ register_driver(name, NULL, init_func);
+}
+
static void load_driver(const char *name)
{
char *so_name;
+@@ -333,12 +349,23 @@ out:
+ static struct ibv_device *try_driver(struct ibv_driver *driver,
+ struct ibv_sysfs_dev *sysfs_dev)
+ {
++ struct verbs_device *vdev;
+ struct ibv_device *dev;
+ char value[8];
+
+- dev = driver->init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
+- if (!dev)
+- return NULL;
++ if (driver->init_func) {
++ dev = driver->init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
++ if (!dev)
++ return NULL;
++ } else {
++ vdev = driver->verbs_init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
++ if (!vdev)
++ return NULL;
++
++ dev = &vdev->device;
++ dev->ops.alloc_context = NULL;
++ dev->ops.free_context = NULL;
++ }
+
+ if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "node_type", value, sizeof value) < 0) {
+ fprintf(stderr, PFX "Warning: no node_type attr under %s.\n",
diff --git a/src/libibverbs.map b/src/libibverbs.map
index 1827da0..ee9adea 100644
--- a/src/libibverbs.map