From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Don Hiatt <don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH for-next 20/27] IB/hfi1: Add support to process 16B header errors
Date: Fri, 04 Aug 2017 13:54:10 -0700 [thread overview]
Message-ID: <20170804205409.17853.54638.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20170804204842.17853.14858.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
From: Don Hiatt <don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Enhance hdr_rcverr() to also handle errors during
16B bypass packet receive.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Don Hiatt <don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/infiniband/hw/hfi1/driver.c | 58 ++++++++++++++++++++++++++++-------
drivers/infiniband/hw/hfi1/hfi.h | 13 +++++++-
drivers/infiniband/hw/hfi1/ruc.c | 31 ++++++++++++-------
drivers/infiniband/hw/hfi1/ud.c | 3 +-
drivers/infiniband/hw/hfi1/verbs.c | 39 +++++++++++++++++++-----
drivers/infiniband/hw/hfi1/verbs.h | 1 +
6 files changed, 112 insertions(+), 33 deletions(-)
diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
index 5280d82..ae6a90d 100644
--- a/drivers/infiniband/hw/hfi1/driver.c
+++ b/drivers/infiniband/hw/hfi1/driver.c
@@ -269,8 +269,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
{
struct ib_header *rhdr = packet->hdr;
u32 rte = rhf_rcv_type_err(packet->rhf);
- u8 lnh = ib_get_lnh(rhdr);
- bool has_grh = false;
+ u32 mlid_base;
struct hfi1_ibport *ibp = rcd_to_iport(rcd);
struct hfi1_devdata *dd = ppd->dd;
struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
@@ -278,14 +277,20 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
if (packet->rhf & (RHF_VCRC_ERR | RHF_ICRC_ERR))
return;
- if (lnh == HFI1_LRH_BTH) {
- packet->ohdr = &rhdr->u.oth;
- } else if (lnh == HFI1_LRH_GRH) {
- has_grh = true;
- packet->ohdr = &rhdr->u.l.oth;
- packet->grh = &rhdr->u.l.grh;
- } else {
+ if (packet->etype == RHF_RCV_TYPE_BYPASS) {
goto drop;
+ } else {
+ u8 lnh = ib_get_lnh(rhdr);
+
+ mlid_base = be16_to_cpu(IB_MULTICAST_LID_BASE);
+ if (lnh == HFI1_LRH_BTH) {
+ packet->ohdr = &rhdr->u.oth;
+ } else if (lnh == HFI1_LRH_GRH) {
+ packet->ohdr = &rhdr->u.l.oth;
+ packet->grh = &rhdr->u.l.grh;
+ } else {
+ goto drop;
+ }
}
if (packet->rhf & RHF_TID_ERR) {
@@ -293,14 +298,13 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
u32 dlid = ib_get_dlid(rhdr);
u32 qp_num;
- u32 mlid_base = be16_to_cpu(IB_MULTICAST_LID_BASE);
/* Sanity check packet */
if (tlen < 24)
goto drop;
/* Check for GRH */
- if (has_grh) {
+ if (packet->grh) {
u32 vtf;
struct ib_grh *grh = packet->grh;
@@ -1370,6 +1374,35 @@ static inline void hfi1_setup_ib_header(struct hfi1_packet *packet)
packet->hlen = (u8 *)packet->rhf_addr - (u8 *)packet->hdr;
}
+static int hfi1_bypass_ingress_pkt_check(struct hfi1_packet *packet)
+{
+ struct hfi1_pportdata *ppd = packet->rcd->ppd;
+
+ /* slid and dlid cannot be 0 */
+ if ((!packet->slid) || (!packet->dlid))
+ return -EINVAL;
+
+ /* Compare port lid with incoming packet dlid */
+ if ((!(hfi1_is_16B_mcast(packet->dlid))) &&
+ (packet->dlid !=
+ opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE), 16B))) {
+ if (packet->dlid != ppd->lid)
+ return -EINVAL;
+ }
+
+ /* No multicast packets with SC15 */
+ if ((hfi1_is_16B_mcast(packet->dlid)) && (packet->sc == 0xF))
+ return -EINVAL;
+
+ /* Packets with permissive DLID always on SC15 */
+ if ((packet->dlid == opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE),
+ 16B)) &&
+ (packet->sc != 0xF))
+ return -EINVAL;
+
+ return 0;
+}
+
static int hfi1_setup_9B_packet(struct hfi1_packet *packet)
{
struct hfi1_ibport *ibp = rcd_to_iport(packet->rcd);
@@ -1479,6 +1512,9 @@ static int hfi1_setup_bypass_packet(struct hfi1_packet *packet)
packet->fecn = hfi1_16B_get_fecn(packet->hdr);
packet->becn = hfi1_16B_get_becn(packet->hdr);
+ if (hfi1_bypass_ingress_pkt_check(packet))
+ goto drop;
+
return 0;
drop:
hfi1_cdbg(PKT, "%s: packet dropped\n", __func__);
diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
index dbbad76..ee19660 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -372,6 +372,10 @@ struct hfi1_packet {
#define OPA_16B_FECN_SHIFT 28
#define OPA_16B_L2_MASK 0x60000000ull
#define OPA_16B_L2_SHIFT 29
+#define OPA_16B_PKEY_MASK 0xFFFF0000ull
+#define OPA_16B_PKEY_SHIFT 16
+#define OPA_16B_LEN_MASK 0x7FF00000ull
+#define OPA_16B_LEN_SHIFT 20
/*
* OPA 16B L2/L4 Encodings
@@ -420,6 +424,11 @@ static inline u8 hfi1_16B_get_l2(struct hfi1_16b_header *hdr)
return (u8)((hdr->lrh[1] & OPA_16B_L2_MASK) >> OPA_16B_L2_SHIFT);
}
+static inline u16 hfi1_16B_get_pkey(struct hfi1_16b_header *hdr)
+{
+ return (u16)((hdr->lrh[2] & OPA_16B_PKEY_MASK) >> OPA_16B_PKEY_SHIFT);
+}
+
/*
* BTH
*/
@@ -1597,9 +1606,9 @@ static void ingress_pkey_table_fail(struct hfi1_pportdata *ppd, u16 pkey,
* by HW and rcv_pkey_check function should be called instead.
*/
static inline int ingress_pkey_check(struct hfi1_pportdata *ppd, u16 pkey,
- u8 sc5, u8 idx, u16 slid)
+ u8 sc5, u8 idx, u32 slid, bool force)
{
- if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
+ if (!(force) && !(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
return 0;
/* If SC15, pkey[0:14] must be 0x7fff */
diff --git a/drivers/infiniband/hw/hfi1/ruc.c b/drivers/infiniband/hw/hfi1/ruc.c
index e30c64f..d252f8f 100644
--- a/drivers/infiniband/hw/hfi1/ruc.c
+++ b/drivers/infiniband/hw/hfi1/ruc.c
@@ -227,15 +227,23 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet)
u32 sl = packet->sl;
int migrated;
u32 bth0, bth1;
+ u16 pkey;
bth0 = be32_to_cpu(packet->ohdr->bth[0]);
bth1 = be32_to_cpu(packet->ohdr->bth[1]);
- migrated = bth0 & IB_BTH_MIG_REQ;
+ if (packet->etype == RHF_RCV_TYPE_BYPASS) {
+ pkey = hfi1_16B_get_pkey(packet->hdr);
+ migrated = bth1 & OPA_BTH_MIG_REQ;
+ } else {
+ pkey = ib_bth_get_pkey(packet->ohdr);
+ migrated = bth0 & IB_BTH_MIG_REQ;
+ }
if (qp->s_mig_state == IB_MIG_ARMED && migrated) {
if (!packet->grh) {
- if (rdma_ah_get_ah_flags(&qp->alt_ah_attr) &
- IB_AH_GRH)
+ if ((rdma_ah_get_ah_flags(&qp->alt_ah_attr) &
+ IB_AH_GRH) &&
+ (packet->etype != RHF_RCV_TYPE_BYPASS))
return 1;
} else {
const struct ib_global_route *grh;
@@ -254,10 +262,10 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet)
grh->dgid.global.interface_id))
return 1;
}
- if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0,
+ if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), pkey,
sc5, slid))) {
- hfi1_bad_pkey(ibp, (u16)bth0, sl,
- 0, qp->ibqp.qp_num, slid, dlid);
+ hfi1_bad_pkey(ibp, pkey, sl, 0, qp->ibqp.qp_num,
+ slid, dlid);
return 1;
}
/* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */
@@ -270,8 +278,9 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet)
spin_unlock_irqrestore(&qp->s_lock, flags);
} else {
if (!packet->grh) {
- if (rdma_ah_get_ah_flags(&qp->remote_ah_attr) &
- IB_AH_GRH)
+ if ((rdma_ah_get_ah_flags(&qp->remote_ah_attr) &
+ IB_AH_GRH) &&
+ (packet->etype != RHF_RCV_TYPE_BYPASS))
return 1;
} else {
const struct ib_global_route *grh;
@@ -290,10 +299,10 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet)
grh->dgid.global.interface_id))
return 1;
}
- if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0,
+ if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), pkey,
sc5, slid))) {
- hfi1_bad_pkey(ibp, (u16)bth0, sl,
- 0, qp->ibqp.qp_num, slid, dlid);
+ hfi1_bad_pkey(ibp, pkey, sl, 0, qp->ibqp.qp_num,
+ slid, dlid);
return 1;
}
/* Validate the SLID. See Ch. 9.6.1.5 */
diff --git a/drivers/infiniband/hw/hfi1/ud.c b/drivers/infiniband/hw/hfi1/ud.c
index 2af993c..b708376 100644
--- a/drivers/infiniband/hw/hfi1/ud.c
+++ b/drivers/infiniband/hw/hfi1/ud.c
@@ -109,7 +109,8 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
slid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
((1 << ppd->lmc) - 1));
if (unlikely(ingress_pkey_check(ppd, pkey, sc5,
- qp->s_pkey_index, slid))) {
+ qp->s_pkey_index,
+ slid, false))) {
hfi1_bad_pkey(ibp, pkey,
rdma_ah_get_sl(ah_attr),
sqp->ibqp.qp_num, qp->ibqp.qp_num,
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 750996a..df4103d 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -568,6 +568,24 @@ static u64 hfi1_fault_tx(struct rvt_qp *qp, u8 opcode, u64 pbc)
return pbc;
}
+static int hfi1_do_pkey_check(struct hfi1_packet *packet)
+{
+ struct hfi1_ctxtdata *rcd = packet->rcd;
+ struct hfi1_pportdata *ppd = rcd->ppd;
+ struct hfi1_16b_header *hdr = packet->hdr;
+ u16 pkey;
+
+ /* Pkey check needed only for bypass packets */
+ if (packet->etype != RHF_RCV_TYPE_BYPASS)
+ return 0;
+
+ /* Perform pkey check */
+ pkey = hfi1_16B_get_pkey(hdr);
+ return ingress_pkey_check(ppd, pkey, packet->sc,
+ packet->qp->s_pkey_index,
+ packet->slid, true);
+}
+
static inline void hfi1_handle_packet(struct hfi1_packet *packet,
bool is_mcast)
{
@@ -594,6 +612,8 @@ static inline void hfi1_handle_packet(struct hfi1_packet *packet,
goto drop;
list_for_each_entry_rcu(p, &mcast->qp_list, list) {
packet->qp = p->qp;
+ if (hfi1_do_pkey_check(packet))
+ goto drop;
spin_lock_irqsave(&packet->qp->r_lock, flags);
packet_handler = qp_ok(packet);
if (likely(packet_handler))
@@ -613,15 +633,16 @@ static inline void hfi1_handle_packet(struct hfi1_packet *packet,
qp_num = ib_bth_get_qpn(packet->ohdr);
rcu_read_lock();
packet->qp = rvt_lookup_qpn(rdi, &ibp->rvp, qp_num);
- if (!packet->qp) {
- rcu_read_unlock();
- goto drop;
- }
+ if (!packet->qp)
+ goto unlock_drop;
+
+ if (hfi1_do_pkey_check(packet))
+ goto unlock_drop;
+
if (unlikely(hfi1_dbg_fault_opcode(packet->qp, packet->opcode,
- true))) {
- rcu_read_unlock();
- goto drop;
- }
+ true)))
+ goto unlock_drop;
+
spin_lock_irqsave(&packet->qp->r_lock, flags);
packet_handler = qp_ok(packet);
if (likely(packet_handler))
@@ -632,6 +653,8 @@ static inline void hfi1_handle_packet(struct hfi1_packet *packet,
rcu_read_unlock();
}
return;
+unlock_drop:
+ rcu_read_unlock();
drop:
ibp->rvp.n_pkt_drops++;
}
diff --git a/drivers/infiniband/hw/hfi1/verbs.h b/drivers/infiniband/hw/hfi1/verbs.h
index 2022410..68577a0 100644
--- a/drivers/infiniband/hw/hfi1/verbs.h
+++ b/drivers/infiniband/hw/hfi1/verbs.h
@@ -95,6 +95,7 @@
#define HFI1_VENDOR_IPG cpu_to_be16(0xFFA0)
#define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL)
+#define OPA_BTH_MIG_REQ BIT(31)
#define RC_OP(x) IB_OPCODE_RC_##x
#define UC_OP(x) IB_OPCODE_UC_##x
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-08-04 20:54 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 20:52 [PATCH for-next 00/27] IB/hfi1, rdmavt, core, etc: patches for next 08/04/2017 Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 01/27] IB/hfi1: Revert egress pkey check enforcement Dennis Dalessandro
[not found] ` <20170804204842.17853.14858.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-08-04 20:52 ` [PATCH for-next 02/27] IB/hfi1: Remove pmtu from the QP structure Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 03/27] IB/hfi1: Remove lstate from hfi1_pportdata Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 04/27] IB/hfi1: Use host_link_state to read state when DC is shut down Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 05/27] IB/hfi1: Protect context array set/clear with spinlock Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 06/27] IB/hf1: User context locking is inconsistent Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 07/27] IB/core: Convert ah_attr from OPA to IB when copying to user Dennis Dalessandro
2017-08-04 20:52 ` [PATCH for-next 08/27] IB/srpt: Increase lid and sm_lid to 32 bits Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 09/27] IB/IPoIB: Increase local_lid " Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 10/27] IB/mad: Change slid in RMPP recv from 16 " Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 11/27] IB/core: Change port_attr.lid size " Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 12/27] IB/core: Change port_attr.sm_lid " Dennis Dalessandro
[not found] ` <20170804205320.17853.77236.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-08-06 8:18 ` Leon Romanovsky
[not found] ` <20170806081857.GC3636-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-08-06 8:22 ` Leon Romanovsky
[not found] ` <20170806082217.GE3636-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-08-08 14:41 ` Leon Romanovsky
[not found] ` <20170808144146.GF28851-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-08-08 16:35 ` Weiny, Ira
[not found] ` <2807E5FD2F6FDA4886F6618EAC48510E67CFAF96-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-08-08 16:49 ` Don Hiatt
[not found] ` <018c6e70-78d5-51ec-993f-35be575a6da1-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-09 6:57 ` Leon Romanovsky
[not found] ` <20170809065730.GC1423-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-08-10 18:18 ` Don Hiatt
2017-08-09 6:56 ` Leon Romanovsky
2017-08-04 20:53 ` [PATCH for-next 13/27] IB/core: Change wc.slid " Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 14/27] IB/CM: Add OPA Path record support to CM Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 15/27] IB/CM: Create appropriate path records when handling CM request Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 16/27] IB/CM: Set appropriate slid and dlid " Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 17/27] IB/rdmavt, hfi1, qib: Modify check_ah() to account for extended LIDs Dennis Dalessandro
2017-08-04 20:53 ` [PATCH for-next 18/27] IB/hfi1: Add support to receive 16B bypass packets Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 19/27] IB/hfi1: Add support to send " Dennis Dalessandro
2017-08-04 20:54 ` Dennis Dalessandro [this message]
2017-08-04 20:54 ` [PATCH for-next 21/27] IB/hfi1: Determine 9B/16B L2 header type based on Address handle Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 22/27] IB/hfi1: Add 16B UD support Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 23/27] IB/hfi1: Add 16B trace support Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 24/27] IB/rdmavt, hfi1, qib: Enhance rdmavt and hfi1 to use 32 bit lids Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 25/27] IB/hfi1: Add 16B RC/UC support Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 26/27] IB/hfi1: Enhance PIO/SDMA send for 16B Dennis Dalessandro
2017-08-04 20:54 ` [PATCH for-next 27/27] IB/hfi1: Enable RDMA_CAP_OPA_AH in hfi driver to support extended LIDs Dennis Dalessandro
2017-08-10 17:05 ` [PATCH for-next 00/27] IB/hfi1, rdmavt, core, etc: patches for next 08/04/2017 Dennis Dalessandro
[not found] ` <f73b2f88-bc1b-92ed-1632-d2f3b1583d60-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-10 18:17 ` Don Hiatt
2017-08-18 19:07 ` Doug Ledford
2017-08-22 18:23 ` Doug Ledford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170804205409.17853.54638.stgit@scvm10.sc.intel.com \
--to=dennis.dalessandro-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=don.hiatt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).