Lines Matching refs:file

74 	struct file		*filp;
88 struct ucma_file *file; member
127 struct ucma_file *file) in _ucma_find_context() argument
134 else if (ctx->file != file) in _ucma_find_context()
139 static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id) in ucma_get_ctx() argument
144 ctx = _ucma_find_context(id, file); in ucma_get_ctx()
183 static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file) in ucma_alloc_ctx() argument
195 ctx->file = file; in ucma_alloc_ctx()
203 list_add_tail(&ctx->list, &file->ctx_list); in ucma_alloc_ctx()
302 queue_work(ctx->file->close_wq, &ctx->close_work); in ucma_removal_event_handler()
306 list_for_each_entry(con_req_eve, &ctx->file->event_list, list) { in ucma_removal_event_handler()
311 queue_work(ctx->file->close_wq, &con_req_eve->close_work); in ucma_removal_event_handler()
331 mutex_lock(&ctx->file->mut); in ucma_event_handler()
365 list_add_tail(&uevent->list, &ctx->file->event_list); in ucma_event_handler()
366 wake_up_interruptible(&ctx->file->poll_wait); in ucma_event_handler()
370 mutex_unlock(&ctx->file->mut); in ucma_event_handler()
374 static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf, in ucma_get_event() argument
388 mutex_lock(&file->mut); in ucma_get_event()
389 while (list_empty(&file->event_list)) { in ucma_get_event()
390 mutex_unlock(&file->mut); in ucma_get_event()
392 if (file->filp->f_flags & O_NONBLOCK) in ucma_get_event()
395 if (wait_event_interruptible(file->poll_wait, in ucma_get_event()
396 !list_empty(&file->event_list))) in ucma_get_event()
399 mutex_lock(&file->mut); in ucma_get_event()
402 uevent = list_entry(file->event_list.next, struct ucma_event, list); in ucma_get_event()
405 ctx = ucma_alloc_ctx(file); in ucma_get_event()
428 mutex_unlock(&file->mut); in ucma_get_event()
450 static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf, in ucma_create_id() argument
469 mutex_lock(&file->mut); in ucma_create_id()
470 ctx = ucma_alloc_ctx(file); in ucma_create_id()
471 mutex_unlock(&file->mut); in ucma_create_id()
518 list_for_each_entry_safe(uevent, tmp, &mc->ctx->file->event_list, list) { in ucma_cleanup_mc_events()
548 mutex_lock(&ctx->file->mut); in ucma_free_ctx()
549 list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) { in ucma_free_ctx()
554 mutex_unlock(&ctx->file->mut); in ucma_free_ctx()
568 static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf, in ucma_destroy_id() argument
583 ctx = _ucma_find_context(cmd.id, file); in ucma_destroy_id()
591 mutex_lock(&ctx->file->mut); in ucma_destroy_id()
593 mutex_unlock(&ctx->file->mut); in ucma_destroy_id()
595 flush_workqueue(ctx->file->close_wq); in ucma_destroy_id()
616 static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf, in ucma_bind_ip() argument
626 ctx = ucma_get_ctx(file, cmd.id); in ucma_bind_ip()
635 static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf, in ucma_bind() argument
650 ctx = ucma_get_ctx(file, cmd.id); in ucma_bind()
659 static ssize_t ucma_resolve_ip(struct ucma_file *file, in ucma_resolve_ip() argument
670 ctx = ucma_get_ctx(file, cmd.id); in ucma_resolve_ip()
681 static ssize_t ucma_resolve_addr(struct ucma_file *file, in ucma_resolve_addr() argument
699 ctx = ucma_get_ctx(file, cmd.id); in ucma_resolve_addr()
708 static ssize_t ucma_resolve_route(struct ucma_file *file, in ucma_resolve_route() argument
719 ctx = ucma_get_ctx(file, cmd.id); in ucma_resolve_route()
792 static ssize_t ucma_query_route(struct ucma_file *file, in ucma_query_route() argument
808 ctx = ucma_get_ctx(file, cmd.id); in ucma_query_route()
961 static ssize_t ucma_query(struct ucma_file *file, in ucma_query() argument
974 ctx = ucma_get_ctx(file, cmd.id); in ucma_query()
1013 static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf, in ucma_connect() argument
1027 ctx = ucma_get_ctx(file, cmd.id); in ucma_connect()
1037 static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf, in ucma_listen() argument
1047 ctx = ucma_get_ctx(file, cmd.id); in ucma_listen()
1058 static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf, in ucma_accept() argument
1069 ctx = ucma_get_ctx(file, cmd.id); in ucma_accept()
1075 mutex_lock(&file->mut); in ucma_accept()
1079 mutex_unlock(&file->mut); in ucma_accept()
1087 static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf, in ucma_reject() argument
1097 ctx = ucma_get_ctx(file, cmd.id); in ucma_reject()
1106 static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf, in ucma_disconnect() argument
1116 ctx = ucma_get_ctx(file, cmd.id); in ucma_disconnect()
1125 static ssize_t ucma_init_qp_attr(struct ucma_file *file, in ucma_init_qp_attr() argument
1141 ctx = ucma_get_ctx(file, cmd.id); in ucma_init_qp_attr()
1262 static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf, in ucma_set_option() argument
1273 ctx = ucma_get_ctx(file, cmd.id); in ucma_set_option()
1293 static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf, in ucma_notify() argument
1303 ctx = ucma_get_ctx(file, cmd.id); in ucma_notify()
1312 static ssize_t ucma_process_join(struct ucma_file *file, in ucma_process_join() argument
1328 ctx = ucma_get_ctx(file, cmd->id); in ucma_process_join()
1332 mutex_lock(&file->mut); in ucma_process_join()
1352 mutex_unlock(&file->mut); in ucma_process_join()
1366 mutex_unlock(&file->mut); in ucma_process_join()
1371 static ssize_t ucma_join_ip_multicast(struct ucma_file *file, in ucma_join_ip_multicast() argument
1388 return ucma_process_join(file, &join_cmd, out_len); in ucma_join_ip_multicast()
1391 static ssize_t ucma_join_multicast(struct ucma_file *file, in ucma_join_multicast() argument
1400 return ucma_process_join(file, &cmd, out_len); in ucma_join_multicast()
1403 static ssize_t ucma_leave_multicast(struct ucma_file *file, in ucma_leave_multicast() argument
1422 else if (mc->ctx->file != file) in ucma_leave_multicast()
1436 mutex_lock(&mc->ctx->file->mut); in ucma_leave_multicast()
1439 mutex_unlock(&mc->ctx->file->mut); in ucma_leave_multicast()
1475 static void ucma_move_events(struct ucma_context *ctx, struct ucma_file *file) in ucma_move_events() argument
1479 list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) in ucma_move_events()
1481 list_move_tail(&uevent->list, &file->event_list); in ucma_move_events()
1500 if (!f.file) in ucma_migrate_id()
1504 ctx = ucma_get_ctx(f.file->private_data, cmd.id); in ucma_migrate_id()
1510 cur_file = ctx->file; in ucma_migrate_id()
1525 ctx->file = new_file; in ucma_migrate_id()
1542 static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
1570 static ssize_t ucma_write(struct file *filp, const char __user *buf, in ucma_write()
1573 struct ucma_file *file = filp->private_data; in ucma_write() local
1595 ret = ucma_cmd_table[hdr.cmd](file, buf + sizeof(hdr), hdr.in, hdr.out); in ucma_write()
1602 static unsigned int ucma_poll(struct file *filp, struct poll_table_struct *wait) in ucma_poll()
1604 struct ucma_file *file = filp->private_data; in ucma_poll() local
1607 poll_wait(filp, &file->poll_wait, wait); in ucma_poll()
1609 if (!list_empty(&file->event_list)) in ucma_poll()
1623 static int ucma_open(struct inode *inode, struct file *filp) in ucma_open()
1625 struct ucma_file *file; in ucma_open() local
1627 file = kmalloc(sizeof *file, GFP_KERNEL); in ucma_open()
1628 if (!file) in ucma_open()
1631 file->close_wq = create_singlethread_workqueue("ucma_close_id"); in ucma_open()
1632 if (!file->close_wq) { in ucma_open()
1633 kfree(file); in ucma_open()
1637 INIT_LIST_HEAD(&file->event_list); in ucma_open()
1638 INIT_LIST_HEAD(&file->ctx_list); in ucma_open()
1639 init_waitqueue_head(&file->poll_wait); in ucma_open()
1640 mutex_init(&file->mut); in ucma_open()
1642 filp->private_data = file; in ucma_open()
1643 file->filp = filp; in ucma_open()
1648 static int ucma_close(struct inode *inode, struct file *filp) in ucma_close()
1650 struct ucma_file *file = filp->private_data; in ucma_close() local
1653 mutex_lock(&file->mut); in ucma_close()
1654 list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) { in ucma_close()
1656 mutex_unlock(&file->mut); in ucma_close()
1662 flush_workqueue(file->close_wq); in ucma_close()
1679 mutex_lock(&file->mut); in ucma_close()
1681 mutex_unlock(&file->mut); in ucma_close()
1682 destroy_workqueue(file->close_wq); in ucma_close()
1683 kfree(file); in ucma_close()