1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
3 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
4 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
10 /* extracted information about a packet carried in an sk_buff struct fits in
11 * the skbuff cb array. Must be at most 48 bytes. stored in control block of
12 * sk_buff for received packets.
15 struct rxe_dev *rxe; /* device that owns packet */
16 struct rxe_qp *qp; /* qp that owns packet */
17 struct rxe_send_wqe *wqe; /* send wqe */
18 u8 *hdr; /* points to bth */
19 u32 mask; /* useful info about pkt */
20 u32 psn; /* bth psn of packet */
21 u16 pkey_index; /* partition of pkt */
22 u16 paylen; /* length of bth - icrc */
23 u8 port_num; /* port pkt received on */
24 u8 opcode; /* bth opcode of packet */
27 /* Macros should be used only for received skb */
28 static inline struct rxe_pkt_info *SKB_TO_PKT(struct sk_buff *skb)
30 BUILD_BUG_ON(sizeof(struct rxe_pkt_info) > sizeof(skb->cb));
31 return (void *)skb->cb;
34 static inline struct sk_buff *PKT_TO_SKB(struct rxe_pkt_info *pkt)
36 return container_of((void *)pkt, struct sk_buff, cb);
40 * IBA header types and methods
42 * Some of these are for reference and completeness only since
43 * rxe does not currently support RD transport
44 * most of this could be moved into IB core. ib_pack.h has
45 * part of this but is incomplete
47 * Header specific routines to insert/extract values to/from headers
48 * the routines that are named __hhh_(set_)fff() take a pointer to a
49 * hhh header and get(set) the fff field. The routines named
50 * hhh_(set_)fff take a packet info struct and find the
51 * header and field based on the opcode in the packet.
52 * Conversion to/from network byte order from cpu order is also done.
55 #define RXE_ICRC_SIZE (4)
56 #define RXE_MAX_HDR_LENGTH (80)
58 /******************************************************************************
59 * Base Transport Header
60 ******************************************************************************/
70 #define BTH_DEF_PKEY (0xffff)
72 #define BTH_SE_MASK (0x80)
73 #define BTH_MIG_MASK (0x40)
74 #define BTH_PAD_MASK (0x30)
75 #define BTH_TVER_MASK (0x0f)
76 #define BTH_FECN_MASK (0x80000000)
77 #define BTH_BECN_MASK (0x40000000)
78 #define BTH_RESV6A_MASK (0x3f000000)
79 #define BTH_QPN_MASK (0x00ffffff)
80 #define BTH_ACK_MASK (0x80000000)
81 #define BTH_RESV7_MASK (0x7f000000)
82 #define BTH_PSN_MASK (0x00ffffff)
84 static inline u8 __bth_opcode(void *arg)
86 struct rxe_bth *bth = arg;
91 static inline void __bth_set_opcode(void *arg, u8 opcode)
93 struct rxe_bth *bth = arg;
98 static inline u8 __bth_se(void *arg)
100 struct rxe_bth *bth = arg;
102 return 0 != (BTH_SE_MASK & bth->flags);
105 static inline void __bth_set_se(void *arg, int se)
107 struct rxe_bth *bth = arg;
110 bth->flags |= BTH_SE_MASK;
112 bth->flags &= ~BTH_SE_MASK;
115 static inline u8 __bth_mig(void *arg)
117 struct rxe_bth *bth = arg;
119 return 0 != (BTH_MIG_MASK & bth->flags);
122 static inline void __bth_set_mig(void *arg, u8 mig)
124 struct rxe_bth *bth = arg;
127 bth->flags |= BTH_MIG_MASK;
129 bth->flags &= ~BTH_MIG_MASK;
132 static inline u8 __bth_pad(void *arg)
134 struct rxe_bth *bth = arg;
136 return (BTH_PAD_MASK & bth->flags) >> 4;
139 static inline void __bth_set_pad(void *arg, u8 pad)
141 struct rxe_bth *bth = arg;
143 bth->flags = (BTH_PAD_MASK & (pad << 4)) |
144 (~BTH_PAD_MASK & bth->flags);
147 static inline u8 __bth_tver(void *arg)
149 struct rxe_bth *bth = arg;
151 return BTH_TVER_MASK & bth->flags;
154 static inline void __bth_set_tver(void *arg, u8 tver)
156 struct rxe_bth *bth = arg;
158 bth->flags = (BTH_TVER_MASK & tver) |
159 (~BTH_TVER_MASK & bth->flags);
162 static inline u16 __bth_pkey(void *arg)
164 struct rxe_bth *bth = arg;
166 return be16_to_cpu(bth->pkey);
169 static inline void __bth_set_pkey(void *arg, u16 pkey)
171 struct rxe_bth *bth = arg;
173 bth->pkey = cpu_to_be16(pkey);
176 static inline u32 __bth_qpn(void *arg)
178 struct rxe_bth *bth = arg;
180 return BTH_QPN_MASK & be32_to_cpu(bth->qpn);
183 static inline void __bth_set_qpn(void *arg, u32 qpn)
185 struct rxe_bth *bth = arg;
186 u32 resvqpn = be32_to_cpu(bth->qpn);
188 bth->qpn = cpu_to_be32((BTH_QPN_MASK & qpn) |
189 (~BTH_QPN_MASK & resvqpn));
192 static inline int __bth_fecn(void *arg)
194 struct rxe_bth *bth = arg;
196 return 0 != (cpu_to_be32(BTH_FECN_MASK) & bth->qpn);
199 static inline void __bth_set_fecn(void *arg, int fecn)
201 struct rxe_bth *bth = arg;
204 bth->qpn |= cpu_to_be32(BTH_FECN_MASK);
206 bth->qpn &= ~cpu_to_be32(BTH_FECN_MASK);
209 static inline int __bth_becn(void *arg)
211 struct rxe_bth *bth = arg;
213 return 0 != (cpu_to_be32(BTH_BECN_MASK) & bth->qpn);
216 static inline void __bth_set_becn(void *arg, int becn)
218 struct rxe_bth *bth = arg;
221 bth->qpn |= cpu_to_be32(BTH_BECN_MASK);
223 bth->qpn &= ~cpu_to_be32(BTH_BECN_MASK);
226 static inline u8 __bth_resv6a(void *arg)
228 struct rxe_bth *bth = arg;
230 return (BTH_RESV6A_MASK & be32_to_cpu(bth->qpn)) >> 24;
233 static inline void __bth_set_resv6a(void *arg)
235 struct rxe_bth *bth = arg;
237 bth->qpn &= cpu_to_be32(~BTH_RESV6A_MASK);
240 static inline int __bth_ack(void *arg)
242 struct rxe_bth *bth = arg;
244 return 0 != (cpu_to_be32(BTH_ACK_MASK) & bth->apsn);
247 static inline void __bth_set_ack(void *arg, int ack)
249 struct rxe_bth *bth = arg;
252 bth->apsn |= cpu_to_be32(BTH_ACK_MASK);
254 bth->apsn &= ~cpu_to_be32(BTH_ACK_MASK);
257 static inline void __bth_set_resv7(void *arg)
259 struct rxe_bth *bth = arg;
261 bth->apsn &= ~cpu_to_be32(BTH_RESV7_MASK);
264 static inline u32 __bth_psn(void *arg)
266 struct rxe_bth *bth = arg;
268 return BTH_PSN_MASK & be32_to_cpu(bth->apsn);
271 static inline void __bth_set_psn(void *arg, u32 psn)
273 struct rxe_bth *bth = arg;
274 u32 apsn = be32_to_cpu(bth->apsn);
276 bth->apsn = cpu_to_be32((BTH_PSN_MASK & psn) |
277 (~BTH_PSN_MASK & apsn));
280 static inline u8 bth_opcode(struct rxe_pkt_info *pkt)
282 return __bth_opcode(pkt->hdr);
285 static inline void bth_set_opcode(struct rxe_pkt_info *pkt, u8 opcode)
287 __bth_set_opcode(pkt->hdr, opcode);
290 static inline u8 bth_se(struct rxe_pkt_info *pkt)
292 return __bth_se(pkt->hdr);
295 static inline void bth_set_se(struct rxe_pkt_info *pkt, int se)
297 __bth_set_se(pkt->hdr, se);
300 static inline u8 bth_mig(struct rxe_pkt_info *pkt)
302 return __bth_mig(pkt->hdr);
305 static inline void bth_set_mig(struct rxe_pkt_info *pkt, u8 mig)
307 __bth_set_mig(pkt->hdr, mig);
310 static inline u8 bth_pad(struct rxe_pkt_info *pkt)
312 return __bth_pad(pkt->hdr);
315 static inline void bth_set_pad(struct rxe_pkt_info *pkt, u8 pad)
317 __bth_set_pad(pkt->hdr, pad);
320 static inline u8 bth_tver(struct rxe_pkt_info *pkt)
322 return __bth_tver(pkt->hdr);
325 static inline void bth_set_tver(struct rxe_pkt_info *pkt, u8 tver)
327 __bth_set_tver(pkt->hdr, tver);
330 static inline u16 bth_pkey(struct rxe_pkt_info *pkt)
332 return __bth_pkey(pkt->hdr);
335 static inline void bth_set_pkey(struct rxe_pkt_info *pkt, u16 pkey)
337 __bth_set_pkey(pkt->hdr, pkey);
340 static inline u32 bth_qpn(struct rxe_pkt_info *pkt)
342 return __bth_qpn(pkt->hdr);
345 static inline void bth_set_qpn(struct rxe_pkt_info *pkt, u32 qpn)
347 __bth_set_qpn(pkt->hdr, qpn);
350 static inline int bth_fecn(struct rxe_pkt_info *pkt)
352 return __bth_fecn(pkt->hdr);
355 static inline void bth_set_fecn(struct rxe_pkt_info *pkt, int fecn)
357 __bth_set_fecn(pkt->hdr, fecn);
360 static inline int bth_becn(struct rxe_pkt_info *pkt)
362 return __bth_becn(pkt->hdr);
365 static inline void bth_set_becn(struct rxe_pkt_info *pkt, int becn)
367 __bth_set_becn(pkt->hdr, becn);
370 static inline u8 bth_resv6a(struct rxe_pkt_info *pkt)
372 return __bth_resv6a(pkt->hdr);
375 static inline void bth_set_resv6a(struct rxe_pkt_info *pkt)
377 __bth_set_resv6a(pkt->hdr);
380 static inline int bth_ack(struct rxe_pkt_info *pkt)
382 return __bth_ack(pkt->hdr);
385 static inline void bth_set_ack(struct rxe_pkt_info *pkt, int ack)
387 __bth_set_ack(pkt->hdr, ack);
390 static inline void bth_set_resv7(struct rxe_pkt_info *pkt)
392 __bth_set_resv7(pkt->hdr);
395 static inline u32 bth_psn(struct rxe_pkt_info *pkt)
397 return __bth_psn(pkt->hdr);
400 static inline void bth_set_psn(struct rxe_pkt_info *pkt, u32 psn)
402 __bth_set_psn(pkt->hdr, psn);
405 static inline void bth_init(struct rxe_pkt_info *pkt, u8 opcode, int se,
406 int mig, int pad, u16 pkey, u32 qpn, int ack_req,
409 struct rxe_bth *bth = (struct rxe_bth *)(pkt->hdr);
411 bth->opcode = opcode;
412 bth->flags = (pad << 4) & BTH_PAD_MASK;
414 bth->flags |= BTH_SE_MASK;
416 bth->flags |= BTH_MIG_MASK;
417 bth->pkey = cpu_to_be16(pkey);
418 bth->qpn = cpu_to_be32(qpn & BTH_QPN_MASK);
422 bth->apsn = cpu_to_be32(psn);
425 /******************************************************************************
426 * Reliable Datagram Extended Transport Header
427 ******************************************************************************/
432 #define RDETH_EEN_MASK (0x00ffffff)
434 static inline u8 __rdeth_een(void *arg)
436 struct rxe_rdeth *rdeth = arg;
438 return RDETH_EEN_MASK & be32_to_cpu(rdeth->een);
441 static inline void __rdeth_set_een(void *arg, u32 een)
443 struct rxe_rdeth *rdeth = arg;
445 rdeth->een = cpu_to_be32(RDETH_EEN_MASK & een);
448 static inline u8 rdeth_een(struct rxe_pkt_info *pkt)
450 return __rdeth_een(pkt->hdr +
451 rxe_opcode[pkt->opcode].offset[RXE_RDETH]);
454 static inline void rdeth_set_een(struct rxe_pkt_info *pkt, u32 een)
456 __rdeth_set_een(pkt->hdr +
457 rxe_opcode[pkt->opcode].offset[RXE_RDETH], een);
460 /******************************************************************************
461 * Datagram Extended Transport Header
462 ******************************************************************************/
468 #define GSI_QKEY (0x80010000)
469 #define DETH_SQP_MASK (0x00ffffff)
471 static inline u32 __deth_qkey(void *arg)
473 struct rxe_deth *deth = arg;
475 return be32_to_cpu(deth->qkey);
478 static inline void __deth_set_qkey(void *arg, u32 qkey)
480 struct rxe_deth *deth = arg;
482 deth->qkey = cpu_to_be32(qkey);
485 static inline u32 __deth_sqp(void *arg)
487 struct rxe_deth *deth = arg;
489 return DETH_SQP_MASK & be32_to_cpu(deth->sqp);
492 static inline void __deth_set_sqp(void *arg, u32 sqp)
494 struct rxe_deth *deth = arg;
496 deth->sqp = cpu_to_be32(DETH_SQP_MASK & sqp);
499 static inline u32 deth_qkey(struct rxe_pkt_info *pkt)
501 return __deth_qkey(pkt->hdr +
502 rxe_opcode[pkt->opcode].offset[RXE_DETH]);
505 static inline void deth_set_qkey(struct rxe_pkt_info *pkt, u32 qkey)
507 __deth_set_qkey(pkt->hdr +
508 rxe_opcode[pkt->opcode].offset[RXE_DETH], qkey);
511 static inline u32 deth_sqp(struct rxe_pkt_info *pkt)
513 return __deth_sqp(pkt->hdr +
514 rxe_opcode[pkt->opcode].offset[RXE_DETH]);
517 static inline void deth_set_sqp(struct rxe_pkt_info *pkt, u32 sqp)
519 __deth_set_sqp(pkt->hdr +
520 rxe_opcode[pkt->opcode].offset[RXE_DETH], sqp);
523 /******************************************************************************
524 * RDMA Extended Transport Header
525 ******************************************************************************/
532 static inline u64 __reth_va(void *arg)
534 struct rxe_reth *reth = arg;
536 return be64_to_cpu(reth->va);
539 static inline void __reth_set_va(void *arg, u64 va)
541 struct rxe_reth *reth = arg;
543 reth->va = cpu_to_be64(va);
546 static inline u32 __reth_rkey(void *arg)
548 struct rxe_reth *reth = arg;
550 return be32_to_cpu(reth->rkey);
553 static inline void __reth_set_rkey(void *arg, u32 rkey)
555 struct rxe_reth *reth = arg;
557 reth->rkey = cpu_to_be32(rkey);
560 static inline u32 __reth_len(void *arg)
562 struct rxe_reth *reth = arg;
564 return be32_to_cpu(reth->len);
567 static inline void __reth_set_len(void *arg, u32 len)
569 struct rxe_reth *reth = arg;
571 reth->len = cpu_to_be32(len);
574 static inline u64 reth_va(struct rxe_pkt_info *pkt)
576 return __reth_va(pkt->hdr +
577 rxe_opcode[pkt->opcode].offset[RXE_RETH]);
580 static inline void reth_set_va(struct rxe_pkt_info *pkt, u64 va)
582 __reth_set_va(pkt->hdr +
583 rxe_opcode[pkt->opcode].offset[RXE_RETH], va);
586 static inline u32 reth_rkey(struct rxe_pkt_info *pkt)
588 return __reth_rkey(pkt->hdr +
589 rxe_opcode[pkt->opcode].offset[RXE_RETH]);
592 static inline void reth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey)
594 __reth_set_rkey(pkt->hdr +
595 rxe_opcode[pkt->opcode].offset[RXE_RETH], rkey);
598 static inline u32 reth_len(struct rxe_pkt_info *pkt)
600 return __reth_len(pkt->hdr +
601 rxe_opcode[pkt->opcode].offset[RXE_RETH]);
604 static inline void reth_set_len(struct rxe_pkt_info *pkt, u32 len)
606 __reth_set_len(pkt->hdr +
607 rxe_opcode[pkt->opcode].offset[RXE_RETH], len);
610 /******************************************************************************
611 * FLUSH Extended Transport Header
612 ******************************************************************************/
618 #define FETH_PLT_MASK (0x0000000f) /* bits 3-0 */
619 #define FETH_SEL_MASK (0x00000030) /* bits 5-4 */
620 #define FETH_SEL_SHIFT (4U)
622 static inline u32 __feth_plt(void *arg)
624 struct rxe_feth *feth = arg;
626 return be32_to_cpu(feth->bits) & FETH_PLT_MASK;
629 static inline u32 __feth_sel(void *arg)
631 struct rxe_feth *feth = arg;
633 return (be32_to_cpu(feth->bits) & FETH_SEL_MASK) >> FETH_SEL_SHIFT;
636 static inline u32 feth_plt(struct rxe_pkt_info *pkt)
638 return __feth_plt(pkt->hdr + rxe_opcode[pkt->opcode].offset[RXE_FETH]);
641 static inline u32 feth_sel(struct rxe_pkt_info *pkt)
643 return __feth_sel(pkt->hdr + rxe_opcode[pkt->opcode].offset[RXE_FETH]);
646 static inline void feth_init(struct rxe_pkt_info *pkt, u8 type, u8 level)
648 struct rxe_feth *feth = (struct rxe_feth *)
649 (pkt->hdr + rxe_opcode[pkt->opcode].offset[RXE_FETH]);
650 u32 bits = ((level << FETH_SEL_SHIFT) & FETH_SEL_MASK) |
651 (type & FETH_PLT_MASK);
653 feth->bits = cpu_to_be32(bits);
656 /******************************************************************************
657 * Atomic Extended Transport Header
658 ******************************************************************************/
666 static inline u64 __atmeth_va(void *arg)
668 struct rxe_atmeth *atmeth = arg;
670 return be64_to_cpu(atmeth->va);
673 static inline void __atmeth_set_va(void *arg, u64 va)
675 struct rxe_atmeth *atmeth = arg;
677 atmeth->va = cpu_to_be64(va);
680 static inline u32 __atmeth_rkey(void *arg)
682 struct rxe_atmeth *atmeth = arg;
684 return be32_to_cpu(atmeth->rkey);
687 static inline void __atmeth_set_rkey(void *arg, u32 rkey)
689 struct rxe_atmeth *atmeth = arg;
691 atmeth->rkey = cpu_to_be32(rkey);
694 static inline u64 __atmeth_swap_add(void *arg)
696 struct rxe_atmeth *atmeth = arg;
698 return be64_to_cpu(atmeth->swap_add);
701 static inline void __atmeth_set_swap_add(void *arg, u64 swap_add)
703 struct rxe_atmeth *atmeth = arg;
705 atmeth->swap_add = cpu_to_be64(swap_add);
708 static inline u64 __atmeth_comp(void *arg)
710 struct rxe_atmeth *atmeth = arg;
712 return be64_to_cpu(atmeth->comp);
715 static inline void __atmeth_set_comp(void *arg, u64 comp)
717 struct rxe_atmeth *atmeth = arg;
719 atmeth->comp = cpu_to_be64(comp);
722 static inline u64 atmeth_va(struct rxe_pkt_info *pkt)
724 return __atmeth_va(pkt->hdr +
725 rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
728 static inline void atmeth_set_va(struct rxe_pkt_info *pkt, u64 va)
730 __atmeth_set_va(pkt->hdr +
731 rxe_opcode[pkt->opcode].offset[RXE_ATMETH], va);
734 static inline u32 atmeth_rkey(struct rxe_pkt_info *pkt)
736 return __atmeth_rkey(pkt->hdr +
737 rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
740 static inline void atmeth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey)
742 __atmeth_set_rkey(pkt->hdr +
743 rxe_opcode[pkt->opcode].offset[RXE_ATMETH], rkey);
746 static inline u64 atmeth_swap_add(struct rxe_pkt_info *pkt)
748 return __atmeth_swap_add(pkt->hdr +
749 rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
752 static inline void atmeth_set_swap_add(struct rxe_pkt_info *pkt, u64 swap_add)
754 __atmeth_set_swap_add(pkt->hdr +
755 rxe_opcode[pkt->opcode].offset[RXE_ATMETH], swap_add);
758 static inline u64 atmeth_comp(struct rxe_pkt_info *pkt)
760 return __atmeth_comp(pkt->hdr +
761 rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
764 static inline void atmeth_set_comp(struct rxe_pkt_info *pkt, u64 comp)
766 __atmeth_set_comp(pkt->hdr +
767 rxe_opcode[pkt->opcode].offset[RXE_ATMETH], comp);
770 /******************************************************************************
771 * Ack Extended Transport Header
772 ******************************************************************************/
777 #define AETH_SYN_MASK (0xff000000)
778 #define AETH_MSN_MASK (0x00ffffff)
781 AETH_TYPE_MASK = 0xe0,
786 AETH_ACK_UNLIMITED = 0x1f,
787 AETH_NAK_PSN_SEQ_ERROR = 0x60,
788 AETH_NAK_INVALID_REQ = 0x61,
789 AETH_NAK_REM_ACC_ERR = 0x62,
790 AETH_NAK_REM_OP_ERR = 0x63,
793 static inline u8 __aeth_syn(void *arg)
795 struct rxe_aeth *aeth = arg;
797 return (AETH_SYN_MASK & be32_to_cpu(aeth->smsn)) >> 24;
800 static inline void __aeth_set_syn(void *arg, u8 syn)
802 struct rxe_aeth *aeth = arg;
803 u32 smsn = be32_to_cpu(aeth->smsn);
805 aeth->smsn = cpu_to_be32((AETH_SYN_MASK & (syn << 24)) |
806 (~AETH_SYN_MASK & smsn));
809 static inline u32 __aeth_msn(void *arg)
811 struct rxe_aeth *aeth = arg;
813 return AETH_MSN_MASK & be32_to_cpu(aeth->smsn);
816 static inline void __aeth_set_msn(void *arg, u32 msn)
818 struct rxe_aeth *aeth = arg;
819 u32 smsn = be32_to_cpu(aeth->smsn);
821 aeth->smsn = cpu_to_be32((AETH_MSN_MASK & msn) |
822 (~AETH_MSN_MASK & smsn));
825 static inline u8 aeth_syn(struct rxe_pkt_info *pkt)
827 return __aeth_syn(pkt->hdr +
828 rxe_opcode[pkt->opcode].offset[RXE_AETH]);
831 static inline void aeth_set_syn(struct rxe_pkt_info *pkt, u8 syn)
833 __aeth_set_syn(pkt->hdr +
834 rxe_opcode[pkt->opcode].offset[RXE_AETH], syn);
837 static inline u32 aeth_msn(struct rxe_pkt_info *pkt)
839 return __aeth_msn(pkt->hdr +
840 rxe_opcode[pkt->opcode].offset[RXE_AETH]);
843 static inline void aeth_set_msn(struct rxe_pkt_info *pkt, u32 msn)
845 __aeth_set_msn(pkt->hdr +
846 rxe_opcode[pkt->opcode].offset[RXE_AETH], msn);
849 /******************************************************************************
850 * Atomic Ack Extended Transport Header
851 ******************************************************************************/
856 static inline u64 __atmack_orig(void *arg)
858 struct rxe_atmack *atmack = arg;
860 return be64_to_cpu(atmack->orig);
863 static inline void __atmack_set_orig(void *arg, u64 orig)
865 struct rxe_atmack *atmack = arg;
867 atmack->orig = cpu_to_be64(orig);
870 static inline u64 atmack_orig(struct rxe_pkt_info *pkt)
872 return __atmack_orig(pkt->hdr +
873 rxe_opcode[pkt->opcode].offset[RXE_ATMACK]);
876 static inline void atmack_set_orig(struct rxe_pkt_info *pkt, u64 orig)
878 __atmack_set_orig(pkt->hdr +
879 rxe_opcode[pkt->opcode].offset[RXE_ATMACK], orig);
882 /******************************************************************************
883 * Immediate Extended Transport Header
884 ******************************************************************************/
889 static inline __be32 __immdt_imm(void *arg)
891 struct rxe_immdt *immdt = arg;
896 static inline void __immdt_set_imm(void *arg, __be32 imm)
898 struct rxe_immdt *immdt = arg;
903 static inline __be32 immdt_imm(struct rxe_pkt_info *pkt)
905 return __immdt_imm(pkt->hdr +
906 rxe_opcode[pkt->opcode].offset[RXE_IMMDT]);
909 static inline void immdt_set_imm(struct rxe_pkt_info *pkt, __be32 imm)
911 __immdt_set_imm(pkt->hdr +
912 rxe_opcode[pkt->opcode].offset[RXE_IMMDT], imm);
915 /******************************************************************************
916 * Invalidate Extended Transport Header
917 ******************************************************************************/
922 static inline u32 __ieth_rkey(void *arg)
924 struct rxe_ieth *ieth = arg;
926 return be32_to_cpu(ieth->rkey);
929 static inline void __ieth_set_rkey(void *arg, u32 rkey)
931 struct rxe_ieth *ieth = arg;
933 ieth->rkey = cpu_to_be32(rkey);
936 static inline u32 ieth_rkey(struct rxe_pkt_info *pkt)
938 return __ieth_rkey(pkt->hdr +
939 rxe_opcode[pkt->opcode].offset[RXE_IETH]);
942 static inline void ieth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey)
944 __ieth_set_rkey(pkt->hdr +
945 rxe_opcode[pkt->opcode].offset[RXE_IETH], rkey);
948 enum rxe_hdr_length {
949 RXE_BTH_BYTES = sizeof(struct rxe_bth),
950 RXE_DETH_BYTES = sizeof(struct rxe_deth),
951 RXE_IMMDT_BYTES = sizeof(struct rxe_immdt),
952 RXE_RETH_BYTES = sizeof(struct rxe_reth),
953 RXE_AETH_BYTES = sizeof(struct rxe_aeth),
954 RXE_ATMACK_BYTES = sizeof(struct rxe_atmack),
955 RXE_ATMETH_BYTES = sizeof(struct rxe_atmeth),
956 RXE_IETH_BYTES = sizeof(struct rxe_ieth),
957 RXE_RDETH_BYTES = sizeof(struct rxe_rdeth),
958 RXE_FETH_BYTES = sizeof(struct rxe_feth),
961 static inline size_t header_size(struct rxe_pkt_info *pkt)
963 return rxe_opcode[pkt->opcode].length;
966 static inline void *payload_addr(struct rxe_pkt_info *pkt)
968 return pkt->hdr + rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD];
971 static inline size_t payload_size(struct rxe_pkt_info *pkt)
973 return pkt->paylen - rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD]
974 - bth_pad(pkt) - RXE_ICRC_SIZE;
977 #endif /* RXE_HDR_H */