Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 1 | /* |
Sean Hefty | ef70044 | 2011-08-02 11:08:22 -0700 | [diff] [blame] | 2 | * Copyright (c) 2004, 2011 Intel Corporation. All rights reserved. |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 3 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. |
| 4 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. |
| 5 | * |
| 6 | * This software is available to you under a choice of one of two |
| 7 | * licenses. You may choose to be licensed under the terms of the GNU |
| 8 | * General Public License (GPL) Version 2, available from the file |
| 9 | * COPYING the madirectory of this source tree, or the |
| 10 | * OpenIB.org BSD license below: |
| 11 | * |
| 12 | * Redistribution and use source and binary forms, with or |
| 13 | * withmodification, are permitted provided that the following |
| 14 | * conditions are met: |
| 15 | * |
| 16 | * - Redistributions of source code must retathe above |
| 17 | * copyright notice, this list of conditions and the following |
| 18 | * disclaimer. |
| 19 | * |
| 20 | * - Redistributions binary form must reproduce the above |
| 21 | * copyright notice, this list of conditions and the following |
| 22 | * disclaimer the documentation and/or other materials |
| 23 | * provided with the distribution. |
| 24 | * |
| 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHWARRANTY OF ANY KIND, |
| 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 28 | * NONINFRINGEMENT. NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 29 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER AN |
| 30 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OF OR IN |
| 31 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS THE |
| 32 | * SOFTWARE. |
| 33 | */ |
| 34 | #if !defined(CM_MSGS_H) |
| 35 | #define CM_MSGS_H |
| 36 | |
Roland Dreier | a4d61e8 | 2005-08-25 13:40:04 -0700 | [diff] [blame] | 37 | #include <rdma/ib_mad.h> |
Sean Hefty | 5d861be | 2007-06-28 19:16:51 -0700 | [diff] [blame] | 38 | #include <rdma/ib_cm.h> |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * Parameters to routines below should be in network-byte order, and values |
| 42 | * are returned in network-byte order. |
| 43 | */ |
| 44 | |
| 45 | #define IB_CM_CLASS_VERSION 2 /* IB specification 1.2 */ |
| 46 | |
Harvey Harrison | 9c3da09 | 2009-01-17 17:11:57 -0800 | [diff] [blame] | 47 | #define CM_REQ_ATTR_ID cpu_to_be16(0x0010) |
| 48 | #define CM_MRA_ATTR_ID cpu_to_be16(0x0011) |
| 49 | #define CM_REJ_ATTR_ID cpu_to_be16(0x0012) |
| 50 | #define CM_REP_ATTR_ID cpu_to_be16(0x0013) |
| 51 | #define CM_RTU_ATTR_ID cpu_to_be16(0x0014) |
| 52 | #define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) |
| 53 | #define CM_DREP_ATTR_ID cpu_to_be16(0x0016) |
| 54 | #define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) |
| 55 | #define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) |
| 56 | #define CM_LAP_ATTR_ID cpu_to_be16(0x0019) |
| 57 | #define CM_APR_ATTR_ID cpu_to_be16(0x001A) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 58 | |
| 59 | enum cm_msg_sequence { |
| 60 | CM_MSG_SEQUENCE_REQ, |
| 61 | CM_MSG_SEQUENCE_LAP, |
| 62 | CM_MSG_SEQUENCE_DREQ, |
| 63 | CM_MSG_SEQUENCE_SIDR |
| 64 | }; |
| 65 | |
| 66 | struct cm_req_msg { |
| 67 | struct ib_mad_hdr hdr; |
| 68 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 69 | __be32 local_comm_id; |
| 70 | __be32 rsvd4; |
| 71 | __be64 service_id; |
| 72 | __be64 local_ca_guid; |
| 73 | __be32 rsvd24; |
| 74 | __be32 local_qkey; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 75 | /* local QPN:24, responder resources:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 76 | __be32 offset32; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 77 | /* local EECN:24, initiator depth:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 78 | __be32 offset36; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 79 | /* |
| 80 | * remote EECN:24, remote CM response timeout:5, |
| 81 | * transport service type:2, end-to-end flow control:1 |
| 82 | */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 83 | __be32 offset40; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 84 | /* starting PSN:24, local CM response timeout:5, retry count:3 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 85 | __be32 offset44; |
| 86 | __be16 pkey; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 87 | /* path MTU:4, RDC exists:1, RNR retry count:3. */ |
| 88 | u8 offset50; |
Sean Hefty | d26a360 | 2011-05-13 10:46:20 -0700 | [diff] [blame] | 89 | /* max CM Retries:4, SRQ:1, extended transport type:3 */ |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 90 | u8 offset51; |
| 91 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 92 | __be16 primary_local_lid; |
| 93 | __be16 primary_remote_lid; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 94 | union ib_gid primary_local_gid; |
| 95 | union ib_gid primary_remote_gid; |
| 96 | /* flow label:20, rsvd:6, packet rate:6 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 97 | __be32 primary_offset88; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 98 | u8 primary_traffic_class; |
| 99 | u8 primary_hop_limit; |
| 100 | /* SL:4, subnet local:1, rsvd:3 */ |
| 101 | u8 primary_offset94; |
| 102 | /* local ACK timeout:5, rsvd:3 */ |
| 103 | u8 primary_offset95; |
| 104 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 105 | __be16 alt_local_lid; |
| 106 | __be16 alt_remote_lid; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 107 | union ib_gid alt_local_gid; |
| 108 | union ib_gid alt_remote_gid; |
| 109 | /* flow label:20, rsvd:6, packet rate:6 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 110 | __be32 alt_offset132; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 111 | u8 alt_traffic_class; |
| 112 | u8 alt_hop_limit; |
| 113 | /* SL:4, subnet local:1, rsvd:3 */ |
| 114 | u8 alt_offset138; |
| 115 | /* local ACK timeout:5, rsvd:3 */ |
| 116 | u8 alt_offset139; |
| 117 | |
| 118 | u8 private_data[IB_CM_REQ_PRIVATE_DATA_SIZE]; |
| 119 | |
| 120 | } __attribute__ ((packed)); |
| 121 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 122 | static inline __be32 cm_req_get_local_qpn(struct cm_req_msg *req_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 123 | { |
| 124 | return cpu_to_be32(be32_to_cpu(req_msg->offset32) >> 8); |
| 125 | } |
| 126 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 127 | static inline void cm_req_set_local_qpn(struct cm_req_msg *req_msg, __be32 qpn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 128 | { |
| 129 | req_msg->offset32 = cpu_to_be32((be32_to_cpu(qpn) << 8) | |
| 130 | (be32_to_cpu(req_msg->offset32) & |
| 131 | 0x000000FF)); |
| 132 | } |
| 133 | |
| 134 | static inline u8 cm_req_get_resp_res(struct cm_req_msg *req_msg) |
| 135 | { |
| 136 | return (u8) be32_to_cpu(req_msg->offset32); |
| 137 | } |
| 138 | |
| 139 | static inline void cm_req_set_resp_res(struct cm_req_msg *req_msg, u8 resp_res) |
| 140 | { |
| 141 | req_msg->offset32 = cpu_to_be32(resp_res | |
| 142 | (be32_to_cpu(req_msg->offset32) & |
| 143 | 0xFFFFFF00)); |
| 144 | } |
| 145 | |
| 146 | static inline u8 cm_req_get_init_depth(struct cm_req_msg *req_msg) |
| 147 | { |
| 148 | return (u8) be32_to_cpu(req_msg->offset36); |
| 149 | } |
| 150 | |
| 151 | static inline void cm_req_set_init_depth(struct cm_req_msg *req_msg, |
| 152 | u8 init_depth) |
| 153 | { |
| 154 | req_msg->offset36 = cpu_to_be32(init_depth | |
| 155 | (be32_to_cpu(req_msg->offset36) & |
| 156 | 0xFFFFFF00)); |
| 157 | } |
| 158 | |
| 159 | static inline u8 cm_req_get_remote_resp_timeout(struct cm_req_msg *req_msg) |
| 160 | { |
| 161 | return (u8) ((be32_to_cpu(req_msg->offset40) & 0xF8) >> 3); |
| 162 | } |
| 163 | |
| 164 | static inline void cm_req_set_remote_resp_timeout(struct cm_req_msg *req_msg, |
| 165 | u8 resp_timeout) |
| 166 | { |
| 167 | req_msg->offset40 = cpu_to_be32((resp_timeout << 3) | |
| 168 | (be32_to_cpu(req_msg->offset40) & |
| 169 | 0xFFFFFF07)); |
| 170 | } |
| 171 | |
| 172 | static inline enum ib_qp_type cm_req_get_qp_type(struct cm_req_msg *req_msg) |
| 173 | { |
| 174 | u8 transport_type = (u8) (be32_to_cpu(req_msg->offset40) & 0x06) >> 1; |
| 175 | switch(transport_type) { |
| 176 | case 0: return IB_QPT_RC; |
| 177 | case 1: return IB_QPT_UC; |
Sean Hefty | d26a360 | 2011-05-13 10:46:20 -0700 | [diff] [blame] | 178 | case 3: |
| 179 | switch (req_msg->offset51 & 0x7) { |
| 180 | case 1: return IB_QPT_XRC_TGT; |
| 181 | default: return 0; |
| 182 | } |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 183 | default: return 0; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | static inline void cm_req_set_qp_type(struct cm_req_msg *req_msg, |
| 188 | enum ib_qp_type qp_type) |
| 189 | { |
| 190 | switch(qp_type) { |
| 191 | case IB_QPT_UC: |
| 192 | req_msg->offset40 = cpu_to_be32((be32_to_cpu( |
| 193 | req_msg->offset40) & |
| 194 | 0xFFFFFFF9) | 0x2); |
Roland Dreier | 3910f44 | 2005-10-20 12:29:36 -0700 | [diff] [blame] | 195 | break; |
Sean Hefty | d26a360 | 2011-05-13 10:46:20 -0700 | [diff] [blame] | 196 | case IB_QPT_XRC_INI: |
| 197 | req_msg->offset40 = cpu_to_be32((be32_to_cpu( |
| 198 | req_msg->offset40) & |
| 199 | 0xFFFFFFF9) | 0x6); |
| 200 | req_msg->offset51 = (req_msg->offset51 & 0xF8) | 1; |
| 201 | break; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 202 | default: |
| 203 | req_msg->offset40 = cpu_to_be32(be32_to_cpu( |
| 204 | req_msg->offset40) & |
| 205 | 0xFFFFFFF9); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | static inline u8 cm_req_get_flow_ctrl(struct cm_req_msg *req_msg) |
| 210 | { |
| 211 | return be32_to_cpu(req_msg->offset40) & 0x1; |
| 212 | } |
| 213 | |
| 214 | static inline void cm_req_set_flow_ctrl(struct cm_req_msg *req_msg, |
| 215 | u8 flow_ctrl) |
| 216 | { |
| 217 | req_msg->offset40 = cpu_to_be32((flow_ctrl & 0x1) | |
| 218 | (be32_to_cpu(req_msg->offset40) & |
| 219 | 0xFFFFFFFE)); |
| 220 | } |
| 221 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 222 | static inline __be32 cm_req_get_starting_psn(struct cm_req_msg *req_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 223 | { |
| 224 | return cpu_to_be32(be32_to_cpu(req_msg->offset44) >> 8); |
| 225 | } |
| 226 | |
| 227 | static inline void cm_req_set_starting_psn(struct cm_req_msg *req_msg, |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 228 | __be32 starting_psn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 229 | { |
| 230 | req_msg->offset44 = cpu_to_be32((be32_to_cpu(starting_psn) << 8) | |
| 231 | (be32_to_cpu(req_msg->offset44) & 0x000000FF)); |
| 232 | } |
| 233 | |
| 234 | static inline u8 cm_req_get_local_resp_timeout(struct cm_req_msg *req_msg) |
| 235 | { |
| 236 | return (u8) ((be32_to_cpu(req_msg->offset44) & 0xF8) >> 3); |
| 237 | } |
| 238 | |
| 239 | static inline void cm_req_set_local_resp_timeout(struct cm_req_msg *req_msg, |
| 240 | u8 resp_timeout) |
| 241 | { |
| 242 | req_msg->offset44 = cpu_to_be32((resp_timeout << 3) | |
| 243 | (be32_to_cpu(req_msg->offset44) & 0xFFFFFF07)); |
| 244 | } |
| 245 | |
| 246 | static inline u8 cm_req_get_retry_count(struct cm_req_msg *req_msg) |
| 247 | { |
| 248 | return (u8) (be32_to_cpu(req_msg->offset44) & 0x7); |
| 249 | } |
| 250 | |
| 251 | static inline void cm_req_set_retry_count(struct cm_req_msg *req_msg, |
| 252 | u8 retry_count) |
| 253 | { |
| 254 | req_msg->offset44 = cpu_to_be32((retry_count & 0x7) | |
| 255 | (be32_to_cpu(req_msg->offset44) & 0xFFFFFFF8)); |
| 256 | } |
| 257 | |
| 258 | static inline u8 cm_req_get_path_mtu(struct cm_req_msg *req_msg) |
| 259 | { |
| 260 | return req_msg->offset50 >> 4; |
| 261 | } |
| 262 | |
| 263 | static inline void cm_req_set_path_mtu(struct cm_req_msg *req_msg, u8 path_mtu) |
| 264 | { |
| 265 | req_msg->offset50 = (u8) ((req_msg->offset50 & 0xF) | (path_mtu << 4)); |
| 266 | } |
| 267 | |
| 268 | static inline u8 cm_req_get_rnr_retry_count(struct cm_req_msg *req_msg) |
| 269 | { |
| 270 | return req_msg->offset50 & 0x7; |
| 271 | } |
| 272 | |
| 273 | static inline void cm_req_set_rnr_retry_count(struct cm_req_msg *req_msg, |
| 274 | u8 rnr_retry_count) |
| 275 | { |
| 276 | req_msg->offset50 = (u8) ((req_msg->offset50 & 0xF8) | |
| 277 | (rnr_retry_count & 0x7)); |
| 278 | } |
| 279 | |
| 280 | static inline u8 cm_req_get_max_cm_retries(struct cm_req_msg *req_msg) |
| 281 | { |
| 282 | return req_msg->offset51 >> 4; |
| 283 | } |
| 284 | |
| 285 | static inline void cm_req_set_max_cm_retries(struct cm_req_msg *req_msg, |
| 286 | u8 retries) |
| 287 | { |
| 288 | req_msg->offset51 = (u8) ((req_msg->offset51 & 0xF) | (retries << 4)); |
| 289 | } |
| 290 | |
| 291 | static inline u8 cm_req_get_srq(struct cm_req_msg *req_msg) |
| 292 | { |
| 293 | return (req_msg->offset51 & 0x8) >> 3; |
| 294 | } |
| 295 | |
| 296 | static inline void cm_req_set_srq(struct cm_req_msg *req_msg, u8 srq) |
| 297 | { |
| 298 | req_msg->offset51 = (u8) ((req_msg->offset51 & 0xF7) | |
| 299 | ((srq & 0x1) << 3)); |
| 300 | } |
| 301 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 302 | static inline __be32 cm_req_get_primary_flow_label(struct cm_req_msg *req_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 303 | { |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 304 | return cpu_to_be32(be32_to_cpu(req_msg->primary_offset88) >> 12); |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | static inline void cm_req_set_primary_flow_label(struct cm_req_msg *req_msg, |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 308 | __be32 flow_label) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 309 | { |
| 310 | req_msg->primary_offset88 = cpu_to_be32( |
| 311 | (be32_to_cpu(req_msg->primary_offset88) & |
| 312 | 0x00000FFF) | |
| 313 | (be32_to_cpu(flow_label) << 12)); |
| 314 | } |
| 315 | |
| 316 | static inline u8 cm_req_get_primary_packet_rate(struct cm_req_msg *req_msg) |
| 317 | { |
| 318 | return (u8) (be32_to_cpu(req_msg->primary_offset88) & 0x3F); |
| 319 | } |
| 320 | |
| 321 | static inline void cm_req_set_primary_packet_rate(struct cm_req_msg *req_msg, |
| 322 | u8 rate) |
| 323 | { |
| 324 | req_msg->primary_offset88 = cpu_to_be32( |
| 325 | (be32_to_cpu(req_msg->primary_offset88) & |
| 326 | 0xFFFFFFC0) | (rate & 0x3F)); |
| 327 | } |
| 328 | |
| 329 | static inline u8 cm_req_get_primary_sl(struct cm_req_msg *req_msg) |
| 330 | { |
| 331 | return (u8) (req_msg->primary_offset94 >> 4); |
| 332 | } |
| 333 | |
| 334 | static inline void cm_req_set_primary_sl(struct cm_req_msg *req_msg, u8 sl) |
| 335 | { |
| 336 | req_msg->primary_offset94 = (u8) ((req_msg->primary_offset94 & 0x0F) | |
| 337 | (sl << 4)); |
| 338 | } |
| 339 | |
| 340 | static inline u8 cm_req_get_primary_subnet_local(struct cm_req_msg *req_msg) |
| 341 | { |
| 342 | return (u8) ((req_msg->primary_offset94 & 0x08) >> 3); |
| 343 | } |
| 344 | |
| 345 | static inline void cm_req_set_primary_subnet_local(struct cm_req_msg *req_msg, |
| 346 | u8 subnet_local) |
| 347 | { |
| 348 | req_msg->primary_offset94 = (u8) ((req_msg->primary_offset94 & 0xF7) | |
| 349 | ((subnet_local & 0x1) << 3)); |
| 350 | } |
| 351 | |
| 352 | static inline u8 cm_req_get_primary_local_ack_timeout(struct cm_req_msg *req_msg) |
| 353 | { |
| 354 | return (u8) (req_msg->primary_offset95 >> 3); |
| 355 | } |
| 356 | |
| 357 | static inline void cm_req_set_primary_local_ack_timeout(struct cm_req_msg *req_msg, |
| 358 | u8 local_ack_timeout) |
| 359 | { |
| 360 | req_msg->primary_offset95 = (u8) ((req_msg->primary_offset95 & 0x07) | |
| 361 | (local_ack_timeout << 3)); |
| 362 | } |
| 363 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 364 | static inline __be32 cm_req_get_alt_flow_label(struct cm_req_msg *req_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 365 | { |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 366 | return cpu_to_be32(be32_to_cpu(req_msg->alt_offset132) >> 12); |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | static inline void cm_req_set_alt_flow_label(struct cm_req_msg *req_msg, |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 370 | __be32 flow_label) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 371 | { |
| 372 | req_msg->alt_offset132 = cpu_to_be32( |
| 373 | (be32_to_cpu(req_msg->alt_offset132) & |
| 374 | 0x00000FFF) | |
| 375 | (be32_to_cpu(flow_label) << 12)); |
| 376 | } |
| 377 | |
| 378 | static inline u8 cm_req_get_alt_packet_rate(struct cm_req_msg *req_msg) |
| 379 | { |
| 380 | return (u8) (be32_to_cpu(req_msg->alt_offset132) & 0x3F); |
| 381 | } |
| 382 | |
| 383 | static inline void cm_req_set_alt_packet_rate(struct cm_req_msg *req_msg, |
| 384 | u8 rate) |
| 385 | { |
| 386 | req_msg->alt_offset132 = cpu_to_be32( |
| 387 | (be32_to_cpu(req_msg->alt_offset132) & |
| 388 | 0xFFFFFFC0) | (rate & 0x3F)); |
| 389 | } |
| 390 | |
| 391 | static inline u8 cm_req_get_alt_sl(struct cm_req_msg *req_msg) |
| 392 | { |
| 393 | return (u8) (req_msg->alt_offset138 >> 4); |
| 394 | } |
| 395 | |
| 396 | static inline void cm_req_set_alt_sl(struct cm_req_msg *req_msg, u8 sl) |
| 397 | { |
| 398 | req_msg->alt_offset138 = (u8) ((req_msg->alt_offset138 & 0x0F) | |
| 399 | (sl << 4)); |
| 400 | } |
| 401 | |
| 402 | static inline u8 cm_req_get_alt_subnet_local(struct cm_req_msg *req_msg) |
| 403 | { |
| 404 | return (u8) ((req_msg->alt_offset138 & 0x08) >> 3); |
| 405 | } |
| 406 | |
| 407 | static inline void cm_req_set_alt_subnet_local(struct cm_req_msg *req_msg, |
| 408 | u8 subnet_local) |
| 409 | { |
| 410 | req_msg->alt_offset138 = (u8) ((req_msg->alt_offset138 & 0xF7) | |
| 411 | ((subnet_local & 0x1) << 3)); |
| 412 | } |
| 413 | |
| 414 | static inline u8 cm_req_get_alt_local_ack_timeout(struct cm_req_msg *req_msg) |
| 415 | { |
| 416 | return (u8) (req_msg->alt_offset139 >> 3); |
| 417 | } |
| 418 | |
| 419 | static inline void cm_req_set_alt_local_ack_timeout(struct cm_req_msg *req_msg, |
| 420 | u8 local_ack_timeout) |
| 421 | { |
| 422 | req_msg->alt_offset139 = (u8) ((req_msg->alt_offset139 & 0x07) | |
| 423 | (local_ack_timeout << 3)); |
| 424 | } |
| 425 | |
| 426 | /* Message REJected or MRAed */ |
| 427 | enum cm_msg_response { |
| 428 | CM_MSG_RESPONSE_REQ = 0x0, |
| 429 | CM_MSG_RESPONSE_REP = 0x1, |
| 430 | CM_MSG_RESPONSE_OTHER = 0x2 |
| 431 | }; |
| 432 | |
| 433 | struct cm_mra_msg { |
| 434 | struct ib_mad_hdr hdr; |
| 435 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 436 | __be32 local_comm_id; |
| 437 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 438 | /* message MRAed:2, rsvd:6 */ |
| 439 | u8 offset8; |
| 440 | /* service timeout:5, rsvd:3 */ |
| 441 | u8 offset9; |
| 442 | |
| 443 | u8 private_data[IB_CM_MRA_PRIVATE_DATA_SIZE]; |
| 444 | |
| 445 | } __attribute__ ((packed)); |
| 446 | |
| 447 | static inline u8 cm_mra_get_msg_mraed(struct cm_mra_msg *mra_msg) |
| 448 | { |
| 449 | return (u8) (mra_msg->offset8 >> 6); |
| 450 | } |
| 451 | |
| 452 | static inline void cm_mra_set_msg_mraed(struct cm_mra_msg *mra_msg, u8 msg) |
| 453 | { |
| 454 | mra_msg->offset8 = (u8) ((mra_msg->offset8 & 0x3F) | (msg << 6)); |
| 455 | } |
| 456 | |
| 457 | static inline u8 cm_mra_get_service_timeout(struct cm_mra_msg *mra_msg) |
| 458 | { |
| 459 | return (u8) (mra_msg->offset9 >> 3); |
| 460 | } |
| 461 | |
| 462 | static inline void cm_mra_set_service_timeout(struct cm_mra_msg *mra_msg, |
| 463 | u8 service_timeout) |
| 464 | { |
| 465 | mra_msg->offset9 = (u8) ((mra_msg->offset9 & 0x07) | |
| 466 | (service_timeout << 3)); |
| 467 | } |
| 468 | |
| 469 | struct cm_rej_msg { |
| 470 | struct ib_mad_hdr hdr; |
| 471 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 472 | __be32 local_comm_id; |
| 473 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 474 | /* message REJected:2, rsvd:6 */ |
| 475 | u8 offset8; |
| 476 | /* reject info length:7, rsvd:1. */ |
| 477 | u8 offset9; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 478 | __be16 reason; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 479 | u8 ari[IB_CM_REJ_ARI_LENGTH]; |
| 480 | |
| 481 | u8 private_data[IB_CM_REJ_PRIVATE_DATA_SIZE]; |
| 482 | |
| 483 | } __attribute__ ((packed)); |
| 484 | |
| 485 | static inline u8 cm_rej_get_msg_rejected(struct cm_rej_msg *rej_msg) |
| 486 | { |
| 487 | return (u8) (rej_msg->offset8 >> 6); |
| 488 | } |
| 489 | |
| 490 | static inline void cm_rej_set_msg_rejected(struct cm_rej_msg *rej_msg, u8 msg) |
| 491 | { |
| 492 | rej_msg->offset8 = (u8) ((rej_msg->offset8 & 0x3F) | (msg << 6)); |
| 493 | } |
| 494 | |
| 495 | static inline u8 cm_rej_get_reject_info_len(struct cm_rej_msg *rej_msg) |
| 496 | { |
| 497 | return (u8) (rej_msg->offset9 >> 1); |
| 498 | } |
| 499 | |
| 500 | static inline void cm_rej_set_reject_info_len(struct cm_rej_msg *rej_msg, |
| 501 | u8 len) |
| 502 | { |
| 503 | rej_msg->offset9 = (u8) ((rej_msg->offset9 & 0x1) | (len << 1)); |
| 504 | } |
| 505 | |
| 506 | struct cm_rep_msg { |
| 507 | struct ib_mad_hdr hdr; |
| 508 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 509 | __be32 local_comm_id; |
| 510 | __be32 remote_comm_id; |
| 511 | __be32 local_qkey; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 512 | /* local QPN:24, rsvd:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 513 | __be32 offset12; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 514 | /* local EECN:24, rsvd:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 515 | __be32 offset16; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 516 | /* starting PSN:24 rsvd:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 517 | __be32 offset20; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 518 | u8 resp_resources; |
| 519 | u8 initiator_depth; |
| 520 | /* target ACK delay:5, failover accepted:2, end-to-end flow control:1 */ |
| 521 | u8 offset26; |
| 522 | /* RNR retry count:3, SRQ:1, rsvd:5 */ |
| 523 | u8 offset27; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 524 | __be64 local_ca_guid; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 525 | |
| 526 | u8 private_data[IB_CM_REP_PRIVATE_DATA_SIZE]; |
| 527 | |
| 528 | } __attribute__ ((packed)); |
| 529 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 530 | static inline __be32 cm_rep_get_local_qpn(struct cm_rep_msg *rep_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 531 | { |
| 532 | return cpu_to_be32(be32_to_cpu(rep_msg->offset12) >> 8); |
| 533 | } |
| 534 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 535 | static inline void cm_rep_set_local_qpn(struct cm_rep_msg *rep_msg, __be32 qpn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 536 | { |
| 537 | rep_msg->offset12 = cpu_to_be32((be32_to_cpu(qpn) << 8) | |
| 538 | (be32_to_cpu(rep_msg->offset12) & 0x000000FF)); |
| 539 | } |
| 540 | |
Sean Hefty | ef70044 | 2011-08-02 11:08:22 -0700 | [diff] [blame] | 541 | static inline __be32 cm_rep_get_local_eecn(struct cm_rep_msg *rep_msg) |
| 542 | { |
| 543 | return cpu_to_be32(be32_to_cpu(rep_msg->offset16) >> 8); |
| 544 | } |
| 545 | |
| 546 | static inline void cm_rep_set_local_eecn(struct cm_rep_msg *rep_msg, __be32 eecn) |
| 547 | { |
| 548 | rep_msg->offset16 = cpu_to_be32((be32_to_cpu(eecn) << 8) | |
| 549 | (be32_to_cpu(rep_msg->offset16) & 0x000000FF)); |
| 550 | } |
| 551 | |
| 552 | static inline __be32 cm_rep_get_qpn(struct cm_rep_msg *rep_msg, enum ib_qp_type qp_type) |
| 553 | { |
| 554 | return (qp_type == IB_QPT_XRC_INI) ? |
| 555 | cm_rep_get_local_eecn(rep_msg) : cm_rep_get_local_qpn(rep_msg); |
| 556 | } |
| 557 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 558 | static inline __be32 cm_rep_get_starting_psn(struct cm_rep_msg *rep_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 559 | { |
| 560 | return cpu_to_be32(be32_to_cpu(rep_msg->offset20) >> 8); |
| 561 | } |
| 562 | |
| 563 | static inline void cm_rep_set_starting_psn(struct cm_rep_msg *rep_msg, |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 564 | __be32 starting_psn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 565 | { |
| 566 | rep_msg->offset20 = cpu_to_be32((be32_to_cpu(starting_psn) << 8) | |
| 567 | (be32_to_cpu(rep_msg->offset20) & 0x000000FF)); |
| 568 | } |
| 569 | |
| 570 | static inline u8 cm_rep_get_target_ack_delay(struct cm_rep_msg *rep_msg) |
| 571 | { |
| 572 | return (u8) (rep_msg->offset26 >> 3); |
| 573 | } |
| 574 | |
| 575 | static inline void cm_rep_set_target_ack_delay(struct cm_rep_msg *rep_msg, |
| 576 | u8 target_ack_delay) |
| 577 | { |
| 578 | rep_msg->offset26 = (u8) ((rep_msg->offset26 & 0x07) | |
| 579 | (target_ack_delay << 3)); |
| 580 | } |
| 581 | |
| 582 | static inline u8 cm_rep_get_failover(struct cm_rep_msg *rep_msg) |
| 583 | { |
| 584 | return (u8) ((rep_msg->offset26 & 0x06) >> 1); |
| 585 | } |
| 586 | |
| 587 | static inline void cm_rep_set_failover(struct cm_rep_msg *rep_msg, u8 failover) |
| 588 | { |
| 589 | rep_msg->offset26 = (u8) ((rep_msg->offset26 & 0xF9) | |
| 590 | ((failover & 0x3) << 1)); |
| 591 | } |
| 592 | |
| 593 | static inline u8 cm_rep_get_flow_ctrl(struct cm_rep_msg *rep_msg) |
| 594 | { |
| 595 | return (u8) (rep_msg->offset26 & 0x01); |
| 596 | } |
| 597 | |
| 598 | static inline void cm_rep_set_flow_ctrl(struct cm_rep_msg *rep_msg, |
| 599 | u8 flow_ctrl) |
| 600 | { |
| 601 | rep_msg->offset26 = (u8) ((rep_msg->offset26 & 0xFE) | |
| 602 | (flow_ctrl & 0x1)); |
| 603 | } |
| 604 | |
| 605 | static inline u8 cm_rep_get_rnr_retry_count(struct cm_rep_msg *rep_msg) |
| 606 | { |
| 607 | return (u8) (rep_msg->offset27 >> 5); |
| 608 | } |
| 609 | |
| 610 | static inline void cm_rep_set_rnr_retry_count(struct cm_rep_msg *rep_msg, |
| 611 | u8 rnr_retry_count) |
| 612 | { |
| 613 | rep_msg->offset27 = (u8) ((rep_msg->offset27 & 0x1F) | |
| 614 | (rnr_retry_count << 5)); |
| 615 | } |
| 616 | |
| 617 | static inline u8 cm_rep_get_srq(struct cm_rep_msg *rep_msg) |
| 618 | { |
| 619 | return (u8) ((rep_msg->offset27 >> 4) & 0x1); |
| 620 | } |
| 621 | |
| 622 | static inline void cm_rep_set_srq(struct cm_rep_msg *rep_msg, u8 srq) |
| 623 | { |
| 624 | rep_msg->offset27 = (u8) ((rep_msg->offset27 & 0xEF) | |
| 625 | ((srq & 0x1) << 4)); |
| 626 | } |
| 627 | |
| 628 | struct cm_rtu_msg { |
| 629 | struct ib_mad_hdr hdr; |
| 630 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 631 | __be32 local_comm_id; |
| 632 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 633 | |
| 634 | u8 private_data[IB_CM_RTU_PRIVATE_DATA_SIZE]; |
| 635 | |
| 636 | } __attribute__ ((packed)); |
| 637 | |
| 638 | struct cm_dreq_msg { |
| 639 | struct ib_mad_hdr hdr; |
| 640 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 641 | __be32 local_comm_id; |
| 642 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 643 | /* remote QPN/EECN:24, rsvd:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 644 | __be32 offset8; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 645 | |
| 646 | u8 private_data[IB_CM_DREQ_PRIVATE_DATA_SIZE]; |
| 647 | |
| 648 | } __attribute__ ((packed)); |
| 649 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 650 | static inline __be32 cm_dreq_get_remote_qpn(struct cm_dreq_msg *dreq_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 651 | { |
| 652 | return cpu_to_be32(be32_to_cpu(dreq_msg->offset8) >> 8); |
| 653 | } |
| 654 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 655 | static inline void cm_dreq_set_remote_qpn(struct cm_dreq_msg *dreq_msg, __be32 qpn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 656 | { |
| 657 | dreq_msg->offset8 = cpu_to_be32((be32_to_cpu(qpn) << 8) | |
| 658 | (be32_to_cpu(dreq_msg->offset8) & 0x000000FF)); |
| 659 | } |
| 660 | |
| 661 | struct cm_drep_msg { |
| 662 | struct ib_mad_hdr hdr; |
| 663 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 664 | __be32 local_comm_id; |
| 665 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 666 | |
| 667 | u8 private_data[IB_CM_DREP_PRIVATE_DATA_SIZE]; |
| 668 | |
| 669 | } __attribute__ ((packed)); |
| 670 | |
| 671 | struct cm_lap_msg { |
| 672 | struct ib_mad_hdr hdr; |
| 673 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 674 | __be32 local_comm_id; |
| 675 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 676 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 677 | __be32 rsvd8; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 678 | /* remote QPN/EECN:24, remote CM response timeout:5, rsvd:3 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 679 | __be32 offset12; |
| 680 | __be32 rsvd16; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 681 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 682 | __be16 alt_local_lid; |
| 683 | __be16 alt_remote_lid; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 684 | union ib_gid alt_local_gid; |
| 685 | union ib_gid alt_remote_gid; |
| 686 | /* flow label:20, rsvd:4, traffic class:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 687 | __be32 offset56; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 688 | u8 alt_hop_limit; |
| 689 | /* rsvd:2, packet rate:6 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 690 | u8 offset61; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 691 | /* SL:4, subnet local:1, rsvd:3 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 692 | u8 offset62; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 693 | /* local ACK timeout:5, rsvd:3 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 694 | u8 offset63; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 695 | |
| 696 | u8 private_data[IB_CM_LAP_PRIVATE_DATA_SIZE]; |
| 697 | } __attribute__ ((packed)); |
| 698 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 699 | static inline __be32 cm_lap_get_remote_qpn(struct cm_lap_msg *lap_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 700 | { |
| 701 | return cpu_to_be32(be32_to_cpu(lap_msg->offset12) >> 8); |
| 702 | } |
| 703 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 704 | static inline void cm_lap_set_remote_qpn(struct cm_lap_msg *lap_msg, __be32 qpn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 705 | { |
| 706 | lap_msg->offset12 = cpu_to_be32((be32_to_cpu(qpn) << 8) | |
| 707 | (be32_to_cpu(lap_msg->offset12) & |
| 708 | 0x000000FF)); |
| 709 | } |
| 710 | |
| 711 | static inline u8 cm_lap_get_remote_resp_timeout(struct cm_lap_msg *lap_msg) |
| 712 | { |
| 713 | return (u8) ((be32_to_cpu(lap_msg->offset12) & 0xF8) >> 3); |
| 714 | } |
| 715 | |
| 716 | static inline void cm_lap_set_remote_resp_timeout(struct cm_lap_msg *lap_msg, |
| 717 | u8 resp_timeout) |
| 718 | { |
| 719 | lap_msg->offset12 = cpu_to_be32((resp_timeout << 3) | |
| 720 | (be32_to_cpu(lap_msg->offset12) & |
| 721 | 0xFFFFFF07)); |
| 722 | } |
| 723 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 724 | static inline __be32 cm_lap_get_flow_label(struct cm_lap_msg *lap_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 725 | { |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 726 | return cpu_to_be32(be32_to_cpu(lap_msg->offset56) >> 12); |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | static inline void cm_lap_set_flow_label(struct cm_lap_msg *lap_msg, |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 730 | __be32 flow_label) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 731 | { |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 732 | lap_msg->offset56 = cpu_to_be32( |
| 733 | (be32_to_cpu(lap_msg->offset56) & 0x00000FFF) | |
| 734 | (be32_to_cpu(flow_label) << 12)); |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | static inline u8 cm_lap_get_traffic_class(struct cm_lap_msg *lap_msg) |
| 738 | { |
| 739 | return (u8) be32_to_cpu(lap_msg->offset56); |
| 740 | } |
| 741 | |
| 742 | static inline void cm_lap_set_traffic_class(struct cm_lap_msg *lap_msg, |
| 743 | u8 traffic_class) |
| 744 | { |
| 745 | lap_msg->offset56 = cpu_to_be32(traffic_class | |
| 746 | (be32_to_cpu(lap_msg->offset56) & |
| 747 | 0xFFFFFF00)); |
| 748 | } |
| 749 | |
| 750 | static inline u8 cm_lap_get_packet_rate(struct cm_lap_msg *lap_msg) |
| 751 | { |
| 752 | return lap_msg->offset61 & 0x3F; |
| 753 | } |
| 754 | |
| 755 | static inline void cm_lap_set_packet_rate(struct cm_lap_msg *lap_msg, |
| 756 | u8 packet_rate) |
| 757 | { |
| 758 | lap_msg->offset61 = (packet_rate & 0x3F) | (lap_msg->offset61 & 0xC0); |
| 759 | } |
| 760 | |
| 761 | static inline u8 cm_lap_get_sl(struct cm_lap_msg *lap_msg) |
| 762 | { |
| 763 | return lap_msg->offset62 >> 4; |
| 764 | } |
| 765 | |
| 766 | static inline void cm_lap_set_sl(struct cm_lap_msg *lap_msg, u8 sl) |
| 767 | { |
| 768 | lap_msg->offset62 = (sl << 4) | (lap_msg->offset62 & 0x0F); |
| 769 | } |
| 770 | |
| 771 | static inline u8 cm_lap_get_subnet_local(struct cm_lap_msg *lap_msg) |
| 772 | { |
| 773 | return (lap_msg->offset62 >> 3) & 0x1; |
| 774 | } |
| 775 | |
| 776 | static inline void cm_lap_set_subnet_local(struct cm_lap_msg *lap_msg, |
| 777 | u8 subnet_local) |
| 778 | { |
| 779 | lap_msg->offset62 = ((subnet_local & 0x1) << 3) | |
| 780 | (lap_msg->offset61 & 0xF7); |
| 781 | } |
| 782 | static inline u8 cm_lap_get_local_ack_timeout(struct cm_lap_msg *lap_msg) |
| 783 | { |
| 784 | return lap_msg->offset63 >> 3; |
| 785 | } |
| 786 | |
| 787 | static inline void cm_lap_set_local_ack_timeout(struct cm_lap_msg *lap_msg, |
| 788 | u8 local_ack_timeout) |
| 789 | { |
| 790 | lap_msg->offset63 = (local_ack_timeout << 3) | |
| 791 | (lap_msg->offset63 & 0x07); |
| 792 | } |
| 793 | |
| 794 | struct cm_apr_msg { |
| 795 | struct ib_mad_hdr hdr; |
| 796 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 797 | __be32 local_comm_id; |
| 798 | __be32 remote_comm_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 799 | |
| 800 | u8 info_length; |
| 801 | u8 ap_status; |
| 802 | u8 info[IB_CM_APR_INFO_LENGTH]; |
| 803 | |
| 804 | u8 private_data[IB_CM_APR_PRIVATE_DATA_SIZE]; |
| 805 | } __attribute__ ((packed)); |
| 806 | |
| 807 | struct cm_sidr_req_msg { |
| 808 | struct ib_mad_hdr hdr; |
| 809 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 810 | __be32 request_id; |
| 811 | __be16 pkey; |
| 812 | __be16 rsvd; |
| 813 | __be64 service_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 814 | |
| 815 | u8 private_data[IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE]; |
| 816 | } __attribute__ ((packed)); |
| 817 | |
| 818 | struct cm_sidr_rep_msg { |
| 819 | struct ib_mad_hdr hdr; |
| 820 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 821 | __be32 request_id; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 822 | u8 status; |
| 823 | u8 info_length; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 824 | __be16 rsvd; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 825 | /* QPN:24, rsvd:8 */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 826 | __be32 offset8; |
| 827 | __be64 service_id; |
| 828 | __be32 qkey; |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 829 | u8 info[IB_CM_SIDR_REP_INFO_LENGTH]; |
| 830 | |
| 831 | u8 private_data[IB_CM_SIDR_REP_PRIVATE_DATA_SIZE]; |
| 832 | } __attribute__ ((packed)); |
| 833 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 834 | static inline __be32 cm_sidr_rep_get_qpn(struct cm_sidr_rep_msg *sidr_rep_msg) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 835 | { |
| 836 | return cpu_to_be32(be32_to_cpu(sidr_rep_msg->offset8) >> 8); |
| 837 | } |
| 838 | |
| 839 | static inline void cm_sidr_rep_set_qpn(struct cm_sidr_rep_msg *sidr_rep_msg, |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 840 | __be32 qpn) |
Hal Rosenstock | a977049 | 2005-07-27 11:45:40 -0700 | [diff] [blame] | 841 | { |
| 842 | sidr_rep_msg->offset8 = cpu_to_be32((be32_to_cpu(qpn) << 8) | |
| 843 | (be32_to_cpu(sidr_rep_msg->offset8) & |
| 844 | 0x000000FF)); |
| 845 | } |
| 846 | |
| 847 | #endif /* CM_MSGS_H */ |