Commit 71e68e3d authored by Jakub Pawlak's avatar Jakub Pawlak Committed by Doug Ledford

IB/hfi1: Correct receive packet handler assignment

Prevent processing receive packet in case when opcode is
accepted by QP but handler for this type of packet is not
defined.
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarJakub Pawlak <jakub.pawlak@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 14833b8c
...@@ -540,19 +540,15 @@ void hfi1_skip_sge(struct rvt_sge_state *ss, u32 length, int release) ...@@ -540,19 +540,15 @@ void hfi1_skip_sge(struct rvt_sge_state *ss, u32 length, int release)
/* /*
* Make sure the QP is ready and able to accept the given opcode. * Make sure the QP is ready and able to accept the given opcode.
*/ */
static inline int qp_ok(int opcode, struct hfi1_packet *packet) static inline opcode_handler qp_ok(int opcode, struct hfi1_packet *packet)
{ {
struct hfi1_ibport *ibp;
if (!(ib_rvt_state_ops[packet->qp->state] & RVT_PROCESS_RECV_OK)) if (!(ib_rvt_state_ops[packet->qp->state] & RVT_PROCESS_RECV_OK))
goto dropit; return NULL;
if (((opcode & RVT_OPCODE_QP_MASK) == packet->qp->allowed_ops) || if (((opcode & RVT_OPCODE_QP_MASK) == packet->qp->allowed_ops) ||
(opcode == IB_OPCODE_CNP)) (opcode == IB_OPCODE_CNP))
return 1; return opcode_handler_tbl[opcode];
dropit:
ibp = &packet->rcd->ppd->ibport_data; return NULL;
ibp->rvp.n_pkt_drops++;
return 0;
} }
/** /**
...@@ -571,6 +567,7 @@ void hfi1_ib_rcv(struct hfi1_packet *packet) ...@@ -571,6 +567,7 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)
struct hfi1_pportdata *ppd = rcd->ppd; struct hfi1_pportdata *ppd = rcd->ppd;
struct hfi1_ibport *ibp = &ppd->ibport_data; struct hfi1_ibport *ibp = &ppd->ibport_data;
struct rvt_dev_info *rdi = &ppd->dd->verbs_dev.rdi; struct rvt_dev_info *rdi = &ppd->dd->verbs_dev.rdi;
opcode_handler packet_handler;
unsigned long flags; unsigned long flags;
u32 qp_num; u32 qp_num;
int lnh; int lnh;
...@@ -616,8 +613,11 @@ void hfi1_ib_rcv(struct hfi1_packet *packet) ...@@ -616,8 +613,11 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)
list_for_each_entry_rcu(p, &mcast->qp_list, list) { list_for_each_entry_rcu(p, &mcast->qp_list, list) {
packet->qp = p->qp; packet->qp = p->qp;
spin_lock_irqsave(&packet->qp->r_lock, flags); spin_lock_irqsave(&packet->qp->r_lock, flags);
if (likely((qp_ok(opcode, packet)))) packet_handler = qp_ok(opcode, packet);
opcode_handler_tbl[opcode](packet); if (likely(packet_handler))
packet_handler(packet);
else
ibp->rvp.n_pkt_drops++;
spin_unlock_irqrestore(&packet->qp->r_lock, flags); spin_unlock_irqrestore(&packet->qp->r_lock, flags);
} }
/* /*
...@@ -634,8 +634,11 @@ void hfi1_ib_rcv(struct hfi1_packet *packet) ...@@ -634,8 +634,11 @@ void hfi1_ib_rcv(struct hfi1_packet *packet)
goto drop; goto drop;
} }
spin_lock_irqsave(&packet->qp->r_lock, flags); spin_lock_irqsave(&packet->qp->r_lock, flags);
if (likely((qp_ok(opcode, packet)))) packet_handler = qp_ok(opcode, packet);
opcode_handler_tbl[opcode](packet); if (likely(packet_handler))
packet_handler(packet);
else
ibp->rvp.n_pkt_drops++;
spin_unlock_irqrestore(&packet->qp->r_lock, flags); spin_unlock_irqrestore(&packet->qp->r_lock, flags);
rcu_read_unlock(); rcu_read_unlock();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment