driver.c (eeea8b40cd2866ca24f25e5ef09225edb076ae45) driver.c (261a4351844bcacb622d6d498a1bc98242b2db9e)
1/*
2 * Copyright(c) 2015, 2016 Intel Corporation.
3 *
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *

--- 262 unchanged lines hidden (view full) ---

271 if (encoded)
272 *encoded = ilog2(size / PAGE_SIZE) + 1;
273 return 1;
274}
275
276static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
277 struct hfi1_packet *packet)
278{
1/*
2 * Copyright(c) 2015, 2016 Intel Corporation.
3 *
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *

--- 262 unchanged lines hidden (view full) ---

271 if (encoded)
272 *encoded = ilog2(size / PAGE_SIZE) + 1;
273 return 1;
274}
275
276static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
277 struct hfi1_packet *packet)
278{
279 struct hfi1_message_header *rhdr = packet->hdr;
279 struct ib_header *rhdr = packet->hdr;
280 u32 rte = rhf_rcv_type_err(packet->rhf);
281 int lnh = be16_to_cpu(rhdr->lrh[0]) & 3;
282 struct hfi1_ibport *ibp = &ppd->ibport_data;
283 struct hfi1_devdata *dd = ppd->dd;
284 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
285
286 if (packet->rhf & (RHF_VCRC_ERR | RHF_ICRC_ERR))
287 return;
288
289 if (packet->rhf & RHF_TID_ERR) {
290 /* For TIDERR and RC QPs preemptively schedule a NAK */
280 u32 rte = rhf_rcv_type_err(packet->rhf);
281 int lnh = be16_to_cpu(rhdr->lrh[0]) & 3;
282 struct hfi1_ibport *ibp = &ppd->ibport_data;
283 struct hfi1_devdata *dd = ppd->dd;
284 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
285
286 if (packet->rhf & (RHF_VCRC_ERR | RHF_ICRC_ERR))
287 return;
288
289 if (packet->rhf & RHF_TID_ERR) {
290 /* For TIDERR and RC QPs preemptively schedule a NAK */
291 struct hfi1_ib_header *hdr = (struct hfi1_ib_header *)rhdr;
292 struct hfi1_other_headers *ohdr = NULL;
291 struct ib_other_headers *ohdr = NULL;
293 u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
292 u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
294 u16 lid = be16_to_cpu(hdr->lrh[1]);
293 u16 lid = be16_to_cpu(rhdr->lrh[1]);
295 u32 qp_num;
296 u32 rcv_flags = 0;
297
298 /* Sanity check packet */
299 if (tlen < 24)
300 goto drop;
301
302 /* Check for GRH */
303 if (lnh == HFI1_LRH_BTH) {
294 u32 qp_num;
295 u32 rcv_flags = 0;
296
297 /* Sanity check packet */
298 if (tlen < 24)
299 goto drop;
300
301 /* Check for GRH */
302 if (lnh == HFI1_LRH_BTH) {
304 ohdr = &hdr->u.oth;
303 ohdr = &rhdr->u.oth;
305 } else if (lnh == HFI1_LRH_GRH) {
306 u32 vtf;
307
304 } else if (lnh == HFI1_LRH_GRH) {
305 u32 vtf;
306
308 ohdr = &hdr->u.l.oth;
309 if (hdr->u.l.grh.next_hdr != IB_GRH_NEXT_HDR)
307 ohdr = &rhdr->u.l.oth;
308 if (rhdr->u.l.grh.next_hdr != IB_GRH_NEXT_HDR)
310 goto drop;
309 goto drop;
311 vtf = be32_to_cpu(hdr->u.l.grh.version_tclass_flow);
310 vtf = be32_to_cpu(rhdr->u.l.grh.version_tclass_flow);
312 if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
313 goto drop;
314 rcv_flags |= HFI1_HAS_GRH;
315 } else {
316 goto drop;
317 }
318 /* Get the destination QP number. */
319 qp_num = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;

--- 19 unchanged lines hidden (view full) ---

339 RVT_PROCESS_RECV_OK)) {
340 ibp->rvp.n_pkt_drops++;
341 }
342
343 switch (qp->ibqp.qp_type) {
344 case IB_QPT_RC:
345 hfi1_rc_hdrerr(
346 rcd,
311 if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
312 goto drop;
313 rcv_flags |= HFI1_HAS_GRH;
314 } else {
315 goto drop;
316 }
317 /* Get the destination QP number. */
318 qp_num = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;

--- 19 unchanged lines hidden (view full) ---

338 RVT_PROCESS_RECV_OK)) {
339 ibp->rvp.n_pkt_drops++;
340 }
341
342 switch (qp->ibqp.qp_type) {
343 case IB_QPT_RC:
344 hfi1_rc_hdrerr(
345 rcd,
347 hdr,
346 rhdr,
348 rcv_flags,
349 qp);
350 break;
351 default:
352 /* For now don't handle any other QP types */
353 break;
354 }
355

--- 91 unchanged lines hidden (view full) ---

447 packet->numpkt = 0;
448 packet->rcv_flags = 0;
449}
450
451void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
452 bool do_cnp)
453{
454 struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
347 rcv_flags,
348 qp);
349 break;
350 default:
351 /* For now don't handle any other QP types */
352 break;
353 }
354

--- 91 unchanged lines hidden (view full) ---

446 packet->numpkt = 0;
447 packet->rcv_flags = 0;
448}
449
450void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
451 bool do_cnp)
452{
453 struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
455 struct hfi1_ib_header *hdr = pkt->hdr;
456 struct hfi1_other_headers *ohdr = pkt->ohdr;
454 struct ib_header *hdr = pkt->hdr;
455 struct ib_other_headers *ohdr = pkt->ohdr;
457 struct ib_grh *grh = NULL;
458 u32 rqpn = 0, bth1;
459 u16 rlid, dlid = be16_to_cpu(hdr->lrh[1]);
460 u8 sc, svc_type;
461 bool is_mcast = false;
462
463 if (pkt->rcv_flags & HFI1_HAS_GRH)
464 grh = &hdr->u.l.grh;

--- 17 unchanged lines hidden (view full) ---

482 rlid = qp->remote_ah_attr.dlid;
483 rqpn = qp->remote_qpn;
484 svc_type = IB_CC_SVCTYPE_RC;
485 break;
486 default:
487 return;
488 }
489
456 struct ib_grh *grh = NULL;
457 u32 rqpn = 0, bth1;
458 u16 rlid, dlid = be16_to_cpu(hdr->lrh[1]);
459 u8 sc, svc_type;
460 bool is_mcast = false;
461
462 if (pkt->rcv_flags & HFI1_HAS_GRH)
463 grh = &hdr->u.l.grh;

--- 17 unchanged lines hidden (view full) ---

481 rlid = qp->remote_ah_attr.dlid;
482 rqpn = qp->remote_qpn;
483 svc_type = IB_CC_SVCTYPE_RC;
484 break;
485 default:
486 return;
487 }
488
490 sc = hdr2sc((struct hfi1_message_header *)hdr, pkt->rhf);
489 sc = hdr2sc(hdr, pkt->rhf);
491
492 bth1 = be32_to_cpu(ohdr->bth[1]);
493 if (do_cnp && (bth1 & HFI1_FECN_SMASK)) {
494 u16 pkey = (u16)be32_to_cpu(ohdr->bth[0]);
495
496 return_cnp(ibp, qp, rqpn, pkey, dlid, rlid, sc, grh);
497 }
498

--- 95 unchanged lines hidden (view full) ---

594 init_ps_mdata(&mdata, packet);
595
596 while (1) {
597 struct hfi1_devdata *dd = rcd->dd;
598 struct hfi1_ibport *ibp = &rcd->ppd->ibport_data;
599 __le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
600 dd->rhf_offset;
601 struct rvt_qp *qp;
490
491 bth1 = be32_to_cpu(ohdr->bth[1]);
492 if (do_cnp && (bth1 & HFI1_FECN_SMASK)) {
493 u16 pkey = (u16)be32_to_cpu(ohdr->bth[0]);
494
495 return_cnp(ibp, qp, rqpn, pkey, dlid, rlid, sc, grh);
496 }
497

--- 95 unchanged lines hidden (view full) ---

593 init_ps_mdata(&mdata, packet);
594
595 while (1) {
596 struct hfi1_devdata *dd = rcd->dd;
597 struct hfi1_ibport *ibp = &rcd->ppd->ibport_data;
598 __le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
599 dd->rhf_offset;
600 struct rvt_qp *qp;
602 struct hfi1_ib_header *hdr;
603 struct hfi1_other_headers *ohdr;
601 struct ib_header *hdr;
602 struct ib_other_headers *ohdr;
604 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
605 u64 rhf = rhf_to_cpu(rhf_addr);
606 u32 etype = rhf_rcv_type(rhf), qpn, bth1;
607 int is_ecn = 0;
608 u8 lnh;
609
610 if (ps_done(&mdata, rhf, rcd))
611 break;
612
613 if (ps_skip(&mdata, rhf, rcd))
614 goto next;
615
616 if (etype != RHF_RCV_TYPE_IB)
617 goto next;
618
603 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
604 u64 rhf = rhf_to_cpu(rhf_addr);
605 u32 etype = rhf_rcv_type(rhf), qpn, bth1;
606 int is_ecn = 0;
607 u8 lnh;
608
609 if (ps_done(&mdata, rhf, rcd))
610 break;
611
612 if (ps_skip(&mdata, rhf, rcd))
613 goto next;
614
615 if (etype != RHF_RCV_TYPE_IB)
616 goto next;
617
619 hdr = (struct hfi1_ib_header *)
620 hfi1_get_msgheader(dd, rhf_addr);
618 hdr = hfi1_get_msgheader(dd, rhf_addr);
619
621 lnh = be16_to_cpu(hdr->lrh[0]) & 3;
622
623 if (lnh == HFI1_LRH_BTH)
624 ohdr = &hdr->u.oth;
625 else if (lnh == HFI1_LRH_GRH)
626 ohdr = &hdr->u.l.oth;
627 else
628 goto next; /* just in case */

--- 258 unchanged lines hidden (view full) ---

887 dd->rcd[i]->do_interrupt = &handle_receive_interrupt;
888}
889
890static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
891 struct hfi1_packet *packet,
892 struct hfi1_devdata *dd)
893{
894 struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
620 lnh = be16_to_cpu(hdr->lrh[0]) & 3;
621
622 if (lnh == HFI1_LRH_BTH)
623 ohdr = &hdr->u.oth;
624 else if (lnh == HFI1_LRH_GRH)
625 ohdr = &hdr->u.l.oth;
626 else
627 goto next; /* just in case */

--- 258 unchanged lines hidden (view full) ---

886 dd->rcd[i]->do_interrupt = &handle_receive_interrupt;
887}
888
889static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
890 struct hfi1_packet *packet,
891 struct hfi1_devdata *dd)
892{
893 struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
895 struct hfi1_message_header *hdr = hfi1_get_msgheader(packet->rcd->dd,
896 packet->rhf_addr);
894 struct ib_header *hdr = hfi1_get_msgheader(packet->rcd->dd,
895 packet->rhf_addr);
897 u8 etype = rhf_rcv_type(packet->rhf);
898
899 if (etype == RHF_RCV_TYPE_IB && hdr2sc(hdr, packet->rhf) != 0xf) {
900 int hwstate = read_logical_state(dd);
901
902 if (hwstate != LSTATE_ACTIVE) {
903 dd_dev_info(dd, "Unexpected link state %d\n", hwstate);
904 return 0;

--- 505 unchanged lines hidden ---
896 u8 etype = rhf_rcv_type(packet->rhf);
897
898 if (etype == RHF_RCV_TYPE_IB && hdr2sc(hdr, packet->rhf) != 0xf) {
899 int hwstate = read_logical_state(dd);
900
901 if (hwstate != LSTATE_ACTIVE) {
902 dd_dev_info(dd, "Unexpected link state %d\n", hwstate);
903 return 0;

--- 505 unchanged lines hidden ---