diff options
-rw-r--r-- | drivers/infiniband/core/cma.c | 77 | ||||
-rw-r--r-- | drivers/infiniband/core/ucma.c | 8 | ||||
-rw-r--r-- | include/rdma/ib_addr.h | 31 | ||||
-rw-r--r-- | net/rds/ib.c | 4 | ||||
-rw-r--r-- | net/rds/iw.c | 4 |
5 files changed, 61 insertions, 63 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index b305b5c17f8d..38867a46d39e 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -330,17 +330,7 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv) | |||
330 | union ib_gid gid; | 330 | union ib_gid gid; |
331 | int ret = -ENODEV; | 331 | int ret = -ENODEV; |
332 | 332 | ||
333 | switch (dev_addr->dev_type) { | 333 | rdma_addr_get_sgid(dev_addr, &gid); |
334 | case ARPHRD_INFINIBAND: | ||
335 | ib_addr_get_sgid(dev_addr, &gid); | ||
336 | break; | ||
337 | case ARPHRD_ETHER: | ||
338 | iw_addr_get_sgid(dev_addr, &gid); | ||
339 | break; | ||
340 | default: | ||
341 | return -ENODEV; | ||
342 | } | ||
343 | |||
344 | list_for_each_entry(cma_dev, &dev_list, list) { | 334 | list_for_each_entry(cma_dev, &dev_list, list) { |
345 | ret = ib_find_cached_gid(cma_dev->device, &gid, | 335 | ret = ib_find_cached_gid(cma_dev->device, &gid, |
346 | &id_priv->id.port_num, NULL); | 336 | &id_priv->id.port_num, NULL); |
@@ -1032,11 +1022,17 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, | |||
1032 | if (rt->num_paths == 2) | 1022 | if (rt->num_paths == 2) |
1033 | rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path; | 1023 | rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path; |
1034 | 1024 | ||
1035 | ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); | 1025 | if (cma_any_addr((struct sockaddr *) &rt->addr.src_addr)) { |
1036 | ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr, | 1026 | rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND; |
1037 | &id->route.addr.dev_addr); | 1027 | rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid); |
1038 | if (ret) | 1028 | ib_addr_set_pkey(&rt->addr.dev_addr, rt->path_rec[0].pkey); |
1039 | goto destroy_id; | 1029 | } else { |
1030 | ret = rdma_translate_ip((struct sockaddr *) &rt->addr.src_addr, | ||
1031 | &rt->addr.dev_addr); | ||
1032 | if (ret) | ||
1033 | goto destroy_id; | ||
1034 | } | ||
1035 | rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); | ||
1040 | 1036 | ||
1041 | id_priv = container_of(id, struct rdma_id_private, id); | 1037 | id_priv = container_of(id, struct rdma_id_private, id); |
1042 | id_priv->state = CMA_CONNECT; | 1038 | id_priv->state = CMA_CONNECT; |
@@ -1071,10 +1067,12 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id, | |||
1071 | cma_save_net_info(&id->route.addr, &listen_id->route.addr, | 1067 | cma_save_net_info(&id->route.addr, &listen_id->route.addr, |
1072 | ip_ver, port, src, dst); | 1068 | ip_ver, port, src, dst); |
1073 | 1069 | ||
1074 | ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr, | 1070 | if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) { |
1075 | &id->route.addr.dev_addr); | 1071 | ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr, |
1076 | if (ret) | 1072 | &id->route.addr.dev_addr); |
1077 | goto err; | 1073 | if (ret) |
1074 | goto err; | ||
1075 | } | ||
1078 | 1076 | ||
1079 | id_priv = container_of(id, struct rdma_id_private, id); | 1077 | id_priv = container_of(id, struct rdma_id_private, id); |
1080 | id_priv->state = CMA_CONNECT; | 1078 | id_priv->state = CMA_CONNECT; |
@@ -1565,8 +1563,8 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, | |||
1565 | struct sockaddr_in6 *sin6; | 1563 | struct sockaddr_in6 *sin6; |
1566 | 1564 | ||
1567 | memset(&path_rec, 0, sizeof path_rec); | 1565 | memset(&path_rec, 0, sizeof path_rec); |
1568 | ib_addr_get_sgid(&addr->dev_addr, &path_rec.sgid); | 1566 | rdma_addr_get_sgid(&addr->dev_addr, &path_rec.sgid); |
1569 | ib_addr_get_dgid(&addr->dev_addr, &path_rec.dgid); | 1567 | rdma_addr_get_dgid(&addr->dev_addr, &path_rec.dgid); |
1570 | path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr)); | 1568 | path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr)); |
1571 | path_rec.numb_path = 1; | 1569 | path_rec.numb_path = 1; |
1572 | path_rec.reversible = 1; | 1570 | path_rec.reversible = 1; |
@@ -1781,7 +1779,11 @@ port_found: | |||
1781 | if (ret) | 1779 | if (ret) |
1782 | goto out; | 1780 | goto out; |
1783 | 1781 | ||
1784 | ib_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid); | 1782 | id_priv->id.route.addr.dev_addr.dev_type = |
1783 | (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB) ? | ||
1784 | ARPHRD_INFINIBAND : ARPHRD_ETHER; | ||
1785 | |||
1786 | rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid); | ||
1785 | ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); | 1787 | ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); |
1786 | id_priv->id.port_num = p; | 1788 | id_priv->id.port_num = p; |
1787 | cma_attach_to_dev(id_priv, cma_dev); | 1789 | cma_attach_to_dev(id_priv, cma_dev); |
@@ -1839,7 +1841,7 @@ out: | |||
1839 | static int cma_resolve_loopback(struct rdma_id_private *id_priv) | 1841 | static int cma_resolve_loopback(struct rdma_id_private *id_priv) |
1840 | { | 1842 | { |
1841 | struct cma_work *work; | 1843 | struct cma_work *work; |
1842 | struct sockaddr_in *src_in, *dst_in; | 1844 | struct sockaddr *src, *dst; |
1843 | union ib_gid gid; | 1845 | union ib_gid gid; |
1844 | int ret; | 1846 | int ret; |
1845 | 1847 | ||
@@ -1853,14 +1855,19 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv) | |||
1853 | goto err; | 1855 | goto err; |
1854 | } | 1856 | } |
1855 | 1857 | ||
1856 | ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid); | 1858 | rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid); |
1857 | ib_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid); | 1859 | rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid); |
1858 | 1860 | ||
1859 | if (cma_zero_addr((struct sockaddr *) &id_priv->id.route.addr.src_addr)) { | 1861 | src = (struct sockaddr *) &id_priv->id.route.addr.src_addr; |
1860 | src_in = (struct sockaddr_in *)&id_priv->id.route.addr.src_addr; | 1862 | if (cma_zero_addr(src)) { |
1861 | dst_in = (struct sockaddr_in *)&id_priv->id.route.addr.dst_addr; | 1863 | dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr; |
1862 | src_in->sin_family = dst_in->sin_family; | 1864 | if ((src->sa_family = dst->sa_family) == AF_INET) { |
1863 | src_in->sin_addr.s_addr = dst_in->sin_addr.s_addr; | 1865 | ((struct sockaddr_in *) src)->sin_addr.s_addr = |
1866 | ((struct sockaddr_in *) dst)->sin_addr.s_addr; | ||
1867 | } else { | ||
1868 | ipv6_addr_copy(&((struct sockaddr_in6 *) src)->sin6_addr, | ||
1869 | &((struct sockaddr_in6 *) dst)->sin6_addr); | ||
1870 | } | ||
1864 | } | 1871 | } |
1865 | 1872 | ||
1866 | work->id = id_priv; | 1873 | work->id = id_priv; |
@@ -2089,7 +2096,9 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) | |||
2089 | if (!cma_comp_exch(id_priv, CMA_IDLE, CMA_ADDR_BOUND)) | 2096 | if (!cma_comp_exch(id_priv, CMA_IDLE, CMA_ADDR_BOUND)) |
2090 | return -EINVAL; | 2097 | return -EINVAL; |
2091 | 2098 | ||
2092 | if (!cma_any_addr(addr)) { | 2099 | if (cma_loopback_addr(addr)) { |
2100 | ret = cma_bind_loopback(id_priv); | ||
2101 | } else if (!cma_zero_addr(addr)) { | ||
2093 | ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); | 2102 | ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); |
2094 | if (ret) | 2103 | if (ret) |
2095 | goto err1; | 2104 | goto err1; |
@@ -2108,7 +2117,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) | |||
2108 | 2117 | ||
2109 | return 0; | 2118 | return 0; |
2110 | err2: | 2119 | err2: |
2111 | if (!cma_any_addr(addr)) { | 2120 | if (id_priv->cma_dev) { |
2112 | mutex_lock(&lock); | 2121 | mutex_lock(&lock); |
2113 | cma_detach_from_dev(id_priv); | 2122 | cma_detach_from_dev(id_priv); |
2114 | mutex_unlock(&lock); | 2123 | mutex_unlock(&lock); |
@@ -2721,7 +2730,7 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv, | |||
2721 | cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid); | 2730 | cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid); |
2722 | if (id_priv->id.ps == RDMA_PS_UDP) | 2731 | if (id_priv->id.ps == RDMA_PS_UDP) |
2723 | rec.qkey = cpu_to_be32(RDMA_UDP_QKEY); | 2732 | rec.qkey = cpu_to_be32(RDMA_UDP_QKEY); |
2724 | ib_addr_get_sgid(dev_addr, &rec.port_gid); | 2733 | rdma_addr_get_sgid(dev_addr, &rec.port_gid); |
2725 | rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); | 2734 | rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); |
2726 | rec.join_state = 1; | 2735 | rec.join_state = 1; |
2727 | 2736 | ||
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index f1cbd26a9de0..b2e16c332d5b 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
@@ -563,10 +563,10 @@ static void ucma_copy_ib_route(struct rdma_ucm_query_route_resp *resp, | |||
563 | switch (route->num_paths) { | 563 | switch (route->num_paths) { |
564 | case 0: | 564 | case 0: |
565 | dev_addr = &route->addr.dev_addr; | 565 | dev_addr = &route->addr.dev_addr; |
566 | ib_addr_get_dgid(dev_addr, | 566 | rdma_addr_get_dgid(dev_addr, |
567 | (union ib_gid *) &resp->ib_route[0].dgid); | 567 | (union ib_gid *) &resp->ib_route[0].dgid); |
568 | ib_addr_get_sgid(dev_addr, | 568 | rdma_addr_get_sgid(dev_addr, |
569 | (union ib_gid *) &resp->ib_route[0].sgid); | 569 | (union ib_gid *) &resp->ib_route[0].sgid); |
570 | resp->ib_route[0].pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); | 570 | resp->ib_route[0].pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr)); |
571 | break; | 571 | break; |
572 | case 2: | 572 | case 2: |
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index 3a39c55d2b9a..fa0d52b8e622 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h | |||
@@ -122,40 +122,29 @@ static inline void ib_addr_get_mgid(struct rdma_dev_addr *dev_addr, | |||
122 | memcpy(gid, dev_addr->broadcast + 4, sizeof *gid); | 122 | memcpy(gid, dev_addr->broadcast + 4, sizeof *gid); |
123 | } | 123 | } |
124 | 124 | ||
125 | static inline void ib_addr_get_sgid(struct rdma_dev_addr *dev_addr, | 125 | static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr) |
126 | union ib_gid *gid) | ||
127 | { | 126 | { |
128 | memcpy(gid, dev_addr->src_dev_addr + 4, sizeof *gid); | 127 | return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0; |
129 | } | 128 | } |
130 | 129 | ||
131 | static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr, | 130 | static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) |
132 | union ib_gid *gid) | ||
133 | { | 131 | { |
134 | memcpy(dev_addr->src_dev_addr + 4, gid, sizeof *gid); | 132 | memcpy(gid, dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof *gid); |
135 | } | 133 | } |
136 | 134 | ||
137 | static inline void ib_addr_get_dgid(struct rdma_dev_addr *dev_addr, | 135 | static inline void rdma_addr_set_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) |
138 | union ib_gid *gid) | ||
139 | { | 136 | { |
140 | memcpy(gid, dev_addr->dst_dev_addr + 4, sizeof *gid); | 137 | memcpy(dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid); |
141 | } | 138 | } |
142 | 139 | ||
143 | static inline void ib_addr_set_dgid(struct rdma_dev_addr *dev_addr, | 140 | static inline void rdma_addr_get_dgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) |
144 | union ib_gid *gid) | ||
145 | { | 141 | { |
146 | memcpy(dev_addr->dst_dev_addr + 4, gid, sizeof *gid); | 142 | memcpy(gid, dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof *gid); |
147 | } | 143 | } |
148 | 144 | ||
149 | static inline void iw_addr_get_sgid(struct rdma_dev_addr *dev_addr, | 145 | static inline void rdma_addr_set_dgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) |
150 | union ib_gid *gid) | ||
151 | { | ||
152 | memcpy(gid, dev_addr->src_dev_addr, sizeof *gid); | ||
153 | } | ||
154 | |||
155 | static inline void iw_addr_get_dgid(struct rdma_dev_addr *dev_addr, | ||
156 | union ib_gid *gid) | ||
157 | { | 146 | { |
158 | memcpy(gid, dev_addr->dst_dev_addr, sizeof *gid); | 147 | memcpy(dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid); |
159 | } | 148 | } |
160 | 149 | ||
161 | #endif /* IB_ADDR_H */ | 150 | #endif /* IB_ADDR_H */ |
diff --git a/net/rds/ib.c b/net/rds/ib.c index 536ebe5d3f6b..3b8992361042 100644 --- a/net/rds/ib.c +++ b/net/rds/ib.c | |||
@@ -182,8 +182,8 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn, | |||
182 | ic = conn->c_transport_data; | 182 | ic = conn->c_transport_data; |
183 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; | 183 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; |
184 | 184 | ||
185 | ib_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); | 185 | rdma_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); |
186 | ib_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); | 186 | rdma_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); |
187 | 187 | ||
188 | rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rds_ib_client); | 188 | rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rds_ib_client); |
189 | iinfo->max_send_wr = ic->i_send_ring.w_nr; | 189 | iinfo->max_send_wr = ic->i_send_ring.w_nr; |
diff --git a/net/rds/iw.c b/net/rds/iw.c index db224f7c2937..b28fa8525b24 100644 --- a/net/rds/iw.c +++ b/net/rds/iw.c | |||
@@ -184,8 +184,8 @@ static int rds_iw_conn_info_visitor(struct rds_connection *conn, | |||
184 | ic = conn->c_transport_data; | 184 | ic = conn->c_transport_data; |
185 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; | 185 | dev_addr = &ic->i_cm_id->route.addr.dev_addr; |
186 | 186 | ||
187 | ib_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); | 187 | rdma_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid); |
188 | ib_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); | 188 | rdma_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid); |
189 | 189 | ||
190 | rds_iwdev = ib_get_client_data(ic->i_cm_id->device, &rds_iw_client); | 190 | rds_iwdev = ib_get_client_data(ic->i_cm_id->device, &rds_iw_client); |
191 | iinfo->max_send_wr = ic->i_send_ring.w_nr; | 191 | iinfo->max_send_wr = ic->i_send_ring.w_nr; |