uvp: obtain desired interface by GUID
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 23 Jul 2008 20:24:16 +0000 (20:24 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 23 Jul 2008 20:24:16 +0000 (20:24 +0000)
The current uvp_get_interface() routine takes a structure as input.
Included in the structure is a version number.

A better solution to supporting multiple interfaces is to define
interfaces using GUIDs.  This not only allows different versions of
the same interface (for example the UVP interface), but also provides
a mechanism that can be used to add new interfaces without affecting
existing ABIs or APIs.

This will make it easier to extend the existing interfaces in the future.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1438 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/al/user/ual_ca.c
core/al/user/ual_support.h
hw/mlx4/user/hca/mlx4.c
hw/mthca/user/mlnx_ual_main.c
inc/user/iba/ib_uvp.h

index b1a12cb..3e595c2 100644 (file)
@@ -117,7 +117,8 @@ open_vendor_lib(
                return IB_SUCCESS;\r
        }\r
 \r
-       pfn_uvp_ifc = al_get_uvp_ifc_pfn( h_lib );\r
+       pfn_uvp_ifc = (uvp_get_interface_t)\r
+                                  GetProcAddress( h_lib, "uvp_get_interface" );\r
        if( !pfn_uvp_ifc )\r
        {\r
 #if defined( _DEBUG_ )\r
@@ -132,7 +133,7 @@ open_vendor_lib(
        }\r
 \r
        /* Query the vendor-supported user-mode functions */\r
-       pfn_uvp_ifc( &p_vca_intf->user_verbs );\r
+       pfn_uvp_ifc( IID_UVP, &p_vca_intf->user_verbs );\r
        p_vca_intf->h_uvp_lib = h_lib;\r
        AL_EXIT( AL_DBG_CA );\r
        return IB_SUCCESS;\r
index 9dcd784..04deb8b 100644 (file)
@@ -80,14 +80,6 @@ al_unload_uvp(
        FreeLibrary( h_uvp_lib );\r
 }\r
 \r
-static inline uvp_get_interface_t\r
-al_get_uvp_ifc_pfn(\r
-       IN                              void                                            *h_uvp_lib )\r
-{\r
-       return (uvp_get_interface_t)\r
-               GetProcAddress( h_uvp_lib, "uvp_get_interface" );\r
-}\r
-\r
 static inline void\r
 al_uvp_lib_err(\r
        IN                              uint32_t                                        dbg_lvl,\r
index 1e9c203..8f6b78d 100644 (file)
@@ -180,22 +180,8 @@ void mlx4_free_context(struct ibv_context *ctx)
        cl_free(context);\r
 }\r
 \r
-__declspec(dllexport) ib_api_status_t\r
-uvp_get_interface (\r
-    IN OUT     uvp_interface_t         *p_uvp )\r
+static void __get_uvp_interface(uvp_interface_t *p_uvp)\r
 {\r
-       CL_ASSERT(p_uvp);\r
-\r
-       /*\r
-        * Version of the header file this interface export can handle\r
-        */\r
-       p_uvp->version = 0x101;\r
-       p_uvp->guid    = 0x12345678;\r
-\r
-\r
-       /*\r
-        * CA Management\r
-        */\r
        p_uvp->pre_open_ca              = mlx4_pre_open_ca;\r
        p_uvp->post_open_ca             = mlx4_post_open_ca;\r
        p_uvp->pre_query_ca             = mlx4_pre_query_ca;\r
@@ -298,30 +284,47 @@ uvp_get_interface (
        p_uvp->rearm_n_cq               = NULL;\r
        p_uvp->peek_cq                  = NULL;\r
        p_uvp->bind_mw                  = NULL;\r
+}\r
 \r
+/* TODO: define and expose XRC through new interface GUID */\r
 #ifdef XRC_SUPPORT\r
+static void __get_xrc_interface(uvp_xrc_interface_t *p_xrc)\r
+{\r
        /*\r
         * XRC Management Verbs\r
         */\r
        p_uvp->pre_create_xrc_srq               = mlx4_pre_create_xrc_srq;\r
-       p_uvp->post_create_xrc_srq      = mlx4_post_create_xrc_srq;\r
-       p_uvp->pre_open_xrc_domain      = mlx4_pre_open_xrc_domain;\r
-       p_uvp->post_open_xrc_domain     = mlx4_post_open_xrc_domain;\r
-       p_uvp->pre_close_xrc_domain     = NULL;\r
+       p_uvp->post_create_xrc_srq              = mlx4_post_create_xrc_srq;\r
+       p_uvp->pre_open_xrc_domain              = mlx4_pre_open_xrc_domain;\r
+       p_uvp->post_open_xrc_domain             = mlx4_post_open_xrc_domain;\r
+       p_uvp->pre_close_xrc_domain             = NULL;\r
        p_uvp->post_close_xrc_domain    = mlx4_post_close_xrc_domain;\r
        p_uvp->pre_create_xrc_rcv_qp    = NULL;\r
        p_uvp->post_create_xrc_rcv_qp   = NULL;\r
        p_uvp->pre_modify_xrc_rcv_qp    = NULL;\r
        p_uvp->post_modify_xrc_rcv_qp   = NULL;\r
-       p_uvp->pre_query_xrc_rcv_qp     = NULL;\r
+       p_uvp->pre_query_xrc_rcv_qp             = NULL;\r
        p_uvp->post_query_xrc_rcv_qp    = NULL;\r
-       p_uvp->pre_reg_xrc_rcv_qp       = NULL;\r
-       p_uvp->post_reg_xrc_rcv_qp      = NULL;\r
-       p_uvp->pre_unreg_xrc_rcv_qp     = NULL;\r
+       p_uvp->pre_reg_xrc_rcv_qp               = NULL;\r
+       p_uvp->post_reg_xrc_rcv_qp              = NULL;\r
+       p_uvp->pre_unreg_xrc_rcv_qp             = NULL;\r
        p_uvp->post_unreg_xrc_rcv_qp    = NULL;\r
+}\r
 #endif\r
 \r
-       return IB_SUCCESS;\r
+__declspec(dllexport) ib_api_status_t\r
+uvp_get_interface (GUID iid, void* pifc)\r
+{\r
+       ib_api_status_t status = IB_SUCCESS;\r
+\r
+       if (IsEqualGUID(&iid, &IID_UVP))\r
+       {\r
+               __get_uvp_interface((uvp_interface_t *) pifc);\r
+       }\r
+       else\r
+       {\r
+               status = IB_UNSUPPORTED;\r
+       }\r
+\r
+       return status;\r
 }\r
-\r
-\r
index 172fd34..35a949e 100644 (file)
@@ -135,70 +135,30 @@ uvp_init()
 \r
 __declspec(dllexport) ib_api_status_t\r
 uvp_get_interface (\r
-    IN OUT     uvp_interface_t         *p_uvp )\r
+       IN              GUID    iid,\r
+       IN              void*   pifc)\r
 {\r
+       ib_api_status_t status = IB_SUCCESS;\r
+\r
     UVP_ENTER(UVP_DBG_SHIM);\r
 \r
-    CL_ASSERT(p_uvp);\r
-    /*\r
-     * Version of the header file this interface export can handle\r
-     */\r
-    p_uvp->version = 0x101;\r
-    p_uvp->guid    = 0x12345678;\r
-\r
-    /*\r
-     * CA Management\r
-     */\r
-    mlnx_get_ca_interface (p_uvp);\r
-    \r
-    /*\r
-     * Protection Domain\r
-     */\r
-    mlnx_get_pd_interface (p_uvp);\r
-\r
-    /*\r
-     * SRQ Management Verbs\r
-     */\r
-    mlnx_get_srq_interface (p_uvp);\r
-\r
-    /*\r
-     * QP Management Verbs\r
-     */\r
-    mlnx_get_qp_interface (p_uvp);\r
-\r
-    /*\r
-     * Completion Queue Management Verbs\r
-     */\r
-    mlnx_get_cq_interface (p_uvp);\r
-\r
-    /*\r
-     * AV Management\r
-     */\r
-    mlnx_get_av_interface(p_uvp);\r
-\r
-    /*\r
-     * Memory Region / Window Management Verbs\r
-     */\r
-    mlnx_get_mrw_interface (p_uvp);\r
-\r
-    /*\r
-     * Multicast Support Verbs\r
-     */\r
-    mlnx_get_mcast_interface (p_uvp);\r
-\r
-    /*\r
-     * OS bypass (send, receive, poll/notify cq)\r
-     */\r
-    mlnx_get_osbypass_interface(p_uvp);\r
-\r
-    \r
-    /*\r
-     * Local MAD support, for HCA's that do not support\r
-     * Agents in the HW.\r
-     * ??? Do we need this for user-mode ???\r
-     */\r
-\r
-    UVP_EXIT(UVP_DBG_SHIM);\r
-    return IB_SUCCESS;\r
-}\r
+       if (IsEqualGUID(&iid, &IID_UVP))\r
+       {\r
+               mlnx_get_ca_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_pd_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_srq_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_qp_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_cq_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_av_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_mrw_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_mcast_interface((uvp_interface_t *) pifc);\r
+               mlnx_get_osbypass_interface((uvp_interface_t *) pifc);\r
+       }\r
+       else\r
+       {\r
+               status = IB_UNSUPPORTED;\r
+       }\r
 \r
+       UVP_EXIT(UVP_DBG_SHIM);\r
+       return status;\r
+}\r
index faf3e68..ed0283f 100644 (file)
@@ -37,6 +37,7 @@
 #include <complib/cl_types.h>\r
 #include <iba/ib_types.h>\r
 #include <iba/ib_ci.h>\r
+#include <initguid.h>\r
 \r
 /****h* UAL_UVP_Interface/user-mode Verbs\r
 * NAME\r
@@ -3343,8 +3344,6 @@ typedef void
 \r
 /********/\r
 \r
-/********/\r
-\r
 /****s* user-mode Verbs/uvp_interface_t\r
 * NAME\r
 *      uvp_interface_t -- Interface holding supported Vendor APIs\r
@@ -3357,107 +3356,59 @@ typedef void
 */\r
 typedef struct _uvp_interface\r
 {\r
-       ib_net64_t                                      guid;\r
-       /*\r
-        * Version of the header file this interface export can handle\r
-        */\r
-       uint32_t                                        version;\r
-\r
-       /* Version 2.00 APIs */\r
-\r
-       /*\r
-        * HCA Access Verbs\r
-        */\r
        uvp_pre_open_ca_t                       pre_open_ca;\r
        uvp_post_open_ca_t                      post_open_ca;\r
-\r
        uvp_pre_query_ca                        pre_query_ca;\r
        uvp_post_query_ca_t                     post_query_ca;\r
-\r
        uvp_pre_modify_ca                       pre_modify_ca;\r
        uvp_post_modify_ca_t            post_modify_ca;\r
-\r
        uvp_pre_close_ca_t                      pre_close_ca;\r
        uvp_post_close_ca_t                     post_close_ca;\r
 \r
        uvp_pre_ci_call                         pre_ci_call;\r
        uvp_post_ci_call                        post_ci_call;\r
 \r
-\r
-       /*\r
-        * Protection Domain\r
-        */\r
        uvp_pre_allocate_pd                     pre_allocate_pd;\r
        uvp_post_allocate_pd_t          post_allocate_pd;\r
        uvp_pre_deallocate_pd           pre_deallocate_pd;\r
        uvp_post_deallocate_pd_t        post_deallocate_pd;\r
 \r
-       /*\r
-        * Address Vector Management Verbs\r
-        */\r
-\r
        uvp_pre_create_av                       pre_create_av;\r
        uvp_post_create_av_t            post_create_av;\r
-\r
        uvp_pre_query_av                        pre_query_av;\r
        uvp_post_query_av_t                     post_query_av;\r
-\r
        uvp_pre_modify_av                       pre_modify_av;\r
        uvp_post_modify_av_t            post_modify_av;\r
        uvp_pre_destroy_av                      pre_destroy_av;\r
        uvp_post_destroy_av_t           post_destroy_av;\r
 \r
-       /*\r
-        * SRQ Management Verbs\r
-        */\r
-       uvp_pre_create_srq              pre_create_srq;\r
+       uvp_pre_create_srq                      pre_create_srq;\r
        uvp_post_create_srq_t           post_create_srq;\r
-\r
-       uvp_pre_modify_srq              pre_modify_srq;\r
+       uvp_pre_modify_srq                      pre_modify_srq;\r
        uvp_post_modify_srq_t           post_modify_srq;\r
-\r
-       uvp_pre_query_srq               pre_query_srq;\r
+       uvp_pre_query_srq                       pre_query_srq;\r
        uvp_post_query_srq_t            post_query_srq;\r
-\r
-       uvp_pre_destroy_srq             pre_destroy_srq;\r
+       uvp_pre_destroy_srq                     pre_destroy_srq;\r
        uvp_post_destroy_srq_t          post_destroy_srq;\r
 \r
-\r
-       /*\r
-        * QP Management Verbs\r
-        */\r
        uvp_pre_create_qp                       pre_create_qp;\r
        uvp_post_create_qp_t            post_create_qp;\r
-\r
-       /* No support for create_spl_qp, UAL will return error */\r
-\r
        uvp_pre_modify_qp                       pre_modify_qp;\r
        uvp_post_modify_qp_t            post_modify_qp;\r
-\r
        uvp_pre_query_qp                        pre_query_qp;\r
        uvp_post_query_qp_t                     post_query_qp;\r
-\r
        uvp_pre_destroy_qp                      pre_destroy_qp;\r
        uvp_post_destroy_qp_t           post_destroy_qp;\r
 \r
-       /*\r
-        * Completion Queue Management Verbs\r
-        */\r
        uvp_pre_create_cq                       pre_create_cq;\r
        uvp_post_create_cq_t            post_create_cq;\r
-\r
        uvp_pre_query_cq                        pre_query_cq;\r
        uvp_post_query_cq_t                     post_query_cq;\r
-\r
        uvp_pre_resize_cq                       pre_resize_cq;\r
        uvp_post_resize_cq_t            post_resize_cq;\r
-\r
        uvp_pre_destroy_cq                      pre_destroy_cq;\r
        uvp_post_destroy_cq_t           post_destroy_cq;\r
 \r
-       /*\r
-        * Memory Window Verbs\r
-        */\r
        uvp_pre_create_mw                       pre_create_mw;\r
        uvp_post_create_mw_t            post_create_mw;\r
        uvp_pre_query_mw                        pre_query_mw;\r
@@ -3465,38 +3416,21 @@ typedef struct _uvp_interface
        uvp_pre_destroy_mw                      pre_destroy_mw;\r
        uvp_post_destroy_mw_t           post_destroy_mw;\r
 \r
-       /* No pre/post functions for bind */\r
        uvp_bind_mw                                     bind_mw;\r
-\r
-       /*\r
-        * Work Request Processing Verbs\r
-        * Should the types be same as Verbs?\r
-        */\r
        uvp_post_send                           post_send;\r
        uvp_post_recv                           post_recv;\r
        uvp_post_srq_recv                       post_srq_recv;\r
 \r
-       /*\r
-        * Completion Processing and\r
-        * Completion Notification Request Verbs.\r
-        * Should the types be same as Verbs?\r
-        */\r
        uvp_peek_cq                                     peek_cq;\r
        uvp_poll_cq                                     poll_cq;\r
        uvp_rearm_cq                            rearm_cq;\r
        uvp_rearm_n_cq                          rearm_n_cq;\r
 \r
-       /*\r
-        * Multicast Support Verbs\r
-        */\r
        uvp_pre_attach_mcast            pre_attach_mcast;\r
        uvp_post_attach_mcast           post_attach_mcast;\r
        uvp_pre_detach_mcast            pre_detach_mcast;\r
        uvp_post_detach_mcast           post_detach_mcast;\r
 \r
-       /*\r
-        * ND Support Verbs\r
-        */\r
        uvp_nd_modify_qp_t                      nd_modify_qp;\r
        uvp_nd_get_qp_state_t           nd_get_qp_state;\r
        uvp_wv_pre_create_qp            wv_pre_create_qp;\r
@@ -3506,35 +3440,42 @@ typedef struct _uvp_interface
 \r
 /********/\r
 \r
+// {A1F1EA66-4D17-4d04-B910-893F658241D0}\r
+DEFINE_GUID(IID_UVP, \r
+0xa1f1ea66, 0x4d17, 0x4d04, 0xb9, 0x10, 0x89, 0x3f, 0x65, 0x82, 0x41, 0xd0);\r
+\r
 /****f* user-mode Verbs/uvp_get_interface\r
 * NAME\r
-*      uvp_get_interface -- Get the Vendor's supported Verbs calls\r
+*      uvp_get_interface -- Get the Vendor's supported function calls\r
 *\r
 * SYNOPSIS\r
 */\r
 typedef ib_api_status_t\r
 (AL_API *uvp_get_interface_t)(\r
-       IN      OUT                     uvp_interface_t*        const   p_uvp );\r
+       IN                      GUID                            iid,\r
+       IN      OUT             void*                           pifc);\r
 /*\r
 * DESCRIPTION\r
-*      This routine is called by UAL to get the functions supported by\r
-*      a vendor's library. Upon discovering a new CA, UAL will look for\r
-*      the appropriate vendor library, load the library and query using\r
-*      this function to get the supported interfaces.\r
+*      This routine is called to get the functions supported by\r
+*      a vendor's library.  It may be used to obtain the list of\r
+*      verb calls supported by a vendor.\r
 *\r
-*      If the vendor does not support an interface function, it should be\r
-*      set to NULL in the interface structure returned.\r
+*      If the vendor does not support an interface, it should returns\r
+*      IB_UNSUPPORTED.  The specific details of each interface returned\r
+*      is dependent upon the requested interface.\r
 *\r
 * PARAMETERS\r
-*      p_uvp\r
-*              [in out] Pointer to the uvp_interface_t structure that has the function\r
-*              vector to support verbs functionality.\r
+*      iid\r
+*              [in] GUID of the requested interface.\r
+*      pifc\r
+*              [in out] Pointer to the structure that that will receive the\r
+*              interface functions.\r
 *\r
 * RETURN VALUE\r
 *      IB_SUCCESS\r
-*              The registration is successful.\r
-*      IB_INSUFFICIENT_MEMORY\r
-*              Insufficient memory to satisfy request\r
+*              The interface was returned successfully.\r
+*      IB_UNSUPPORTED\r
+*              The requested interface isn't supported by the vendor's library.\r
 *\r
 * PORTABILITY\r
 *      User mode\r
@@ -3544,6 +3485,4 @@ typedef ib_api_status_t
 *\r
 ********/\r
 \r
-/********/\r
-\r
 #endif // __IB_UAL_UVP_H__\r