From patchwork Thu Jan 31 13:08:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10790511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F6FD13B4 for ; Thu, 31 Jan 2019 13:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3150D30B91 for ; Thu, 31 Jan 2019 13:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2280C30BC1; Thu, 31 Jan 2019 13:18:34 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9458230B91 for ; Thu, 31 Jan 2019 13:18:33 +0000 (UTC) Received: from localhost ([127.0.0.1]:54657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpCEi-0006bp-Dj for patchwork-qemu-devel@patchwork.kernel.org; Thu, 31 Jan 2019 08:18:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpC5o-0007Iy-2i for qemu-devel@nongnu.org; Thu, 31 Jan 2019 08:09:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpC5m-0000Lz-VH for qemu-devel@nongnu.org; Thu, 31 Jan 2019 08:09:20 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpC5m-0000Lf-MG for qemu-devel@nongnu.org; Thu, 31 Jan 2019 08:09:18 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0VD4LYk128567; Thu, 31 Jan 2019 13:09:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=9vRoJetCPpzksGL6EaIFT9gG9n5wNYgUd0Pv1UWrYLw=; b=SRq4lzAFbyfZrl8SYmX0Bg4Nn9tHqgmpjDJgydTfUugzrnuIGpk/3obKqmnVygQxBm/Z NXa3iFO16RYeKa/K0SnWDQNqRYZxkr/FQWPixVB644i8LAJZUzyjsg5zLRJCi/g2mZSQ WpdQRNJ/8cREoEyIezXjVgRc/PL9BpJEROEBWMfagN/zZDw4y9XV/ymJzCr4DpsZ9xzJ ykSiydsw4MBxkZ95GHyJLdlL14v/lb9l7wF3F/qX5eU+LMASoQMrG7EWbNhEAQUNwWvR 6F9b/x/iaTZ7wpFnUKfbvZc+X2Z5re5zUhLYYPb0/fzAuJfbv0/V2PRKN5GW833wBphW Og== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2q8g6rghh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Jan 2019 13:09:16 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0VD9Bwf032228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Jan 2019 13:09:11 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0VD9Bqo027622; Thu, 31 Jan 2019 13:09:11 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 31 Jan 2019 05:09:10 -0800 From: Yuval Shaia To: dgilbert@redhat.com, yuval.shaia@oracle.com, marcel.apfelbaum@gmail.com, armbru@redhat.com, qemu-devel@nongnu.org Date: Thu, 31 Jan 2019 15:08:46 +0200 Message-Id: <20190131130850.6850-7-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190131130850.6850-1-yuval.shaia@oracle.com> References: <20190131130850.6850-1-yuval.shaia@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9152 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901310103 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH 06/10] hw/pvrdma: Dump device statistics counters to file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Yuval Shaia --- hw/rdma/vmw/pvrdma.h | 1 + hw/rdma/vmw/pvrdma_main.c | 72 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h index 167706ec2c..dc10f21ca0 100644 --- a/hw/rdma/vmw/pvrdma.h +++ b/hw/rdma/vmw/pvrdma.h @@ -133,5 +133,6 @@ static inline void post_interrupt(PVRDMADev *dev, unsigned vector) } int pvrdma_exec_cmd(PVRDMADev *dev); +void pvrdma_dump_statistics(FILE *f, fprintf_function fprintf_func); #endif diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index cf82e78f08..79900076ec 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -14,6 +14,7 @@ */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "hw/hw.h" #include "hw/pci/pci.h" @@ -36,6 +37,8 @@ #include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" #include "pvrdma_qp_ops.h" +GSList *devices; + static Property pvrdma_dev_properties[] = { DEFINE_PROP_STRING("netdev", PVRDMADev, backend_eth_device_name), DEFINE_PROP_STRING("ibdev", PVRDMADev, backend_device_name), @@ -55,6 +58,72 @@ static Property pvrdma_dev_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void pvrdma_dump_device_statistics(gpointer data, gpointer user_data) +{ + CPUListState *s = user_data; + PCIDevice *pdev = data; + PVRDMADev *dev = PVRDMA_DEV(pdev); + + (*s->cpu_fprintf)(s->file, "%s_%x.%x\n", pdev->name, + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); + (*s->cpu_fprintf)(s->file, "\tcommands : %" PRId64 "\n", + dev->stats.commands); + (*s->cpu_fprintf)(s->file, "\ttx : %" PRId64 "\n", + dev->rdma_dev_res.stats.tx); + (*s->cpu_fprintf)(s->file, "\ttx_len : %" PRId64 "\n", + dev->rdma_dev_res.stats.tx_len); + (*s->cpu_fprintf)(s->file, "\ttx_err : %" PRId64 "\n", + dev->rdma_dev_res.stats.tx_err); + (*s->cpu_fprintf)(s->file, "\trx_bufs : %" PRId64 "\n", + dev->rdma_dev_res.stats.rx_bufs); + (*s->cpu_fprintf)(s->file, "\trx_bufs_len : %" PRId64 "\n", + dev->rdma_dev_res.stats.rx_bufs_len); + (*s->cpu_fprintf)(s->file, "\trx_bufs_err : %" PRId64 "\n", + dev->rdma_dev_res.stats.rx_bufs_err); + (*s->cpu_fprintf)(s->file, "\tcompletions : %" PRId64 "\n", + dev->rdma_dev_res.stats.completions); + (*s->cpu_fprintf)(s->file, "\tpoll_cq (bk) : %" PRId64 "\n", + dev->rdma_dev_res.stats.poll_cq_from_bk); + (*s->cpu_fprintf)(s->file, "\tpoll_cq_ppoll_to : %" PRId64 "\n", + dev->rdma_dev_res.stats.poll_cq_ppoll_to); + (*s->cpu_fprintf)(s->file, "\tpoll_cq (fe) : %" PRId64 "\n", + dev->rdma_dev_res.stats.poll_cq_from_guest); + (*s->cpu_fprintf)(s->file, "\tmad_tx : %" PRId64 "\n", + dev->rdma_dev_res.stats.mad_tx); + (*s->cpu_fprintf)(s->file, "\tmad_tx_err : %" PRId64 "\n", + dev->rdma_dev_res.stats.mad_tx_err); + (*s->cpu_fprintf)(s->file, "\tmad_rx : %" PRId64 "\n", + dev->rdma_dev_res.stats.mad_rx); + (*s->cpu_fprintf)(s->file, "\tmad_rx_err : %" PRId64 "\n", + dev->rdma_dev_res.stats.mad_rx_err); + (*s->cpu_fprintf)(s->file, "\tmad_rx_bufs : %" PRId64 "\n", + dev->rdma_dev_res.stats.mad_rx_bufs); + (*s->cpu_fprintf)(s->file, "\tmad_rx_bufs_err : %" PRId64 "\n", + dev->rdma_dev_res.stats.mad_rx_bufs_err); + (*s->cpu_fprintf)(s->file, "\tPDs : %" PRId32 "\n", + dev->rdma_dev_res.pd_tbl.used); + (*s->cpu_fprintf)(s->file, "\tMRs : %" PRId32 "\n", + dev->rdma_dev_res.mr_tbl.used); + (*s->cpu_fprintf)(s->file, "\tUCs : %" PRId32 "\n", + dev->rdma_dev_res.uc_tbl.used); + (*s->cpu_fprintf)(s->file, "\tQPs : %" PRId32 "\n", + dev->rdma_dev_res.qp_tbl.used); + (*s->cpu_fprintf)(s->file, "\tCQs : %" PRId32 "\n", + dev->rdma_dev_res.cq_tbl.used); + (*s->cpu_fprintf)(s->file, "\tCEQ_CTXs : %" PRId32 "\n", + dev->rdma_dev_res.cqe_ctx_tbl.used); +} + +void pvrdma_dump_statistics(FILE *f, fprintf_function fprintf_func) +{ + CPUListState s = { + .file = f, + .cpu_fprintf = fprintf_func, + }; + + g_slist_foreach(devices, pvrdma_dump_device_statistics, &s); +} + static void free_dev_ring(PCIDevice *pci_dev, PvrdmaRing *ring, void *ring_state) { @@ -618,6 +687,8 @@ static void pvrdma_realize(PCIDevice *pdev, Error **errp) dev->shutdown_notifier.notify = pvrdma_shutdown_notifier; qemu_register_shutdown_notifier(&dev->shutdown_notifier); + devices = g_slist_append(devices, pdev); + out: if (rc) { pvrdma_fini(pdev); @@ -627,6 +698,7 @@ out: static void pvrdma_exit(PCIDevice *pdev) { + devices = g_slist_remove(devices, pdev); pvrdma_fini(pdev); }