OSDN Git Service

IB/ehca: Discard double CQE for one WR
authorAlexander Schmidt <alexs@linux.vnet.ibm.com>
Tue, 12 Aug 2008 13:46:30 +0000 (15:46 +0200)
committerRoland Dreier <rolandd@cisco.com>
Tue, 12 Aug 2008 18:34:59 +0000 (11:34 -0700)
commit6773f079b72ab0200fe9afa9bb0c656a6af5400c
tree92b3b86492965367f62c37a84414b892d50504cf
parent129a10fb81309f455eeb444560ec38657d29c46f
IB/ehca: Discard double CQE for one WR

Under rare circumstances, the ehca hardware might erroneously generate
two CQEs for the same WQE, which is not compliant to the IB spec and
will cause unpredictable errors like memory being freed twice. To
avoid this problem, the driver needs to detect the second CQE and
discard it.

For this purpose, introduce an array holding as many elements as the
SQ of the QP, called sq_map. Each sq_map entry stores a "reported"
flag for one WQE in the SQ. When a work request is posted to the SQ,
the respective "reported" flag is set to zero. After the arrival of a
CQE, the flag is set to 1, which allows to detect the occurence of a
second CQE.

The mapping between WQE / CQE and the corresponding sq_map element is
implemented by replacing the lowest 16 Bits of the wr_id with the
index in the queue map. The original 16 Bits are stored in the sq_map
entry and are restored when the CQE is passed to the application.

Signed-off-by: Alexander Schmidt <alexs@linux.vnet.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ehca/ehca_classes.h
drivers/infiniband/hw/ehca/ehca_qes.h
drivers/infiniband/hw/ehca/ehca_qp.c
drivers/infiniband/hw/ehca/ehca_reqs.c