Commit 24d44a39 authored by Steve Wise's avatar Steve Wise Committed by Roland Dreier

RDMA/cma: Add IPv6 support for iWARP

Modify the type of local_addr and remote_addr fields in struct
iw_cm_id from struct sockaddr_in to struct sockaddr_storage to hold
IPv6 and IPv4 addresses uniformly.

Change the references of local_addr and remote_addr in cxgb4, cxgb3,
nes and amso drivers to match this.  However to be able to actully run
traffic over IPv6, low-level drivers have to add code to support this.
Signed-off-by: default avatarSteve Wise <swise@opengridcomputing.com>
Reviewed-by: default avatarSean Hefty <sean.hefty@intel.com>

[ Fix unused variable warnings when INFINIBAND_NES_DEBUG not set.
  - Roland ]
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent c095ba72
...@@ -1385,8 +1385,9 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) ...@@ -1385,8 +1385,9 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
{ {
struct rdma_id_private *id_priv = iw_id->context; struct rdma_id_private *id_priv = iw_id->context;
struct rdma_cm_event event; struct rdma_cm_event event;
struct sockaddr_in *sin;
int ret = 0; int ret = 0;
struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) if (cma_disable_callback(id_priv, RDMA_CM_CONNECT))
return 0; return 0;
...@@ -1397,10 +1398,10 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) ...@@ -1397,10 +1398,10 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
event.event = RDMA_CM_EVENT_DISCONNECTED; event.event = RDMA_CM_EVENT_DISCONNECTED;
break; break;
case IW_CM_EVENT_CONNECT_REPLY: case IW_CM_EVENT_CONNECT_REPLY:
sin = (struct sockaddr_in *) cma_src_addr(id_priv); memcpy(cma_src_addr(id_priv), laddr,
*sin = iw_event->local_addr; rdma_addr_size(laddr));
sin = (struct sockaddr_in *) cma_dst_addr(id_priv); memcpy(cma_dst_addr(id_priv), raddr,
*sin = iw_event->remote_addr; rdma_addr_size(raddr));
switch (iw_event->status) { switch (iw_event->status) {
case 0: case 0:
event.event = RDMA_CM_EVENT_ESTABLISHED; event.event = RDMA_CM_EVENT_ESTABLISHED;
...@@ -1450,11 +1451,12 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, ...@@ -1450,11 +1451,12 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
{ {
struct rdma_cm_id *new_cm_id; struct rdma_cm_id *new_cm_id;
struct rdma_id_private *listen_id, *conn_id; struct rdma_id_private *listen_id, *conn_id;
struct sockaddr_in *sin;
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct rdma_cm_event event; struct rdma_cm_event event;
int ret; int ret;
struct ib_device_attr attr; struct ib_device_attr attr;
struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
listen_id = cm_id->context; listen_id = cm_id->context;
if (cma_disable_callback(listen_id, RDMA_CM_LISTEN)) if (cma_disable_callback(listen_id, RDMA_CM_LISTEN))
...@@ -1472,14 +1474,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, ...@@ -1472,14 +1474,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING); mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
conn_id->state = RDMA_CM_CONNECT; conn_id->state = RDMA_CM_CONNECT;
dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr); ret = rdma_translate_ip(laddr, &conn_id->id.route.addr.dev_addr);
if (!dev) {
ret = -EADDRNOTAVAIL;
mutex_unlock(&conn_id->handler_mutex);
rdma_destroy_id(new_cm_id);
goto out;
}
ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL);
if (ret) { if (ret) {
mutex_unlock(&conn_id->handler_mutex); mutex_unlock(&conn_id->handler_mutex);
rdma_destroy_id(new_cm_id); rdma_destroy_id(new_cm_id);
...@@ -1497,10 +1492,8 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, ...@@ -1497,10 +1492,8 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
cm_id->context = conn_id; cm_id->context = conn_id;
cm_id->cm_handler = cma_iw_handler; cm_id->cm_handler = cma_iw_handler;
sin = (struct sockaddr_in *) cma_src_addr(conn_id); memcpy(cma_src_addr(conn_id), laddr, rdma_addr_size(laddr));
*sin = iw_event->local_addr; memcpy(cma_dst_addr(conn_id), raddr, rdma_addr_size(raddr));
sin = (struct sockaddr_in *) cma_dst_addr(conn_id);
*sin = iw_event->remote_addr;
ret = ib_query_device(conn_id->id.device, &attr); ret = ib_query_device(conn_id->id.device, &attr);
if (ret) { if (ret) {
...@@ -1576,7 +1569,6 @@ static int cma_ib_listen(struct rdma_id_private *id_priv) ...@@ -1576,7 +1569,6 @@ static int cma_ib_listen(struct rdma_id_private *id_priv)
static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog) static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog)
{ {
int ret; int ret;
struct sockaddr_in *sin;
struct iw_cm_id *id; struct iw_cm_id *id;
id = iw_create_cm_id(id_priv->id.device, id = iw_create_cm_id(id_priv->id.device,
...@@ -1587,8 +1579,8 @@ static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog) ...@@ -1587,8 +1579,8 @@ static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog)
id_priv->cm_id.iw = id; id_priv->cm_id.iw = id;
sin = (struct sockaddr_in *) cma_src_addr(id_priv); memcpy(&id_priv->cm_id.iw->local_addr, cma_src_addr(id_priv),
id_priv->cm_id.iw->local_addr = *sin; rdma_addr_size(cma_src_addr(id_priv)));
ret = iw_cm_listen(id_priv->cm_id.iw, backlog); ret = iw_cm_listen(id_priv->cm_id.iw, backlog);
...@@ -2803,7 +2795,6 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, ...@@ -2803,7 +2795,6 @@ static int cma_connect_iw(struct rdma_id_private *id_priv,
struct rdma_conn_param *conn_param) struct rdma_conn_param *conn_param)
{ {
struct iw_cm_id *cm_id; struct iw_cm_id *cm_id;
struct sockaddr_in* sin;
int ret; int ret;
struct iw_cm_conn_param iw_param; struct iw_cm_conn_param iw_param;
...@@ -2813,11 +2804,10 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, ...@@ -2813,11 +2804,10 @@ static int cma_connect_iw(struct rdma_id_private *id_priv,
id_priv->cm_id.iw = cm_id; id_priv->cm_id.iw = cm_id;
sin = (struct sockaddr_in *) cma_src_addr(id_priv); memcpy(&cm_id->local_addr, cma_src_addr(id_priv),
cm_id->local_addr = *sin; rdma_addr_size(cma_src_addr(id_priv)));
memcpy(&cm_id->remote_addr, cma_dst_addr(id_priv),
sin = (struct sockaddr_in *) cma_dst_addr(id_priv); rdma_addr_size(cma_dst_addr(id_priv)));
cm_id->remote_addr = *sin;
ret = cma_modify_qp_rtr(id_priv, conn_param); ret = cma_modify_qp_rtr(id_priv, conn_param);
if (ret) if (ret)
......
...@@ -155,6 +155,8 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) ...@@ -155,6 +155,8 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index)
enum c2_event_id event_id; enum c2_event_id event_id;
unsigned long flags; unsigned long flags;
int status; int status;
struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_event.local_addr;
struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_event.remote_addr;
/* /*
* retrieve the message * retrieve the message
...@@ -206,10 +208,10 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) ...@@ -206,10 +208,10 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index)
case CCAE_ACTIVE_CONNECT_RESULTS: case CCAE_ACTIVE_CONNECT_RESULTS:
res = &wr->ae.ae_active_connect_results; res = &wr->ae.ae_active_connect_results;
cm_event.event = IW_CM_EVENT_CONNECT_REPLY; cm_event.event = IW_CM_EVENT_CONNECT_REPLY;
cm_event.local_addr.sin_addr.s_addr = res->laddr; laddr->sin_addr.s_addr = res->laddr;
cm_event.remote_addr.sin_addr.s_addr = res->raddr; raddr->sin_addr.s_addr = res->raddr;
cm_event.local_addr.sin_port = res->lport; laddr->sin_port = res->lport;
cm_event.remote_addr.sin_port = res->rport; raddr->sin_port = res->rport;
if (status == 0) { if (status == 0) {
cm_event.private_data_len = cm_event.private_data_len =
be32_to_cpu(res->private_data_length); be32_to_cpu(res->private_data_length);
...@@ -281,10 +283,10 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) ...@@ -281,10 +283,10 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index)
} }
cm_event.event = IW_CM_EVENT_CONNECT_REQUEST; cm_event.event = IW_CM_EVENT_CONNECT_REQUEST;
cm_event.provider_data = (void*)(unsigned long)req->cr_handle; cm_event.provider_data = (void*)(unsigned long)req->cr_handle;
cm_event.local_addr.sin_addr.s_addr = req->laddr; laddr->sin_addr.s_addr = req->laddr;
cm_event.remote_addr.sin_addr.s_addr = req->raddr; raddr->sin_addr.s_addr = req->raddr;
cm_event.local_addr.sin_port = req->lport; laddr->sin_port = req->lport;
cm_event.remote_addr.sin_port = req->rport; raddr->sin_port = req->rport;
cm_event.private_data_len = cm_event.private_data_len =
be32_to_cpu(req->private_data_length); be32_to_cpu(req->private_data_length);
cm_event.private_data = req->private_data; cm_event.private_data = req->private_data;
......
...@@ -46,6 +46,10 @@ int c2_llp_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) ...@@ -46,6 +46,10 @@ int c2_llp_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
struct c2wr_qp_connect_req *wr; /* variable size needs a malloc. */ struct c2wr_qp_connect_req *wr; /* variable size needs a malloc. */
struct c2_vq_req *vq_req; struct c2_vq_req *vq_req;
int err; int err;
struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr;
if (cm_id->remote_addr.ss_family != AF_INET)
return -ENOSYS;
ibqp = c2_get_qp(cm_id->device, iw_param->qpn); ibqp = c2_get_qp(cm_id->device, iw_param->qpn);
if (!ibqp) if (!ibqp)
...@@ -91,8 +95,8 @@ int c2_llp_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) ...@@ -91,8 +95,8 @@ int c2_llp_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
wr->rnic_handle = c2dev->adapter_handle; wr->rnic_handle = c2dev->adapter_handle;
wr->qp_handle = qp->adapter_handle; wr->qp_handle = qp->adapter_handle;
wr->remote_addr = cm_id->remote_addr.sin_addr.s_addr; wr->remote_addr = raddr->sin_addr.s_addr;
wr->remote_port = cm_id->remote_addr.sin_port; wr->remote_port = raddr->sin_port;
/* /*
* Move any private data from the callers's buf into * Move any private data from the callers's buf into
...@@ -135,6 +139,10 @@ int c2_llp_service_create(struct iw_cm_id *cm_id, int backlog) ...@@ -135,6 +139,10 @@ int c2_llp_service_create(struct iw_cm_id *cm_id, int backlog)
struct c2wr_ep_listen_create_rep *reply; struct c2wr_ep_listen_create_rep *reply;
struct c2_vq_req *vq_req; struct c2_vq_req *vq_req;
int err; int err;
struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr;
if (cm_id->local_addr.ss_family != AF_INET)
return -ENOSYS;
c2dev = to_c2dev(cm_id->device); c2dev = to_c2dev(cm_id->device);
if (c2dev == NULL) if (c2dev == NULL)
...@@ -153,8 +161,8 @@ int c2_llp_service_create(struct iw_cm_id *cm_id, int backlog) ...@@ -153,8 +161,8 @@ int c2_llp_service_create(struct iw_cm_id *cm_id, int backlog)
c2_wr_set_id(&wr, CCWR_EP_LISTEN_CREATE); c2_wr_set_id(&wr, CCWR_EP_LISTEN_CREATE);
wr.hdr.context = (u64) (unsigned long) vq_req; wr.hdr.context = (u64) (unsigned long) vq_req;
wr.rnic_handle = c2dev->adapter_handle; wr.rnic_handle = c2dev->adapter_handle;
wr.local_addr = cm_id->local_addr.sin_addr.s_addr; wr.local_addr = laddr->sin_addr.s_addr;
wr.local_port = cm_id->local_addr.sin_port; wr.local_port = laddr->sin_port;
wr.backlog = cpu_to_be32(backlog); wr.backlog = cpu_to_be32(backlog);
wr.user_context = (u64) (unsigned long) cm_id; wr.user_context = (u64) (unsigned long) cm_id;
......
...@@ -721,8 +721,10 @@ static void connect_reply_upcall(struct iwch_ep *ep, int status) ...@@ -721,8 +721,10 @@ static void connect_reply_upcall(struct iwch_ep *ep, int status)
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_CONNECT_REPLY; event.event = IW_CM_EVENT_CONNECT_REPLY;
event.status = status; event.status = status;
event.local_addr = ep->com.local_addr; memcpy(&event.local_addr, &ep->com.local_addr,
event.remote_addr = ep->com.remote_addr; sizeof(ep->com.local_addr));
memcpy(&event.remote_addr, &ep->com.remote_addr,
sizeof(ep->com.remote_addr));
if ((status == 0) || (status == -ECONNREFUSED)) { if ((status == 0) || (status == -ECONNREFUSED)) {
event.private_data_len = ep->plen; event.private_data_len = ep->plen;
...@@ -747,8 +749,10 @@ static void connect_request_upcall(struct iwch_ep *ep) ...@@ -747,8 +749,10 @@ static void connect_request_upcall(struct iwch_ep *ep)
PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid); PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid);
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_CONNECT_REQUEST; event.event = IW_CM_EVENT_CONNECT_REQUEST;
event.local_addr = ep->com.local_addr; memcpy(&event.local_addr, &ep->com.local_addr,
event.remote_addr = ep->com.remote_addr; sizeof(ep->com.local_addr));
memcpy(&event.remote_addr, &ep->com.remote_addr,
sizeof(ep->com.local_addr));
event.private_data_len = ep->plen; event.private_data_len = ep->plen;
event.private_data = ep->mpa_pkt + sizeof(struct mpa_message); event.private_data = ep->mpa_pkt + sizeof(struct mpa_message);
event.provider_data = ep; event.provider_data = ep;
...@@ -1872,8 +1876,9 @@ int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -1872,8 +1876,9 @@ int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
static int is_loopback_dst(struct iw_cm_id *cm_id) static int is_loopback_dst(struct iw_cm_id *cm_id)
{ {
struct net_device *dev; struct net_device *dev;
struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr;
dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr); dev = ip_dev_find(&init_net, raddr->sin_addr.s_addr);
if (!dev) if (!dev)
return 0; return 0;
dev_put(dev); dev_put(dev);
...@@ -1886,6 +1891,13 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -1886,6 +1891,13 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
struct iwch_ep *ep; struct iwch_ep *ep;
struct rtable *rt; struct rtable *rt;
int err = 0; int err = 0;
struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr;
struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr;
if (cm_id->remote_addr.ss_family != PF_INET) {
err = -ENOSYS;
goto out;
}
if (is_loopback_dst(cm_id)) { if (is_loopback_dst(cm_id)) {
err = -ENOSYS; err = -ENOSYS;
...@@ -1929,11 +1941,9 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -1929,11 +1941,9 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
} }
/* find a route */ /* find a route */
rt = find_route(h->rdev.t3cdev_p, rt = find_route(h->rdev.t3cdev_p, laddr->sin_addr.s_addr,
cm_id->local_addr.sin_addr.s_addr, raddr->sin_addr.s_addr, laddr->sin_port,
cm_id->remote_addr.sin_addr.s_addr, raddr->sin_port, IPTOS_LOWDELAY);
cm_id->local_addr.sin_port,
cm_id->remote_addr.sin_port, IPTOS_LOWDELAY);
if (!rt) { if (!rt) {
printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); printk(KERN_ERR MOD "%s - cannot find route.\n", __func__);
err = -EHOSTUNREACH; err = -EHOSTUNREACH;
...@@ -1941,7 +1951,7 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -1941,7 +1951,7 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
} }
ep->dst = &rt->dst; ep->dst = &rt->dst;
ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst, NULL, ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst, NULL,
&cm_id->remote_addr.sin_addr.s_addr); &raddr->sin_addr.s_addr);
if (!ep->l2t) { if (!ep->l2t) {
printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__);
err = -ENOMEM; err = -ENOMEM;
...@@ -1950,8 +1960,10 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -1950,8 +1960,10 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
state_set(&ep->com, CONNECTING); state_set(&ep->com, CONNECTING);
ep->tos = IPTOS_LOWDELAY; ep->tos = IPTOS_LOWDELAY;
ep->com.local_addr = cm_id->local_addr; memcpy(&ep->com.local_addr, &cm_id->local_addr,
ep->com.remote_addr = cm_id->remote_addr; sizeof(ep->com.local_addr));
memcpy(&ep->com.remote_addr, &cm_id->remote_addr,
sizeof(ep->com.remote_addr));
/* send connect request to rnic */ /* send connect request to rnic */
err = send_connect(ep); err = send_connect(ep);
...@@ -1979,6 +1991,11 @@ int iwch_create_listen(struct iw_cm_id *cm_id, int backlog) ...@@ -1979,6 +1991,11 @@ int iwch_create_listen(struct iw_cm_id *cm_id, int backlog)
might_sleep(); might_sleep();
if (cm_id->local_addr.ss_family != PF_INET) {
err = -ENOSYS;
goto fail1;
}
ep = alloc_ep(sizeof(*ep), GFP_KERNEL); ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
if (!ep) { if (!ep) {
printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __func__); printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __func__);
...@@ -1990,7 +2007,8 @@ int iwch_create_listen(struct iw_cm_id *cm_id, int backlog) ...@@ -1990,7 +2007,8 @@ int iwch_create_listen(struct iw_cm_id *cm_id, int backlog)
cm_id->add_ref(cm_id); cm_id->add_ref(cm_id);
ep->com.cm_id = cm_id; ep->com.cm_id = cm_id;
ep->backlog = backlog; ep->backlog = backlog;
ep->com.local_addr = cm_id->local_addr; memcpy(&ep->com.local_addr, &cm_id->local_addr,
sizeof(ep->com.local_addr));
/* /*
* Allocate a server TID. * Allocate a server TID.
......
...@@ -952,8 +952,10 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status) ...@@ -952,8 +952,10 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_CONNECT_REPLY; event.event = IW_CM_EVENT_CONNECT_REPLY;
event.status = status; event.status = status;
event.local_addr = ep->com.local_addr; memcpy(&event.local_addr, &ep->com.local_addr,
event.remote_addr = ep->com.remote_addr; sizeof(ep->com.local_addr));
memcpy(&event.remote_addr, &ep->com.remote_addr,
sizeof(ep->com.remote_addr));
if ((status == 0) || (status == -ECONNREFUSED)) { if ((status == 0) || (status == -ECONNREFUSED)) {
if (!ep->tried_with_mpa_v1) { if (!ep->tried_with_mpa_v1) {
...@@ -989,8 +991,10 @@ static void connect_request_upcall(struct c4iw_ep *ep) ...@@ -989,8 +991,10 @@ static void connect_request_upcall(struct c4iw_ep *ep)
PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_CONNECT_REQUEST; event.event = IW_CM_EVENT_CONNECT_REQUEST;
event.local_addr = ep->com.local_addr; memcpy(&event.local_addr, &ep->com.local_addr,
event.remote_addr = ep->com.remote_addr; sizeof(ep->com.local_addr));
memcpy(&event.remote_addr, &ep->com.remote_addr,
sizeof(ep->com.remote_addr));
event.provider_data = ep; event.provider_data = ep;
if (!ep->tried_with_mpa_v1) { if (!ep->tried_with_mpa_v1) {
/* this means MPA_v2 is used */ /* this means MPA_v2 is used */
...@@ -1568,6 +1572,10 @@ static int c4iw_reconnect(struct c4iw_ep *ep) ...@@ -1568,6 +1572,10 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
struct net_device *pdev; struct net_device *pdev;
int step; int step;
struct neighbour *neigh; struct neighbour *neigh;
struct sockaddr_in *laddr = (struct sockaddr_in *)
&ep->com.cm_id->local_addr;
struct sockaddr_in *raddr = (struct sockaddr_in *)
&ep->com.cm_id->remote_addr;
PDBG("%s qp %p cm_id %p\n", __func__, ep->com.qp, ep->com.cm_id); PDBG("%s qp %p cm_id %p\n", __func__, ep->com.qp, ep->com.cm_id);
init_timer(&ep->timer); init_timer(&ep->timer);
...@@ -1585,10 +1593,8 @@ static int c4iw_reconnect(struct c4iw_ep *ep) ...@@ -1585,10 +1593,8 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
/* find a route */ /* find a route */
rt = find_route(ep->com.dev, rt = find_route(ep->com.dev,
ep->com.cm_id->local_addr.sin_addr.s_addr, laddr->sin_addr.s_addr, raddr->sin_addr.s_addr,
ep->com.cm_id->remote_addr.sin_addr.s_addr, laddr->sin_port, raddr->sin_port, 0);
ep->com.cm_id->local_addr.sin_port,
ep->com.cm_id->remote_addr.sin_port, 0);
if (!rt) { if (!rt) {
pr_err("%s - cannot find route.\n", __func__); pr_err("%s - cannot find route.\n", __func__);
err = -EHOSTUNREACH; err = -EHOSTUNREACH;
...@@ -1596,8 +1602,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep) ...@@ -1596,8 +1602,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
} }
ep->dst = &rt->dst; ep->dst = &rt->dst;
neigh = dst_neigh_lookup(ep->dst, neigh = dst_neigh_lookup(ep->dst, &raddr->sin_addr.s_addr);
&ep->com.cm_id->remote_addr.sin_addr.s_addr);
if (!neigh) { if (!neigh) {
pr_err("%s - cannot alloc neigh.\n", __func__); pr_err("%s - cannot alloc neigh.\n", __func__);
err = -ENOMEM; err = -ENOMEM;
...@@ -1607,8 +1612,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep) ...@@ -1607,8 +1612,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
/* get a l2t entry */ /* get a l2t entry */
if (neigh->dev->flags & IFF_LOOPBACK) { if (neigh->dev->flags & IFF_LOOPBACK) {
PDBG("%s LOOPBACK\n", __func__); PDBG("%s LOOPBACK\n", __func__);
pdev = ip_dev_find(&init_net, pdev = ip_dev_find(&init_net, raddr->sin_addr.s_addr);
ep->com.cm_id->remote_addr.sin_addr.s_addr);
ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t, ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t,
neigh, pdev, 0); neigh, pdev, 0);
pi = (struct port_info *)netdev_priv(pdev); pi = (struct port_info *)netdev_priv(pdev);
...@@ -2518,6 +2522,8 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -2518,6 +2522,8 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
struct c4iw_ep *ep; struct c4iw_ep *ep;
struct rtable *rt; struct rtable *rt;
int err = 0; int err = 0;
struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr;
struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr;
if ((conn_param->ord > c4iw_max_read_depth) || if ((conn_param->ord > c4iw_max_read_depth) ||
(conn_param->ird > c4iw_max_read_depth)) { (conn_param->ird > c4iw_max_read_depth)) {
...@@ -2562,17 +2568,12 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -2562,17 +2568,12 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
insert_handle(dev, &dev->atid_idr, ep, ep->atid); insert_handle(dev, &dev->atid_idr, ep, ep->atid);
PDBG("%s saddr 0x%x sport 0x%x raddr 0x%x rport 0x%x\n", __func__, PDBG("%s saddr 0x%x sport 0x%x raddr 0x%x rport 0x%x\n", __func__,
ntohl(cm_id->local_addr.sin_addr.s_addr), ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port),
ntohs(cm_id->local_addr.sin_port), ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port));
ntohl(cm_id->remote_addr.sin_addr.s_addr),
ntohs(cm_id->remote_addr.sin_port));
/* find a route */ /* find a route */
rt = find_route(dev, rt = find_route(dev, laddr->sin_addr.s_addr, raddr->sin_addr.s_addr,
cm_id->local_addr.sin_addr.s_addr, laddr->sin_port, raddr->sin_port, 0);
cm_id->remote_addr.sin_addr.s_addr,
cm_id->local_addr.sin_port,
cm_id->remote_addr.sin_port, 0);
if (!rt) { if (!rt) {
printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); printk(KERN_ERR MOD "%s - cannot find route.\n", __func__);
err = -EHOSTUNREACH; err = -EHOSTUNREACH;
...@@ -2580,8 +2581,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -2580,8 +2581,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
} }
ep->dst = &rt->dst; ep->dst = &rt->dst;
err = import_ep(ep, cm_id->remote_addr.sin_addr.s_addr, err = import_ep(ep, raddr->sin_addr.s_addr, ep->dst, ep->com.dev, true);
ep->dst, ep->com.dev, true);
if (err) { if (err) {
printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__);
goto fail4; goto fail4;
...@@ -2593,8 +2593,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -2593,8 +2593,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
state_set(&ep->com, CONNECTING); state_set(&ep->com, CONNECTING);
ep->tos = 0; ep->tos = 0;
ep->com.local_addr = cm_id->local_addr; memcpy(&ep->com.local_addr, &cm_id->local_addr,
ep->com.remote_addr = cm_id->remote_addr; sizeof(ep->com.local_addr));
memcpy(&ep->com.remote_addr, &cm_id->remote_addr,
sizeof(ep->com.remote_addr));
/* send connect request to rnic */ /* send connect request to rnic */
err = send_connect(ep); err = send_connect(ep);
...@@ -2633,7 +2635,8 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) ...@@ -2633,7 +2635,8 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog)
ep->com.cm_id = cm_id; ep->com.cm_id = cm_id;
ep->com.dev = dev; ep->com.dev = dev;
ep->backlog = backlog; ep->backlog = backlog;
ep->com.local_addr = cm_id->local_addr; memcpy(&ep->com.local_addr, &cm_id->local_addr,
sizeof(ep->com.local_addr));
/* /*
* Allocate a server TID. * Allocate a server TID.
......
This diff is collapsed.
...@@ -49,8 +49,8 @@ enum iw_cm_event_type { ...@@ -49,8 +49,8 @@ enum iw_cm_event_type {
struct iw_cm_event { struct iw_cm_event {
enum iw_cm_event_type event; enum iw_cm_event_type event;
int status; int status;
struct sockaddr_in local_addr; struct sockaddr_storage local_addr;
struct sockaddr_in remote_addr; struct sockaddr_storage remote_addr;
void *private_data; void *private_data;
void *provider_data; void *provider_data;
u8 private_data_len; u8 private_data_len;
...@@ -83,8 +83,8 @@ struct iw_cm_id { ...@@ -83,8 +83,8 @@ struct iw_cm_id {
iw_cm_handler cm_handler; /* client callback function */ iw_cm_handler cm_handler; /* client callback function */
void *context; /* client cb context */ void *context; /* client cb context */
struct ib_device *device; struct ib_device *device;
struct sockaddr_in local_addr; struct sockaddr_storage local_addr;
struct sockaddr_in remote_addr; struct sockaddr_storage remote_addr;
void *provider_data; /* provider private data */ void *provider_data; /* provider private data */
iw_event_handler event_handler; /* cb for provider iw_event_handler event_handler; /* cb for provider
events */ events */
......
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