aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-03-08 12:24:21 -0800
committerRoland Dreier <rolandd@cisco.com>2007-03-08 12:24:21 -0800
commit768efce599ae1eb06949ff4c25aa85da254d59c1 (patch)
treee95fdf981adda2c0b08bfd6f105ad4cddda9bbb6
parent6dc3f25d9ddbc4e2da95e6bff3af1e91a6263890 (diff)
downloadlibmthca-768efce599ae1eb06949ff4c25aa85da254d59c1.tar.gz
Check mthca kernel driver's ABI
Have libmthca ignore devices whose device-specific ABI is newer than expected. This avoids the possibility of an old library failing in a hard-to-diagnose way when used with a too-new kernel. Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--src/mthca-abi.h2
-rw-r--r--src/mthca.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/mthca-abi.h b/src/mthca-abi.h
index 1215412..2557274 100644
--- a/src/mthca-abi.h
+++ b/src/mthca-abi.h
@@ -36,6 +36,8 @@
#include <infiniband/kern-abi.h>
+#define MTHCA_UVERBS_ABI_VERSION 1
+
struct mthca_alloc_ucontext_resp {
struct ibv_get_context_resp ibv_resp;
__u32 qp_tab_size;
diff --git a/src/mthca.c b/src/mthca.c
index 81ac891..0f7e953 100644
--- a/src/mthca.c
+++ b/src/mthca.c
@@ -282,6 +282,12 @@ static struct ibv_device *mthca_driver_init(const char *uverbs_sys_path,
return NULL;
found:
+ if (abi_version > MTHCA_UVERBS_ABI_VERSION) {
+ fprintf(stderr, PFX "Fatal: ABI version %d of %s is too new (expected %d)\n",
+ abi_version, uverbs_sys_path, MTHCA_UVERBS_ABI_VERSION);
+ return NULL;
+ }
+
dev = malloc(sizeof *dev);
if (!dev) {
fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",