[IBAL\IOU\INC] support 2 HCAs that connect to the same IOC/IOU.
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 28 Nov 2006 07:27:28 +0000 (07:27 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 28 Nov 2006 07:27:28 +0000 (07:27 +0000)
- rcontext_map changed from qmap to fmap
  IOC/IOU key is 128 bits (IOC guid and ca guid)
  CA\PORT key is 64 bits (guid)
- start new sweep only if the query_cnt is 0.
- IOC uniqe_id is 128 bits and construct from IOC guid and ca guid.
- fix prints

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@550 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/al/al_pnp.h
core/al/kernel/al_ioc_pnp.c
core/al/kernel/al_pnp.c
core/bus/kernel/bus_iou_mgr.c
core/bus/kernel/bus_port_mgr.c
core/iou/kernel/iou_driver.h
core/iou/kernel/iou_ioc_mgr.c

index 5b788ab..4c56edb 100644 (file)
@@ -38,7 +38,7 @@
 #include "al_ca.h"\r
 #include <iba/ib_al_ioctl.h>\r
 #include <complib/cl_ptr_vector.h>\r
-#include <complib/cl_qmap.h>\r
+#include <complib/cl_fleximap.h>\r
 \r
 \r
 extern char*   ib_pnp_event_str[];\r
@@ -54,7 +54,7 @@ typedef struct _al_pnp
        cl_list_item_t                  list_item;\r
        cl_async_proc_item_t    dereg_item;\r
        ib_pnp_class_t                  pnp_class;\r
-       cl_qmap_t                               context_map;\r
+       cl_fmap_t                               context_map;\r
        IRP                                             *p_rearm_irp;\r
        IRP                                             *p_dereg_irp;\r
 #else  /* defined( CL_KERNEL ) */\r
@@ -99,8 +99,9 @@ typedef struct _al_pnp
 typedef struct _al_pnp_context\r
 {\r
        /* List item must be first. */\r
-       cl_map_item_t                   map_item;\r
+       cl_fmap_item_t                  map_item;\r
        ib_net64_t                              guid;\r
+       ib_net64_t                              ca_guid;\r
        const void                              *context;\r
 \r
 }      al_pnp_context_t;\r
@@ -195,13 +196,13 @@ pnp_poll(
 al_pnp_context_t*\r
 pnp_create_context(\r
        IN                              al_pnp_t* const                         p_reg,\r
-       IN              const   net64_t                                         guid );\r
+       IN              const   void* const                                     p_key );\r
 /******/\r
 \r
 al_pnp_context_t*\r
 pnp_get_context(\r
        IN              const   al_pnp_t* const                         p_reg,\r
-       IN              const   ib_net64_t                                      guid );\r
+       IN              const   void* const                                     p_key );\r
 \r
 void\r
 pnp_reg_complete(\r
index 3cfee0b..20e14b8 100644 (file)
@@ -1223,7 +1223,7 @@ __ioc_pnp_cb(
        case IB_PNP_SM_CHANGE:\r
        case IB_PNP_PORT_ACTIVE:\r
                /* Initiate a sweep - delay a bit to allow the ports to come up. */\r
-               if( g_ioc_poll_interval )\r
+               if( g_ioc_poll_interval && !gp_ioc_pnp->query_cnt)\r
                {\r
                        cl_status = cl_timer_start( &gp_ioc_pnp->sweep_timer, 250 );\r
                        CL_ASSERT( cl_status == CL_SUCCESS );\r
@@ -2926,23 +2926,28 @@ __notify_users(
        {\r
        case IB_PNP_IOU_ADD:\r
                CL_ASSERT( pnp_get_class( p_reg->pnp_class ) == IB_PNP_IOU );\r
-               p_context = pnp_create_context( p_reg, p_event->p_rec->guid );\r
+               p_context = pnp_create_context( p_reg, &p_event->p_rec->guid);\r
                break;\r
 \r
        case IB_PNP_IOU_REMOVE:\r
                CL_ASSERT( pnp_get_class( p_reg->pnp_class ) == IB_PNP_IOU );\r
                /* Lookup the context for this IOU. */\r
-               p_context = pnp_get_context( p_reg, p_event->p_rec->guid );\r
+               p_context = pnp_get_context( p_reg, &p_event->p_rec->guid );\r
                break;\r
 \r
        case IB_PNP_IOC_ADD:\r
                CL_ASSERT( pnp_get_class( p_reg->pnp_class ) == IB_PNP_IOC );\r
-               p_context = pnp_create_context( p_reg, p_event->p_rec->guid );\r
+               p_context = pnp_create_context( p_reg, &p_event->p_rec->guid);\r
                break;\r
-\r
-       default:\r
+       case IB_PNP_IOC_PATH_ADD:\r
+       case IB_PNP_IOC_PATH_REMOVE:\r
                CL_ASSERT( pnp_get_class( p_reg->pnp_class ) == IB_PNP_IOC );\r
-               p_context = pnp_get_context( p_reg, p_event->p_rec->guid );\r
+               p_context = pnp_get_context( p_reg, &p_event->p_rec->guid );\r
+               break;\r
+       default:\r
+               AL_PRINT_EXIT(TRACE_LEVEL_WARNING, AL_DBG_PNP,("Invalid PnP event %#x\n",\r
+                       p_event->p_rec->pnp_event));\r
+               return CL_NOT_DONE;\r
                break;\r
        }\r
        if( !p_context )\r
@@ -2958,7 +2963,7 @@ __notify_users(
                p_event->p_rec->pnp_event == IB_PNP_IOU_REMOVE ||\r
                p_event->p_rec->pnp_event == IB_PNP_IOC_REMOVE )\r
        {\r
-               cl_qmap_remove_item( &p_reg->context_map, &p_context->map_item );\r
+               cl_fmap_remove_item( &p_reg->context_map, &p_context->map_item );\r
                cl_free( p_context );\r
        }\r
        else\r
@@ -2993,7 +2998,10 @@ __report_iou_add(
        }\r
        p_rec->pnp_rec.pnp_event = IB_PNP_IOU_ADD;\r
        p_rec->pnp_rec.guid = p_iou->guid;\r
+       p_rec->pnp_rec.ca_guid = p_iou->ca_guid;\r
+       \r
        p_rec->ca_guid = p_iou->ca_guid;\r
+       p_rec->guid = p_iou->guid;\r
        p_rec->vend_id = p_iou->vend_id;\r
        p_rec->dev_id = p_iou->dev_id;\r
        p_rec->revision = p_iou->revision;\r
@@ -3086,6 +3094,8 @@ __report_ioc_add(
 \r
        p_rec->pnp_rec.pnp_event = IB_PNP_IOC_ADD;\r
        p_rec->pnp_rec.guid = p_ioc->profile.ioc_guid;\r
+       p_rec->pnp_rec.ca_guid = p_ioc->p_iou->ca_guid;\r
+       \r
        p_rec->ca_guid = p_ioc->p_iou->ca_guid;\r
        cl_memcpy( p_rec->svc_entry_array, p_ioc->p_svc_entries,\r
                p_ioc->profile.num_svc_entries * sizeof(ib_svc_entry_t) );\r
@@ -3178,14 +3188,14 @@ __report_path(
        p_rec = (ib_pnp_ioc_path_rec_t*)cl_zalloc( event.rec_size * 2 );\r
        if( !p_rec )\r
                return;\r
-\r
+       p_rec->pnp_rec.pnp_event = pnp_event;\r
+       p_rec->pnp_rec.guid = p_ioc->profile.ioc_guid;\r
+       p_rec->pnp_rec.ca_guid = p_path->ca_guid;\r
+       \r
        p_rec->ca_guid = p_path->ca_guid;\r
        p_rec->port_guid = p_path->port_guid;\r
        p_rec->path = p_path->rec;\r
 \r
-       p_rec->pnp_rec.pnp_event = pnp_event;\r
-       p_rec->pnp_rec.guid = p_ioc->profile.ioc_guid;\r
-\r
        event.p_rec = (ib_pnp_rec_t*)p_rec;\r
        event.p_user_rec = (ib_pnp_rec_t*)(((uint8_t*)p_rec) + event.rec_size);\r
 \r
index bd0910d..5dd72c7 100644 (file)
@@ -83,6 +83,33 @@ __pnp_free(
        IN                              al_obj_t                                        *p_obj );\r
 \r
 \r
+/*\r
+ * Compares two context for inserts/lookups in a flexi map.  Keys are the\r
+ * address of the reg guid1, which is adjacent to the context guid2 (if exist).\r
+ * This allows for a single call to cl_memcmp.\r
+ */\r
+static intn_t\r
+__context_cmp128(\r
+       IN              const   void* const                                     p_key1,\r
+       IN              const   void* const                                     p_key2 )\r
+{\r
+       return cl_memcmp( p_key1, p_key2, sizeof(uint64_t) * 2 );\r
+}\r
+\r
+/*\r
+ * Compares two context for inserts/lookups in a flexi map.  Keys are the\r
+ * address of the reg guid1, which is adjacent to the context guid2 (if exist).\r
+ * This allows for a single call to cl_memcmp.\r
+ */\r
+static intn_t\r
+__context_cmp64(\r
+       IN              const   void* const                                     p_key1,\r
+       IN              const   void* const                                     p_key2 )\r
+{\r
+       return cl_memcmp( p_key1, p_key2, sizeof(uint64_t) );\r
+}\r
+\r
+\r
 /*\r
  * Event structures for queuing to the async proc manager.\r
  */\r
@@ -291,7 +318,7 @@ __pnp_reg_cleanup(
        IN                              al_obj_t                                        *p_obj )\r
 {\r
        al_pnp_t                *p_reg;\r
-       cl_map_item_t   *p_item;\r
+       cl_fmap_item_t  *p_item;\r
        IRP                             *p_irp;\r
 \r
        AL_ENTER( AL_DBG_PNP );\r
@@ -299,10 +326,10 @@ __pnp_reg_cleanup(
        p_reg = PARENT_STRUCT( p_obj, al_pnp_t, obj );\r
 \r
        /* Cleanup the context list. */\r
-       while( cl_qmap_count( &p_reg->context_map ) )\r
+       while( cl_fmap_count( &p_reg->context_map ) )\r
        {\r
-               p_item = cl_qmap_tail( &p_reg->context_map );\r
-               cl_qmap_remove_item( &p_reg->context_map, p_item );\r
+               p_item = cl_fmap_tail( &p_reg->context_map );\r
+               cl_fmap_remove_item( &p_reg->context_map, p_item );\r
                cl_free( p_item );\r
        }\r
 \r
@@ -338,17 +365,17 @@ __pnp_reg_free(
        IN                              al_obj_t                                        *p_obj )\r
 {\r
        al_pnp_t                *p_reg;\r
-       cl_map_item_t   *p_item;\r
+       cl_fmap_item_t  *p_item;\r
 \r
        AL_ENTER( AL_DBG_PNP );\r
 \r
        p_reg = PARENT_STRUCT( p_obj, al_pnp_t, obj );\r
 \r
        /* Cleanup the context list. */\r
-       while( cl_qmap_count( &p_reg->context_map ) )\r
+       while( cl_fmap_count( &p_reg->context_map ) )\r
        {\r
-               p_item = cl_qmap_tail( &p_reg->context_map );\r
-               cl_qmap_remove_item( &p_reg->context_map, p_item );\r
+               p_item = cl_fmap_tail( &p_reg->context_map );\r
+               cl_fmap_remove_item( &p_reg->context_map, p_item );\r
                cl_free( p_item );\r
        }\r
 \r
@@ -373,15 +400,15 @@ __pnp_reg_free(
 al_pnp_context_t*\r
 pnp_get_context(\r
        IN              const   al_pnp_t* const                         p_reg,\r
-       IN              const   ib_net64_t                                      guid )\r
+       IN                              const void* const                               p_key )\r
 {\r
-       cl_map_item_t           *p_context_item;\r
+       cl_fmap_item_t          *p_context_item;\r
 \r
        AL_ENTER( AL_DBG_PNP );\r
 \r
        /* Search the context list for this CA. */\r
-       p_context_item = cl_qmap_get( &p_reg->context_map, guid );\r
-       if( p_context_item != cl_qmap_end( &p_reg->context_map ) )\r
+       p_context_item = cl_fmap_get( &p_reg->context_map, p_key );\r
+       if( p_context_item != cl_fmap_end( &p_reg->context_map ) )\r
        {\r
                AL_EXIT( AL_DBG_PNP );\r
                return PARENT_STRUCT( p_context_item, al_pnp_context_t, map_item );\r
@@ -529,7 +556,7 @@ __pnp_notify_user(
        }\r
        else\r
        {\r
-               cl_qmap_remove_item( &p_reg->context_map, &p_context->map_item );\r
+               cl_fmap_remove_item( &p_reg->context_map, &p_context->map_item );\r
                cl_free( p_context );\r
        }\r
 \r
@@ -545,10 +572,10 @@ __pnp_notify_user(
 al_pnp_context_t*\r
 pnp_create_context(\r
        IN                              al_pnp_t* const                         p_reg,\r
-       IN              const   net64_t                                         guid )\r
+       IN                              const void* const                               p_key )\r
 {\r
        al_pnp_context_t        *p_context;\r
-       cl_map_item_t           *p_item;\r
+       cl_fmap_item_t          *p_item;\r
 \r
        AL_ENTER( AL_DBG_PNP );\r
 \r
@@ -563,14 +590,20 @@ pnp_create_context(
                        sizeof(al_pnp_context_t)) );\r
                return NULL;\r
        }\r
-\r
        /* Store the GUID in the context record. */\r
-       p_context->guid = guid;\r
+       cl_memcpy(&p_context->guid, p_key, sizeof(ib_net64_t) * 2);\r
 \r
        /* Add the context to the context list. */\r
-       p_item = cl_qmap_insert( &p_reg->context_map, p_context->guid,\r
+       p_item = cl_fmap_insert( &p_reg->context_map, &p_context->guid,\r
                &p_context->map_item );\r
-\r
+       if( p_item != &p_context->map_item )\r
+       {\r
+               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_PNP,\r
+                       ("p_context is already in context map %I64x \n",p_context->guid));\r
+               p_context = NULL;\r
+       }\r
+       \r
+       \r
        AL_EXIT( AL_DBG_PNP );\r
        return p_context;\r
 }\r
@@ -603,7 +636,7 @@ __pnp_port_notify(
                p_port_attr += event_rec.port_index;\r
 \r
                /* Create a new context for user port information. */\r
-               p_context = pnp_create_context( p_reg, p_port_attr->port_guid );\r
+               p_context = pnp_create_context( p_reg, &p_port_attr->port_guid);\r
                if( !p_context )\r
                        continue;\r
 \r
@@ -674,7 +707,7 @@ __pnp_reg_notify(
                case IB_PNP_CA:\r
                        event_rec.pnp_event = IB_PNP_CA_ADD;\r
                        p_context = pnp_create_context( p_reg,\r
-                               event_rec.p_ci_ca->p_pnp_attr->ca_guid );\r
+                               &event_rec.p_ci_ca->p_pnp_attr->ca_guid);\r
                        if( !p_context )\r
                                break;\r
 \r
@@ -803,7 +836,19 @@ al_reg_pnp(
 \r
        /* Initialize the registration info. */\r
        construct_al_obj( &p_reg->obj, AL_OBJ_TYPE_H_PNP );\r
-       cl_qmap_init( &p_reg->context_map );\r
+       switch(pnp_get_class(p_pnp_req->pnp_class)){\r
+               case IB_PNP_IOU:\r
+               case IB_PNP_IOC:\r
+                       cl_fmap_init( &p_reg->context_map, __context_cmp128 );\r
+                       break;\r
+               case IB_PNP_PORT:\r
+               case IB_PNP_CA:\r
+                       cl_fmap_init( &p_reg->context_map, __context_cmp64 );\r
+                       break;\r
+               default:\r
+                       AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
+                       ("unknown pnp_class 0x%x.\n", pnp_get_class(p_pnp_req->pnp_class)));\r
+       }\r
        status = init_al_obj( &p_reg->obj, p_pnp_req->pnp_context, TRUE,\r
                __pnp_reg_destroying, __pnp_reg_cleanup, __pnp_reg_free );\r
        if( status != IB_SUCCESS )\r
@@ -924,7 +969,7 @@ __pnp_process_add_ca(
                 * exercise to the open source community.\r
                 */\r
                p_context = pnp_create_context( p_reg,\r
-                       p_event_rec->p_ci_ca->p_pnp_attr->ca_guid );\r
+                       &p_event_rec->p_ci_ca->p_pnp_attr->ca_guid);\r
                if( !p_context )\r
                        continue;\r
 \r
@@ -990,7 +1035,7 @@ __pnp_process_remove_port(
                {\r
                        p_port_attr = p_event_rec->p_ci_ca->p_pnp_attr->p_port_attr;\r
                        p_port_attr += port_index;\r
-                       p_context = pnp_get_context( p_reg, p_port_attr->port_guid );\r
+                       p_context = pnp_get_context( p_reg, &p_port_attr->port_guid );\r
                        if( !p_context )\r
                                continue;\r
 \r
@@ -1014,7 +1059,7 @@ __pnp_process_remove_port(
                                 * Remove the port context from the registrant's\r
                                 * context list.\r
                                 */\r
-                               cl_qmap_remove_item( &p_reg->context_map,\r
+                               cl_fmap_remove_item( &p_reg->context_map,\r
                                        &p_context->map_item );\r
                                /* Free the context. */\r
                                cl_free( p_context );\r
@@ -1054,7 +1099,7 @@ __pnp_process_remove_ca(
 \r
                /* Search the context list for this CA. */\r
                p_context =\r
-                       pnp_get_context( p_reg, p_event_rec->p_ci_ca->verbs.guid );\r
+                       pnp_get_context( p_reg, &p_event_rec->p_ci_ca->p_pnp_attr->ca_guid);\r
 \r
                /* Make sure we found a context. */\r
                if( !p_context )\r
@@ -1064,7 +1109,7 @@ __pnp_process_remove_ca(
                if( __pnp_notify_user( p_reg, p_context, p_event_rec ) == IB_SUCCESS )\r
                {\r
                        /* Remove the context from the context list. */\r
-                       cl_qmap_remove_item( &p_reg->context_map, &p_context->map_item );\r
+                       cl_fmap_remove_item( &p_reg->context_map, &p_context->map_item );\r
 \r
                        /* Deallocate the context block. */\r
                        cl_free( p_context );\r
@@ -1221,7 +1266,7 @@ __pnp_process_port_forward(
                p_port_attr = p_event_rec->p_ci_ca->p_pnp_attr->p_port_attr;\r
                p_port_attr += p_event_rec->port_index;\r
 \r
-               p_context = pnp_get_context( p_reg, p_port_attr->port_guid );\r
+               p_context = pnp_get_context( p_reg, &p_port_attr->port_guid );\r
                if( !p_context )\r
                        continue;\r
 \r
@@ -1260,7 +1305,7 @@ __pnp_process_port_backward(
                p_port_attr = p_event_rec->p_ci_ca->p_pnp_attr->p_port_attr;\r
                p_port_attr += p_event_rec->port_index;\r
 \r
-               p_context = pnp_get_context( p_reg, p_port_attr->port_guid );\r
+               p_context = pnp_get_context( p_reg, &p_port_attr->port_guid );\r
                if( !p_context )\r
                        continue;\r
 \r
index 808c83e..1f1bf4f 100644 (file)
@@ -325,7 +325,7 @@ create_iou_mgr(
        {\r
                cl_obj_destroy( &gp_iou_mgr->obj );\r
                BUS_TRACE_EXIT( BUS_DBG_ERROR, \r
-                       ("ib_reg_pnp returned %s.\n", ib_get_err_str(status)) );\r
+                       ("bus_reg_iou_pnp returned %s.\n", ib_get_err_str(status)) );\r
                return status;\r
        }\r
 \r
index 5f94d50..c3663cf 100644 (file)
@@ -319,7 +319,7 @@ create_port_mgr(
        {\r
                cl_obj_destroy( &gp_port_mgr->obj );\r
                BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
-                       ("ib_reg_pnp returned %s.\n", ib_get_err_str(status)) );\r
+                       ("bus_reg_port_pnp returned %s.\n", ib_get_err_str(status)) );\r
                return status;\r
        }\r
 \r
index d8c028f..381630e 100644 (file)
@@ -199,6 +199,14 @@ typedef struct _iou_pdo_ext
 \r
        cl_list_item_t                  list_item;\r
 \r
+       /* All reported PDOs are children of an HCA. */\r
+       ib_ca_handle_t                  h_ca;\r
+\r
+       /*\r
+        * CA GUID copy - in case we get IRPs after the CA\r
+        * handle has been released.\r
+        */\r
+       net64_t                                 ca_guid;\r
        POWER_STATE                             dev_po_state;\r
 \r
        /*\r
index c59c19e..8a78be9 100644 (file)
@@ -310,7 +310,7 @@ ioc_mgr_init(
        {\r
                cl_obj_destroy( &p_ioc_mgr->obj );\r
                IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
-                       ("ib_reg_pnp returned %s.\n",\r
+                       ("open_al returned %s.\n",\r
                        p_ioc_mgr->ifc.get_err_str(status)) );\r
                return status;\r
        }\r
@@ -538,7 +538,8 @@ ioc_mgr_ioc_add(
        p_ioc_ext->pdo.p_parent_ext = p_ext;\r
        p_ioc_ext->pdo.b_present = TRUE;\r
        p_ioc_ext->pdo.b_reported_missing = FALSE;\r
-\r
+       p_ioc_ext->pdo.ca_guid = p_pnp_rec->ca_guid;\r
+               \r
        /* Copy the IOC profile and service entries. */\r
        p_ioc_ext->info = p_pnp_rec->info;\r
        cl_memcpy( p_ioc_ext->svc_entries, p_pnp_rec->svc_entry_array,\r
@@ -1031,7 +1032,7 @@ ioc_query_unique_id(
        }\r
 \r
        /* The instance ID is the port GUID. */\r
-       p_string = ExAllocatePool( PagedPool, sizeof(WCHAR) * 17 );\r
+       p_string = ExAllocatePool( PagedPool, sizeof(WCHAR) * 33 );\r
        if( !p_string )\r
        {\r
                IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
@@ -1040,8 +1041,8 @@ ioc_query_unique_id(
                return STATUS_NO_MEMORY;\r
        }\r
 \r
-       status = RtlStringCchPrintfW(\r
-               p_string, 17, L"%016I64x", p_ext->info.profile.ioc_guid );\r
+       status = RtlStringCchPrintfW(p_string, 33, L"%016I64x%016I64x",\r
+                p_ext->info.profile.ioc_guid,p_ext->pdo.ca_guid);\r
        if( !NT_SUCCESS( status ) )\r
        {\r
                CL_ASSERT( NT_SUCCESS( status ) );\r