Commit dd05cb82 authored by Kamal Heib's avatar Kamal Heib Committed by Jason Gunthorpe

RDMA: Get rid of iw_cm_verbs

Integrate iw_cm_verbs data members into ib_device_ops and ib_device
structs, this is done to achieve the following:

1) Avoid memory related bugs durring error unwind
2) Make the code more cleaner
3) Reduce code duplication
Signed-off-by: default avatarKamal Heib <kamalheib1@gmail.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent eb15c78b
...@@ -2370,6 +2370,14 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) ...@@ -2370,6 +2370,14 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
SET_DEVICE_OP(dev_ops, get_vf_config); SET_DEVICE_OP(dev_ops, get_vf_config);
SET_DEVICE_OP(dev_ops, get_vf_stats); SET_DEVICE_OP(dev_ops, get_vf_stats);
SET_DEVICE_OP(dev_ops, init_port); SET_DEVICE_OP(dev_ops, init_port);
SET_DEVICE_OP(dev_ops, iw_accept);
SET_DEVICE_OP(dev_ops, iw_add_ref);
SET_DEVICE_OP(dev_ops, iw_connect);
SET_DEVICE_OP(dev_ops, iw_create_listen);
SET_DEVICE_OP(dev_ops, iw_destroy_listen);
SET_DEVICE_OP(dev_ops, iw_get_qp);
SET_DEVICE_OP(dev_ops, iw_reject);
SET_DEVICE_OP(dev_ops, iw_rem_ref);
SET_DEVICE_OP(dev_ops, map_mr_sg); SET_DEVICE_OP(dev_ops, map_mr_sg);
SET_DEVICE_OP(dev_ops, map_phys_fmr); SET_DEVICE_OP(dev_ops, map_phys_fmr);
SET_DEVICE_OP(dev_ops, mmap); SET_DEVICE_OP(dev_ops, mmap);
......
...@@ -394,7 +394,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) ...@@ -394,7 +394,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id)
cm_id_priv->state = IW_CM_STATE_DESTROYING; cm_id_priv->state = IW_CM_STATE_DESTROYING;
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
/* destroy the listening endpoint */ /* destroy the listening endpoint */
cm_id->device->iwcm->destroy_listen(cm_id); cm_id->device->ops.iw_destroy_listen(cm_id);
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
break; break;
case IW_CM_STATE_ESTABLISHED: case IW_CM_STATE_ESTABLISHED:
...@@ -417,7 +417,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) ...@@ -417,7 +417,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id)
*/ */
cm_id_priv->state = IW_CM_STATE_DESTROYING; cm_id_priv->state = IW_CM_STATE_DESTROYING;
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
cm_id->device->iwcm->reject(cm_id, NULL, 0); cm_id->device->ops.iw_reject(cm_id, NULL, 0);
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
break; break;
case IW_CM_STATE_CONN_SENT: case IW_CM_STATE_CONN_SENT:
...@@ -427,7 +427,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id) ...@@ -427,7 +427,7 @@ static void destroy_cm_id(struct iw_cm_id *cm_id)
break; break;
} }
if (cm_id_priv->qp) { if (cm_id_priv->qp) {
cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp); cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp);
cm_id_priv->qp = NULL; cm_id_priv->qp = NULL;
} }
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
...@@ -504,7 +504,7 @@ static void iw_cm_check_wildcard(struct sockaddr_storage *pm_addr, ...@@ -504,7 +504,7 @@ static void iw_cm_check_wildcard(struct sockaddr_storage *pm_addr,
static int iw_cm_map(struct iw_cm_id *cm_id, bool active) static int iw_cm_map(struct iw_cm_id *cm_id, bool active)
{ {
const char *devname = dev_name(&cm_id->device->dev); const char *devname = dev_name(&cm_id->device->dev);
const char *ifname = cm_id->device->iwcm->ifname; const char *ifname = cm_id->device->iw_ifname;
struct iwpm_dev_data pm_reg_msg = {}; struct iwpm_dev_data pm_reg_msg = {};
struct iwpm_sa_data pm_msg; struct iwpm_sa_data pm_msg;
int status; int status;
...@@ -526,7 +526,7 @@ static int iw_cm_map(struct iw_cm_id *cm_id, bool active) ...@@ -526,7 +526,7 @@ static int iw_cm_map(struct iw_cm_id *cm_id, bool active)
cm_id->mapped = true; cm_id->mapped = true;
pm_msg.loc_addr = cm_id->local_addr; pm_msg.loc_addr = cm_id->local_addr;
pm_msg.rem_addr = cm_id->remote_addr; pm_msg.rem_addr = cm_id->remote_addr;
pm_msg.flags = (cm_id->device->iwcm->driver_flags & IW_F_NO_PORT_MAP) ? pm_msg.flags = (cm_id->device->iw_driver_flags & IW_F_NO_PORT_MAP) ?
IWPM_FLAGS_NO_PORT_MAP : 0; IWPM_FLAGS_NO_PORT_MAP : 0;
if (active) if (active)
status = iwpm_add_and_query_mapping(&pm_msg, status = iwpm_add_and_query_mapping(&pm_msg,
...@@ -577,7 +577,8 @@ int iw_cm_listen(struct iw_cm_id *cm_id, int backlog) ...@@ -577,7 +577,8 @@ int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
ret = iw_cm_map(cm_id, false); ret = iw_cm_map(cm_id, false);
if (!ret) if (!ret)
ret = cm_id->device->iwcm->create_listen(cm_id, backlog); ret = cm_id->device->ops.iw_create_listen(cm_id,
backlog);
if (ret) if (ret)
cm_id_priv->state = IW_CM_STATE_IDLE; cm_id_priv->state = IW_CM_STATE_IDLE;
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
...@@ -617,7 +618,7 @@ int iw_cm_reject(struct iw_cm_id *cm_id, ...@@ -617,7 +618,7 @@ int iw_cm_reject(struct iw_cm_id *cm_id,
cm_id_priv->state = IW_CM_STATE_IDLE; cm_id_priv->state = IW_CM_STATE_IDLE;
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
ret = cm_id->device->iwcm->reject(cm_id, private_data, ret = cm_id->device->ops.iw_reject(cm_id, private_data,
private_data_len); private_data_len);
clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
...@@ -653,25 +654,25 @@ int iw_cm_accept(struct iw_cm_id *cm_id, ...@@ -653,25 +654,25 @@ int iw_cm_accept(struct iw_cm_id *cm_id,
return -EINVAL; return -EINVAL;
} }
/* Get the ib_qp given the QPN */ /* Get the ib_qp given the QPN */
qp = cm_id->device->iwcm->get_qp(cm_id->device, iw_param->qpn); qp = cm_id->device->ops.iw_get_qp(cm_id->device, iw_param->qpn);
if (!qp) { if (!qp) {
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
wake_up_all(&cm_id_priv->connect_wait); wake_up_all(&cm_id_priv->connect_wait);
return -EINVAL; return -EINVAL;
} }
cm_id->device->iwcm->add_ref(qp); cm_id->device->ops.iw_add_ref(qp);
cm_id_priv->qp = qp; cm_id_priv->qp = qp;
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
ret = cm_id->device->iwcm->accept(cm_id, iw_param); ret = cm_id->device->ops.iw_accept(cm_id, iw_param);
if (ret) { if (ret) {
/* An error on accept precludes provider events */ /* An error on accept precludes provider events */
BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV); BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
cm_id_priv->state = IW_CM_STATE_IDLE; cm_id_priv->state = IW_CM_STATE_IDLE;
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
if (cm_id_priv->qp) { if (cm_id_priv->qp) {
cm_id->device->iwcm->rem_ref(qp); cm_id->device->ops.iw_rem_ref(qp);
cm_id_priv->qp = NULL; cm_id_priv->qp = NULL;
} }
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
...@@ -712,25 +713,25 @@ int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) ...@@ -712,25 +713,25 @@ int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
} }
/* Get the ib_qp given the QPN */ /* Get the ib_qp given the QPN */
qp = cm_id->device->iwcm->get_qp(cm_id->device, iw_param->qpn); qp = cm_id->device->ops.iw_get_qp(cm_id->device, iw_param->qpn);
if (!qp) { if (!qp) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
cm_id->device->iwcm->add_ref(qp); cm_id->device->ops.iw_add_ref(qp);
cm_id_priv->qp = qp; cm_id_priv->qp = qp;
cm_id_priv->state = IW_CM_STATE_CONN_SENT; cm_id_priv->state = IW_CM_STATE_CONN_SENT;
spin_unlock_irqrestore(&cm_id_priv->lock, flags); spin_unlock_irqrestore(&cm_id_priv->lock, flags);
ret = iw_cm_map(cm_id, true); ret = iw_cm_map(cm_id, true);
if (!ret) if (!ret)
ret = cm_id->device->iwcm->connect(cm_id, iw_param); ret = cm_id->device->ops.iw_connect(cm_id, iw_param);
if (!ret) if (!ret)
return 0; /* success */ return 0; /* success */
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
if (cm_id_priv->qp) { if (cm_id_priv->qp) {
cm_id->device->iwcm->rem_ref(qp); cm_id->device->ops.iw_rem_ref(qp);
cm_id_priv->qp = NULL; cm_id_priv->qp = NULL;
} }
cm_id_priv->state = IW_CM_STATE_IDLE; cm_id_priv->state = IW_CM_STATE_IDLE;
...@@ -895,7 +896,7 @@ static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv, ...@@ -895,7 +896,7 @@ static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
cm_id_priv->state = IW_CM_STATE_ESTABLISHED; cm_id_priv->state = IW_CM_STATE_ESTABLISHED;
} else { } else {
/* REJECTED or RESET */ /* REJECTED or RESET */
cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp); cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp);
cm_id_priv->qp = NULL; cm_id_priv->qp = NULL;
cm_id_priv->state = IW_CM_STATE_IDLE; cm_id_priv->state = IW_CM_STATE_IDLE;
} }
...@@ -946,7 +947,7 @@ static int cm_close_handler(struct iwcm_id_private *cm_id_priv, ...@@ -946,7 +947,7 @@ static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
if (cm_id_priv->qp) { if (cm_id_priv->qp) {
cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp); cm_id_priv->id.device->ops.iw_rem_ref(cm_id_priv->qp);
cm_id_priv->qp = NULL; cm_id_priv->qp = NULL;
} }
switch (cm_id_priv->state) { switch (cm_id_priv->state) {
......
...@@ -1321,6 +1321,14 @@ static const struct ib_device_ops iwch_dev_ops = { ...@@ -1321,6 +1321,14 @@ static const struct ib_device_ops iwch_dev_ops = {
.get_dma_mr = iwch_get_dma_mr, .get_dma_mr = iwch_get_dma_mr,
.get_hw_stats = iwch_get_mib, .get_hw_stats = iwch_get_mib,
.get_port_immutable = iwch_port_immutable, .get_port_immutable = iwch_port_immutable,
.iw_accept = iwch_accept_cr,
.iw_add_ref = iwch_qp_add_ref,
.iw_connect = iwch_connect,
.iw_create_listen = iwch_create_listen,
.iw_destroy_listen = iwch_destroy_listen,
.iw_get_qp = iwch_get_qp,
.iw_reject = iwch_reject_cr,
.iw_rem_ref = iwch_qp_rem_ref,
.map_mr_sg = iwch_map_mr_sg, .map_mr_sg = iwch_map_mr_sg,
.mmap = iwch_mmap, .mmap = iwch_mmap,
.modify_qp = iwch_ib_modify_qp, .modify_qp = iwch_ib_modify_qp,
...@@ -1340,8 +1348,6 @@ static const struct ib_device_ops iwch_dev_ops = { ...@@ -1340,8 +1348,6 @@ static const struct ib_device_ops iwch_dev_ops = {
int iwch_register_device(struct iwch_dev *dev) int iwch_register_device(struct iwch_dev *dev)
{ {
int ret;
pr_debug("%s iwch_dev %p\n", __func__, dev); pr_debug("%s iwch_dev %p\n", __func__, dev);
memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
...@@ -1379,34 +1385,18 @@ int iwch_register_device(struct iwch_dev *dev) ...@@ -1379,34 +1385,18 @@ int iwch_register_device(struct iwch_dev *dev)
dev->ibdev.dev.parent = &dev->rdev.rnic_info.pdev->dev; dev->ibdev.dev.parent = &dev->rdev.rnic_info.pdev->dev;
dev->ibdev.uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION; dev->ibdev.uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION;
dev->ibdev.iwcm = kzalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); memcpy(dev->ibdev.iw_ifname, dev->rdev.t3cdev_p->lldev->name,
if (!dev->ibdev.iwcm) sizeof(dev->ibdev.iw_ifname));
return -ENOMEM;
dev->ibdev.iwcm->connect = iwch_connect;
dev->ibdev.iwcm->accept = iwch_accept_cr;
dev->ibdev.iwcm->reject = iwch_reject_cr;
dev->ibdev.iwcm->create_listen = iwch_create_listen;
dev->ibdev.iwcm->destroy_listen = iwch_destroy_listen;
dev->ibdev.iwcm->add_ref = iwch_qp_add_ref;
dev->ibdev.iwcm->rem_ref = iwch_qp_rem_ref;
dev->ibdev.iwcm->get_qp = iwch_get_qp;
memcpy(dev->ibdev.iwcm->ifname, dev->rdev.t3cdev_p->lldev->name,
sizeof(dev->ibdev.iwcm->ifname));
dev->ibdev.driver_id = RDMA_DRIVER_CXGB3; dev->ibdev.driver_id = RDMA_DRIVER_CXGB3;
rdma_set_device_sysfs_group(&dev->ibdev, &iwch_attr_group); rdma_set_device_sysfs_group(&dev->ibdev, &iwch_attr_group);
ib_set_device_ops(&dev->ibdev, &iwch_dev_ops); ib_set_device_ops(&dev->ibdev, &iwch_dev_ops);
ret = ib_register_device(&dev->ibdev, "cxgb3_%d"); return ib_register_device(&dev->ibdev, "cxgb3_%d");
if (ret)
kfree(dev->ibdev.iwcm);
return ret;
} }
void iwch_unregister_device(struct iwch_dev *dev) void iwch_unregister_device(struct iwch_dev *dev)
{ {
pr_debug("%s iwch_dev %p\n", __func__, dev); pr_debug("%s iwch_dev %p\n", __func__, dev);
ib_unregister_device(&dev->ibdev); ib_unregister_device(&dev->ibdev);
kfree(dev->ibdev.iwcm);
return; return;
} }
...@@ -510,6 +510,14 @@ static const struct ib_device_ops c4iw_dev_ops = { ...@@ -510,6 +510,14 @@ static const struct ib_device_ops c4iw_dev_ops = {
.get_dma_mr = c4iw_get_dma_mr, .get_dma_mr = c4iw_get_dma_mr,
.get_hw_stats = c4iw_get_mib, .get_hw_stats = c4iw_get_mib,
.get_port_immutable = c4iw_port_immutable, .get_port_immutable = c4iw_port_immutable,
.iw_accept = c4iw_accept_cr,
.iw_add_ref = c4iw_qp_add_ref,
.iw_connect = c4iw_connect,
.iw_create_listen = c4iw_create_listen,
.iw_destroy_listen = c4iw_destroy_listen,
.iw_get_qp = c4iw_get_qp,
.iw_reject = c4iw_reject_cr,
.iw_rem_ref = c4iw_qp_rem_ref,
.map_mr_sg = c4iw_map_mr_sg, .map_mr_sg = c4iw_map_mr_sg,
.mmap = c4iw_mmap, .mmap = c4iw_mmap,
.modify_qp = c4iw_ib_modify_qp, .modify_qp = c4iw_ib_modify_qp,
...@@ -588,36 +596,20 @@ void c4iw_register_device(struct work_struct *work) ...@@ -588,36 +596,20 @@ void c4iw_register_device(struct work_struct *work)
dev->ibdev.dev.parent = &dev->rdev.lldi.pdev->dev; dev->ibdev.dev.parent = &dev->rdev.lldi.pdev->dev;
dev->ibdev.uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION; dev->ibdev.uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION;
dev->ibdev.iwcm = kzalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); memcpy(dev->ibdev.iw_ifname, dev->rdev.lldi.ports[0]->name,
if (!dev->ibdev.iwcm) { sizeof(dev->ibdev.iw_ifname));
ret = -ENOMEM;
goto err_dealloc_ctx;
}
dev->ibdev.iwcm->connect = c4iw_connect;
dev->ibdev.iwcm->accept = c4iw_accept_cr;
dev->ibdev.iwcm->reject = c4iw_reject_cr;
dev->ibdev.iwcm->create_listen = c4iw_create_listen;
dev->ibdev.iwcm->destroy_listen = c4iw_destroy_listen;
dev->ibdev.iwcm->add_ref = c4iw_qp_add_ref;
dev->ibdev.iwcm->rem_ref = c4iw_qp_rem_ref;
dev->ibdev.iwcm->get_qp = c4iw_get_qp;
memcpy(dev->ibdev.iwcm->ifname, dev->rdev.lldi.ports[0]->name,
sizeof(dev->ibdev.iwcm->ifname));
rdma_set_device_sysfs_group(&dev->ibdev, &c4iw_attr_group); rdma_set_device_sysfs_group(&dev->ibdev, &c4iw_attr_group);
dev->ibdev.driver_id = RDMA_DRIVER_CXGB4; dev->ibdev.driver_id = RDMA_DRIVER_CXGB4;
ib_set_device_ops(&dev->ibdev, &c4iw_dev_ops); ib_set_device_ops(&dev->ibdev, &c4iw_dev_ops);
ret = set_netdevs(&dev->ibdev, &dev->rdev); ret = set_netdevs(&dev->ibdev, &dev->rdev);
if (ret) if (ret)
goto err_kfree_iwcm; goto err_dealloc_ctx;
ret = ib_register_device(&dev->ibdev, "cxgb4_%d"); ret = ib_register_device(&dev->ibdev, "cxgb4_%d");
if (ret) if (ret)
goto err_kfree_iwcm; goto err_dealloc_ctx;
return; return;
err_kfree_iwcm:
kfree(dev->ibdev.iwcm);
err_dealloc_ctx: err_dealloc_ctx:
pr_err("%s - Failed registering iwarp device: %d\n", pr_err("%s - Failed registering iwarp device: %d\n",
pci_name(ctx->lldi.pdev), ret); pci_name(ctx->lldi.pdev), ret);
...@@ -629,6 +621,5 @@ void c4iw_unregister_device(struct c4iw_dev *dev) ...@@ -629,6 +621,5 @@ void c4iw_unregister_device(struct c4iw_dev *dev)
{ {
pr_debug("c4iw_dev %p\n", dev); pr_debug("c4iw_dev %p\n", dev);
ib_unregister_device(&dev->ibdev); ib_unregister_device(&dev->ibdev);
kfree(dev->ibdev.iwcm);
return; return;
} }
...@@ -2704,6 +2704,14 @@ static const struct ib_device_ops i40iw_dev_ops = { ...@@ -2704,6 +2704,14 @@ static const struct ib_device_ops i40iw_dev_ops = {
.get_dma_mr = i40iw_get_dma_mr, .get_dma_mr = i40iw_get_dma_mr,
.get_hw_stats = i40iw_get_hw_stats, .get_hw_stats = i40iw_get_hw_stats,
.get_port_immutable = i40iw_port_immutable, .get_port_immutable = i40iw_port_immutable,
.iw_accept = i40iw_accept,
.iw_add_ref = i40iw_add_ref,
.iw_connect = i40iw_connect,
.iw_create_listen = i40iw_create_listen,
.iw_destroy_listen = i40iw_destroy_listen,
.iw_get_qp = i40iw_get_qp,
.iw_reject = i40iw_reject,
.iw_rem_ref = i40iw_rem_ref,
.map_mr_sg = i40iw_map_mr_sg, .map_mr_sg = i40iw_map_mr_sg,
.mmap = i40iw_mmap, .mmap = i40iw_mmap,
.modify_qp = i40iw_modify_qp, .modify_qp = i40iw_modify_qp,
...@@ -2767,22 +2775,8 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev ...@@ -2767,22 +2775,8 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
iwibdev->ibdev.phys_port_cnt = 1; iwibdev->ibdev.phys_port_cnt = 1;
iwibdev->ibdev.num_comp_vectors = iwdev->ceqs_count; iwibdev->ibdev.num_comp_vectors = iwdev->ceqs_count;
iwibdev->ibdev.dev.parent = &pcidev->dev; iwibdev->ibdev.dev.parent = &pcidev->dev;
iwibdev->ibdev.iwcm = kzalloc(sizeof(*iwibdev->ibdev.iwcm), GFP_KERNEL); memcpy(iwibdev->ibdev.iw_ifname, netdev->name,
if (!iwibdev->ibdev.iwcm) { sizeof(iwibdev->ibdev.iw_ifname));
ib_dealloc_device(&iwibdev->ibdev);
return NULL;
}
iwibdev->ibdev.iwcm->add_ref = i40iw_add_ref;
iwibdev->ibdev.iwcm->rem_ref = i40iw_rem_ref;
iwibdev->ibdev.iwcm->get_qp = i40iw_get_qp;
iwibdev->ibdev.iwcm->connect = i40iw_connect;
iwibdev->ibdev.iwcm->accept = i40iw_accept;
iwibdev->ibdev.iwcm->reject = i40iw_reject;
iwibdev->ibdev.iwcm->create_listen = i40iw_create_listen;
iwibdev->ibdev.iwcm->destroy_listen = i40iw_destroy_listen;
memcpy(iwibdev->ibdev.iwcm->ifname, netdev->name,
sizeof(iwibdev->ibdev.iwcm->ifname));
ib_set_device_ops(&iwibdev->ibdev, &i40iw_dev_ops); ib_set_device_ops(&iwibdev->ibdev, &i40iw_dev_ops);
return iwibdev; return iwibdev;
...@@ -2813,8 +2807,6 @@ void i40iw_destroy_rdma_device(struct i40iw_ib_device *iwibdev) ...@@ -2813,8 +2807,6 @@ void i40iw_destroy_rdma_device(struct i40iw_ib_device *iwibdev)
return; return;
ib_unregister_device(&iwibdev->ibdev); ib_unregister_device(&iwibdev->ibdev);
kfree(iwibdev->ibdev.iwcm);
iwibdev->ibdev.iwcm = NULL;
wait_event_timeout(iwibdev->iwdev->close_wq, wait_event_timeout(iwibdev->iwdev->close_wq,
!atomic64_read(&iwibdev->iwdev->use_count), !atomic64_read(&iwibdev->iwdev->use_count),
I40IW_EVENT_TIMEOUT); I40IW_EVENT_TIMEOUT);
...@@ -2842,8 +2834,6 @@ int i40iw_register_rdma_device(struct i40iw_device *iwdev) ...@@ -2842,8 +2834,6 @@ int i40iw_register_rdma_device(struct i40iw_device *iwdev)
return 0; return 0;
error: error:
kfree(iwdev->iwibdev->ibdev.iwcm);
iwdev->iwibdev->ibdev.iwcm = NULL;
ib_dealloc_device(&iwdev->iwibdev->ibdev); ib_dealloc_device(&iwdev->iwibdev->ibdev);
return ret; return ret;
} }
...@@ -3577,6 +3577,14 @@ static const struct ib_device_ops nes_dev_ops = { ...@@ -3577,6 +3577,14 @@ static const struct ib_device_ops nes_dev_ops = {
.get_dev_fw_str = get_dev_fw_str, .get_dev_fw_str = get_dev_fw_str,
.get_dma_mr = nes_get_dma_mr, .get_dma_mr = nes_get_dma_mr,
.get_port_immutable = nes_port_immutable, .get_port_immutable = nes_port_immutable,
.iw_accept = nes_accept,
.iw_add_ref = nes_add_ref,
.iw_connect = nes_connect,
.iw_create_listen = nes_create_listen,
.iw_destroy_listen = nes_destroy_listen,
.iw_get_qp = nes_get_qp,
.iw_reject = nes_reject,
.iw_rem_ref = nes_rem_ref,
.map_mr_sg = nes_map_mr_sg, .map_mr_sg = nes_map_mr_sg,
.mmap = nes_mmap, .mmap = nes_mmap,
.modify_qp = nes_modify_qp, .modify_qp = nes_modify_qp,
...@@ -3641,23 +3649,9 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev) ...@@ -3641,23 +3649,9 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
nesibdev->ibdev.num_comp_vectors = 1; nesibdev->ibdev.num_comp_vectors = 1;
nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev; nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev;
nesibdev->ibdev.iwcm = kzalloc(sizeof(*nesibdev->ibdev.iwcm), GFP_KERNEL);
if (nesibdev->ibdev.iwcm == NULL) {
ib_dealloc_device(&nesibdev->ibdev);
return NULL;
}
nesibdev->ibdev.iwcm->add_ref = nes_add_ref;
nesibdev->ibdev.iwcm->rem_ref = nes_rem_ref;
nesibdev->ibdev.iwcm->get_qp = nes_get_qp;
nesibdev->ibdev.iwcm->connect = nes_connect;
nesibdev->ibdev.iwcm->accept = nes_accept;
nesibdev->ibdev.iwcm->reject = nes_reject;
nesibdev->ibdev.iwcm->create_listen = nes_create_listen;
nesibdev->ibdev.iwcm->destroy_listen = nes_destroy_listen;
ib_set_device_ops(&nesibdev->ibdev, &nes_dev_ops); ib_set_device_ops(&nesibdev->ibdev, &nes_dev_ops);
memcpy(nesibdev->ibdev.iwcm->ifname, netdev->name, memcpy(nesibdev->ibdev.iw_ifname, netdev->name,
sizeof(nesibdev->ibdev.iwcm->ifname)); sizeof(nesibdev->ibdev.iw_ifname));
return nesibdev; return nesibdev;
} }
...@@ -3718,7 +3712,6 @@ void nes_destroy_ofa_device(struct nes_ib_device *nesibdev) ...@@ -3718,7 +3712,6 @@ void nes_destroy_ofa_device(struct nes_ib_device *nesibdev)
nes_unregister_ofa_device(nesibdev); nes_unregister_ofa_device(nesibdev);
kfree(nesibdev->ibdev.iwcm);
ib_dealloc_device(&nesibdev->ibdev); ib_dealloc_device(&nesibdev->ibdev);
} }
......
...@@ -148,6 +148,14 @@ static const struct attribute_group qedr_attr_group = { ...@@ -148,6 +148,14 @@ static const struct attribute_group qedr_attr_group = {
static const struct ib_device_ops qedr_iw_dev_ops = { static const struct ib_device_ops qedr_iw_dev_ops = {
.get_port_immutable = qedr_iw_port_immutable, .get_port_immutable = qedr_iw_port_immutable,
.iw_accept = qedr_iw_accept,
.iw_add_ref = qedr_iw_qp_add_ref,
.iw_connect = qedr_iw_connect,
.iw_create_listen = qedr_iw_create_listen,
.iw_destroy_listen = qedr_iw_destroy_listen,
.iw_get_qp = qedr_iw_get_qp,
.iw_reject = qedr_iw_reject,
.iw_rem_ref = qedr_iw_qp_rem_ref,
.query_gid = qedr_iw_query_gid, .query_gid = qedr_iw_query_gid,
}; };
...@@ -157,21 +165,8 @@ static int qedr_iw_register_device(struct qedr_dev *dev) ...@@ -157,21 +165,8 @@ static int qedr_iw_register_device(struct qedr_dev *dev)
ib_set_device_ops(&dev->ibdev, &qedr_iw_dev_ops); ib_set_device_ops(&dev->ibdev, &qedr_iw_dev_ops);
dev->ibdev.iwcm = kzalloc(sizeof(*dev->ibdev.iwcm), GFP_KERNEL); memcpy(dev->ibdev.iw_ifname,
if (!dev->ibdev.iwcm) dev->ndev->name, sizeof(dev->ibdev.iw_ifname));
return -ENOMEM;
dev->ibdev.iwcm->connect = qedr_iw_connect;
dev->ibdev.iwcm->accept = qedr_iw_accept;
dev->ibdev.iwcm->reject = qedr_iw_reject;
dev->ibdev.iwcm->create_listen = qedr_iw_create_listen;
dev->ibdev.iwcm->destroy_listen = qedr_iw_destroy_listen;
dev->ibdev.iwcm->add_ref = qedr_iw_qp_add_ref;
dev->ibdev.iwcm->rem_ref = qedr_iw_qp_rem_ref;
dev->ibdev.iwcm->get_qp = qedr_iw_get_qp;
memcpy(dev->ibdev.iwcm->ifname,
dev->ndev->name, sizeof(dev->ibdev.iwcm->ifname));
return 0; return 0;
} }
......
...@@ -2221,8 +2221,6 @@ struct ib_cache { ...@@ -2221,8 +2221,6 @@ struct ib_cache {
struct ib_event_handler event_handler; struct ib_event_handler event_handler;
}; };
struct iw_cm_verbs;
struct ib_port_immutable { struct ib_port_immutable {
int pkey_tbl_len; int pkey_tbl_len;
int gid_tbl_len; int gid_tbl_len;
...@@ -2304,6 +2302,8 @@ struct ib_counters_read_attr { ...@@ -2304,6 +2302,8 @@ struct ib_counters_read_attr {
}; };
struct uverbs_attr_bundle; struct uverbs_attr_bundle;
struct iw_cm_id;
struct iw_cm_conn_param;
#define INIT_RDMA_OBJ_SIZE(ib_struct, drv_struct, member) \ #define INIT_RDMA_OBJ_SIZE(ib_struct, drv_struct, member) \
.size_##ib_struct = \ .size_##ib_struct = \
...@@ -2581,6 +2581,19 @@ struct ib_device_ops { ...@@ -2581,6 +2581,19 @@ struct ib_device_ops {
*/ */
void (*dealloc_driver)(struct ib_device *dev); void (*dealloc_driver)(struct ib_device *dev);
/* iWarp CM callbacks */
void (*iw_add_ref)(struct ib_qp *qp);
void (*iw_rem_ref)(struct ib_qp *qp);
struct ib_qp *(*iw_get_qp)(struct ib_device *device, int qpn);
int (*iw_connect)(struct iw_cm_id *cm_id,
struct iw_cm_conn_param *conn_param);
int (*iw_accept)(struct iw_cm_id *cm_id,
struct iw_cm_conn_param *conn_param);
int (*iw_reject)(struct iw_cm_id *cm_id, const void *pdata,
u8 pdata_len);
int (*iw_create_listen)(struct iw_cm_id *cm_id, int backlog);
int (*iw_destroy_listen)(struct iw_cm_id *cm_id);
DECLARE_RDMA_OBJ_SIZE(ib_ah); DECLARE_RDMA_OBJ_SIZE(ib_ah);
DECLARE_RDMA_OBJ_SIZE(ib_pd); DECLARE_RDMA_OBJ_SIZE(ib_pd);
DECLARE_RDMA_OBJ_SIZE(ib_srq); DECLARE_RDMA_OBJ_SIZE(ib_srq);
...@@ -2621,8 +2634,6 @@ struct ib_device { ...@@ -2621,8 +2634,6 @@ struct ib_device {
int num_comp_vectors; int num_comp_vectors;
struct iw_cm_verbs *iwcm;
struct module *owner; struct module *owner;
union { union {
struct device dev; struct device dev;
...@@ -2675,6 +2686,10 @@ struct ib_device { ...@@ -2675,6 +2686,10 @@ struct ib_device {
struct mutex compat_devs_mutex; struct mutex compat_devs_mutex;
/* Maintains compat devices for each net namespace */ /* Maintains compat devices for each net namespace */
struct xarray compat_devs; struct xarray compat_devs;
/* Used by iWarp CM */
char iw_ifname[IFNAMSIZ];
u32 iw_driver_flags;
}; };
struct ib_client { struct ib_client {
......
...@@ -118,31 +118,6 @@ enum iw_flags { ...@@ -118,31 +118,6 @@ enum iw_flags {
IW_F_NO_PORT_MAP = (1 << 0), IW_F_NO_PORT_MAP = (1 << 0),
}; };
struct iw_cm_verbs {
void (*add_ref)(struct ib_qp *qp);
void (*rem_ref)(struct ib_qp *qp);
struct ib_qp * (*get_qp)(struct ib_device *device,
int qpn);
int (*connect)(struct iw_cm_id *cm_id,
struct iw_cm_conn_param *conn_param);
int (*accept)(struct iw_cm_id *cm_id,
struct iw_cm_conn_param *conn_param);
int (*reject)(struct iw_cm_id *cm_id,
const void *pdata, u8 pdata_len);
int (*create_listen)(struct iw_cm_id *cm_id,
int backlog);
int (*destroy_listen)(struct iw_cm_id *cm_id);
char ifname[IFNAMSIZ];
enum iw_flags driver_flags;
};
/** /**
* iw_create_cm_id - Create an IW CM identifier. * iw_create_cm_id - Create an IW CM identifier.
* *
......
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