aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@wdc.com>2017-10-06 16:06:17 -0400
committerDoug Ledford <dledford@redhat.com>2017-10-10 10:49:44 -0400
commit9d18717790c43c904fabe9da7a4c6b2ebed2c4d8 (patch)
treede8c28625958592b5015d30c0c2101d5f7508b07
parent9cc12ad6db55d7d902260fead28a91710dd5dbe5 (diff)
IB/core: Simplify sa_path_set_[sd]lid() calls
Instead of making every caller convert the second argument of sa_path_set_slid() and sa_path_set_dlid() to big endian format, make these two functions accept LIDs in CPU endian format. This patch does not change any functionality. Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Cc: Don Hiatt <don.hiatt@intel.com> Cc: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/core/cm.c26
-rw-r--r--drivers/infiniband/core/uverbs_marshall.c10
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c2
-rw-r--r--include/rdma/ib_sa.h12
4 files changed, 24 insertions, 26 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 4c4b46586af2..d80911d4abb7 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -1472,31 +1472,29 @@ static void cm_format_path_lid_from_req(struct cm_req_msg *req_msg,
1472 1472
1473 if (primary_path->rec_type != SA_PATH_REC_TYPE_OPA) { 1473 if (primary_path->rec_type != SA_PATH_REC_TYPE_OPA) {
1474 sa_path_set_dlid(primary_path, 1474 sa_path_set_dlid(primary_path,
1475 htonl(ntohs(req_msg->primary_local_lid))); 1475 ntohs(req_msg->primary_local_lid));
1476 sa_path_set_slid(primary_path, 1476 sa_path_set_slid(primary_path,
1477 htonl(ntohs(req_msg->primary_remote_lid))); 1477 ntohs(req_msg->primary_remote_lid));
1478 } else { 1478 } else {
1479 lid = opa_get_lid_from_gid(&req_msg->primary_local_gid); 1479 lid = opa_get_lid_from_gid(&req_msg->primary_local_gid);
1480 sa_path_set_dlid(primary_path, cpu_to_be32(lid)); 1480 sa_path_set_dlid(primary_path, lid);
1481 1481
1482 lid = opa_get_lid_from_gid(&req_msg->primary_remote_gid); 1482 lid = opa_get_lid_from_gid(&req_msg->primary_remote_gid);
1483 sa_path_set_slid(primary_path, cpu_to_be32(lid)); 1483 sa_path_set_slid(primary_path, lid);
1484 } 1484 }
1485 1485
1486 if (!cm_req_has_alt_path(req_msg)) 1486 if (!cm_req_has_alt_path(req_msg))
1487 return; 1487 return;
1488 1488
1489 if (alt_path->rec_type != SA_PATH_REC_TYPE_OPA) { 1489 if (alt_path->rec_type != SA_PATH_REC_TYPE_OPA) {
1490 sa_path_set_dlid(alt_path, 1490 sa_path_set_dlid(alt_path, ntohs(req_msg->alt_local_lid));
1491 htonl(ntohs(req_msg->alt_local_lid))); 1491 sa_path_set_slid(alt_path, ntohs(req_msg->alt_remote_lid));
1492 sa_path_set_slid(alt_path,
1493 htonl(ntohs(req_msg->alt_remote_lid)));
1494 } else { 1492 } else {
1495 lid = opa_get_lid_from_gid(&req_msg->alt_local_gid); 1493 lid = opa_get_lid_from_gid(&req_msg->alt_local_gid);
1496 sa_path_set_dlid(alt_path, cpu_to_be32(lid)); 1494 sa_path_set_dlid(alt_path, lid);
1497 1495
1498 lid = opa_get_lid_from_gid(&req_msg->alt_remote_gid); 1496 lid = opa_get_lid_from_gid(&req_msg->alt_remote_gid);
1499 sa_path_set_slid(alt_path, cpu_to_be32(lid)); 1497 sa_path_set_slid(alt_path, lid);
1500 } 1498 }
1501} 1499}
1502 1500
@@ -3037,14 +3035,14 @@ static void cm_format_path_lid_from_lap(struct cm_lap_msg *lap_msg,
3037 u32 lid; 3035 u32 lid;
3038 3036
3039 if (path->rec_type != SA_PATH_REC_TYPE_OPA) { 3037 if (path->rec_type != SA_PATH_REC_TYPE_OPA) {
3040 sa_path_set_dlid(path, htonl(ntohs(lap_msg->alt_local_lid))); 3038 sa_path_set_dlid(path, ntohs(lap_msg->alt_local_lid));
3041 sa_path_set_slid(path, htonl(ntohs(lap_msg->alt_remote_lid))); 3039 sa_path_set_slid(path, ntohs(lap_msg->alt_remote_lid));
3042 } else { 3040 } else {
3043 lid = opa_get_lid_from_gid(&lap_msg->alt_local_gid); 3041 lid = opa_get_lid_from_gid(&lap_msg->alt_local_gid);
3044 sa_path_set_dlid(path, cpu_to_be32(lid)); 3042 sa_path_set_dlid(path, lid);
3045 3043
3046 lid = opa_get_lid_from_gid(&lap_msg->alt_remote_gid); 3044 lid = opa_get_lid_from_gid(&lap_msg->alt_remote_gid);
3047 sa_path_set_slid(path, cpu_to_be32(lid)); 3045 sa_path_set_slid(path, lid);
3048 } 3046 }
3049} 3047}
3050 3048
diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
index bd0acf376af0..aeb2824efbc7 100644
--- a/drivers/infiniband/core/uverbs_marshall.c
+++ b/drivers/infiniband/core/uverbs_marshall.c
@@ -176,18 +176,18 @@ EXPORT_SYMBOL(ib_copy_path_rec_to_user);
176void ib_copy_path_rec_from_user(struct sa_path_rec *dst, 176void ib_copy_path_rec_from_user(struct sa_path_rec *dst,
177 struct ib_user_path_rec *src) 177 struct ib_user_path_rec *src)
178{ 178{
179 __be32 slid, dlid; 179 u32 slid, dlid;
180 180
181 memset(dst, 0, sizeof(*dst)); 181 memset(dst, 0, sizeof(*dst));
182 if ((ib_is_opa_gid((union ib_gid *)src->sgid)) || 182 if ((ib_is_opa_gid((union ib_gid *)src->sgid)) ||
183 (ib_is_opa_gid((union ib_gid *)src->dgid))) { 183 (ib_is_opa_gid((union ib_gid *)src->dgid))) {
184 dst->rec_type = SA_PATH_REC_TYPE_OPA; 184 dst->rec_type = SA_PATH_REC_TYPE_OPA;
185 slid = htonl(opa_get_lid_from_gid((union ib_gid *)src->sgid)); 185 slid = opa_get_lid_from_gid((union ib_gid *)src->sgid);
186 dlid = htonl(opa_get_lid_from_gid((union ib_gid *)src->dgid)); 186 dlid = opa_get_lid_from_gid((union ib_gid *)src->dgid);
187 } else { 187 } else {
188 dst->rec_type = SA_PATH_REC_TYPE_IB; 188 dst->rec_type = SA_PATH_REC_TYPE_IB;
189 slid = htonl(ntohs(src->slid)); 189 slid = ntohs(src->slid);
190 dlid = htonl(ntohs(src->dlid)); 190 dlid = ntohs(src->dlid);
191 } 191 }
192 memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid); 192 memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
193 memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid); 193 memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index fa5ccdb3bb2a..778a08250f16 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2403,7 +2403,7 @@ static void srp_cm_rej_handler(struct ib_cm_id *cm_id,
2403 switch (event->param.rej_rcvd.reason) { 2403 switch (event->param.rej_rcvd.reason) {
2404 case IB_CM_REJ_PORT_CM_REDIRECT: 2404 case IB_CM_REJ_PORT_CM_REDIRECT:
2405 cpi = event->param.rej_rcvd.ari; 2405 cpi = event->param.rej_rcvd.ari;
2406 sa_path_set_dlid(&ch->path, htonl(ntohs(cpi->redirect_lid))); 2406 sa_path_set_dlid(&ch->path, ntohs(cpi->redirect_lid));
2407 ch->path.pkey = cpi->redirect_pkey; 2407 ch->path.pkey = cpi->redirect_pkey;
2408 cm_id->remote_cm_qpn = be32_to_cpu(cpi->redirect_qp) & 0x00ffffff; 2408 cm_id->remote_cm_qpn = be32_to_cpu(cpi->redirect_qp) & 0x00ffffff;
2409 memcpy(ch->path.dgid.raw, cpi->redirect_gid, 16); 2409 memcpy(ch->path.dgid.raw, cpi->redirect_gid, 16);
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index 355b81f4242d..1f7f604db5aa 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -590,20 +590,20 @@ static inline bool sa_path_is_roce(struct sa_path_rec *rec)
590 (rec->rec_type == SA_PATH_REC_TYPE_ROCE_V2)); 590 (rec->rec_type == SA_PATH_REC_TYPE_ROCE_V2));
591} 591}
592 592
593static inline void sa_path_set_slid(struct sa_path_rec *rec, __be32 slid) 593static inline void sa_path_set_slid(struct sa_path_rec *rec, u32 slid)
594{ 594{
595 if (rec->rec_type == SA_PATH_REC_TYPE_IB) 595 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
596 rec->ib.slid = htons(ntohl(slid)); 596 rec->ib.slid = cpu_to_be16(slid);
597 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA) 597 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
598 rec->opa.slid = slid; 598 rec->opa.slid = cpu_to_be32(slid);
599} 599}
600 600
601static inline void sa_path_set_dlid(struct sa_path_rec *rec, __be32 dlid) 601static inline void sa_path_set_dlid(struct sa_path_rec *rec, u32 dlid)
602{ 602{
603 if (rec->rec_type == SA_PATH_REC_TYPE_IB) 603 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
604 rec->ib.dlid = htons(ntohl(dlid)); 604 rec->ib.dlid = cpu_to_be16(dlid);
605 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA) 605 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
606 rec->opa.dlid = dlid; 606 rec->opa.dlid = cpu_to_be32(dlid);
607} 607}
608 608
609static inline void sa_path_set_raw_traffic(struct sa_path_rec *rec, 609static inline void sa_path_set_raw_traffic(struct sa_path_rec *rec,