Beispiel #1
0
/*
 *
 * This should be called with the QP r_lock held.
 *
 * The s_lock will be acquired around the qib_migrate_qp() call.
 */
int qib_ruc_check_hdr(struct qib_ibport *ibp, struct ib_header *hdr,
		      int has_grh, struct rvt_qp *qp, u32 bth0)
{
	__be64 guid;
	unsigned long flags;

	if (qp->s_mig_state == IB_MIG_ARMED && (bth0 & IB_BTH_MIG_REQ)) {
		if (!has_grh) {
			if (rdma_ah_get_ah_flags(&qp->alt_ah_attr) &
			    IB_AH_GRH)
				goto err;
		} else {
			const struct ib_global_route *grh;

			if (!(rdma_ah_get_ah_flags(&qp->alt_ah_attr) &
			      IB_AH_GRH))
				goto err;
			grh = rdma_ah_read_grh(&qp->alt_ah_attr);
			guid = get_sguid(ibp, grh->sgid_index);
			if (!gid_ok(&hdr->u.l.grh.dgid,
				    ibp->rvp.gid_prefix, guid))
				goto err;
			if (!gid_ok(&hdr->u.l.grh.sgid,
			    grh->dgid.global.subnet_prefix,
			    grh->dgid.global.interface_id))
				goto err;
		}
		if (!qib_pkey_ok((u16)bth0,
				 qib_get_pkey(ibp, qp->s_alt_pkey_index))) {
			qib_bad_pkey(ibp,
				     (u16)bth0,
				     (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
				     0, qp->ibqp.qp_num,
				     hdr->lrh[3], hdr->lrh[1]);
			goto err;
		}
		/* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */
		if ((be16_to_cpu(hdr->lrh[3]) !=
		     rdma_ah_get_dlid(&qp->alt_ah_attr)) ||
		    ppd_from_ibp(ibp)->port !=
			    rdma_ah_get_port_num(&qp->alt_ah_attr))
			goto err;
		spin_lock_irqsave(&qp->s_lock, flags);
		qib_migrate_qp(qp);
		spin_unlock_irqrestore(&qp->s_lock, flags);
	} else {
Beispiel #2
0
/*
 *
 * This should be called with the QP r_lock held.
 *
 * The s_lock will be acquired around the qib_migrate_qp() call.
 */
int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr,
                      int has_grh, struct qib_qp *qp, u32 bth0)
{
    __be64 guid;
    unsigned long flags;

    if (qp->s_mig_state == IB_MIG_ARMED && (bth0 & IB_BTH_MIG_REQ)) {
        if (!has_grh) {
            if (qp->alt_ah_attr.ah_flags & IB_AH_GRH)
                goto err;
        } else {
            if (!(qp->alt_ah_attr.ah_flags & IB_AH_GRH))
                goto err;
            guid = get_sguid(ibp, qp->alt_ah_attr.grh.sgid_index);
            if (!gid_ok(&hdr->u.l.grh.dgid, ibp->gid_prefix, guid))
                goto err;
            if (!gid_ok(&hdr->u.l.grh.sgid,
                        qp->alt_ah_attr.grh.dgid.global.subnet_prefix,
                        qp->alt_ah_attr.grh.dgid.global.interface_id))
                goto err;
        }
        if (!qib_pkey_ok((u16)bth0,
                         qib_get_pkey(ibp, qp->s_alt_pkey_index))) {
            qib_bad_pqkey(ibp, IB_NOTICE_TRAP_BAD_PKEY,
                          (u16)bth0,
                          (be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF,
                          0, qp->ibqp.qp_num,
                          hdr->lrh[3], hdr->lrh[1]);
            goto err;
        }
        /* Validate the SLID. See Ch. 9.6.1.5 and 17.2.8 */
        if (be16_to_cpu(hdr->lrh[3]) != qp->alt_ah_attr.dlid ||
                ppd_from_ibp(ibp)->port != qp->alt_ah_attr.port_num)
            goto err;
        spin_lock_irqsave(&qp->s_lock, flags);
        qib_migrate_qp(qp);
        spin_unlock_irqrestore(&qp->s_lock, flags);
    } else {