aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/core/cma.c176
1 files changed, 31 insertions, 145 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index f1dd0ca34d83..daec9319502d 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -80,7 +80,6 @@ static LIST_HEAD(dev_list);
80static LIST_HEAD(listen_any_list); 80static LIST_HEAD(listen_any_list);
81static DEFINE_MUTEX(lock); 81static DEFINE_MUTEX(lock);
82static struct workqueue_struct *cma_wq; 82static struct workqueue_struct *cma_wq;
83static DEFINE_IDR(sdp_ps);
84static DEFINE_IDR(tcp_ps); 83static DEFINE_IDR(tcp_ps);
85static DEFINE_IDR(udp_ps); 84static DEFINE_IDR(udp_ps);
86static DEFINE_IDR(ipoib_ps); 85static DEFINE_IDR(ipoib_ps);
@@ -196,24 +195,7 @@ struct cma_hdr {
196 union cma_ip_addr dst_addr; 195 union cma_ip_addr dst_addr;
197}; 196};
198 197
199struct sdp_hh {
200 u8 bsdh[16];
201 u8 sdp_version; /* Major version: 7:4 */
202 u8 ip_version; /* IP version: 7:4 */
203 u8 sdp_specific1[10];
204 __be16 port;
205 __be16 sdp_specific2;
206 union cma_ip_addr src_addr;
207 union cma_ip_addr dst_addr;
208};
209
210struct sdp_hah {
211 u8 bsdh[16];
212 u8 sdp_version;
213};
214
215#define CMA_VERSION 0x00 198#define CMA_VERSION 0x00
216#define SDP_MAJ_VERSION 0x2
217 199
218static int cma_comp(struct rdma_id_private *id_priv, enum rdma_cm_state comp) 200static int cma_comp(struct rdma_id_private *id_priv, enum rdma_cm_state comp)
219{ 201{
@@ -262,21 +244,6 @@ static inline void cma_set_ip_ver(struct cma_hdr *hdr, u8 ip_ver)
262 hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF); 244 hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF);
263} 245}
264 246
265static inline u8 sdp_get_majv(u8 sdp_version)
266{
267 return sdp_version >> 4;
268}
269
270static inline u8 sdp_get_ip_ver(struct sdp_hh *hh)
271{
272 return hh->ip_version >> 4;
273}
274
275static inline void sdp_set_ip_ver(struct sdp_hh *hh, u8 ip_ver)
276{
277 hh->ip_version = (ip_ver << 4) | (hh->ip_version & 0xF);
278}
279
280static void cma_attach_to_dev(struct rdma_id_private *id_priv, 247static void cma_attach_to_dev(struct rdma_id_private *id_priv,
281 struct cma_device *cma_dev) 248 struct cma_device *cma_dev)
282{ 249{
@@ -847,27 +814,13 @@ static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
847 u8 *ip_ver, __be16 *port, 814 u8 *ip_ver, __be16 *port,
848 union cma_ip_addr **src, union cma_ip_addr **dst) 815 union cma_ip_addr **src, union cma_ip_addr **dst)
849{ 816{
850 switch (ps) { 817 if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION)
851 case RDMA_PS_SDP: 818 return -EINVAL;
852 if (sdp_get_majv(((struct sdp_hh *) hdr)->sdp_version) !=
853 SDP_MAJ_VERSION)
854 return -EINVAL;
855
856 *ip_ver = sdp_get_ip_ver(hdr);
857 *port = ((struct sdp_hh *) hdr)->port;
858 *src = &((struct sdp_hh *) hdr)->src_addr;
859 *dst = &((struct sdp_hh *) hdr)->dst_addr;
860 break;
861 default:
862 if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION)
863 return -EINVAL;
864 819
865 *ip_ver = cma_get_ip_ver(hdr); 820 *ip_ver = cma_get_ip_ver(hdr);
866 *port = ((struct cma_hdr *) hdr)->port; 821 *port = ((struct cma_hdr *) hdr)->port;
867 *src = &((struct cma_hdr *) hdr)->src_addr; 822 *src = &((struct cma_hdr *) hdr)->src_addr;
868 *dst = &((struct cma_hdr *) hdr)->dst_addr; 823 *dst = &((struct cma_hdr *) hdr)->dst_addr;
869 break;
870 }
871 824
872 if (*ip_ver != 4 && *ip_ver != 6) 825 if (*ip_ver != 4 && *ip_ver != 6)
873 return -EINVAL; 826 return -EINVAL;
@@ -914,12 +867,7 @@ static void cma_save_net_info(struct rdma_addr *addr,
914 867
915static inline int cma_user_data_offset(enum rdma_port_space ps) 868static inline int cma_user_data_offset(enum rdma_port_space ps)
916{ 869{
917 switch (ps) { 870 return sizeof(struct cma_hdr);
918 case RDMA_PS_SDP:
919 return 0;
920 default:
921 return sizeof(struct cma_hdr);
922 }
923} 871}
924 872
925static void cma_cancel_route(struct rdma_id_private *id_priv) 873static void cma_cancel_route(struct rdma_id_private *id_priv)
@@ -1085,16 +1033,6 @@ reject:
1085 return ret; 1033 return ret;
1086} 1034}
1087 1035
1088static int cma_verify_rep(struct rdma_id_private *id_priv, void *data)
1089{
1090 if (id_priv->id.ps == RDMA_PS_SDP &&
1091 sdp_get_majv(((struct sdp_hah *) data)->sdp_version) !=
1092 SDP_MAJ_VERSION)
1093 return -EINVAL;
1094
1095 return 0;
1096}
1097
1098static void cma_set_rep_event_data(struct rdma_cm_event *event, 1036static void cma_set_rep_event_data(struct rdma_cm_event *event,
1099 struct ib_cm_rep_event_param *rep_data, 1037 struct ib_cm_rep_event_param *rep_data,
1100 void *private_data) 1038 void *private_data)
@@ -1129,15 +1067,13 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1129 event.status = -ETIMEDOUT; 1067 event.status = -ETIMEDOUT;
1130 break; 1068 break;
1131 case IB_CM_REP_RECEIVED: 1069 case IB_CM_REP_RECEIVED:
1132 event.status = cma_verify_rep(id_priv, ib_event->private_data); 1070 if (id_priv->id.qp) {
1133 if (event.status)
1134 event.event = RDMA_CM_EVENT_CONNECT_ERROR;
1135 else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) {
1136 event.status = cma_rep_recv(id_priv); 1071 event.status = cma_rep_recv(id_priv);
1137 event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR : 1072 event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
1138 RDMA_CM_EVENT_ESTABLISHED; 1073 RDMA_CM_EVENT_ESTABLISHED;
1139 } else 1074 } else {
1140 event.event = RDMA_CM_EVENT_CONNECT_RESPONSE; 1075 event.event = RDMA_CM_EVENT_CONNECT_RESPONSE;
1076 }
1141 cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd, 1077 cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd,
1142 ib_event->private_data); 1078 ib_event->private_data);
1143 break; 1079 break;
@@ -1389,49 +1325,31 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
1389 struct ib_cm_compare_data *compare) 1325 struct ib_cm_compare_data *compare)
1390{ 1326{
1391 struct cma_hdr *cma_data, *cma_mask; 1327 struct cma_hdr *cma_data, *cma_mask;
1392 struct sdp_hh *sdp_data, *sdp_mask;
1393 __be32 ip4_addr; 1328 __be32 ip4_addr;
1394 struct in6_addr ip6_addr; 1329 struct in6_addr ip6_addr;
1395 1330
1396 memset(compare, 0, sizeof *compare); 1331 memset(compare, 0, sizeof *compare);
1397 cma_data = (void *) compare->data; 1332 cma_data = (void *) compare->data;
1398 cma_mask = (void *) compare->mask; 1333 cma_mask = (void *) compare->mask;
1399 sdp_data = (void *) compare->data;
1400 sdp_mask = (void *) compare->mask;
1401 1334
1402 switch (addr->sa_family) { 1335 switch (addr->sa_family) {
1403 case AF_INET: 1336 case AF_INET:
1404 ip4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr; 1337 ip4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
1405 if (ps == RDMA_PS_SDP) { 1338 cma_set_ip_ver(cma_data, 4);
1406 sdp_set_ip_ver(sdp_data, 4); 1339 cma_set_ip_ver(cma_mask, 0xF);
1407 sdp_set_ip_ver(sdp_mask, 0xF); 1340 if (!cma_any_addr(addr)) {
1408 sdp_data->dst_addr.ip4.addr = ip4_addr; 1341 cma_data->dst_addr.ip4.addr = ip4_addr;
1409 sdp_mask->dst_addr.ip4.addr = htonl(~0); 1342 cma_mask->dst_addr.ip4.addr = htonl(~0);
1410 } else {
1411 cma_set_ip_ver(cma_data, 4);
1412 cma_set_ip_ver(cma_mask, 0xF);
1413 if (!cma_any_addr(addr)) {
1414 cma_data->dst_addr.ip4.addr = ip4_addr;
1415 cma_mask->dst_addr.ip4.addr = htonl(~0);
1416 }
1417 } 1343 }
1418 break; 1344 break;
1419 case AF_INET6: 1345 case AF_INET6:
1420 ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr; 1346 ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr;
1421 if (ps == RDMA_PS_SDP) { 1347 cma_set_ip_ver(cma_data, 6);
1422 sdp_set_ip_ver(sdp_data, 6); 1348 cma_set_ip_ver(cma_mask, 0xF);
1423 sdp_set_ip_ver(sdp_mask, 0xF); 1349 if (!cma_any_addr(addr)) {
1424 sdp_data->dst_addr.ip6 = ip6_addr; 1350 cma_data->dst_addr.ip6 = ip6_addr;
1425 memset(&sdp_mask->dst_addr.ip6, 0xFF, 1351 memset(&cma_mask->dst_addr.ip6, 0xFF,
1426 sizeof sdp_mask->dst_addr.ip6); 1352 sizeof cma_mask->dst_addr.ip6);
1427 } else {
1428 cma_set_ip_ver(cma_data, 6);
1429 cma_set_ip_ver(cma_mask, 0xF);
1430 if (!cma_any_addr(addr)) {
1431 cma_data->dst_addr.ip6 = ip6_addr;
1432 memset(&cma_mask->dst_addr.ip6, 0xFF,
1433 sizeof cma_mask->dst_addr.ip6);
1434 }
1435 } 1353 }
1436 break; 1354 break;
1437 default: 1355 default:
@@ -2452,8 +2370,6 @@ static int cma_bind_listen(struct rdma_id_private *id_priv)
2452static struct idr *cma_select_inet_ps(struct rdma_id_private *id_priv) 2370static struct idr *cma_select_inet_ps(struct rdma_id_private *id_priv)
2453{ 2371{
2454 switch (id_priv->id.ps) { 2372 switch (id_priv->id.ps) {
2455 case RDMA_PS_SDP:
2456 return &sdp_ps;
2457 case RDMA_PS_TCP: 2373 case RDMA_PS_TCP:
2458 return &tcp_ps; 2374 return &tcp_ps;
2459 case RDMA_PS_UDP: 2375 case RDMA_PS_UDP:
@@ -2642,58 +2558,29 @@ EXPORT_SYMBOL(rdma_bind_addr);
2642static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) 2558static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv)
2643{ 2559{
2644 struct cma_hdr *cma_hdr; 2560 struct cma_hdr *cma_hdr;
2645 struct sdp_hh *sdp_hdr;
2646 2561
2562 cma_hdr = hdr;
2563 cma_hdr->cma_version = CMA_VERSION;
2647 if (cma_family(id_priv) == AF_INET) { 2564 if (cma_family(id_priv) == AF_INET) {
2648 struct sockaddr_in *src4, *dst4; 2565 struct sockaddr_in *src4, *dst4;
2649 2566
2650 src4 = (struct sockaddr_in *) cma_src_addr(id_priv); 2567 src4 = (struct sockaddr_in *) cma_src_addr(id_priv);
2651 dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv); 2568 dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);
2652 2569
2653 switch (id_priv->id.ps) { 2570 cma_set_ip_ver(cma_hdr, 4);
2654 case RDMA_PS_SDP: 2571 cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
2655 sdp_hdr = hdr; 2572 cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
2656 if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) 2573 cma_hdr->port = src4->sin_port;
2657 return -EINVAL;
2658 sdp_set_ip_ver(sdp_hdr, 4);
2659 sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
2660 sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
2661 sdp_hdr->port = src4->sin_port;
2662 break;
2663 default:
2664 cma_hdr = hdr;
2665 cma_hdr->cma_version = CMA_VERSION;
2666 cma_set_ip_ver(cma_hdr, 4);
2667 cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
2668 cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
2669 cma_hdr->port = src4->sin_port;
2670 break;
2671 }
2672 } else { 2574 } else {
2673 struct sockaddr_in6 *src6, *dst6; 2575 struct sockaddr_in6 *src6, *dst6;
2674 2576
2675 src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); 2577 src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
2676 dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv); 2578 dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);
2677 2579
2678 switch (id_priv->id.ps) { 2580 cma_set_ip_ver(cma_hdr, 6);
2679 case RDMA_PS_SDP: 2581 cma_hdr->src_addr.ip6 = src6->sin6_addr;
2680 sdp_hdr = hdr; 2582 cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
2681 if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION) 2583 cma_hdr->port = src6->sin6_port;
2682 return -EINVAL;
2683 sdp_set_ip_ver(sdp_hdr, 6);
2684 sdp_hdr->src_addr.ip6 = src6->sin6_addr;
2685 sdp_hdr->dst_addr.ip6 = dst6->sin6_addr;
2686 sdp_hdr->port = src6->sin6_port;
2687 break;
2688 default:
2689 cma_hdr = hdr;
2690 cma_hdr->cma_version = CMA_VERSION;
2691 cma_set_ip_ver(cma_hdr, 6);
2692 cma_hdr->src_addr.ip6 = src6->sin6_addr;
2693 cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
2694 cma_hdr->port = src6->sin6_port;
2695 break;
2696 }
2697 } 2584 }
2698 return 0; 2585 return 0;
2699} 2586}
@@ -3747,7 +3634,6 @@ static void __exit cma_cleanup(void)
3747 rdma_addr_unregister_client(&addr_client); 3634 rdma_addr_unregister_client(&addr_client);
3748 ib_sa_unregister_client(&sa_client); 3635 ib_sa_unregister_client(&sa_client);
3749 destroy_workqueue(cma_wq); 3636 destroy_workqueue(cma_wq);
3750 idr_destroy(&sdp_ps);
3751 idr_destroy(&tcp_ps); 3637 idr_destroy(&tcp_ps);
3752 idr_destroy(&udp_ps); 3638 idr_destroy(&udp_ps);
3753 idr_destroy(&ipoib_ps); 3639 idr_destroy(&ipoib_ps);