Commit 07d357d0 authored by Sean Hefty's avatar Sean Hefty Committed by Roland Dreier

[IB] CM: bind IDs to a specific device

Bind communication identifiers to a device to support device removal.
Export per HCA CM devices to userspace.
Signed-off-by: default avatarSean Hefty <sean.hefty@intel.com>
parent 595e726a
...@@ -366,9 +366,15 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) ...@@ -366,9 +366,15 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
cur_cm_id_priv = rb_entry(parent, struct cm_id_private, cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
service_node); service_node);
if ((cur_cm_id_priv->id.service_mask & service_id) == if ((cur_cm_id_priv->id.service_mask & service_id) ==
(service_mask & cur_cm_id_priv->id.service_id)) (service_mask & cur_cm_id_priv->id.service_id) &&
return cm_id_priv; (cm_id_priv->id.device == cur_cm_id_priv->id.device))
if (service_id < cur_cm_id_priv->id.service_id) return cur_cm_id_priv;
if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
link = &(*link)->rb_left;
else if (cm_id_priv->id.device > cur_cm_id_priv->id.device)
link = &(*link)->rb_right;
else if (service_id < cur_cm_id_priv->id.service_id)
link = &(*link)->rb_left; link = &(*link)->rb_left;
else else
link = &(*link)->rb_right; link = &(*link)->rb_right;
...@@ -378,7 +384,8 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) ...@@ -378,7 +384,8 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
return NULL; return NULL;
} }
static struct cm_id_private * cm_find_listen(__be64 service_id) static struct cm_id_private * cm_find_listen(struct ib_device *device,
__be64 service_id)
{ {
struct rb_node *node = cm.listen_service_table.rb_node; struct rb_node *node = cm.listen_service_table.rb_node;
struct cm_id_private *cm_id_priv; struct cm_id_private *cm_id_priv;
...@@ -386,9 +393,15 @@ static struct cm_id_private * cm_find_listen(__be64 service_id) ...@@ -386,9 +393,15 @@ static struct cm_id_private * cm_find_listen(__be64 service_id)
while (node) { while (node) {
cm_id_priv = rb_entry(node, struct cm_id_private, service_node); cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
if ((cm_id_priv->id.service_mask & service_id) == if ((cm_id_priv->id.service_mask & service_id) ==
(cm_id_priv->id.service_mask & cm_id_priv->id.service_id)) cm_id_priv->id.service_id &&
(cm_id_priv->id.device == device))
return cm_id_priv; return cm_id_priv;
if (service_id < cm_id_priv->id.service_id)
if (device < cm_id_priv->id.device)
node = node->rb_left;
else if (device > cm_id_priv->id.device)
node = node->rb_right;
else if (service_id < cm_id_priv->id.service_id)
node = node->rb_left; node = node->rb_left;
else else
node = node->rb_right; node = node->rb_right;
...@@ -523,7 +536,8 @@ static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv, ...@@ -523,7 +536,8 @@ static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv,
ib_send_cm_sidr_rep(&cm_id_priv->id, &param); ib_send_cm_sidr_rep(&cm_id_priv->id, &param);
} }
struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler, struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
ib_cm_handler cm_handler,
void *context) void *context)
{ {
struct cm_id_private *cm_id_priv; struct cm_id_private *cm_id_priv;
...@@ -535,6 +549,7 @@ struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler, ...@@ -535,6 +549,7 @@ struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler,
memset(cm_id_priv, 0, sizeof *cm_id_priv); memset(cm_id_priv, 0, sizeof *cm_id_priv);
cm_id_priv->id.state = IB_CM_IDLE; cm_id_priv->id.state = IB_CM_IDLE;
cm_id_priv->id.device = device;
cm_id_priv->id.cm_handler = cm_handler; cm_id_priv->id.cm_handler = cm_handler;
cm_id_priv->id.context = context; cm_id_priv->id.context = context;
cm_id_priv->id.remote_cm_qpn = 1; cm_id_priv->id.remote_cm_qpn = 1;
...@@ -1047,7 +1062,6 @@ static void cm_format_req_event(struct cm_work *work, ...@@ -1047,7 +1062,6 @@ static void cm_format_req_event(struct cm_work *work,
req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
param = &work->cm_event.param.req_rcvd; param = &work->cm_event.param.req_rcvd;
param->listen_id = listen_id; param->listen_id = listen_id;
param->device = cm_id_priv->av.port->mad_agent->device;
param->port = cm_id_priv->av.port->port_num; param->port = cm_id_priv->av.port->port_num;
param->primary_path = &work->path[0]; param->primary_path = &work->path[0];
if (req_msg->alt_local_lid) if (req_msg->alt_local_lid)
...@@ -1226,7 +1240,8 @@ static struct cm_id_private * cm_match_req(struct cm_work *work, ...@@ -1226,7 +1240,8 @@ static struct cm_id_private * cm_match_req(struct cm_work *work,
} }
/* Find matching listen request. */ /* Find matching listen request. */
listen_cm_id_priv = cm_find_listen(req_msg->service_id); listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device,
req_msg->service_id);
if (!listen_cm_id_priv) { if (!listen_cm_id_priv) {
spin_unlock_irqrestore(&cm.lock, flags); spin_unlock_irqrestore(&cm.lock, flags);
cm_issue_rej(work->port, work->mad_recv_wc, cm_issue_rej(work->port, work->mad_recv_wc,
...@@ -1254,7 +1269,7 @@ static int cm_req_handler(struct cm_work *work) ...@@ -1254,7 +1269,7 @@ static int cm_req_handler(struct cm_work *work)
req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
cm_id = ib_create_cm_id(NULL, NULL); cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
if (IS_ERR(cm_id)) if (IS_ERR(cm_id))
return PTR_ERR(cm_id); return PTR_ERR(cm_id);
...@@ -2629,7 +2644,6 @@ static void cm_format_sidr_req_event(struct cm_work *work, ...@@ -2629,7 +2644,6 @@ static void cm_format_sidr_req_event(struct cm_work *work,
param = &work->cm_event.param.sidr_req_rcvd; param = &work->cm_event.param.sidr_req_rcvd;
param->pkey = __be16_to_cpu(sidr_req_msg->pkey); param->pkey = __be16_to_cpu(sidr_req_msg->pkey);
param->listen_id = listen_id; param->listen_id = listen_id;
param->device = work->port->mad_agent->device;
param->port = work->port->port_num; param->port = work->port->port_num;
work->cm_event.private_data = &sidr_req_msg->private_data; work->cm_event.private_data = &sidr_req_msg->private_data;
} }
...@@ -2642,7 +2656,7 @@ static int cm_sidr_req_handler(struct cm_work *work) ...@@ -2642,7 +2656,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
struct ib_wc *wc; struct ib_wc *wc;
unsigned long flags; unsigned long flags;
cm_id = ib_create_cm_id(NULL, NULL); cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
if (IS_ERR(cm_id)) if (IS_ERR(cm_id))
return PTR_ERR(cm_id); return PTR_ERR(cm_id);
cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_id_priv = container_of(cm_id, struct cm_id_private, id);
...@@ -2666,7 +2680,8 @@ static int cm_sidr_req_handler(struct cm_work *work) ...@@ -2666,7 +2680,8 @@ static int cm_sidr_req_handler(struct cm_work *work)
spin_unlock_irqrestore(&cm.lock, flags); spin_unlock_irqrestore(&cm.lock, flags);
goto out; /* Duplicate message. */ goto out; /* Duplicate message. */
} }
cur_cm_id_priv = cm_find_listen(sidr_req_msg->service_id); cur_cm_id_priv = cm_find_listen(cm_id->device,
sidr_req_msg->service_id);
if (!cur_cm_id_priv) { if (!cur_cm_id_priv) {
rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
spin_unlock_irqrestore(&cm.lock, flags); spin_unlock_irqrestore(&cm.lock, flags);
......
...@@ -52,12 +52,20 @@ MODULE_AUTHOR("Libor Michalek"); ...@@ -52,12 +52,20 @@ MODULE_AUTHOR("Libor Michalek");
MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access"); MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access");
MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE("Dual BSD/GPL");
struct ib_ucm_device {
int devnum;
struct cdev dev;
struct class_device class_dev;
struct ib_device *ib_dev;
};
struct ib_ucm_file { struct ib_ucm_file {
struct semaphore mutex; struct semaphore mutex;
struct file *filp; struct file *filp;
struct ib_ucm_device *device;
struct list_head ctxs; /* list of active connections */ struct list_head ctxs;
struct list_head events; /* list of pending events */ struct list_head events;
wait_queue_head_t poll_wait; wait_queue_head_t poll_wait;
}; };
...@@ -90,14 +98,24 @@ struct ib_ucm_event { ...@@ -90,14 +98,24 @@ struct ib_ucm_event {
enum { enum {
IB_UCM_MAJOR = 231, IB_UCM_MAJOR = 231,
IB_UCM_MINOR = 255 IB_UCM_BASE_MINOR = 224,
IB_UCM_MAX_DEVICES = 32
}; };
#define IB_UCM_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_MINOR) #define IB_UCM_BASE_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_BASE_MINOR)
static struct semaphore ctx_id_mutex; static void ib_ucm_add_one(struct ib_device *device);
static struct idr ctx_id_table; static void ib_ucm_remove_one(struct ib_device *device);
static struct ib_client ucm_client = {
.name = "ucm",
.add = ib_ucm_add_one,
.remove = ib_ucm_remove_one
};
DECLARE_MUTEX(ctx_id_mutex);
DEFINE_IDR(ctx_id_table);
static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);
static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
{ {
...@@ -184,10 +202,7 @@ error: ...@@ -184,10 +202,7 @@ error:
kfree(ctx); kfree(ctx);
return NULL; return NULL;
} }
/*
* Event portion of the API, handle CM events
* and allow event polling.
*/
static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath, static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath,
struct ib_sa_path_rec *kpath) struct ib_sa_path_rec *kpath)
{ {
...@@ -234,6 +249,7 @@ static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq, ...@@ -234,6 +249,7 @@ static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
ureq->retry_count = kreq->retry_count; ureq->retry_count = kreq->retry_count;
ureq->rnr_retry_count = kreq->rnr_retry_count; ureq->rnr_retry_count = kreq->rnr_retry_count;
ureq->srq = kreq->srq; ureq->srq = kreq->srq;
ureq->port = kreq->port;
ib_ucm_event_path_get(&ureq->primary_path, kreq->primary_path); ib_ucm_event_path_get(&ureq->primary_path, kreq->primary_path);
ib_ucm_event_path_get(&ureq->alternate_path, kreq->alternate_path); ib_ucm_event_path_get(&ureq->alternate_path, kreq->alternate_path);
...@@ -320,6 +336,8 @@ static int ib_ucm_event_process(struct ib_cm_event *evt, ...@@ -320,6 +336,8 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
case IB_CM_SIDR_REQ_RECEIVED: case IB_CM_SIDR_REQ_RECEIVED:
uvt->resp.u.sidr_req_resp.pkey = uvt->resp.u.sidr_req_resp.pkey =
evt->param.sidr_req_rcvd.pkey; evt->param.sidr_req_rcvd.pkey;
uvt->resp.u.sidr_req_resp.port =
evt->param.sidr_req_rcvd.port;
uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE; uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE;
break; break;
case IB_CM_SIDR_REP_RECEIVED: case IB_CM_SIDR_REP_RECEIVED:
...@@ -412,9 +430,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file, ...@@ -412,9 +430,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,
if (copy_from_user(&cmd, inbuf, sizeof(cmd))) if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
return -EFAULT; return -EFAULT;
/*
* wait
*/
down(&file->mutex); down(&file->mutex);
while (list_empty(&file->events)) { while (list_empty(&file->events)) {
...@@ -496,7 +512,6 @@ done: ...@@ -496,7 +512,6 @@ done:
return result; return result;
} }
static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
const char __user *inbuf, const char __user *inbuf,
int in_len, int out_len) int in_len, int out_len)
...@@ -519,29 +534,27 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, ...@@ -519,29 +534,27 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
return -ENOMEM; return -ENOMEM;
ctx->uid = cmd.uid; ctx->uid = cmd.uid;
ctx->cm_id = ib_create_cm_id(ib_ucm_event_handler, ctx); ctx->cm_id = ib_create_cm_id(file->device->ib_dev,
ib_ucm_event_handler, ctx);
if (IS_ERR(ctx->cm_id)) { if (IS_ERR(ctx->cm_id)) {
result = PTR_ERR(ctx->cm_id); result = PTR_ERR(ctx->cm_id);
goto err; goto err1;
} }
resp.id = ctx->id; resp.id = ctx->id;
if (copy_to_user((void __user *)(unsigned long)cmd.response, if (copy_to_user((void __user *)(unsigned long)cmd.response,
&resp, sizeof(resp))) { &resp, sizeof(resp))) {
result = -EFAULT; result = -EFAULT;
goto err; goto err2;
} }
return 0; return 0;
err: err2:
ib_destroy_cm_id(ctx->cm_id);
err1:
down(&ctx_id_mutex); down(&ctx_id_mutex);
idr_remove(&ctx_id_table, ctx->id); idr_remove(&ctx_id_table, ctx->id);
up(&ctx_id_mutex); up(&ctx_id_mutex);
if (!IS_ERR(ctx->cm_id))
ib_destroy_cm_id(ctx->cm_id);
kfree(ctx); kfree(ctx);
return result; return result;
} }
...@@ -1253,6 +1266,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp) ...@@ -1253,6 +1266,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
filp->private_data = file; filp->private_data = file;
file->filp = filp; file->filp = filp;
file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev);
return 0; return 0;
} }
...@@ -1283,7 +1297,17 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) ...@@ -1283,7 +1297,17 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
return 0; return 0;
} }
static struct file_operations ib_ucm_fops = { static void ib_ucm_release_class_dev(struct class_device *class_dev)
{
struct ib_ucm_device *dev;
dev = container_of(class_dev, struct ib_ucm_device, class_dev);
cdev_del(&dev->dev);
clear_bit(dev->devnum, dev_map);
kfree(dev);
}
static struct file_operations ucm_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = ib_ucm_open, .open = ib_ucm_open,
.release = ib_ucm_close, .release = ib_ucm_close,
...@@ -1291,55 +1315,141 @@ static struct file_operations ib_ucm_fops = { ...@@ -1291,55 +1315,141 @@ static struct file_operations ib_ucm_fops = {
.poll = ib_ucm_poll, .poll = ib_ucm_poll,
}; };
static struct class ucm_class = {
.name = "infiniband_cm",
.release = ib_ucm_release_class_dev
};
static struct class *ib_ucm_class; static ssize_t show_dev(struct class_device *class_dev, char *buf)
static struct cdev ib_ucm_cdev; {
struct ib_ucm_device *dev;
static int __init ib_ucm_init(void) dev = container_of(class_dev, struct ib_ucm_device, class_dev);
return print_dev_t(buf, dev->dev.dev);
}
static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
{ {
int result; struct ib_ucm_device *dev;
result = register_chrdev_region(IB_UCM_DEV, 1, "infiniband_cm"); dev = container_of(class_dev, struct ib_ucm_device, class_dev);
if (result) { return sprintf(buf, "%s\n", dev->ib_dev->name);
printk(KERN_ERR "ucm: Error <%d> registering dev\n", result); }
goto err_chr; static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
}
static void ib_ucm_add_one(struct ib_device *device)
{
struct ib_ucm_device *ucm_dev;
if (!device->alloc_ucontext)
return;
ucm_dev = kmalloc(sizeof *ucm_dev, GFP_KERNEL);
if (!ucm_dev)
return;
memset(ucm_dev, 0, sizeof *ucm_dev);
ucm_dev->ib_dev = device;
ucm_dev->devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES);
if (ucm_dev->devnum >= IB_UCM_MAX_DEVICES)
goto err;
set_bit(ucm_dev->devnum, dev_map);
cdev_init(&ib_ucm_cdev, &ib_ucm_fops); cdev_init(&ucm_dev->dev, &ucm_fops);
ucm_dev->dev.owner = THIS_MODULE;
kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum);
if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
goto err;
result = cdev_add(&ib_ucm_cdev, IB_UCM_DEV, 1); ucm_dev->class_dev.class = &ucm_class;
if (result) { ucm_dev->class_dev.dev = device->dma_device;
printk(KERN_ERR "ucm: Error <%d> adding cdev\n", result); snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d",
ucm_dev->devnum);
if (class_device_register(&ucm_dev->class_dev))
goto err_cdev; goto err_cdev;
}
ib_ucm_class = class_create(THIS_MODULE, "infiniband_cm"); if (class_device_create_file(&ucm_dev->class_dev,
if (IS_ERR(ib_ucm_class)) { &class_device_attr_dev))
result = PTR_ERR(ib_ucm_class); goto err_class;
printk(KERN_ERR "Error <%d> creating class\n", result); if (class_device_create_file(&ucm_dev->class_dev,
&class_device_attr_ibdev))
goto err_class; goto err_class;
ib_set_client_data(device, &ucm_client, ucm_dev);
return;
err_class:
class_device_unregister(&ucm_dev->class_dev);
err_cdev:
cdev_del(&ucm_dev->dev);
clear_bit(ucm_dev->devnum, dev_map);
err:
kfree(ucm_dev);
return;
}
static void ib_ucm_remove_one(struct ib_device *device)
{
struct ib_ucm_device *ucm_dev = ib_get_client_data(device, &ucm_client);
if (!ucm_dev)
return;
class_device_unregister(&ucm_dev->class_dev);
}
static ssize_t show_abi_version(struct class *class, char *buf)
{
return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION);
}
static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
static int __init ib_ucm_init(void)
{
int ret;
ret = register_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES,
"infiniband_cm");
if (ret) {
printk(KERN_ERR "ucm: couldn't register device number\n");
goto err;
} }
class_device_create(ib_ucm_class, IB_UCM_DEV, NULL, "ucm"); ret = class_register(&ucm_class);
if (ret) {
printk(KERN_ERR "ucm: couldn't create class infiniband_cm\n");
goto err_chrdev;
}
idr_init(&ctx_id_table); ret = class_create_file(&ucm_class, &class_attr_abi_version);
init_MUTEX(&ctx_id_mutex); if (ret) {
printk(KERN_ERR "ucm: couldn't create abi_version attribute\n");
goto err_class;
}
ret = ib_register_client(&ucm_client);
if (ret) {
printk(KERN_ERR "ucm: couldn't register client\n");
goto err_class;
}
return 0; return 0;
err_class: err_class:
cdev_del(&ib_ucm_cdev); class_unregister(&ucm_class);
err_cdev: err_chrdev:
unregister_chrdev_region(IB_UCM_DEV, 1); unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
err_chr: err:
return result; return ret;
} }
static void __exit ib_ucm_cleanup(void) static void __exit ib_ucm_cleanup(void)
{ {
class_device_destroy(ib_ucm_class, IB_UCM_DEV); ib_unregister_client(&ucm_client);
class_destroy(ib_ucm_class); class_unregister(&ucm_class);
cdev_del(&ib_ucm_cdev); unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
unregister_chrdev_region(IB_UCM_DEV, 1);
} }
module_init(ib_ucm_init); module_init(ib_ucm_init);
......
/* /*
* Copyright (c) 2004 Intel Corporation. All rights reserved. * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved. * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
...@@ -109,7 +109,6 @@ struct ib_cm_id; ...@@ -109,7 +109,6 @@ struct ib_cm_id;
struct ib_cm_req_event_param { struct ib_cm_req_event_param {
struct ib_cm_id *listen_id; struct ib_cm_id *listen_id;
struct ib_device *device;
u8 port; u8 port;
struct ib_sa_path_rec *primary_path; struct ib_sa_path_rec *primary_path;
...@@ -220,7 +219,6 @@ struct ib_cm_apr_event_param { ...@@ -220,7 +219,6 @@ struct ib_cm_apr_event_param {
struct ib_cm_sidr_req_event_param { struct ib_cm_sidr_req_event_param {
struct ib_cm_id *listen_id; struct ib_cm_id *listen_id;
struct ib_device *device;
u8 port; u8 port;
u16 pkey; u16 pkey;
}; };
...@@ -284,6 +282,7 @@ typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, ...@@ -284,6 +282,7 @@ typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
struct ib_cm_id { struct ib_cm_id {
ib_cm_handler cm_handler; ib_cm_handler cm_handler;
void *context; void *context;
struct ib_device *device;
__be64 service_id; __be64 service_id;
__be64 service_mask; __be64 service_mask;
enum ib_cm_state state; /* internal CM/debug use */ enum ib_cm_state state; /* internal CM/debug use */
...@@ -295,6 +294,8 @@ struct ib_cm_id { ...@@ -295,6 +294,8 @@ struct ib_cm_id {
/** /**
* ib_create_cm_id - Allocate a communication identifier. * ib_create_cm_id - Allocate a communication identifier.
* @device: Device associated with the cm_id. All related communication will
* be associated with the specified device.
* @cm_handler: Callback invoked to notify the user of CM events. * @cm_handler: Callback invoked to notify the user of CM events.
* @context: User specified context associated with the communication * @context: User specified context associated with the communication
* identifier. * identifier.
...@@ -302,7 +303,8 @@ struct ib_cm_id { ...@@ -302,7 +303,8 @@ struct ib_cm_id {
* Communication identifiers are used to track connection states, service * Communication identifiers are used to track connection states, service
* ID resolution requests, and listen requests. * ID resolution requests, and listen requests.
*/ */
struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler, struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
ib_cm_handler cm_handler,
void *context); void *context);
/** /**
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <linux/types.h> #include <linux/types.h>
#define IB_USER_CM_ABI_VERSION 2 #define IB_USER_CM_ABI_VERSION 3
enum { enum {
IB_USER_CM_CMD_CREATE_ID, IB_USER_CM_CMD_CREATE_ID,
...@@ -299,8 +299,6 @@ struct ib_ucm_event_get { ...@@ -299,8 +299,6 @@ struct ib_ucm_event_get {
}; };
struct ib_ucm_req_event_resp { struct ib_ucm_req_event_resp {
/* device */
/* port */
struct ib_ucm_path_rec primary_path; struct ib_ucm_path_rec primary_path;
struct ib_ucm_path_rec alternate_path; struct ib_ucm_path_rec alternate_path;
__be64 remote_ca_guid; __be64 remote_ca_guid;
...@@ -316,6 +314,7 @@ struct ib_ucm_req_event_resp { ...@@ -316,6 +314,7 @@ struct ib_ucm_req_event_resp {
__u8 retry_count; __u8 retry_count;
__u8 rnr_retry_count; __u8 rnr_retry_count;
__u8 srq; __u8 srq;
__u8 port;
}; };
struct ib_ucm_rep_event_resp { struct ib_ucm_rep_event_resp {
...@@ -353,10 +352,9 @@ struct ib_ucm_apr_event_resp { ...@@ -353,10 +352,9 @@ struct ib_ucm_apr_event_resp {
}; };
struct ib_ucm_sidr_req_event_resp { struct ib_ucm_sidr_req_event_resp {
/* device */
/* port */
__u16 pkey; __u16 pkey;
__u8 reserved[2]; __u8 port;
__u8 reserved;
}; };
struct ib_ucm_sidr_rep_event_resp { struct ib_ucm_sidr_rep_event_resp {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment