• Max Gurtovoy's avatar
    IB/core: add support for draining Shared receive queues · 844bc12e
    Max Gurtovoy authored
    To avoid leakage for QPs assocoated with SRQ, according to IB spec
    (section 10.3.1):
    
    "Note, for QPs that are associated with an SRQ, the Consumer should take
    the QP through the Error State before invoking a Destroy QP or a Modify
    QP to the Reset State. The Consumer may invoke the Destroy QP without
    first performing a Modify QP to the Error State and waiting for the Affiliated
    Asynchronous Last WQE Reached Event. However, if the Consumer
    does not wait for the Affiliated Asynchronous Last WQE Reached Event,
    then WQE and Data Segment leakage may occur. Therefore, it is good
    programming practice to teardown a QP that is associated with an SRQ
    by using the following process:
     - Put the QP in the Error State;
     - wait for the Affiliated Asynchronous Last WQE Reached Event;
     - either:
       - drain the CQ by invoking the Poll CQ verb and either wait for CQ
         to be empty or the number of Poll CQ operations has exceeded
         CQ capacity size; or
       - post another WR that completes on the same CQ and wait for this
         WR to return as a WC;
     - and then invoke a Destroy QP or Reset QP."
    
    Catch the Last WQE Reached Event in the core layer during drain QP flow.
    Signed-off-by: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
    Link: https://lore.kernel.org/r/20240619171153.34631-2-mgurtovoy@nvidia.comReviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
    Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
    Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
    844bc12e
ib_verbs.h 142 KB