]> git.ipfire.org Git - people/ms/linux.git/commitdiff
IB/hfi1: Remove blind constants from 16B update
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Thu, 1 Feb 2018 18:52:35 +0000 (10:52 -0800)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 1 Feb 2018 22:43:30 +0000 (15:43 -0700)
These values were introduced as part of the 16B code to
account for the varying size of the LRH between the differing
packet formats.

Replace the blind constants with defines based on FIELD_SIZEOF()
calls.

Fixes: 5b6cabb0db77 ("IB/hfi1: Add 16B RC/UC support")
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/hfi1/driver.c
drivers/infiniband/hw/hfi1/ruc.c
drivers/infiniband/hw/hfi1/ud.c
drivers/infiniband/hw/hfi1/verbs.h

index 98703f1ce7ac40aba5ed0b6433fe2b183260be64..c7e6b670e809e1461f3fa2cbad24e26bb9d943b4 100644 (file)
@@ -1499,8 +1499,10 @@ static int hfi1_setup_bypass_packet(struct hfi1_packet *packet)
 
        /* Query commonly used fields from packet header */
        packet->opcode = ib_bth_get_opcode(packet->ohdr);
-       packet->hlen = hdr_len_by_opcode[packet->opcode] + 8 + grh_len;
-       packet->payload = packet->ebuf + packet->hlen - (4 * sizeof(u32));
+       /* hdr_len_by_opcode already has an IB LRH factored in */
+       packet->hlen = hdr_len_by_opcode[packet->opcode] +
+               (LRH_16B_BYTES - LRH_9B_BYTES) + grh_len;
+       packet->payload = packet->ebuf + packet->hlen - LRH_16B_BYTES;
        packet->slid = hfi1_16B_get_slid(packet->hdr);
        packet->dlid = hfi1_16B_get_dlid(packet->hdr);
        if (unlikely(hfi1_is_16B_mcast(packet->dlid)))
index 425272210da05e4c0f7057cba2afd01f2c891929..edef320d745d95c531114dc8279cdc6f3296d5e6 100644 (file)
@@ -758,8 +758,6 @@ static inline void hfi1_make_ruc_header_16B(struct rvt_qp *qp,
                struct ib_grh *grh;
                struct ib_global_route *grd =
                        rdma_ah_retrieve_grh(&qp->remote_ah_attr);
-               int hdrwords;
-
                /*
                 * Ensure OPA GIDs are transformed to IB gids
                 * before creating the GRH.
@@ -768,9 +766,10 @@ static inline void hfi1_make_ruc_header_16B(struct rvt_qp *qp,
                        grd->sgid_index = 0;
                grh = &ps->s_txreq->phdr.hdr.opah.u.l.grh;
                l4 = OPA_16B_L4_IB_GLOBAL;
-               hdrwords = ps->s_txreq->hdr_dwords - 4;
-               ps->s_txreq->hdr_dwords += hfi1_make_grh(ibp, grh, grd,
-                                                        hdrwords, nwords);
+               ps->s_txreq->hdr_dwords +=
+                       hfi1_make_grh(ibp, grh, grd,
+                                     ps->s_txreq->hdr_dwords - LRH_16B_DWORDS,
+                                     nwords);
                middle = 0;
        }
 
@@ -824,13 +823,13 @@ static inline void hfi1_make_ruc_header_9B(struct rvt_qp *qp,
 
        if (unlikely(rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH)) {
                struct ib_grh *grh = &ps->s_txreq->phdr.hdr.ibh.u.l.grh;
-               int hdrwords = ps->s_txreq->hdr_dwords - 2;
 
                lrh0 = HFI1_LRH_GRH;
                ps->s_txreq->hdr_dwords +=
                        hfi1_make_grh(ibp, grh,
                                      rdma_ah_read_grh(&qp->remote_ah_attr),
-                                     hdrwords, nwords);
+                                     ps->s_txreq->hdr_dwords - LRH_9B_DWORDS,
+                                     nwords);
                middle = 0;
        }
        lrh0 |= (priv->s_sc & 0xf) << 12 |
index cff2fd8907f5133a2dd2961e5813ee3b9ca4e384..066afbcfc064bb1716e3f8de05441dbee4484cee 100644 (file)
@@ -348,7 +348,8 @@ void hfi1_make_ud_req_9B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
                grh = &ps->s_txreq->phdr.hdr.ibh.u.l.grh;
                ps->s_txreq->hdr_dwords +=
                        hfi1_make_grh(ibp, grh, rdma_ah_read_grh(ah_attr),
-                                     ps->s_txreq->hdr_dwords - 2, nwords);
+                                     ps->s_txreq->hdr_dwords - LRH_9B_DWORDS,
+                                     nwords);
                lrh0 = HFI1_LRH_GRH;
                ohdr = &ps->s_txreq->phdr.hdr.ibh.u.l.oth;
        } else {
@@ -428,8 +429,10 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
                        grd->sgid_index = 0;
                }
                grh = &ps->s_txreq->phdr.hdr.opah.u.l.grh;
-               ps->s_txreq->hdr_dwords += hfi1_make_grh(ibp, grh, grd,
-                                       ps->s_txreq->hdr_dwords - 4, nwords);
+               ps->s_txreq->hdr_dwords += hfi1_make_grh(
+                       ibp, grh, grd,
+                       ps->s_txreq->hdr_dwords - LRH_16B_DWORDS,
+                       nwords);
                ohdr = &ps->s_txreq->phdr.hdr.opah.u.l.oth;
                l4 = OPA_16B_L4_IB_GLOBAL;
        } else {
@@ -648,7 +651,8 @@ void return_cnp_16B(struct hfi1_ibport *ibp, struct rvt_qp *qp,
                struct ib_grh *grh = &hdr.u.l.grh;
 
                grh->version_tclass_flow = old_grh->version_tclass_flow;
-               grh->paylen = cpu_to_be16((hwords - 4 + nwords) << 2);
+               grh->paylen = cpu_to_be16(
+                       (hwords - LRH_16B_DWORDS + nwords) << 2);
                grh->hop_limit = 0xff;
                grh->sgid = old_grh->dgid;
                grh->dgid = old_grh->sgid;
@@ -702,7 +706,8 @@ void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn,
                struct ib_grh *grh = &hdr.u.l.grh;
 
                grh->version_tclass_flow = old_grh->version_tclass_flow;
-               grh->paylen = cpu_to_be16((hwords - 2 + SIZE_OF_CRC) << 2);
+               grh->paylen = cpu_to_be16(
+                       (hwords - LRH_9B_DWORDS + SIZE_OF_CRC) << 2);
                grh->hop_limit = 0xff;
                grh->sgid = old_grh->dgid;
                grh->dgid = old_grh->sgid;
index 4ea040df334b7f71ddab7e47aa07070b72727706..2d787b8346cab67779d79eb379c407efdc1e47d7 100644 (file)
@@ -105,6 +105,11 @@ enum {
        HFI1_HAS_GRH = (1 << 0),
 };
 
+#define LRH_16B_BYTES (FIELD_SIZEOF(struct hfi1_16b_header, lrh))
+#define LRH_16B_DWORDS (LRH_16B_BYTES / sizeof(u32))
+#define LRH_9B_BYTES (FIELD_SIZEOF(struct ib_header, lrh))
+#define LRH_9B_DWORDS (LRH_9B_BYTES / sizeof(u32))
+
 struct hfi1_16b_header {
        u32 lrh[4];
        union {