From patchwork Sat May 16 07:51:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 6415191 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4DABA9F318 for ; Fri, 15 May 2015 15:26:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 446AD204FB for ; Fri, 15 May 2015 15:26:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2714820522 for ; Fri, 15 May 2015 15:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934740AbbEOP0G (ORCPT ); Fri, 15 May 2015 11:26:06 -0400 Received: from cmrelayp1.emulex.com ([138.239.112.140]:54915 "EHLO CMRELAYP1.ad.emulex.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S934751AbbEOP0F (ORCPT ); Fri, 15 May 2015 11:26:05 -0400 Received: from codebrowse.emulex.com ([10.192.207.129]) by CMRELAYP1.ad.emulex.com with Microsoft SMTPSVC(7.5.7601.17514); Fri, 15 May 2015 08:26:05 -0700 From: Selvin Xavier To: linux-rdma@vger.kernel.org Cc: dledford@redhat.com Subject: [PATCH for-4.1 09/11] RDMA/ocrdma: Add CQ usage statistics counters Date: Sat, 16 May 2015 13:21:47 +0530 Message-Id: <1431762709-20740-10-git-send-email-selvin.xavier@avagotech.com> X-Mailer: git-send-email 2.2.0 In-Reply-To: <1431762709-20740-1-git-send-email-selvin.xavier@avagotech.com> References: <1431762709-20740-1-git-send-email-selvin.xavier@avagotech.com> X-OriginalArrivalTime: 15 May 2015 15:26:05.0383 (UTC) FILETIME=[75A09570:01D08F23] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_12_24, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Meghana Cheripady Add counters for tracking the CQ usage by applications. Signed-off-by: Meghana Cheripady Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/ocrdma/ocrdma.h | 2 ++ drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 8 ++++++++ drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 15 +++++++++++++++ drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 ++ 4 files changed, 27 insertions(+) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h index ee9e335..8782e1f 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma.h +++ b/drivers/infiniband/hw/ocrdma/ocrdma.h @@ -290,6 +290,8 @@ struct ocrdma_dev { struct dentry *dir; atomic_t async_err_stats[OCRDMA_MAX_ASYNC_ERRORS]; atomic_t cqe_err_stats[OCRDMA_MAX_CQE_ERR]; + atomic_t act_cq_stats; + atomic_t th_cq_stats; struct ocrdma_pd_resource_mgr *pd_mgr; }; diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 319675c..596d8c9 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1720,6 +1720,7 @@ int ocrdma_mbx_create_cq(struct ocrdma_dev *dev, struct ocrdma_cq *cq, struct ocrdma_create_cq *cmd; struct ocrdma_create_cq_rsp *rsp; u32 hw_pages, cqe_size, page_size, cqe_count; + int act_cq_cnt, th_cq_cnt; if (entries > dev->attr.max_cqe) { pr_err("%s(%d) max_cqe=0x%x, requester_cqe=0x%x\n", @@ -1808,6 +1809,13 @@ int ocrdma_mbx_create_cq(struct ocrdma_dev *dev, struct ocrdma_cq *cq, rsp = (struct ocrdma_create_cq_rsp *)cmd; cq->id = (u16) (rsp->rsp.cq_id & OCRDMA_CREATE_CQ_RSP_CQ_ID_MASK); + + atomic_inc(&dev->act_cq_stats); + act_cq_cnt = atomic_read(&dev->act_cq_stats); + th_cq_cnt = atomic_read(&dev->th_cq_stats); + if (th_cq_cnt < act_cq_cnt) + atomic_set(&dev->th_cq_stats, act_cq_cnt); + kfree(cmd); return 0; mbx_err: diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c index 48d7ef5..47fef14 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c @@ -146,6 +146,8 @@ static char *ocrdma_resource_stats(struct ocrdma_dev *dev) (u64)rsrc_stats->phy_mr); pcur += ocrdma_add_stat(stats, pcur, "active_mw", (u64)rsrc_stats->mw); + pcur += ocrdma_add_stat(stats, pcur, "active_cq_usage_stats", + (u64)atomic_read(&dev->act_cq_stats)); /* Print the threshold stats */ rsrc_stats = &rdma_stats->th_rsrc_stats; @@ -200,6 +202,8 @@ static char *ocrdma_resource_stats(struct ocrdma_dev *dev) (u64)rsrc_stats->phy_mr); pcur += ocrdma_add_stat(stats, pcur, "threshold_mw", (u64)rsrc_stats->mw); + pcur += ocrdma_add_stat(stats, pcur, "threshold_cq_usage_stats", + (u64)atomic_read(&dev->th_cq_stats)); return stats; } @@ -745,6 +749,16 @@ static const struct file_operations ocrdma_dbg_ops = { .write = ocrdma_dbgfs_ops_write, }; +static void ocrdma_init_cq_stats(struct ocrdma_dev *dev) +{ + int i, cq_cnt = 0; + + for (i = 0; i < dev->eq_cnt; i++) + cq_cnt += dev->eq_tbl[i].cq_cnt; + atomic_set(&dev->act_cq_stats, cq_cnt); + atomic_set(&dev->th_cq_stats, cq_cnt); +} + void ocrdma_add_port_stats(struct ocrdma_dev *dev) { if (!ocrdma_dbgfs_dir) @@ -828,6 +842,7 @@ void ocrdma_add_port_stats(struct ocrdma_dev *dev) goto err; mutex_init(&dev->stats_lock); + ocrdma_init_cq_stats(dev); return; err: diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 9dcb660..48ec56f 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -1119,6 +1119,8 @@ int ocrdma_destroy_cq(struct ib_cq *ibcq) dev->nic_info.db_page_size); } + atomic_dec(&dev->act_cq_stats); + kfree(cq); return 0; }