From patchwork Wed Jul 14 16:56:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 12377461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9964C07E9C for ; Wed, 14 Jul 2021 16:59:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B9CD61360 for ; Wed, 14 Jul 2021 16:59:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B9CD61360 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3iEc-0004bS-Bh for qemu-devel@archiver.kernel.org; Wed, 14 Jul 2021 12:59:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3iC9-0007gX-Ra for qemu-devel@nongnu.org; Wed, 14 Jul 2021 12:57:13 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:21534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3iC7-0003f3-AZ for qemu-devel@nongnu.org; Wed, 14 Jul 2021 12:57:13 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EGtcdt032238; Wed, 14 Jul 2021 16:57:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=imGJZLavO3HM5Ul8UPo2ousBPYxvdod4skLtnsaEUYE=; b=IA2+Ydnc7aDAZuw696DWH/PRXZRCPie3CSCPUDltbnSNGHESuI5OE4xQkwgFstu/0maJ +yRWB2h9UOcHgvcR3RMBGAS1spmgyIa7wectW6xstITGgziaCgpKLFqxWKtVOzlXAKm1 3N6daN+m03U169XJ2XPK3DAL7ixSH0o5a9w+XvZ5eQ0GPjxgJ37sEta4fqZQXfTVzX5+ vo6UUqyaR/o99rqVrrY0XL612kPU9/TXQwaTc1i06tt4GIidfppF9d1SBl9lZlrmgQ4w DK7+rMcgm/NwGZ8/Dc2ureKoDoQhotOi/PHWAh/hhVSowF909iPG1cklW0pC1mWuN89W FQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=imGJZLavO3HM5Ul8UPo2ousBPYxvdod4skLtnsaEUYE=; b=nUB+NneA1mqW+fKjFG1yp3NcbHmc8yVbkiIsfs9GVGCAaA5kK56ZEtxYXMnb7mkfKROx znoxRgy3des+toehpDeJn2PxUlHiLmhD6GSjurN4PSNvJAEuHI37W1WfjC5ydS3UQLgk EGQ/xKQDYY9DZZn8tSQGx/J0sRbECIubIxCAVkm0sNG4/OTYzWEMsbDJir9oSi92Lk4u Rpzth2JEdphUEO7VYu1XI7QVHuZB54NwOAkj2lQOA2yY3tC9np1ec6zhq3kWSIsKcNje wA2H9wyiUwd6qZXf+nSsYlbhXEp4l4wmouPfmRPbzodXBCedDHzM77jbPOI1pDGbmb8O dw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39sbtujx94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:57:08 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16EGovq9168314; Wed, 14 Jul 2021 16:57:07 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by aserp3030.oracle.com with ESMTP id 39qyd12hr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:57:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Enmh8nVwhB+tQ+dB+bpcP0Yjlw6NEqI4XdCyPdG2sD77XbLlibrRgsBqzVD8e1bdBcookDyq9YvAkluVZjHVNe2cEbXs6YaRr/ruNWuLNgV+HQCy15CTuGJgID8yjZfm7mebq8iaB76jWDIC795WydmVpa9LWta4TB8/Hf0FO6kgwGf8sn/d9lRYpQKD1fsKU8aOl6YtcqOGIp9kVw14r3A2F8DYhCUioIhNUQulZ+LzWpvnNm3IGGZAJsbQxwrzh9vOzupGhQV2B7n2qEMvI2eKkm93Y/uoD1CJRwuZsK7sIeuuWILoAtog6llyPgS3BI387PrwkhNAktL+LZR18Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=imGJZLavO3HM5Ul8UPo2ousBPYxvdod4skLtnsaEUYE=; b=aTNjbry4y30EWghOhalY3AQV78AdDj/MzeV1sHST4zcb6/TmJ3BDYXOd+IyxIb/47oDTUyODKbfS7rENJgvjb/2Ur6cHz7i/X9rDjLIvryhHDnc7xwPH5O1RQl8Ixf36a+a/gq2IosgQNWP86g1HKvah/V2GDYkp1Xlqd9Czlaeg5snHaS1ivvtjUXC224um0QXI0OAxNeCgBCPBXafz8+a+XTj9JA6TR1TPHmCw6/VyD7ZezuMF4OOvfTbRowQ+n6I+hlK8LkeSdB+n3bfgGnFKnD5XVcWFRb5Y2HHnW/EPQwWK9NDjvejYKnV7W4ga3GJ+pNi7jw1ZQ0pQZ4R0GA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=imGJZLavO3HM5Ul8UPo2ousBPYxvdod4skLtnsaEUYE=; b=Pf1H/cQ9NAQWxW1e8CeBcDf1L3sqJHGmy21DTOmw8Z5i4gKc16Jsd/7EK1VwVkbUYvcvZJdngS79rafvfCuvuHOno/ntDRZ+myr9LpSOX6LSsQmFKT41r8Brdv19qykyMjTWTMlRuvwlHj4AZn/dlXEKXgY2oOICkVgRanZwgWw= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) by SJ0PR10MB5438.namprd10.prod.outlook.com (2603:10b6:a03:3b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Wed, 14 Jul 2021 16:57:05 +0000 Received: from BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::fd75:49c3:72bb:ca64]) by BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::fd75:49c3:72bb:ca64%5]) with mapi id 15.20.4331.022; Wed, 14 Jul 2021 16:57:05 +0000 From: Dongli Zhang To: qemu-devel@nongnu.org Subject: [PATCH v4 1/3] msix/hmp: add hmp interface to dump MSI-X info Date: Wed, 14 Jul 2021 09:56:52 -0700 Message-Id: <20210714165654.23211-2-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210714165654.23211-1-dongli.zhang@oracle.com> References: <20210714165654.23211-1-dongli.zhang@oracle.com> X-ClientProxiedBy: SA0PR11CA0009.namprd11.prod.outlook.com (2603:10b6:806:d3::14) To BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (138.3.200.16) by SA0PR11CA0009.namprd11.prod.outlook.com (2603:10b6:806:d3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Wed, 14 Jul 2021 16:57:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4fd6c143-4a1d-485f-0555-08d946e868bf X-MS-TrafficTypeDiagnostic: SJ0PR10MB5438: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:22; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dqE/xeKrQquz5Vpfu+S7T6hd+YZo7FYQGX9rq8gHkzJ3/NqhYZ1OEQeltZDCVx23qZnKFmbywzToRqdAN5NN08gKFs4TtEJiylfLclLGwxe2Arh5mKKssAFktEaM6522RMlIMAC+sIRmVMf3PLq+yHlzViCLkmXcd5tJc2Cyh4R7hCv8SWcCEAmhCpoRSEStFUBI8pPQBv+KgXmCPGXC6APfs5udo/a1Sza+FqdLWo9P4BQoKTA0zLeNTOYhnWxyrBc1p/ZdECA0hztgwg6Q8Fh0Af686DFrmnivXaFwiuBeQtLxvuUuuQ3j2fAr5pAuETnejgjcl4Z2QXqXagZh4hv1ldStHY0ttnPBR4NQRkef9baqEvL7du4ey+7IBzrSoLDIyPVi5oKRAjYLkkh1GpMJ3gjJ2/n/xZXXYETQNFAlcvQB32q3QoTpwJDyIh9AOlVXvpo1FBJlU9FVgTHqQ6+9pkz94tCLnX/XuxhaK/KBVhuyPxKUVy+2q8D+7UCBsRENMvFGFn1PwH+AAo9pDatqJmbN0HjOcKa04OzOHzD0rMh/XscTOu0g0hZ1gnzTScKrUI8xobj3H5UThLOUnp06F+A/s/s9TPRrpvtuGFaBjNSvymzrCwsqCZZvPKgsGhUFEdDUgu6Xcs5fUWfIyjpNBYjSVmFuuUTMto2wgZf/65n/obbZV5jS1vsf4FXtuhiITWlZKuBkWZ6GxsndWQqv3sUL4LkAfEE/gT1nKMQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2663.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(376002)(39860400002)(346002)(366004)(36756003)(52116002)(6916009)(66476007)(6486002)(38350700002)(2906002)(8676002)(956004)(6512007)(44832011)(66946007)(2616005)(66556008)(6666004)(478600001)(8936002)(86362001)(5660300002)(4326008)(107886003)(26005)(83380400001)(186003)(1076003)(38100700002)(6506007)(316002)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8P2PsxqeRIbfWTtJjX0YiD/7Iu8T5rng0EGgctA1P6MF3Wed7kReMYre6bt9z/CWtCmaDLsknnecLqth6YZHvBJLrOvj20yzic2q0Ba2qQWr5Ul1rogADa9+KVqoao/MRd3V+yHIhu9qoZE20QYtdxXbacMKNUtH2IB83mJWbCITVKQGjcsZWb8KOWQacjmwlRUnNvaQqn3jY6+gzfcoX3PK2zq/BKAL2kt+HgCWWyvJCHeVXtHNZhbRtdEmeF9NXskSxu+YZfoyl81DbOl4ToGi0at0F4hyMSCDnYXO88UICXJGDFMkOpDTPekd2LbfZXEoMYVzpmaGPm7C0orSgHZnO0ZejJgk5Za9aVLxFRMj/Q6wmcIUg25rqNGrsoRzFUafOb/KM25CVUQEpA2/jGxNMkYQ8y/BsXvf3ROj9TRzlqv/GeDUzmUBjEaYRLzsUpVUES1HiY2w0wXGBxYX8Qlv/0QnDJ0T/K252CTojg3kAp3vlbm8UIOQuhAz0bcr8oWgODvEzFhaZ6xDd9XkW16s7pbk0pvWiURmtdzKLI3+mivW6g3mrdtwhzIa9UWwc3RvEm3Yf16DXO7JTqmjwAzgqBpt+G62tfb86bwMOluebo9ZUSPfImstqA8madAxkeotaKTo/eZv5SUL30MO9auTRq9JPLvb/rnO1MCYWP6faL+A+CmUurCrGAK22uaGIpvATMnMCgFJ79hQ54HyS7p/UGIRex4kTOe8R3GOx3Iv0AUCbbhbD26De126raNH58g2X2yRpaa4sUqihEtca4hUDTUQwIHElFmDc8UqEFE1U3sTOPIzddA9brLfA9eg6swPmGLDqgWmqDSOURKcfYbOFbF5BavZzNdOrJ2yOpDXkh4+l0BDn4czIq98SrGZuthyQA0zKgptdWZUAfiejmrZkleC+oo8/lU4fm6U6+SezPucxr/RbUh7+II1gLV2Ffj8YGB0gVNaSelbShOHeOhZR9MOdzddB/a8m+PxEhgmEteliVxzfmbXiOhkLPKCahGxrenZDpB6Lt7jD8QKXpkozn3G5ZzeFvfDTAeWGmC4/b6moY+l+0Qk//DthNN6FRYZ649qRJQnw2hJzxtViY3ZhykNH/SoSnteghr4ylDOLNGuzzls+Xe/KTpG09+x5RNmt/EWg8f7F3mqVO4nYGnbdM3UJntRZoOT+Axym+z0uNFDmWvx+DcoSRi0+Xc8cCFJ+Ezv6XR2qvEJp7iNyliSmfoYvzUODi6EEyrZdg8M5A3Z9l1Juqdzgb6qJLVCHMxwa/84TSyD7X4ZBkZ71n06lGwMc8iVnURhI5+wZNY+pmmY6wOvYEX8OD8/1hED X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fd6c143-4a1d-485f-0555-08d946e868bf X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2663.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2021 16:57:05.5300 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KsICGugb9f5OVour55UyOWjAzGqHQc1wmq3Jxc0QwEAQLtzixIufvZWoJIgpa2RYEWIARBA2v/m7LH786T/2jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5438 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10045 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=992 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140101 X-Proofpoint-GUID: mHXQqjivm6-2aRMnC3kwNDmnJsmwKhUd X-Proofpoint-ORIG-GUID: mHXQqjivm6-2aRMnC3kwNDmnJsmwKhUd Received-SPF: pass client-ip=205.220.165.32; envelope-from=dongli.zhang@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, jasowang@redhat.com, joe.jin@oracle.com, dgilbert@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch is to add the HMP interface to dump MSI-X table and PBA, in order to help diagnose the loss of IRQ issue in VM (e.g., if an MSI-X vector is erroneously masked permanently). Here is the example with vhost-scsi: (qemu) info msix /machine/peripheral/vscsi0 Msg L.Addr Msg U.Addr Msg Data Vect Ctrl 0xfee00000 0x00000000 0x00004041 0x00000000 0xfee00000 0x00000000 0x00004051 0x00000000 0xfee00000 0x00000000 0x00004061 0x00000000 0xfee00000 0x00000000 0x00004071 0x00000000 0xfee01000 0x00000000 0x000040b1 0x00000000 0xfee02000 0x00000000 0x000040c1 0x00000000 0xfee03000 0x00000000 0x000040d1 0x00000000 MSI-X PBA 0 0 0 0 0 0 0 Since this is just for debugging by humans, provide the command only in HMP, not in QMP. Cc: Jason Wang Cc: Joe Jin Signed-off-by: Dongli Zhang Acked-by: Dr. David Alan Gilbert Acked-by: Jason Wang --- Changed since v1/v2: - Add msix_present() to pci-stub.c to avoid build error Changed since v3: - Rework commit message to explain why only HMP (suggested by Markus Armbruster) hmp-commands-info.hx | 13 +++++++++ hw/pci/msix.c | 63 ++++++++++++++++++++++++++++++++++++++++++ hw/pci/pci-stub.c | 5 ++++ include/hw/pci/msix.h | 2 ++ include/monitor/hmp.h | 1 + softmmu/qdev-monitor.c | 25 +++++++++++++++++ 6 files changed, 109 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 27206ac049..ce5c550d44 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -221,6 +221,19 @@ SRST Show PCI information. ERST + { + .name = "msix", + .args_type = "dev:s", + .params = "dev", + .help = "dump MSI-X information", + .cmd = hmp_info_msix, + }, + +SRST + ``info msix`` *dev* + Dump MSI-X information for device *dev*. +ERST + #if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \ defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K) { diff --git a/hw/pci/msix.c b/hw/pci/msix.c index ae9331cd0b..4b4ec87eee 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -22,6 +22,7 @@ #include "sysemu/xen.h" #include "migration/qemu-file-types.h" #include "migration/vmstate.h" +#include "monitor/monitor.h" #include "qemu/range.h" #include "qapi/error.h" #include "trace.h" @@ -669,3 +670,65 @@ const VMStateDescription vmstate_msix = { VMSTATE_END_OF_LIST() } }; + +static void msix_dump_table(Monitor *mon, PCIDevice *dev) +{ + int vector; + uint32_t val; + uint8_t *table_entry; + + monitor_printf(mon, "Msg L.Addr "); + monitor_printf(mon, "Msg U.Addr "); + monitor_printf(mon, "Msg Data "); + monitor_printf(mon, "Vect Ctrl\n"); + + for (vector = 0; vector < dev->msix_entries_nr; vector++) { + table_entry = dev->msix_table + vector * PCI_MSIX_ENTRY_SIZE; + + val = pci_get_long(table_entry + PCI_MSIX_ENTRY_LOWER_ADDR); + monitor_printf(mon, "0x%08x ", val); + + val = pci_get_long(table_entry + PCI_MSIX_ENTRY_UPPER_ADDR); + monitor_printf(mon, "0x%08x ", val); + + val = pci_get_long(table_entry + PCI_MSIX_ENTRY_DATA); + monitor_printf(mon, "0x%08x ", val); + + val = pci_get_long(table_entry + PCI_MSIX_ENTRY_VECTOR_CTRL); + monitor_printf(mon, "0x%08x\n", val); + } + + monitor_printf(mon, "\n"); +} + +static void msix_dump_pba(Monitor *mon, PCIDevice *dev) +{ + int vector; + + monitor_printf(mon, "MSI-X PBA\n"); + + for (vector = 0; vector < dev->msix_entries_nr; vector++) { + monitor_printf(mon, "%d ", !!msix_is_pending(dev, vector)); + + if (vector % 16 == 15) { + monitor_printf(mon, "\n"); + } + } + + if (vector % 16 != 15) { + monitor_printf(mon, "\n"); + } + + monitor_printf(mon, "\n"); +} + +void msix_dump_info(Monitor *mon, PCIDevice *dev, Error **errp) +{ + if (!msix_present(dev)) { + error_setg(errp, "MSI-X not available"); + return; + } + + msix_dump_table(mon, dev); + msix_dump_pba(mon, dev); +} diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index 3a027c42e4..8191d49d56 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -91,3 +91,8 @@ MSIMessage msix_get_message(PCIDevice *dev, unsigned int vector) { g_assert_not_reached(); } + +void msix_dump_info(Monitor *mon, PCIDevice *dev, Error **errp) +{ + monitor_printf(mon, "PCI devices not supported\n"); +} diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h index 4c4a60c739..10a4500295 100644 --- a/include/hw/pci/msix.h +++ b/include/hw/pci/msix.h @@ -47,6 +47,8 @@ int msix_set_vector_notifiers(PCIDevice *dev, MSIVectorPollNotifier poll_notifier); void msix_unset_vector_notifiers(PCIDevice *dev); +void msix_dump_info(Monitor *mon, PCIDevice *dev, Error **errp); + extern const VMStateDescription vmstate_msix; #define VMSTATE_MSIX_TEST(_field, _state, _test) { \ diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 3baa1058e2..97c040a3c8 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -36,6 +36,7 @@ void hmp_info_irq(Monitor *mon, const QDict *qdict); void hmp_info_pic(Monitor *mon, const QDict *qdict); void hmp_info_rdma(Monitor *mon, const QDict *qdict); void hmp_info_pci(Monitor *mon, const QDict *qdict); +void hmp_info_msix(Monitor *mon, const QDict *qdict); void hmp_info_tpm(Monitor *mon, const QDict *qdict); void hmp_info_iothreads(Monitor *mon, const QDict *qdict); void hmp_quit(Monitor *mon, const QDict *qdict); diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 721dec2d82..7837a17d0d 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" +#include "hw/pci/msix.h" #include "monitor/hmp.h" #include "monitor/monitor.h" #include "monitor/qdev.h" @@ -1005,3 +1006,27 @@ bool qmp_command_available(const QmpCommand *cmd, Error **errp) } return true; } + +void hmp_info_msix(Monitor *mon, const QDict *qdict) +{ + const char *name = qdict_get_str(qdict, "dev"); + DeviceState *dev = find_device_state(name, NULL); + PCIDevice *pci_dev; + Error *err = NULL; + + if (!dev) { + error_setg(&err, "Device %s not found", name); + goto exit; + } + + if (!object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + error_setg(&err, "Not a PCI device"); + goto exit; + } + + pci_dev = PCI_DEVICE(dev); + msix_dump_info(mon, pci_dev, &err); + +exit: + hmp_handle_error(mon, err); +} From patchwork Wed Jul 14 16:56:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 12377465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50CCC07E9C for ; Wed, 14 Jul 2021 17:02:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 668B361003 for ; Wed, 14 Jul 2021 17:02:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 668B361003 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3iGw-0008Lu-62 for qemu-devel@archiver.kernel.org; Wed, 14 Jul 2021 13:02:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3iCB-0007ll-4W for qemu-devel@nongnu.org; Wed, 14 Jul 2021 12:57:15 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:24170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3iC8-0003gg-Vn for qemu-devel@nongnu.org; Wed, 14 Jul 2021 12:57:14 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EGtTO2022036; Wed, 14 Jul 2021 16:57:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=UIRcz0pvGTUkSkZCcsyk27rw5xMmS/v/s2dXMtmEXco=; b=Ep2goG6aDzzsJ1Z/38xS6WyAJ8Xopu26lnhpx4YKHsqRi+G/kAgA7AkvGwVvm9MbYT23 XcRO7OAKgxWzo4Z0nrqbqK5Am8dot8FB6JE2L7o4OgJA9354Pe/tbfZdaePFQ5qWqH1l pYeD+UW0PnpiHxeDVeozVDQjxZPbHLpo4Z/FZN8EQVRTG7y4r1PAdQ6PiOEx6+cBIM2b eMQ2fpEz9MM/iCnl7HUUQiEyE43Mq+lFcSfw1iK5aB1sYkPhbYTlUfCnrwxlqhmdIu5a Cc7EaCUZjuVbRjmVXmPoAQi5juP+DtIrbnAN3ODNruKuotB1va8hg+S5bcnpyM8yybJx rQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=UIRcz0pvGTUkSkZCcsyk27rw5xMmS/v/s2dXMtmEXco=; b=EyzunnNJ5aAFzSMSe3R+BsHdbeeSVJ2aQAXIeeE4JOwIcXwm8z5ui8JPe6tK5ssrTJqo 00J2p5Aeb5Ul5uLyBe2XW6Sfnp7Ntfljj0z6vZ7Qu4NIPRLaX0CjmCIVujCBDw21sdT9 oBNOG1ztUHewVjRV8GQsL2wb1CjWtl50A5vzMt8nJWsjBB49gz0nzj+I+CQCJCfx12mO hImwHpkXDXnCatg3qmX90OSd2V3PNouaVe391XH/xG+zVV59QZv0L2OcUmHr39q50MLI KO8EAnWaE4umfVgdw4pZbB8jjax1dZ8fen4VbWzgNvuzPRH9x/S7+HMPoEbPud7/MGg3 aw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39suk8s578-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:57:09 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16EGovqA168314; Wed, 14 Jul 2021 16:57:08 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by aserp3030.oracle.com with ESMTP id 39qyd12hr1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:57:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AeZF0DNXuuerBkmkPr38SvGr6BGyytf7NZxGV12q8jMd3vTdw149ndCMA8fnsOcRbrWOHj3iYZ1Rr5EBjNdJ3CebiqA5f4TWhhqqt4niXKTfkaneR4C/JO6MHVQLLNvIlc9qhT98ZPP3ZmX3j2yD4ixdr+HQP21vUwKIVrWxECcu0bioCXo8kKK37HhmFOO10km6qKqC7HVLOmjQlK+3LBQUy6G13TTHpYMzHYzsYxXsQisWVOMSHaYOKeI7PJPT6MLHu0ON2C2SA32Y8kLkguQaEFPjiwWH3lTtWPR3+85QqbfNUZGJxEq/rJoMKdh0SPjoxBnzs5L47n4zX56qJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UIRcz0pvGTUkSkZCcsyk27rw5xMmS/v/s2dXMtmEXco=; b=at95jD/dn7ZhGu+a8IO9TecLw8OcUSYg5BwfQjQ6BdTjNyh0XowDJlzltyvEaXku7vuWxEWZloKvgFhTVmG/siuNjskdkX+8fJiLbHxk4QMdfpW7N0EsOwDZCwLpn2wkWmDVm4ZO3VZ6ZAe1ZiNJ8uOJuDuFDdNr95DctjNxrQ8oZDLbyT8A7LhmJRyeiWvwxbrkvewnuqrcet7uy81h3R1E3LvIJz/uadzTLh8qCtO2sIHm1jJmqtxDYeA69JIDbflQ9P5AFDYzX1NM3FaowZv6OSnNi/e18oSt0a01bxk9KU4oVd02+37527GjEn426MXyq4+M2LMVldeF5waWwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UIRcz0pvGTUkSkZCcsyk27rw5xMmS/v/s2dXMtmEXco=; b=tb4FnQxyrH7Gd38zoRCKO9I2+BQ9f8VVraVbmeLVekmOu5t9zFRji/pE2BeWiikmIednp/j/dr4GwcdRfVzJZ8b/wXJYPTD/RWkmY8auoNr1kuT6Bzb24Y4mldUJkH/Thcm0PEVJw8NXiFnV0t7y+jFmJqMB95ivTVKfJu3AI80= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) by SJ0PR10MB5438.namprd10.prod.outlook.com (2603:10b6:a03:3b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Wed, 14 Jul 2021 16:57:06 +0000 Received: from BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::fd75:49c3:72bb:ca64]) by BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::fd75:49c3:72bb:ca64%5]) with mapi id 15.20.4331.022; Wed, 14 Jul 2021 16:57:06 +0000 From: Dongli Zhang To: qemu-devel@nongnu.org Subject: [PATCH v4 2/3] msix/hmp: add interface to dump device specific info Date: Wed, 14 Jul 2021 09:56:53 -0700 Message-Id: <20210714165654.23211-3-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210714165654.23211-1-dongli.zhang@oracle.com> References: <20210714165654.23211-1-dongli.zhang@oracle.com> X-ClientProxiedBy: SA0PR11CA0009.namprd11.prod.outlook.com (2603:10b6:806:d3::14) To BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (138.3.200.16) by SA0PR11CA0009.namprd11.prod.outlook.com (2603:10b6:806:d3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Wed, 14 Jul 2021 16:57:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1274970e-a461-4815-8b27-08d946e86980 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5438: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:183; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cOfP8HvIlaeHTYU6kpjmPA0x7UJMlrrpdsFjm89L+Uo2986ctBYDcZx2Oq2cwdonSfqZBDVPEqS2wiwpgpWEtsAX/bkA7ReqH5a5OSK9r9RqWq3ovMhuAH/R8Vo9i4FPUZ3A/G4MDk/hlpMmRYVeios67CZuqg8Nq239bDTkyNzHJ1btFoLXrOsQn1bav0pgFfSvmCq3iHQNsjLPItuYk9zYgJ8YuODobMIHYlGC5Ad3vY3WXJwNPx0PyJtAAzXCy6A1SC7RSpqQdDSskZOay5JGhixvNZlgdltsq8MVcK6PpEpd5AyxMkPWnzAXM7eRFv9JqF5LkWN8KR3UaDp+X6MOtQld69K6G4Qxfy/O5ldWA0K1/b0ldyMYNilq1Peyk5q9oIZQ2Xg48kzlr0Tt0wzR4yMaPodpRaMNbQ2ow+OU71b2pcatP9We6RTjgwl+IXiIyoORlHyq95RRBQMyri3+yq7l3UF8+CCrdUF9lwt/n/q1WgbaNP+GhcZK9kNPs09FD+/FiwCgOKAY6AAXwp3vU78DfjjFvdE2Y5Ac9zsHcwuJXnjzjdqNqNEC8HcC3GN0Tlun63Yz6H/JKvevTpLILngGGnO1DCliG4Ojw8DEtoiB0/bm3OmJmpu5eODlknMvdDhOA6KEL6kQ37sFsOxOZ5BcOuyasfFF1Stetqzd1AyjoBTtk4Be9vbA7Bf4LcGgN2XLSvPBWTvB9K1mrw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2663.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(376002)(39860400002)(346002)(366004)(36756003)(52116002)(6916009)(66476007)(6486002)(38350700002)(2906002)(8676002)(956004)(6512007)(44832011)(66946007)(2616005)(66556008)(6666004)(478600001)(8936002)(86362001)(5660300002)(4326008)(107886003)(26005)(83380400001)(186003)(1076003)(38100700002)(6506007)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IMVWgN2CtrEN/gOqPX1K7xAgOnvcgMBX4huBjRfpMRVAFyX7POyWKGqpJLaw4opysucLob7USXvFsCRy/C4grZyJjGwu3j5Cx4Lk6qnw0pOE2u8KDd/A/WP75d1xpcfw44TnMKOwvSWTHmYJ6fbwqFc2vsUYQJBPh5+45EwUetLdtmzKCmg+o3tT6kv5LfbEAp4dV01KzhSFDgoRTf0QFAvcNiXHit5lbjIY2N5Wx44SG/KA1EBOzt4BtLEhDiBhMccEEIt152KeF0KdeclDloy3AYtnDtcnnLjrQf9f9cZQedL9wwWRXB+fh/AH/0TsRUDaE/TwYo7E7u64jGl8jW+3wcPmQiwkx4ui60Os48xp53vnp65hlv02CEUP0wZvOEvansHzHP48rScy895rA4vbDH5KRkxHEIIUk+9KRNOCbAShig6GHDJfSts0RMsQHkNBxXrabcw0tIq4/nViAO9X927+nJ2JXTGiFSbZzsklgCZqCFp3Zqcrs+Sa+AaWhguySTW+xp/cRh6ZtS7rXLXRJY8fJPawyaFXytajeqmqIiPwB1Nr+RDLlUqSpIpMtBUq30+9HVrfggPUJIOKJg6xg4iuvY7/HdjE38uKzPoD1+OUl/xYGJhGPjBMhns0gMkoLc765mfAbsscR/WChVc4L/qlwNi4V66YmtMvbUPheyIygQkZuiEnPjxuNQt87Zkx9jOIpKAGOlhpGUqvdj2CNtIaqb7xVcw2y2Jbv5nT90Aj42lgAgRQHH9/8QCpflG1sjkQ9qV9uXewhSd9uEJKr5boxfgqr5pWARze/nOrXXYXdL+Wec1BKkIE1t/2CPgQ9r0NqxximJQfqlyI8mSAcaOpP060nCUcGBMeuzjJkYfFSJbB9KDD9ruKApQLTGFTMikN1j+ZjRT0ODlqaSYBvhnR9407unTWFyO0MNjyt7wvyaZ7I3dVOtplE0zRn5tMuSPf8o/wQSyC3t7LZKIkycaIulzSueNuBLtsM0r1czkGSfvliXc+w1djO1QilJiMgH2a6Fj60JgRgtYarvLnvcwHcD7CxHDoj2Q+w8mirZ05K6OOwUBzZX55xP3qJGSKxVOmPtfFT3492FecfNohTUwUktrtjFiugkeKFBDnzTuqyjsZlpreJQbJGtp7Ik2SUyldbFgh/hoxvt17BBjT7zEzFXkpy8tC+kglcqxzJzK3qnzxwbyAdVOGjv7B9aYXp5aC0on8cY39bywiifl2yNwqLnUqV8Vzy2mtPkR6unXq2G6TOeVrBIjFIwHyzvwg8ZoVOiTVWkHjpucYfA3oWek3VX3c0ijlUvVqlebf3912u2DNyZ623ffxyfrJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1274970e-a461-4815-8b27-08d946e86980 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2663.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2021 16:57:06.7753 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LJNBNnYTTlD00SneRFVCnbV79IQn9aMtiDu2NMyz692xOkODU5cYFVYZR5OhgD2uuT1vyIOgkF9lyrULixAFXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5438 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10045 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140101 X-Proofpoint-ORIG-GUID: 3TrBjMuNJ51EDikcqw6VWh54DjKj53Dq X-Proofpoint-GUID: 3TrBjMuNJ51EDikcqw6VWh54DjKj53Dq Received-SPF: pass client-ip=205.220.165.32; envelope-from=dongli.zhang@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, jasowang@redhat.com, joe.jin@oracle.com, dgilbert@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" While the previous patch is to dump the MSI-X table, sometimes we may need to dump device specific data, e.g., to help match the vector with the specific device queue. This patch is to add the PCI device specific interface to help dump those information. Any PCI device class may implement this PCIDeviceClass->msix_info interface. Cc: Jason Wang Cc: Joe Jin Suggested-by: Jason Wang Signed-off-by: Dongli Zhang Acked-by: Jason Wang --- hmp-commands-info.hx | 7 ++++--- include/hw/pci/pci.h | 3 +++ softmmu/qdev-monitor.c | 11 +++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ce5c550d44..4e831d7ae4 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -223,9 +223,10 @@ ERST { .name = "msix", - .args_type = "dev:s", - .params = "dev", - .help = "dump MSI-X information", + .args_type = "info:-d,dev:s", + .params = "[-d] dev", + .help = "dump MSI-X information; " + "(-d: show device specific info)", .cmd = hmp_info_msix, }, diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6be4e0c460..4620b9e757 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -129,6 +129,8 @@ typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num, pcibus_t addr, pcibus_t size, int type); typedef void PCIUnregisterFunc(PCIDevice *pci_dev); +typedef void PCIMSIXInfoFunc(Monitor *mon, PCIDevice *dev, Error **errp); + typedef struct PCIIORegion { pcibus_t addr; /* current PCI mapping address. -1 means not mapped */ #define PCI_BAR_UNMAPPED (~(pcibus_t)0) @@ -224,6 +226,7 @@ struct PCIDeviceClass { PCIUnregisterFunc *exit; PCIConfigReadFunc *config_read; PCIConfigWriteFunc *config_write; + PCIMSIXInfoFunc *msix_info; uint16_t vendor_id; uint16_t device_id; diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 7837a17d0d..7fd3fe0ada 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -1011,7 +1011,9 @@ void hmp_info_msix(Monitor *mon, const QDict *qdict) { const char *name = qdict_get_str(qdict, "dev"); DeviceState *dev = find_device_state(name, NULL); + bool info = qdict_get_try_bool(qdict, "info", false); PCIDevice *pci_dev; + PCIDeviceClass *pc; Error *err = NULL; if (!dev) { @@ -1027,6 +1029,15 @@ void hmp_info_msix(Monitor *mon, const QDict *qdict) pci_dev = PCI_DEVICE(dev); msix_dump_info(mon, pci_dev, &err); + if (info) { + pc = PCI_DEVICE_GET_CLASS(pci_dev); + if (pc->msix_info) { + pc->msix_info(mon, pci_dev, &err); + } else { + error_setg(&err, "Device specific info not supported"); + } + } + exit: hmp_handle_error(mon, err); } From patchwork Wed Jul 14 16:56:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 12377485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AA56C07E9A for ; Wed, 14 Jul 2021 17:07:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB3F960698 for ; Wed, 14 Jul 2021 17:07:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB3F960698 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3iLf-0001nk-Pl for qemu-devel@archiver.kernel.org; Wed, 14 Jul 2021 13:07:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3iC9-0007f1-De for qemu-devel@nongnu.org; Wed, 14 Jul 2021 12:57:13 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:2120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3iC7-0003fD-AY for qemu-devel@nongnu.org; Wed, 14 Jul 2021 12:57:13 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EGtQLr008692; Wed, 14 Jul 2021 16:57:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=r1n7485cQhaxPzj8emFerG876GfvUQJ2MFub7M84KMs=; b=VFu4Dz+F/xmO123Eque0chsmP6ewKV9gQKrNZ/jUFDVqK46KEagqS6ZJQFME6IoqTGsG zNqGEfCBgj5X3xC8xv/79ASaFzCYDfWyLEqqk9dYSr1EWgKOccGC2FUa1MSusVDV5+hg kq97Ze016qC1ImGnwqGYye5pj3aox0tutd7X5hUgTEp1K9c0USlfBMX96Me+bwQw4vy5 kBqtSy57hd7KK37uRy0MO21gbw2V2akJieCc6pazV9bjL/YapcKYvoSvLq7JEjNtreSm fSrzKSc3qFO6lvxSaypvto9AwD1E1PhsuK8e9EK9uopnARMITNKWgSU8bteMso4PFY8p Qg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=r1n7485cQhaxPzj8emFerG876GfvUQJ2MFub7M84KMs=; b=LiimVfJEtPUum1EkUXsr2Hqxt+enjPUHoxv8T7RAOYzDT4WPDBd5JGvDv4Pfx/t+esmi KLcHaFGdvqzi44EQ1X5ANxpdV46K5vIyd7PfueETZpbnuCnkHgJBYKIimZZxg3n7l2YI bk9LNrWBpsbQC5DLGKRyzuVizdeHWvWGCz0aIjkQ5zdcr579xb3IgbjEpXqbW69zrbqz IjpLSoKzJxFSFCjlXika18BXstG4cCjeSA265cBSFtKw6+4r/feezJfbcEK9WNwk1lDv 5Q1PEQJf2RRgP2A3jU9Nnozi+S4YEpVS7+yK12eW3bOYHiSm9G2F6DhOs0wsV2187/f9 uQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39t2fcg6xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:57:09 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16EGovqB168314; Wed, 14 Jul 2021 16:57:09 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by aserp3030.oracle.com with ESMTP id 39qyd12hr1-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 16:57:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QnNOTHXgKLGmhb0a+Jtxk8a6Eez6xWoE6NbS74Bph+1vnLQ3bWZIIexkCcuhmfM3/iOSnE/ZjkSnPldX7cCqMmsnEo5pkupHKOls8+ZPGSCrLsMoLYnncCkF8bXbjpLcQaNAOjpKld9I5IPPpSLvGPCBg/U9JrgAlAelTewTQAmdI5z9EkHZgD7XuqUiYlh7+CxEpVfTbjTStbUT8VBjfk4uteyy9cE67Ruj+afU8jdkl9eXekILpN6D4aONF51dGbAzan6BPE90IopGwTKA0Ex1g6g9juEGZmYKv9u8YGEj4p9VR2NGhl8OqkJpDWVMUewmNwBm9TgWysND5zFTWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r1n7485cQhaxPzj8emFerG876GfvUQJ2MFub7M84KMs=; b=THJCmXBm67mT1rlUPFsjA50ar1nlBJlCNudqU+4Xhh1KObZ6JVxgphRNM8qrpLUz1U1TbSAJjNCCxUXxsZlcO+YLvKiogJQ4Cc55YRm+vq5FvgQt3RngbMmoLHvCkTYSoYmgq7qEPJWpF8QD1AzLSV40Dnm6fTU1ArAQYGdf30zR5ZJrcN11dSdmGAfZ28zJ0zV17qZ+Z+J3fIyAALdlISPbNhZxak/4F2LVJRi6TZoJLLD0MN6I6XZvjw4W11xfm9uVt7LJGJKPa/Ba7z1vq4Eu+yJkVe2l/BA4LTbFkPcEUs+SnYK89Z7IiN5bI+sAkbMSU8GuUzsjZSl3slZrRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r1n7485cQhaxPzj8emFerG876GfvUQJ2MFub7M84KMs=; b=NMrv0jJPcSaR6vnFMdEnEAJSzopU98JaMcpk0XFlbt8y6ZqOgfWQRJxMIUvG6uNc7kGmzT3lFKqFrI3lBYefNG3GKA4uH6mdQl2+KSr+0w4TSSRawq734iphLNgeXIvo2GmgSYiLfGWCwr1+bi0VWQU9/aP7x51g4DjDwHuvo6I= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) by SJ0PR10MB5438.namprd10.prod.outlook.com (2603:10b6:a03:3b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Wed, 14 Jul 2021 16:57:08 +0000 Received: from BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::fd75:49c3:72bb:ca64]) by BYAPR10MB2663.namprd10.prod.outlook.com ([fe80::fd75:49c3:72bb:ca64%5]) with mapi id 15.20.4331.022; Wed, 14 Jul 2021 16:57:08 +0000 From: Dongli Zhang To: qemu-devel@nongnu.org Subject: [PATCH v4 3/3] virtio-pci/hmp: implement device specific hmp interface Date: Wed, 14 Jul 2021 09:56:54 -0700 Message-Id: <20210714165654.23211-4-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210714165654.23211-1-dongli.zhang@oracle.com> References: <20210714165654.23211-1-dongli.zhang@oracle.com> X-ClientProxiedBy: SA0PR11CA0009.namprd11.prod.outlook.com (2603:10b6:806:d3::14) To BYAPR10MB2663.namprd10.prod.outlook.com (2603:10b6:a02:a9::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (138.3.200.16) by SA0PR11CA0009.namprd11.prod.outlook.com (2603:10b6:806:d3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Wed, 14 Jul 2021 16:57:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b187de1b-89a6-440b-8f09-08d946e86a3e X-MS-TrafficTypeDiagnostic: SJ0PR10MB5438: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:192; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KrL7mw48o6eGUgjHevpEEgiAcYbBBrZhP8WQEbZFMAScfoYU74bhEuYeWFkpIl2MZH1+K1XSBamyt9ikIhOBXLCt/9QwuJz5vioBZQQdWnCO+TM+JwX2jK2FasXZVhO/R8FfVl/oNOVuU+Xsy3w3dj9MJj5SDF/cNuNBrRXQGWBrkIC0m5/KFybYlyXtnuU+6oNATh+LoJJLYjf+LwGq9Bk/QblE+pK9PJhB0p54FHALDcPMbOJcDOxZEuzaYbHeuhQQtKxgiCXkoNw4mO3hTK/phVnhXiwpM4x8JGsX8IFVHNPSmzJza4H6h5Xz+W+/xDUdBvd1oQqXQBVONTupy5ikr2+N1mxqwviMWIiC07p8oA9mPw9CC7DiZh5qUUFT97aXObk3/DzbCaZ15X5obdn8Oedb54O7uVmqdoB2O8fdJcoqwxs51swzMadR66DfAv9hbTwnti0gnzZbnwaFSrlrqacAsI5xf+EB0KDoXIhy/wcbNp6hUrpj9hBeRv/lX2yoOpnnAb5Fpuc0LpuqqUOs9S/k3Dc26wwl1fLoRlGah5lz1/7+TwDjq2mINI0sp80APHkDa8XCkCBT3tmA3JJM2Vd6c4u8x+FrU6ivvPN8JgMT7/Mz9e9TDsHh1Npuz+kbf6h2ShUx0ccUPZgVyF1voz2wzwr+cbffig4MJ98rCUqx4bZqyTUaQaIeV5dp+8LxMywMQJ6/9wzIuGa02g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2663.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(376002)(39860400002)(346002)(366004)(36756003)(52116002)(6916009)(66476007)(6486002)(38350700002)(2906002)(8676002)(956004)(6512007)(44832011)(66946007)(2616005)(66556008)(6666004)(478600001)(8936002)(86362001)(5660300002)(4326008)(107886003)(26005)(83380400001)(186003)(1076003)(38100700002)(6506007)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WKPUqEXdws/VQw7PONM2MjJ8XsAT7zunyo2t+ftbmoKBs+giAXvsu8cc1AKax0+vEpk7dC+Bu8RLHurAYZPd9z+snKMmkIcXSzO5SsbF2hXRZNq1tgDcq8uHibVV69W/eAFOyAm90KnmmWVRVYCQWl5qKcEA9ZzbS3Hk7RhGSb5I4s1aNb3hd1OkSvQLwmeTtKoluquLdy6vKM0YQmFCAg7WrcpnZh+JaJV7RavQvhMAeaqPsftnuFaQG9Z6aJFslSZE9ICyWlrDCc9gwTzgoZO9afNdmxXNoQcqxkbcy8qjMjosnt8gjTd/3CniQnArRktry8nct+otn+3ek5pnOxNCEPa3rkQN0XWe2djy43aokt0DSofPlMx42v7MtL2DNECf8G9woSkpXjf4tjk/UO34jRxo0hatu5YdwaLuolx+aXw9JaDRfUd3A02qelfCunz/2o14VcmPtbv5le3N7K5LDI4yvZe70xvY3Oros+24Lcexrav2mxVXtNs+N8KVwacQ4rZBKA3d6tAtoKnO+iz80/FyEWh/++iq51pTGzVAUo5JAA7iGbrzH3CBz4i7ifJ+SEaIk+AJNV+5kytocqnEc5SqeXuUZXNuSDd1iiCgRR9VmvR9YLxAwUiIxkVp3Oc027Dx797nEFo09QpJ8aqdmXk+XaltZ1MwkaN70/ZzN/JAMhrBfYPIrBghNvkw3tKa608ra3dhiwdj3gYsTd9iqtlHqfz34r/Il56e3OCAYAKJJUqnJq+EhHZVKvw3WsbWEuBlfyHiPaspS2RLBMXjI1+TRezhKe0YuUNqmNQ3N+gmf7uqEZnzEpDfqpvh/emhIZ5KG3Ndvrj6PST+uQE4N15BLwth94s5tJJsYBQPbhqTkE6YAC0jKIYrtYSs1zXx6zB5ogSz6DF7jMoikx32Yy9YMfWloZp6nDA+HqYUEo7dOZSVqmQ/129CHQ1ujYsaNAe3q5rTeE3F2NaoxiThPvDypnBClWVOiGstGT/TgdG3he31umhyzZIZe7cu9sTrImJ6z6GTGb2qdYmRbbB3rLJLyO/7ytE0UgqP/T/EEUTws5BHt+iyVCaKNis9+Brq/dPkvYHFNrmTT3UcXnRoRNm//lMK4MsDoJOqfc4PCiQzMqvU591BFjRxQvuEawa09jIWIyYJpssbFIhcd82bWgZhVvwDAURWJD+8hF5k4QWVFQTqMSy0pjy3f0pM4e5La/eGsy3UZwicuv9DbJhdMombaAqHusy0PHaC6B7sM7YKHqSBw2/3CKD2zGfFBFGCFf/7YqZIUXsjSa4UUMh02qKBe9YB3SUrXuwpI8wJjh+7Q1udNzPPFavVMW4L X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b187de1b-89a6-440b-8f09-08d946e86a3e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2663.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2021 16:57:08.0376 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DsdVhe6O2EDD3Pn3Do4IvrMEq4JUhYOYnxwS63R4Sik1nyj6Iedpr/+GHuw2VDnBOS9Zhg4nD6lQrC0QumvD7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5438 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10045 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140101 X-Proofpoint-GUID: Q189zVZsaX9bke-fuJgcQHtkYrFqc3ql X-Proofpoint-ORIG-GUID: Q189zVZsaX9bke-fuJgcQHtkYrFqc3ql Received-SPF: pass client-ip=205.220.177.32; envelope-from=dongli.zhang@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_BL=0.001, RCVD_IN_MSPIKE_L3=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, ehabkost@redhat.com, mst@redhat.com, jasowang@redhat.com, joe.jin@oracle.com, dgilbert@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch is to implement the device specific interface to dump the mapping between virtio queues and vectors. (qemu) info msix -d /machine/peripheral/vscsi0 Msg L.Addr Msg U.Addr Msg Data Vect Ctrl 0xfee00000 0x00000000 0x00004041 0x00000000 0xfee00000 0x00000000 0x00004051 0x00000000 0xfee00000 0x00000000 0x00004061 0x00000000 0xfee00000 0x00000000 0x00004071 0x00000000 0xfee01000 0x00000000 0x000040b1 0x00000000 0xfee02000 0x00000000 0x000040c1 0x00000000 0xfee03000 0x00000000 0x000040d1 0x00000000 MSI-X PBA 0 0 0 0 0 0 0 virtio pci vector info: config: 0 queue 0: 1 queue 1: 2 queue 2: 3 queue 3: 4 queue 4: 5 queue 5: 6 Cc: Jason Wang Cc: Joe Jin Suggested-by: Jason Wang Signed-off-by: Dongli Zhang Acked-by: Jason Wang --- hw/virtio/virtio-pci.c | 22 ++++++++++++++++++++++ hw/virtio/virtio.c | 10 ++++++++++ include/hw/virtio/virtio.h | 2 ++ 3 files changed, 34 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 433060ac02..2971e8049c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -38,6 +38,7 @@ #include "hw/virtio/virtio-bus.h" #include "qapi/visitor.h" #include "sysemu/replay.h" +#include "monitor/monitor.h" #define VIRTIO_PCI_REGION_SIZE(dev) VIRTIO_PCI_CONFIG_OFF(msix_present(dev)) @@ -1587,6 +1588,26 @@ static void virtio_pci_modern_io_region_unmap(VirtIOPCIProxy *proxy, ®ion->mr); } +static void virtio_pci_dc_msix_info(Monitor *mon, PCIDevice *dev, + Error **errp) +{ + DeviceState *qdev = DEVICE(dev); + VirtIOPCIProxy *proxy = to_virtio_pci_proxy_fast(qdev); + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + int num = virtio_get_num_queues(vdev); + int i; + + monitor_printf(mon, "virtio pci vector info:\n"); + + monitor_printf(mon, "config: %d\n", virtio_get_config_vector(vdev)); + + for (i = 0; i < num; i++) + monitor_printf(mon, "queue %d: %u\n", + i, virtio_get_vector(vdev, i)); + + monitor_printf(mon, "\n"); +} + static void virtio_pci_pre_plugged(DeviceState *d, Error **errp) { VirtIOPCIProxy *proxy = VIRTIO_PCI(d); @@ -2004,6 +2025,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data) k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_OTHERS; + k->msix_info = virtio_pci_dc_msix_info; device_class_set_parent_realize(dc, virtio_pci_dc_realize, &vpciklass->parent_dc_realize); dc->reset = virtio_pci_reset; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 874377f37a..ea54939e98 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2581,6 +2581,16 @@ void virtio_notify_config(VirtIODevice *vdev) virtio_notify_vector(vdev, vdev->config_vector); } +uint16_t virtio_get_vector(VirtIODevice *vdev, int n) +{ + return vdev->vq[n].vector; +} + +uint16_t virtio_get_config_vector(VirtIODevice *vdev) +{ + return vdev->config_vector; +} + static bool virtio_device_endian_needed(void *opaque) { VirtIODevice *vdev = opaque; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8bab9cfb75..6746227f73 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -268,6 +268,8 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val); void virtio_reset(void *opaque); void virtio_update_irq(VirtIODevice *vdev); int virtio_set_features(VirtIODevice *vdev, uint64_t val); +uint16_t virtio_get_vector(VirtIODevice *vdev, int n); +uint16_t virtio_get_config_vector(VirtIODevice *vdev); /* Base devices. */ typedef struct VirtIOBlkConf VirtIOBlkConf;