Commit 13d84914 authored by Dennis Dalessandro's avatar Dennis Dalessandro Committed by Doug Ledford

IB/hfi1,qib: Do not send QKey trap for UD qps

According to IBTA spec a QKey violation should not result in a bad qkey
trap being triggered for UD queue pairs. Also since it is a silent error
we do not increment the q_key violation or the dropped packet counters.
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent bec7c79c
...@@ -180,10 +180,10 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len) ...@@ -180,10 +180,10 @@ static void send_trap(struct hfi1_ibport *ibp, void *data, unsigned len)
} }
/* /*
* Send a bad [PQ]_Key trap (ch. 14.3.8). * Send a bad P_Key trap (ch. 14.3.8).
*/ */
void hfi1_bad_pqkey(struct hfi1_ibport *ibp, __be16 trap_num, u32 key, u32 sl, void hfi1_bad_pkey(struct hfi1_ibport *ibp, u32 key, u32 sl,
u32 qp1, u32 qp2, u16 lid1, u16 lid2) u32 qp1, u32 qp2, u16 lid1, u16 lid2)
{ {
struct opa_mad_notice_attr data; struct opa_mad_notice_attr data;
u32 lid = ppd_from_ibp(ibp)->lid; u32 lid = ppd_from_ibp(ibp)->lid;
...@@ -191,17 +191,13 @@ void hfi1_bad_pqkey(struct hfi1_ibport *ibp, __be16 trap_num, u32 key, u32 sl, ...@@ -191,17 +191,13 @@ void hfi1_bad_pqkey(struct hfi1_ibport *ibp, __be16 trap_num, u32 key, u32 sl,
u32 _lid2 = lid2; u32 _lid2 = lid2;
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
if (trap_num == OPA_TRAP_BAD_P_KEY)
ibp->rvp.pkey_violations++;
else
ibp->rvp.qkey_violations++;
ibp->rvp.n_pkt_drops++; ibp->rvp.n_pkt_drops++;
ibp->rvp.pkey_violations++;
/* Send violation trap */ /* Send violation trap */
data.generic_type = IB_NOTICE_TYPE_SECURITY; data.generic_type = IB_NOTICE_TYPE_SECURITY;
data.prod_type_lsb = IB_NOTICE_PROD_CA; data.prod_type_lsb = IB_NOTICE_PROD_CA;
data.trap_num = trap_num; data.trap_num = OPA_TRAP_BAD_P_KEY;
data.issuer_lid = cpu_to_be32(lid); data.issuer_lid = cpu_to_be32(lid);
data.ntc_257_258.lid1 = cpu_to_be32(_lid1); data.ntc_257_258.lid1 = cpu_to_be32(_lid1);
data.ntc_257_258.lid2 = cpu_to_be32(_lid2); data.ntc_257_258.lid2 = cpu_to_be32(_lid2);
......
...@@ -254,8 +254,8 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet) ...@@ -254,8 +254,8 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet)
} }
if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0, if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0,
sc5, slid))) { sc5, slid))) {
hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_P_KEY, (u16)bth0, sl, hfi1_bad_pkey(ibp, (u16)bth0, sl,
0, qp->ibqp.qp_num, slid, dlid); 0, qp->ibqp.qp_num, slid, dlid);
return 1; return 1;
} }
/* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */ /* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */
...@@ -290,8 +290,8 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet) ...@@ -290,8 +290,8 @@ int hfi1_ruc_check_hdr(struct hfi1_ibport *ibp, struct hfi1_packet *packet)
} }
if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0, if (unlikely(rcv_pkey_check(ppd_from_ibp(ibp), (u16)bth0,
sc5, slid))) { sc5, slid))) {
hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_P_KEY, (u16)bth0, sl, hfi1_bad_pkey(ibp, (u16)bth0, sl,
0, qp->ibqp.qp_num, slid, dlid); 0, qp->ibqp.qp_num, slid, dlid);
return 1; return 1;
} }
/* Validate the SLID. See Ch. 9.6.1.5 */ /* Validate the SLID. See Ch. 9.6.1.5 */
......
...@@ -110,10 +110,10 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -110,10 +110,10 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
((1 << ppd->lmc) - 1)); ((1 << ppd->lmc) - 1));
if (unlikely(ingress_pkey_check(ppd, pkey, sc5, if (unlikely(ingress_pkey_check(ppd, pkey, sc5,
qp->s_pkey_index, slid))) { qp->s_pkey_index, slid))) {
hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_P_KEY, pkey, hfi1_bad_pkey(ibp, pkey,
rdma_ah_get_sl(ah_attr), rdma_ah_get_sl(ah_attr),
sqp->ibqp.qp_num, qp->ibqp.qp_num, sqp->ibqp.qp_num, qp->ibqp.qp_num,
slid, rdma_ah_get_dlid(ah_attr)); slid, rdma_ah_get_dlid(ah_attr));
goto drop; goto drop;
} }
} }
...@@ -128,18 +128,8 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -128,18 +128,8 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
qkey = (int)swqe->ud_wr.remote_qkey < 0 ? qkey = (int)swqe->ud_wr.remote_qkey < 0 ?
sqp->qkey : swqe->ud_wr.remote_qkey; sqp->qkey : swqe->ud_wr.remote_qkey;
if (unlikely(qkey != qp->qkey)) { if (unlikely(qkey != qp->qkey))
u16 lid; goto drop; /* silently drop per IBTA spec */
lid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
((1 << ppd->lmc) - 1));
hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_Q_KEY, qkey,
rdma_ah_get_sl(ah_attr),
sqp->ibqp.qp_num, qp->ibqp.qp_num,
lid,
rdma_ah_get_dlid(ah_attr));
goto drop;
}
} }
/* /*
...@@ -722,10 +712,10 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -722,10 +712,10 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
* for invalid pkeys is optional according to * for invalid pkeys is optional according to
* IB spec (release 1.3, section 10.9.4) * IB spec (release 1.3, section 10.9.4)
*/ */
hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_P_KEY, hfi1_bad_pkey(ibp,
pkey, sl, pkey, sl,
src_qp, qp->ibqp.qp_num, src_qp, qp->ibqp.qp_num,
slid, dlid); slid, dlid);
return; return;
} }
} else { } else {
...@@ -734,12 +724,9 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -734,12 +724,9 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
if (mgmt_pkey_idx < 0) if (mgmt_pkey_idx < 0)
goto drop; goto drop;
} }
if (unlikely(qkey != qp->qkey)) { if (unlikely(qkey != qp->qkey)) /* Silent drop */
hfi1_bad_pqkey(ibp, OPA_TRAP_BAD_Q_KEY, qkey, sl,
src_qp, qp->ibqp.qp_num,
slid, dlid);
return; return;
}
/* Drop invalid MAD packets (see 13.5.3.1). */ /* Drop invalid MAD packets (see 13.5.3.1). */
if (unlikely(qp->ibqp.qp_num == 1 && if (unlikely(qp->ibqp.qp_num == 1 &&
(tlen > 2048 || (sc5 == 0xF)))) (tlen > 2048 || (sc5 == 0xF))))
......
...@@ -236,8 +236,8 @@ static inline int hfi1_send_ok(struct rvt_qp *qp) ...@@ -236,8 +236,8 @@ static inline int hfi1_send_ok(struct rvt_qp *qp)
/* /*
* This must be called with s_lock held. * This must be called with s_lock held.
*/ */
void hfi1_bad_pqkey(struct hfi1_ibport *ibp, __be16 trap_num, u32 key, u32 sl, void hfi1_bad_pkey(struct hfi1_ibport *ibp, u32 key, u32 sl,
u32 qp1, u32 qp2, u16 lid1, u16 lid2); u32 qp1, u32 qp2, u16 lid1, u16 lid2);
void hfi1_cap_mask_chg(struct rvt_dev_info *rdi, u8 port_num); void hfi1_cap_mask_chg(struct rvt_dev_info *rdi, u8 port_num);
void hfi1_sys_guid_chg(struct hfi1_ibport *ibp); void hfi1_sys_guid_chg(struct hfi1_ibport *ibp);
void hfi1_node_desc_chg(struct hfi1_ibport *ibp); void hfi1_node_desc_chg(struct hfi1_ibport *ibp);
......
...@@ -134,24 +134,21 @@ static void qib_send_trap(struct qib_ibport *ibp, void *data, unsigned len) ...@@ -134,24 +134,21 @@ static void qib_send_trap(struct qib_ibport *ibp, void *data, unsigned len)
} }
/* /*
* Send a bad [PQ]_Key trap (ch. 14.3.8). * Send a bad P_Key trap (ch. 14.3.8).
*/ */
void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl, void qib_bad_pkey(struct qib_ibport *ibp, u32 key, u32 sl,
u32 qp1, u32 qp2, __be16 lid1, __be16 lid2) u32 qp1, u32 qp2, __be16 lid1, __be16 lid2)
{ {
struct ib_mad_notice_attr data; struct ib_mad_notice_attr data;
if (trap_num == IB_NOTICE_TRAP_BAD_PKEY)
ibp->rvp.pkey_violations++;
else
ibp->rvp.qkey_violations++;
ibp->rvp.n_pkt_drops++; ibp->rvp.n_pkt_drops++;
ibp->rvp.pkey_violations++;
/* Send violation trap */ /* Send violation trap */
data.generic_type = IB_NOTICE_TYPE_SECURITY; data.generic_type = IB_NOTICE_TYPE_SECURITY;
data.prod_type_msb = 0; data.prod_type_msb = 0;
data.prod_type_lsb = IB_NOTICE_PROD_CA; data.prod_type_lsb = IB_NOTICE_PROD_CA;
data.trap_num = trap_num; data.trap_num = IB_NOTICE_TRAP_BAD_PKEY;
data.issuer_lid = cpu_to_be16(ppd_from_ibp(ibp)->lid); data.issuer_lid = cpu_to_be16(ppd_from_ibp(ibp)->lid);
data.toggle_count = 0; data.toggle_count = 0;
memset(&data.details, 0, sizeof(data.details)); memset(&data.details, 0, sizeof(data.details));
......
...@@ -256,11 +256,11 @@ int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr, ...@@ -256,11 +256,11 @@ int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
} }
if (!qib_pkey_ok((u16)bth0, if (!qib_pkey_ok((u16)bth0,
qib_get_pkey(ibp, qp->s_alt_pkey_index))) { qib_get_pkey(ibp, qp->s_alt_pkey_index))) {
qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_PKEY, qib_bad_pkey(ibp,
(u16)bth0, (u16)bth0,
(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF, (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
0, qp->ibqp.qp_num, 0, qp->ibqp.qp_num,
hdr->lrh[3], hdr->lrh[1]); hdr->lrh[3], hdr->lrh[1]);
goto err; goto err;
} }
/* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */ /* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */
...@@ -295,11 +295,11 @@ int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr, ...@@ -295,11 +295,11 @@ int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
} }
if (!qib_pkey_ok((u16)bth0, if (!qib_pkey_ok((u16)bth0,
qib_get_pkey(ibp, qp->s_pkey_index))) { qib_get_pkey(ibp, qp->s_pkey_index))) {
qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_PKEY, qib_bad_pkey(ibp,
(u16)bth0, (u16)bth0,
(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF, (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
0, qp->ibqp.qp_num, 0, qp->ibqp.qp_num,
hdr->lrh[3], hdr->lrh[1]); hdr->lrh[3], hdr->lrh[1]);
goto err; goto err;
} }
/* Validate the SLID. See Ch. 9.6.1.5 */ /* Validate the SLID. See Ch. 9.6.1.5 */
......
...@@ -66,8 +66,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -66,8 +66,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
qp = rvt_lookup_qpn(rdi, &ibp->rvp, swqe->ud_wr.remote_qpn); qp = rvt_lookup_qpn(rdi, &ibp->rvp, swqe->ud_wr.remote_qpn);
if (!qp) { if (!qp) {
ibp->rvp.n_pkt_drops++; ibp->rvp.n_pkt_drops++;
rcu_read_unlock(); goto drop;
return;
} }
sqptype = sqp->ibqp.qp_type == IB_QPT_GSI ? sqptype = sqp->ibqp.qp_type == IB_QPT_GSI ?
...@@ -94,11 +93,11 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -94,11 +93,11 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
if (unlikely(!qib_pkey_ok(pkey1, pkey2))) { if (unlikely(!qib_pkey_ok(pkey1, pkey2))) {
lid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) & lid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
((1 << ppd->lmc) - 1)); ((1 << ppd->lmc) - 1));
qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_PKEY, pkey1, qib_bad_pkey(ibp, pkey1,
rdma_ah_get_sl(ah_attr), rdma_ah_get_sl(ah_attr),
sqp->ibqp.qp_num, qp->ibqp.qp_num, sqp->ibqp.qp_num, qp->ibqp.qp_num,
cpu_to_be16(lid), cpu_to_be16(lid),
cpu_to_be16(rdma_ah_get_dlid(ah_attr))); cpu_to_be16(rdma_ah_get_dlid(ah_attr)));
goto drop; goto drop;
} }
} }
...@@ -113,18 +112,8 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -113,18 +112,8 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
qkey = (int)swqe->ud_wr.remote_qkey < 0 ? qkey = (int)swqe->ud_wr.remote_qkey < 0 ?
sqp->qkey : swqe->ud_wr.remote_qkey; sqp->qkey : swqe->ud_wr.remote_qkey;
if (unlikely(qkey != qp->qkey)) { if (unlikely(qkey != qp->qkey))
u16 lid;
lid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
((1 << ppd->lmc) - 1));
qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_QKEY, qkey,
rdma_ah_get_sl(ah_attr),
sqp->ibqp.qp_num, qp->ibqp.qp_num,
cpu_to_be16(lid),
cpu_to_be16(rdma_ah_get_dlid(ah_attr)));
goto drop; goto drop;
}
} }
/* /*
...@@ -487,22 +476,18 @@ void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr, ...@@ -487,22 +476,18 @@ void qib_ud_rcv(struct qib_ibport *ibp, struct ib_header *hdr,
pkey1 = be32_to_cpu(ohdr->bth[0]); pkey1 = be32_to_cpu(ohdr->bth[0]);
pkey2 = qib_get_pkey(ibp, qp->s_pkey_index); pkey2 = qib_get_pkey(ibp, qp->s_pkey_index);
if (unlikely(!qib_pkey_ok(pkey1, pkey2))) { if (unlikely(!qib_pkey_ok(pkey1, pkey2))) {
qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_PKEY, qib_bad_pkey(ibp,
pkey1, pkey1,
(be16_to_cpu(hdr->lrh[0]) >> 4) & (be16_to_cpu(hdr->lrh[0]) >> 4) &
0xF, 0xF,
src_qp, qp->ibqp.qp_num, src_qp, qp->ibqp.qp_num,
hdr->lrh[3], hdr->lrh[1]); hdr->lrh[3], hdr->lrh[1]);
return; return;
} }
} }
if (unlikely(qkey != qp->qkey)) { if (unlikely(qkey != qp->qkey))
qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_QKEY, qkey,
(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
src_qp, qp->ibqp.qp_num,
hdr->lrh[3], hdr->lrh[1]);
return; return;
}
/* Drop invalid MAD packets (see 13.5.3.1). */ /* Drop invalid MAD packets (see 13.5.3.1). */
if (unlikely(qp->ibqp.qp_num == 1 && if (unlikely(qp->ibqp.qp_num == 1 &&
(tlen != 256 || (tlen != 256 ||
......
...@@ -241,8 +241,8 @@ static inline int qib_pkey_ok(u16 pkey1, u16 pkey2) ...@@ -241,8 +241,8 @@ static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)
return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0); return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0);
} }
void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl, void qib_bad_pkey(struct qib_ibport *ibp, u32 key, u32 sl,
u32 qp1, u32 qp2, __be16 lid1, __be16 lid2); u32 qp1, u32 qp2, __be16 lid1, __be16 lid2);
void qib_cap_mask_chg(struct rvt_dev_info *rdi, u8 port_num); void qib_cap_mask_chg(struct rvt_dev_info *rdi, u8 port_num);
void qib_sys_guid_chg(struct qib_ibport *ibp); void qib_sys_guid_chg(struct qib_ibport *ibp);
void qib_node_desc_chg(struct qib_ibport *ibp); void qib_node_desc_chg(struct qib_ibport *ibp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment