From patchwork Thu Jun 29 19:28:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 9817851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C94446020A for ; Thu, 29 Jun 2017 19:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBE8F212E8 for ; Thu, 29 Jun 2017 19:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0D7F285E1; Thu, 29 Jun 2017 19:29:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BD61212E8 for ; Thu, 29 Jun 2017 19:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753157AbdF2T3h (ORCPT ); Thu, 29 Jun 2017 15:29:37 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35146 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751776AbdF2T3g (ORCPT ); Thu, 29 Jun 2017 15:29:36 -0400 Received: by mail-wm0-f51.google.com with SMTP id w126so91312002wme.0 for ; Thu, 29 Jun 2017 12:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1YdBkcME8POEuf7NlPulE5ZmgxqMJWCFYcJWKMXhOZs=; b=bDEsy2tZNWJy9cv7sXNcRG9Pa+OmHyBcnEIGzDwlOM5C0M+bjqTRc1j4XAclqwUSdr 4ZLdvtN8aWim8f22VjC1Q01UAB5oegVliR4b8/rI+ijOSWX2ZItdPbXSH2DrL5deyr9q GwMFRLXaA4XPWfpoq4JTHN4dRlZhKgrVCiLYM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1YdBkcME8POEuf7NlPulE5ZmgxqMJWCFYcJWKMXhOZs=; b=J0CHoTk6ghT30p5UnirOtL6bVqtJwT6JhWco4uOF6OZp1IWdxgiL52P1/ub+U37UUC E74d3zF/BFAhNOuQet3NZjoBxYsyTc8QeeLuQmeFUQbb1GJhWJYHVAQPU3QPjxt+10HZ wdJY9LI4GTf+TLGDS234Yd3kWoQtLlttStRdX+WGqmIPJjjhWd2fCBKk7pR4A8ljMjav yZj2jIT0/MRefBCWsxD5YkZPFBP3Yi2bgLRlh9Pn/ge+ImD3kXT1R6clolTi/V7Z47wK yzB+zKQc+dLjSAebfz/VCNMlPafJEmnJ7OcjTqP8dln1CDjYbM1FNbZ2WPWhDNyOPWOa iPUQ== X-Gm-Message-State: AIVw112ymG+roIWglM9xB/EfN3tYRTqpxhMkB0U+eLCqbWE8Dlm4Rocy t2o8Qu6Z1V1VnwHc X-Received: by 10.28.4.145 with SMTP id 139mr3104371wme.19.1498764570301; Thu, 29 Jun 2017 12:29:30 -0700 (PDT) Received: from dhcp-10-192-206-197.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id r40sm6135032wrb.37.2017.06.29.12.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 12:29:29 -0700 (PDT) From: Selvin Xavier To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Selvin Xavier Subject: [PATCH for-next V2 12/13] RDMA/bnxt_re: Report MISSED_EVENTS in req_notify_cq Date: Thu, 29 Jun 2017 12:28:18 -0700 Message-Id: <1498764499-24157-13-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1498764499-24157-1-git-send-email-selvin.xavier@broadcom.com> References: <1498764499-24157-1-git-send-email-selvin.xavier@broadcom.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While invoking the req_notify_cq hook, ULPs can request whether the CQs have any CQEs pending. If CQEs are pending, drivers can indicate it by returning 1 for req_notify_cq. The stack will poll CQ again till CQ is empty. This patch peeks the CQ for any valid entries and return accordingly. Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 +++++ drivers/infiniband/hw/bnxt_re/qplib_fp.c | 19 +++++++++++++++++++ drivers/infiniband/hw/bnxt_re/qplib_fp.h | 1 + 3 files changed, 25 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 27893f7..2cfcd38 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -3034,6 +3034,11 @@ int bnxt_re_req_notify_cq(struct ib_cq *ib_cq, else if (ib_cqn_flags & IB_CQ_SOLICITED) type = DBR_DBR_TYPE_CQ_ARMSE; + /* Poll to see if there are missed events */ + if ((ib_cqn_flags & IB_CQ_REPORT_MISSED_EVENTS) && + !(bnxt_qplib_is_cq_empty(&cq->qplib_cq))) + return 1; + bnxt_qplib_req_notify_cq(&cq->qplib_cq, type); return 0; diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index bd95539..31e15f3 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c @@ -2164,6 +2164,25 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, return rc; } +bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq) +{ + struct cq_base *hw_cqe, **hw_cqe_ptr; + unsigned long flags; + u32 sw_cons, raw_cons; + bool rc = true; + + spin_lock_irqsave(&cq->hwq.lock, flags); + raw_cons = cq->hwq.cons; + sw_cons = HWQ_CMP(raw_cons, &cq->hwq); + hw_cqe_ptr = (struct cq_base **)cq->hwq.pbl_ptr; + hw_cqe = &hw_cqe_ptr[CQE_PG(sw_cons)][CQE_IDX(sw_cons)]; + + /* Check for Valid bit. If the CQE is valid, return false */ + rc = !CQE_CMP_VALID(hw_cqe, raw_cons, cq->hwq.max_elements); + spin_unlock_irqrestore(&cq->hwq.lock, flags); + return rc; +} + static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, struct cq_res_raweth_qp1 *hwcqe, struct bnxt_qplib_cqe **pcqe, diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.h b/drivers/infiniband/hw/bnxt_re/qplib_fp.h index 2495b33..23a26d5 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.h @@ -463,6 +463,7 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq); int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq); int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe, int num, struct bnxt_qplib_qp **qp); +bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq); void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type); void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq); int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq);