2 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
3 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 /* extracted information about a packet carried in an sk_buff struct fits in
38 * the skbuff cb array. Must be at most 48 bytes. stored in control block of
39 * sk_buff for received packets.
42 struct rxe_dev
*rxe
; /* device that owns packet */
43 struct rxe_qp
*qp
; /* qp that owns packet */
44 struct rxe_send_wqe
*wqe
; /* send wqe */
45 u8
*hdr
; /* points to bth */
46 u32 mask
; /* useful info about pkt */
47 u32 psn
; /* bth psn of packet */
48 u16 pkey_index
; /* partition of pkt */
49 u16 paylen
; /* length of bth - icrc */
50 u8 port_num
; /* port pkt received on */
51 u8 opcode
; /* bth opcode of packet */
52 u8 offset
; /* bth offset from pkt->hdr */
55 /* Macros should be used only for received skb */
56 static inline struct rxe_pkt_info
*SKB_TO_PKT(struct sk_buff
*skb
)
58 BUILD_BUG_ON(sizeof(struct rxe_pkt_info
) > sizeof(skb
->cb
));
59 return (void *)skb
->cb
;
62 static inline struct sk_buff
*PKT_TO_SKB(struct rxe_pkt_info
*pkt
)
64 return container_of((void *)pkt
, struct sk_buff
, cb
);
68 * IBA header types and methods
70 * Some of these are for reference and completeness only since
71 * rxe does not currently support RD transport
72 * most of this could be moved into IB core. ib_pack.h has
73 * part of this but is incomplete
75 * Header specific routines to insert/extract values to/from headers
76 * the routines that are named __hhh_(set_)fff() take a pointer to a
77 * hhh header and get(set) the fff field. The routines named
78 * hhh_(set_)fff take a packet info struct and find the
79 * header and field based on the opcode in the packet.
80 * Conversion to/from network byte order from cpu order is also done.
83 #define RXE_ICRC_SIZE (4)
84 #define RXE_MAX_HDR_LENGTH (80)
86 /******************************************************************************
87 * Base Transport Header
88 ******************************************************************************/
98 #define BTH_DEF_PKEY (0xffff)
100 #define BTH_SE_MASK (0x80)
101 #define BTH_MIG_MASK (0x40)
102 #define BTH_PAD_MASK (0x30)
103 #define BTH_TVER_MASK (0x0f)
104 #define BTH_FECN_MASK (0x80000000)
105 #define BTH_BECN_MASK (0x40000000)
106 #define BTH_RESV6A_MASK (0x3f000000)
107 #define BTH_QPN_MASK (0x00ffffff)
108 #define BTH_ACK_MASK (0x80000000)
109 #define BTH_RESV7_MASK (0x7f000000)
110 #define BTH_PSN_MASK (0x00ffffff)
112 static inline u8
__bth_opcode(void *arg
)
114 struct rxe_bth
*bth
= arg
;
119 static inline void __bth_set_opcode(void *arg
, u8 opcode
)
121 struct rxe_bth
*bth
= arg
;
123 bth
->opcode
= opcode
;
126 static inline u8
__bth_se(void *arg
)
128 struct rxe_bth
*bth
= arg
;
130 return 0 != (BTH_SE_MASK
& bth
->flags
);
133 static inline void __bth_set_se(void *arg
, int se
)
135 struct rxe_bth
*bth
= arg
;
138 bth
->flags
|= BTH_SE_MASK
;
140 bth
->flags
&= ~BTH_SE_MASK
;
143 static inline u8
__bth_mig(void *arg
)
145 struct rxe_bth
*bth
= arg
;
147 return 0 != (BTH_MIG_MASK
& bth
->flags
);
150 static inline void __bth_set_mig(void *arg
, u8 mig
)
152 struct rxe_bth
*bth
= arg
;
155 bth
->flags
|= BTH_MIG_MASK
;
157 bth
->flags
&= ~BTH_MIG_MASK
;
160 static inline u8
__bth_pad(void *arg
)
162 struct rxe_bth
*bth
= arg
;
164 return (BTH_PAD_MASK
& bth
->flags
) >> 4;
167 static inline void __bth_set_pad(void *arg
, u8 pad
)
169 struct rxe_bth
*bth
= arg
;
171 bth
->flags
= (BTH_PAD_MASK
& (pad
<< 4)) |
172 (~BTH_PAD_MASK
& bth
->flags
);
175 static inline u8
__bth_tver(void *arg
)
177 struct rxe_bth
*bth
= arg
;
179 return BTH_TVER_MASK
& bth
->flags
;
182 static inline void __bth_set_tver(void *arg
, u8 tver
)
184 struct rxe_bth
*bth
= arg
;
186 bth
->flags
= (BTH_TVER_MASK
& tver
) |
187 (~BTH_TVER_MASK
& bth
->flags
);
190 static inline u16
__bth_pkey(void *arg
)
192 struct rxe_bth
*bth
= arg
;
194 return be16_to_cpu(bth
->pkey
);
197 static inline void __bth_set_pkey(void *arg
, u16 pkey
)
199 struct rxe_bth
*bth
= arg
;
201 bth
->pkey
= cpu_to_be16(pkey
);
204 static inline u32
__bth_qpn(void *arg
)
206 struct rxe_bth
*bth
= arg
;
208 return BTH_QPN_MASK
& be32_to_cpu(bth
->qpn
);
211 static inline void __bth_set_qpn(void *arg
, u32 qpn
)
213 struct rxe_bth
*bth
= arg
;
214 u32 resvqpn
= be32_to_cpu(bth
->qpn
);
216 bth
->qpn
= cpu_to_be32((BTH_QPN_MASK
& qpn
) |
217 (~BTH_QPN_MASK
& resvqpn
));
220 static inline int __bth_fecn(void *arg
)
222 struct rxe_bth
*bth
= arg
;
224 return 0 != (cpu_to_be32(BTH_FECN_MASK
) & bth
->qpn
);
227 static inline void __bth_set_fecn(void *arg
, int fecn
)
229 struct rxe_bth
*bth
= arg
;
232 bth
->qpn
|= cpu_to_be32(BTH_FECN_MASK
);
234 bth
->qpn
&= ~cpu_to_be32(BTH_FECN_MASK
);
237 static inline int __bth_becn(void *arg
)
239 struct rxe_bth
*bth
= arg
;
241 return 0 != (cpu_to_be32(BTH_BECN_MASK
) & bth
->qpn
);
244 static inline void __bth_set_becn(void *arg
, int becn
)
246 struct rxe_bth
*bth
= arg
;
249 bth
->qpn
|= cpu_to_be32(BTH_BECN_MASK
);
251 bth
->qpn
&= ~cpu_to_be32(BTH_BECN_MASK
);
254 static inline u8
__bth_resv6a(void *arg
)
256 struct rxe_bth
*bth
= arg
;
258 return (BTH_RESV6A_MASK
& be32_to_cpu(bth
->qpn
)) >> 24;
261 static inline void __bth_set_resv6a(void *arg
)
263 struct rxe_bth
*bth
= arg
;
265 bth
->qpn
= cpu_to_be32(~BTH_RESV6A_MASK
);
268 static inline int __bth_ack(void *arg
)
270 struct rxe_bth
*bth
= arg
;
272 return 0 != (cpu_to_be32(BTH_ACK_MASK
) & bth
->apsn
);
275 static inline void __bth_set_ack(void *arg
, int ack
)
277 struct rxe_bth
*bth
= arg
;
280 bth
->apsn
|= cpu_to_be32(BTH_ACK_MASK
);
282 bth
->apsn
&= ~cpu_to_be32(BTH_ACK_MASK
);
285 static inline void __bth_set_resv7(void *arg
)
287 struct rxe_bth
*bth
= arg
;
289 bth
->apsn
&= ~cpu_to_be32(BTH_RESV7_MASK
);
292 static inline u32
__bth_psn(void *arg
)
294 struct rxe_bth
*bth
= arg
;
296 return BTH_PSN_MASK
& be32_to_cpu(bth
->apsn
);
299 static inline void __bth_set_psn(void *arg
, u32 psn
)
301 struct rxe_bth
*bth
= arg
;
302 u32 apsn
= be32_to_cpu(bth
->apsn
);
304 bth
->apsn
= cpu_to_be32((BTH_PSN_MASK
& psn
) |
305 (~BTH_PSN_MASK
& apsn
));
308 static inline u8
bth_opcode(struct rxe_pkt_info
*pkt
)
310 return __bth_opcode(pkt
->hdr
+ pkt
->offset
);
313 static inline void bth_set_opcode(struct rxe_pkt_info
*pkt
, u8 opcode
)
315 __bth_set_opcode(pkt
->hdr
+ pkt
->offset
, opcode
);
318 static inline u8
bth_se(struct rxe_pkt_info
*pkt
)
320 return __bth_se(pkt
->hdr
+ pkt
->offset
);
323 static inline void bth_set_se(struct rxe_pkt_info
*pkt
, int se
)
325 __bth_set_se(pkt
->hdr
+ pkt
->offset
, se
);
328 static inline u8
bth_mig(struct rxe_pkt_info
*pkt
)
330 return __bth_mig(pkt
->hdr
+ pkt
->offset
);
333 static inline void bth_set_mig(struct rxe_pkt_info
*pkt
, u8 mig
)
335 __bth_set_mig(pkt
->hdr
+ pkt
->offset
, mig
);
338 static inline u8
bth_pad(struct rxe_pkt_info
*pkt
)
340 return __bth_pad(pkt
->hdr
+ pkt
->offset
);
343 static inline void bth_set_pad(struct rxe_pkt_info
*pkt
, u8 pad
)
345 __bth_set_pad(pkt
->hdr
+ pkt
->offset
, pad
);
348 static inline u8
bth_tver(struct rxe_pkt_info
*pkt
)
350 return __bth_tver(pkt
->hdr
+ pkt
->offset
);
353 static inline void bth_set_tver(struct rxe_pkt_info
*pkt
, u8 tver
)
355 __bth_set_tver(pkt
->hdr
+ pkt
->offset
, tver
);
358 static inline u16
bth_pkey(struct rxe_pkt_info
*pkt
)
360 return __bth_pkey(pkt
->hdr
+ pkt
->offset
);
363 static inline void bth_set_pkey(struct rxe_pkt_info
*pkt
, u16 pkey
)
365 __bth_set_pkey(pkt
->hdr
+ pkt
->offset
, pkey
);
368 static inline u32
bth_qpn(struct rxe_pkt_info
*pkt
)
370 return __bth_qpn(pkt
->hdr
+ pkt
->offset
);
373 static inline void bth_set_qpn(struct rxe_pkt_info
*pkt
, u32 qpn
)
375 __bth_set_qpn(pkt
->hdr
+ pkt
->offset
, qpn
);
378 static inline int bth_fecn(struct rxe_pkt_info
*pkt
)
380 return __bth_fecn(pkt
->hdr
+ pkt
->offset
);
383 static inline void bth_set_fecn(struct rxe_pkt_info
*pkt
, int fecn
)
385 __bth_set_fecn(pkt
->hdr
+ pkt
->offset
, fecn
);
388 static inline int bth_becn(struct rxe_pkt_info
*pkt
)
390 return __bth_becn(pkt
->hdr
+ pkt
->offset
);
393 static inline void bth_set_becn(struct rxe_pkt_info
*pkt
, int becn
)
395 __bth_set_becn(pkt
->hdr
+ pkt
->offset
, becn
);
398 static inline u8
bth_resv6a(struct rxe_pkt_info
*pkt
)
400 return __bth_resv6a(pkt
->hdr
+ pkt
->offset
);
403 static inline void bth_set_resv6a(struct rxe_pkt_info
*pkt
)
405 __bth_set_resv6a(pkt
->hdr
+ pkt
->offset
);
408 static inline int bth_ack(struct rxe_pkt_info
*pkt
)
410 return __bth_ack(pkt
->hdr
+ pkt
->offset
);
413 static inline void bth_set_ack(struct rxe_pkt_info
*pkt
, int ack
)
415 __bth_set_ack(pkt
->hdr
+ pkt
->offset
, ack
);
418 static inline void bth_set_resv7(struct rxe_pkt_info
*pkt
)
420 __bth_set_resv7(pkt
->hdr
+ pkt
->offset
);
423 static inline u32
bth_psn(struct rxe_pkt_info
*pkt
)
425 return __bth_psn(pkt
->hdr
+ pkt
->offset
);
428 static inline void bth_set_psn(struct rxe_pkt_info
*pkt
, u32 psn
)
430 __bth_set_psn(pkt
->hdr
+ pkt
->offset
, psn
);
433 static inline void bth_init(struct rxe_pkt_info
*pkt
, u8 opcode
, int se
,
434 int mig
, int pad
, u16 pkey
, u32 qpn
, int ack_req
,
437 struct rxe_bth
*bth
= (struct rxe_bth
*)(pkt
->hdr
+ pkt
->offset
);
439 bth
->opcode
= opcode
;
440 bth
->flags
= (pad
<< 4) & BTH_PAD_MASK
;
442 bth
->flags
|= BTH_SE_MASK
;
444 bth
->flags
|= BTH_MIG_MASK
;
445 bth
->pkey
= cpu_to_be16(pkey
);
446 bth
->qpn
= cpu_to_be32(qpn
& BTH_QPN_MASK
);
450 bth
->apsn
= cpu_to_be32(psn
);
453 /******************************************************************************
454 * Reliable Datagram Extended Transport Header
455 ******************************************************************************/
460 #define RDETH_EEN_MASK (0x00ffffff)
462 static inline u8
__rdeth_een(void *arg
)
464 struct rxe_rdeth
*rdeth
= arg
;
466 return RDETH_EEN_MASK
& be32_to_cpu(rdeth
->een
);
469 static inline void __rdeth_set_een(void *arg
, u32 een
)
471 struct rxe_rdeth
*rdeth
= arg
;
473 rdeth
->een
= cpu_to_be32(RDETH_EEN_MASK
& een
);
476 static inline u8
rdeth_een(struct rxe_pkt_info
*pkt
)
478 return __rdeth_een(pkt
->hdr
+ pkt
->offset
479 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RDETH
]);
482 static inline void rdeth_set_een(struct rxe_pkt_info
*pkt
, u32 een
)
484 __rdeth_set_een(pkt
->hdr
+ pkt
->offset
485 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RDETH
], een
);
488 /******************************************************************************
489 * Datagram Extended Transport Header
490 ******************************************************************************/
496 #define GSI_QKEY (0x80010000)
497 #define DETH_SQP_MASK (0x00ffffff)
499 static inline u32
__deth_qkey(void *arg
)
501 struct rxe_deth
*deth
= arg
;
503 return be32_to_cpu(deth
->qkey
);
506 static inline void __deth_set_qkey(void *arg
, u32 qkey
)
508 struct rxe_deth
*deth
= arg
;
510 deth
->qkey
= cpu_to_be32(qkey
);
513 static inline u32
__deth_sqp(void *arg
)
515 struct rxe_deth
*deth
= arg
;
517 return DETH_SQP_MASK
& be32_to_cpu(deth
->sqp
);
520 static inline void __deth_set_sqp(void *arg
, u32 sqp
)
522 struct rxe_deth
*deth
= arg
;
524 deth
->sqp
= cpu_to_be32(DETH_SQP_MASK
& sqp
);
527 static inline u32
deth_qkey(struct rxe_pkt_info
*pkt
)
529 return __deth_qkey(pkt
->hdr
+ pkt
->offset
530 + rxe_opcode
[pkt
->opcode
].offset
[RXE_DETH
]);
533 static inline void deth_set_qkey(struct rxe_pkt_info
*pkt
, u32 qkey
)
535 __deth_set_qkey(pkt
->hdr
+ pkt
->offset
536 + rxe_opcode
[pkt
->opcode
].offset
[RXE_DETH
], qkey
);
539 static inline u32
deth_sqp(struct rxe_pkt_info
*pkt
)
541 return __deth_sqp(pkt
->hdr
+ pkt
->offset
542 + rxe_opcode
[pkt
->opcode
].offset
[RXE_DETH
]);
545 static inline void deth_set_sqp(struct rxe_pkt_info
*pkt
, u32 sqp
)
547 __deth_set_sqp(pkt
->hdr
+ pkt
->offset
548 + rxe_opcode
[pkt
->opcode
].offset
[RXE_DETH
], sqp
);
551 /******************************************************************************
552 * RDMA Extended Transport Header
553 ******************************************************************************/
560 static inline u64
__reth_va(void *arg
)
562 struct rxe_reth
*reth
= arg
;
564 return be64_to_cpu(reth
->va
);
567 static inline void __reth_set_va(void *arg
, u64 va
)
569 struct rxe_reth
*reth
= arg
;
571 reth
->va
= cpu_to_be64(va
);
574 static inline u32
__reth_rkey(void *arg
)
576 struct rxe_reth
*reth
= arg
;
578 return be32_to_cpu(reth
->rkey
);
581 static inline void __reth_set_rkey(void *arg
, u32 rkey
)
583 struct rxe_reth
*reth
= arg
;
585 reth
->rkey
= cpu_to_be32(rkey
);
588 static inline u32
__reth_len(void *arg
)
590 struct rxe_reth
*reth
= arg
;
592 return be32_to_cpu(reth
->len
);
595 static inline void __reth_set_len(void *arg
, u32 len
)
597 struct rxe_reth
*reth
= arg
;
599 reth
->len
= cpu_to_be32(len
);
602 static inline u64
reth_va(struct rxe_pkt_info
*pkt
)
604 return __reth_va(pkt
->hdr
+ pkt
->offset
605 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RETH
]);
608 static inline void reth_set_va(struct rxe_pkt_info
*pkt
, u64 va
)
610 __reth_set_va(pkt
->hdr
+ pkt
->offset
611 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RETH
], va
);
614 static inline u32
reth_rkey(struct rxe_pkt_info
*pkt
)
616 return __reth_rkey(pkt
->hdr
+ pkt
->offset
617 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RETH
]);
620 static inline void reth_set_rkey(struct rxe_pkt_info
*pkt
, u32 rkey
)
622 __reth_set_rkey(pkt
->hdr
+ pkt
->offset
623 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RETH
], rkey
);
626 static inline u32
reth_len(struct rxe_pkt_info
*pkt
)
628 return __reth_len(pkt
->hdr
+ pkt
->offset
629 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RETH
]);
632 static inline void reth_set_len(struct rxe_pkt_info
*pkt
, u32 len
)
634 __reth_set_len(pkt
->hdr
+ pkt
->offset
635 + rxe_opcode
[pkt
->opcode
].offset
[RXE_RETH
], len
);
638 /******************************************************************************
639 * Atomic Extended Transport Header
640 ******************************************************************************/
648 static inline u64
__atmeth_va(void *arg
)
650 struct rxe_atmeth
*atmeth
= arg
;
652 return be64_to_cpu(atmeth
->va
);
655 static inline void __atmeth_set_va(void *arg
, u64 va
)
657 struct rxe_atmeth
*atmeth
= arg
;
659 atmeth
->va
= cpu_to_be64(va
);
662 static inline u32
__atmeth_rkey(void *arg
)
664 struct rxe_atmeth
*atmeth
= arg
;
666 return be32_to_cpu(atmeth
->rkey
);
669 static inline void __atmeth_set_rkey(void *arg
, u32 rkey
)
671 struct rxe_atmeth
*atmeth
= arg
;
673 atmeth
->rkey
= cpu_to_be32(rkey
);
676 static inline u64
__atmeth_swap_add(void *arg
)
678 struct rxe_atmeth
*atmeth
= arg
;
680 return be64_to_cpu(atmeth
->swap_add
);
683 static inline void __atmeth_set_swap_add(void *arg
, u64 swap_add
)
685 struct rxe_atmeth
*atmeth
= arg
;
687 atmeth
->swap_add
= cpu_to_be64(swap_add
);
690 static inline u64
__atmeth_comp(void *arg
)
692 struct rxe_atmeth
*atmeth
= arg
;
694 return be64_to_cpu(atmeth
->comp
);
697 static inline void __atmeth_set_comp(void *arg
, u64 comp
)
699 struct rxe_atmeth
*atmeth
= arg
;
701 atmeth
->comp
= cpu_to_be64(comp
);
704 static inline u64
atmeth_va(struct rxe_pkt_info
*pkt
)
706 return __atmeth_va(pkt
->hdr
+ pkt
->offset
707 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
]);
710 static inline void atmeth_set_va(struct rxe_pkt_info
*pkt
, u64 va
)
712 __atmeth_set_va(pkt
->hdr
+ pkt
->offset
713 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
], va
);
716 static inline u32
atmeth_rkey(struct rxe_pkt_info
*pkt
)
718 return __atmeth_rkey(pkt
->hdr
+ pkt
->offset
719 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
]);
722 static inline void atmeth_set_rkey(struct rxe_pkt_info
*pkt
, u32 rkey
)
724 __atmeth_set_rkey(pkt
->hdr
+ pkt
->offset
725 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
], rkey
);
728 static inline u64
atmeth_swap_add(struct rxe_pkt_info
*pkt
)
730 return __atmeth_swap_add(pkt
->hdr
+ pkt
->offset
731 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
]);
734 static inline void atmeth_set_swap_add(struct rxe_pkt_info
*pkt
, u64 swap_add
)
736 __atmeth_set_swap_add(pkt
->hdr
+ pkt
->offset
737 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
], swap_add
);
740 static inline u64
atmeth_comp(struct rxe_pkt_info
*pkt
)
742 return __atmeth_comp(pkt
->hdr
+ pkt
->offset
743 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
]);
746 static inline void atmeth_set_comp(struct rxe_pkt_info
*pkt
, u64 comp
)
748 __atmeth_set_comp(pkt
->hdr
+ pkt
->offset
749 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMETH
], comp
);
752 /******************************************************************************
753 * Ack Extended Transport Header
754 ******************************************************************************/
759 #define AETH_SYN_MASK (0xff000000)
760 #define AETH_MSN_MASK (0x00ffffff)
763 AETH_TYPE_MASK
= 0xe0,
768 AETH_ACK_UNLIMITED
= 0x1f,
769 AETH_NAK_PSN_SEQ_ERROR
= 0x60,
770 AETH_NAK_INVALID_REQ
= 0x61,
771 AETH_NAK_REM_ACC_ERR
= 0x62,
772 AETH_NAK_REM_OP_ERR
= 0x63,
773 AETH_NAK_INV_RD_REQ
= 0x64,
776 static inline u8
__aeth_syn(void *arg
)
778 struct rxe_aeth
*aeth
= arg
;
780 return (AETH_SYN_MASK
& be32_to_cpu(aeth
->smsn
)) >> 24;
783 static inline void __aeth_set_syn(void *arg
, u8 syn
)
785 struct rxe_aeth
*aeth
= arg
;
786 u32 smsn
= be32_to_cpu(aeth
->smsn
);
788 aeth
->smsn
= cpu_to_be32((AETH_SYN_MASK
& (syn
<< 24)) |
789 (~AETH_SYN_MASK
& smsn
));
792 static inline u32
__aeth_msn(void *arg
)
794 struct rxe_aeth
*aeth
= arg
;
796 return AETH_MSN_MASK
& be32_to_cpu(aeth
->smsn
);
799 static inline void __aeth_set_msn(void *arg
, u32 msn
)
801 struct rxe_aeth
*aeth
= arg
;
802 u32 smsn
= be32_to_cpu(aeth
->smsn
);
804 aeth
->smsn
= cpu_to_be32((AETH_MSN_MASK
& msn
) |
805 (~AETH_MSN_MASK
& smsn
));
808 static inline u8
aeth_syn(struct rxe_pkt_info
*pkt
)
810 return __aeth_syn(pkt
->hdr
+ pkt
->offset
811 + rxe_opcode
[pkt
->opcode
].offset
[RXE_AETH
]);
814 static inline void aeth_set_syn(struct rxe_pkt_info
*pkt
, u8 syn
)
816 __aeth_set_syn(pkt
->hdr
+ pkt
->offset
817 + rxe_opcode
[pkt
->opcode
].offset
[RXE_AETH
], syn
);
820 static inline u32
aeth_msn(struct rxe_pkt_info
*pkt
)
822 return __aeth_msn(pkt
->hdr
+ pkt
->offset
823 + rxe_opcode
[pkt
->opcode
].offset
[RXE_AETH
]);
826 static inline void aeth_set_msn(struct rxe_pkt_info
*pkt
, u32 msn
)
828 __aeth_set_msn(pkt
->hdr
+ pkt
->offset
829 + rxe_opcode
[pkt
->opcode
].offset
[RXE_AETH
], msn
);
832 /******************************************************************************
833 * Atomic Ack Extended Transport Header
834 ******************************************************************************/
839 static inline u64
__atmack_orig(void *arg
)
841 struct rxe_atmack
*atmack
= arg
;
843 return be64_to_cpu(atmack
->orig
);
846 static inline void __atmack_set_orig(void *arg
, u64 orig
)
848 struct rxe_atmack
*atmack
= arg
;
850 atmack
->orig
= cpu_to_be64(orig
);
853 static inline u64
atmack_orig(struct rxe_pkt_info
*pkt
)
855 return __atmack_orig(pkt
->hdr
+ pkt
->offset
856 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMACK
]);
859 static inline void atmack_set_orig(struct rxe_pkt_info
*pkt
, u64 orig
)
861 __atmack_set_orig(pkt
->hdr
+ pkt
->offset
862 + rxe_opcode
[pkt
->opcode
].offset
[RXE_ATMACK
], orig
);
865 /******************************************************************************
866 * Immediate Extended Transport Header
867 ******************************************************************************/
872 static inline __be32
__immdt_imm(void *arg
)
874 struct rxe_immdt
*immdt
= arg
;
879 static inline void __immdt_set_imm(void *arg
, __be32 imm
)
881 struct rxe_immdt
*immdt
= arg
;
886 static inline __be32
immdt_imm(struct rxe_pkt_info
*pkt
)
888 return __immdt_imm(pkt
->hdr
+ pkt
->offset
889 + rxe_opcode
[pkt
->opcode
].offset
[RXE_IMMDT
]);
892 static inline void immdt_set_imm(struct rxe_pkt_info
*pkt
, __be32 imm
)
894 __immdt_set_imm(pkt
->hdr
+ pkt
->offset
895 + rxe_opcode
[pkt
->opcode
].offset
[RXE_IMMDT
], imm
);
898 /******************************************************************************
899 * Invalidate Extended Transport Header
900 ******************************************************************************/
905 static inline u32
__ieth_rkey(void *arg
)
907 struct rxe_ieth
*ieth
= arg
;
909 return be32_to_cpu(ieth
->rkey
);
912 static inline void __ieth_set_rkey(void *arg
, u32 rkey
)
914 struct rxe_ieth
*ieth
= arg
;
916 ieth
->rkey
= cpu_to_be32(rkey
);
919 static inline u32
ieth_rkey(struct rxe_pkt_info
*pkt
)
921 return __ieth_rkey(pkt
->hdr
+ pkt
->offset
922 + rxe_opcode
[pkt
->opcode
].offset
[RXE_IETH
]);
925 static inline void ieth_set_rkey(struct rxe_pkt_info
*pkt
, u32 rkey
)
927 __ieth_set_rkey(pkt
->hdr
+ pkt
->offset
928 + rxe_opcode
[pkt
->opcode
].offset
[RXE_IETH
], rkey
);
931 enum rxe_hdr_length
{
932 RXE_BTH_BYTES
= sizeof(struct rxe_bth
),
933 RXE_DETH_BYTES
= sizeof(struct rxe_deth
),
934 RXE_IMMDT_BYTES
= sizeof(struct rxe_immdt
),
935 RXE_RETH_BYTES
= sizeof(struct rxe_reth
),
936 RXE_AETH_BYTES
= sizeof(struct rxe_aeth
),
937 RXE_ATMACK_BYTES
= sizeof(struct rxe_atmack
),
938 RXE_ATMETH_BYTES
= sizeof(struct rxe_atmeth
),
939 RXE_IETH_BYTES
= sizeof(struct rxe_ieth
),
940 RXE_RDETH_BYTES
= sizeof(struct rxe_rdeth
),
943 static inline size_t header_size(struct rxe_pkt_info
*pkt
)
945 return pkt
->offset
+ rxe_opcode
[pkt
->opcode
].length
;
948 static inline void *payload_addr(struct rxe_pkt_info
*pkt
)
950 return pkt
->hdr
+ pkt
->offset
951 + rxe_opcode
[pkt
->opcode
].offset
[RXE_PAYLOAD
];
954 static inline size_t payload_size(struct rxe_pkt_info
*pkt
)
956 return pkt
->paylen
- rxe_opcode
[pkt
->opcode
].offset
[RXE_PAYLOAD
]
957 - bth_pad(pkt
) - RXE_ICRC_SIZE
;
960 #endif /* RXE_HDR_H */