Skip to content

Commit 88733e3

Browse files
Don Hiattdledford
authored andcommitted
IB/hfi1: Add 16B UD support
Add 16B bypass packet support for UD traffic types. 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 d98bb7f commit 88733e3

File tree

7 files changed

+457
-131
lines changed

7 files changed

+457
-131
lines changed

drivers/infiniband/hw/hfi1/driver.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,23 +437,33 @@ void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
437437
bool do_cnp)
438438
{
439439
struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
440-
struct ib_header *hdr = pkt->hdr;
441440
struct ib_other_headers *ohdr = pkt->ohdr;
442441
struct ib_grh *grh = pkt->grh;
443442
u32 rqpn = 0, bth1;
444-
u16 rlid, dlid = ib_get_dlid(hdr);
445-
u8 sc, svc_type;
443+
u16 pkey, rlid, dlid = ib_get_dlid(pkt->hdr);
444+
u8 hdr_type, sc, svc_type;
446445
bool is_mcast = false;
447446

447+
if (pkt->etype == RHF_RCV_TYPE_BYPASS) {
448+
is_mcast = hfi1_is_16B_mcast(dlid);
449+
pkey = hfi1_16B_get_pkey(pkt->hdr);
450+
sc = hfi1_16B_get_sc(pkt->hdr);
451+
hdr_type = HFI1_PKT_TYPE_16B;
452+
} else {
453+
is_mcast = (dlid > be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
454+
(dlid != be16_to_cpu(IB_LID_PERMISSIVE));
455+
pkey = ib_bth_get_pkey(ohdr);
456+
sc = hfi1_9B_get_sc5(pkt->hdr, pkt->rhf);
457+
hdr_type = HFI1_PKT_TYPE_9B;
458+
}
459+
448460
switch (qp->ibqp.qp_type) {
449461
case IB_QPT_SMI:
450462
case IB_QPT_GSI:
451463
case IB_QPT_UD:
452-
rlid = ib_get_slid(hdr);
453-
rqpn = ib_get_sqpn(ohdr);
464+
rlid = ib_get_slid(pkt->hdr);
465+
rqpn = ib_get_sqpn(pkt->ohdr);
454466
svc_type = IB_CC_SVCTYPE_UD;
455-
is_mcast = (dlid > be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
456-
(dlid != be16_to_cpu(IB_LID_PERMISSIVE));
457467
break;
458468
case IB_QPT_UC:
459469
rlid = rdma_ah_get_dlid(&qp->remote_ah_attr);
@@ -469,14 +479,11 @@ void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
469479
return;
470480
}
471481

472-
sc = hfi1_9B_get_sc5(hdr, pkt->rhf);
473-
474482
bth1 = be32_to_cpu(ohdr->bth[1]);
475-
if (do_cnp && (bth1 & IB_FECN_SMASK)) {
476-
u16 pkey = ib_bth_get_pkey(ohdr);
477-
478-
return_cnp(ibp, qp, rqpn, pkey, dlid, rlid, sc, grh);
479-
}
483+
/* Call appropriate CNP handler */
484+
if (do_cnp && (bth1 & IB_FECN_SMASK))
485+
hfi1_handle_cnp_tbl[hdr_type](ibp, qp, rqpn, pkey,
486+
dlid, rlid, sc, grh);
480487

481488
if (!is_mcast && (bth1 & IB_BECN_SMASK)) {
482489
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);

drivers/infiniband/hw/hfi1/hfi.h

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ struct hfi1_pportdata {
831831
typedef int (*rhf_rcv_function_ptr)(struct hfi1_packet *packet);
832832

833833
typedef void (*opcode_handler)(struct hfi1_packet *packet);
834+
typedef void (*hfi1_make_req)(struct rvt_qp *qp,
835+
struct hfi1_pkt_state *ps,
836+
struct rvt_swqe *wqe);
837+
834838

835839
/* return values for the RHF receive functions */
836840
#define RHF_RCV_CONTINUE 0 /* keep going */
@@ -1373,6 +1377,13 @@ void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd);
13731377
void hfi1_reset_vnic_msix_info(struct hfi1_ctxtdata *rcd);
13741378

13751379
extern const struct pci_device_id hfi1_pci_tbl[];
1380+
void hfi1_make_ud_req_9B(struct rvt_qp *qp,
1381+
struct hfi1_pkt_state *ps,
1382+
struct rvt_swqe *wqe);
1383+
1384+
void hfi1_make_ud_req_16B(struct rvt_qp *qp,
1385+
struct hfi1_pkt_state *ps,
1386+
struct rvt_swqe *wqe);
13761387

13771388
/* receive packet handler dispositions */
13781389
#define RCV_PKT_OK 0x0 /* keep going */
@@ -1507,6 +1518,18 @@ void process_becn(struct hfi1_pportdata *ppd, u8 sl, u16 rlid, u32 lqpn,
15071518
void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn,
15081519
u32 pkey, u32 slid, u32 dlid, u8 sc5,
15091520
const struct ib_grh *old_grh);
1521+
void return_cnp_16B(struct hfi1_ibport *ibp, struct rvt_qp *qp,
1522+
u32 remote_qpn, u32 pkey, u32 slid, u32 dlid,
1523+
u8 sc5, const struct ib_grh *old_grh);
1524+
typedef void (*hfi1_handle_cnp)(struct hfi1_ibport *ibp, struct rvt_qp *qp,
1525+
u32 remote_qpn, u32 pkey, u32 slid, u32 dlid,
1526+
u8 sc5, const struct ib_grh *old_grh);
1527+
1528+
/* We support only two types - 9B and 16B for now */
1529+
static const hfi1_handle_cnp hfi1_handle_cnp_tbl[2] = {
1530+
[HFI1_PKT_TYPE_9B] = &return_cnp,
1531+
[HFI1_PKT_TYPE_16B] = &return_cnp_16B
1532+
};
15101533
#define PKEY_CHECK_INVALID -1
15111534
int egress_pkey_check(struct hfi1_pportdata *ppd, __be16 *lrh, __be32 *bth,
15121535
u8 sc5, int8_t s_pkey_index);
@@ -1747,12 +1770,22 @@ static inline bool process_ecn(struct rvt_qp *qp, struct hfi1_packet *pkt,
17471770
bool do_cnp)
17481771
{
17491772
struct ib_other_headers *ohdr = pkt->ohdr;
1750-
u32 bth1;
17511773

1752-
bth1 = be32_to_cpu(ohdr->bth[1]);
1753-
if (unlikely(bth1 & (IB_BECN_SMASK | IB_FECN_SMASK))) {
1774+
u32 bth1;
1775+
bool becn = false;
1776+
bool fecn = false;
1777+
1778+
if (pkt->etype == RHF_RCV_TYPE_BYPASS) {
1779+
fecn = hfi1_16B_get_fecn(pkt->hdr);
1780+
becn = hfi1_16B_get_becn(pkt->hdr);
1781+
} else {
1782+
bth1 = be32_to_cpu(ohdr->bth[1]);
1783+
fecn = bth1 & IB_FECN_SMASK;
1784+
becn = bth1 & IB_BECN_SMASK;
1785+
}
1786+
if (unlikely(fecn || becn)) {
17541787
hfi1_process_ecn_slowpath(qp, pkt, do_cnp);
1755-
return !!(bth1 & IB_FECN_SMASK);
1788+
return fecn;
17561789
}
17571790
return false;
17581791
}
@@ -2315,4 +2348,80 @@ static inline bool hfi1_get_hdr_type(u32 lid, struct rdma_ah_attr *attr)
23152348

23162349
return hfi1_get_packet_type(lid);
23172350
}
2351+
2352+
static inline void hfi1_make_ext_grh(struct hfi1_packet *packet,
2353+
struct ib_grh *grh, u32 slid,
2354+
u32 dlid)
2355+
{
2356+
struct hfi1_ibport *ibp = &packet->rcd->ppd->ibport_data;
2357+
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
2358+
2359+
if (!ibp)
2360+
return;
2361+
2362+
grh->hop_limit = 1;
2363+
grh->sgid.global.subnet_prefix = ibp->rvp.gid_prefix;
2364+
if (slid == opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE), 16B))
2365+
grh->sgid.global.interface_id =
2366+
OPA_MAKE_ID(be32_to_cpu(OPA_LID_PERMISSIVE));
2367+
else
2368+
grh->sgid.global.interface_id = OPA_MAKE_ID(slid);
2369+
2370+
/*
2371+
* Upper layers (like mad) may compare the dgid in the
2372+
* wc that is obtained here with the sgid_index in
2373+
* the wr. Since sgid_index in wr is always 0 for
2374+
* extended lids, set the dgid here to the default
2375+
* IB gid.
2376+
*/
2377+
grh->dgid.global.subnet_prefix = ibp->rvp.gid_prefix;
2378+
grh->dgid.global.interface_id =
2379+
cpu_to_be64(ppd->guids[HFI1_PORT_GUID_INDEX]);
2380+
}
2381+
2382+
static inline int hfi1_get_16b_padding(u32 hdr_size, u32 payload)
2383+
{
2384+
return -(hdr_size + payload + (SIZE_OF_CRC << 2) +
2385+
SIZE_OF_LT) & 0x7;
2386+
}
2387+
2388+
static inline void hfi1_make_ib_hdr(struct ib_header *hdr,
2389+
u16 lrh0, u16 len,
2390+
u16 dlid, u16 slid)
2391+
{
2392+
hdr->lrh[0] = cpu_to_be16(lrh0);
2393+
hdr->lrh[1] = cpu_to_be16(dlid);
2394+
hdr->lrh[2] = cpu_to_be16(len);
2395+
hdr->lrh[3] = cpu_to_be16(slid);
2396+
}
2397+
2398+
static inline void hfi1_make_16b_hdr(struct hfi1_16b_header *hdr,
2399+
u32 slid, u32 dlid,
2400+
u16 len, u16 pkey,
2401+
u8 becn, u8 fecn, u8 l4,
2402+
u8 sc)
2403+
{
2404+
u32 lrh0 = 0;
2405+
u32 lrh1 = 0x40000000;
2406+
u32 lrh2 = 0;
2407+
u32 lrh3 = 0;
2408+
2409+
lrh0 = (lrh0 & ~OPA_16B_BECN_MASK) | (becn << OPA_16B_BECN_SHIFT);
2410+
lrh0 = (lrh0 & ~OPA_16B_LEN_MASK) | (len << OPA_16B_LEN_SHIFT);
2411+
lrh0 = (lrh0 & ~OPA_16B_LID_MASK) | (slid & OPA_16B_LID_MASK);
2412+
lrh1 = (lrh1 & ~OPA_16B_FECN_MASK) | (fecn << OPA_16B_FECN_SHIFT);
2413+
lrh1 = (lrh1 & ~OPA_16B_SC_MASK) | (sc << OPA_16B_SC_SHIFT);
2414+
lrh1 = (lrh1 & ~OPA_16B_LID_MASK) | (dlid & OPA_16B_LID_MASK);
2415+
lrh2 = (lrh2 & ~OPA_16B_SLID_MASK) |
2416+
((slid >> OPA_16B_SLID_SHIFT) << OPA_16B_SLID_HIGH_SHIFT);
2417+
lrh2 = (lrh2 & ~OPA_16B_DLID_MASK) |
2418+
((dlid >> OPA_16B_DLID_SHIFT) << OPA_16B_DLID_HIGH_SHIFT);
2419+
lrh2 = (lrh2 & ~OPA_16B_PKEY_MASK) | (pkey << OPA_16B_PKEY_SHIFT);
2420+
lrh2 = (lrh2 & ~OPA_16B_L4_MASK) | l4;
2421+
2422+
hdr->lrh[0] = lrh0;
2423+
hdr->lrh[1] = lrh1;
2424+
hdr->lrh[2] = lrh2;
2425+
hdr->lrh[3] = lrh3;
2426+
}
23182427
#endif /* _HFI1_KERNEL_H */

drivers/infiniband/hw/hfi1/mad.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,10 @@ static struct trap_node *create_trap_node(u8 type, __be16 trap_num, u32 lid)
373373
* Send a bad P_Key trap (ch. 14.3.8).
374374
*/
375375
void hfi1_bad_pkey(struct hfi1_ibport *ibp, u32 key, u32 sl,
376-
u32 qp1, u32 qp2, u16 lid1, u16 lid2)
376+
u32 qp1, u32 qp2, u32 lid1, u32 lid2)
377377
{
378378
struct trap_node *trap;
379379
u32 lid = ppd_from_ibp(ibp)->lid;
380-
u32 _lid1 = lid1;
381-
u32 _lid2 = lid2;
382380

383381
ibp->rvp.n_pkt_drops++;
384382
ibp->rvp.pkey_violations++;
@@ -389,8 +387,8 @@ void hfi1_bad_pkey(struct hfi1_ibport *ibp, u32 key, u32 sl,
389387
return;
390388

391389
/* Send violation trap */
392-
trap->data.ntc_257_258.lid1 = cpu_to_be32(_lid1);
393-
trap->data.ntc_257_258.lid2 = cpu_to_be32(_lid2);
390+
trap->data.ntc_257_258.lid1 = cpu_to_be32(lid1);
391+
trap->data.ntc_257_258.lid2 = cpu_to_be32(lid2);
394392
trap->data.ntc_257_258.key = cpu_to_be32(key);
395393
trap->data.ntc_257_258.sl = sl << 3;
396394
trap->data.ntc_257_258.qp1 = cpu_to_be32(qp1);

drivers/infiniband/hw/hfi1/ruc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static void ruc_loopback(struct rvt_qp *sqp)
649649
* @ibp: a pointer to the IB port
650650
* @hdr: a pointer to the GRH header being constructed
651651
* @grh: the global route address to send to
652-
* @hwords: the number of 32 bit words of header being sent
652+
* @hwords: size of header after grh being sent in dwords
653653
* @nwords: the number of 32 bit words of data being sent
654654
*
655655
* Return the size of the header in 32 bit words.
@@ -661,7 +661,7 @@ u32 hfi1_make_grh(struct hfi1_ibport *ibp, struct ib_grh *hdr,
661661
cpu_to_be32((IB_GRH_VERSION << IB_GRH_VERSION_SHIFT) |
662662
(grh->traffic_class << IB_GRH_TCLASS_SHIFT) |
663663
(grh->flow_label << IB_GRH_FLOW_SHIFT));
664-
hdr->paylen = cpu_to_be16((hwords - 2 + nwords + SIZE_OF_CRC) << 2);
664+
hdr->paylen = cpu_to_be16((hwords + nwords) << 2);
665665
/* next_hdr is defined by C8-7 in ch. 8.4.1 */
666666
hdr->next_hdr = IB_GRH_NEXT_HDR;
667667
hdr->hop_limit = grh->hop_limit;

0 commit comments

Comments
 (0)