^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright(c) 2015 - 2019 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This file is provided under a dual BSD/GPLv2 license. When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * GPL LICENSE SUMMARY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of version 2 of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * BSD LICENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * - Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * - Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * - Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include <rdma/ib_smi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include "hfi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #include "mad.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include "verbs_txreq.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #include "trace_ibhdrs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include "qp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* We support only two types - 9B and 16B for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static const hfi1_make_req hfi1_make_ud_req_tbl[2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) [HFI1_PKT_TYPE_9B] = &hfi1_make_ud_req_9B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) [HFI1_PKT_TYPE_16B] = &hfi1_make_ud_req_16B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * ud_loopback - handle send on loopback QPs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @sqp: the sending QP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @swqe: the send work request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * This is called from hfi1_make_ud_req() to forward a WQE addressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * to the same HFI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * Note that the receive interrupt handler may be calling hfi1_ud_rcv()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * while this is being called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct hfi1_ibport *ibp = to_iport(sqp->ibqp.device, sqp->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct hfi1_pportdata *ppd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct hfi1_qp_priv *priv = sqp->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct rvt_qp *qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct rdma_ah_attr *ah_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct rvt_sge_state ssge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct rvt_sge *sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct ib_wc wc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) enum ib_qp_type sqptype, dqptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) qp = rvt_lookup_qpn(ib_to_rvt(sqp->ibqp.device), &ibp->rvp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) rvt_get_swqe_remote_qpn(swqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (!qp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ibp->rvp.n_pkt_drops++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) sqptype = sqp->ibqp.qp_type == IB_QPT_GSI ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) IB_QPT_UD : sqp->ibqp.qp_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) dqptype = qp->ibqp.qp_type == IB_QPT_GSI ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) IB_QPT_UD : qp->ibqp.qp_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (dqptype != sqptype ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) !(ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) ibp->rvp.n_pkt_drops++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ah_attr = rvt_get_swqe_ah_attr(swqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (qp->ibqp.qp_num > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u16 pkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) u32 slid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) u8 sc5 = ibp->sl_to_sc[rdma_ah_get_sl(ah_attr)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) pkey = hfi1_get_pkey(ibp, sqp->s_pkey_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) slid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) ((1 << ppd->lmc) - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (unlikely(ingress_pkey_check(ppd, pkey, sc5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) qp->s_pkey_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) slid, false))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) hfi1_bad_pkey(ibp, pkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) rdma_ah_get_sl(ah_attr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) sqp->ibqp.qp_num, qp->ibqp.qp_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) slid, rdma_ah_get_dlid(ah_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * Check that the qkey matches (except for QP0, see 9.6.1.4.1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * Qkeys with the high order bit set mean use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * qkey from the QP context instead of the WR (see 10.2.5).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (qp->ibqp.qp_num) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u32 qkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) qkey = (int)rvt_get_swqe_remote_qkey(swqe) < 0 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) sqp->qkey : rvt_get_swqe_remote_qkey(swqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (unlikely(qkey != qp->qkey))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) goto drop; /* silently drop per IBTA spec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * A GRH is expected to precede the data even if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * present on the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) length = swqe->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) memset(&wc, 0, sizeof(wc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) wc.byte_len = length + sizeof(struct ib_grh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) wc.wc_flags = IB_WC_WITH_IMM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) wc.ex.imm_data = swqe->wr.ex.imm_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) spin_lock_irqsave(&qp->r_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * Get the next work request entry to find where to put the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (qp->r_flags & RVT_R_REUSE_SGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) qp->r_flags &= ~RVT_R_REUSE_SGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) ret = rvt_get_rwqe(qp, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (qp->ibqp.qp_num == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ibp->rvp.n_vl15_dropped++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* Silently drop packets which are too big. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (unlikely(wc.byte_len > qp->r_len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) qp->r_flags |= RVT_R_REUSE_SGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) ibp->rvp.n_pkt_drops++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct ib_grh grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct ib_global_route grd = *(rdma_ah_read_grh(ah_attr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * For loopback packets with extended LIDs, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * sgid_index in the GRH is 0 and the dgid is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * OPA GID of the sender. While creating a response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * to the loopback packet, IB core creates the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * sgid_index from the DGID and that will be the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * OPA_GID_INDEX. The new dgid is from the sgid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * index and that will be in the IB GID format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * We now have a case where the sent packet had a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * different sgid_index and dgid compared to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * one that was received in response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * Fix this inconsistency.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (priv->hdr_type == HFI1_PKT_TYPE_16B) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (grd.sgid_index == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) grd.sgid_index = OPA_GID_INDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (ib_is_opa_gid(&grd.dgid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) grd.dgid.global.interface_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) cpu_to_be64(ppd->guids[HFI1_PORT_GUID_INDEX]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) hfi1_make_grh(ibp, &grh, &grd, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) rvt_copy_sge(qp, &qp->r_sge, &grh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) sizeof(grh), true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) wc.wc_flags |= IB_WC_GRH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ssge.sg_list = swqe->sg_list + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ssge.sge = *swqe->sg_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) ssge.num_sge = swqe->wr.num_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) sge = &ssge.sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) while (length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) u32 len = rvt_get_sge_length(sge, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) WARN_ON_ONCE(len == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) rvt_copy_sge(qp, &qp->r_sge, sge->vaddr, len, true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) rvt_update_sge(&ssge, len, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) length -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) rvt_put_ss(&qp->r_sge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) goto bail_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) wc.wr_id = qp->r_wr_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) wc.status = IB_WC_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) wc.opcode = IB_WC_RECV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) wc.qp = &qp->ibqp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) wc.src_qp = sqp->ibqp.qp_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (sqp->ibqp.qp_type == IB_QPT_GSI ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) sqp->ibqp.qp_type == IB_QPT_SMI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) wc.pkey_index = rvt_get_swqe_pkey_index(swqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) wc.pkey_index = sqp->s_pkey_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) wc.pkey_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) wc.slid = (ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) ((1 << ppd->lmc) - 1))) & U16_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /* Check for loopback when the port lid is not set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (wc.slid == 0 && sqp->ibqp.qp_type == IB_QPT_GSI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) wc.slid = be16_to_cpu(IB_LID_PERMISSIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) wc.sl = rdma_ah_get_sl(ah_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) wc.dlid_path_bits = rdma_ah_get_dlid(ah_attr) & ((1 << ppd->lmc) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) wc.port_num = qp->port_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /* Signal completion event if the solicited bit is set. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) rvt_recv_cq(qp, &wc, swqe->wr.send_flags & IB_SEND_SOLICITED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) ibp->rvp.n_loop_pkts++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) bail_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) spin_unlock_irqrestore(&qp->r_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) drop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static void hfi1_make_bth_deth(struct rvt_qp *qp, struct rvt_swqe *wqe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct ib_other_headers *ohdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) u16 *pkey, u32 extra_bytes, bool bypass)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) u32 bth0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct hfi1_ibport *ibp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) ibp = to_iport(qp->ibqp.device, qp->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (wqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ohdr->u.ud.imm_data = wqe->wr.ex.imm_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) bth0 = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE << 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) bth0 = IB_OPCODE_UD_SEND_ONLY << 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) if (wqe->wr.send_flags & IB_SEND_SOLICITED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) bth0 |= IB_BTH_SOLICITED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) bth0 |= extra_bytes << 20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *pkey = hfi1_get_pkey(ibp, qp->s_pkey_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) if (!bypass)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) bth0 |= *pkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) ohdr->bth[0] = cpu_to_be32(bth0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) ohdr->bth[1] = cpu_to_be32(rvt_get_swqe_remote_qpn(wqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ohdr->bth[2] = cpu_to_be32(mask_psn(wqe->psn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * Qkeys with the high order bit set mean use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * qkey from the QP context instead of the WR (see 10.2.5).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) ohdr->u.ud.deth[0] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) cpu_to_be32((int)rvt_get_swqe_remote_qkey(wqe) < 0 ? qp->qkey :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) rvt_get_swqe_remote_qkey(wqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) void hfi1_make_ud_req_9B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) struct rvt_swqe *wqe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) u32 nwords, extra_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) u16 len, slid, dlid, pkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) u16 lrh0 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) u8 sc5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) struct hfi1_qp_priv *priv = qp->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct ib_other_headers *ohdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) struct rdma_ah_attr *ah_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct hfi1_pportdata *ppd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct hfi1_ibport *ibp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) struct ib_grh *grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) ibp = to_iport(qp->ibqp.device, qp->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) ah_attr = rvt_get_swqe_ah_attr(wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) extra_bytes = -wqe->length & 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) nwords = ((wqe->length + extra_bytes) >> 2) + SIZE_OF_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /* header size in dwords LRH+BTH+DETH = (8+12+8)/4. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) ps->s_txreq->hdr_dwords = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) if (wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) ps->s_txreq->hdr_dwords++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) if (rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) grh = &ps->s_txreq->phdr.hdr.ibh.u.l.grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) ps->s_txreq->hdr_dwords +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) hfi1_make_grh(ibp, grh, rdma_ah_read_grh(ah_attr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ps->s_txreq->hdr_dwords - LRH_9B_DWORDS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) nwords);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) lrh0 = HFI1_LRH_GRH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) ohdr = &ps->s_txreq->phdr.hdr.ibh.u.l.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) lrh0 = HFI1_LRH_BTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) ohdr = &ps->s_txreq->phdr.hdr.ibh.u.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) sc5 = ibp->sl_to_sc[rdma_ah_get_sl(ah_attr)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) lrh0 |= (rdma_ah_get_sl(ah_attr) & 0xf) << 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if (qp->ibqp.qp_type == IB_QPT_SMI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) lrh0 |= 0xF000; /* Set VL (see ch. 13.5.3.1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) priv->s_sc = 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) lrh0 |= (sc5 & 0xf) << 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) priv->s_sc = sc5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) dlid = opa_get_lid(rdma_ah_get_dlid(ah_attr), 9B);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (dlid == be16_to_cpu(IB_LID_PERMISSIVE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) slid = be16_to_cpu(IB_LID_PERMISSIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) u16 lid = (u16)ppd->lid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (lid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) lid |= rdma_ah_get_path_bits(ah_attr) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) ((1 << ppd->lmc) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) slid = lid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) slid = be16_to_cpu(IB_LID_PERMISSIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) hfi1_make_bth_deth(qp, wqe, ohdr, &pkey, extra_bytes, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) len = ps->s_txreq->hdr_dwords + nwords;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* Setup the packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) ps->s_txreq->phdr.hdr.hdr_type = HFI1_PKT_TYPE_9B;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) hfi1_make_ib_hdr(&ps->s_txreq->phdr.hdr.ibh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) lrh0, len, dlid, slid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) struct rvt_swqe *wqe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct hfi1_qp_priv *priv = qp->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) struct ib_other_headers *ohdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct rdma_ah_attr *ah_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct hfi1_pportdata *ppd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct hfi1_ibport *ibp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) u32 dlid, slid, nwords, extra_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) u32 dest_qp = rvt_get_swqe_remote_qpn(wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) u32 src_qp = qp->ibqp.qp_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) u16 len, pkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) u8 l4, sc5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) bool is_mgmt = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) ibp = to_iport(qp->ibqp.device, qp->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) ah_attr = rvt_get_swqe_ah_attr(wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * Build 16B Management Packet if either the destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * or source queue pair number is 0 or 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) if (dest_qp == 0 || src_qp == 0 || dest_qp == 1 || src_qp == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /* header size in dwords 16B LRH+L4_FM = (16+8)/4. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ps->s_txreq->hdr_dwords = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) is_mgmt = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) /* header size in dwords 16B LRH+BTH+DETH = (16+12+8)/4. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ps->s_txreq->hdr_dwords = 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) ps->s_txreq->hdr_dwords++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) /* SW provides space for CRC and LT for bypass packets. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) extra_bytes = hfi1_get_16b_padding((ps->s_txreq->hdr_dwords << 2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) wqe->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) nwords = ((wqe->length + extra_bytes + SIZE_OF_LT) >> 2) + SIZE_OF_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if ((rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) hfi1_check_mcast(rdma_ah_get_dlid(ah_attr))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) struct ib_grh *grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) struct ib_global_route *grd = rdma_ah_retrieve_grh(ah_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * Ensure OPA GIDs are transformed to IB gids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * before creating the GRH.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if (grd->sgid_index == OPA_GID_INDEX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) dd_dev_warn(ppd->dd, "Bad sgid_index. sgid_index: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) grd->sgid_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) grd->sgid_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) grh = &ps->s_txreq->phdr.hdr.opah.u.l.grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) ps->s_txreq->hdr_dwords += hfi1_make_grh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) ibp, grh, grd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) ps->s_txreq->hdr_dwords - LRH_16B_DWORDS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) nwords);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) ohdr = &ps->s_txreq->phdr.hdr.opah.u.l.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) l4 = OPA_16B_L4_IB_GLOBAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) ohdr = &ps->s_txreq->phdr.hdr.opah.u.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) l4 = OPA_16B_L4_IB_LOCAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) sc5 = ibp->sl_to_sc[rdma_ah_get_sl(ah_attr)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) if (qp->ibqp.qp_type == IB_QPT_SMI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) priv->s_sc = 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) priv->s_sc = sc5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) dlid = opa_get_lid(rdma_ah_get_dlid(ah_attr), 16B);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (!ppd->lid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) slid = be32_to_cpu(OPA_LID_PERMISSIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) slid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) ((1 << ppd->lmc) - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) if (is_mgmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) l4 = OPA_16B_L4_FM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) hfi1_16B_set_qpn(&ps->s_txreq->phdr.hdr.opah.u.mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) dest_qp, src_qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) hfi1_make_bth_deth(qp, wqe, ohdr, &pkey, extra_bytes, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) /* Convert dwords to flits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) len = (ps->s_txreq->hdr_dwords + nwords) >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* Setup the packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) ps->s_txreq->phdr.hdr.hdr_type = HFI1_PKT_TYPE_16B;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) hfi1_make_16b_hdr(&ps->s_txreq->phdr.hdr.opah,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) slid, dlid, len, pkey, 0, 0, l4, priv->s_sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * hfi1_make_ud_req - construct a UD request packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * @qp: the QP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * Assume s_lock is held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * Return 1 if constructed; otherwise, return 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) struct hfi1_qp_priv *priv = qp->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) struct rdma_ah_attr *ah_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) struct hfi1_pportdata *ppd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) struct hfi1_ibport *ibp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) struct rvt_swqe *wqe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) int next_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) u32 lid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) ps->s_txreq = get_txreq(ps->dev, qp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (!ps->s_txreq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) goto bail_no_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_NEXT_SEND_OK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) if (!(ib_rvt_state_ops[qp->state] & RVT_FLUSH_SEND))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) /* We are in the error state, flush the work request. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) if (qp->s_last == READ_ONCE(qp->s_head))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) /* If DMAs are in progress, we can't flush immediately. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (iowait_sdma_pending(&priv->s_iowait)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) qp->s_flags |= RVT_S_WAIT_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) wqe = rvt_get_swqe_ptr(qp, qp->s_last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) rvt_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) goto done_free_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) /* see post_one_send() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) if (qp->s_cur == READ_ONCE(qp->s_head))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) wqe = rvt_get_swqe_ptr(qp, qp->s_cur);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) next_cur = qp->s_cur + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) if (next_cur >= qp->s_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) next_cur = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) /* Construct the header. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) ibp = to_iport(qp->ibqp.device, qp->port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) ah_attr = rvt_get_swqe_ah_attr(wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) priv->hdr_type = hfi1_get_hdr_type(ppd->lid, ah_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if ((!hfi1_check_mcast(rdma_ah_get_dlid(ah_attr))) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) (rdma_ah_get_dlid(ah_attr) == be32_to_cpu(OPA_LID_PERMISSIVE))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) lid = rdma_ah_get_dlid(ah_attr) & ~((1 << ppd->lmc) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) if (unlikely(!loopback &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) ((lid == ppd->lid) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) ((lid == be32_to_cpu(OPA_LID_PERMISSIVE)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) (qp->ibqp.qp_type == IB_QPT_GSI))))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) unsigned long tflags = ps->flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * If DMAs are in progress, we can't generate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * a completion for the loopback packet since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * it would be out of order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * Instead of waiting, we could queue a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * zero length descriptor so we get a callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if (iowait_sdma_pending(&priv->s_iowait)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) qp->s_flags |= RVT_S_WAIT_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) qp->s_cur = next_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) spin_unlock_irqrestore(&qp->s_lock, tflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) ud_loopback(qp, wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) spin_lock_irqsave(&qp->s_lock, tflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) ps->flags = tflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) rvt_send_complete(qp, wqe, IB_WC_SUCCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) goto done_free_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) qp->s_cur = next_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) ps->s_txreq->s_cur_size = wqe->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) ps->s_txreq->ss = &qp->s_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) qp->s_srate = rdma_ah_get_static_rate(ah_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) qp->srate_mbps = ib_rate_to_mbps(qp->s_srate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) qp->s_wqe = wqe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) qp->s_sge.sge = wqe->sg_list[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) qp->s_sge.sg_list = wqe->sg_list + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) qp->s_sge.num_sge = wqe->wr.num_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) qp->s_sge.total_len = wqe->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) /* Make the appropriate header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) hfi1_make_ud_req_tbl[priv->hdr_type](qp, ps, qp->s_wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) priv->s_sde = qp_to_sdma_engine(qp, priv->s_sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) ps->s_txreq->sde = priv->s_sde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) priv->s_sendcontext = qp_to_send_context(qp, priv->s_sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) ps->s_txreq->psc = priv->s_sendcontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) /* disarm any ahg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) priv->s_ahg->ahgcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) priv->s_ahg->ahgidx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) priv->s_ahg->tx_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) done_free_tx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) hfi1_put_txreq(ps->s_txreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) ps->s_txreq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) hfi1_put_txreq(ps->s_txreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) bail_no_tx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) ps->s_txreq = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) qp->s_flags &= ~RVT_S_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) * Hardware can't check this so we do it here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) * This is a slightly different algorithm than the standard pkey check. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) * special cases the management keys and allows for 0x7fff and 0xffff to be in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) * the table at the same time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * @returns the index found or -1 if not found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) int hfi1_lookup_pkey_idx(struct hfi1_ibport *ibp, u16 pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) unsigned i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) if (pkey == FULL_MGMT_P_KEY || pkey == LIM_MGMT_P_KEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) unsigned lim_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) for (i = 0; i < ARRAY_SIZE(ppd->pkeys); ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /* here we look for an exact match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) if (ppd->pkeys[i] == pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) if (ppd->pkeys[i] == LIM_MGMT_P_KEY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) lim_idx = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) /* did not find 0xffff return 0x7fff idx if found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) if (pkey == FULL_MGMT_P_KEY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) return lim_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) /* no match... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) pkey &= 0x7fff; /* remove limited/full membership bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) for (i = 0; i < ARRAY_SIZE(ppd->pkeys); ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if ((ppd->pkeys[i] & 0x7fff) == pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * Should not get here, this means hardware failed to validate pkeys.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) void return_cnp_16B(struct hfi1_ibport *ibp, struct rvt_qp *qp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) u32 remote_qpn, u16 pkey, u32 slid, u32 dlid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) u8 sc5, const struct ib_grh *old_grh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) u64 pbc, pbc_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) u32 bth0, plen, vl, hwords = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) u16 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) u8 l4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) struct hfi1_opa_header hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) struct ib_other_headers *ohdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) struct pio_buf *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) struct send_context *ctxt = qp_to_send_context(qp, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) u32 nwords;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) hdr.hdr_type = HFI1_PKT_TYPE_16B;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) /* Populate length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) nwords = ((hfi1_get_16b_padding(hwords << 2, 0) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) SIZE_OF_LT) >> 2) + SIZE_OF_CRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) if (old_grh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) struct ib_grh *grh = &hdr.opah.u.l.grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) grh->version_tclass_flow = old_grh->version_tclass_flow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) grh->paylen = cpu_to_be16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) (hwords - LRH_16B_DWORDS + nwords) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) grh->hop_limit = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) grh->sgid = old_grh->dgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) grh->dgid = old_grh->sgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) ohdr = &hdr.opah.u.l.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) l4 = OPA_16B_L4_IB_GLOBAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) hwords += sizeof(struct ib_grh) / sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) ohdr = &hdr.opah.u.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) l4 = OPA_16B_L4_IB_LOCAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) /* BIT 16 to 19 is TVER. Bit 20 to 22 is pad cnt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) bth0 = (IB_OPCODE_CNP << 24) | (1 << 16) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) (hfi1_get_16b_padding(hwords << 2, 0) << 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) ohdr->bth[0] = cpu_to_be32(bth0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) ohdr->bth[1] = cpu_to_be32(remote_qpn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) ohdr->bth[2] = 0; /* PSN 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) /* Convert dwords to flits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) len = (hwords + nwords) >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) hfi1_make_16b_hdr(&hdr.opah, slid, dlid, len, pkey, 1, 0, l4, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) plen = 2 /* PBC */ + hwords + nwords;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) pbc_flags |= PBC_PACKET_BYPASS | PBC_INSERT_BYPASS_ICRC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) vl = sc_to_vlt(ppd->dd, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) pbc = create_pbc(ppd, pbc_flags, qp->srate_mbps, vl, plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) if (ctxt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) pbuf = sc_buffer_alloc(ctxt, plen, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (!IS_ERR_OR_NULL(pbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) trace_pio_output_ibhdr(ppd->dd, &hdr, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) ppd->dd->pio_inline_send(ppd->dd, pbuf, pbc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) &hdr, hwords);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) u16 pkey, u32 slid, u32 dlid, u8 sc5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) const struct ib_grh *old_grh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) u64 pbc, pbc_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) u32 bth0, plen, vl, hwords = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) u16 lrh0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) u8 sl = ibp->sc_to_sl[sc5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) struct hfi1_opa_header hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) struct ib_other_headers *ohdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) struct pio_buf *pbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) struct send_context *ctxt = qp_to_send_context(qp, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) hdr.hdr_type = HFI1_PKT_TYPE_9B;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) if (old_grh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) struct ib_grh *grh = &hdr.ibh.u.l.grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) grh->version_tclass_flow = old_grh->version_tclass_flow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) grh->paylen = cpu_to_be16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) (hwords - LRH_9B_DWORDS + SIZE_OF_CRC) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) grh->hop_limit = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) grh->sgid = old_grh->dgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) grh->dgid = old_grh->sgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) ohdr = &hdr.ibh.u.l.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) lrh0 = HFI1_LRH_GRH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) hwords += sizeof(struct ib_grh) / sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) ohdr = &hdr.ibh.u.oth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) lrh0 = HFI1_LRH_BTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) lrh0 |= (sc5 & 0xf) << 12 | sl << 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) bth0 = pkey | (IB_OPCODE_CNP << 24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) ohdr->bth[0] = cpu_to_be32(bth0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) ohdr->bth[1] = cpu_to_be32(remote_qpn | (1 << IB_BECN_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) ohdr->bth[2] = 0; /* PSN 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) hfi1_make_ib_hdr(&hdr.ibh, lrh0, hwords + SIZE_OF_CRC, dlid, slid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) plen = 2 /* PBC */ + hwords;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) pbc_flags |= (ib_is_sc5(sc5) << PBC_DC_INFO_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) vl = sc_to_vlt(ppd->dd, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) pbc = create_pbc(ppd, pbc_flags, qp->srate_mbps, vl, plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) if (ctxt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) pbuf = sc_buffer_alloc(ctxt, plen, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) if (!IS_ERR_OR_NULL(pbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) trace_pio_output_ibhdr(ppd->dd, &hdr, sc5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) ppd->dd->pio_inline_send(ppd->dd, pbuf, pbc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) &hdr, hwords);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) * opa_smp_check() - Do the regular pkey checking, and the additional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) * checks for SMPs specified in OPAv1 rev 1.0, 9/19/2016 update, section
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) * 9.10.25 ("SMA Packet Checks").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) * Note that:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) * - Checks are done using the pkey directly from the packet's BTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) * and specifically _not_ the pkey that we attach to the completion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) * which may be different.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) * - These checks are specifically for "non-local" SMPs (i.e., SMPs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) * which originated on another node). SMPs which are sent from, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) * destined to this node are checked in opa_local_smp_check().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) * At the point where opa_smp_check() is called, we know:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) * - destination QP is QP0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) * opa_smp_check() returns 0 if all checks succeed, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) static int opa_smp_check(struct hfi1_ibport *ibp, u16 pkey, u8 sc5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) struct rvt_qp *qp, u16 slid, struct opa_smp *smp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) * I don't think it's possible for us to get here with sc != 0xf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) * but check it to be certain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) if (sc5 != 0xf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) if (rcv_pkey_check(ppd, pkey, sc5, slid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * At this point we know (and so don't need to check again) that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * the pkey is either LIM_MGMT_P_KEY, or FULL_MGMT_P_KEY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) * (see ingress_pkey_check).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) if (smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) smp->mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) ingress_pkey_table_fail(ppd, pkey, slid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) * SMPs fall into one of four (disjoint) categories:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) * SMA request, SMA response, SMA trap, or SMA trap repress.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) * Our response depends, in part, on which type of SMP we're
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) * processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) * If this is an SMA response, skip the check here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) * If this is an SMA request or SMA trap repress:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) * - pkey != FULL_MGMT_P_KEY =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) * increment port recv constraint errors, drop MAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * Otherwise:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) * - accept if the port is running an SM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) * - drop MAD if it's an SMA trap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) * - pkey == FULL_MGMT_P_KEY =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) * reply with unsupported method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) * - pkey != FULL_MGMT_P_KEY =>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) * increment port recv constraint errors, drop MAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) switch (smp->method) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) case IB_MGMT_METHOD_GET_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) case IB_MGMT_METHOD_REPORT_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) case IB_MGMT_METHOD_GET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) case IB_MGMT_METHOD_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) case IB_MGMT_METHOD_REPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) case IB_MGMT_METHOD_TRAP_REPRESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) if (pkey != FULL_MGMT_P_KEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) ingress_pkey_table_fail(ppd, pkey, slid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) if (ibp->rvp.port_cap_flags & IB_PORT_SM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) if (smp->method == IB_MGMT_METHOD_TRAP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) if (pkey == FULL_MGMT_P_KEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) smp->status |= IB_SMP_UNSUP_METHOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) ingress_pkey_table_fail(ppd, pkey, slid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) * hfi1_ud_rcv - receive an incoming UD packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) * @ibp: the port the packet came in on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) * @hdr: the packet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) * @rcv_flags: flags relevant to rcv processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) * @data: the packet data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) * @tlen: the packet length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) * @qp: the QP the packet came on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) * This is called from qp_rcv() to process an incoming UD packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) * for the given QP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) * Called at interrupt level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) void hfi1_ud_rcv(struct hfi1_packet *packet)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) u32 hdrsize = packet->hlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) struct ib_wc wc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) u32 src_qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) u16 pkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) int mgmt_pkey_idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) struct hfi1_ibport *ibp = rcd_to_iport(packet->rcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) void *data = packet->payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) u32 tlen = packet->tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) struct rvt_qp *qp = packet->qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) u8 sc5 = packet->sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) u8 sl_from_sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) u8 opcode = packet->opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) u8 sl = packet->sl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) u32 dlid = packet->dlid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) u32 slid = packet->slid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) u8 extra_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) u8 l4 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) bool dlid_is_permissive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) bool slid_is_permissive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) bool solicited = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) extra_bytes = packet->pad + packet->extra_byte + (SIZE_OF_CRC << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) if (packet->etype == RHF_RCV_TYPE_BYPASS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) u32 permissive_lid =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE), 16B);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) l4 = hfi1_16B_get_l4(packet->hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) pkey = hfi1_16B_get_pkey(packet->hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) dlid_is_permissive = (dlid == permissive_lid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) slid_is_permissive = (slid == permissive_lid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) pkey = ib_bth_get_pkey(packet->ohdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) dlid_is_permissive = (dlid == be16_to_cpu(IB_LID_PERMISSIVE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) slid_is_permissive = (slid == be16_to_cpu(IB_LID_PERMISSIVE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) sl_from_sc = ibp->sc_to_sl[sc5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) if (likely(l4 != OPA_16B_L4_FM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) src_qp = ib_get_sqpn(packet->ohdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) solicited = ib_bth_is_solicited(packet->ohdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) src_qp = hfi1_16B_get_src_qpn(packet->mgmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) process_ecn(qp, packet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) * Get the number of bytes the message was padded by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) * and drop incomplete packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) if (unlikely(tlen < (hdrsize + extra_bytes)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) tlen -= hdrsize + extra_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) * Check that the permissive LID is only used on QP0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) * and the QKEY matches (see 9.6.1.4.1 and 9.6.1.5.1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) if (qp->ibqp.qp_num) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) if (unlikely(dlid_is_permissive || slid_is_permissive))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) if (qp->ibqp.qp_num > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) if (unlikely(rcv_pkey_check(ppd, pkey, sc5, slid))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) * Traps will not be sent for packets dropped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) * by the HW. This is fine, as sending trap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) * for invalid pkeys is optional according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) * IB spec (release 1.3, section 10.9.4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) hfi1_bad_pkey(ibp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) pkey, sl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) src_qp, qp->ibqp.qp_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) slid, dlid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) /* GSI packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) mgmt_pkey_idx = hfi1_lookup_pkey_idx(ibp, pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) if (mgmt_pkey_idx < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) if (unlikely(l4 != OPA_16B_L4_FM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) ib_get_qkey(packet->ohdr) != qp->qkey))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) return; /* Silent drop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) /* Drop invalid MAD packets (see 13.5.3.1). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) if (unlikely(qp->ibqp.qp_num == 1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) (tlen > 2048 || (sc5 == 0xF))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) /* Received on QP0, and so by definition, this is an SMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) struct opa_smp *smp = (struct opa_smp *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) if (opa_smp_check(ibp, pkey, sc5, qp, slid, smp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) if (tlen > 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) if ((dlid_is_permissive || slid_is_permissive) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) /* look up SMI pkey */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) mgmt_pkey_idx = hfi1_lookup_pkey_idx(ibp, pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) if (mgmt_pkey_idx < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) if (qp->ibqp.qp_num > 1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) opcode == IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) wc.ex.imm_data = packet->ohdr->u.ud.imm_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) wc.wc_flags = IB_WC_WITH_IMM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) } else if (opcode == IB_OPCODE_UD_SEND_ONLY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) wc.ex.imm_data = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) wc.wc_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) * A GRH is expected to precede the data even if not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) * present on the wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) wc.byte_len = tlen + sizeof(struct ib_grh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) * Get the next work request entry to find where to put the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) if (qp->r_flags & RVT_R_REUSE_SGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) qp->r_flags &= ~RVT_R_REUSE_SGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) ret = rvt_get_rwqe(qp, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) rvt_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) if (qp->ibqp.qp_num == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) ibp->rvp.n_vl15_dropped++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) /* Silently drop packets which are too big. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) if (unlikely(wc.byte_len > qp->r_len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) qp->r_flags |= RVT_R_REUSE_SGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) goto drop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) if (packet->grh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) rvt_copy_sge(qp, &qp->r_sge, packet->grh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) sizeof(struct ib_grh), true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) wc.wc_flags |= IB_WC_GRH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) } else if (packet->etype == RHF_RCV_TYPE_BYPASS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) struct ib_grh grh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) * Assuming we only created 16B on the send side
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) * if we want to use large LIDs, since GRH was stripped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) * out when creating 16B, add back the GRH here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) hfi1_make_ext_grh(packet, &grh, slid, dlid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) rvt_copy_sge(qp, &qp->r_sge, &grh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) sizeof(struct ib_grh), true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) wc.wc_flags |= IB_WC_GRH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) rvt_skip_sge(&qp->r_sge, sizeof(struct ib_grh), true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) rvt_copy_sge(qp, &qp->r_sge, data, wc.byte_len - sizeof(struct ib_grh),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) true, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) rvt_put_ss(&qp->r_sge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) if (!test_and_clear_bit(RVT_R_WRID_VALID, &qp->r_aflags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) wc.wr_id = qp->r_wr_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) wc.status = IB_WC_SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) wc.opcode = IB_WC_RECV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) wc.vendor_err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) wc.qp = &qp->ibqp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) wc.src_qp = src_qp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) if (qp->ibqp.qp_type == IB_QPT_GSI ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) qp->ibqp.qp_type == IB_QPT_SMI) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) if (mgmt_pkey_idx < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) if (net_ratelimit()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) struct hfi1_devdata *dd = ppd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) dd_dev_err(dd, "QP type %d mgmt_pkey_idx < 0 and packet not dropped???\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) qp->ibqp.qp_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) mgmt_pkey_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) wc.pkey_index = (unsigned)mgmt_pkey_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) wc.pkey_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) if (slid_is_permissive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) slid = be32_to_cpu(OPA_LID_PERMISSIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) wc.slid = slid & U16_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) wc.sl = sl_from_sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) * Save the LMC lower bits if the destination LID is a unicast LID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) wc.dlid_path_bits = hfi1_check_mcast(dlid) ? 0 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) dlid & ((1 << ppd_from_ibp(ibp)->lmc) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) wc.port_num = qp->port_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) /* Signal completion event if the solicited bit is set. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) rvt_recv_cq(qp, &wc, solicited);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) drop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) ibp->rvp.n_pkt_drops++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) }