[ofw] [PATCH 2/4] ib/cm: separate listen callback into own handler
Sean Hefty
sean.hefty at intel.com
Mon Jan 11 22:32:02 PST 2010
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 at intel.com>
---
This patch should go into WinoF 2.2 after committing to the trunk.
trunk/core/al/kernel/al_cm.c | 48 +++++++++++++++++++++++++++++++-----------
1 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/trunk/core/al/kernel/al_cm.c b/trunk/core/al/kernel/al_cm.c
index 955985a..177bb9e 100644
--- a/trunk/core/al/kernel/al_cm.c
+++ b/trunk/core/al/kernel/al_cm.c
@@ -77,28 +77,49 @@ cm_cep_handler(const ib_al_handle_t h_al, const net32_t cid)
void *context;
net32_t new_cid;
ib_mad_element_t *mad;
- iba_cm_id *id, *listen_id;
+ iba_cm_id *id;
iba_cm_event event;
NTSTATUS status;
while (al_cep_poll(h_al, cid, &context, &new_cid, &mad) == IB_SUCCESS) {
- if (new_cid == AL_INVALID_CID) {
- id = (iba_cm_id *) context;
- } else {
- listen_id = (iba_cm_id *) context;
+ id = (iba_cm_id *) context;
+ kal_cep_format_event(h_al, id->cid, mad, &event);
+
+ status = id->callback(id, &event);
+ if (!NT_SUCCESS(status)) {
+ kal_cep_config(h_al, new_cid, NULL, NULL, NULL);
+ kal_cep_destroy(h_al, id->cid, status);
+ cm_free_id(id);
+ }
+ ib_put_mad(mad);
+ }
+}
+
+static void
+cm_listen_handler(const ib_al_handle_t h_al, const net32_t cid)
+{
+ void *context;
+ net32_t new_cid;
+ ib_mad_element_t *mad;
+ iba_cm_id *id, *listen_id;
+ iba_cm_event event;
+ NTSTATUS status;
+
+ while (al_cep_poll(h_al, cid, &context, &new_cid, &mad) == IB_SUCCESS) {
- id = cm_alloc_id(listen_id->callback, listen_id);
- if (id == NULL) {
- kal_cep_destroy(h_al, new_cid, STATUS_NO_MORE_ENTRIES);
- ib_put_mad(mad);
- continue;
- }
+ listen_id = (iba_cm_id *) context;
- kal_cep_config(h_al, new_cid, cm_cep_handler, id, cm_destroy_handler);
- id->cid = new_cid;
+ id = cm_alloc_id(listen_id->callback, listen_id);
+ if (id == NULL) {
+ kal_cep_destroy(h_al, new_cid, STATUS_NO_MORE_ENTRIES);
+ ib_put_mad(mad);
+ continue;
}
+ kal_cep_config(h_al, new_cid, cm_cep_handler, id, cm_destroy_handler);
+ id->cid = new_cid;
+
kal_cep_format_event(h_al, id->cid, mad, &event);
status = id->callback(id, &event);
if (!NT_SUCCESS(status)) {
@@ -157,6 +178,7 @@ cm_listen(iba_cm_id *p_id, net64_t service_id, void *p_compare_buf,
info.cmp_len = compare_len;
info.cmp_offset = compare_offset;
+ kal_cep_config(gh_al, p_id->cid, cm_listen_handler, p_id, cm_destroy_handler);
ib_status = al_cep_listen(gh_al, p_id->cid, &info);
return ib_to_ntstatus(ib_status);
}
More information about the ofw
mailing list