提交 896ce45d 编写于 作者: M Mike Marciniszyn 提交者: Doug Ledford

IB/hfi1: Correct issues with sc5 computation

There are several computatations of the sc in the
ud receive routine.

Besides the code duplication, all are wrong when the
sc is greater than 15.   In that case the code incorrectly
or's a 1 into the computed sc instead of 1 shifted left
by 4.

Fix precomputed sc5 by using an already implemented routine
hdr2sc() and deleting flawed duplicated code.

Cc: Stable <stable@vger.kernel.org> # 4.6+
Reviewed-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 9903fd13
...@@ -678,8 +678,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -678,8 +678,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
u32 tlen = packet->tlen; u32 tlen = packet->tlen;
struct rvt_qp *qp = packet->qp; struct rvt_qp *qp = packet->qp;
bool has_grh = rcv_flags & HFI1_HAS_GRH; bool has_grh = rcv_flags & HFI1_HAS_GRH;
bool sc4_bit = has_sc4_bit(packet); u8 sc5 = hdr2sc((struct hfi1_message_header *)hdr, packet->rhf);
u8 sc;
u32 bth1; u32 bth1;
int is_mcast; int is_mcast;
struct ib_grh *grh = NULL; struct ib_grh *grh = NULL;
...@@ -697,10 +696,8 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -697,10 +696,8 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
*/ */
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp); struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
u32 lqpn = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK; u32 lqpn = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
u8 sl, sc5; u8 sl;
sc5 = (be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf;
sc5 |= sc4_bit;
sl = ibp->sc_to_sl[sc5]; sl = ibp->sc_to_sl[sc5];
process_becn(ppd, sl, 0, lqpn, 0, IB_CC_SVCTYPE_UD); process_becn(ppd, sl, 0, lqpn, 0, IB_CC_SVCTYPE_UD);
...@@ -717,10 +714,6 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -717,10 +714,6 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
if (!is_mcast && (opcode != IB_OPCODE_CNP) && bth1 & HFI1_FECN_SMASK) { if (!is_mcast && (opcode != IB_OPCODE_CNP) && bth1 & HFI1_FECN_SMASK) {
u16 slid = be16_to_cpu(hdr->lrh[3]); u16 slid = be16_to_cpu(hdr->lrh[3]);
u8 sc5;
sc5 = (be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf;
sc5 |= sc4_bit;
return_cnp(ibp, qp, src_qp, pkey, dlid, slid, sc5, grh); return_cnp(ibp, qp, src_qp, pkey, dlid, slid, sc5, grh);
} }
...@@ -745,10 +738,6 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -745,10 +738,6 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
if (qp->ibqp.qp_num > 1) { if (qp->ibqp.qp_num > 1) {
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp); struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
u16 slid; u16 slid;
u8 sc5;
sc5 = (be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf;
sc5 |= sc4_bit;
slid = be16_to_cpu(hdr->lrh[3]); slid = be16_to_cpu(hdr->lrh[3]);
if (unlikely(rcv_pkey_check(ppd, pkey, sc5, slid))) { if (unlikely(rcv_pkey_check(ppd, pkey, sc5, slid))) {
...@@ -790,10 +779,6 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -790,10 +779,6 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
/* Received on QP0, and so by definition, this is an SMP */ /* Received on QP0, and so by definition, this is an SMP */
struct opa_smp *smp = (struct opa_smp *)data; struct opa_smp *smp = (struct opa_smp *)data;
u16 slid = be16_to_cpu(hdr->lrh[3]); u16 slid = be16_to_cpu(hdr->lrh[3]);
u8 sc5;
sc5 = (be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf;
sc5 |= sc4_bit;
if (opa_smp_check(ibp, pkey, sc5, qp, slid, smp)) if (opa_smp_check(ibp, pkey, sc5, qp, slid, smp))
goto drop; goto drop;
...@@ -890,9 +875,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet) ...@@ -890,9 +875,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
} }
wc.slid = be16_to_cpu(hdr->lrh[3]); wc.slid = be16_to_cpu(hdr->lrh[3]);
sc = (be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf; wc.sl = ibp->sc_to_sl[sc5];
sc |= sc4_bit;
wc.sl = ibp->sc_to_sl[sc];
/* /*
* Save the LMC lower bits if the destination LID is a unicast LID. * Save the LMC lower bits if the destination LID is a unicast LID.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册