ib/cm: separate listen callback into own handler
authorLOCALS~1\Temp/report.7.tmp <LOCALS~1\Temp/report.7.tmp@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 13 Jan 2010 19:34:07 +0000 (19:34 +0000)
committerLOCALS~1\Temp/report.7.tmp <LOCALS~1\Temp/report.7.tmp@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 13 Jan 2010 19:34:07 +0000 (19:34 +0000)
Extract listen handling in cm_cep_handler into a separate
handler.  This will simplify changes to support queuing
connection requests and allow connection requests to move
to a fetch model, rather than a callback model.

Since connection requests require allocating new resources,
connection rates can be improved by queuing the requests
until the user has allocated the resources, then fetches
the request.

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

core/al/kernel/al_cm.c

index 955985a..177bb9e 100644 (file)
@@ -77,28 +77,49 @@ cm_cep_handler(const ib_al_handle_t h_al, const net32_t cid)
        void                            *context;\r
        net32_t                         new_cid;\r
        ib_mad_element_t        *mad;\r
-       iba_cm_id                       *id, *listen_id;\r
+       iba_cm_id                       *id;\r
        iba_cm_event            event;\r
        NTSTATUS                        status;\r
 \r
        while (al_cep_poll(h_al, cid, &context, &new_cid, &mad) == IB_SUCCESS) {\r
 \r
-               if (new_cid == AL_INVALID_CID) {\r
-                       id = (iba_cm_id *) context;\r
-               } else {\r
-                       listen_id = (iba_cm_id *) context;\r
+               id = (iba_cm_id *) context;\r
+               kal_cep_format_event(h_al, id->cid, mad, &event);\r
+\r
+               status = id->callback(id, &event);\r
+               if (!NT_SUCCESS(status)) {\r
+                       kal_cep_config(h_al, new_cid, NULL, NULL, NULL);\r
+                       kal_cep_destroy(h_al, id->cid, status);\r
+                       cm_free_id(id);\r
+               }\r
+               ib_put_mad(mad);\r
+       }\r
+}\r
+\r
+static void\r
+cm_listen_handler(const ib_al_handle_t h_al, const net32_t cid)\r
+{\r
+       void                            *context;\r
+       net32_t                         new_cid;\r
+       ib_mad_element_t        *mad;\r
+       iba_cm_id                       *id, *listen_id;\r
+       iba_cm_event            event;\r
+       NTSTATUS                        status;\r
+\r
+       while (al_cep_poll(h_al, cid, &context, &new_cid, &mad) == IB_SUCCESS) {\r
 \r
-                       id = cm_alloc_id(listen_id->callback, listen_id);\r
-                       if (id == NULL) {\r
-                               kal_cep_destroy(h_al, new_cid, STATUS_NO_MORE_ENTRIES);\r
-                               ib_put_mad(mad);\r
-                               continue;\r
-                       }\r
+               listen_id = (iba_cm_id *) context;\r
 \r
-                       kal_cep_config(h_al, new_cid, cm_cep_handler, id, cm_destroy_handler);\r
-                       id->cid = new_cid;\r
+               id = cm_alloc_id(listen_id->callback, listen_id);\r
+               if (id == NULL) {\r
+                       kal_cep_destroy(h_al, new_cid, STATUS_NO_MORE_ENTRIES);\r
+                       ib_put_mad(mad);\r
+                       continue;\r
                }\r
 \r
+               kal_cep_config(h_al, new_cid, cm_cep_handler, id, cm_destroy_handler);\r
+               id->cid = new_cid;\r
+\r
                kal_cep_format_event(h_al, id->cid, mad, &event);\r
                status = id->callback(id, &event);\r
                if (!NT_SUCCESS(status)) {\r
@@ -157,6 +178,7 @@ cm_listen(iba_cm_id *p_id, net64_t service_id, void *p_compare_buf,
        info.cmp_len = compare_len;\r
        info.cmp_offset = compare_offset;\r
        \r
+       kal_cep_config(gh_al, p_id->cid, cm_listen_handler, p_id, cm_destroy_handler);\r
        ib_status = al_cep_listen(gh_al, p_id->cid, &info);\r
        return ib_to_ntstatus(ib_status);\r
 }\r