diff options
author | Steve Wise <swise@opengridcomputing.com> | 2013-07-04 06:40:44 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-08-12 15:32:31 -0400 |
commit | 24d44a391f1b5d56e9c7a4fc1edd085687864ff9 (patch) | |
tree | 3076b01a1b85d6b21d08f615a44a4b7c2f5b5acb /drivers | |
parent | c095ba7224d8edc71dcef0d655911399a8bd4a3f (diff) |
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: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
[ Fix unused variable warnings when INFINIBAND_NES_DEBUG not set.
- Roland ]
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/cma.c | 44 | ||||
-rw-r--r-- | drivers/infiniband/hw/amso1100/c2_ae.c | 18 | ||||
-rw-r--r-- | drivers/infiniband/hw/amso1100/c2_cm.c | 16 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_cm.c | 46 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb4/cm.c | 55 | ||||
-rw-r--r-- | drivers/infiniband/hw/nes/nes_cm.c | 153 |
6 files changed, 184 insertions, 148 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 7c0f9535fb7d..3a2c3c3bf723 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -1385,8 +1385,9 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) | |||
1385 | { | 1385 | { |
1386 | struct rdma_id_private *id_priv = iw_id->context; | 1386 | struct rdma_id_private *id_priv = iw_id->context; |
1387 | struct rdma_cm_event event; | 1387 | struct rdma_cm_event event; |
1388 | struct sockaddr_in *sin; | ||
1389 | int ret = 0; | 1388 | int ret = 0; |
1389 | struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr; | ||
1390 | struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr; | ||
1390 | 1391 | ||
1391 | if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) | 1392 | if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) |
1392 | return 0; | 1393 | return 0; |
@@ -1397,10 +1398,10 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) | |||
1397 | event.event = RDMA_CM_EVENT_DISCONNECTED; | 1398 | event.event = RDMA_CM_EVENT_DISCONNECTED; |
1398 | break; | 1399 | break; |
1399 | case IW_CM_EVENT_CONNECT_REPLY: | 1400 | case IW_CM_EVENT_CONNECT_REPLY: |
1400 | sin = (struct sockaddr_in *) cma_src_addr(id_priv); | 1401 | memcpy(cma_src_addr(id_priv), laddr, |
1401 | *sin = iw_event->local_addr; | 1402 | rdma_addr_size(laddr)); |
1402 | sin = (struct sockaddr_in *) cma_dst_addr(id_priv); | 1403 | memcpy(cma_dst_addr(id_priv), raddr, |
1403 | *sin = iw_event->remote_addr; | 1404 | rdma_addr_size(raddr)); |
1404 | switch (iw_event->status) { | 1405 | switch (iw_event->status) { |
1405 | case 0: | 1406 | case 0: |
1406 | event.event = RDMA_CM_EVENT_ESTABLISHED; | 1407 | event.event = RDMA_CM_EVENT_ESTABLISHED; |
@@ -1450,11 +1451,12 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, | |||
1450 | { | 1451 | { |
1451 | struct rdma_cm_id *new_cm_id; | 1452 | struct rdma_cm_id *new_cm_id; |
1452 | struct rdma_id_private *listen_id, *conn_id; | 1453 | struct rdma_id_private *listen_id, *conn_id; |
1453 | struct sockaddr_in *sin; | ||
1454 | struct net_device *dev = NULL; | 1454 | struct net_device *dev = NULL; |
1455 | struct rdma_cm_event event; | 1455 | struct rdma_cm_event event; |
1456 | int ret; | 1456 | int ret; |
1457 | struct ib_device_attr attr; | 1457 | struct ib_device_attr attr; |
1458 | struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr; | ||
1459 | struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr; | ||
1458 | 1460 | ||
1459 | listen_id = cm_id->context; | 1461 | listen_id = cm_id->context; |
1460 | if (cma_disable_callback(listen_id, RDMA_CM_LISTEN)) | 1462 | 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 | mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING); | 1474 | mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING); |
1473 | conn_id->state = RDMA_CM_CONNECT; | 1475 | conn_id->state = RDMA_CM_CONNECT; |
1474 | 1476 | ||
1475 | dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr); | 1477 | ret = rdma_translate_ip(laddr, &conn_id->id.route.addr.dev_addr); |
1476 | if (!dev) { | ||
1477 | ret = -EADDRNOTAVAIL; | ||
1478 | mutex_unlock(&conn_id->handler_mutex); | ||
1479 | rdma_destroy_id(new_cm_id); | ||
1480 | goto out; | ||
1481 | } | ||
1482 | ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL); | ||
1483 | if (ret) { | 1478 | if (ret) { |
1484 | mutex_unlock(&conn_id->handler_mutex); | 1479 | mutex_unlock(&conn_id->handler_mutex); |
1485 | rdma_destroy_id(new_cm_id); | 1480 | rdma_destroy_id(new_cm_id); |
@@ -1497,10 +1492,8 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, | |||
1497 | cm_id->context = conn_id; | 1492 | cm_id->context = conn_id; |
1498 | cm_id->cm_handler = cma_iw_handler; | 1493 | cm_id->cm_handler = cma_iw_handler; |
1499 | 1494 | ||
1500 | sin = (struct sockaddr_in *) cma_src_addr(conn_id); | 1495 | memcpy(cma_src_addr(conn_id), laddr, rdma_addr_size(laddr)); |
1501 | *sin = iw_event->local_addr; | 1496 | memcpy(cma_dst_addr(conn_id), raddr, rdma_addr_size(raddr)); |
1502 | sin = (struct sockaddr_in *) cma_dst_addr(conn_id); | ||
1503 | *sin = iw_event->remote_addr; | ||
1504 | 1497 | ||
1505 | ret = ib_query_device(conn_id->id.device, &attr); | 1498 | ret = ib_query_device(conn_id->id.device, &attr); |
1506 | if (ret) { | 1499 | if (ret) { |
@@ -1576,7 +1569,6 @@ static int cma_ib_listen(struct rdma_id_private *id_priv) | |||
1576 | static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog) | 1569 | static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog) |
1577 | { | 1570 | { |
1578 | int ret; | 1571 | int ret; |
1579 | struct sockaddr_in *sin; | ||
1580 | struct iw_cm_id *id; | 1572 | struct iw_cm_id *id; |
1581 | 1573 | ||
1582 | id = iw_create_cm_id(id_priv->id.device, | 1574 | 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 | 1579 | ||
1588 | id_priv->cm_id.iw = id; | 1580 | id_priv->cm_id.iw = id; |
1589 | 1581 | ||
1590 | sin = (struct sockaddr_in *) cma_src_addr(id_priv); | 1582 | memcpy(&id_priv->cm_id.iw->local_addr, cma_src_addr(id_priv), |
1591 | id_priv->cm_id.iw->local_addr = *sin; | 1583 | rdma_addr_size(cma_src_addr(id_priv))); |
1592 | 1584 | ||
1593 | ret = iw_cm_listen(id_priv->cm_id.iw, backlog); | 1585 | ret = iw_cm_listen(id_priv->cm_id.iw, backlog); |
1594 | 1586 | ||
@@ -2803,7 +2795,6 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, | |||
2803 | struct rdma_conn_param *conn_param) | 2795 | struct rdma_conn_param *conn_param) |
2804 | { | 2796 | { |
2805 | struct iw_cm_id *cm_id; | 2797 | struct iw_cm_id *cm_id; |
2806 | struct sockaddr_in* sin; | ||
2807 | int ret; | 2798 | int ret; |
2808 | struct iw_cm_conn_param iw_param; | 2799 | struct iw_cm_conn_param iw_param; |
2809 | 2800 | ||
@@ -2813,11 +2804,10 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, | |||
2813 | 2804 | ||
2814 | id_priv->cm_id.iw = cm_id; | 2805 | id_priv->cm_id.iw = cm_id; |
2815 | 2806 | ||
2816 | sin = (struct sockaddr_in *) cma_src_addr(id_priv); | 2807 | memcpy(&cm_id->local_addr, cma_src_addr(id_priv), |
2817 | cm_id->local_addr = *sin; | 2808 | rdma_addr_size(cma_src_addr(id_priv))); |
2818 | 2809 | memcpy(&cm_id->remote_addr, cma_dst_addr(id_priv), | |
2819 | sin = (struct sockaddr_in *) cma_dst_addr(id_priv); | 2810 | rdma_addr_size(cma_dst_addr(id_priv))); |
2820 | cm_id->remote_addr = *sin; | ||
2821 | 2811 | ||
2822 | ret = cma_modify_qp_rtr(id_priv, conn_param); | 2812 | ret = cma_modify_qp_rtr(id_priv, conn_param); |
2823 | if (ret) | 2813 | if (ret) |
diff --git a/drivers/infiniband/hw/amso1100/c2_ae.c b/drivers/infiniband/hw/amso1100/c2_ae.c index 706cf97cbe8f..d5d1929753e4 100644 --- a/drivers/infiniband/hw/amso1100/c2_ae.c +++ b/drivers/infiniband/hw/amso1100/c2_ae.c | |||
@@ -155,6 +155,8 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) | |||
155 | enum c2_event_id event_id; | 155 | enum c2_event_id event_id; |
156 | unsigned long flags; | 156 | unsigned long flags; |
157 | int status; | 157 | int status; |
158 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_event.local_addr; | ||
159 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_event.remote_addr; | ||
158 | 160 | ||
159 | /* | 161 | /* |
160 | * retrieve the message | 162 | * retrieve the message |
@@ -206,10 +208,10 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) | |||
206 | case CCAE_ACTIVE_CONNECT_RESULTS: | 208 | case CCAE_ACTIVE_CONNECT_RESULTS: |
207 | res = &wr->ae.ae_active_connect_results; | 209 | res = &wr->ae.ae_active_connect_results; |
208 | cm_event.event = IW_CM_EVENT_CONNECT_REPLY; | 210 | cm_event.event = IW_CM_EVENT_CONNECT_REPLY; |
209 | cm_event.local_addr.sin_addr.s_addr = res->laddr; | 211 | laddr->sin_addr.s_addr = res->laddr; |
210 | cm_event.remote_addr.sin_addr.s_addr = res->raddr; | 212 | raddr->sin_addr.s_addr = res->raddr; |
211 | cm_event.local_addr.sin_port = res->lport; | 213 | laddr->sin_port = res->lport; |
212 | cm_event.remote_addr.sin_port = res->rport; | 214 | raddr->sin_port = res->rport; |
213 | if (status == 0) { | 215 | if (status == 0) { |
214 | cm_event.private_data_len = | 216 | cm_event.private_data_len = |
215 | be32_to_cpu(res->private_data_length); | 217 | be32_to_cpu(res->private_data_length); |
@@ -281,10 +283,10 @@ void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) | |||
281 | } | 283 | } |
282 | cm_event.event = IW_CM_EVENT_CONNECT_REQUEST; | 284 | cm_event.event = IW_CM_EVENT_CONNECT_REQUEST; |
283 | cm_event.provider_data = (void*)(unsigned long)req->cr_handle; | 285 | cm_event.provider_data = (void*)(unsigned long)req->cr_handle; |
284 | cm_event.local_addr.sin_addr.s_addr = req->laddr; | 286 | laddr->sin_addr.s_addr = req->laddr; |
285 | cm_event.remote_addr.sin_addr.s_addr = req->raddr; | 287 | raddr->sin_addr.s_addr = req->raddr; |
286 | cm_event.local_addr.sin_port = req->lport; | 288 | laddr->sin_port = req->lport; |
287 | cm_event.remote_addr.sin_port = req->rport; | 289 | raddr->sin_port = req->rport; |
288 | cm_event.private_data_len = | 290 | cm_event.private_data_len = |
289 | be32_to_cpu(req->private_data_length); | 291 | be32_to_cpu(req->private_data_length); |
290 | cm_event.private_data = req->private_data; | 292 | cm_event.private_data = req->private_data; |
diff --git a/drivers/infiniband/hw/amso1100/c2_cm.c b/drivers/infiniband/hw/amso1100/c2_cm.c index 95f58ab1e0b8..23bfa94fbd4e 100644 --- a/drivers/infiniband/hw/amso1100/c2_cm.c +++ b/drivers/infiniband/hw/amso1100/c2_cm.c | |||
@@ -46,6 +46,10 @@ int c2_llp_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) | |||
46 | struct c2wr_qp_connect_req *wr; /* variable size needs a malloc. */ | 46 | struct c2wr_qp_connect_req *wr; /* variable size needs a malloc. */ |
47 | struct c2_vq_req *vq_req; | 47 | struct c2_vq_req *vq_req; |
48 | int err; | 48 | int err; |
49 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
50 | |||
51 | if (cm_id->remote_addr.ss_family != AF_INET) | ||
52 | return -ENOSYS; | ||
49 | 53 | ||
50 | ibqp = c2_get_qp(cm_id->device, iw_param->qpn); | 54 | ibqp = c2_get_qp(cm_id->device, iw_param->qpn); |
51 | if (!ibqp) | 55 | if (!ibqp) |
@@ -91,8 +95,8 @@ int c2_llp_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) | |||
91 | wr->rnic_handle = c2dev->adapter_handle; | 95 | wr->rnic_handle = c2dev->adapter_handle; |
92 | wr->qp_handle = qp->adapter_handle; | 96 | wr->qp_handle = qp->adapter_handle; |
93 | 97 | ||
94 | wr->remote_addr = cm_id->remote_addr.sin_addr.s_addr; | 98 | wr->remote_addr = raddr->sin_addr.s_addr; |
95 | wr->remote_port = cm_id->remote_addr.sin_port; | 99 | wr->remote_port = raddr->sin_port; |
96 | 100 | ||
97 | /* | 101 | /* |
98 | * Move any private data from the callers's buf into | 102 | * 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 | struct c2wr_ep_listen_create_rep *reply; | 139 | struct c2wr_ep_listen_create_rep *reply; |
136 | struct c2_vq_req *vq_req; | 140 | struct c2_vq_req *vq_req; |
137 | int err; | 141 | int err; |
142 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
143 | |||
144 | if (cm_id->local_addr.ss_family != AF_INET) | ||
145 | return -ENOSYS; | ||
138 | 146 | ||
139 | c2dev = to_c2dev(cm_id->device); | 147 | c2dev = to_c2dev(cm_id->device); |
140 | if (c2dev == NULL) | 148 | if (c2dev == NULL) |
@@ -153,8 +161,8 @@ int c2_llp_service_create(struct iw_cm_id *cm_id, int backlog) | |||
153 | c2_wr_set_id(&wr, CCWR_EP_LISTEN_CREATE); | 161 | c2_wr_set_id(&wr, CCWR_EP_LISTEN_CREATE); |
154 | wr.hdr.context = (u64) (unsigned long) vq_req; | 162 | wr.hdr.context = (u64) (unsigned long) vq_req; |
155 | wr.rnic_handle = c2dev->adapter_handle; | 163 | wr.rnic_handle = c2dev->adapter_handle; |
156 | wr.local_addr = cm_id->local_addr.sin_addr.s_addr; | 164 | wr.local_addr = laddr->sin_addr.s_addr; |
157 | wr.local_port = cm_id->local_addr.sin_port; | 165 | wr.local_port = laddr->sin_port; |
158 | wr.backlog = cpu_to_be32(backlog); | 166 | wr.backlog = cpu_to_be32(backlog); |
159 | wr.user_context = (u64) (unsigned long) cm_id; | 167 | wr.user_context = (u64) (unsigned long) cm_id; |
160 | 168 | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c index 3e094cd6a0e3..095bb046e2c8 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c | |||
@@ -721,8 +721,10 @@ static void connect_reply_upcall(struct iwch_ep *ep, int status) | |||
721 | memset(&event, 0, sizeof(event)); | 721 | memset(&event, 0, sizeof(event)); |
722 | event.event = IW_CM_EVENT_CONNECT_REPLY; | 722 | event.event = IW_CM_EVENT_CONNECT_REPLY; |
723 | event.status = status; | 723 | event.status = status; |
724 | event.local_addr = ep->com.local_addr; | 724 | memcpy(&event.local_addr, &ep->com.local_addr, |
725 | event.remote_addr = ep->com.remote_addr; | 725 | sizeof(ep->com.local_addr)); |
726 | memcpy(&event.remote_addr, &ep->com.remote_addr, | ||
727 | sizeof(ep->com.remote_addr)); | ||
726 | 728 | ||
727 | if ((status == 0) || (status == -ECONNREFUSED)) { | 729 | if ((status == 0) || (status == -ECONNREFUSED)) { |
728 | event.private_data_len = ep->plen; | 730 | event.private_data_len = ep->plen; |
@@ -747,8 +749,10 @@ static void connect_request_upcall(struct iwch_ep *ep) | |||
747 | PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid); | 749 | PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid); |
748 | memset(&event, 0, sizeof(event)); | 750 | memset(&event, 0, sizeof(event)); |
749 | event.event = IW_CM_EVENT_CONNECT_REQUEST; | 751 | event.event = IW_CM_EVENT_CONNECT_REQUEST; |
750 | event.local_addr = ep->com.local_addr; | 752 | memcpy(&event.local_addr, &ep->com.local_addr, |
751 | event.remote_addr = ep->com.remote_addr; | 753 | sizeof(ep->com.local_addr)); |
754 | memcpy(&event.remote_addr, &ep->com.remote_addr, | ||
755 | sizeof(ep->com.local_addr)); | ||
752 | event.private_data_len = ep->plen; | 756 | event.private_data_len = ep->plen; |
753 | event.private_data = ep->mpa_pkt + sizeof(struct mpa_message); | 757 | event.private_data = ep->mpa_pkt + sizeof(struct mpa_message); |
754 | event.provider_data = ep; | 758 | event.provider_data = ep; |
@@ -1872,8 +1876,9 @@ err: | |||
1872 | static int is_loopback_dst(struct iw_cm_id *cm_id) | 1876 | static int is_loopback_dst(struct iw_cm_id *cm_id) |
1873 | { | 1877 | { |
1874 | struct net_device *dev; | 1878 | struct net_device *dev; |
1879 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
1875 | 1880 | ||
1876 | dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr); | 1881 | dev = ip_dev_find(&init_net, raddr->sin_addr.s_addr); |
1877 | if (!dev) | 1882 | if (!dev) |
1878 | return 0; | 1883 | return 0; |
1879 | dev_put(dev); | 1884 | dev_put(dev); |
@@ -1886,6 +1891,13 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
1886 | struct iwch_ep *ep; | 1891 | struct iwch_ep *ep; |
1887 | struct rtable *rt; | 1892 | struct rtable *rt; |
1888 | int err = 0; | 1893 | int err = 0; |
1894 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
1895 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
1896 | |||
1897 | if (cm_id->remote_addr.ss_family != PF_INET) { | ||
1898 | err = -ENOSYS; | ||
1899 | goto out; | ||
1900 | } | ||
1889 | 1901 | ||
1890 | if (is_loopback_dst(cm_id)) { | 1902 | if (is_loopback_dst(cm_id)) { |
1891 | err = -ENOSYS; | 1903 | err = -ENOSYS; |
@@ -1929,11 +1941,9 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
1929 | } | 1941 | } |
1930 | 1942 | ||
1931 | /* find a route */ | 1943 | /* find a route */ |
1932 | rt = find_route(h->rdev.t3cdev_p, | 1944 | rt = find_route(h->rdev.t3cdev_p, laddr->sin_addr.s_addr, |
1933 | cm_id->local_addr.sin_addr.s_addr, | 1945 | raddr->sin_addr.s_addr, laddr->sin_port, |
1934 | cm_id->remote_addr.sin_addr.s_addr, | 1946 | raddr->sin_port, IPTOS_LOWDELAY); |
1935 | cm_id->local_addr.sin_port, | ||
1936 | cm_id->remote_addr.sin_port, IPTOS_LOWDELAY); | ||
1937 | if (!rt) { | 1947 | if (!rt) { |
1938 | printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); | 1948 | printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); |
1939 | err = -EHOSTUNREACH; | 1949 | err = -EHOSTUNREACH; |
@@ -1941,7 +1951,7 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
1941 | } | 1951 | } |
1942 | ep->dst = &rt->dst; | 1952 | ep->dst = &rt->dst; |
1943 | ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst, NULL, | 1953 | ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst, NULL, |
1944 | &cm_id->remote_addr.sin_addr.s_addr); | 1954 | &raddr->sin_addr.s_addr); |
1945 | if (!ep->l2t) { | 1955 | if (!ep->l2t) { |
1946 | printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); | 1956 | printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); |
1947 | err = -ENOMEM; | 1957 | err = -ENOMEM; |
@@ -1950,8 +1960,10 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
1950 | 1960 | ||
1951 | state_set(&ep->com, CONNECTING); | 1961 | state_set(&ep->com, CONNECTING); |
1952 | ep->tos = IPTOS_LOWDELAY; | 1962 | ep->tos = IPTOS_LOWDELAY; |
1953 | ep->com.local_addr = cm_id->local_addr; | 1963 | memcpy(&ep->com.local_addr, &cm_id->local_addr, |
1954 | ep->com.remote_addr = cm_id->remote_addr; | 1964 | sizeof(ep->com.local_addr)); |
1965 | memcpy(&ep->com.remote_addr, &cm_id->remote_addr, | ||
1966 | sizeof(ep->com.remote_addr)); | ||
1955 | 1967 | ||
1956 | /* send connect request to rnic */ | 1968 | /* send connect request to rnic */ |
1957 | err = send_connect(ep); | 1969 | err = send_connect(ep); |
@@ -1979,6 +1991,11 @@ int iwch_create_listen(struct iw_cm_id *cm_id, int backlog) | |||
1979 | 1991 | ||
1980 | might_sleep(); | 1992 | might_sleep(); |
1981 | 1993 | ||
1994 | if (cm_id->local_addr.ss_family != PF_INET) { | ||
1995 | err = -ENOSYS; | ||
1996 | goto fail1; | ||
1997 | } | ||
1998 | |||
1982 | ep = alloc_ep(sizeof(*ep), GFP_KERNEL); | 1999 | ep = alloc_ep(sizeof(*ep), GFP_KERNEL); |
1983 | if (!ep) { | 2000 | if (!ep) { |
1984 | printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __func__); | 2001 | 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 | cm_id->add_ref(cm_id); | 2007 | cm_id->add_ref(cm_id); |
1991 | ep->com.cm_id = cm_id; | 2008 | ep->com.cm_id = cm_id; |
1992 | ep->backlog = backlog; | 2009 | ep->backlog = backlog; |
1993 | ep->com.local_addr = cm_id->local_addr; | 2010 | memcpy(&ep->com.local_addr, &cm_id->local_addr, |
2011 | sizeof(ep->com.local_addr)); | ||
1994 | 2012 | ||
1995 | /* | 2013 | /* |
1996 | * Allocate a server TID. | 2014 | * Allocate a server TID. |
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index 65c30ea8c1a1..76d8812f9e9a 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c | |||
@@ -952,8 +952,10 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status) | |||
952 | memset(&event, 0, sizeof(event)); | 952 | memset(&event, 0, sizeof(event)); |
953 | event.event = IW_CM_EVENT_CONNECT_REPLY; | 953 | event.event = IW_CM_EVENT_CONNECT_REPLY; |
954 | event.status = status; | 954 | event.status = status; |
955 | event.local_addr = ep->com.local_addr; | 955 | memcpy(&event.local_addr, &ep->com.local_addr, |
956 | event.remote_addr = ep->com.remote_addr; | 956 | sizeof(ep->com.local_addr)); |
957 | memcpy(&event.remote_addr, &ep->com.remote_addr, | ||
958 | sizeof(ep->com.remote_addr)); | ||
957 | 959 | ||
958 | if ((status == 0) || (status == -ECONNREFUSED)) { | 960 | if ((status == 0) || (status == -ECONNREFUSED)) { |
959 | if (!ep->tried_with_mpa_v1) { | 961 | if (!ep->tried_with_mpa_v1) { |
@@ -989,8 +991,10 @@ static void connect_request_upcall(struct c4iw_ep *ep) | |||
989 | PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); | 991 | PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); |
990 | memset(&event, 0, sizeof(event)); | 992 | memset(&event, 0, sizeof(event)); |
991 | event.event = IW_CM_EVENT_CONNECT_REQUEST; | 993 | event.event = IW_CM_EVENT_CONNECT_REQUEST; |
992 | event.local_addr = ep->com.local_addr; | 994 | memcpy(&event.local_addr, &ep->com.local_addr, |
993 | event.remote_addr = ep->com.remote_addr; | 995 | sizeof(ep->com.local_addr)); |
996 | memcpy(&event.remote_addr, &ep->com.remote_addr, | ||
997 | sizeof(ep->com.remote_addr)); | ||
994 | event.provider_data = ep; | 998 | event.provider_data = ep; |
995 | if (!ep->tried_with_mpa_v1) { | 999 | if (!ep->tried_with_mpa_v1) { |
996 | /* this means MPA_v2 is used */ | 1000 | /* this means MPA_v2 is used */ |
@@ -1568,6 +1572,10 @@ static int c4iw_reconnect(struct c4iw_ep *ep) | |||
1568 | struct net_device *pdev; | 1572 | struct net_device *pdev; |
1569 | int step; | 1573 | int step; |
1570 | struct neighbour *neigh; | 1574 | struct neighbour *neigh; |
1575 | struct sockaddr_in *laddr = (struct sockaddr_in *) | ||
1576 | &ep->com.cm_id->local_addr; | ||
1577 | struct sockaddr_in *raddr = (struct sockaddr_in *) | ||
1578 | &ep->com.cm_id->remote_addr; | ||
1571 | 1579 | ||
1572 | PDBG("%s qp %p cm_id %p\n", __func__, ep->com.qp, ep->com.cm_id); | 1580 | PDBG("%s qp %p cm_id %p\n", __func__, ep->com.qp, ep->com.cm_id); |
1573 | init_timer(&ep->timer); | 1581 | init_timer(&ep->timer); |
@@ -1585,10 +1593,8 @@ static int c4iw_reconnect(struct c4iw_ep *ep) | |||
1585 | 1593 | ||
1586 | /* find a route */ | 1594 | /* find a route */ |
1587 | rt = find_route(ep->com.dev, | 1595 | rt = find_route(ep->com.dev, |
1588 | ep->com.cm_id->local_addr.sin_addr.s_addr, | 1596 | laddr->sin_addr.s_addr, raddr->sin_addr.s_addr, |
1589 | ep->com.cm_id->remote_addr.sin_addr.s_addr, | 1597 | laddr->sin_port, raddr->sin_port, 0); |
1590 | ep->com.cm_id->local_addr.sin_port, | ||
1591 | ep->com.cm_id->remote_addr.sin_port, 0); | ||
1592 | if (!rt) { | 1598 | if (!rt) { |
1593 | pr_err("%s - cannot find route.\n", __func__); | 1599 | pr_err("%s - cannot find route.\n", __func__); |
1594 | err = -EHOSTUNREACH; | 1600 | err = -EHOSTUNREACH; |
@@ -1596,8 +1602,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep) | |||
1596 | } | 1602 | } |
1597 | ep->dst = &rt->dst; | 1603 | ep->dst = &rt->dst; |
1598 | 1604 | ||
1599 | neigh = dst_neigh_lookup(ep->dst, | 1605 | neigh = dst_neigh_lookup(ep->dst, &raddr->sin_addr.s_addr); |
1600 | &ep->com.cm_id->remote_addr.sin_addr.s_addr); | ||
1601 | if (!neigh) { | 1606 | if (!neigh) { |
1602 | pr_err("%s - cannot alloc neigh.\n", __func__); | 1607 | pr_err("%s - cannot alloc neigh.\n", __func__); |
1603 | err = -ENOMEM; | 1608 | err = -ENOMEM; |
@@ -1607,8 +1612,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep) | |||
1607 | /* get a l2t entry */ | 1612 | /* get a l2t entry */ |
1608 | if (neigh->dev->flags & IFF_LOOPBACK) { | 1613 | if (neigh->dev->flags & IFF_LOOPBACK) { |
1609 | PDBG("%s LOOPBACK\n", __func__); | 1614 | PDBG("%s LOOPBACK\n", __func__); |
1610 | pdev = ip_dev_find(&init_net, | 1615 | pdev = ip_dev_find(&init_net, raddr->sin_addr.s_addr); |
1611 | ep->com.cm_id->remote_addr.sin_addr.s_addr); | ||
1612 | ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t, | 1616 | ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t, |
1613 | neigh, pdev, 0); | 1617 | neigh, pdev, 0); |
1614 | pi = (struct port_info *)netdev_priv(pdev); | 1618 | 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 | struct c4iw_ep *ep; | 2522 | struct c4iw_ep *ep; |
2519 | struct rtable *rt; | 2523 | struct rtable *rt; |
2520 | int err = 0; | 2524 | int err = 0; |
2525 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
2526 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
2521 | 2527 | ||
2522 | if ((conn_param->ord > c4iw_max_read_depth) || | 2528 | if ((conn_param->ord > c4iw_max_read_depth) || |
2523 | (conn_param->ird > c4iw_max_read_depth)) { | 2529 | (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 | insert_handle(dev, &dev->atid_idr, ep, ep->atid); | 2568 | insert_handle(dev, &dev->atid_idr, ep, ep->atid); |
2563 | 2569 | ||
2564 | PDBG("%s saddr 0x%x sport 0x%x raddr 0x%x rport 0x%x\n", __func__, | 2570 | PDBG("%s saddr 0x%x sport 0x%x raddr 0x%x rport 0x%x\n", __func__, |
2565 | ntohl(cm_id->local_addr.sin_addr.s_addr), | 2571 | ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port), |
2566 | ntohs(cm_id->local_addr.sin_port), | 2572 | ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port)); |
2567 | ntohl(cm_id->remote_addr.sin_addr.s_addr), | ||
2568 | ntohs(cm_id->remote_addr.sin_port)); | ||
2569 | 2573 | ||
2570 | /* find a route */ | 2574 | /* find a route */ |
2571 | rt = find_route(dev, | 2575 | rt = find_route(dev, laddr->sin_addr.s_addr, raddr->sin_addr.s_addr, |
2572 | cm_id->local_addr.sin_addr.s_addr, | 2576 | laddr->sin_port, raddr->sin_port, 0); |
2573 | cm_id->remote_addr.sin_addr.s_addr, | ||
2574 | cm_id->local_addr.sin_port, | ||
2575 | cm_id->remote_addr.sin_port, 0); | ||
2576 | if (!rt) { | 2577 | if (!rt) { |
2577 | printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); | 2578 | printk(KERN_ERR MOD "%s - cannot find route.\n", __func__); |
2578 | err = -EHOSTUNREACH; | 2579 | err = -EHOSTUNREACH; |
@@ -2580,8 +2581,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
2580 | } | 2581 | } |
2581 | ep->dst = &rt->dst; | 2582 | ep->dst = &rt->dst; |
2582 | 2583 | ||
2583 | err = import_ep(ep, cm_id->remote_addr.sin_addr.s_addr, | 2584 | err = import_ep(ep, raddr->sin_addr.s_addr, ep->dst, ep->com.dev, true); |
2584 | ep->dst, ep->com.dev, true); | ||
2585 | if (err) { | 2585 | if (err) { |
2586 | printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); | 2586 | printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); |
2587 | goto fail4; | 2587 | goto fail4; |
@@ -2593,8 +2593,10 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
2593 | 2593 | ||
2594 | state_set(&ep->com, CONNECTING); | 2594 | state_set(&ep->com, CONNECTING); |
2595 | ep->tos = 0; | 2595 | ep->tos = 0; |
2596 | ep->com.local_addr = cm_id->local_addr; | 2596 | memcpy(&ep->com.local_addr, &cm_id->local_addr, |
2597 | ep->com.remote_addr = cm_id->remote_addr; | 2597 | sizeof(ep->com.local_addr)); |
2598 | memcpy(&ep->com.remote_addr, &cm_id->remote_addr, | ||
2599 | sizeof(ep->com.remote_addr)); | ||
2598 | 2600 | ||
2599 | /* send connect request to rnic */ | 2601 | /* send connect request to rnic */ |
2600 | err = send_connect(ep); | 2602 | err = send_connect(ep); |
@@ -2633,7 +2635,8 @@ int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) | |||
2633 | ep->com.cm_id = cm_id; | 2635 | ep->com.cm_id = cm_id; |
2634 | ep->com.dev = dev; | 2636 | ep->com.dev = dev; |
2635 | ep->backlog = backlog; | 2637 | ep->backlog = backlog; |
2636 | ep->com.local_addr = cm_id->local_addr; | 2638 | memcpy(&ep->com.local_addr, &cm_id->local_addr, |
2639 | sizeof(ep->com.local_addr)); | ||
2637 | 2640 | ||
2638 | /* | 2641 | /* |
2639 | * Allocate a server TID. | 2642 | * Allocate a server TID. |
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c index 24b9f1a0107b..6b29249aa85a 100644 --- a/drivers/infiniband/hw/nes/nes_cm.c +++ b/drivers/infiniband/hw/nes/nes_cm.c | |||
@@ -2998,6 +2998,8 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
2998 | u8 *start_ptr = &start_addr; | 2998 | u8 *start_ptr = &start_addr; |
2999 | u8 **start_buff = &start_ptr; | 2999 | u8 **start_buff = &start_ptr; |
3000 | u16 buff_len = 0; | 3000 | u16 buff_len = 0; |
3001 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
3002 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
3001 | 3003 | ||
3002 | ibqp = nes_get_qp(cm_id->device, conn_param->qpn); | 3004 | ibqp = nes_get_qp(cm_id->device, conn_param->qpn); |
3003 | if (!ibqp) | 3005 | if (!ibqp) |
@@ -3062,8 +3064,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3062 | /* setup our first outgoing iWarp send WQE (the IETF frame response) */ | 3064 | /* setup our first outgoing iWarp send WQE (the IETF frame response) */ |
3063 | wqe = &nesqp->hwqp.sq_vbase[0]; | 3065 | wqe = &nesqp->hwqp.sq_vbase[0]; |
3064 | 3066 | ||
3065 | if (cm_id->remote_addr.sin_addr.s_addr != | 3067 | if (raddr->sin_addr.s_addr != laddr->sin_addr.s_addr) { |
3066 | cm_id->local_addr.sin_addr.s_addr) { | ||
3067 | u64temp = (unsigned long)nesqp; | 3068 | u64temp = (unsigned long)nesqp; |
3068 | nesibdev = nesvnic->nesibdev; | 3069 | nesibdev = nesvnic->nesibdev; |
3069 | nespd = nesqp->nespd; | 3070 | nespd = nesqp->nespd; |
@@ -3132,13 +3133,10 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3132 | 3133 | ||
3133 | nes_cm_init_tsa_conn(nesqp, cm_node); | 3134 | nes_cm_init_tsa_conn(nesqp, cm_node); |
3134 | 3135 | ||
3135 | nesqp->nesqp_context->tcpPorts[0] = | 3136 | nesqp->nesqp_context->tcpPorts[0] = cpu_to_le16(ntohs(laddr->sin_port)); |
3136 | cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); | 3137 | nesqp->nesqp_context->tcpPorts[1] = cpu_to_le16(ntohs(raddr->sin_port)); |
3137 | nesqp->nesqp_context->tcpPorts[1] = | ||
3138 | cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); | ||
3139 | 3138 | ||
3140 | nesqp->nesqp_context->ip0 = | 3139 | nesqp->nesqp_context->ip0 = cpu_to_le32(ntohl(raddr->sin_addr.s_addr)); |
3141 | cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); | ||
3142 | 3140 | ||
3143 | nesqp->nesqp_context->misc2 |= cpu_to_le32( | 3141 | nesqp->nesqp_context->misc2 |= cpu_to_le32( |
3144 | (u32)PCI_FUNC(nesdev->pcidev->devfn) << | 3142 | (u32)PCI_FUNC(nesdev->pcidev->devfn) << |
@@ -3162,9 +3160,9 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3162 | memset(&nes_quad, 0, sizeof(nes_quad)); | 3160 | memset(&nes_quad, 0, sizeof(nes_quad)); |
3163 | nes_quad.DstIpAdrIndex = | 3161 | nes_quad.DstIpAdrIndex = |
3164 | cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); | 3162 | cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); |
3165 | nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; | 3163 | nes_quad.SrcIpadr = raddr->sin_addr.s_addr; |
3166 | nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; | 3164 | nes_quad.TcpPorts[0] = raddr->sin_port; |
3167 | nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; | 3165 | nes_quad.TcpPorts[1] = laddr->sin_port; |
3168 | 3166 | ||
3169 | /* Produce hash key */ | 3167 | /* Produce hash key */ |
3170 | crc_value = get_crc_value(&nes_quad); | 3168 | crc_value = get_crc_value(&nes_quad); |
@@ -3180,10 +3178,8 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3180 | nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = " | 3178 | nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = " |
3181 | "0x%08X:0x%04X, rcv_nxt=0x%08X, snd_nxt=0x%08X, mpa + " | 3179 | "0x%08X:0x%04X, rcv_nxt=0x%08X, snd_nxt=0x%08X, mpa + " |
3182 | "private data length=%u.\n", nesqp->hwqp.qp_id, | 3180 | "private data length=%u.\n", nesqp->hwqp.qp_id, |
3183 | ntohl(cm_id->remote_addr.sin_addr.s_addr), | 3181 | ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port), |
3184 | ntohs(cm_id->remote_addr.sin_port), | 3182 | ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port), |
3185 | ntohl(cm_id->local_addr.sin_addr.s_addr), | ||
3186 | ntohs(cm_id->local_addr.sin_port), | ||
3187 | le32_to_cpu(nesqp->nesqp_context->rcv_nxt), | 3183 | le32_to_cpu(nesqp->nesqp_context->rcv_nxt), |
3188 | le32_to_cpu(nesqp->nesqp_context->snd_nxt), | 3184 | le32_to_cpu(nesqp->nesqp_context->snd_nxt), |
3189 | buff_len); | 3185 | buff_len); |
@@ -3263,7 +3259,11 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3263 | struct nes_cm_node *cm_node; | 3259 | struct nes_cm_node *cm_node; |
3264 | struct nes_cm_info cm_info; | 3260 | struct nes_cm_info cm_info; |
3265 | int apbvt_set = 0; | 3261 | int apbvt_set = 0; |
3262 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
3263 | struct sockaddr_in *raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
3266 | 3264 | ||
3265 | if (cm_id->remote_addr.ss_family != AF_INET) | ||
3266 | return -ENOSYS; | ||
3267 | ibqp = nes_get_qp(cm_id->device, conn_param->qpn); | 3267 | ibqp = nes_get_qp(cm_id->device, conn_param->qpn); |
3268 | if (!ibqp) | 3268 | if (!ibqp) |
3269 | return -EINVAL; | 3269 | return -EINVAL; |
@@ -3277,16 +3277,14 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3277 | if (!nesdev) | 3277 | if (!nesdev) |
3278 | return -EINVAL; | 3278 | return -EINVAL; |
3279 | 3279 | ||
3280 | if (!(cm_id->local_addr.sin_port) || !(cm_id->remote_addr.sin_port)) | 3280 | if (!laddr->sin_port || !raddr->sin_port) |
3281 | return -EINVAL; | 3281 | return -EINVAL; |
3282 | 3282 | ||
3283 | nes_debug(NES_DBG_CM, "QP%u, current IP = 0x%08X, Destination IP = " | 3283 | nes_debug(NES_DBG_CM, "QP%u, current IP = 0x%08X, Destination IP = " |
3284 | "0x%08X:0x%04X, local = 0x%08X:0x%04X.\n", nesqp->hwqp.qp_id, | 3284 | "0x%08X:0x%04X, local = 0x%08X:0x%04X.\n", nesqp->hwqp.qp_id, |
3285 | ntohl(nesvnic->local_ipaddr), | 3285 | ntohl(nesvnic->local_ipaddr), ntohl(raddr->sin_addr.s_addr), |
3286 | ntohl(cm_id->remote_addr.sin_addr.s_addr), | 3286 | ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr), |
3287 | ntohs(cm_id->remote_addr.sin_port), | 3287 | ntohs(laddr->sin_port)); |
3288 | ntohl(cm_id->local_addr.sin_addr.s_addr), | ||
3289 | ntohs(cm_id->local_addr.sin_port)); | ||
3290 | 3288 | ||
3291 | atomic_inc(&cm_connects); | 3289 | atomic_inc(&cm_connects); |
3292 | nesqp->active_conn = 1; | 3290 | nesqp->active_conn = 1; |
@@ -3306,18 +3304,18 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3306 | nes_debug(NES_DBG_CM, "mpa private data len =%u\n", | 3304 | nes_debug(NES_DBG_CM, "mpa private data len =%u\n", |
3307 | conn_param->private_data_len); | 3305 | conn_param->private_data_len); |
3308 | 3306 | ||
3309 | if (cm_id->local_addr.sin_addr.s_addr != | 3307 | if (laddr->sin_addr.s_addr != raddr->sin_addr.s_addr) { |
3310 | cm_id->remote_addr.sin_addr.s_addr) { | 3308 | nes_manage_apbvt(nesvnic, ntohs(laddr->sin_port), |
3311 | nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), | 3309 | PCI_FUNC(nesdev->pcidev->devfn), |
3312 | PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD); | 3310 | NES_MANAGE_APBVT_ADD); |
3313 | apbvt_set = 1; | 3311 | apbvt_set = 1; |
3314 | } | 3312 | } |
3315 | 3313 | ||
3316 | /* set up the connection params for the node */ | 3314 | /* set up the connection params for the node */ |
3317 | cm_info.loc_addr = htonl(cm_id->local_addr.sin_addr.s_addr); | 3315 | cm_info.loc_addr = htonl(laddr->sin_addr.s_addr); |
3318 | cm_info.loc_port = htons(cm_id->local_addr.sin_port); | 3316 | cm_info.loc_port = htons(laddr->sin_port); |
3319 | cm_info.rem_addr = htonl(cm_id->remote_addr.sin_addr.s_addr); | 3317 | cm_info.rem_addr = htonl(raddr->sin_addr.s_addr); |
3320 | cm_info.rem_port = htons(cm_id->remote_addr.sin_port); | 3318 | cm_info.rem_port = htons(raddr->sin_port); |
3321 | cm_info.cm_id = cm_id; | 3319 | cm_info.cm_id = cm_id; |
3322 | cm_info.conn_type = NES_CM_IWARP_CONN_TYPE; | 3320 | cm_info.conn_type = NES_CM_IWARP_CONN_TYPE; |
3323 | 3321 | ||
@@ -3329,7 +3327,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) | |||
3329 | &cm_info); | 3327 | &cm_info); |
3330 | if (!cm_node) { | 3328 | if (!cm_node) { |
3331 | if (apbvt_set) | 3329 | if (apbvt_set) |
3332 | nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), | 3330 | nes_manage_apbvt(nesvnic, ntohs(laddr->sin_port), |
3333 | PCI_FUNC(nesdev->pcidev->devfn), | 3331 | PCI_FUNC(nesdev->pcidev->devfn), |
3334 | NES_MANAGE_APBVT_DEL); | 3332 | NES_MANAGE_APBVT_DEL); |
3335 | 3333 | ||
@@ -3355,10 +3353,13 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog) | |||
3355 | struct nes_cm_listener *cm_node; | 3353 | struct nes_cm_listener *cm_node; |
3356 | struct nes_cm_info cm_info; | 3354 | struct nes_cm_info cm_info; |
3357 | int err; | 3355 | int err; |
3356 | struct sockaddr_in *laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
3358 | 3357 | ||
3359 | nes_debug(NES_DBG_CM, "cm_id = %p, local port = 0x%04X.\n", | 3358 | nes_debug(NES_DBG_CM, "cm_id = %p, local port = 0x%04X.\n", |
3360 | cm_id, ntohs(cm_id->local_addr.sin_port)); | 3359 | cm_id, ntohs(laddr->sin_port)); |
3361 | 3360 | ||
3361 | if (cm_id->local_addr.ss_family != AF_INET) | ||
3362 | return -ENOSYS; | ||
3362 | nesvnic = to_nesvnic(cm_id->device); | 3363 | nesvnic = to_nesvnic(cm_id->device); |
3363 | if (!nesvnic) | 3364 | if (!nesvnic) |
3364 | return -EINVAL; | 3365 | return -EINVAL; |
@@ -3367,11 +3368,11 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog) | |||
3367 | nesvnic, nesvnic->netdev, nesvnic->netdev->name); | 3368 | nesvnic, nesvnic->netdev, nesvnic->netdev->name); |
3368 | 3369 | ||
3369 | nes_debug(NES_DBG_CM, "nesvnic->local_ipaddr=0x%08x, sin_addr.s_addr=0x%08x\n", | 3370 | nes_debug(NES_DBG_CM, "nesvnic->local_ipaddr=0x%08x, sin_addr.s_addr=0x%08x\n", |
3370 | nesvnic->local_ipaddr, cm_id->local_addr.sin_addr.s_addr); | 3371 | nesvnic->local_ipaddr, laddr->sin_addr.s_addr); |
3371 | 3372 | ||
3372 | /* setup listen params in our api call struct */ | 3373 | /* setup listen params in our api call struct */ |
3373 | cm_info.loc_addr = nesvnic->local_ipaddr; | 3374 | cm_info.loc_addr = nesvnic->local_ipaddr; |
3374 | cm_info.loc_port = cm_id->local_addr.sin_port; | 3375 | cm_info.loc_port = laddr->sin_port; |
3375 | cm_info.backlog = backlog; | 3376 | cm_info.backlog = backlog; |
3376 | cm_info.cm_id = cm_id; | 3377 | cm_info.cm_id = cm_id; |
3377 | 3378 | ||
@@ -3388,8 +3389,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog) | |||
3388 | cm_id->provider_data = cm_node; | 3389 | cm_id->provider_data = cm_node; |
3389 | 3390 | ||
3390 | if (!cm_node->reused_node) { | 3391 | if (!cm_node->reused_node) { |
3391 | err = nes_manage_apbvt(nesvnic, | 3392 | err = nes_manage_apbvt(nesvnic, ntohs(laddr->sin_port), |
3392 | ntohs(cm_id->local_addr.sin_port), | ||
3393 | PCI_FUNC(nesvnic->nesdev->pcidev->devfn), | 3393 | PCI_FUNC(nesvnic->nesdev->pcidev->devfn), |
3394 | NES_MANAGE_APBVT_ADD); | 3394 | NES_MANAGE_APBVT_ADD); |
3395 | if (err) { | 3395 | if (err) { |
@@ -3487,6 +3487,9 @@ static void cm_event_connected(struct nes_cm_event *event) | |||
3487 | struct nes_v4_quad nes_quad; | 3487 | struct nes_v4_quad nes_quad; |
3488 | u32 crc_value; | 3488 | u32 crc_value; |
3489 | int ret; | 3489 | int ret; |
3490 | struct sockaddr_in *laddr; | ||
3491 | struct sockaddr_in *raddr; | ||
3492 | struct sockaddr_in *cm_event_laddr; | ||
3490 | 3493 | ||
3491 | /* get all our handles */ | 3494 | /* get all our handles */ |
3492 | cm_node = event->cm_node; | 3495 | cm_node = event->cm_node; |
@@ -3496,27 +3499,24 @@ static void cm_event_connected(struct nes_cm_event *event) | |||
3496 | nesvnic = to_nesvnic(nesqp->ibqp.device); | 3499 | nesvnic = to_nesvnic(nesqp->ibqp.device); |
3497 | nesdev = nesvnic->nesdev; | 3500 | nesdev = nesvnic->nesdev; |
3498 | nesadapter = nesdev->nesadapter; | 3501 | nesadapter = nesdev->nesadapter; |
3502 | laddr = (struct sockaddr_in *)&cm_id->local_addr; | ||
3503 | raddr = (struct sockaddr_in *)&cm_id->remote_addr; | ||
3504 | cm_event_laddr = (struct sockaddr_in *)&cm_event.local_addr; | ||
3499 | 3505 | ||
3500 | if (nesqp->destroyed) | 3506 | if (nesqp->destroyed) |
3501 | return; | 3507 | return; |
3502 | atomic_inc(&cm_connecteds); | 3508 | atomic_inc(&cm_connecteds); |
3503 | nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on" | 3509 | nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on" |
3504 | " local port 0x%04X. jiffies = %lu.\n", | 3510 | " local port 0x%04X. jiffies = %lu.\n", |
3505 | nesqp->hwqp.qp_id, | 3511 | nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr), |
3506 | ntohl(cm_id->remote_addr.sin_addr.s_addr), | 3512 | ntohs(raddr->sin_port), ntohs(laddr->sin_port), jiffies); |
3507 | ntohs(cm_id->remote_addr.sin_port), | ||
3508 | ntohs(cm_id->local_addr.sin_port), | ||
3509 | jiffies); | ||
3510 | 3513 | ||
3511 | nes_cm_init_tsa_conn(nesqp, cm_node); | 3514 | nes_cm_init_tsa_conn(nesqp, cm_node); |
3512 | 3515 | ||
3513 | /* set the QP tsa context */ | 3516 | /* set the QP tsa context */ |
3514 | nesqp->nesqp_context->tcpPorts[0] = | 3517 | nesqp->nesqp_context->tcpPorts[0] = cpu_to_le16(ntohs(laddr->sin_port)); |
3515 | cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); | 3518 | nesqp->nesqp_context->tcpPorts[1] = cpu_to_le16(ntohs(raddr->sin_port)); |
3516 | nesqp->nesqp_context->tcpPorts[1] = | 3519 | nesqp->nesqp_context->ip0 = cpu_to_le32(ntohl(raddr->sin_addr.s_addr)); |
3517 | cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); | ||
3518 | nesqp->nesqp_context->ip0 = | ||
3519 | cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); | ||
3520 | 3520 | ||
3521 | nesqp->nesqp_context->misc2 |= cpu_to_le32( | 3521 | nesqp->nesqp_context->misc2 |= cpu_to_le32( |
3522 | (u32)PCI_FUNC(nesdev->pcidev->devfn) << | 3522 | (u32)PCI_FUNC(nesdev->pcidev->devfn) << |
@@ -3544,9 +3544,9 @@ static void cm_event_connected(struct nes_cm_event *event) | |||
3544 | 3544 | ||
3545 | nes_quad.DstIpAdrIndex = | 3545 | nes_quad.DstIpAdrIndex = |
3546 | cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); | 3546 | cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); |
3547 | nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; | 3547 | nes_quad.SrcIpadr = raddr->sin_addr.s_addr; |
3548 | nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; | 3548 | nes_quad.TcpPorts[0] = raddr->sin_port; |
3549 | nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; | 3549 | nes_quad.TcpPorts[1] = laddr->sin_port; |
3550 | 3550 | ||
3551 | /* Produce hash key */ | 3551 | /* Produce hash key */ |
3552 | crc_value = get_crc_value(&nes_quad); | 3552 | crc_value = get_crc_value(&nes_quad); |
@@ -3565,8 +3565,8 @@ static void cm_event_connected(struct nes_cm_event *event) | |||
3565 | cm_event.event = IW_CM_EVENT_CONNECT_REPLY; | 3565 | cm_event.event = IW_CM_EVENT_CONNECT_REPLY; |
3566 | cm_event.status = 0; | 3566 | cm_event.status = 0; |
3567 | cm_event.provider_data = cm_id->provider_data; | 3567 | cm_event.provider_data = cm_id->provider_data; |
3568 | cm_event.local_addr.sin_family = AF_INET; | 3568 | cm_event_laddr->sin_family = AF_INET; |
3569 | cm_event.local_addr.sin_port = cm_id->local_addr.sin_port; | 3569 | cm_event_laddr->sin_port = laddr->sin_port; |
3570 | cm_event.remote_addr = cm_id->remote_addr; | 3570 | cm_event.remote_addr = cm_id->remote_addr; |
3571 | 3571 | ||
3572 | cm_event.private_data = (void *)event->cm_node->mpa_frame_buf; | 3572 | cm_event.private_data = (void *)event->cm_node->mpa_frame_buf; |
@@ -3574,7 +3574,7 @@ static void cm_event_connected(struct nes_cm_event *event) | |||
3574 | cm_event.ird = cm_node->ird_size; | 3574 | cm_event.ird = cm_node->ird_size; |
3575 | cm_event.ord = cm_node->ord_size; | 3575 | cm_event.ord = cm_node->ord_size; |
3576 | 3576 | ||
3577 | cm_event.local_addr.sin_addr.s_addr = event->cm_info.rem_addr; | 3577 | cm_event_laddr->sin_addr.s_addr = event->cm_info.rem_addr; |
3578 | ret = cm_id->event_handler(cm_id, &cm_event); | 3578 | ret = cm_id->event_handler(cm_id, &cm_event); |
3579 | nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); | 3579 | nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); |
3580 | 3580 | ||
@@ -3627,9 +3627,16 @@ static void cm_event_connect_error(struct nes_cm_event *event) | |||
3627 | cm_event.private_data = NULL; | 3627 | cm_event.private_data = NULL; |
3628 | cm_event.private_data_len = 0; | 3628 | cm_event.private_data_len = 0; |
3629 | 3629 | ||
3630 | nes_debug(NES_DBG_CM, "call CM_EVENT REJECTED, local_addr=%08x, " | 3630 | #ifdef CONFIG_INFINIBAND_NES_DEBUG |
3631 | "remove_addr=%08x\n", cm_event.local_addr.sin_addr.s_addr, | 3631 | { |
3632 | cm_event.remote_addr.sin_addr.s_addr); | 3632 | struct sockaddr_in *cm_event_laddr = (struct sockaddr_in *) |
3633 | &cm_event.local_addr; | ||
3634 | struct sockaddr_in *cm_event_raddr = (struct sockaddr_in *) | ||
3635 | &cm_event.remote_addr; | ||
3636 | nes_debug(NES_DBG_CM, "call CM_EVENT REJECTED, local_addr=%08x, remote_addr=%08x\n", | ||
3637 | cm_event_laddr->sin_addr.s_addr, cm_event_raddr->sin_addr.s_addr); | ||
3638 | } | ||
3639 | #endif | ||
3633 | 3640 | ||
3634 | ret = cm_id->event_handler(cm_id, &cm_event); | 3641 | ret = cm_id->event_handler(cm_id, &cm_event); |
3635 | nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); | 3642 | nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); |
@@ -3709,6 +3716,10 @@ static void cm_event_mpa_req(struct nes_cm_event *event) | |||
3709 | struct iw_cm_event cm_event; | 3716 | struct iw_cm_event cm_event; |
3710 | int ret; | 3717 | int ret; |
3711 | struct nes_cm_node *cm_node; | 3718 | struct nes_cm_node *cm_node; |
3719 | struct sockaddr_in *cm_event_laddr = (struct sockaddr_in *) | ||
3720 | &cm_event.local_addr; | ||
3721 | struct sockaddr_in *cm_event_raddr = (struct sockaddr_in *) | ||
3722 | &cm_event.remote_addr; | ||
3712 | 3723 | ||
3713 | cm_node = event->cm_node; | 3724 | cm_node = event->cm_node; |
3714 | if (!cm_node) | 3725 | if (!cm_node) |
@@ -3723,13 +3734,13 @@ static void cm_event_mpa_req(struct nes_cm_event *event) | |||
3723 | cm_event.status = 0; | 3734 | cm_event.status = 0; |
3724 | cm_event.provider_data = (void *)cm_node; | 3735 | cm_event.provider_data = (void *)cm_node; |
3725 | 3736 | ||
3726 | cm_event.local_addr.sin_family = AF_INET; | 3737 | cm_event_laddr->sin_family = AF_INET; |
3727 | cm_event.local_addr.sin_port = htons(event->cm_info.loc_port); | 3738 | cm_event_laddr->sin_port = htons(event->cm_info.loc_port); |
3728 | cm_event.local_addr.sin_addr.s_addr = htonl(event->cm_info.loc_addr); | 3739 | cm_event_laddr->sin_addr.s_addr = htonl(event->cm_info.loc_addr); |
3729 | 3740 | ||
3730 | cm_event.remote_addr.sin_family = AF_INET; | 3741 | cm_event_raddr->sin_family = AF_INET; |
3731 | cm_event.remote_addr.sin_port = htons(event->cm_info.rem_port); | 3742 | cm_event_raddr->sin_port = htons(event->cm_info.rem_port); |
3732 | cm_event.remote_addr.sin_addr.s_addr = htonl(event->cm_info.rem_addr); | 3743 | cm_event_raddr->sin_addr.s_addr = htonl(event->cm_info.rem_addr); |
3733 | cm_event.private_data = cm_node->mpa_frame_buf; | 3744 | cm_event.private_data = cm_node->mpa_frame_buf; |
3734 | cm_event.private_data_len = (u8)cm_node->mpa_frame_size; | 3745 | cm_event.private_data_len = (u8)cm_node->mpa_frame_size; |
3735 | cm_event.ird = cm_node->ird_size; | 3746 | cm_event.ird = cm_node->ird_size; |
@@ -3749,6 +3760,10 @@ static void cm_event_mpa_reject(struct nes_cm_event *event) | |||
3749 | struct iw_cm_event cm_event; | 3760 | struct iw_cm_event cm_event; |
3750 | struct nes_cm_node *cm_node; | 3761 | struct nes_cm_node *cm_node; |
3751 | int ret; | 3762 | int ret; |
3763 | struct sockaddr_in *cm_event_laddr = (struct sockaddr_in *) | ||
3764 | &cm_event.local_addr; | ||
3765 | struct sockaddr_in *cm_event_raddr = (struct sockaddr_in *) | ||
3766 | &cm_event.remote_addr; | ||
3752 | 3767 | ||
3753 | cm_node = event->cm_node; | 3768 | cm_node = event->cm_node; |
3754 | if (!cm_node) | 3769 | if (!cm_node) |
@@ -3763,21 +3778,21 @@ static void cm_event_mpa_reject(struct nes_cm_event *event) | |||
3763 | cm_event.status = -ECONNREFUSED; | 3778 | cm_event.status = -ECONNREFUSED; |
3764 | cm_event.provider_data = cm_id->provider_data; | 3779 | cm_event.provider_data = cm_id->provider_data; |
3765 | 3780 | ||
3766 | cm_event.local_addr.sin_family = AF_INET; | 3781 | cm_event_laddr->sin_family = AF_INET; |
3767 | cm_event.local_addr.sin_port = htons(event->cm_info.loc_port); | 3782 | cm_event_laddr->sin_port = htons(event->cm_info.loc_port); |
3768 | cm_event.local_addr.sin_addr.s_addr = htonl(event->cm_info.loc_addr); | 3783 | cm_event_laddr->sin_addr.s_addr = htonl(event->cm_info.loc_addr); |
3769 | 3784 | ||
3770 | cm_event.remote_addr.sin_family = AF_INET; | 3785 | cm_event_raddr->sin_family = AF_INET; |
3771 | cm_event.remote_addr.sin_port = htons(event->cm_info.rem_port); | 3786 | cm_event_raddr->sin_port = htons(event->cm_info.rem_port); |
3772 | cm_event.remote_addr.sin_addr.s_addr = htonl(event->cm_info.rem_addr); | 3787 | cm_event_raddr->sin_addr.s_addr = htonl(event->cm_info.rem_addr); |
3773 | 3788 | ||
3774 | cm_event.private_data = cm_node->mpa_frame_buf; | 3789 | cm_event.private_data = cm_node->mpa_frame_buf; |
3775 | cm_event.private_data_len = (u8)cm_node->mpa_frame_size; | 3790 | cm_event.private_data_len = (u8)cm_node->mpa_frame_size; |
3776 | 3791 | ||
3777 | nes_debug(NES_DBG_CM, "call CM_EVENT_MPA_REJECTED, local_addr=%08x, " | 3792 | nes_debug(NES_DBG_CM, "call CM_EVENT_MPA_REJECTED, local_addr=%08x, " |
3778 | "remove_addr=%08x\n", | 3793 | "remove_addr=%08x\n", |
3779 | cm_event.local_addr.sin_addr.s_addr, | 3794 | cm_event_laddr->sin_addr.s_addr, |
3780 | cm_event.remote_addr.sin_addr.s_addr); | 3795 | cm_event_raddr->sin_addr.s_addr); |
3781 | 3796 | ||
3782 | ret = cm_id->event_handler(cm_id, &cm_event); | 3797 | ret = cm_id->event_handler(cm_id, &cm_event); |
3783 | if (ret) | 3798 | if (ret) |