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 */
25 u8 offset; /* bth offset from pkt->hdr */
28 /* Macros should be used only for received skb */
29 static inline struct rxe_pkt_info *SKB_TO_PKT(struct sk_buff *skb)
31 BUILD_BUG_ON(sizeof(struct rxe_pkt_info) > sizeof(skb->cb));
32 return (void *)skb->cb;
35 static inline struct sk_buff *PKT_TO_SKB(struct rxe_pkt_info *pkt)
37 return container_of((void *)pkt, struct sk_buff, cb);
41 * IBA header types and methods
43 * Some of these are for reference and completeness only since
44 * rxe does not currently support RD transport
45 * most of this could be moved into IB core. ib_pack.h has
46 * part of this but is incomplete
48 * Header specific routines to insert/extract values to/from headers
49 * the routines that are named __hhh_(set_)fff() take a pointer to a
50 * hhh header and get(set) the fff field. The routines named
51 * hhh_(set_)fff take a packet info struct and find the
52 * header and field based on the opcode in the packet.
53 * Conversion to/from network byte order from cpu order is also done.
56 #define RXE_ICRC_SIZE (4)
57 #define RXE_MAX_HDR_LENGTH (80)
59 /******************************************************************************
60 * Base Transport Header
61 ******************************************************************************/
71 #define BTH_DEF_PKEY (0xffff)
73 #define BTH_SE_MASK (0x80)
74 #define BTH_MIG_MASK (0x40)
75 #define BTH_PAD_MASK (0x30)
76 #define BTH_TVER_MASK (0x0f)
77 #define BTH_FECN_MASK (0x80000000)
78 #define BTH_BECN_MASK (0x40000000)
79 #define BTH_RESV6A_MASK (0x3f000000)
80 #define BTH_QPN_MASK (0x00ffffff)
81 #define BTH_ACK_MASK (0x80000000)
82 #define BTH_RESV7_MASK (0x7f000000)
83 #define BTH_PSN_MASK (0x00ffffff)
85 static inline u8 __bth_opcode(void *arg)
87 struct rxe_bth *bth = arg;
92 static inline void __bth_set_opcode(void *arg, u8 opcode)
94 struct rxe_bth *bth = arg;
99 static inline u8 __bth_se(void *arg)
101 struct rxe_bth *bth = arg;
103 return 0 != (BTH_SE_MASK & bth->flags);
106 static inline void __bth_set_se(void *arg, int se)
108 struct rxe_bth *bth = arg;
111 bth->flags |= BTH_SE_MASK;
113 bth->flags &= ~BTH_SE_MASK;
116 static inline u8 __bth_mig(void *arg)
118 struct rxe_bth *bth = arg;
120 return 0 != (BTH_MIG_MASK & bth->flags);
123 static inline void __bth_set_mig(void *arg, u8 mig)
125 struct rxe_bth *bth = arg;
128 bth->flags |= BTH_MIG_MASK;
130 bth->flags &= ~BTH_MIG_MASK;
133 static inline u8 __bth_pad(void *arg)
135 struct rxe_bth *bth = arg;
137 return (BTH_PAD_MASK & bth->flags) >> 4;
140 static inline void __bth_set_pad(void *arg, u8 pad)
142 struct rxe_bth *bth = arg;
144 bth->flags = (BTH_PAD_MASK & (pad << 4)) |
145 (~BTH_PAD_MASK & bth->flags);
148 static inline u8 __bth_tver(void *arg)
150 struct rxe_bth *bth = arg;
152 return BTH_TVER_MASK & bth->flags;
155 static inline void __bth_set_tver(void *arg, u8 tver)
157 struct rxe_bth *bth = arg;
159 bth->flags = (BTH_TVER_MASK & tver) |
160 (~BTH_TVER_MASK & bth->flags);
163 static inline u16 __bth_pkey(void *arg)
165 struct rxe_bth *bth = arg;
167 return be16_to_cpu(bth->pkey);
170 static inline void __bth_set_pkey(void *arg, u16 pkey)
172 struct rxe_bth *bth = arg;
174 bth->pkey = cpu_to_be16(pkey);
177 static inline u32 __bth_qpn(void *arg)
179 struct rxe_bth *bth = arg;
181 return BTH_QPN_MASK & be32_to_cpu(bth->qpn);
184 static inline void __bth_set_qpn(void *arg, u32 qpn)
186 struct rxe_bth *bth = arg;
187 u32 resvqpn = be32_to_cpu(bth->qpn);
189 bth->qpn = cpu_to_be32((BTH_QPN_MASK & qpn) |
190 (~BTH_QPN_MASK & resvqpn));
193 static inline int __bth_fecn(void *arg)
195 struct rxe_bth *bth = arg;
197 return 0 != (cpu_to_be32(BTH_FECN_MASK) & bth->qpn);
200 static inline void __bth_set_fecn(void *arg, int fecn)
202 struct rxe_bth *bth = arg;
205 bth->qpn |= cpu_to_be32(BTH_FECN_MASK);
207 bth->qpn &= ~cpu_to_be32(BTH_FECN_MASK);
210 static inline int __bth_becn(void *arg)
212 struct rxe_bth *bth = arg;
214 return 0 != (cpu_to_be32(BTH_BECN_MASK) & bth->qpn);
217 static inline void __bth_set_becn(void *arg, int becn)
219 struct rxe_bth *bth = arg;
222 bth->qpn |= cpu_to_be32(BTH_BECN_MASK);
224 bth->qpn &= ~cpu_to_be32(BTH_BECN_MASK);
227 static inline u8 __bth_resv6a(void *arg)
229 struct rxe_bth *bth = arg;
231 return (BTH_RESV6A_MASK & be32_to_cpu(bth->qpn)) >> 24;
234 static inline void __bth_set_resv6a(void *arg)
236 struct rxe_bth *bth = arg;
238 bth->qpn = cpu_to_be32(~BTH_RESV6A_MASK);
241 static inline int __bth_ack(void *arg)
243 struct rxe_bth *bth = arg;
245 return 0 != (cpu_to_be32(BTH_ACK_MASK) & bth->apsn);
248 static inline void __bth_set_ack(void *arg, int ack)
250 struct rxe_bth *bth = arg;
253 bth->apsn |= cpu_to_be32(BTH_ACK_MASK);
255 bth->apsn &= ~cpu_to_be32(BTH_ACK_MASK);
258 static inline void __bth_set_resv7(void *arg)
260 struct rxe_bth *bth = arg;
262 bth->apsn &= ~cpu_to_be32(BTH_RESV7_MASK);
265 static inline u32 __bth_psn(void *arg)
267 struct rxe_bth *bth = arg;
269 return BTH_PSN_MASK & be32_to_cpu(bth->apsn);
272 static inline void __bth_set_psn(void *arg, u32 psn)
274 struct rxe_bth *bth = arg;
275 u32 apsn = be32_to_cpu(bth->apsn);
277 bth->apsn = cpu_to_be32((BTH_PSN_MASK & psn) |
278 (~BTH_PSN_MASK & apsn));
281 static inline u8 bth_opcode(struct rxe_pkt_info *pkt)
283 return __bth_opcode(pkt->hdr + pkt->offset);
286 static inline void bth_set_opcode(struct rxe_pkt_info *pkt, u8 opcode)
288 __bth_set_opcode(pkt->hdr + pkt->offset, opcode);
291 static inline u8 bth_se(struct rxe_pkt_info *pkt)
293 return __bth_se(pkt->hdr + pkt->offset);
296 static inline void bth_set_se(struct rxe_pkt_info *pkt, int se)
298 __bth_set_se(pkt->hdr + pkt->offset, se);
301 static inline u8 bth_mig(struct rxe_pkt_info *pkt)
303 return __bth_mig(pkt->hdr + pkt->offset);
306 static inline void bth_set_mig(struct rxe_pkt_info *pkt, u8 mig)
308 __bth_set_mig(pkt->hdr + pkt->offset, mig);
311 static inline u8 bth_pad(struct rxe_pkt_info *pkt)
313 return __bth_pad(pkt->hdr + pkt->offset);
316 static inline void bth_set_pad(struct rxe_pkt_info *pkt, u8 pad)
318 __bth_set_pad(pkt->hdr + pkt->offset, pad);
321 static inline u8 bth_tver(struct rxe_pkt_info *pkt)
323 return __bth_tver(pkt->hdr + pkt->offset);
326 static inline void bth_set_tver(struct rxe_pkt_info *pkt, u8 tver)
328 __bth_set_tver(pkt->hdr + pkt->offset, tver);
331 static inline u16 bth_pkey(struct rxe_pkt_info *pkt)
333 return __bth_pkey(pkt->hdr + pkt->offset);
336 static inline void bth_set_pkey(struct rxe_pkt_info *pkt, u16 pkey)
338 __bth_set_pkey(pkt->hdr + pkt->offset, pkey);
341 static inline u32 bth_qpn(struct rxe_pkt_info *pkt)
343 return __bth_qpn(pkt->hdr + pkt->offset);
346 static inline void bth_set_qpn(struct rxe_pkt_info *pkt, u32 qpn)
348 __bth_set_qpn(pkt->hdr + pkt->offset, qpn);
351 static inline int bth_fecn(struct rxe_pkt_info *pkt)
353 return __bth_fecn(pkt->hdr + pkt->offset);
356 static inline void bth_set_fecn(struct rxe_pkt_info *pkt, int fecn)
358 __bth_set_fecn(pkt->hdr + pkt->offset, fecn);
361 static inline int bth_becn(struct rxe_pkt_info *pkt)
363 return __bth_becn(pkt->hdr + pkt->offset);
366 static inline void bth_set_becn(struct rxe_pkt_info *pkt, int becn)
368 __bth_set_becn(pkt->hdr + pkt->offset, becn);
371 static inline u8 bth_resv6a(struct rxe_pkt_info *pkt)
373 return __bth_resv6a(pkt->hdr + pkt->offset);
376 static inline void bth_set_resv6a(struct rxe_pkt_info *pkt)
378 __bth_set_resv6a(pkt->hdr + pkt->offset);
381 static inline int bth_ack(struct rxe_pkt_info *pkt)
383 return __bth_ack(pkt->hdr + pkt->offset);
386 static inline void bth_set_ack(struct rxe_pkt_info *pkt, int ack)
388 __bth_set_ack(pkt->hdr + pkt->offset, ack);
391 static inline void bth_set_resv7(struct rxe_pkt_info *pkt)
393 __bth_set_resv7(pkt->hdr + pkt->offset);
396 static inline u32 bth_psn(struct rxe_pkt_info *pkt)
398 return __bth_psn(pkt->hdr + pkt->offset);
401 static inline void bth_set_psn(struct rxe_pkt_info *pkt, u32 psn)
403 __bth_set_psn(pkt->hdr + pkt->offset, psn);
406 static inline void bth_init(struct rxe_pkt_info *pkt, u8 opcode, int se,
407 int mig, int pad, u16 pkey, u32 qpn, int ack_req,
410 struct rxe_bth *bth = (struct rxe_bth *)(pkt->hdr + pkt->offset);
412 bth->opcode = opcode;
413 bth->flags = (pad << 4) & BTH_PAD_MASK;
415 bth->flags |= BTH_SE_MASK;
417 bth->flags |= BTH_MIG_MASK;
418 bth->pkey = cpu_to_be16(pkey);
419 bth->qpn = cpu_to_be32(qpn & BTH_QPN_MASK);
423 bth->apsn = cpu_to_be32(psn);
426 /******************************************************************************
427 * Reliable Datagram Extended Transport Header
428 ******************************************************************************/
433 #define RDETH_EEN_MASK (0x00ffffff)
435 static inline u8 __rdeth_een(void *arg)
437 struct rxe_rdeth *rdeth = arg;
439 return RDETH_EEN_MASK & be32_to_cpu(rdeth->een);
442 static inline void __rdeth_set_een(void *arg, u32 een)
444 struct rxe_rdeth *rdeth = arg;
446 rdeth->een = cpu_to_be32(RDETH_EEN_MASK & een);
449 static inline u8 rdeth_een(struct rxe_pkt_info *pkt)
451 return __rdeth_een(pkt->hdr + pkt->offset
452 + rxe_opcode[pkt->opcode].offset[RXE_RDETH]);
455 static inline void rdeth_set_een(struct rxe_pkt_info *pkt, u32 een)
457 __rdeth_set_een(pkt->hdr + pkt->offset
458 + rxe_opcode[pkt->opcode].offset[RXE_RDETH], een);
461 /******************************************************************************
462 * Datagram Extended Transport Header
463 ******************************************************************************/
469 #define GSI_QKEY (0x80010000)
470 #define DETH_SQP_MASK (0x00ffffff)
472 static inline u32 __deth_qkey(void *arg)
474 struct rxe_deth *deth = arg;
476 return be32_to_cpu(deth->qkey);
479 static inline void __deth_set_qkey(void *arg, u32 qkey)
481 struct rxe_deth *deth = arg;
483 deth->qkey = cpu_to_be32(qkey);
486 static inline u32 __deth_sqp(void *arg)
488 struct rxe_deth *deth = arg;
490 return DETH_SQP_MASK & be32_to_cpu(deth->sqp);
493 static inline void __deth_set_sqp(void *arg, u32 sqp)
495 struct rxe_deth *deth = arg;
497 deth->sqp = cpu_to_be32(DETH_SQP_MASK & sqp);
500 static inline u32 deth_qkey(struct rxe_pkt_info *pkt)
502 return __deth_qkey(pkt->hdr + pkt->offset
503 + rxe_opcode[pkt->opcode].offset[RXE_DETH]);
506 static inline void deth_set_qkey(struct rxe_pkt_info *pkt, u32 qkey)
508 __deth_set_qkey(pkt->hdr + pkt->offset
509 + rxe_opcode[pkt->opcode].offset[RXE_DETH], qkey);
512 static inline u32 deth_sqp(struct rxe_pkt_info *pkt)
514 return __deth_sqp(pkt->hdr + pkt->offset
515 + rxe_opcode[pkt->opcode].offset[RXE_DETH]);
518 static inline void deth_set_sqp(struct rxe_pkt_info *pkt, u32 sqp)
520 __deth_set_sqp(pkt->hdr + pkt->offset
521 + rxe_opcode[pkt->opcode].offset[RXE_DETH], sqp);
524 /******************************************************************************
525 * RDMA Extended Transport Header
526 ******************************************************************************/
533 static inline u64 __reth_va(void *arg)
535 struct rxe_reth *reth = arg;
537 return be64_to_cpu(reth->va);
540 static inline void __reth_set_va(void *arg, u64 va)
542 struct rxe_reth *reth = arg;
544 reth->va = cpu_to_be64(va);
547 static inline u32 __reth_rkey(void *arg)
549 struct rxe_reth *reth = arg;
551 return be32_to_cpu(reth->rkey);
554 static inline void __reth_set_rkey(void *arg, u32 rkey)
556 struct rxe_reth *reth = arg;
558 reth->rkey = cpu_to_be32(rkey);
561 static inline u32 __reth_len(void *arg)
563 struct rxe_reth *reth = arg;
565 return be32_to_cpu(reth->len);
568 static inline void __reth_set_len(void *arg, u32 len)
570 struct rxe_reth *reth = arg;
572 reth->len = cpu_to_be32(len);
575 static inline u64 reth_va(struct rxe_pkt_info *pkt)
577 return __reth_va(pkt->hdr + pkt->offset
578 + rxe_opcode[pkt->opcode].offset[RXE_RETH]);
581 static inline void reth_set_va(struct rxe_pkt_info *pkt, u64 va)
583 __reth_set_va(pkt->hdr + pkt->offset
584 + rxe_opcode[pkt->opcode].offset[RXE_RETH], va);
587 static inline u32 reth_rkey(struct rxe_pkt_info *pkt)
589 return __reth_rkey(pkt->hdr + pkt->offset
590 + rxe_opcode[pkt->opcode].offset[RXE_RETH]);
593 static inline void reth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey)
595 __reth_set_rkey(pkt->hdr + pkt->offset
596 + rxe_opcode[pkt->opcode].offset[RXE_RETH], rkey);
599 static inline u32 reth_len(struct rxe_pkt_info *pkt)
601 return __reth_len(pkt->hdr + pkt->offset
602 + rxe_opcode[pkt->opcode].offset[RXE_RETH]);
605 static inline void reth_set_len(struct rxe_pkt_info *pkt, u32 len)
607 __reth_set_len(pkt->hdr + pkt->offset
608 + rxe_opcode[pkt->opcode].offset[RXE_RETH], len);
611 /******************************************************************************
612 * Atomic Extended Transport Header
613 ******************************************************************************/
621 static inline u64 __atmeth_va(void *arg)
623 struct rxe_atmeth *atmeth = arg;
625 return be64_to_cpu(atmeth->va);
628 static inline void __atmeth_set_va(void *arg, u64 va)
630 struct rxe_atmeth *atmeth = arg;
632 atmeth->va = cpu_to_be64(va);
635 static inline u32 __atmeth_rkey(void *arg)
637 struct rxe_atmeth *atmeth = arg;
639 return be32_to_cpu(atmeth->rkey);
642 static inline void __atmeth_set_rkey(void *arg, u32 rkey)
644 struct rxe_atmeth *atmeth = arg;
646 atmeth->rkey = cpu_to_be32(rkey);
649 static inline u64 __atmeth_swap_add(void *arg)
651 struct rxe_atmeth *atmeth = arg;
653 return be64_to_cpu(atmeth->swap_add);
656 static inline void __atmeth_set_swap_add(void *arg, u64 swap_add)
658 struct rxe_atmeth *atmeth = arg;
660 atmeth->swap_add = cpu_to_be64(swap_add);
663 static inline u64 __atmeth_comp(void *arg)
665 struct rxe_atmeth *atmeth = arg;
667 return be64_to_cpu(atmeth->comp);
670 static inline void __atmeth_set_comp(void *arg, u64 comp)
672 struct rxe_atmeth *atmeth = arg;
674 atmeth->comp = cpu_to_be64(comp);
677 static inline u64 atmeth_va(struct rxe_pkt_info *pkt)
679 return __atmeth_va(pkt->hdr + pkt->offset
680 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
683 static inline void atmeth_set_va(struct rxe_pkt_info *pkt, u64 va)
685 __atmeth_set_va(pkt->hdr + pkt->offset
686 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], va);
689 static inline u32 atmeth_rkey(struct rxe_pkt_info *pkt)
691 return __atmeth_rkey(pkt->hdr + pkt->offset
692 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
695 static inline void atmeth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey)
697 __atmeth_set_rkey(pkt->hdr + pkt->offset
698 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], rkey);
701 static inline u64 atmeth_swap_add(struct rxe_pkt_info *pkt)
703 return __atmeth_swap_add(pkt->hdr + pkt->offset
704 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
707 static inline void atmeth_set_swap_add(struct rxe_pkt_info *pkt, u64 swap_add)
709 __atmeth_set_swap_add(pkt->hdr + pkt->offset
710 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], swap_add);
713 static inline u64 atmeth_comp(struct rxe_pkt_info *pkt)
715 return __atmeth_comp(pkt->hdr + pkt->offset
716 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH]);
719 static inline void atmeth_set_comp(struct rxe_pkt_info *pkt, u64 comp)
721 __atmeth_set_comp(pkt->hdr + pkt->offset
722 + rxe_opcode[pkt->opcode].offset[RXE_ATMETH], comp);
725 /******************************************************************************
726 * Ack Extended Transport Header
727 ******************************************************************************/
732 #define AETH_SYN_MASK (0xff000000)
733 #define AETH_MSN_MASK (0x00ffffff)
736 AETH_TYPE_MASK = 0xe0,
741 AETH_ACK_UNLIMITED = 0x1f,
742 AETH_NAK_PSN_SEQ_ERROR = 0x60,
743 AETH_NAK_INVALID_REQ = 0x61,
744 AETH_NAK_REM_ACC_ERR = 0x62,
745 AETH_NAK_REM_OP_ERR = 0x63,
746 AETH_NAK_INV_RD_REQ = 0x64,
749 static inline u8 __aeth_syn(void *arg)
751 struct rxe_aeth *aeth = arg;
753 return (AETH_SYN_MASK & be32_to_cpu(aeth->smsn)) >> 24;
756 static inline void __aeth_set_syn(void *arg, u8 syn)
758 struct rxe_aeth *aeth = arg;
759 u32 smsn = be32_to_cpu(aeth->smsn);
761 aeth->smsn = cpu_to_be32((AETH_SYN_MASK & (syn << 24)) |
762 (~AETH_SYN_MASK & smsn));
765 static inline u32 __aeth_msn(void *arg)
767 struct rxe_aeth *aeth = arg;
769 return AETH_MSN_MASK & be32_to_cpu(aeth->smsn);
772 static inline void __aeth_set_msn(void *arg, u32 msn)
774 struct rxe_aeth *aeth = arg;
775 u32 smsn = be32_to_cpu(aeth->smsn);
777 aeth->smsn = cpu_to_be32((AETH_MSN_MASK & msn) |
778 (~AETH_MSN_MASK & smsn));
781 static inline u8 aeth_syn(struct rxe_pkt_info *pkt)
783 return __aeth_syn(pkt->hdr + pkt->offset
784 + rxe_opcode[pkt->opcode].offset[RXE_AETH]);
787 static inline void aeth_set_syn(struct rxe_pkt_info *pkt, u8 syn)
789 __aeth_set_syn(pkt->hdr + pkt->offset
790 + rxe_opcode[pkt->opcode].offset[RXE_AETH], syn);
793 static inline u32 aeth_msn(struct rxe_pkt_info *pkt)
795 return __aeth_msn(pkt->hdr + pkt->offset
796 + rxe_opcode[pkt->opcode].offset[RXE_AETH]);
799 static inline void aeth_set_msn(struct rxe_pkt_info *pkt, u32 msn)
801 __aeth_set_msn(pkt->hdr + pkt->offset
802 + rxe_opcode[pkt->opcode].offset[RXE_AETH], msn);
805 /******************************************************************************
806 * Atomic Ack Extended Transport Header
807 ******************************************************************************/
812 static inline u64 __atmack_orig(void *arg)
814 struct rxe_atmack *atmack = arg;
816 return be64_to_cpu(atmack->orig);
819 static inline void __atmack_set_orig(void *arg, u64 orig)
821 struct rxe_atmack *atmack = arg;
823 atmack->orig = cpu_to_be64(orig);
826 static inline u64 atmack_orig(struct rxe_pkt_info *pkt)
828 return __atmack_orig(pkt->hdr + pkt->offset
829 + rxe_opcode[pkt->opcode].offset[RXE_ATMACK]);
832 static inline void atmack_set_orig(struct rxe_pkt_info *pkt, u64 orig)
834 __atmack_set_orig(pkt->hdr + pkt->offset
835 + rxe_opcode[pkt->opcode].offset[RXE_ATMACK], orig);
838 /******************************************************************************
839 * Immediate Extended Transport Header
840 ******************************************************************************/
845 static inline __be32 __immdt_imm(void *arg)
847 struct rxe_immdt *immdt = arg;
852 static inline void __immdt_set_imm(void *arg, __be32 imm)
854 struct rxe_immdt *immdt = arg;
859 static inline __be32 immdt_imm(struct rxe_pkt_info *pkt)
861 return __immdt_imm(pkt->hdr + pkt->offset
862 + rxe_opcode[pkt->opcode].offset[RXE_IMMDT]);
865 static inline void immdt_set_imm(struct rxe_pkt_info *pkt, __be32 imm)
867 __immdt_set_imm(pkt->hdr + pkt->offset
868 + rxe_opcode[pkt->opcode].offset[RXE_IMMDT], imm);
871 /******************************************************************************
872 * Invalidate Extended Transport Header
873 ******************************************************************************/
878 static inline u32 __ieth_rkey(void *arg)
880 struct rxe_ieth *ieth = arg;
882 return be32_to_cpu(ieth->rkey);
885 static inline void __ieth_set_rkey(void *arg, u32 rkey)
887 struct rxe_ieth *ieth = arg;
889 ieth->rkey = cpu_to_be32(rkey);
892 static inline u32 ieth_rkey(struct rxe_pkt_info *pkt)
894 return __ieth_rkey(pkt->hdr + pkt->offset
895 + rxe_opcode[pkt->opcode].offset[RXE_IETH]);
898 static inline void ieth_set_rkey(struct rxe_pkt_info *pkt, u32 rkey)
900 __ieth_set_rkey(pkt->hdr + pkt->offset
901 + rxe_opcode[pkt->opcode].offset[RXE_IETH], rkey);
904 enum rxe_hdr_length {
905 RXE_BTH_BYTES = sizeof(struct rxe_bth),
906 RXE_DETH_BYTES = sizeof(struct rxe_deth),
907 RXE_IMMDT_BYTES = sizeof(struct rxe_immdt),
908 RXE_RETH_BYTES = sizeof(struct rxe_reth),
909 RXE_AETH_BYTES = sizeof(struct rxe_aeth),
910 RXE_ATMACK_BYTES = sizeof(struct rxe_atmack),
911 RXE_ATMETH_BYTES = sizeof(struct rxe_atmeth),
912 RXE_IETH_BYTES = sizeof(struct rxe_ieth),
913 RXE_RDETH_BYTES = sizeof(struct rxe_rdeth),
916 static inline size_t header_size(struct rxe_pkt_info *pkt)
918 return pkt->offset + rxe_opcode[pkt->opcode].length;
921 static inline void *payload_addr(struct rxe_pkt_info *pkt)
923 return pkt->hdr + pkt->offset
924 + rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD];
927 static inline size_t payload_size(struct rxe_pkt_info *pkt)
929 return pkt->paylen - rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD]
930 - bth_pad(pkt) - RXE_ICRC_SIZE;
933 #endif /* RXE_HDR_H */