diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2020-01-16 18:00:31 +0100 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2020-01-25 20:05:59 +0100 |
commit | 792a7c1f2e74bba878a1836cfbe9611f98576d3b (patch) | |
tree | aaa439e6ff1fcc556393bce9b561aad54f297de2 /drivers/infiniband | |
parent | IB/mlx5: Return the administrative GUID if exists (diff) | |
download | linux-792a7c1f2e74bba878a1836cfbe9611f98576d3b.tar.xz linux-792a7c1f2e74bba878a1836cfbe9611f98576d3b.zip |
RDMA/cm: Add accessors for CM_REQ transport_type
Access the two fields through wrappers, like all other fields, to make it
clearer what is happening.
Link: https://lore.kernel.org/r/20200116170037.30109-2-jgg@ziepe.ca
Tested-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/cm_msgs.h | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/infiniband/core/cm_msgs.h b/drivers/infiniband/core/cm_msgs.h index 23e3d0c6a67c..9af9a3212074 100644 --- a/drivers/infiniband/core/cm_msgs.h +++ b/drivers/infiniband/core/cm_msgs.h @@ -124,14 +124,37 @@ static inline void cm_req_set_remote_resp_timeout(struct cm_req_msg *req_msg, 0xFFFFFF07)); } +static inline u8 cm_req_get_transport_type(struct cm_req_msg *req_msg) +{ + return (u8) ((be32_to_cpu(req_msg->offset40) & 0x06) >> 1); +} + +static inline void cm_req_set_transport_type(struct cm_req_msg *req_msg, u8 val) +{ + req_msg->offset40 = + cpu_to_be32((be32_to_cpu(req_msg->offset40) & 0xFFFFFFF9) | + (val << 1)); +} + +static inline u8 cm_req_get_transport_type_ex(struct cm_req_msg *req_msg) +{ + return req_msg->offset51 & 0x7; +} + +static inline void cm_req_set_transport_type_ex(struct cm_req_msg *req_msg, + u8 val) +{ + req_msg->offset51 = (req_msg->offset51 & 0xF8) | val; +} + static inline enum ib_qp_type cm_req_get_qp_type(struct cm_req_msg *req_msg) { - u8 transport_type = (u8) (be32_to_cpu(req_msg->offset40) & 0x06) >> 1; + u8 transport_type = cm_req_get_transport_type(req_msg); switch(transport_type) { case 0: return IB_QPT_RC; case 1: return IB_QPT_UC; case 3: - switch (req_msg->offset51 & 0x7) { + switch (cm_req_get_transport_type_ex(req_msg)) { case 1: return IB_QPT_XRC_TGT; default: return 0; } @@ -144,20 +167,14 @@ static inline void cm_req_set_qp_type(struct cm_req_msg *req_msg, { switch(qp_type) { case IB_QPT_UC: - req_msg->offset40 = cpu_to_be32((be32_to_cpu( - req_msg->offset40) & - 0xFFFFFFF9) | 0x2); + cm_req_set_transport_type(req_msg, 1); break; case IB_QPT_XRC_INI: - req_msg->offset40 = cpu_to_be32((be32_to_cpu( - req_msg->offset40) & - 0xFFFFFFF9) | 0x6); - req_msg->offset51 = (req_msg->offset51 & 0xF8) | 1; + cm_req_set_transport_type(req_msg, 3); + cm_req_set_transport_type_ex(req_msg, 1); break; default: - req_msg->offset40 = cpu_to_be32(be32_to_cpu( - req_msg->offset40) & - 0xFFFFFFF9); + cm_req_set_transport_type(req_msg, 0); } } |