hfi1_put_tid(dd, i, PT_INVALID, 0, 0);
 }
 
-struct hfi1_message_header *hfi1_get_msgheader(
-                               struct hfi1_devdata *dd, __le32 *rhf_addr)
+struct ib_header *hfi1_get_msgheader(
+       struct hfi1_devdata *dd, __le32 *rhf_addr)
 {
        u32 offset = rhf_hdrq_offset(rhf_to_cpu(rhf_addr));
 
-       return (struct hfi1_message_header *)
+       return (struct ib_header *)
                (rhf_addr - dd->rhf_offset + offset);
 }
 
 
 u64 get_all_cpu_total(u64 __percpu *cntr);
 void hfi1_start_cleanup(struct hfi1_devdata *dd);
 void hfi1_clear_tids(struct hfi1_ctxtdata *rcd);
-struct hfi1_message_header *hfi1_get_msgheader(
+struct ib_header *hfi1_get_msgheader(
                                struct hfi1_devdata *dd, __le32 *rhf_addr);
 int hfi1_init_ctxt(struct send_context *sc);
 void hfi1_put_tid(struct hfi1_devdata *dd, u32 index,
 
 /* RHF receive type error - bypass packet errors */
 #define RHF_RTE_BYPASS_NO_ERR          0x0
 
-/*
- * This structure contains the first field common to all protocols
- * that employ this chip.
- */
-struct hfi1_message_header {
-       __be16 lrh[4];
-};
-
 /* IB - LRH header constants */
 #define HFI1_LRH_GRH 0x0003      /* 1. word of IB LRH - next header: GRH */
 #define HFI1_LRH_BTH 0x0002      /* 1. word of IB LRH - next header: BTH */
 
 static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
                       struct hfi1_packet *packet)
 {
-       struct hfi1_message_header *rhdr = packet->hdr;
+       struct ib_header *rhdr = packet->hdr;
        u32 rte = rhf_rcv_type_err(packet->rhf);
        int lnh = be16_to_cpu(rhdr->lrh[0]) & 3;
        struct hfi1_ibport *ibp = &ppd->ibport_data;
 
        if (packet->rhf & RHF_TID_ERR) {
                /* For TIDERR and RC QPs preemptively schedule a NAK */
-               struct hfi1_ib_header *hdr = (struct hfi1_ib_header *)rhdr;
-               struct hfi1_other_headers *ohdr = NULL;
+               struct ib_other_headers *ohdr = NULL;
                u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
-               u16 lid  = be16_to_cpu(hdr->lrh[1]);
+               u16 lid  = be16_to_cpu(rhdr->lrh[1]);
                u32 qp_num;
                u32 rcv_flags = 0;
 
 
                /* Check for GRH */
                if (lnh == HFI1_LRH_BTH) {
-                       ohdr = &hdr->u.oth;
+                       ohdr = &rhdr->u.oth;
                } else if (lnh == HFI1_LRH_GRH) {
                        u32 vtf;
 
-                       ohdr = &hdr->u.l.oth;
-                       if (hdr->u.l.grh.next_hdr != IB_GRH_NEXT_HDR)
+                       ohdr = &rhdr->u.l.oth;
+                       if (rhdr->u.l.grh.next_hdr != IB_GRH_NEXT_HDR)
                                goto drop;
-                       vtf = be32_to_cpu(hdr->u.l.grh.version_tclass_flow);
+                       vtf = be32_to_cpu(rhdr->u.l.grh.version_tclass_flow);
                        if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
                                goto drop;
                        rcv_flags |= HFI1_HAS_GRH;
                        case IB_QPT_RC:
                                hfi1_rc_hdrerr(
                                        rcd,
-                                       hdr,
+                                       rhdr,
                                        rcv_flags,
                                        qp);
                                break;
                               bool do_cnp)
 {
        struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
-       struct hfi1_ib_header *hdr = pkt->hdr;
-       struct hfi1_other_headers *ohdr = pkt->ohdr;
+       struct ib_header *hdr = pkt->hdr;
+       struct ib_other_headers *ohdr = pkt->ohdr;
        struct ib_grh *grh = NULL;
        u32 rqpn = 0, bth1;
        u16 rlid, dlid = be16_to_cpu(hdr->lrh[1]);
                return;
        }
 
-       sc = hdr2sc((struct hfi1_message_header *)hdr, pkt->rhf);
+       sc = hdr2sc(hdr, pkt->rhf);
 
        bth1 = be32_to_cpu(ohdr->bth[1]);
        if (do_cnp && (bth1 & HFI1_FECN_SMASK)) {
                __le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
                                         dd->rhf_offset;
                struct rvt_qp *qp;
-               struct hfi1_ib_header *hdr;
-               struct hfi1_other_headers *ohdr;
+               struct ib_header *hdr;
+               struct ib_other_headers *ohdr;
                struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
                u64 rhf = rhf_to_cpu(rhf_addr);
                u32 etype = rhf_rcv_type(rhf), qpn, bth1;
                if (etype != RHF_RCV_TYPE_IB)
                        goto next;
 
-               hdr = (struct hfi1_ib_header *)
-                       hfi1_get_msgheader(dd, rhf_addr);
+               hdr = hfi1_get_msgheader(dd, rhf_addr);
+
                lnh = be16_to_cpu(hdr->lrh[0]) & 3;
 
                if (lnh == HFI1_LRH_BTH)
                                      struct hfi1_devdata *dd)
 {
        struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
-       struct hfi1_message_header *hdr = hfi1_get_msgheader(packet->rcd->dd,
-                                                            packet->rhf_addr);
+       struct ib_header *hdr = hfi1_get_msgheader(packet->rcd->dd,
+                                                  packet->rhf_addr);
        u8 etype = rhf_rcv_type(packet->rhf);
 
        if (etype == RHF_RCV_TYPE_IB && hdr2sc(hdr, packet->rhf) != 0xf) {
 
 #include <linux/kthread.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
+#include <rdma/ib_hdrs.h>
 #include <rdma/rdma_vt.h>
 
 #include "chip_registers.h"
        struct hfi1_ctxtdata *rcd;
        __le32 *rhf_addr;
        struct rvt_qp *qp;
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        u64 rhf;
        u32 maxcnt;
        u32 rhqoff;
 void receive_interrupt_work(struct work_struct *work);
 
 /* extract service channel from header and rhf */
-static inline int hdr2sc(struct hfi1_message_header *hdr, u64 rhf)
+static inline int hdr2sc(struct ib_header *hdr, u64 rhf)
 {
        return ((be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf) |
               ((!!(rhf_dc_info(rhf))) << 4);
 static inline bool process_ecn(struct rvt_qp *qp, struct hfi1_packet *pkt,
                               bool do_cnp)
 {
-       struct hfi1_other_headers *ohdr = pkt->ohdr;
+       struct ib_other_headers *ohdr = pkt->ohdr;
        u32 bth1;
 
        bth1 = be32_to_cpu(ohdr->bth[1]);
 
  * Note the QP s_lock must be held.
  */
 static int make_rc_ack(struct hfi1_ibdev *dev, struct rvt_qp *qp,
-                      struct hfi1_other_headers *ohdr,
+                      struct ib_other_headers *ohdr,
                       struct hfi1_pkt_state *ps)
 {
        struct rvt_ack_entry *e;
                        len = 0;
                        qp->s_ack_state = OP(ATOMIC_ACKNOWLEDGE);
                        ohdr->u.at.aeth = hfi1_compute_aeth(qp);
-                       ohdr->u.at.atomic_ack_eth[0] =
-                               cpu_to_be32(e->atomic_data >> 32);
-                       ohdr->u.at.atomic_ack_eth[1] =
-                               cpu_to_be32(e->atomic_data);
+                       ib_u64_put(e->atomic_data, &ohdr->u.at.atomic_ack_eth);
                        hwords += sizeof(ohdr->u.at) / sizeof(u32);
                        bth2 = mask_psn(e->psn);
                        e->sent = 1;
 {
        struct hfi1_qp_priv *priv = qp->priv;
        struct hfi1_ibdev *dev = to_idev(qp->ibqp.device);
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_sge_state *ss;
        struct rvt_swqe *wqe;
        /* header size in 32-bit words LRH+BTH = (8+12)/4. */
                                qp->s_flags |= RVT_S_WAIT_SSN_CREDIT;
                                goto bail;
                        }
-                       ohdr->u.rc.reth.vaddr =
-                               cpu_to_be64(wqe->rdma_wr.remote_addr);
+                       put_ib_reth_vaddr(
+                               wqe->rdma_wr.remote_addr,
+                               &ohdr->u.rc.reth);
                        ohdr->u.rc.reth.rkey =
                                cpu_to_be32(wqe->rdma_wr.rkey);
                        ohdr->u.rc.reth.length = cpu_to_be32(len);
                                if (!(qp->s_flags & RVT_S_UNLIMITED_CREDIT))
                                        qp->s_lsn++;
                        }
-                       ohdr->u.rc.reth.vaddr =
-                               cpu_to_be64(wqe->rdma_wr.remote_addr);
+                       put_ib_reth_vaddr(
+                               wqe->rdma_wr.remote_addr,
+                               &ohdr->u.rc.reth);
                        ohdr->u.rc.reth.rkey =
                                cpu_to_be32(wqe->rdma_wr.rkey);
                        ohdr->u.rc.reth.length = cpu_to_be32(len);
                        }
                        if (wqe->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
                                qp->s_state = OP(COMPARE_SWAP);
-                               ohdr->u.atomic_eth.swap_data = cpu_to_be64(
-                                       wqe->atomic_wr.swap);
-                               ohdr->u.atomic_eth.compare_data = cpu_to_be64(
-                                       wqe->atomic_wr.compare_add);
+                               put_ib_ateth_swap(wqe->atomic_wr.swap,
+                                                 &ohdr->u.atomic_eth);
+                               put_ib_ateth_compare(wqe->atomic_wr.compare_add,
+                                                    &ohdr->u.atomic_eth);
                        } else {
                                qp->s_state = OP(FETCH_ADD);
-                               ohdr->u.atomic_eth.swap_data = cpu_to_be64(
-                                       wqe->atomic_wr.compare_add);
-                               ohdr->u.atomic_eth.compare_data = 0;
+                               put_ib_ateth_swap(wqe->atomic_wr.compare_add,
+                                                 &ohdr->u.atomic_eth);
+                               put_ib_ateth_compare(0, &ohdr->u.atomic_eth);
                        }
-                       ohdr->u.atomic_eth.vaddr[0] = cpu_to_be32(
-                               wqe->atomic_wr.remote_addr >> 32);
-                       ohdr->u.atomic_eth.vaddr[1] = cpu_to_be32(
-                               wqe->atomic_wr.remote_addr);
+                       put_ib_ateth_vaddr(wqe->atomic_wr.remote_addr,
+                                          &ohdr->u.atomic_eth);
                        ohdr->u.atomic_eth.rkey = cpu_to_be32(
                                wqe->atomic_wr.rkey);
                        hwords += sizeof(struct ib_atomic_eth) / sizeof(u32);
                 * See restart_rc().
                 */
                len = (delta_psn(qp->s_psn, wqe->psn)) * pmtu;
-               ohdr->u.rc.reth.vaddr =
-                       cpu_to_be64(wqe->rdma_wr.remote_addr + len);
+               put_ib_reth_vaddr(
+                       wqe->rdma_wr.remote_addr + len,
+                       &ohdr->u.rc.reth);
                ohdr->u.rc.reth.rkey =
                        cpu_to_be32(wqe->rdma_wr.rkey);
                ohdr->u.rc.reth.length = cpu_to_be32(wqe->length - len);
        u32 vl, plen;
        struct send_context *sc;
        struct pio_buf *pbuf;
-       struct hfi1_ib_header hdr;
-       struct hfi1_other_headers *ohdr;
+       struct ib_header hdr;
+       struct ib_other_headers *ohdr;
        unsigned long flags;
 
        /* Don't send ACK or NAK if a RDMA read or atomic is pending. */
 /*
  * This should be called with the QP s_lock held and interrupts disabled.
  */
-void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_ib_header *hdr)
+void hfi1_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr)
 {
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_swqe *wqe;
        struct ib_wc wc;
        unsigned i;
  * Called at interrupt level.
  */
 static void rc_rcv_resp(struct hfi1_ibport *ibp,
-                       struct hfi1_other_headers *ohdr,
+                       struct ib_other_headers *ohdr,
                        void *data, u32 tlen, struct rvt_qp *qp,
                        u32 opcode, u32 psn, u32 hdrsize, u32 pmtu,
                        struct hfi1_ctxtdata *rcd)
        case OP(ATOMIC_ACKNOWLEDGE):
        case OP(RDMA_READ_RESPONSE_FIRST):
                aeth = be32_to_cpu(ohdr->u.aeth);
-               if (opcode == OP(ATOMIC_ACKNOWLEDGE)) {
-                       __be32 *p = ohdr->u.at.atomic_ack_eth;
-
-                       val = ((u64)be32_to_cpu(p[0]) << 32) |
-                               be32_to_cpu(p[1]);
-               } else {
+               if (opcode == OP(ATOMIC_ACKNOWLEDGE))
+                       val = ib_u64_get(&ohdr->u.at.atomic_ack_eth);
+               else
                        val = 0;
-               }
                if (!do_rc_ack(qp, aeth, psn, opcode, val, rcd) ||
                    opcode != OP(RDMA_READ_RESPONSE_FIRST))
                        goto ack_done;
  * Return 1 if no more processing is needed; otherwise return 0 to
  * schedule a response to be sent.
  */
-static noinline int rc_rcv_error(struct hfi1_other_headers *ohdr, void *data,
+static noinline int rc_rcv_error(struct ib_other_headers *ohdr, void *data,
                                 struct rvt_qp *qp, u32 opcode, u32 psn,
                                 int diff, struct hfi1_ctxtdata *rcd)
 {
                }
                if (len != 0) {
                        u32 rkey = be32_to_cpu(reth->rkey);
-                       u64 vaddr = be64_to_cpu(reth->vaddr);
+                       u64 vaddr = get_ib_reth_vaddr(reth);
                        int ok;
 
                        ok = rvt_rkey_ok(qp, &e->rdma_sge, len, vaddr, rkey,
 void hfi1_rc_rcv(struct hfi1_packet *packet)
 {
        struct hfi1_ctxtdata *rcd = packet->rcd;
-       struct hfi1_ib_header *hdr = packet->hdr;
+       struct ib_header *hdr = packet->hdr;
        u32 rcv_flags = packet->rcv_flags;
        void *data = packet->ebuf;
        u32 tlen = packet->tlen;
        struct rvt_qp *qp = packet->qp;
        struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
-       struct hfi1_other_headers *ohdr = packet->ohdr;
+       struct ib_other_headers *ohdr = packet->ohdr;
        u32 bth0, opcode;
        u32 hdrsize = packet->hlen;
        u32 psn;
                qp->r_sge.sg_list = NULL;
                if (qp->r_len != 0) {
                        u32 rkey = be32_to_cpu(reth->rkey);
-                       u64 vaddr = be64_to_cpu(reth->vaddr);
+                       u64 vaddr = get_ib_reth_vaddr(reth);
                        int ok;
 
                        /* Check rkey & NAK */
                len = be32_to_cpu(reth->length);
                if (len) {
                        u32 rkey = be32_to_cpu(reth->rkey);
-                       u64 vaddr = be64_to_cpu(reth->vaddr);
+                       u64 vaddr = get_ib_reth_vaddr(reth);
                        int ok;
 
                        /* Check rkey & NAK */
                        e->rdma_sge.mr = NULL;
                }
                ateth = &ohdr->u.atomic_eth;
-               vaddr = ((u64)be32_to_cpu(ateth->vaddr[0]) << 32) |
-                       be32_to_cpu(ateth->vaddr[1]);
+               vaddr = get_ib_ateth_vaddr(ateth);
                if (unlikely(vaddr & (sizeof(u64) - 1)))
                        goto nack_inv_unlck;
                rkey = be32_to_cpu(ateth->rkey);
                        goto nack_acc_unlck;
                /* Perform atomic OP and save result. */
                maddr = (atomic64_t *)qp->r_sge.sge.vaddr;
-               sdata = be64_to_cpu(ateth->swap_data);
+               sdata = get_ib_ateth_swap(ateth);
                e->atomic_data = (opcode == OP(FETCH_ADD)) ?
                        (u64)atomic64_add_return(sdata, maddr) - sdata :
                        (u64)cmpxchg((u64 *)qp->r_sge.sge.vaddr,
-                                     be64_to_cpu(ateth->compare_data),
+                                     get_ib_ateth_compare(ateth),
                                      sdata);
                rvt_put_mr(qp->r_sge.sge.mr);
                qp->r_sge.num_sge = 0;
 
 void hfi1_rc_hdrerr(
        struct hfi1_ctxtdata *rcd,
-       struct hfi1_ib_header *hdr,
+       struct ib_header *hdr,
        u32 rcv_flags,
        struct rvt_qp *qp)
 {
        int has_grh = rcv_flags & HFI1_HAS_GRH;
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
        int diff;
        u32 opcode;
 
  *
  * The s_lock will be acquired around the hfi1_migrate_qp() call.
  */
-int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_ib_header *hdr,
+int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct ib_header *hdr,
                       int has_grh, struct rvt_qp *qp, u32 bth0)
 {
        __be64 guid;
        }
 }
 
-void hfi1_make_ruc_header(struct rvt_qp *qp, struct hfi1_other_headers *ohdr,
+void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
                          u32 bth0, u32 bth2, int middle,
                          struct hfi1_pkt_state *ps)
 {
 
 #define CREATE_TRACE_POINTS
 #include "trace.h"
 
-u8 ibhdr_exhdr_len(struct hfi1_ib_header *hdr)
+u8 ibhdr_exhdr_len(struct ib_header *hdr)
 {
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        u8 opcode;
        u8 lnh = (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
 
 
 #define OP(transport, op) IB_OPCODE_## transport ## _ ## op
 
-static u64 ib_u64_get(__be32 *p)
-{
-       return ((u64)be32_to_cpu(p[0]) << 32) | be32_to_cpu(p[1]);
-}
-
 static const char *parse_syndrome(u8 syndrome)
 {
        switch (syndrome >> 5) {
        case OP(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE):
        case OP(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE):
                trace_seq_printf(p, RETH_PRN " " IMM_PRN,
-                                (unsigned long long)ib_u64_get(
-                                (__be32 *)&eh->rc.reth.vaddr),
+                                get_ib_reth_vaddr(&eh->rc.reth),
                                 be32_to_cpu(eh->rc.reth.rkey),
                                 be32_to_cpu(eh->rc.reth.length),
                                 be32_to_cpu(eh->rc.imm_data));
        case OP(RC, RDMA_WRITE_ONLY):
        case OP(UC, RDMA_WRITE_ONLY):
                trace_seq_printf(p, RETH_PRN,
-                                (unsigned long long)ib_u64_get(
-                                (__be32 *)&eh->rc.reth.vaddr),
+                                get_ib_reth_vaddr(&eh->rc.reth),
                                 be32_to_cpu(eh->rc.reth.rkey),
                                 be32_to_cpu(eh->rc.reth.length));
                break;
                                 be32_to_cpu(eh->at.aeth) >> 24,
                                 parse_syndrome(be32_to_cpu(eh->at.aeth) >> 24),
                                 be32_to_cpu(eh->at.aeth) & HFI1_MSN_MASK,
-                                (unsigned long long)
-                                ib_u64_get(eh->at.atomic_ack_eth));
+                                ib_u64_get(&eh->at.atomic_ack_eth));
                break;
        /* atomiceth */
        case OP(RC, COMPARE_SWAP):
        case OP(RC, FETCH_ADD):
                trace_seq_printf(p, ATOMICETH_PRN,
-                                (unsigned long long)ib_u64_get(
-                                eh->atomic_eth.vaddr),
+                                get_ib_ateth_vaddr(&eh->atomic_eth),
                                 eh->atomic_eth.rkey,
-                                (unsigned long long)ib_u64_get(
-                                (__be32 *)&eh->atomic_eth.swap_data),
-                                (unsigned long long)ib_u64_get(
-                                (__be32 *)&eh->atomic_eth.compare_data));
+                                get_ib_ateth_swap(&eh->atomic_eth),
+                                get_ib_ateth_compare(&eh->atomic_eth));
                break;
        /* deth */
        case OP(UD, SEND_ONLY):
 
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM hfi1_ibhdrs
 
-u8 ibhdr_exhdr_len(struct hfi1_ib_header *hdr);
+u8 ibhdr_exhdr_len(struct ib_header *hdr);
 const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
 
 #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
 
 DECLARE_EVENT_CLASS(hfi1_ibhdr_template,
                    TP_PROTO(struct hfi1_devdata *dd,
-                            struct hfi1_ib_header *hdr),
+                            struct ib_header *hdr),
                    TP_ARGS(dd, hdr),
                    TP_STRUCT__entry(
                        DD_DEV_ENTRY(dd)
                        __dynamic_array(u8, ehdrs, ibhdr_exhdr_len(hdr))
                        ),
                      TP_fast_assign(
-                       struct hfi1_other_headers *ohdr;
+                       struct ib_other_headers *ohdr;
 
                        DD_DEV_ASSIGN(dd);
                        /* LRH */
 );
 
 DEFINE_EVENT(hfi1_ibhdr_template, input_ibhdr,
-            TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
+            TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
             TP_ARGS(dd, hdr));
 
 DEFINE_EVENT(hfi1_ibhdr_template, pio_output_ibhdr,
-            TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
+            TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
             TP_ARGS(dd, hdr));
 
 DEFINE_EVENT(hfi1_ibhdr_template, ack_output_ibhdr,
-            TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
+            TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
             TP_ARGS(dd, hdr));
 
 DEFINE_EVENT(hfi1_ibhdr_template, sdma_output_ibhdr,
-            TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
+            TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
             TP_ARGS(dd, hdr));
 
 #endif /* __HFI1_TRACE_IBHDRS_H */
 
 TRACE_EVENT(snoop_capture,
            TP_PROTO(struct hfi1_devdata *dd,
                     int hdr_len,
-                    struct hfi1_ib_header *hdr,
+                    struct ib_header *hdr,
                     int data_len,
                     void *data),
            TP_ARGS(dd, hdr_len, hdr, data_len, data),
                             __dynamic_array(u8, raw_pkt, data_len)
                             ),
            TP_fast_assign(
-               struct hfi1_other_headers *ohdr;
+               struct ib_other_headers *ohdr;
 
                __entry->lnh = (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
                if (__entry->lnh == HFI1_LRH_BTH)
 
 int hfi1_make_uc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
 {
        struct hfi1_qp_priv *priv = qp->priv;
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_swqe *wqe;
        u32 hwords = 5;
        u32 bth0 = 0;
 void hfi1_uc_rcv(struct hfi1_packet *packet)
 {
        struct hfi1_ibport *ibp = &packet->rcd->ppd->ibport_data;
-       struct hfi1_ib_header *hdr = packet->hdr;
+       struct ib_header *hdr = packet->hdr;
        u32 rcv_flags = packet->rcv_flags;
        void *data = packet->ebuf;
        u32 tlen = packet->tlen;
        struct rvt_qp *qp = packet->qp;
-       struct hfi1_other_headers *ohdr = packet->ohdr;
+       struct ib_other_headers *ohdr = packet->ohdr;
        u32 bth0, opcode;
        u32 hdrsize = packet->hlen;
        u32 psn;
 
 int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
 {
        struct hfi1_qp_priv *priv = qp->priv;
-       struct hfi1_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct ib_ah_attr *ah_attr;
        struct hfi1_pportdata *ppd;
        struct hfi1_ibport *ibp;
        u32 bth0, plen, vl, hwords = 5;
        u16 lrh0;
        u8 sl = ibp->sc_to_sl[sc5];
-       struct hfi1_ib_header hdr;
-       struct hfi1_other_headers *ohdr;
+       struct ib_header hdr;
+       struct ib_other_headers *ohdr;
        struct pio_buf *pbuf;
        struct send_context *ctxt = qp_to_send_context(qp, sc5);
        struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
  */
 void hfi1_ud_rcv(struct hfi1_packet *packet)
 {
-       struct hfi1_other_headers *ohdr = packet->ohdr;
+       struct ib_other_headers *ohdr = packet->ohdr;
        int opcode;
        u32 hdrsize = packet->hlen;
        struct ib_wc wc;
        int mgmt_pkey_idx = -1;
        struct hfi1_ibport *ibp = &packet->rcd->ppd->ibport_data;
        struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
-       struct hfi1_ib_header *hdr = packet->hdr;
+       struct ib_header *hdr = packet->hdr;
        u32 rcv_flags = packet->rcv_flags;
        void *data = packet->ebuf;
        u32 tlen = packet->tlen;
        struct rvt_qp *qp = packet->qp;
        bool has_grh = rcv_flags & HFI1_HAS_GRH;
-       u8 sc5 = hdr2sc((struct hfi1_message_header *)hdr, packet->rhf);
+       u8 sc5 = hdr2sc(hdr, packet->rhf);
        u32 bth1;
        u8 sl_from_sc, sl;
        u16 slid;
 
 void hfi1_ib_rcv(struct hfi1_packet *packet)
 {
        struct hfi1_ctxtdata *rcd = packet->rcd;
-       struct hfi1_ib_header *hdr = packet->hdr;
+       struct ib_header *hdr = packet->hdr;
        u32 tlen = packet->tlen;
        struct hfi1_pportdata *ppd = rcd->ppd;
        struct hfi1_ibport *ibp = &ppd->ibport_data;
        if (tx->wqe) {
                hfi1_send_complete(qp, tx->wqe, IB_WC_SUCCESS);
        } else if (qp->ibqp.qp_type == IB_QPT_RC) {
-               struct hfi1_ib_header *hdr;
+               struct ib_header *hdr;
 
                hdr = &tx->phdr.hdr;
                hfi1_rc_send_complete(qp, hdr);
 {
        struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
        struct hfi1_qp_priv *priv = qp->priv;
-       struct hfi1_ib_header *h = &tx->phdr.hdr;
+       struct ib_header *h = &tx->phdr.hdr;
 
        if (unlikely(!(dd->flags & HFI1_HAS_SEND_DMA)))
                return dd->process_pio_send;
 {
        struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
        struct hfi1_qp_priv *priv = qp->priv;
-       struct hfi1_other_headers *ohdr;
-       struct hfi1_ib_header *hdr;
+       struct ib_other_headers *ohdr;
+       struct ib_header *hdr;
        send_routine sr;
        int ret;
        u8 lnh;
 {
        struct hfi1_ibport *ibp = &packet->rcd->ppd->ibport_data;
        struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
-       struct hfi1_ib_header *hdr = packet->hdr;
+       struct ib_header *hdr = packet->hdr;
        struct rvt_qp *qp = packet->qp;
        u32 lqpn, rqpn = 0;
        u16 rlid = 0;
                return;
        }
 
-       sc5 = hdr2sc((struct hfi1_message_header *)hdr, packet->rhf);
+       sc5 = hdr2sc(hdr, packet->rhf);
        sl = ibp->sc_to_sl[sc5];
        lqpn = qp->ibqp.qp_num;
 
 
 #include <rdma/ib_pack.h>
 #include <rdma/ib_user_verbs.h>
 #include <rdma/ib_mad.h>
+#include <rdma/ib_hdrs.h>
 #include <rdma/rdma_vt.h>
 #include <rdma/rdmavt_qp.h>
 #include <rdma/rdmavt_cq.h>
  */
 #define HFI1_UVERBS_ABI_VERSION       2
 
-#define IB_SEQ_NAK     (3 << 29)
-
-/* AETH NAK opcode values */
-#define IB_RNR_NAK                      0x20
-#define IB_NAK_PSN_ERROR                0x60
-#define IB_NAK_INVALID_REQUEST          0x61
-#define IB_NAK_REMOTE_ACCESS_ERROR      0x62
-#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
-#define IB_NAK_INVALID_RD_REQUEST       0x64
-
 /* IB Performance Manager status values */
 #define IB_PMA_SAMPLE_STATUS_DONE       0x00
 #define IB_PMA_SAMPLE_STATUS_STARTED    0x01
 
 #define HFI1_VENDOR_IPG                cpu_to_be16(0xFFA0)
 
-#define IB_BTH_REQ_ACK         BIT(31)
-#define IB_BTH_SOLICITED       BIT(23)
-#define IB_BTH_MIG_REQ         BIT(22)
-
-#define IB_GRH_VERSION         6
-#define IB_GRH_VERSION_MASK    0xF
-#define IB_GRH_VERSION_SHIFT   28
-#define IB_GRH_TCLASS_MASK     0xFF
-#define IB_GRH_TCLASS_SHIFT    20
-#define IB_GRH_FLOW_MASK       0xFFFFF
-#define IB_GRH_FLOW_SHIFT      0
-#define IB_GRH_NEXT_HDR                0x1B
-
 #define IB_DEFAULT_GID_PREFIX  cpu_to_be64(0xfe80000000000000ULL)
 
 /* flags passed by hfi1_ib_rcv() */
        HFI1_HAS_GRH = (1 << 0),
 };
 
-struct ib_reth {
-       __be64 vaddr;
-       __be32 rkey;
-       __be32 length;
-} __packed;
-
-struct ib_atomic_eth {
-       __be32 vaddr[2];        /* unaligned so access as 2 32-bit words */
-       __be32 rkey;
-       __be64 swap_data;
-       __be64 compare_data;
-} __packed;
-
-union ib_ehdrs {
-       struct {
-               __be32 deth[2];
-               __be32 imm_data;
-       } ud;
-       struct {
-               struct ib_reth reth;
-               __be32 imm_data;
-       } rc;
-       struct {
-               __be32 aeth;
-               __be32 atomic_ack_eth[2];
-       } at;
-       __be32 imm_data;
-       __be32 aeth;
-       __be32 ieth;
-       struct ib_atomic_eth atomic_eth;
-}  __packed;
-
-struct hfi1_other_headers {
-       __be32 bth[3];
-       union ib_ehdrs u;
-} __packed;
-
-/*
- * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes
- * long (72 w/ imm_data).  Only the first 56 bytes of the IB header
- * will be in the eager header buffer.  The remaining 12 or 16 bytes
- * are in the data buffer.
- */
-struct hfi1_ib_header {
-       __be16 lrh[4];
-       union {
-               struct {
-                       struct ib_grh grh;
-                       struct hfi1_other_headers oth;
-               } l;
-               struct hfi1_other_headers oth;
-       } u;
-} __packed;
-
 struct hfi1_ahg_info {
        u32 ahgdesc[2];
        u16 tx_flags;
 
 struct hfi1_sdma_header {
        __le64 pbc;
-       struct hfi1_ib_header hdr;
+       struct ib_header hdr;
 } __packed;
 
 /*
 
 void hfi1_rc_hdrerr(
        struct hfi1_ctxtdata *rcd,
-       struct hfi1_ib_header *hdr,
+       struct ib_header *hdr,
        u32 rcv_flags,
        struct rvt_qp *qp);
 
 void hfi1_del_timers_sync(struct rvt_qp *qp);
 void hfi1_stop_rc_timers(struct rvt_qp *qp);
 
-void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_ib_header *hdr);
+void hfi1_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
 
 void hfi1_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
 
 extern const u32 rc_only_opcode;
 extern const u32 uc_only_opcode;
 
-static inline u8 get_opcode(struct hfi1_ib_header *h)
+static inline u8 get_opcode(struct ib_header *h)
 {
        u16 lnh = be16_to_cpu(h->lrh[0]) & 3;
 
                return be32_to_cpu(h->u.l.oth.bth[0]) >> 24;
 }
 
-int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_ib_header *hdr,
+int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct ib_header *hdr,
                       int has_grh, struct rvt_qp *qp, u32 bth0);
 
 u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,
                  struct ib_global_route *grh, u32 hwords, u32 nwords);
 
-void hfi1_make_ruc_header(struct rvt_qp *qp, struct hfi1_other_headers *ohdr,
+void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
                          u32 bth0, u32 bth2, int middle,
                          struct hfi1_pkt_state *ps);
 
 
 #include <linux/kref.h>
 #include <linux/sched.h>
 #include <linux/kthread.h>
+#include <rdma/ib_hdrs.h>
 #include <rdma/rdma_vt.h>
 
 #include "qib_common.h"
 
                ret = 1;
        else if (eflags == QLOGIC_IB_RHF_H_TIDERR) {
                /* For TIDERR and RC QPs premptively schedule a NAK */
-               struct qib_ib_header *hdr = (struct qib_ib_header *) rhdr;
-               struct qib_other_headers *ohdr = NULL;
+               struct ib_header *hdr = (struct ib_header *)rhdr;
+               struct ib_other_headers *ohdr = NULL;
                struct qib_ibport *ibp = &ppd->ibport_data;
                struct qib_devdata *dd = ppd->dd;
                struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
 
        u32 *hdr;
        u64 pbc;
        const unsigned hdrwords = 7;
-       static struct qib_ib_header ibhdr = {
+       static struct ib_header ibhdr = {
                .lrh[0] = cpu_to_be16(0xF000 | QIB_LRH_BTH),
                .lrh[1] = IB_LID_PERMISSIVE,
                .lrh[2] = cpu_to_be16(hdrwords + SIZE_OF_CRC),
 
  * Note the QP s_lock must be held.
  */
 static int qib_make_rc_ack(struct qib_ibdev *dev, struct rvt_qp *qp,
-                          struct qib_other_headers *ohdr, u32 pmtu)
+                          struct ib_other_headers *ohdr, u32 pmtu)
 {
        struct rvt_ack_entry *e;
        u32 hwords;
                        len = 0;
                        qp->s_ack_state = OP(ATOMIC_ACKNOWLEDGE);
                        ohdr->u.at.aeth = qib_compute_aeth(qp);
-                       ohdr->u.at.atomic_ack_eth[0] =
-                               cpu_to_be32(e->atomic_data >> 32);
-                       ohdr->u.at.atomic_ack_eth[1] =
-                               cpu_to_be32(e->atomic_data);
+                       ib_u64_put(e->atomic_data, &ohdr->u.at.atomic_ack_eth);
                        hwords += sizeof(ohdr->u.at) / sizeof(u32);
                        bth2 = e->psn & QIB_PSN_MASK;
                        e->sent = 1;
 {
        struct qib_qp_priv *priv = qp->priv;
        struct qib_ibdev *dev = to_idev(qp->ibqp.device);
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_sge_state *ss;
        struct rvt_swqe *wqe;
        u32 hwords;
                        }
                        if (wqe->atomic_wr.wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
                                qp->s_state = OP(COMPARE_SWAP);
-                               ohdr->u.atomic_eth.swap_data = cpu_to_be64(
-                                       wqe->atomic_wr.swap);
-                               ohdr->u.atomic_eth.compare_data = cpu_to_be64(
-                                       wqe->atomic_wr.compare_add);
+                               put_ib_ateth_swap(wqe->atomic_wr.swap,
+                                                 &ohdr->u.atomic_eth);
+                               put_ib_ateth_swap(wqe->atomic_wr.compare_add,
+                                                 &ohdr->u.atomic_eth);
                        } else {
                                qp->s_state = OP(FETCH_ADD);
-                               ohdr->u.atomic_eth.swap_data = cpu_to_be64(
-                                       wqe->atomic_wr.compare_add);
-                               ohdr->u.atomic_eth.compare_data = 0;
+                               put_ib_ateth_swap(wqe->atomic_wr.compare_add,
+                                                 &ohdr->u.atomic_eth);
+                               put_ib_ateth_swap(0, &ohdr->u.atomic_eth);
                        }
-                       ohdr->u.atomic_eth.vaddr[0] = cpu_to_be32(
-                               wqe->atomic_wr.remote_addr >> 32);
-                       ohdr->u.atomic_eth.vaddr[1] = cpu_to_be32(
-                               wqe->atomic_wr.remote_addr);
+                       put_ib_ateth_vaddr(wqe->atomic_wr.remote_addr,
+                                          &ohdr->u.atomic_eth);
                        ohdr->u.atomic_eth.rkey = cpu_to_be32(
                                wqe->atomic_wr.rkey);
                        hwords += sizeof(struct ib_atomic_eth) / sizeof(u32);
        u32 hwords;
        u32 pbufn;
        u32 __iomem *piobuf;
-       struct qib_ib_header hdr;
-       struct qib_other_headers *ohdr;
+       struct ib_header hdr;
+       struct ib_other_headers *ohdr;
        u32 control;
        unsigned long flags;
 
 /*
  * This should be called with the QP s_lock held and interrupts disabled.
  */
-void qib_rc_send_complete(struct rvt_qp *qp, struct qib_ib_header *hdr)
+void qib_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr)
 {
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_swqe *wqe;
        struct ib_wc wc;
        unsigned i;
  * Called at interrupt level.
  */
 static void qib_rc_rcv_resp(struct qib_ibport *ibp,
-                           struct qib_other_headers *ohdr,
+                           struct ib_other_headers *ohdr,
                            void *data, u32 tlen,
                            struct rvt_qp *qp,
                            u32 opcode,
        case OP(ATOMIC_ACKNOWLEDGE):
        case OP(RDMA_READ_RESPONSE_FIRST):
                aeth = be32_to_cpu(ohdr->u.aeth);
-               if (opcode == OP(ATOMIC_ACKNOWLEDGE)) {
-                       __be32 *p = ohdr->u.at.atomic_ack_eth;
-
-                       val = ((u64) be32_to_cpu(p[0]) << 32) |
-                               be32_to_cpu(p[1]);
-               } else
+               if (opcode == OP(ATOMIC_ACKNOWLEDGE))
+                       val = ib_u64_get(&ohdr->u.at.atomic_ack_eth);
+               else
                        val = 0;
                if (!do_rc_ack(qp, aeth, psn, opcode, val, rcd) ||
                    opcode != OP(RDMA_READ_RESPONSE_FIRST))
  * Return 1 if no more processing is needed; otherwise return 0 to
  * schedule a response to be sent.
  */
-static int qib_rc_rcv_error(struct qib_other_headers *ohdr,
+static int qib_rc_rcv_error(struct ib_other_headers *ohdr,
                            void *data,
                            struct rvt_qp *qp,
                            u32 opcode,
  * for the given QP.
  * Called at interrupt level.
  */
-void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
+void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
                int has_grh, void *data, u32 tlen, struct rvt_qp *qp)
 {
        struct qib_ibport *ibp = &rcd->ppd->ibport_data;
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        u32 opcode;
        u32 hdrsize;
        u32 psn;
                        e->rdma_sge.mr = NULL;
                }
                ateth = &ohdr->u.atomic_eth;
-               vaddr = ((u64) be32_to_cpu(ateth->vaddr[0]) << 32) |
-                       be32_to_cpu(ateth->vaddr[1]);
+               vaddr = get_ib_ateth_vaddr(ateth);
                if (unlikely(vaddr & (sizeof(u64) - 1)))
                        goto nack_inv_unlck;
                rkey = be32_to_cpu(ateth->rkey);
                        goto nack_acc_unlck;
                /* Perform atomic OP and save result. */
                maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
-               sdata = be64_to_cpu(ateth->swap_data);
+               sdata = get_ib_ateth_swap(ateth);
                e->atomic_data = (opcode == OP(FETCH_ADD)) ?
                        (u64) atomic64_add_return(sdata, maddr) - sdata :
                        (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
-                                     be64_to_cpu(ateth->compare_data),
+                                     get_ib_ateth_compare(ateth),
                                      sdata);
                rvt_put_mr(qp->r_sge.sge.mr);
                qp->r_sge.num_sge = 0;
 
  *
  * The s_lock will be acquired around the qib_migrate_qp() call.
  */
-int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
+int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
                      int has_grh, struct rvt_qp *qp, u32 bth0)
 {
        __be64 guid;
        return sizeof(struct ib_grh) / sizeof(u32);
 }
 
-void qib_make_ruc_header(struct rvt_qp *qp, struct qib_other_headers *ohdr,
+void qib_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
                         u32 bth0, u32 bth2)
 {
        struct qib_qp_priv *priv = qp->priv;
 
 int qib_make_uc_req(struct rvt_qp *qp, unsigned long *flags)
 {
        struct qib_qp_priv *priv = qp->priv;
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_swqe *wqe;
        u32 hwords;
        u32 bth0;
  * for the given QP.
  * Called at interrupt level.
  */
-void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
+void qib_uc_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
                int has_grh, void *data, u32 tlen, struct rvt_qp *qp)
 {
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        u32 opcode;
        u32 hdrsize;
        u32 psn;
 
 int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags)
 {
        struct qib_qp_priv *priv = qp->priv;
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct ib_ah_attr *ah_attr;
        struct qib_pportdata *ppd;
        struct qib_ibport *ibp;
  * for the given QP.
  * Called at interrupt level.
  */
-void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
+void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
                int has_grh, void *data, u32 tlen, struct rvt_qp *qp)
 {
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        int opcode;
        u32 hdrsize;
        u32 pad;
 
  * for the given QP.
  * Called at interrupt level.
  */
-static void qib_qp_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
+static void qib_qp_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
                       int has_grh, void *data, u32 tlen, struct rvt_qp *qp)
 {
        struct qib_ibport *ibp = &rcd->ppd->ibport_data;
 {
        struct qib_pportdata *ppd = rcd->ppd;
        struct qib_ibport *ibp = &ppd->ibport_data;
-       struct qib_ib_header *hdr = rhdr;
+       struct ib_header *hdr = rhdr;
        struct qib_devdata *dd = ppd->dd;
        struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
-       struct qib_other_headers *ohdr;
+       struct ib_other_headers *ohdr;
        struct rvt_qp *qp;
        u32 qp_num;
        int lnh;
        if (tx->wqe)
                qib_send_complete(qp, tx->wqe, IB_WC_SUCCESS);
        else if (qp->ibqp.qp_type == IB_QPT_RC) {
-               struct qib_ib_header *hdr;
+               struct ib_header *hdr;
 
                if (tx->txreq.flags & QIB_SDMA_TXREQ_F_FREEBUF)
                        hdr = &tx->align_buf->hdr;
        return ret;
 }
 
-static int qib_verbs_send_dma(struct rvt_qp *qp, struct qib_ib_header *hdr,
+static int qib_verbs_send_dma(struct rvt_qp *qp, struct ib_header *hdr,
                              u32 hdrwords, struct rvt_sge_state *ss, u32 len,
                              u32 plen, u32 dwords)
 {
        return ret;
 }
 
-static int qib_verbs_send_pio(struct rvt_qp *qp, struct qib_ib_header *ibhdr,
+static int qib_verbs_send_pio(struct rvt_qp *qp, struct ib_header *ibhdr,
                              u32 hdrwords, struct rvt_sge_state *ss, u32 len,
                              u32 plen, u32 dwords)
 {
  * Return zero if packet is sent or queued OK.
  * Return non-zero and clear qp->s_flags RVT_S_BUSY otherwise.
  */
-int qib_verbs_send(struct rvt_qp *qp, struct qib_ib_header *hdr,
+int qib_verbs_send(struct rvt_qp *qp, struct ib_header *hdr,
                   u32 hdrwords, struct rvt_sge_state *ss, u32 len)
 {
        struct qib_devdata *dd = dd_from_ibdev(qp->ibqp.device);
 
 #include <linux/completion.h>
 #include <rdma/ib_pack.h>
 #include <rdma/ib_user_verbs.h>
+#include <rdma/ib_hdrs.h>
 #include <rdma/rdma_vt.h>
 #include <rdma/rdmavt_cq.h>
 
  */
 #define QIB_UVERBS_ABI_VERSION       2
 
-#define IB_SEQ_NAK     (3 << 29)
-
-/* AETH NAK opcode values */
-#define IB_RNR_NAK                      0x20
-#define IB_NAK_PSN_ERROR                0x60
-#define IB_NAK_INVALID_REQUEST          0x61
-#define IB_NAK_REMOTE_ACCESS_ERROR      0x62
-#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
-#define IB_NAK_INVALID_RD_REQUEST       0x64
-
 /* IB Performance Manager status values */
 #define IB_PMA_SAMPLE_STATUS_DONE       0x00
 #define IB_PMA_SAMPLE_STATUS_STARTED    0x01
 
 #define QIB_VENDOR_IPG         cpu_to_be16(0xFFA0)
 
-#define IB_BTH_REQ_ACK         (1 << 31)
-#define IB_BTH_SOLICITED       (1 << 23)
-#define IB_BTH_MIG_REQ         (1 << 22)
-
 /* XXX Should be defined in ib_verbs.h enum ib_port_cap_flags */
 #define IB_PORT_OTHER_LOCAL_CHANGES_SUP (1 << 26)
 
-#define IB_GRH_VERSION         6
-#define IB_GRH_VERSION_MASK    0xF
-#define IB_GRH_VERSION_SHIFT   28
-#define IB_GRH_TCLASS_MASK     0xFF
-#define IB_GRH_TCLASS_SHIFT    20
-#define IB_GRH_FLOW_MASK       0xFFFFF
-#define IB_GRH_FLOW_SHIFT      0
-#define IB_GRH_NEXT_HDR                0x1B
-
 #define IB_DEFAULT_GID_PREFIX  cpu_to_be64(0xfe80000000000000ULL)
 
 /* Values for set/get portinfo VLCap OperationalVLs */
        }
 }
 
-struct ib_reth {
-       __be64 vaddr;
-       __be32 rkey;
-       __be32 length;
-} __packed;
-
-struct ib_atomic_eth {
-       __be32 vaddr[2];        /* unaligned so access as 2 32-bit words */
-       __be32 rkey;
-       __be64 swap_data;
-       __be64 compare_data;
-} __packed;
-
-struct qib_other_headers {
-       __be32 bth[3];
-       union {
-               struct {
-                       __be32 deth[2];
-                       __be32 imm_data;
-               } ud;
-               struct {
-                       struct ib_reth reth;
-                       __be32 imm_data;
-               } rc;
-               struct {
-                       __be32 aeth;
-                       __be32 atomic_ack_eth[2];
-               } at;
-               __be32 imm_data;
-               __be32 aeth;
-               __be32 ieth;
-               struct ib_atomic_eth atomic_eth;
-       } u;
-} __packed;
-
-/*
- * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes
- * long (72 w/ imm_data).  Only the first 56 bytes of the IB header
- * will be in the eager header buffer.  The remaining 12 or 16 bytes
- * are in the data buffer.
- */
-struct qib_ib_header {
-       __be16 lrh[4];
-       union {
-               struct {
-                       struct ib_grh grh;
-                       struct qib_other_headers oth;
-               } l;
-               struct qib_other_headers oth;
-       } u;
-} __packed;
-
 struct qib_pio_header {
        __le32 pbc[2];
-       struct qib_ib_header hdr;
+       struct ib_header hdr;
 } __packed;
 
 /*
  * is made common.
  */
 struct qib_qp_priv {
-       struct qib_ib_header *s_hdr;    /* next packet header to send */
+       struct ib_header *s_hdr;        /* next packet header to send */
        struct list_head iowait;        /* link for wait PIO buf */
        atomic_t s_dma_busy;
        struct qib_verbs_txreq *s_tx;
 
 void qib_put_txreq(struct qib_verbs_txreq *tx);
 
-int qib_verbs_send(struct rvt_qp *qp, struct qib_ib_header *hdr,
+int qib_verbs_send(struct rvt_qp *qp, struct ib_header *hdr,
                   u32 hdrwords, struct rvt_sge_state *ss, u32 len);
 
 void qib_copy_sge(struct rvt_sge_state *ss, void *data, u32 length,
 
 void qib_skip_sge(struct rvt_sge_state *ss, u32 length, int release);
 
-void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
+void qib_uc_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
                int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
 
-void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
+void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
                int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
 
 int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
 
 void qib_rc_rnr_retry(unsigned long arg);
 
-void qib_rc_send_complete(struct rvt_qp *qp, struct qib_ib_header *hdr);
+void qib_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
 
 void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err);
 
 int qib_post_ud_send(struct rvt_qp *qp, struct ib_send_wr *wr);
 
-void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
+void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
                int has_grh, void *data, u32 tlen, struct rvt_qp *qp);
 
 void mr_rcu_callback(struct rcu_head *list);
 
 void qib_migrate_qp(struct rvt_qp *qp);
 
-int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
+int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
                      int has_grh, struct rvt_qp *qp, u32 bth0);
 
 u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr,
                 struct ib_global_route *grh, u32 hwords, u32 nwords);
 
-void qib_make_ruc_header(struct rvt_qp *qp, struct qib_other_headers *ohdr,
+void qib_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
                         u32 bth0, u32 bth2);
 
 void _qib_do_send(struct work_struct *work);