]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/infiniband/core/cm_msgs.h
infiniband: remove dev_base_lock use
[net-next-2.6.git] / drivers / infiniband / core / cm_msgs.h
CommitLineData
a977049d
HR
1/*
2 * Copyright (c) 2004 Intel Corporation. All rights reserved.
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
a4d61e84 37#include <rdma/ib_mad.h>
5d861be8 38#include <rdma/ib_cm.h>
a977049d
HR
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
9c3da099
HH
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)
a977049d
HR
58
59enum 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
66struct cm_req_msg {
67 struct ib_mad_hdr hdr;
68
97f52eb4
SH
69 __be32 local_comm_id;
70 __be32 rsvd4;
71 __be64 service_id;
72 __be64 local_ca_guid;
73 __be32 rsvd24;
74 __be32 local_qkey;
a977049d 75 /* local QPN:24, responder resources:8 */
97f52eb4 76 __be32 offset32;
a977049d 77 /* local EECN:24, initiator depth:8 */
97f52eb4 78 __be32 offset36;
a977049d
HR
79 /*
80 * remote EECN:24, remote CM response timeout:5,
81 * transport service type:2, end-to-end flow control:1
82 */
97f52eb4 83 __be32 offset40;
a977049d 84 /* starting PSN:24, local CM response timeout:5, retry count:3 */
97f52eb4
SH
85 __be32 offset44;
86 __be16 pkey;
a977049d
HR
87 /* path MTU:4, RDC exists:1, RNR retry count:3. */
88 u8 offset50;
89 /* max CM Retries:4, SRQ:1, rsvd:3 */
90 u8 offset51;
91
97f52eb4
SH
92 __be16 primary_local_lid;
93 __be16 primary_remote_lid;
a977049d
HR
94 union ib_gid primary_local_gid;
95 union ib_gid primary_remote_gid;
96 /* flow label:20, rsvd:6, packet rate:6 */
97f52eb4 97 __be32 primary_offset88;
a977049d
HR
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
97f52eb4
SH
105 __be16 alt_local_lid;
106 __be16 alt_remote_lid;
a977049d
HR
107 union ib_gid alt_local_gid;
108 union ib_gid alt_remote_gid;
109 /* flow label:20, rsvd:6, packet rate:6 */
97f52eb4 110 __be32 alt_offset132;
a977049d
HR
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
97f52eb4 122static inline __be32 cm_req_get_local_qpn(struct cm_req_msg *req_msg)
a977049d
HR
123{
124 return cpu_to_be32(be32_to_cpu(req_msg->offset32) >> 8);
125}
126
97f52eb4 127static inline void cm_req_set_local_qpn(struct cm_req_msg *req_msg, __be32 qpn)
a977049d
HR
128{
129 req_msg->offset32 = cpu_to_be32((be32_to_cpu(qpn) << 8) |
130 (be32_to_cpu(req_msg->offset32) &
131 0x000000FF));
132}
133
134static 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
139static 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
146static 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
151static 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
159static 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
164static 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
172static 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;
178 default: return 0;
179 }
180}
181
182static inline void cm_req_set_qp_type(struct cm_req_msg *req_msg,
183 enum ib_qp_type qp_type)
184{
185 switch(qp_type) {
186 case IB_QPT_UC:
187 req_msg->offset40 = cpu_to_be32((be32_to_cpu(
188 req_msg->offset40) &
189 0xFFFFFFF9) | 0x2);
3910f44d 190 break;
a977049d
HR
191 default:
192 req_msg->offset40 = cpu_to_be32(be32_to_cpu(
193 req_msg->offset40) &
194 0xFFFFFFF9);
195 }
196}
197
198static inline u8 cm_req_get_flow_ctrl(struct cm_req_msg *req_msg)
199{
200 return be32_to_cpu(req_msg->offset40) & 0x1;
201}
202
203static inline void cm_req_set_flow_ctrl(struct cm_req_msg *req_msg,
204 u8 flow_ctrl)
205{
206 req_msg->offset40 = cpu_to_be32((flow_ctrl & 0x1) |
207 (be32_to_cpu(req_msg->offset40) &
208 0xFFFFFFFE));
209}
210
97f52eb4 211static inline __be32 cm_req_get_starting_psn(struct cm_req_msg *req_msg)
a977049d
HR
212{
213 return cpu_to_be32(be32_to_cpu(req_msg->offset44) >> 8);
214}
215
216static inline void cm_req_set_starting_psn(struct cm_req_msg *req_msg,
97f52eb4 217 __be32 starting_psn)
a977049d
HR
218{
219 req_msg->offset44 = cpu_to_be32((be32_to_cpu(starting_psn) << 8) |
220 (be32_to_cpu(req_msg->offset44) & 0x000000FF));
221}
222
223static inline u8 cm_req_get_local_resp_timeout(struct cm_req_msg *req_msg)
224{
225 return (u8) ((be32_to_cpu(req_msg->offset44) & 0xF8) >> 3);
226}
227
228static inline void cm_req_set_local_resp_timeout(struct cm_req_msg *req_msg,
229 u8 resp_timeout)
230{
231 req_msg->offset44 = cpu_to_be32((resp_timeout << 3) |
232 (be32_to_cpu(req_msg->offset44) & 0xFFFFFF07));
233}
234
235static inline u8 cm_req_get_retry_count(struct cm_req_msg *req_msg)
236{
237 return (u8) (be32_to_cpu(req_msg->offset44) & 0x7);
238}
239
240static inline void cm_req_set_retry_count(struct cm_req_msg *req_msg,
241 u8 retry_count)
242{
243 req_msg->offset44 = cpu_to_be32((retry_count & 0x7) |
244 (be32_to_cpu(req_msg->offset44) & 0xFFFFFFF8));
245}
246
247static inline u8 cm_req_get_path_mtu(struct cm_req_msg *req_msg)
248{
249 return req_msg->offset50 >> 4;
250}
251
252static inline void cm_req_set_path_mtu(struct cm_req_msg *req_msg, u8 path_mtu)
253{
254 req_msg->offset50 = (u8) ((req_msg->offset50 & 0xF) | (path_mtu << 4));
255}
256
257static inline u8 cm_req_get_rnr_retry_count(struct cm_req_msg *req_msg)
258{
259 return req_msg->offset50 & 0x7;
260}
261
262static inline void cm_req_set_rnr_retry_count(struct cm_req_msg *req_msg,
263 u8 rnr_retry_count)
264{
265 req_msg->offset50 = (u8) ((req_msg->offset50 & 0xF8) |
266 (rnr_retry_count & 0x7));
267}
268
269static inline u8 cm_req_get_max_cm_retries(struct cm_req_msg *req_msg)
270{
271 return req_msg->offset51 >> 4;
272}
273
274static inline void cm_req_set_max_cm_retries(struct cm_req_msg *req_msg,
275 u8 retries)
276{
277 req_msg->offset51 = (u8) ((req_msg->offset51 & 0xF) | (retries << 4));
278}
279
280static inline u8 cm_req_get_srq(struct cm_req_msg *req_msg)
281{
282 return (req_msg->offset51 & 0x8) >> 3;
283}
284
285static inline void cm_req_set_srq(struct cm_req_msg *req_msg, u8 srq)
286{
287 req_msg->offset51 = (u8) ((req_msg->offset51 & 0xF7) |
288 ((srq & 0x1) << 3));
289}
290
97f52eb4 291static inline __be32 cm_req_get_primary_flow_label(struct cm_req_msg *req_msg)
a977049d 292{
97f52eb4 293 return cpu_to_be32(be32_to_cpu(req_msg->primary_offset88) >> 12);
a977049d
HR
294}
295
296static inline void cm_req_set_primary_flow_label(struct cm_req_msg *req_msg,
97f52eb4 297 __be32 flow_label)
a977049d
HR
298{
299 req_msg->primary_offset88 = cpu_to_be32(
300 (be32_to_cpu(req_msg->primary_offset88) &
301 0x00000FFF) |
302 (be32_to_cpu(flow_label) << 12));
303}
304
305static inline u8 cm_req_get_primary_packet_rate(struct cm_req_msg *req_msg)
306{
307 return (u8) (be32_to_cpu(req_msg->primary_offset88) & 0x3F);
308}
309
310static inline void cm_req_set_primary_packet_rate(struct cm_req_msg *req_msg,
311 u8 rate)
312{
313 req_msg->primary_offset88 = cpu_to_be32(
314 (be32_to_cpu(req_msg->primary_offset88) &
315 0xFFFFFFC0) | (rate & 0x3F));
316}
317
318static inline u8 cm_req_get_primary_sl(struct cm_req_msg *req_msg)
319{
320 return (u8) (req_msg->primary_offset94 >> 4);
321}
322
323static inline void cm_req_set_primary_sl(struct cm_req_msg *req_msg, u8 sl)
324{
325 req_msg->primary_offset94 = (u8) ((req_msg->primary_offset94 & 0x0F) |
326 (sl << 4));
327}
328
329static inline u8 cm_req_get_primary_subnet_local(struct cm_req_msg *req_msg)
330{
331 return (u8) ((req_msg->primary_offset94 & 0x08) >> 3);
332}
333
334static inline void cm_req_set_primary_subnet_local(struct cm_req_msg *req_msg,
335 u8 subnet_local)
336{
337 req_msg->primary_offset94 = (u8) ((req_msg->primary_offset94 & 0xF7) |
338 ((subnet_local & 0x1) << 3));
339}
340
341static inline u8 cm_req_get_primary_local_ack_timeout(struct cm_req_msg *req_msg)
342{
343 return (u8) (req_msg->primary_offset95 >> 3);
344}
345
346static inline void cm_req_set_primary_local_ack_timeout(struct cm_req_msg *req_msg,
347 u8 local_ack_timeout)
348{
349 req_msg->primary_offset95 = (u8) ((req_msg->primary_offset95 & 0x07) |
350 (local_ack_timeout << 3));
351}
352
97f52eb4 353static inline __be32 cm_req_get_alt_flow_label(struct cm_req_msg *req_msg)
a977049d 354{
97f52eb4 355 return cpu_to_be32(be32_to_cpu(req_msg->alt_offset132) >> 12);
a977049d
HR
356}
357
358static inline void cm_req_set_alt_flow_label(struct cm_req_msg *req_msg,
97f52eb4 359 __be32 flow_label)
a977049d
HR
360{
361 req_msg->alt_offset132 = cpu_to_be32(
362 (be32_to_cpu(req_msg->alt_offset132) &
363 0x00000FFF) |
364 (be32_to_cpu(flow_label) << 12));
365}
366
367static inline u8 cm_req_get_alt_packet_rate(struct cm_req_msg *req_msg)
368{
369 return (u8) (be32_to_cpu(req_msg->alt_offset132) & 0x3F);
370}
371
372static inline void cm_req_set_alt_packet_rate(struct cm_req_msg *req_msg,
373 u8 rate)
374{
375 req_msg->alt_offset132 = cpu_to_be32(
376 (be32_to_cpu(req_msg->alt_offset132) &
377 0xFFFFFFC0) | (rate & 0x3F));
378}
379
380static inline u8 cm_req_get_alt_sl(struct cm_req_msg *req_msg)
381{
382 return (u8) (req_msg->alt_offset138 >> 4);
383}
384
385static inline void cm_req_set_alt_sl(struct cm_req_msg *req_msg, u8 sl)
386{
387 req_msg->alt_offset138 = (u8) ((req_msg->alt_offset138 & 0x0F) |
388 (sl << 4));
389}
390
391static inline u8 cm_req_get_alt_subnet_local(struct cm_req_msg *req_msg)
392{
393 return (u8) ((req_msg->alt_offset138 & 0x08) >> 3);
394}
395
396static inline void cm_req_set_alt_subnet_local(struct cm_req_msg *req_msg,
397 u8 subnet_local)
398{
399 req_msg->alt_offset138 = (u8) ((req_msg->alt_offset138 & 0xF7) |
400 ((subnet_local & 0x1) << 3));
401}
402
403static inline u8 cm_req_get_alt_local_ack_timeout(struct cm_req_msg *req_msg)
404{
405 return (u8) (req_msg->alt_offset139 >> 3);
406}
407
408static inline void cm_req_set_alt_local_ack_timeout(struct cm_req_msg *req_msg,
409 u8 local_ack_timeout)
410{
411 req_msg->alt_offset139 = (u8) ((req_msg->alt_offset139 & 0x07) |
412 (local_ack_timeout << 3));
413}
414
415/* Message REJected or MRAed */
416enum cm_msg_response {
417 CM_MSG_RESPONSE_REQ = 0x0,
418 CM_MSG_RESPONSE_REP = 0x1,
419 CM_MSG_RESPONSE_OTHER = 0x2
420};
421
422 struct cm_mra_msg {
423 struct ib_mad_hdr hdr;
424
97f52eb4
SH
425 __be32 local_comm_id;
426 __be32 remote_comm_id;
a977049d
HR
427 /* message MRAed:2, rsvd:6 */
428 u8 offset8;
429 /* service timeout:5, rsvd:3 */
430 u8 offset9;
431
432 u8 private_data[IB_CM_MRA_PRIVATE_DATA_SIZE];
433
434} __attribute__ ((packed));
435
436static inline u8 cm_mra_get_msg_mraed(struct cm_mra_msg *mra_msg)
437{
438 return (u8) (mra_msg->offset8 >> 6);
439}
440
441static inline void cm_mra_set_msg_mraed(struct cm_mra_msg *mra_msg, u8 msg)
442{
443 mra_msg->offset8 = (u8) ((mra_msg->offset8 & 0x3F) | (msg << 6));
444}
445
446static inline u8 cm_mra_get_service_timeout(struct cm_mra_msg *mra_msg)
447{
448 return (u8) (mra_msg->offset9 >> 3);
449}
450
451static inline void cm_mra_set_service_timeout(struct cm_mra_msg *mra_msg,
452 u8 service_timeout)
453{
454 mra_msg->offset9 = (u8) ((mra_msg->offset9 & 0x07) |
455 (service_timeout << 3));
456}
457
458struct cm_rej_msg {
459 struct ib_mad_hdr hdr;
460
97f52eb4
SH
461 __be32 local_comm_id;
462 __be32 remote_comm_id;
a977049d
HR
463 /* message REJected:2, rsvd:6 */
464 u8 offset8;
465 /* reject info length:7, rsvd:1. */
466 u8 offset9;
97f52eb4 467 __be16 reason;
a977049d
HR
468 u8 ari[IB_CM_REJ_ARI_LENGTH];
469
470 u8 private_data[IB_CM_REJ_PRIVATE_DATA_SIZE];
471
472} __attribute__ ((packed));
473
474static inline u8 cm_rej_get_msg_rejected(struct cm_rej_msg *rej_msg)
475{
476 return (u8) (rej_msg->offset8 >> 6);
477}
478
479static inline void cm_rej_set_msg_rejected(struct cm_rej_msg *rej_msg, u8 msg)
480{
481 rej_msg->offset8 = (u8) ((rej_msg->offset8 & 0x3F) | (msg << 6));
482}
483
484static inline u8 cm_rej_get_reject_info_len(struct cm_rej_msg *rej_msg)
485{
486 return (u8) (rej_msg->offset9 >> 1);
487}
488
489static inline void cm_rej_set_reject_info_len(struct cm_rej_msg *rej_msg,
490 u8 len)
491{
492 rej_msg->offset9 = (u8) ((rej_msg->offset9 & 0x1) | (len << 1));
493}
494
495struct cm_rep_msg {
496 struct ib_mad_hdr hdr;
497
97f52eb4
SH
498 __be32 local_comm_id;
499 __be32 remote_comm_id;
500 __be32 local_qkey;
a977049d 501 /* local QPN:24, rsvd:8 */
97f52eb4 502 __be32 offset12;
a977049d 503 /* local EECN:24, rsvd:8 */
97f52eb4 504 __be32 offset16;
a977049d 505 /* starting PSN:24 rsvd:8 */
97f52eb4 506 __be32 offset20;
a977049d
HR
507 u8 resp_resources;
508 u8 initiator_depth;
509 /* target ACK delay:5, failover accepted:2, end-to-end flow control:1 */
510 u8 offset26;
511 /* RNR retry count:3, SRQ:1, rsvd:5 */
512 u8 offset27;
97f52eb4 513 __be64 local_ca_guid;
a977049d
HR
514
515 u8 private_data[IB_CM_REP_PRIVATE_DATA_SIZE];
516
517} __attribute__ ((packed));
518
97f52eb4 519static inline __be32 cm_rep_get_local_qpn(struct cm_rep_msg *rep_msg)
a977049d
HR
520{
521 return cpu_to_be32(be32_to_cpu(rep_msg->offset12) >> 8);
522}
523
97f52eb4 524static inline void cm_rep_set_local_qpn(struct cm_rep_msg *rep_msg, __be32 qpn)
a977049d
HR
525{
526 rep_msg->offset12 = cpu_to_be32((be32_to_cpu(qpn) << 8) |
527 (be32_to_cpu(rep_msg->offset12) & 0x000000FF));
528}
529
97f52eb4 530static inline __be32 cm_rep_get_starting_psn(struct cm_rep_msg *rep_msg)
a977049d
HR
531{
532 return cpu_to_be32(be32_to_cpu(rep_msg->offset20) >> 8);
533}
534
535static inline void cm_rep_set_starting_psn(struct cm_rep_msg *rep_msg,
97f52eb4 536 __be32 starting_psn)
a977049d
HR
537{
538 rep_msg->offset20 = cpu_to_be32((be32_to_cpu(starting_psn) << 8) |
539 (be32_to_cpu(rep_msg->offset20) & 0x000000FF));
540}
541
542static inline u8 cm_rep_get_target_ack_delay(struct cm_rep_msg *rep_msg)
543{
544 return (u8) (rep_msg->offset26 >> 3);
545}
546
547static inline void cm_rep_set_target_ack_delay(struct cm_rep_msg *rep_msg,
548 u8 target_ack_delay)
549{
550 rep_msg->offset26 = (u8) ((rep_msg->offset26 & 0x07) |
551 (target_ack_delay << 3));
552}
553
554static inline u8 cm_rep_get_failover(struct cm_rep_msg *rep_msg)
555{
556 return (u8) ((rep_msg->offset26 & 0x06) >> 1);
557}
558
559static inline void cm_rep_set_failover(struct cm_rep_msg *rep_msg, u8 failover)
560{
561 rep_msg->offset26 = (u8) ((rep_msg->offset26 & 0xF9) |
562 ((failover & 0x3) << 1));
563}
564
565static inline u8 cm_rep_get_flow_ctrl(struct cm_rep_msg *rep_msg)
566{
567 return (u8) (rep_msg->offset26 & 0x01);
568}
569
570static inline void cm_rep_set_flow_ctrl(struct cm_rep_msg *rep_msg,
571 u8 flow_ctrl)
572{
573 rep_msg->offset26 = (u8) ((rep_msg->offset26 & 0xFE) |
574 (flow_ctrl & 0x1));
575}
576
577static inline u8 cm_rep_get_rnr_retry_count(struct cm_rep_msg *rep_msg)
578{
579 return (u8) (rep_msg->offset27 >> 5);
580}
581
582static inline void cm_rep_set_rnr_retry_count(struct cm_rep_msg *rep_msg,
583 u8 rnr_retry_count)
584{
585 rep_msg->offset27 = (u8) ((rep_msg->offset27 & 0x1F) |
586 (rnr_retry_count << 5));
587}
588
589static inline u8 cm_rep_get_srq(struct cm_rep_msg *rep_msg)
590{
591 return (u8) ((rep_msg->offset27 >> 4) & 0x1);
592}
593
594static inline void cm_rep_set_srq(struct cm_rep_msg *rep_msg, u8 srq)
595{
596 rep_msg->offset27 = (u8) ((rep_msg->offset27 & 0xEF) |
597 ((srq & 0x1) << 4));
598}
599
600struct cm_rtu_msg {
601 struct ib_mad_hdr hdr;
602
97f52eb4
SH
603 __be32 local_comm_id;
604 __be32 remote_comm_id;
a977049d
HR
605
606 u8 private_data[IB_CM_RTU_PRIVATE_DATA_SIZE];
607
608} __attribute__ ((packed));
609
610struct cm_dreq_msg {
611 struct ib_mad_hdr hdr;
612
97f52eb4
SH
613 __be32 local_comm_id;
614 __be32 remote_comm_id;
a977049d 615 /* remote QPN/EECN:24, rsvd:8 */
97f52eb4 616 __be32 offset8;
a977049d
HR
617
618 u8 private_data[IB_CM_DREQ_PRIVATE_DATA_SIZE];
619
620} __attribute__ ((packed));
621
97f52eb4 622static inline __be32 cm_dreq_get_remote_qpn(struct cm_dreq_msg *dreq_msg)
a977049d
HR
623{
624 return cpu_to_be32(be32_to_cpu(dreq_msg->offset8) >> 8);
625}
626
97f52eb4 627static inline void cm_dreq_set_remote_qpn(struct cm_dreq_msg *dreq_msg, __be32 qpn)
a977049d
HR
628{
629 dreq_msg->offset8 = cpu_to_be32((be32_to_cpu(qpn) << 8) |
630 (be32_to_cpu(dreq_msg->offset8) & 0x000000FF));
631}
632
633struct cm_drep_msg {
634 struct ib_mad_hdr hdr;
635
97f52eb4
SH
636 __be32 local_comm_id;
637 __be32 remote_comm_id;
a977049d
HR
638
639 u8 private_data[IB_CM_DREP_PRIVATE_DATA_SIZE];
640
641} __attribute__ ((packed));
642
643struct cm_lap_msg {
644 struct ib_mad_hdr hdr;
645
97f52eb4
SH
646 __be32 local_comm_id;
647 __be32 remote_comm_id;
a977049d 648
97f52eb4 649 __be32 rsvd8;
a977049d 650 /* remote QPN/EECN:24, remote CM response timeout:5, rsvd:3 */
97f52eb4
SH
651 __be32 offset12;
652 __be32 rsvd16;
a977049d 653
97f52eb4
SH
654 __be16 alt_local_lid;
655 __be16 alt_remote_lid;
a977049d
HR
656 union ib_gid alt_local_gid;
657 union ib_gid alt_remote_gid;
658 /* flow label:20, rsvd:4, traffic class:8 */
97f52eb4 659 __be32 offset56;
a977049d
HR
660 u8 alt_hop_limit;
661 /* rsvd:2, packet rate:6 */
97f52eb4 662 u8 offset61;
a977049d 663 /* SL:4, subnet local:1, rsvd:3 */
97f52eb4 664 u8 offset62;
a977049d 665 /* local ACK timeout:5, rsvd:3 */
97f52eb4 666 u8 offset63;
a977049d
HR
667
668 u8 private_data[IB_CM_LAP_PRIVATE_DATA_SIZE];
669} __attribute__ ((packed));
670
97f52eb4 671static inline __be32 cm_lap_get_remote_qpn(struct cm_lap_msg *lap_msg)
a977049d
HR
672{
673 return cpu_to_be32(be32_to_cpu(lap_msg->offset12) >> 8);
674}
675
97f52eb4 676static inline void cm_lap_set_remote_qpn(struct cm_lap_msg *lap_msg, __be32 qpn)
a977049d
HR
677{
678 lap_msg->offset12 = cpu_to_be32((be32_to_cpu(qpn) << 8) |
679 (be32_to_cpu(lap_msg->offset12) &
680 0x000000FF));
681}
682
683static inline u8 cm_lap_get_remote_resp_timeout(struct cm_lap_msg *lap_msg)
684{
685 return (u8) ((be32_to_cpu(lap_msg->offset12) & 0xF8) >> 3);
686}
687
688static inline void cm_lap_set_remote_resp_timeout(struct cm_lap_msg *lap_msg,
689 u8 resp_timeout)
690{
691 lap_msg->offset12 = cpu_to_be32((resp_timeout << 3) |
692 (be32_to_cpu(lap_msg->offset12) &
693 0xFFFFFF07));
694}
695
97f52eb4 696static inline __be32 cm_lap_get_flow_label(struct cm_lap_msg *lap_msg)
a977049d 697{
97f52eb4 698 return cpu_to_be32(be32_to_cpu(lap_msg->offset56) >> 12);
a977049d
HR
699}
700
701static inline void cm_lap_set_flow_label(struct cm_lap_msg *lap_msg,
97f52eb4 702 __be32 flow_label)
a977049d 703{
97f52eb4
SH
704 lap_msg->offset56 = cpu_to_be32(
705 (be32_to_cpu(lap_msg->offset56) & 0x00000FFF) |
706 (be32_to_cpu(flow_label) << 12));
a977049d
HR
707}
708
709static inline u8 cm_lap_get_traffic_class(struct cm_lap_msg *lap_msg)
710{
711 return (u8) be32_to_cpu(lap_msg->offset56);
712}
713
714static inline void cm_lap_set_traffic_class(struct cm_lap_msg *lap_msg,
715 u8 traffic_class)
716{
717 lap_msg->offset56 = cpu_to_be32(traffic_class |
718 (be32_to_cpu(lap_msg->offset56) &
719 0xFFFFFF00));
720}
721
722static inline u8 cm_lap_get_packet_rate(struct cm_lap_msg *lap_msg)
723{
724 return lap_msg->offset61 & 0x3F;
725}
726
727static inline void cm_lap_set_packet_rate(struct cm_lap_msg *lap_msg,
728 u8 packet_rate)
729{
730 lap_msg->offset61 = (packet_rate & 0x3F) | (lap_msg->offset61 & 0xC0);
731}
732
733static inline u8 cm_lap_get_sl(struct cm_lap_msg *lap_msg)
734{
735 return lap_msg->offset62 >> 4;
736}
737
738static inline void cm_lap_set_sl(struct cm_lap_msg *lap_msg, u8 sl)
739{
740 lap_msg->offset62 = (sl << 4) | (lap_msg->offset62 & 0x0F);
741}
742
743static inline u8 cm_lap_get_subnet_local(struct cm_lap_msg *lap_msg)
744{
745 return (lap_msg->offset62 >> 3) & 0x1;
746}
747
748static inline void cm_lap_set_subnet_local(struct cm_lap_msg *lap_msg,
749 u8 subnet_local)
750{
751 lap_msg->offset62 = ((subnet_local & 0x1) << 3) |
752 (lap_msg->offset61 & 0xF7);
753}
754static inline u8 cm_lap_get_local_ack_timeout(struct cm_lap_msg *lap_msg)
755{
756 return lap_msg->offset63 >> 3;
757}
758
759static inline void cm_lap_set_local_ack_timeout(struct cm_lap_msg *lap_msg,
760 u8 local_ack_timeout)
761{
762 lap_msg->offset63 = (local_ack_timeout << 3) |
763 (lap_msg->offset63 & 0x07);
764}
765
766struct cm_apr_msg {
767 struct ib_mad_hdr hdr;
768
97f52eb4
SH
769 __be32 local_comm_id;
770 __be32 remote_comm_id;
a977049d
HR
771
772 u8 info_length;
773 u8 ap_status;
774 u8 info[IB_CM_APR_INFO_LENGTH];
775
776 u8 private_data[IB_CM_APR_PRIVATE_DATA_SIZE];
777} __attribute__ ((packed));
778
779struct cm_sidr_req_msg {
780 struct ib_mad_hdr hdr;
781
97f52eb4
SH
782 __be32 request_id;
783 __be16 pkey;
784 __be16 rsvd;
785 __be64 service_id;
a977049d
HR
786
787 u8 private_data[IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE];
788} __attribute__ ((packed));
789
790struct cm_sidr_rep_msg {
791 struct ib_mad_hdr hdr;
792
97f52eb4 793 __be32 request_id;
a977049d
HR
794 u8 status;
795 u8 info_length;
97f52eb4 796 __be16 rsvd;
a977049d 797 /* QPN:24, rsvd:8 */
97f52eb4
SH
798 __be32 offset8;
799 __be64 service_id;
800 __be32 qkey;
a977049d
HR
801 u8 info[IB_CM_SIDR_REP_INFO_LENGTH];
802
803 u8 private_data[IB_CM_SIDR_REP_PRIVATE_DATA_SIZE];
804} __attribute__ ((packed));
805
97f52eb4 806static inline __be32 cm_sidr_rep_get_qpn(struct cm_sidr_rep_msg *sidr_rep_msg)
a977049d
HR
807{
808 return cpu_to_be32(be32_to_cpu(sidr_rep_msg->offset8) >> 8);
809}
810
811static inline void cm_sidr_rep_set_qpn(struct cm_sidr_rep_msg *sidr_rep_msg,
97f52eb4 812 __be32 qpn)
a977049d
HR
813{
814 sidr_rep_msg->offset8 = cpu_to_be32((be32_to_cpu(qpn) << 8) |
815 (be32_to_cpu(sidr_rep_msg->offset8) &
816 0x000000FF));
817}
818
819#endif /* CM_MSGS_H */