Lines Matching refs:ctx

91 	struct list_head    file_list; /* member in file ctx list */
95 struct ib_ucm_context *ctx;
97 struct list_head ctx_list; /* member in ctx event list */
130 struct ib_ucm_context *ctx;
133 ctx = idr_find(&ctx_id_table, id);
134 if (!ctx)
135 ctx = ERR_PTR(-ENOENT);
136 else if (ctx->file != file)
137 ctx = ERR_PTR(-EINVAL);
139 atomic_inc(&ctx->ref);
142 return ctx;
145 static void ib_ucm_ctx_put(struct ib_ucm_context *ctx)
147 if (atomic_dec_and_test(&ctx->ref))
148 complete(&ctx->comp);
156 static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
160 mutex_lock(&ctx->file->file_mutex);
161 list_del(&ctx->file_list);
162 while (!list_empty(&ctx->events)) {
164 uevent = list_entry(ctx->events.next,
168 mutex_unlock(&ctx->file->file_mutex);
175 mutex_lock(&ctx->file->file_mutex);
177 mutex_unlock(&ctx->file->file_mutex);
182 struct ib_ucm_context *ctx;
184 ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
185 if (!ctx)
188 atomic_set(&ctx->ref, 1);
189 init_completion(&ctx->comp);
190 ctx->file = file;
191 INIT_LIST_HEAD(&ctx->events);
194 ctx->id = idr_alloc(&ctx_id_table, ctx, 0, 0, GFP_KERNEL);
196 if (ctx->id < 0)
199 list_add_tail(&ctx->file_list, &file->ctxs);
200 return ctx;
203 kfree(ctx);
355 struct ib_ucm_context *ctx;
358 ctx = cm_id->context;
364 uevent->ctx = ctx;
366 uevent->resp.uid = ctx->uid;
367 uevent->resp.id = ctx->id;
374 mutex_lock(&ctx->file->file_mutex);
375 list_add_tail(&uevent->file_list, &ctx->file->events);
376 list_add_tail(&uevent->ctx_list, &ctx->events);
377 wake_up_interruptible(&ctx->file->poll_wait);
378 mutex_unlock(&ctx->file->file_mutex);
392 struct ib_ucm_context *ctx;
420 ctx = ib_ucm_ctx_alloc(file);
421 if (!ctx) {
426 ctx->cm_id = uevent->cm_id;
427 ctx->cm_id->context = ctx;
428 uevent->resp.id = ctx->id;
463 uevent->ctx->events_reported++;
479 struct ib_ucm_context *ctx;
489 ctx = ib_ucm_ctx_alloc(file);
491 if (!ctx)
494 ctx->uid = cmd.uid;
495 ctx->cm_id = ib_create_cm_id(file->device->ib_dev,
496 ib_ucm_event_handler, ctx);
497 if (IS_ERR(ctx->cm_id)) {
498 result = PTR_ERR(ctx->cm_id);
502 resp.id = ctx->id;
511 ib_destroy_cm_id(ctx->cm_id);
514 idr_remove(&ctx_id_table, ctx->id);
516 kfree(ctx);
526 struct ib_ucm_context *ctx;
536 ctx = idr_find(&ctx_id_table, cmd.id);
537 if (!ctx)
538 ctx = ERR_PTR(-ENOENT);
539 else if (ctx->file != file)
540 ctx = ERR_PTR(-EINVAL);
542 idr_remove(&ctx_id_table, ctx->id);
545 if (IS_ERR(ctx))
546 return PTR_ERR(ctx);
548 ib_ucm_ctx_put(ctx);
549 wait_for_completion(&ctx->comp);
552 ib_destroy_cm_id(ctx->cm_id);
554 ib_ucm_cleanup_events(ctx);
556 resp.events_reported = ctx->events_reported;
561 kfree(ctx);
571 struct ib_ucm_context *ctx;
580 ctx = ib_ucm_ctx_get(file, cmd.id);
581 if (IS_ERR(ctx))
582 return PTR_ERR(ctx);
584 resp.service_id = ctx->cm_id->service_id;
585 resp.service_mask = ctx->cm_id->service_mask;
586 resp.local_id = ctx->cm_id->local_id;
587 resp.remote_id = ctx->cm_id->remote_id;
593 ib_ucm_ctx_put(ctx);
603 struct ib_ucm_context *ctx;
613 ctx = ib_ucm_ctx_get(file, cmd.id);
614 if (IS_ERR(ctx))
615 return PTR_ERR(ctx);
620 result = ib_cm_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask);
631 ib_ucm_ctx_put(ctx);
651 struct ib_ucm_context *ctx;
657 ctx = ib_ucm_ctx_get(file, cmd.id);
658 if (IS_ERR(ctx))
659 return PTR_ERR(ctx);
665 result = ib_cm_listen(ctx->cm_id, cmd.service_id, cmd.service_mask);
667 ib_ucm_ctx_put(ctx);
676 struct ib_ucm_context *ctx;
682 ctx = ib_ucm_ctx_get(file, cmd.id);
683 if (IS_ERR(ctx))
684 return PTR_ERR(ctx);
686 result = ib_cm_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
687 ib_ucm_ctx_put(ctx);
739 struct ib_ucm_context *ctx;
778 ctx = ib_ucm_ctx_get(file, cmd.id);
779 if (!IS_ERR(ctx)) {
780 result = ib_send_cm_req(ctx->cm_id, &param);
781 ib_ucm_ctx_put(ctx);
783 result = PTR_ERR(ctx);
797 struct ib_ucm_context *ctx;
820 ctx = ib_ucm_ctx_get(file, cmd.id);
821 if (!IS_ERR(ctx)) {
822 ctx->uid = cmd.uid;
823 result = ib_send_cm_rep(ctx->cm_id, &param);
824 ib_ucm_ctx_put(ctx);
826 result = PTR_ERR(ctx);
839 struct ib_ucm_context *ctx;
850 ctx = ib_ucm_ctx_get(file, cmd.id);
851 if (!IS_ERR(ctx)) {
852 result = func(ctx->cm_id, private_data, cmd.len);
853 ib_ucm_ctx_put(ctx);
855 result = PTR_ERR(ctx);
891 struct ib_ucm_context *ctx;
908 ctx = ib_ucm_ctx_get(file, cmd.id);
909 if (!IS_ERR(ctx)) {
910 result = func(ctx->cm_id, cmd.status, info, cmd.info_len,
912 ib_ucm_ctx_put(ctx);
914 result = PTR_ERR(ctx);
940 struct ib_ucm_context *ctx;
952 ctx = ib_ucm_ctx_get(file, cmd.id);
953 if (!IS_ERR(ctx)) {
954 result = ib_send_cm_mra(ctx->cm_id, cmd.timeout, data, cmd.len);
955 ib_ucm_ctx_put(ctx);
957 result = PTR_ERR(ctx);
967 struct ib_ucm_context *ctx;
984 ctx = ib_ucm_ctx_get(file, cmd.id);
985 if (!IS_ERR(ctx)) {
986 result = ib_send_cm_lap(ctx->cm_id, path, data, cmd.len);
987 ib_ucm_ctx_put(ctx);
989 result = PTR_ERR(ctx);
1002 struct ib_ucm_context *ctx;
1025 ctx = ib_ucm_ctx_get(file, cmd.id);
1026 if (!IS_ERR(ctx)) {
1027 result = ib_send_cm_sidr_req(ctx->cm_id, &param);
1028 ib_ucm_ctx_put(ctx);
1030 result = PTR_ERR(ctx);
1044 struct ib_ucm_context *ctx;
1067 ctx = ib_ucm_ctx_get(file, cmd.id);
1068 if (!IS_ERR(ctx)) {
1069 result = ib_send_cm_sidr_rep(ctx->cm_id, &param);
1070 ib_ucm_ctx_put(ctx);
1072 result = PTR_ERR(ctx);
1179 struct ib_ucm_context *ctx;
1183 ctx = list_entry(file->ctxs.next,
1188 idr_remove(&ctx_id_table, ctx->id);
1191 ib_destroy_cm_id(ctx->cm_id);
1192 ib_ucm_cleanup_events(ctx);
1193 kfree(ctx);