[ofw] [PATCH] Add uverbs version

Sean Hefty sean.hefty at intel.com
Thu Mar 27 10:03:28 PDT 2008


There are a couple of minor problems with this approach.  It breaks the existing
applications that don’t set the version now on input, and it requires that the
version field always be located in the same location in the structure. 

As an alternative, please see the patches that I posted for this, and which are
checked into my svn tree.  I added a new interface:

typedef ib_api_status_t
(AL_API *uvp_get_interface_n_t)(
	IN		const	uint32_t			version,
	IN	OUT			void*			p_uvp_interface,
	IN				size_t		uvp_interface_size);

This avoids the minor issues mentioned above, and avoids casting from a smaller
structure to a larger one of another type.  (I.e. we can't assume that future
versions of uvp_interface_t will always be larger than a previous version, and
casting from, say, something like uvp_interface2_t to uvp_interface_t can lead
to out of range memory accesses.)

As for the patch below, the major number should still be the same (1.x).  Only
the minor number has changed, since only new calls were added.

- Sean

________________________________________
From: ofw-bounces at lists.openfabrics.org
[mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Reuven Amitai
Sent: Wednesday, March 26, 2008 12:39 AM
To: ofw at lists.openfabrics.org
Subject: [ofw] [PATCH] Add uverbs version

Hi,
 
The patch adds version to uvp interface the same way the kvp has (
inc\iba\ib_ci.h ).
It also adds checking for the returned version of the uvp.
comments / suggestions are welcome.
 
Reuven.
 
 
Index: core/al/user/ual_ci_ca.c
===================================================================
--- core/al/user/ual_ci_ca.c	(revision 992)
+++ core/al/user/ual_ci_ca.c	(working copy)
@@ -162,6 +162,17 @@
 	add_ci_ca( p_ci_ca );
 	open_vendor_lib( ca_guid, &p_ci_ca->verbs );
 
+	/* Check vendor lib version */
+	if (p_ci_ca->verbs.user_verbs.version != UVERBS_VERSION)
+	{
+		p_ci_ca->obj.pfn_destroy( &p_ci_ca->obj, NULL );
+		AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR,
+			("Unsupported uvp interface version, "
+			"expected = 0x%x, actual = 0x%x.\n",
+			UVERBS_VERSION, p_ci_ca->verbs.user_verbs.version) );
+		return IB_UNSUPPORTED;
+	}
+	
 	/* Now open the UAL CA to be assigned to p_ci_ca */
 	status = ib_open_ca( h_al, ca_guid, ca_event_cb, p_ci_ca,
 		&p_ci_ca->h_ca );
Index: hw/mthca/user/mlnx_ual_main.c
===================================================================
--- hw/mthca/user/mlnx_ual_main.c	(revision 992)
+++ hw/mthca/user/mlnx_ual_main.c	(working copy)
@@ -143,7 +143,7 @@
     /*
      * Version of the header file this interface export can handle
      */
-    p_uvp->version = 0x101;
+    p_uvp->version = UVERBS_VERSION;
     p_uvp->guid    = 0x12345678;
 
     /*
Index: inc/user/iba/ib_uvp.h
===================================================================
--- inc/user/iba/ib_uvp.h	(revision 992)
+++ inc/user/iba/ib_uvp.h	(working copy)
@@ -116,6 +116,17 @@
 *
 */
 
+/*
+ * Version that identifies this version of the header file for interface
+ * definition.
+ */
+#define UVERBS_MAJOR_VER			(0x0002)
+#define UVERBS_MINOR_VER			(0x0000)
+
+#define UVERBS_VERSION			(((UVERBS_MAJOR_VER) << 16) |
(UVERBS_MINOR_VER))
+#define MK_UVERBS_VERSION(maj,min)	((((maj) & 0xFFFF) << 16) | \
+									((min) &
0xFFFF))
+
 /******/
 
 /******/





More information about the ofw mailing list