/* We support only two types - 9B and 16B for now */ staticconst hfi1_make_req hfi1_make_ud_req_tbl[2] = {
[HFI1_PKT_TYPE_9B] = &hfi1_make_ud_req_9B,
[HFI1_PKT_TYPE_16B] = &hfi1_make_ud_req_16B
};
/** * ud_loopback - handle send on loopback QPs * @sqp: the sending QP * @swqe: the send work request * * This is called from hfi1_make_ud_req() to forward a WQE addressed * to the same HFI. * Note that the receive interrupt handler may be calling hfi1_ud_rcv() * while this is being called.
*/ staticvoid ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
{ struct hfi1_ibport *ibp = to_iport(sqp->ibqp.device, sqp->port_num); struct hfi1_pportdata *ppd; struct hfi1_qp_priv *priv = sqp->priv; struct rvt_qp *qp; struct rdma_ah_attr *ah_attr; unsignedlong flags; struct rvt_sge_state ssge; struct rvt_sge *sge; struct ib_wc wc;
u32 length; enum ib_qp_type sqptype, dqptype;
/* * Check that the qkey matches (except for QP0, see 9.6.1.4.1). * Qkeys with the high order bit set mean use the * qkey from the QP context instead of the WR (see 10.2.5).
*/ if (qp->ibqp.qp_num) {
u32 qkey;
qkey = (int)rvt_get_swqe_remote_qkey(swqe) < 0 ?
sqp->qkey : rvt_get_swqe_remote_qkey(swqe); if (unlikely(qkey != qp->qkey)) goto drop; /* silently drop per IBTA spec */
}
/* * A GRH is expected to precede the data even if not * present on the wire.
*/
length = swqe->length;
memset(&wc, 0, sizeof(wc));
wc.byte_len = length + sizeof(struct ib_grh);
/* * Get the next work request entry to find where to put the data.
*/ if (qp->r_flags & RVT_R_REUSE_SGE) {
qp->r_flags &= ~RVT_R_REUSE_SGE;
} else { int ret;
ret = rvt_get_rwqe(qp, false); if (ret < 0) {
rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR); goto bail_unlock;
} if (!ret) { if (qp->ibqp.qp_num == 0)
ibp->rvp.n_vl15_dropped++; goto bail_unlock;
}
} /* Silently drop packets which are too big. */ if (unlikely(wc.byte_len > qp->r_len)) {
qp->r_flags |= RVT_R_REUSE_SGE;
ibp->rvp.n_pkt_drops++; goto bail_unlock;
}
/* * For loopback packets with extended LIDs, the * sgid_index in the GRH is 0 and the dgid is * OPA GID of the sender. While creating a response * to the loopback packet, IB core creates the new * sgid_index from the DGID and that will be the * OPA_GID_INDEX. The new dgid is from the sgid * index and that will be in the IB GID format. * * We now have a case where the sent packet had a * different sgid_index and dgid compared to the * one that was received in response. * * Fix this inconsistency.
*/ if (priv->hdr_type == HFI1_PKT_TYPE_16B) { if (grd.sgid_index == 0)
grd.sgid_index = OPA_GID_INDEX;
if (ib_is_opa_gid(&grd.dgid))
grd.dgid.global.interface_id =
cpu_to_be64(ppd->guids[HFI1_PORT_GUID_INDEX]);
}
if (wqe->wr.send_flags & IB_SEND_SOLICITED)
bth0 |= IB_BTH_SOLICITED;
bth0 |= extra_bytes << 20; if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI)
*pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe)); else
*pkey = hfi1_get_pkey(ibp, qp->s_pkey_index); if (!bypass)
bth0 |= *pkey;
ohdr->bth[0] = cpu_to_be32(bth0);
ohdr->bth[1] = cpu_to_be32(rvt_get_swqe_remote_qpn(wqe));
ohdr->bth[2] = cpu_to_be32(mask_psn(wqe->psn)); /* * Qkeys with the high order bit set mean use the * qkey from the QP context instead of the WR (see 10.2.5).
*/
ohdr->u.ud.deth[0] =
cpu_to_be32((int)rvt_get_swqe_remote_qkey(wqe) < 0 ? qp->qkey :
rvt_get_swqe_remote_qkey(wqe));
ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
}
/** * hfi1_make_ud_req - construct a UD request packet * @qp: the QP * @ps: the current packet state * * Assume s_lock is held. * * Return 1 if constructed; otherwise, return 0.
*/ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
{ struct hfi1_qp_priv *priv = qp->priv; struct rdma_ah_attr *ah_attr; struct hfi1_pportdata *ppd; struct hfi1_ibport *ibp; struct rvt_swqe *wqe; int next_cur;
u32 lid;
ps->s_txreq = get_txreq(ps->dev, qp); if (!ps->s_txreq) goto bail_no_tx;
if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_NEXT_SEND_OK)) { if (!(ib_rvt_state_ops[qp->state] & RVT_FLUSH_SEND)) goto bail; /* We are in the error state, flush the work request. */ if (qp->s_last == READ_ONCE(qp->s_head)) goto bail; /* If DMAs are in progress, we can't flush immediately. */ if (iowait_sdma_pending(&priv->s_iowait)) {
qp->s_flags |= RVT_S_WAIT_DMA; goto bail;
}
wqe = rvt_get_swqe_ptr(qp, qp->s_last);
rvt_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR); goto done_free_tx;
}
/* see post_one_send() */ if (qp->s_cur == READ_ONCE(qp->s_head)) goto bail;
/* Construct the header. */
ibp = to_iport(qp->ibqp.device, qp->port_num);
ppd = ppd_from_ibp(ibp);
ah_attr = rvt_get_swqe_ah_attr(wqe);
priv->hdr_type = hfi1_get_hdr_type(ppd->lid, ah_attr); if ((!hfi1_check_mcast(rdma_ah_get_dlid(ah_attr))) ||
(rdma_ah_get_dlid(ah_attr) == be32_to_cpu(OPA_LID_PERMISSIVE))) {
lid = rdma_ah_get_dlid(ah_attr) & ~((1 << ppd->lmc) - 1); if (unlikely(!loopback &&
((lid == ppd->lid) ||
((lid == be32_to_cpu(OPA_LID_PERMISSIVE)) &&
(qp->ibqp.qp_type == IB_QPT_GSI))))) { unsignedlong tflags = ps->flags; /* * If DMAs are in progress, we can't generate * a completion for the loopback packet since * it would be out of order. * Instead of waiting, we could queue a * zero length descriptor so we get a callback.
*/ if (iowait_sdma_pending(&priv->s_iowait)) {
qp->s_flags |= RVT_S_WAIT_DMA; goto bail;
}
qp->s_cur = next_cur;
spin_unlock_irqrestore(&qp->s_lock, tflags);
ud_loopback(qp, wqe);
spin_lock_irqsave(&qp->s_lock, tflags);
ps->flags = tflags;
rvt_send_complete(qp, wqe, IB_WC_SUCCESS); goto done_free_tx;
}
}
/* * Hardware can't check this so we do it here. * * This is a slightly different algorithm than the standard pkey check. It * special cases the management keys and allows for 0x7fff and 0xffff to be in * the table at the same time. * * @returns the index found or -1 if not found
*/ int hfi1_lookup_pkey_idx(struct hfi1_ibport *ibp, u16 pkey)
{ struct hfi1_pportdata *ppd = ppd_from_ibp(ibp); unsigned i;
for (i = 0; i < ARRAY_SIZE(ppd->pkeys); ++i) { /* here we look for an exact match */ if (ppd->pkeys[i] == pkey) return i; if (ppd->pkeys[i] == LIM_MGMT_P_KEY)
lim_idx = i;
}
/* did not find 0xffff return 0x7fff idx if found */ if (pkey == FULL_MGMT_P_KEY) return lim_idx;
/* no match... */ return -1;
}
pkey &= 0x7fff; /* remove limited/full membership bit */
for (i = 0; i < ARRAY_SIZE(ppd->pkeys); ++i) if ((ppd->pkeys[i] & 0x7fff) == pkey) return i;
/* * Should not get here, this means hardware failed to validate pkeys.
*/ return -1;
}
/* BIT 16 to 19 is TVER. Bit 20 to 22 is pad cnt */
bth0 = (IB_OPCODE_CNP << 24) | (1 << 16) |
(hfi1_get_16b_padding(hwords << 2, 0) << 20);
ohdr->bth[0] = cpu_to_be32(bth0);
/* * opa_smp_check() - Do the regular pkey checking, and the additional * checks for SMPs specified in OPAv1 rev 1.0, 9/19/2016 update, section * 9.10.25 ("SMA Packet Checks"). * * Note that: * - Checks are done using the pkey directly from the packet's BTH, * and specifically _not_ the pkey that we attach to the completion, * which may be different. * - These checks are specifically for "non-local" SMPs (i.e., SMPs * which originated on another node). SMPs which are sent from, and * destined to this node are checked in opa_local_smp_check(). * * At the point where opa_smp_check() is called, we know: * - destination QP is QP0 * * opa_smp_check() returns 0 if all checks succeed, 1 otherwise.
*/ staticint opa_smp_check(struct hfi1_ibport *ibp, u16 pkey, u8 sc5, struct rvt_qp *qp, u16 slid, struct opa_smp *smp)
{ struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
/* * I don't think it's possible for us to get here with sc != 0xf, * but check it to be certain.
*/ if (sc5 != 0xf) return 1;
if (rcv_pkey_check(ppd, pkey, sc5, slid)) return 1;
/* * At this point we know (and so don't need to check again) that * the pkey is either LIM_MGMT_P_KEY, or FULL_MGMT_P_KEY * (see ingress_pkey_check).
*/ if (smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE &&
smp->mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED) {
ingress_pkey_table_fail(ppd, pkey, slid); return 1;
}
/* * SMPs fall into one of four (disjoint) categories: * SMA request, SMA response, SMA trap, or SMA trap repress. * Our response depends, in part, on which type of SMP we're * processing. * * If this is an SMA response, skip the check here. * * If this is an SMA request or SMA trap repress: * - pkey != FULL_MGMT_P_KEY => * increment port recv constraint errors, drop MAD * * Otherwise: * - accept if the port is running an SM * - drop MAD if it's an SMA trap * - pkey == FULL_MGMT_P_KEY => * reply with unsupported method * - pkey != FULL_MGMT_P_KEY => * increment port recv constraint errors, drop MAD
*/ switch (smp->method) { case IB_MGMT_METHOD_GET_RESP: case IB_MGMT_METHOD_REPORT_RESP: break; case IB_MGMT_METHOD_GET: case IB_MGMT_METHOD_SET: case IB_MGMT_METHOD_REPORT: case IB_MGMT_METHOD_TRAP_REPRESS: if (pkey != FULL_MGMT_P_KEY) {
ingress_pkey_table_fail(ppd, pkey, slid); return 1;
} break; default: if (ibp->rvp.port_cap_flags & IB_PORT_SM) return 0; if (smp->method == IB_MGMT_METHOD_TRAP) return 1; if (pkey == FULL_MGMT_P_KEY) {
smp->status |= IB_SMP_UNSUP_METHOD; return 0;
}
ingress_pkey_table_fail(ppd, pkey, slid); return 1;
} return 0;
}
/** * hfi1_ud_rcv - receive an incoming UD packet * @packet: the packet structure * * This is called from qp_rcv() to process an incoming UD packet * for the given QP. * Called at interrupt level.
*/ void hfi1_ud_rcv(struct hfi1_packet *packet)
{
u32 hdrsize = packet->hlen; struct ib_wc wc;
u32 src_qp;
u16 pkey; int mgmt_pkey_idx = -1; struct hfi1_ibport *ibp = rcd_to_iport(packet->rcd); struct hfi1_pportdata *ppd = ppd_from_ibp(ibp); void *data = packet->payload;
u32 tlen = packet->tlen; struct rvt_qp *qp = packet->qp;
u8 sc5 = packet->sc;
u8 sl_from_sc;
u8 opcode = packet->opcode;
u8 sl = packet->sl;
u32 dlid = packet->dlid;
u32 slid = packet->slid;
u8 extra_bytes;
u8 l4 = 0; bool dlid_is_permissive; bool slid_is_permissive; bool solicited = false;
process_ecn(qp, packet); /* * Get the number of bytes the message was padded by * and drop incomplete packets.
*/ if (unlikely(tlen < (hdrsize + extra_bytes))) goto drop;
tlen -= hdrsize + extra_bytes;
/* * Check that the permissive LID is only used on QP0 * and the QKEY matches (see 9.6.1.4.1 and 9.6.1.5.1).
*/ if (qp->ibqp.qp_num) { if (unlikely(dlid_is_permissive || slid_is_permissive)) goto drop; if (qp->ibqp.qp_num > 1) { if (unlikely(rcv_pkey_check(ppd, pkey, sc5, slid))) { /* * Traps will not be sent for packets dropped * by the HW. This is fine, as sending trap * for invalid pkeys is optional according to * IB spec (release 1.3, section 10.9.4)
*/
hfi1_bad_pkey(ibp,
pkey, sl,
src_qp, qp->ibqp.qp_num,
slid, dlid); return;
}
} else { /* GSI packet */
mgmt_pkey_idx = hfi1_lookup_pkey_idx(ibp, pkey); if (mgmt_pkey_idx < 0) goto drop;
} if (unlikely(l4 != OPA_16B_L4_FM &&
ib_get_qkey(packet->ohdr) != qp->qkey)) return; /* Silent drop */
/* Drop invalid MAD packets (see 13.5.3.1). */ if (unlikely(qp->ibqp.qp_num == 1 &&
(tlen > 2048 || (sc5 == 0xF)))) goto drop;
} else { /* Received on QP0, and so by definition, this is an SMP */ struct opa_smp *smp = (struct opa_smp *)data;
if (opa_smp_check(ibp, pkey, sc5, qp, slid, smp)) goto drop;
if (tlen > 2048) goto drop; if ((dlid_is_permissive || slid_is_permissive) &&
smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) goto drop;
/* look up SMI pkey */
mgmt_pkey_idx = hfi1_lookup_pkey_idx(ibp, pkey); if (mgmt_pkey_idx < 0) goto drop;
}
/* * A GRH is expected to precede the data even if not * present on the wire.
*/
wc.byte_len = tlen + sizeof(struct ib_grh);
/* * Get the next work request entry to find where to put the data.
*/ if (qp->r_flags & RVT_R_REUSE_SGE) {
qp->r_flags &= ~RVT_R_REUSE_SGE;
} else { int ret;
ret = rvt_get_rwqe(qp, false); if (ret < 0) {
rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR); return;
} if (!ret) { if (qp->ibqp.qp_num == 0)
ibp->rvp.n_vl15_dropped++; return;
}
} /* Silently drop packets which are too big. */ if (unlikely(wc.byte_len > qp->r_len)) {
qp->r_flags |= RVT_R_REUSE_SGE; goto drop;
} if (packet->grh) {
rvt_copy_sge(qp, &qp->r_sge, packet->grh, sizeof(struct ib_grh), true, false);
wc.wc_flags |= IB_WC_GRH;
} elseif (packet->etype == RHF_RCV_TYPE_BYPASS) { struct ib_grh grh; /* * Assuming we only created 16B on the send side * if we want to use large LIDs, since GRH was stripped * out when creating 16B, add back the GRH here.
*/
hfi1_make_ext_grh(packet, &grh, slid, dlid);
rvt_copy_sge(qp, &qp->r_sge, &grh, sizeof(struct ib_grh), true, false);
wc.wc_flags |= IB_WC_GRH;
} else {
rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
}
rvt_copy_sge(qp, &qp->r_sge, data, wc.byte_len - sizeof(struct ib_grh), true, false);
rvt_put_ss(&qp->r_sge); if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags)) return;
wc.wr_id = qp->r_wr_id;
wc.status = IB_WC_SUCCESS;
wc.opcode = IB_WC_RECV;
wc.vendor_err = 0;
wc.qp = &qp->ibqp;
wc.src_qp = src_qp;
if (qp->ibqp.qp_type == IB_QPT_GSI ||
qp->ibqp.qp_type == IB_QPT_SMI) { if (mgmt_pkey_idx < 0) { if (net_ratelimit()) { struct hfi1_devdata *dd = ppd->dd;
dd_dev_err(dd, "QP type %d mgmt_pkey_idx < 0 and packet not dropped???\n",
qp->ibqp.qp_type);
mgmt_pkey_idx = 0;
}
}
wc.pkey_index = (unsigned)mgmt_pkey_idx;
} else {
wc.pkey_index = 0;
} if (slid_is_permissive)
slid = be32_to_cpu(OPA_LID_PERMISSIVE);
wc.slid = slid & U16_MAX;
wc.sl = sl_from_sc;
/* * Save the LMC lower bits if the destination LID is a unicast LID.
*/
wc.dlid_path_bits = hfi1_check_mcast(dlid) ? 0 :
dlid & ((1 << ppd_from_ibp(ibp)->lmc) - 1);
wc.port_num = qp->port_num; /* Signal completion event if the solicited bit is set. */
rvt_recv_cq(qp, &wc, solicited); return;
drop:
ibp->rvp.n_pkt_drops++;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.