aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/core/cma.c21
-rw-r--r--include/rdma/ib_addr.h10
2 files changed, 17 insertions, 14 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 863f64befc7c..c2cba734c5cb 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -262,14 +262,14 @@ static void cma_detach_from_dev(struct rdma_id_private *id_priv)
262static int cma_acquire_ib_dev(struct rdma_id_private *id_priv) 262static int cma_acquire_ib_dev(struct rdma_id_private *id_priv)
263{ 263{
264 struct cma_device *cma_dev; 264 struct cma_device *cma_dev;
265 union ib_gid *gid; 265 union ib_gid gid;
266 int ret = -ENODEV; 266 int ret = -ENODEV;
267 267
268 gid = ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr); 268 ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid),
269 269
270 mutex_lock(&lock); 270 mutex_lock(&lock);
271 list_for_each_entry(cma_dev, &dev_list, list) { 271 list_for_each_entry(cma_dev, &dev_list, list) {
272 ret = ib_find_cached_gid(cma_dev->device, gid, 272 ret = ib_find_cached_gid(cma_dev->device, &gid,
273 &id_priv->id.port_num, NULL); 273 &id_priv->id.port_num, NULL);
274 if (!ret) { 274 if (!ret) {
275 cma_attach_to_dev(id_priv, cma_dev); 275 cma_attach_to_dev(id_priv, cma_dev);
@@ -1134,8 +1134,8 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
1134 struct ib_sa_path_rec path_rec; 1134 struct ib_sa_path_rec path_rec;
1135 1135
1136 memset(&path_rec, 0, sizeof path_rec); 1136 memset(&path_rec, 0, sizeof path_rec);
1137 path_rec.sgid = *ib_addr_get_sgid(addr); 1137 ib_addr_get_sgid(addr, &path_rec.sgid);
1138 path_rec.dgid = *ib_addr_get_dgid(addr); 1138 ib_addr_get_dgid(addr, &path_rec.dgid);
1139 path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(addr)); 1139 path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(addr));
1140 path_rec.numb_path = 1; 1140 path_rec.numb_path = 1;
1141 1141
@@ -1263,7 +1263,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
1263{ 1263{
1264 struct cma_device *cma_dev; 1264 struct cma_device *cma_dev;
1265 struct ib_port_attr port_attr; 1265 struct ib_port_attr port_attr;
1266 union ib_gid *gid; 1266 union ib_gid gid;
1267 u16 pkey; 1267 u16 pkey;
1268 int ret; 1268 int ret;
1269 u8 p; 1269 u8 p;
@@ -1284,8 +1284,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
1284 } 1284 }
1285 1285
1286port_found: 1286port_found:
1287 gid = ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr); 1287 ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);
1288 ret = ib_get_cached_gid(cma_dev->device, p, 0, gid);
1289 if (ret) 1288 if (ret)
1290 goto out; 1289 goto out;
1291 1290
@@ -1293,6 +1292,7 @@ port_found:
1293 if (ret) 1292 if (ret)
1294 goto out; 1293 goto out;
1295 1294
1295 ib_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
1296 ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); 1296 ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
1297 id_priv->id.port_num = p; 1297 id_priv->id.port_num = p;
1298 cma_attach_to_dev(id_priv, cma_dev); 1298 cma_attach_to_dev(id_priv, cma_dev);
@@ -1339,6 +1339,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
1339{ 1339{
1340 struct cma_work *work; 1340 struct cma_work *work;
1341 struct sockaddr_in *src_in, *dst_in; 1341 struct sockaddr_in *src_in, *dst_in;
1342 union ib_gid gid;
1342 int ret; 1343 int ret;
1343 1344
1344 work = kzalloc(sizeof *work, GFP_KERNEL); 1345 work = kzalloc(sizeof *work, GFP_KERNEL);
@@ -1351,8 +1352,8 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
1351 goto err; 1352 goto err;
1352 } 1353 }
1353 1354
1354 ib_addr_set_dgid(&id_priv->id.route.addr.dev_addr, 1355 ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
1355 ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr)); 1356 ib_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
1356 1357
1357 if (cma_zero_addr(&id_priv->id.route.addr.src_addr)) { 1358 if (cma_zero_addr(&id_priv->id.route.addr.src_addr)) {
1358 src_in = (struct sockaddr_in *)&id_priv->id.route.addr.src_addr; 1359 src_in = (struct sockaddr_in *)&id_priv->id.route.addr.src_addr;
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index fcb5ba87dcc5..0ff67398928d 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -89,9 +89,10 @@ static inline void ib_addr_set_pkey(struct rdma_dev_addr *dev_addr, u16 pkey)
89 dev_addr->broadcast[9] = (unsigned char) pkey; 89 dev_addr->broadcast[9] = (unsigned char) pkey;
90} 90}
91 91
92static inline union ib_gid *ib_addr_get_sgid(struct rdma_dev_addr *dev_addr) 92static inline void ib_addr_get_sgid(struct rdma_dev_addr *dev_addr,
93 union ib_gid *gid)
93{ 94{
94 return (union ib_gid *) (dev_addr->src_dev_addr + 4); 95 memcpy(gid, dev_addr->src_dev_addr + 4, sizeof *gid);
95} 96}
96 97
97static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr, 98static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr,
@@ -100,9 +101,10 @@ static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr,
100 memcpy(dev_addr->src_dev_addr + 4, gid, sizeof *gid); 101 memcpy(dev_addr->src_dev_addr + 4, gid, sizeof *gid);
101} 102}
102 103
103static inline union ib_gid *ib_addr_get_dgid(struct rdma_dev_addr *dev_addr) 104static inline void ib_addr_get_dgid(struct rdma_dev_addr *dev_addr,
105 union ib_gid *gid)
104{ 106{
105 return (union ib_gid *) (dev_addr->dst_dev_addr + 4); 107 memcpy(gid, dev_addr->dst_dev_addr + 4, sizeof *gid);
106} 108}
107 109
108static inline void ib_addr_set_dgid(struct rdma_dev_addr *dev_addr, 110static inline void ib_addr_set_dgid(struct rdma_dev_addr *dev_addr,