Skip to content

Commit 30e0741

Browse files
Don Hiattdledford
authored andcommitted
IB/hfi1: Add support to send 16B bypass packets
We introduce struct hfi1_opa_header as a union of ib (9B) and 16B headers. Reviewed-by: Dennis Dalessandro <[email protected]> Signed-off-by: Dasaratharaman Chandramouli <[email protected]> Signed-off-by: Don Hiatt <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 72c07e2 commit 30e0741

File tree

7 files changed

+84
-60
lines changed

7 files changed

+84
-60
lines changed

drivers/infiniband/hw/hfi1/rc.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ int hfi1_make_rc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
273273
if (IS_ERR(ps->s_txreq))
274274
goto bail_no_tx;
275275

276-
ohdr = &ps->s_txreq->phdr.hdr.u.oth;
276+
ohdr = &ps->s_txreq->phdr.hdr.ibh.u.oth;
277277
if (rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH)
278-
ohdr = &ps->s_txreq->phdr.hdr.u.l.oth;
278+
ohdr = &ps->s_txreq->phdr.hdr.ibh.u.l.oth;
279279

280280
/* Sending responses has higher priority over sending requests. */
281281
if ((qp->s_flags & RVT_S_RESP_PENDING) &&
@@ -724,7 +724,8 @@ void hfi1_send_rc_ack(struct hfi1_ctxtdata *rcd, struct rvt_qp *qp,
724724
u32 vl, plen;
725725
struct send_context *sc;
726726
struct pio_buf *pbuf;
727-
struct ib_header hdr;
727+
struct hfi1_opa_header opah;
728+
struct ib_header *hdr;
728729
struct ib_other_headers *ohdr;
729730
unsigned long flags;
730731

@@ -741,16 +742,19 @@ void hfi1_send_rc_ack(struct hfi1_ctxtdata *rcd, struct rvt_qp *qp,
741742
goto queue_ack;
742743

743744
/* Construct the header */
745+
opah.hdr_type = 0;
746+
hdr = &opah.ibh;
747+
744748
/* header size in 32-bit words LRH+BTH+AETH = (8+12+4)/4 */
745749
hwords = 6;
746750
if (unlikely(rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH)) {
747-
hwords += hfi1_make_grh(ibp, &hdr.u.l.grh,
751+
hwords += hfi1_make_grh(ibp, &hdr->u.l.grh,
748752
rdma_ah_read_grh(&qp->remote_ah_attr),
749753
hwords, 0);
750-
ohdr = &hdr.u.l.oth;
754+
ohdr = &hdr->u.l.oth;
751755
lrh0 = HFI1_LRH_GRH;
752756
} else {
753-
ohdr = &hdr.u.oth;
757+
ohdr = &hdr->u.oth;
754758
lrh0 = HFI1_LRH_BTH;
755759
}
756760
/* read pkey_index w/o lock (its atomic) */
@@ -768,11 +772,11 @@ void hfi1_send_rc_ack(struct hfi1_ctxtdata *rcd, struct rvt_qp *qp,
768772
pbc_flags |= (ib_is_sc5(sc5) << PBC_DC_INFO_SHIFT);
769773
lrh0 |= (sc5 & 0xf) << 12 | (rdma_ah_get_sl(&qp->remote_ah_attr)
770774
& 0xf) << 4;
771-
hdr.lrh[0] = cpu_to_be16(lrh0);
772-
hdr.lrh[1] = cpu_to_be16(rdma_ah_get_dlid(&qp->remote_ah_attr));
773-
hdr.lrh[2] = cpu_to_be16(hwords + SIZE_OF_CRC);
774-
hdr.lrh[3] = cpu_to_be16(ppd->lid |
775-
rdma_ah_get_path_bits(&qp->remote_ah_attr));
775+
hdr->lrh[0] = cpu_to_be16(lrh0);
776+
hdr->lrh[1] = cpu_to_be16(rdma_ah_get_dlid(&qp->remote_ah_attr));
777+
hdr->lrh[2] = cpu_to_be16(hwords + SIZE_OF_CRC);
778+
hdr->lrh[3] = cpu_to_be16(ppd->lid |
779+
rdma_ah_get_path_bits(&qp->remote_ah_attr));
776780
ohdr->bth[0] = cpu_to_be32(bth0);
777781
ohdr->bth[1] = cpu_to_be32(qp->remote_qpn);
778782
ohdr->bth[1] |= cpu_to_be32((!!is_fecn) << IB_BECN_SHIFT);
@@ -799,10 +803,10 @@ void hfi1_send_rc_ack(struct hfi1_ctxtdata *rcd, struct rvt_qp *qp,
799803
}
800804

801805
trace_ack_output_ibhdr(dd_from_ibdev(qp->ibqp.device),
802-
&hdr, ib_is_sc5(sc5));
806+
&opah, ib_is_sc5(sc5));
803807

804808
/* write the pbc and data */
805-
ppd->dd->pio_inline_send(ppd->dd, pbuf, pbc, &hdr, hwords);
809+
ppd->dd->pio_inline_send(ppd->dd, pbuf, pbc, hdr, hwords);
806810

807811
return;
808812

@@ -985,9 +989,10 @@ static void reset_sending_psn(struct rvt_qp *qp, u32 psn)
985989
/*
986990
* This should be called with the QP s_lock held and interrupts disabled.
987991
*/
988-
void hfi1_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr)
992+
void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_opa_header *opah)
989993
{
990994
struct ib_other_headers *ohdr;
995+
struct ib_header *hdr = &opah->ibh;
991996
struct rvt_swqe *wqe;
992997
u32 opcode;
993998
u32 psn;

drivers/infiniband/hw/hfi1/ruc.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,8 @@ u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,
668668
return sizeof(struct ib_grh) / sizeof(u32);
669669
}
670670

671-
#define BTH2_OFFSET (offsetof(struct hfi1_sdma_header, hdr.u.oth.bth[2]) / 4)
671+
#define BTH2_OFFSET (offsetof(struct hfi1_sdma_header, \
672+
hdr.ibh.u.oth.bth[2]) / 4)
672673

673674
/**
674675
* build_ahg - create ahg in s_ahg
@@ -743,8 +744,8 @@ void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
743744
if (unlikely(rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH)) {
744745
qp->s_hdrwords +=
745746
hfi1_make_grh(ibp,
746-
&ps->s_txreq->phdr.hdr.u.l.grh,
747-
rdma_ah_read_grh(&qp->remote_ah_attr),
747+
&ps->s_txreq->phdr.hdr.ibh.u.l.grh,
748+
&qp->remote_ah_attr.grh,
748749
qp->s_hdrwords, nwords);
749750
lrh0 = HFI1_LRH_GRH;
750751
middle = 0;
@@ -773,14 +774,14 @@ void hfi1_make_ruc_header(struct rvt_qp *qp, struct ib_other_headers *ohdr,
773774
build_ahg(qp, bth2);
774775
else
775776
qp->s_flags &= ~RVT_S_AHG_VALID;
776-
ps->s_txreq->phdr.hdr.lrh[0] = cpu_to_be16(lrh0);
777-
ps->s_txreq->phdr.hdr.lrh[1] =
777+
ps->s_txreq->phdr.hdr.ibh.lrh[0] = cpu_to_be16(lrh0);
778+
ps->s_txreq->phdr.hdr.ibh.lrh[1] =
778779
cpu_to_be16(rdma_ah_get_dlid(&qp->remote_ah_attr));
779-
ps->s_txreq->phdr.hdr.lrh[2] =
780+
ps->s_txreq->phdr.hdr.ibh.lrh[2] =
780781
cpu_to_be16(qp->s_hdrwords + nwords + SIZE_OF_CRC);
781-
ps->s_txreq->phdr.hdr.lrh[3] =
782+
ps->s_txreq->phdr.hdr.ibh.lrh[3] =
782783
cpu_to_be16(ppd_from_ibp(ibp)->lid |
783-
rdma_ah_get_path_bits(&qp->remote_ah_attr));
784+
rdma_ah_get_path_bits(&qp->remote_ah_attr));
784785
bth0 |= hfi1_get_pkey(ibp, qp->s_pkey_index);
785786
bth0 |= extra_bytes << 20;
786787
ohdr->bth[0] = cpu_to_be32(bth0);

drivers/infiniband/hw/hfi1/trace_ibhdrs.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
213213

214214
DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
215215
TP_PROTO(struct hfi1_devdata *dd,
216-
struct ib_header *hdr,
216+
struct hfi1_opa_header *opah,
217217
bool sc5),
218-
TP_ARGS(dd, hdr, sc5),
218+
TP_ARGS(dd, opah, sc5),
219219
TP_STRUCT__entry(
220220
DD_DEV_ENTRY(dd)
221221
__field(u8, lnh)
@@ -238,10 +238,11 @@ DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
238238
__field(u32, psn)
239239
/* extended headers */
240240
__dynamic_array(u8, ehdrs,
241-
hfi1_trace_ib_hdr_len(hdr))
241+
hfi1_trace_ib_hdr_len(&opah->ibh))
242242
),
243243
TP_fast_assign(
244244
struct ib_other_headers *ohdr;
245+
struct ib_header *hdr = &opah->ibh;
245246

246247
DD_DEV_ASSIGN(dd);
247248

@@ -294,18 +295,18 @@ DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
294295

295296
DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
296297
TP_PROTO(struct hfi1_devdata *dd,
297-
struct ib_header *hdr, bool sc5),
298-
TP_ARGS(dd, hdr, sc5));
298+
struct hfi1_opa_header *opah, bool sc5),
299+
TP_ARGS(dd, opah, sc5));
299300

300301
DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
301302
TP_PROTO(struct hfi1_devdata *dd,
302-
struct ib_header *hdr, bool sc5),
303-
TP_ARGS(dd, hdr, sc5));
303+
struct hfi1_opa_header *opah, bool sc5),
304+
TP_ARGS(dd, opah, sc5));
304305

305306
DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
306307
TP_PROTO(struct hfi1_devdata *dd,
307-
struct ib_header *hdr, bool sc5),
308-
TP_ARGS(dd, hdr, sc5));
308+
struct hfi1_opa_header *opah, bool sc5),
309+
TP_ARGS(dd, opah, sc5));
309310

310311

311312
#endif /* __HFI1_TRACE_IBHDRS_H */

drivers/infiniband/hw/hfi1/uc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ int hfi1_make_uc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
9393
goto done_free_tx;
9494
}
9595

96-
ohdr = &ps->s_txreq->phdr.hdr.u.oth;
96+
ohdr = &ps->s_txreq->phdr.hdr.ibh.u.oth;
9797
if (rdma_ah_get_ah_flags(&qp->remote_ah_attr) & IB_AH_GRH)
98-
ohdr = &ps->s_txreq->phdr.hdr.u.l.oth;
98+
ohdr = &ps->s_txreq->phdr.hdr.ibh.u.l.oth;
9999

100100
/* Get the next send request. */
101101
wqe = rvt_get_swqe_ptr(qp, qp->s_cur);

drivers/infiniband/hw/hfi1/ud.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,21 @@ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
357357

358358
if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
359359
/* Header size in 32-bit words. */
360-
qp->s_hdrwords += hfi1_make_grh(ibp,
361-
&ps->s_txreq->phdr.hdr.u.l.grh,
362-
rdma_ah_read_grh(ah_attr),
363-
qp->s_hdrwords, nwords);
360+
qp->s_hdrwords +=
361+
hfi1_make_grh(ibp,
362+
&ps->s_txreq->phdr.hdr.ibh.u.l.grh,
363+
rdma_ah_read_grh(ah_attr),
364+
qp->s_hdrwords, nwords);
364365
lrh0 = HFI1_LRH_GRH;
365-
ohdr = &ps->s_txreq->phdr.hdr.u.l.oth;
366+
ohdr = &ps->s_txreq->phdr.hdr.ibh.u.l.oth;
366367
/*
367368
* Don't worry about sending to locally attached multicast
368369
* QPs. It is unspecified by the spec. what happens.
369370
*/
370371
} else {
371372
/* Header size in 32-bit words. */
372373
lrh0 = HFI1_LRH_BTH;
373-
ohdr = &ps->s_txreq->phdr.hdr.u.oth;
374+
ohdr = &ps->s_txreq->phdr.hdr.ibh.u.oth;
374375
}
375376
if (wqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
376377
qp->s_hdrwords++;
@@ -392,21 +393,21 @@ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
392393
ps->s_txreq->sde = priv->s_sde;
393394
priv->s_sendcontext = qp_to_send_context(qp, priv->s_sc);
394395
ps->s_txreq->psc = priv->s_sendcontext;
395-
ps->s_txreq->phdr.hdr.lrh[0] = cpu_to_be16(lrh0);
396-
ps->s_txreq->phdr.hdr.lrh[1] =
396+
ps->s_txreq->phdr.hdr.ibh.lrh[0] = cpu_to_be16(lrh0);
397+
ps->s_txreq->phdr.hdr.ibh.lrh[1] =
397398
cpu_to_be16(rdma_ah_get_dlid(ah_attr));
398-
ps->s_txreq->phdr.hdr.lrh[2] =
399+
ps->s_txreq->phdr.hdr.ibh.lrh[2] =
399400
cpu_to_be16(qp->s_hdrwords + nwords + SIZE_OF_CRC);
400401
if (rdma_ah_get_dlid(ah_attr) == be16_to_cpu(IB_LID_PERMISSIVE)) {
401-
ps->s_txreq->phdr.hdr.lrh[3] = IB_LID_PERMISSIVE;
402+
ps->s_txreq->phdr.hdr.ibh.lrh[3] = IB_LID_PERMISSIVE;
402403
} else {
403404
lid = ppd->lid;
404405
if (lid) {
405406
lid |= rdma_ah_get_path_bits(ah_attr) &
406407
((1 << ppd->lmc) - 1);
407-
ps->s_txreq->phdr.hdr.lrh[3] = cpu_to_be16(lid);
408+
ps->s_txreq->phdr.hdr.ibh.lrh[3] = cpu_to_be16(lid);
408409
} else {
409-
ps->s_txreq->phdr.hdr.lrh[3] = IB_LID_PERMISSIVE;
410+
ps->s_txreq->phdr.hdr.ibh.lrh[3] = IB_LID_PERMISSIVE;
410411
}
411412
}
412413
if (wqe->wr.send_flags & IB_SEND_SOLICITED)

drivers/infiniband/hw/hfi1/verbs.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,24 @@ void hfi1_copy_sge(
506506
}
507507
}
508508

509+
static u8 get_opcode(struct hfi1_opa_header *hdr)
510+
{
511+
struct ib_other_headers *ohdr;
512+
513+
if (hdr->hdr_type) {
514+
if (hfi1_16B_get_l4(&hdr->opah) == OPA_16B_L4_IB_LOCAL)
515+
ohdr = &hdr->opah.u.oth;
516+
else
517+
ohdr = &hdr->opah.u.l.oth;
518+
} else {
519+
if (ib_get_lnh(&hdr->ibh) == HFI1_LRH_BTH)
520+
ohdr = &hdr->ibh.u.oth;
521+
else
522+
ohdr = &hdr->ibh.u.l.oth;
523+
}
524+
return ib_bth_get_opcode(ohdr);
525+
}
526+
509527
/*
510528
* Make sure the QP is ready and able to accept the given opcode.
511529
*/
@@ -686,7 +704,7 @@ static void verbs_sdma_complete(
686704
if (tx->wqe) {
687705
hfi1_send_complete(qp, tx->wqe, IB_WC_SUCCESS);
688706
} else if (qp->ibqp.qp_type == IB_QPT_RC) {
689-
struct ib_header *hdr;
707+
struct hfi1_opa_header *hdr;
690708

691709
hdr = &tx->phdr.hdr;
692710
hfi1_rc_send_complete(qp, hdr);
@@ -1175,7 +1193,7 @@ static inline send_routine get_send_routine(struct rvt_qp *qp,
11751193
{
11761194
struct hfi1_devdata *dd = dd_from_ibdev(qp->ibqp.device);
11771195
struct hfi1_qp_priv *priv = qp->priv;
1178-
struct ib_header *h = &tx->phdr.hdr;
1196+
struct hfi1_opa_header *h = &tx->phdr.hdr;
11791197

11801198
if (unlikely(!(dd->flags & HFI1_HAS_SEND_DMA)))
11811199
return dd->process_pio_send;
@@ -1221,7 +1239,7 @@ int hfi1_verbs_send(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
12211239
int ret;
12221240
u8 lnh;
12231241

1224-
hdr = &ps->s_txreq->phdr.hdr;
1242+
hdr = &ps->s_txreq->phdr.hdr.ibh;
12251243
/* locate the pkey within the headers */
12261244
lnh = ib_get_lnh(hdr);
12271245
if (lnh == HFI1_LRH_GRH)

drivers/infiniband/hw/hfi1/verbs.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ struct hfi1_16b_header {
115115
} u;
116116
} __packed;
117117

118+
struct hfi1_opa_header {
119+
union {
120+
struct ib_header ibh; /* 9B header */
121+
struct hfi1_16b_header opah; /* 16B header */
122+
};
123+
u8 hdr_type; /* 9B or 16B */
124+
} __packed;
125+
118126
struct hfi1_ahg_info {
119127
u32 ahgdesc[2];
120128
u16 tx_flags;
@@ -124,7 +132,7 @@ struct hfi1_ahg_info {
124132

125133
struct hfi1_sdma_header {
126134
__le64 pbc;
127-
struct ib_header hdr;
135+
struct hfi1_opa_header hdr;
128136
} __packed;
129137

130138
/*
@@ -326,7 +334,7 @@ u8 ah_to_sc(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr);
326334

327335
struct ib_ah *hfi1_create_qp0_ah(struct hfi1_ibport *ibp, u16 dlid);
328336

329-
void hfi1_rc_send_complete(struct rvt_qp *qp, struct ib_header *hdr);
337+
void hfi1_rc_send_complete(struct rvt_qp *qp, struct hfi1_opa_header *opah);
330338

331339
void hfi1_ud_rcv(struct hfi1_packet *packet);
332340

@@ -347,16 +355,6 @@ int hfi1_check_send_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe);
347355
extern const u32 rc_only_opcode;
348356
extern const u32 uc_only_opcode;
349357

350-
static inline u8 get_opcode(struct ib_header *h)
351-
{
352-
u16 lnh = be16_to_cpu(h->lrh[0]) & 3;
353-
354-
if (lnh == IB_LNH_IBA_LOCAL)
355-
return be32_to_cpu(h->u.oth.bth[0]) >> 24;
356-
else
357-
return be32_to_cpu(h->u.l.oth.bth[0]) >> 24;
358-
}
359-
360358
int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet);
361359

362360
u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,

0 commit comments

Comments
 (0)