From patchwork Wed Mar 30 18:03:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BCE9C433FE for ; Wed, 30 Mar 2022 18:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349671AbiC3SHr (ORCPT ); Wed, 30 Mar 2022 14:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345055AbiC3SHp (ORCPT ); Wed, 30 Mar 2022 14:07:45 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D6D3334F; Wed, 30 Mar 2022 11:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sYYEZsMoX1IF0WdGyK05wlg2fCihGbgVkXhhOVHIci8=; b=HisHrKBY8x74ggf+BY+iM8WeyCDp/TXPExlWc5zmMW3u3hY1yywDDZ6n5LEWSYsvIQRKbZPR6tEwS+OMZDkEPn+wuNs82NA/qp4VzQ8z/hKWl9AD0akLPw2QzZQysnt08T7YBaYoE0CijSihLz4ikWTHVDAs2ftO+3GLFiTYNuQ= Received: from DM5PR19CA0057.namprd19.prod.outlook.com (2603:10b6:3:116::19) by SN6PR02MB5344.namprd02.prod.outlook.com (2603:10b6:805:73::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.18; Wed, 30 Mar 2022 18:05:56 +0000 Received: from DM3NAM02FT051.eop-nam02.prod.protection.outlook.com (2603:10b6:3:116:cafe::37) by DM5PR19CA0057.outlook.office365.com (2603:10b6:3:116::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:05:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT051.mail.protection.outlook.com (10.13.4.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:05:55 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 4438C41CD7; Wed, 30 Mar 2022 18:05:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J6NCzSwSMzo54w98+j6oesNe9zGy2NfpqJ1uj4OVOXcqJgXcwyJc4eV5b3l2wElYne/VOq+HvrSjgai1zs81HjpMI9AFvdJaNht179JS90XHsIVMRMR3r5SdQZB/+Q9DPvBC3OnzU6D8oNiLowUTiSF7CJSk827PGV2HNOyNva5lu2QxqSQ6/Y4griWK6+NAmVM24O6ZJRYQ7s8bO9q1f7JnYNNp7+wgTr4OzosHMX5E8juK6ZBq3IWDxagDHXDQ3oIbCs7289sVm603DKLEMnm2WF5Rem+BTFbjZDrktLKAPzeTKL7+0GUpmtYi2ktk1VgSTzkMUgWnXtdYjqdSmQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sYYEZsMoX1IF0WdGyK05wlg2fCihGbgVkXhhOVHIci8=; b=cNLNn03+CREqX2jyHv5yVE84ae3e1r87ZyN/q7iXTMK2fdjxWO2vaszQqAY3hWvY4Co3LQfzaAONxrLlrN1EGxN6L7CT4b08beiPxm6q41hi76fVaAO4PE8cx4PDoc47/53gzvrwxcXv58mfrGfQ9k4TOWGtb7lf9duH8SFgFLzQJVNpCUl4Ov87evBgX5NohpKkvYmcbqTCRSAA9xg4eT0pNNpj/3rd+QTUxphvzGsh7hwNm+HG3FY1tH5lwtefMjNlUQHqj1JYdyzJRDU0J5f1xuGVb6DylChKbC5glcuLdHgU+C6LzMHQWseyvKdEmlcagpuOuAyiD0haQhbZ6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN9P220CA0028.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::33) by MW4PR02MB7105.namprd02.prod.outlook.com (2603:10b6:303:70::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 30 Mar 2022 18:05:52 +0000 Received: from BN1NAM02FT060.eop-nam02.prod.protection.outlook.com (2603:10b6:408:13e:cafe::8a) by BN9P220CA0028.outlook.office365.com (2603:10b6:408:13e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:05:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT060.mail.protection.outlook.com (10.13.3.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:05:52 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:05:51 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:05:51 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZchb-000CCQ-3X; Wed, 30 Mar 2022 11:05:51 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , , , , CC: , , , , , , , , , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 01/19] vhost: move the backend feature bits to vhost_types.h Date: Wed, 30 Mar 2022 23:33:41 +0530 Message-ID: <20220330180436.24644-2-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: a0f9c0ae-7ade-4a23-372c-08da1277efc4 X-MS-TrafficTypeDiagnostic: MW4PR02MB7105:EE_|DM3NAM02FT051:EE_|SN6PR02MB5344:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: rbGt3nHq13snBDeyPEx/blKIbUcvSoRLwf8GTsCHkaweos7WRJDPdNkArrrIQ/Fo/J00WxlS01rhPitO+oJG0sWJ0FSvAuOe0Wjz/WvtMX8HGCGWoQMWPeONX9XHJo+wI3dlBQngtrjUf6jr1viR72eDPjUe77HUR8Ty/1LuJfqwWXIbLpTn/BBEHA7q2wWgOO0ezKdJsRL6FcNXfTLZowEgsIJcTC1vkw8r3QCLDLXp3sM9eei0MNjFljfbnWviF907MW5raHGgGogJovZ6aCAiQVm1tHnikSl2NZwTBzIy7s9mgbKFaWeHIbOiA3HCXtMcIqJd5StfrP5RQ+hFIw/1bRSSyNLQW/gq9SfKv9i0KwjSQkkUdMt4XVQfiSzv2m6dQIeh1g3STBH45ozag4M7jNOlRD0UmTsPfL3G0oK8VXBqyY579svOLwfOLsRH7Gsy7Mon90EBlh/8Pei+Gs2oMV+KQ8x6zK9GS1E4kLaj8fIf6xlnUJu/zEPC1DpQQLXf7UQuPRr5NTulAcAiqlELFlUXUwqmsTrQuXzhHIpFZVyprMHUUENyVf2DiyP572VLUaxEu/nqiwZzETJrsNLo5eoa6p30yaDUlpoS2O+mCzLEyT28lz3l8pMFD8Cx/8EeN3CB2RnbgwujNadreUaYxb7/pjvg4Kn8ILT/yWcdaoYbBVXQWsp6wAXlIYqn+cTgaETB1mdYI6PB+slEQw== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(36756003)(7636003)(6666004)(7416002)(54906003)(47076005)(5660300002)(36860700001)(186003)(356005)(1076003)(110136005)(316002)(2616005)(82310400004)(9786002)(26005)(4326008)(8676002)(70586007)(70206006)(83380400001)(508600001)(7696005)(8936002)(426003)(44832011)(2906002)(40460700003)(336012)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7105 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT051.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: be92ef49-9b0d-4960-2f09-08da1277edbe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wLmZRP0+ZSwaEBjPTTnnLjfT4R9IYtVD3lzF4d7BVlfF1PpRSrAVhPCuwJdUYAe8eCGMapSPeyTwf+qAhzKX/BnPek2eXc07YsYk2Ef3LouKkC01IU0D9wHz2vxF2eugmPoawAv6ejhVvrm4MbFzQi84yCkMVmNu94kr4Iu2lJVhOUnE24Fh10w6/fCbNFhaCz3HWmGRfGNKJeTJWIzdVoEMPbvoG523S53azuV7fzi2iQcViUAbhl0s5Yg0TFl44eMczGveRFJMkNnOHp2sCuI8y5XRkhx14mJd11cG2Yhve0Ej+MHwu7FhAp5d2Xw50asKx+p/1rwNyMOPSVjft/Ivq5Ubgv4ZznNrqJJX512UAxfj8k+HUtxp51rsv4CraXDThsfT0ljrMDc4AVLT+aRFxvLoBKqmiApdu4SWxO8ZZeXlMJ9sb9skmCGYZv0aN6DBvw9XyQYT8uy8J5MuWqd/gYWotn1pzzmbrZRcZD1xSO/ooYTUsR2kExKUYvxe4dtxqVtBYhxii4dF8VzObn6xV3F8FUvU+pzbeDnnGqM3JCoxaFOoio4B3YijsdXfJr1K3UFH6KDBaiP4A54JN0I39dwQN8lu22eHsR4L5c/OaQc2RWD9L9SXBh+Tqy8DfV/E2mMlAABXGN/mQvJMNdH7u9JDVe1rodJsmtoHJgB4pbE4vqK4h9XUxiCCmMylYhSwSDHSBdz4QYxXBBmDK2/hN9Mh9dqyYzEm8jwwKLed8aKw2oYrpftktVaz4QKw X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(7416002)(36860700001)(44832011)(36756003)(8676002)(70206006)(426003)(9786002)(2906002)(83380400001)(81166007)(47076005)(4326008)(8936002)(5660300002)(1076003)(316002)(82310400004)(2616005)(336012)(7696005)(6666004)(508600001)(54906003)(26005)(186003)(110136005)(40460700003)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:05:55.8118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0f9c0ae-7ade-4a23-372c-08da1277efc4 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT051.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB5344 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We should store feature bits in vhost_types.h as what has been done for e.g VHOST_F_LOG_ALL. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- include/uapi/linux/vhost.h | 5 ----- include/uapi/linux/vhost_types.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 5d99e7c242a2..8f7b4a95d6f9 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -89,11 +89,6 @@ /* Set or get vhost backend capability */ -/* Use message type V2 */ -#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 -/* IOTLB can accept batching hints */ -#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 - #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index f7f6a3a28977..76ee7016c501 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -153,4 +153,9 @@ struct vhost_vdpa_iova_range { /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ #define VHOST_NET_F_VIRTIO_NET_HDR 27 +/* Use message type V2 */ +#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 +/* IOTLB can accept batching hints */ +#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 + #endif From patchwork Wed Mar 30 18:03:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A366CC433FE for ; Wed, 30 Mar 2022 18:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349693AbiC3SI7 (ORCPT ); Wed, 30 Mar 2022 14:08:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349755AbiC3SIo (ORCPT ); Wed, 30 Mar 2022 14:08:44 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2078.outbound.protection.outlook.com [40.107.93.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8B03D48E; Wed, 30 Mar 2022 11:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yvhDDtxMkPbg2jNe02Wu42VkpULzJmgbg7z+jUGBhqg=; b=LsbrFve/Y5sdRS1DRnBaSHn+KB9w6b4WyHKzbsX7HyeZ+DG1KGNt+sNxx1B+AF7caTmnTz9tjroEqHUdro3yLXPwF8MIzsIYZmbcxIt4CK33AI1rG7H6A9H0iwEL7+6rmTXEXMsHY0TxHyld5o4Bdsg0LhN/bWUhkppCzquQJmI= Received: from SA9PR13CA0167.namprd13.prod.outlook.com (2603:10b6:806:28::22) by DM6PR02MB6921.namprd02.prod.outlook.com (2603:10b6:5:258::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Wed, 30 Mar 2022 18:06:48 +0000 Received: from SN1NAM02FT0032.eop-nam02.prod.protection.outlook.com (2603:10b6:806:28:cafe::14) by SA9PR13CA0167.outlook.office365.com (2603:10b6:806:28::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:06:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0032.mail.protection.outlook.com (10.97.5.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:06:47 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 6631741CDE; Wed, 30 Mar 2022 18:06:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fwnw2q7PEEOb/PAB9wfePXTnRyKVFIBeShUJVbPuYN7rCf21MUPfm/EeOlqQw/te7Qh67M4/6ZgBOu31hNQv2Sj3zOrOuXMOgANVrs76nuF5vzJyBJNblSfB61grauxzdKYPCfev1gfDRG+AbpohnxrqJetdkn9csNoJuxwM8BrHGbU1J/vb+a8mNSPCrfU3vb8bZxcA/qLd4vf9izqmo9S6HlllQebTii09qC0KTRxvCzfK8NO5rkXiqtcsTbskvNE8MRnMSQuCfgAClmPw6BUMdonvjCAR8pyTB0q9RzUTXLAv2+2jmo09dhTqhpWDxQ9TeQdyH88ATq7Zi2h+0w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yvhDDtxMkPbg2jNe02Wu42VkpULzJmgbg7z+jUGBhqg=; b=BCI6yvmMx8ldS+22DYuDJOIc6par8Dbnq5cVeZu6ljIMLBhddcsk4ofLT9c+c0/tsrvVea5gIqq5eTY6vgM7SKimZHW0Q7XsVD43i7US7HkduuO71QtD+TTR6jPhMmfOBsnP0zERxx6uLxL5HP+gPb3YHZtX3eK8HoltZXwlLxVvkt8mGQKbvqrOMxyLZhTyXZKXRbuvxSDG+sOBSoULh3Wb9Xc43ObFNqt2cnjcgjMa5Gl2Frth+wBgGV1MXjwtWQqjPmPI8hq4mxudZmx6koDAyjq9hfjgGU/AzX5UnlkUVmEaM8Nha20rillkTKhFRDWF+QwHkOPn6utUBed4Eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN0PR04CA0067.namprd04.prod.outlook.com (2603:10b6:408:ea::12) by BN6PR02MB2835.namprd02.prod.outlook.com (2603:10b6:404:fc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:06:43 +0000 Received: from BN1NAM02FT057.eop-nam02.prod.protection.outlook.com (2603:10b6:408:ea:cafe::e4) by BN0PR04CA0067.outlook.office365.com (2603:10b6:408:ea::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:06:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT057.mail.protection.outlook.com (10.13.2.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:06:43 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:06:41 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:06:41 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZciO-000CCQ-Mi; Wed, 30 Mar 2022 11:06:41 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 02/19] virtio-vdpa: don't set callback if virtio doesn't need it Date: Wed, 30 Mar 2022 23:33:42 +0530 Message-ID: <20220330180436.24644-3-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 11e8b4a4-418a-4fc4-6e86-08da12780ede X-MS-TrafficTypeDiagnostic: BN6PR02MB2835:EE_|SN1NAM02FT0032:EE_|DM6PR02MB6921:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FnNoH6xZgDxz+wrkX5K3pES2GThteypEwrouT2lMdCnuFmBQcQU2Y31aCLhNFZ+2ovl/9dlG/apiwNXXaxWrs38bBr7QrPIR+kZUgB6mFrk1Wz1pPQhpXTWojE74oNMQBbBR3lgxavaeWnBvPVls0gL2qaXuMzp5XkfCBknnHAs/me6Tuc9QOWN9odgElda3KtV5uHPYzM6IRKGMOl+Y4Kpcxt0XLBOT18E4KN8e71TQyK3KLkz9ZPuIF2t+BTb0wZtLsjfSjJmqxvsn4Vx1+/YA2y9WW8LfPLnqjikRzSmnsge32pg6yxrqa1zFyERLoTAWotoT5JnSmfqAStVudLpWrmZRYMWb8/+czH02o6umgt/lvX/AVVAtGjZ5TdkTN9Bq69l6noppUoGEN79o58dEkHkTgvpNuJ3+PSBOSM2QUpIul/I9LcrwGtdBANbHxSTgIHjUmi4kkeTbZGy6fNKWRbPJYtyIUgr/IoLIx4Jkdv+0KNET0SRFRMi8/hphmdzMN9BMUNJzg2HIhNYxU5z1NHLn/xqyAntlJ+OPWvyIk+unlZBizGAmCYKtjFzmILoJ4WH7ojIiaKj3UXqqhOAtgiBdOUFiUM8hMP+puKtPQkd4AQzMFHO0LasqLFugTpUF4rwZ7/LZzQO/CN2O8HZ3sqihWxKsU/Ab50qlG8348PWXPx/JmIxanDWLbGcyqvrREo2SAIf3VrKrF9jR2g== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(26005)(186003)(7636003)(4326008)(83380400001)(47076005)(426003)(336012)(356005)(2616005)(7416002)(36860700001)(5660300002)(8936002)(9786002)(4744005)(44832011)(1076003)(8676002)(70586007)(508600001)(36756003)(2906002)(7696005)(40460700003)(110136005)(54906003)(82310400004)(316002)(70206006)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB2835 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0032.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b883bca1-1a78-48d7-47b2-08da12780c48 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /tZHUzJbldErK1z+HdaJKNO4gyiVhxFZGaSaU1yAiWWABe4DfTlcFlafIbITPeXrnhaKDq9S+RdRqZ/45saFgvmpeZMLeU7zzPnjoRQ1JmuR4R2AgLuTDtkjNPjXIsuHiYmkThlTXp2/ZFWed7VK/ftdh2Eua5ou8TXl7MXSq9RhX0VnvCEjq+I9Z1o4rWSMkdXXeZYZin1VY8/+luVzww98P6akofjZNcHQBEcF3smUdxjg51KDVRKZKX5ttYxWhdZz22Dy4DkBvgQAcD0UToth6yIIPISStrtJ5yzsTg9dzS0n99VmIjSCx1vMHz2Xb1AhXuYjvSWlSO1tIMlIgNci2HYK0Zrs7JdkEmPYQ8xMe8fG4AclTANu+cMnBTknv9nYsRJkqkLxwbaPv55YtVtsdzU8NoOMM5QDxaD8Xz+hLCfW3qmqzGACTXfFKXs8ksFatBQ2ewyc0ra6o6ogLLlzUUu0rYXxk4zCoOcKAQiAEAVDnkSbiG+mqRz17nXS6wIriK1iK9S5cr1nxrYUjqB5xvt7TpqUEpKHBAjMwYT9d/RuFEmvFaU6VndpopQrQt6KkgHacFNHD0GoYyfwm3N0k3eP7qE4Zv2LK/rQHJ0QtVvo9ALKBQAX1ITiIG6GaBbak3+hiJa8OMKfOa6/0ojMrVVbipU3AjBuTl1AG/9KcxQFNkHB+bn1LKBZxpVxyIcf7pndH74bA7lNfMH9lrirjswvVkTy2zFW87JAGGM= X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(40460700003)(186003)(26005)(83380400001)(36756003)(426003)(70206006)(81166007)(2616005)(1076003)(336012)(9786002)(316002)(110136005)(47076005)(8936002)(5660300002)(7416002)(4744005)(36860700001)(54906003)(82310400004)(2906002)(4326008)(8676002)(508600001)(44832011)(7696005)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:06:47.9774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11e8b4a4-418a-4fc4-6e86-08da12780ede X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0032.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6921 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org There's no need for setting callbacks for the driver that doesn't care about that. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/virtio/virtio_vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index 76504559bc25..46c71653f508 100644 --- a/drivers/virtio/virtio_vdpa.c +++ b/drivers/virtio/virtio_vdpa.c @@ -184,7 +184,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, } /* Setup virtqueue callback */ - cb.callback = virtio_vdpa_virtqueue_cb; + cb.callback = callback ? virtio_vdpa_virtqueue_cb : NULL; cb.private = info; ops->set_vq_cb(vdpa, index, &cb); ops->set_vq_num(vdpa, index, virtqueue_get_vring_size(vq)); From patchwork Wed Mar 30 18:03:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E411C433F5 for ; Wed, 30 Mar 2022 18:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349758AbiC3SJ3 (ORCPT ); Wed, 30 Mar 2022 14:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349739AbiC3SJW (ORCPT ); Wed, 30 Mar 2022 14:09:22 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A2337033; Wed, 30 Mar 2022 11:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x5N+DzVfLymIpkC0kdTUOxGNTtMH4HbnDMMHFXJ5OwM=; b=QIMkz2EcOF8O+dVGp7+kLzrL1VxGMYvcsBRafYm3Cu46/CcV5YGV0zxx4GozF7LiXsSklZ4ClWiyQzwyiv/JEO3FUyELBxoCXx80pBng4cERWD6UCQnc7BqtXgyM43cGQZiS5PPt+6L7ALfw/Gr1PCbitYhOIeFvBbDKWVLG6iA= Received: from DS7PR07CA0011.namprd07.prod.outlook.com (2603:10b6:5:3af::22) by SJ0PR02MB8433.namprd02.prod.outlook.com (2603:10b6:a03:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 18:07:27 +0000 Received: from DM3NAM02FT019.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3af:cafe::c3) by DS7PR07CA0011.outlook.office365.com (2603:10b6:5:3af::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:07:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT019.mail.protection.outlook.com (10.13.4.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:07:26 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 2CB4241D82; Wed, 30 Mar 2022 18:07:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bSpXAY9fOUNEJfYY3ZwRyi18enjcKK7ihqXY/GoOijwKP6Y6QOxU6xnuym1qaAqoYpAF+tdIf0GwqeCfTEUuQo7CbLOMEl4AnNhQ7/e/PaK6esRp0FCEVM10yM/Zm567vyqL26xu4qz/JphgsTJHC7YBJR1xAm4rHBb0fDUwAPVEMYJmTiDh5wD57Fay1trBIIbW15oIVkyQ/thW0ZoMRKyZ9ZxmYLAIyTRuOM/4ft+AU/IEaNL0wUlbVt5qkHL4I6keLcSEyuECU5BE/DglGtM/ckpqknj3uxHg38ihBxVigAj3CUIIVQ/xo3pzAq7sacxjV0f4AHSDBloJiRbi5w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x5N+DzVfLymIpkC0kdTUOxGNTtMH4HbnDMMHFXJ5OwM=; b=EIIVnG2i+2nBN1eq8eRbDhhCXT/rKmPA+I+y0GKgwxc5eHaJ5Iu3LAQReHb7h6jOCbvPQcrkqklcV6e6Qr6ToDvx/Df1QL7j9bGEPxbOlagQmwPZIl7mRq+Iw2AXmTeJavbvvlkHiHBMAHpR35vnxWEGpK+gzYjC2J7rY5Kqgh289J2BBMVLpzf8DShXeMr6nj1nHAkjSBLS4ISfaDcAgz7pTi/cEpKiw3tmFnAc+0gbXoKhq1bzS/fUDC4GPtiiidSZpEGJWOBjyzcge7aqHWmNIzFApO5ry4YNiYh1yLRVVSavKxPgIxzEe53B8SDTBhjOr4yFwqkJrYgQ4nNDJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN0PR03CA0033.namprd03.prod.outlook.com (2603:10b6:408:e7::8) by SJ0PR02MB8420.namprd02.prod.outlook.com (2603:10b6:a03:3f5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 18:07:24 +0000 Received: from BN1NAM02FT008.eop-nam02.prod.protection.outlook.com (2603:10b6:408:e7:cafe::bb) by BN0PR03CA0033.outlook.office365.com (2603:10b6:408:e7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:07:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT008.mail.protection.outlook.com (10.13.2.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:07:24 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:07:22 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:07:22 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcj4-000CCQ-Cz; Wed, 30 Mar 2022 11:07:22 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 03/19] vhost-vdpa: passing iotlb to IOMMU mapping helpers Date: Wed, 30 Mar 2022 23:33:43 +0530 Message-ID: <20220330180436.24644-4-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 19f15fd6-7c90-4a40-adae-08da127825e1 X-MS-TrafficTypeDiagnostic: SJ0PR02MB8420:EE_|DM3NAM02FT019:EE_|SJ0PR02MB8433:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: eK/94eGXR9FXtBBEMxjeJdkyjOpD+feO0t+3KM6G8qE3QAVOQUAULGEknBKSb/3GkgMnfcAAJ7ZECyNA0G44+xkmHg9rG6wN8Q3Iex1sZ2iuZPH2MspQck3T3o2kQYDTb05TY71XlGWFRxbdWrIPvA3t2TwgsyEU+CoZ2s7T8LkTxZh0unIiUVthqVJYdeoJioL1BApgrwOrndoUdh5OOsM5F1ZB2xQt41div0xPgXNs+qPGsk64Q1DKz5cKsFm7nWWLpcEryneV+sXWC898bWJxvsMNVxTEEfu7q1sNJ6ylbCL4fK6Imf00YwEm7zONUKJjMmLSsh7nZ7uQRLRP/G4ij3a3ah4WGnboxcC1D+96Fry5tpVh4GTy9bv6HMr0k8DkSNbt1F762AJD6mSbYsnrDXpRZKTBm1B6px1NdjRCuy2hQDULQdTwyAcJhMRHhv8wY7PWyx10Q9/+h05vGYXw4UZS0VlCUYNaGNX7dUJJ2sgr+8GOzmBPRKSEL0m/f8P45C7joGJvjgwqJmrxzcQ6DeS7Mn/7SE2fgpnWx/ooLPLB/QR1PDhgbJRrzs+RRdTokkCjoVmWNe6mhO0NmmOwZTdE/3GSSX8hz4DcfJuOQ/vyha/5zLbQHYBNkOr4kTsTQ6Lwj7jXUbidQY1+89eB9RwBqPPy4MBAs1Ibp0hTYUpDqRSZVl9cUp4Mu8y2RahcvdJW04WJ57Lwpt3gtA== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(44832011)(7696005)(82310400004)(426003)(7416002)(36756003)(36860700001)(8936002)(110136005)(47076005)(6666004)(5660300002)(9786002)(26005)(186003)(336012)(2906002)(54906003)(356005)(40460700003)(1076003)(2616005)(508600001)(70586007)(4326008)(8676002)(7636003)(316002)(83380400001)(70206006)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB8420 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT019.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dab99898-a346-4dc1-c107-08da12782482 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xfKsWGv9s9mdxlNlm93Ia0DgTvA9XfCT6yhWLD/h6/fgfHDOd6eDIOl0R1px4+/GpLGTZ6ku9CIM89a6w4knYiHxl/EER2S45ADBz+McVSDacc3Yx068WA202AByCBeLIg9pNXvxYRQf1uI3PE8a01UwBjw/WotTqHnqfvCWyn/FgaiBCS8goB8MU2kG/bBOL9nm5MbwctTJF14RKC030mqQO1aXtsb5X+M5Ij1qcT3E3Yux+9UEYam5jsfHqkZIbX/0sPVY0d+oaB2V/IBulQZGHICz9JWCSsPdCarCX0vGteoiC3xu2VBbynRlHoul++jIP69nIIV9jiCYz7QLn+MYQ9QWIv4soneVs8nB8f1XfuH7bh7HwyjWFZykJq/F5QWPVB/A3i/p2ui818ZTKkSCHWAihRc/OBCkEX2rFsllOB+xccOhEvt0HPgXeaSRLUQCmXHOCk99KijCQTOW9fO4Jc72uxw3vOBA14TfoWf8eBsw7Gfnx4wJRPfN3lSrmUkrFGJXDELVSmBYJzgtsr+ZP5HMNTeA/EMAwQ+ohngW/Uz7o7uC6nNe7xx/J4PnNUWrMqq6qFHrI8GjcvT4Kfkpl48CsF7DNE24mJOh+UmNWyrIKZnPtG0awHpEwcd/i5FQzzhbx1uhf0p/o0keJn3MSYzEHpBeU9RvagAWkixHfpVjbDZQx6s/Lyuy85nh0K+fed4JUgO+0qmOZw+nvTeUesC6I57KheG+0v+GnEoweIvI86Fu2VPFItqd1RvD X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(336012)(426003)(1076003)(2616005)(26005)(186003)(6666004)(7696005)(81166007)(7416002)(5660300002)(8936002)(44832011)(9786002)(40460700003)(36860700001)(508600001)(316002)(47076005)(82310400004)(36756003)(83380400001)(2906002)(70206006)(54906003)(110136005)(8676002)(4326008)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:07:26.6175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19f15fd6-7c90-4a40-adae-08da127825e1 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT019.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB8433 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org To prepare for the ASID support for vhost-vdpa, try to pass IOTLB object to dma helpers. No functional changes, it's just a preparation for support multiple IOTLBs. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 67 ++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 4c2f0bd06285..6d670e32e67b 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -537,10 +537,11 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, return r; } -static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, u64 start, u64 last) +static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, + u64 start, u64 last) { struct vhost_dev *dev = &v->vdev; - struct vhost_iotlb *iotlb = dev->iotlb; struct vhost_iotlb_map *map; struct page *page; unsigned long pfn, pinned; @@ -559,10 +560,10 @@ static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, u64 start, u64 last) } } -static void vhost_vdpa_va_unmap(struct vhost_vdpa *v, u64 start, u64 last) +static void vhost_vdpa_va_unmap(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, + u64 start, u64 last) { - struct vhost_dev *dev = &v->vdev; - struct vhost_iotlb *iotlb = dev->iotlb; struct vhost_iotlb_map *map; struct vdpa_map_file *map_file; @@ -574,21 +575,24 @@ static void vhost_vdpa_va_unmap(struct vhost_vdpa *v, u64 start, u64 last) } } -static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, u64 start, u64 last) +static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, + u64 start, u64 last) { struct vdpa_device *vdpa = v->vdpa; if (vdpa->use_va) - return vhost_vdpa_va_unmap(v, start, last); + return vhost_vdpa_va_unmap(v, iotlb, start, last); - return vhost_vdpa_pa_unmap(v, start, last); + return vhost_vdpa_pa_unmap(v, iotlb, start, last); } static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v) { struct vhost_dev *dev = &v->vdev; + struct vhost_iotlb *iotlb = dev->iotlb; - vhost_vdpa_iotlb_unmap(v, 0ULL, 0ULL - 1); + vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1); kfree(dev->iotlb); dev->iotlb = NULL; } @@ -615,15 +619,15 @@ static int perm_to_iommu_flags(u32 perm) return flags | IOMMU_CACHE; } -static int vhost_vdpa_map(struct vhost_vdpa *v, u64 iova, - u64 size, u64 pa, u32 perm, void *opaque) +static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, + u64 iova, u64 size, u64 pa, u32 perm, void *opaque) { struct vhost_dev *dev = &v->vdev; struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; int r = 0; - r = vhost_iotlb_add_range_ctx(dev->iotlb, iova, iova + size - 1, + r = vhost_iotlb_add_range_ctx(iotlb, iova, iova + size - 1, pa, perm, opaque); if (r) return r; @@ -632,13 +636,13 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, u64 iova, r = ops->dma_map(vdpa, iova, size, pa, perm, opaque); } else if (ops->set_map) { if (!v->in_batch) - r = ops->set_map(vdpa, dev->iotlb); + r = ops->set_map(vdpa, iotlb); } else { r = iommu_map(v->domain, iova, pa, size, perm_to_iommu_flags(perm)); } if (r) { - vhost_iotlb_del_range(dev->iotlb, iova, iova + size - 1); + vhost_iotlb_del_range(iotlb, iova, iova + size - 1); return r; } @@ -648,25 +652,27 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, u64 iova, return 0; } -static void vhost_vdpa_unmap(struct vhost_vdpa *v, u64 iova, u64 size) +static void vhost_vdpa_unmap(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, + u64 iova, u64 size) { - struct vhost_dev *dev = &v->vdev; struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; - vhost_vdpa_iotlb_unmap(v, iova, iova + size - 1); + vhost_vdpa_iotlb_unmap(v, iotlb, iova, iova + size - 1); if (ops->dma_map) { ops->dma_unmap(vdpa, iova, size); } else if (ops->set_map) { if (!v->in_batch) - ops->set_map(vdpa, dev->iotlb); + ops->set_map(vdpa, iotlb); } else { iommu_unmap(v->domain, iova, size); } } static int vhost_vdpa_va_map(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, u64 iova, u64 size, u64 uaddr, u32 perm) { struct vhost_dev *dev = &v->vdev; @@ -696,7 +702,7 @@ static int vhost_vdpa_va_map(struct vhost_vdpa *v, offset = (vma->vm_pgoff << PAGE_SHIFT) + uaddr - vma->vm_start; map_file->offset = offset; map_file->file = get_file(vma->vm_file); - ret = vhost_vdpa_map(v, map_iova, map_size, uaddr, + ret = vhost_vdpa_map(v, iotlb, map_iova, map_size, uaddr, perm, map_file); if (ret) { fput(map_file->file); @@ -709,7 +715,7 @@ static int vhost_vdpa_va_map(struct vhost_vdpa *v, map_iova += map_size; } if (ret) - vhost_vdpa_unmap(v, iova, map_iova - iova); + vhost_vdpa_unmap(v, iotlb, iova, map_iova - iova); mmap_read_unlock(dev->mm); @@ -717,6 +723,7 @@ static int vhost_vdpa_va_map(struct vhost_vdpa *v, } static int vhost_vdpa_pa_map(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, u64 iova, u64 size, u64 uaddr, u32 perm) { struct vhost_dev *dev = &v->vdev; @@ -780,7 +787,7 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, if (last_pfn && (this_pfn != last_pfn + 1)) { /* Pin a contiguous chunk of memory */ csize = PFN_PHYS(last_pfn - map_pfn + 1); - ret = vhost_vdpa_map(v, iova, csize, + ret = vhost_vdpa_map(v, iotlb, iova, csize, PFN_PHYS(map_pfn), perm, NULL); if (ret) { @@ -810,7 +817,7 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, } /* Pin the rest chunk */ - ret = vhost_vdpa_map(v, iova, PFN_PHYS(last_pfn - map_pfn + 1), + ret = vhost_vdpa_map(v, iotlb, iova, PFN_PHYS(last_pfn - map_pfn + 1), PFN_PHYS(map_pfn), perm, NULL); out: if (ret) { @@ -830,7 +837,7 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, for (pfn = map_pfn; pfn <= last_pfn; pfn++) unpin_user_page(pfn_to_page(pfn)); } - vhost_vdpa_unmap(v, start, size); + vhost_vdpa_unmap(v, iotlb, start, size); } unlock: mmap_read_unlock(dev->mm); @@ -841,11 +848,10 @@ static int vhost_vdpa_pa_map(struct vhost_vdpa *v, } static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, + struct vhost_iotlb *iotlb, struct vhost_iotlb_msg *msg) { - struct vhost_dev *dev = &v->vdev; struct vdpa_device *vdpa = v->vdpa; - struct vhost_iotlb *iotlb = dev->iotlb; if (msg->iova < v->range.first || !msg->size || msg->iova > U64_MAX - msg->size + 1 || @@ -857,10 +863,10 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, return -EEXIST; if (vdpa->use_va) - return vhost_vdpa_va_map(v, msg->iova, msg->size, + return vhost_vdpa_va_map(v, iotlb, msg->iova, msg->size, msg->uaddr, msg->perm); - return vhost_vdpa_pa_map(v, msg->iova, msg->size, msg->uaddr, + return vhost_vdpa_pa_map(v, iotlb, msg->iova, msg->size, msg->uaddr, msg->perm); } @@ -870,6 +876,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; + struct vhost_iotlb *iotlb = dev->iotlb; int r = 0; mutex_lock(&dev->mutex); @@ -880,17 +887,17 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, switch (msg->type) { case VHOST_IOTLB_UPDATE: - r = vhost_vdpa_process_iotlb_update(v, msg); + r = vhost_vdpa_process_iotlb_update(v, iotlb, msg); break; case VHOST_IOTLB_INVALIDATE: - vhost_vdpa_unmap(v, msg->iova, msg->size); + vhost_vdpa_unmap(v, iotlb, msg->iova, msg->size); break; case VHOST_IOTLB_BATCH_BEGIN: v->in_batch = true; break; case VHOST_IOTLB_BATCH_END: if (v->in_batch && ops->set_map) - ops->set_map(vdpa, dev->iotlb); + ops->set_map(vdpa, iotlb); v->in_batch = false; break; default: From patchwork Wed Mar 30 18:03:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46047C433FE for ; Wed, 30 Mar 2022 18:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349708AbiC3SKi (ORCPT ); Wed, 30 Mar 2022 14:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349712AbiC3SKg (ORCPT ); Wed, 30 Mar 2022 14:10:36 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2055.outbound.protection.outlook.com [40.107.223.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4DBDCD; Wed, 30 Mar 2022 11:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SP6ojcmP4JQ0BjSsfSCAtKPMgUZ/gwQ5cS2KSCB/JtU=; b=Kc1Bh0jRsi0DesxB35czYbCMrxUQvkWwU0jWaxDN5acEmXwyiiEgGQYdZcMWN474DW9fRu3mBQ/8xElK/IQBsSJddTdBHbaxcIZ1SpiGtQ0C3KCgcNxzCsJRIe2ewO/rHrNr1qFozYHzocoYGcv2NndBQFnTxnOatQPfVeroapw= Received: from SA9PR13CA0005.namprd13.prod.outlook.com (2603:10b6:806:21::10) by CH0PR02MB8210.namprd02.prod.outlook.com (2603:10b6:610:f3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Wed, 30 Mar 2022 18:08:44 +0000 Received: from SN1NAM02FT0040.eop-nam02.prod.protection.outlook.com (2603:10b6:806:21:cafe::f4) by SA9PR13CA0005.outlook.office365.com (2603:10b6:806:21::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.12 via Frontend Transport; Wed, 30 Mar 2022 18:08:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0040.mail.protection.outlook.com (10.97.5.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:08:44 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2048.outbound.protection.outlook.com [104.47.74.48]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 86CE53F02B; Wed, 30 Mar 2022 18:08:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IJdIjFAexsXxhVmzxtZ43YA3f8cn/T6wIbJ0hFKGqWlMrtAXE59cZZ+kTWOvKiQgyPAMIb3YwcNZ/imjs9FK/nOZ09k2hZJv8dtiFC/rz2RB2r+zEV3A199tIgUEggJOtPqheiMFyP1csGAtFeU2rhOBF4gWmsRPZxEdEGaYILpsDgCNPPrXYRRr9LaGNZRlxSBWEI7AQb0nQK3n96PdE8jhfm982SLO/1kluwI6jeZXHhaqnlheacmpprc3kpAKVLivhW8pWawrDMlBjJSVulUh7k0p8Xe80PR3OnajX87K79+Mx4kAA/yZub6mCt7X2V4lczsggpSGi9lk16t04w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SP6ojcmP4JQ0BjSsfSCAtKPMgUZ/gwQ5cS2KSCB/JtU=; b=PKg8mkr27MQ8E7lGPYg2l9A97pqyaqVXD5Q1hEjHm2tQh3LEJds8qmXRix14GHEqH5/ew/Q/fpn5Ql8KrmiHCj5lvWD606bZY6qcG1+nK277MFd6xa8tPCI6gesZpCxbnYNbhtpIBifa4mOUuPwcFYaREZE0kz6DfcFUzloGtgJX6F96RcUQBCabOtKGrEUc3wMtiv4QbotFQmGLNIn3aWn65e7MjsRUuC4sYEdZMBQWqS/nvDFlJnhZtu2/e0zD85y94IjuUmuxT/2MWRADlnK1hGJyRf5SV+UGiDT2I68UbJsvJRKWBrZHEBKQS+lWuiBqJ7KWBJHCp3nwTs9DlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from DM5PR07CA0027.namprd07.prod.outlook.com (2603:10b6:3:16::13) by DM6PR02MB4908.namprd02.prod.outlook.com (2603:10b6:5:13::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:08:10 +0000 Received: from DM3NAM02FT054.eop-nam02.prod.protection.outlook.com (2603:10b6:3:16:cafe::7) by DM5PR07CA0027.outlook.office365.com (2603:10b6:3:16::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:08:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT054.mail.protection.outlook.com (10.13.5.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:08:10 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:08:07 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:08:07 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcjm-000CCQ-Jv; Wed, 30 Mar 2022 11:08:07 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 04/19] vhost-vdpa: switch to use vhost-vdpa specific IOTLB Date: Wed, 30 Mar 2022 23:33:44 +0530 Message-ID: <20220330180436.24644-5-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: c453c91c-55ba-44fe-80d5-08da1278541c X-MS-TrafficTypeDiagnostic: DM6PR02MB4908:EE_|SN1NAM02FT0040:EE_|CH0PR02MB8210:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TrScQRry2Kjd8QEuD7N6C6kWZwb4e7ppFwFN9L3Wo+RIamYsX6iqxWTEjjXPMSA4XXe7f0sL0db2xwoqju/BPDEpWZ76O3WIA/KsUY36bjdFAEMpfrHSt09gnqbMtFkWSNbxL5zDQ8XVOH9Bg+NgTHMDWPNNdLn6UsBtj2RN6NOgy1L4oybnm6D9zCIPUXpC1HY/l8W40tbmrvR/pmxAuHKGgovOBKl36sshsR2cKRM2KYklo6p9xQAbSV4tGifBDnYlpIvJ3GI+Ij24OosmbIFqQ7DwljfKkhDPj4Rfn7cSedXGNHrltrWatVEl646H8YxdkEQ/OUjRX7f6bt4p1dRmvmis2MtwxHmEQMzg6jRYrssXHIQYbE1t7XGa/BAefxKhbxi24O6mjpj0coiMz3AoqvlSyLRwZ9n0fdlcUUbd128GBZ/psW5/3BIMdEb7fw+AUuFdwvFEZNrCZd5HVXm7/pPNOiwlIA+ICJmjoomJq+2/h6qMniK2EHCBHfV8uFbLvJmH0V420Tqg5kDKTx8NEkLpN6VjjGLGSddFCcC2dMAvoIjVXK55A4hNNnNmZc5q0VUB6KJGsX+DjYxhHzaslJcnVfFaPFT4DqAFyJ318mIFOc5/qlH+an1xe/J6SWijwx+HgOdoiy+amUO9Pj0LVrp6mEiJh5X85RQzoxvMcMOvzSIcJz30CERzJANTiZs+PBv+ui9A3QqJgjejeA== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(8676002)(4326008)(82310400004)(7696005)(508600001)(6666004)(70586007)(70206006)(316002)(54906003)(110136005)(426003)(83380400001)(36860700001)(40460700003)(47076005)(336012)(8936002)(7636003)(44832011)(2616005)(1076003)(26005)(186003)(36756003)(356005)(9786002)(7416002)(5660300002)(2906002)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB4908 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0040.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 704fa12a-e56c-4a4e-f542-08da12784004 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XbwQhQoy1Tz3Ww/TLNWltrR+7BqCaGAW76PwwXwuLmymldTRpY4Ts3yIrzAgdfTuVxvDeDEImdscUkLEPacMIeW5DBjzribbEBJTkyXfm0HRfT7OXxNBLwWJOP/Fn8EW5QY/iO7+LhdUWtsO73myQDSC/0dZr1mnPk0+dsLE4krsa3ecezhOju3v+KFw2DUJeDsXn5bOwgIm72Z8YllcPeDstSId+5HyeseyGNERdbd6FGHuNk6tTm+3ataS59QLD5RxaayFGq34PWNLSm5J3yD7bvUGj8dpIFStxWWUbDruHQkc6IudJSezn7e2NcIOFTFLPpH0BCO0w9bgBBX1l0T7ciLkb750GdMPtSqXrZxh1IWeIpFuSdo6OVrxuOnY7ulU7Kljd07tyngnhuH5nVPqUOAyYvAkoM56GQSbtPmyyPDTLaDqdUO07Yhqvi2oFutFmgXzw3lSgrqV4YzwMzOi3BpSkKFeMT1DBkjTZAztF+qKv9dt3TTmaKKel54IDrRWx6I7pszZfXDlFUZyRD431Maty7erPky6R4s39ssXamkXveHYPo0Kjk2xu636kmT25CrGY+qY1hMYI7RofjDQjuOK5KvOwKX048386GTpC4h6CjyWrXm4Z5a1AVKri2ozGpk105nrvTabdsPReC/BRJ7Rt4ksHrvNUgAnDN//s1pDPxoc9GCKmPP3sOziN52yKdTd9F94q2BNAbRa++CXqU5B+MPOjlBTlB6FJVPrMFm+Na1wbypLnMTMxIhq X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(40460700003)(316002)(54906003)(83380400001)(110136005)(36860700001)(47076005)(426003)(336012)(8936002)(9786002)(4326008)(186003)(7416002)(70206006)(6666004)(36756003)(508600001)(5660300002)(81166007)(26005)(2616005)(1076003)(44832011)(2906002)(7696005)(8676002)(82310400004)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:08:44.1626 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c453c91c-55ba-44fe-80d5-08da1278541c X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0040.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB8210 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org To ease the implementation of per group ASID support for vDPA device. This patch switches to use a vhost-vdpa specific IOTLB to avoid the unnecessary refactoring of the vhost core. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 6d670e32e67b..632c43eb5ecf 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -39,6 +39,7 @@ struct vhost_vdpa { struct vhost_virtqueue *vqs; struct completion completion; struct vdpa_device *vdpa; + struct vhost_iotlb *iotlb; struct device dev; struct cdev cdev; atomic_t opened; @@ -589,12 +590,11 @@ static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v) { - struct vhost_dev *dev = &v->vdev; - struct vhost_iotlb *iotlb = dev->iotlb; + struct vhost_iotlb *iotlb = v->iotlb; vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1); - kfree(dev->iotlb); - dev->iotlb = NULL; + kfree(v->iotlb); + v->iotlb = NULL; } static int perm_to_iommu_flags(u32 perm) @@ -876,7 +876,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; - struct vhost_iotlb *iotlb = dev->iotlb; + struct vhost_iotlb *iotlb = v->iotlb; int r = 0; mutex_lock(&dev->mutex); @@ -1017,15 +1017,15 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false, vhost_vdpa_process_iotlb_msg); - dev->iotlb = vhost_iotlb_alloc(0, 0); - if (!dev->iotlb) { + v->iotlb = vhost_iotlb_alloc(0, 0); + if (!v->iotlb) { r = -ENOMEM; goto err_init_iotlb; } r = vhost_vdpa_alloc_domain(v); if (r) - goto err_init_iotlb; + goto err_alloc_domain; vhost_vdpa_set_iova_range(v); @@ -1033,6 +1033,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) return 0; +err_alloc_domain: + vhost_vdpa_iotlb_free(v); err_init_iotlb: vhost_dev_cleanup(&v->vdev); kfree(vqs); From patchwork Wed Mar 30 18:03:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF019C433F5 for ; Wed, 30 Mar 2022 18:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349712AbiC3SLP (ORCPT ); Wed, 30 Mar 2022 14:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234766AbiC3SLN (ORCPT ); Wed, 30 Mar 2022 14:11:13 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2067.outbound.protection.outlook.com [40.107.243.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E1543D492; Wed, 30 Mar 2022 11:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MwOoCnrVx3Vcm099wfgaMH25hE9Tb6K0lYqyxOZWrls=; b=YGFXWV2T/eXQH5DdwQU4rFaxNRcrY3TB1hi93OsarfIQFeXsooIauQcwzrSC5XZe7HRqgR2ky5RcNP3STjRACcZ5wvn9lYeYHggnYAPMzNj7a4kGbEmUChtsVMMXIyRpQnGvJL9O/WHozWrEsq257iusVEw4jFioNen33c6i9lM= Received: from DS7PR05CA0066.namprd05.prod.outlook.com (2603:10b6:8:57::11) by SN1PR02MB3711.namprd02.prod.outlook.com (2603:10b6:802:29::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Wed, 30 Mar 2022 18:09:25 +0000 Received: from DM3NAM02FT019.eop-nam02.prod.protection.outlook.com (2603:10b6:8:57:cafe::6b) by DS7PR05CA0066.outlook.office365.com (2603:10b6:8:57::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:09:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT019.mail.protection.outlook.com (10.13.4.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:09:24 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 3EB4341CDE; Wed, 30 Mar 2022 18:09:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aqEwNZQmQsjtiRye+0qSyCdSjibwPxro85/Yur7AAZwMbm7ngn581qah3fr85jQyLnrnXlze0tA9RIIoXVLsrcqXQsFjDkhdIXRo+tvMJh/MR3PsYrElNYiI3g2YmnicJsV0h6JwbZZDGElX3z2K7bzf9Ue0z29Q9JQB7mv9rR/Rfl8nA3boQyNoXSoMct2KyIrHz3y5oS1r0DirmHvaUO3ixjbPfXKxZrNVqNxJ5Q0g+izKq31bLAbYjpq1vranB35QJXPZHS+I4R/WWq0WOp0s7+icam9Yiimb0l9JtKDRPW8Qa6lKE1OKYgNbik3Y7uvg9sx90K0C9uk5+Ghpzw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MwOoCnrVx3Vcm099wfgaMH25hE9Tb6K0lYqyxOZWrls=; b=En1OgMrtflXlzmJUoXeXo3eY5jONoixSI75d0Vy38f18C05rP6InzHvEVCaCwJ3y2/dLAClwhnGdsKJdUwIbkh/Fl20t762Jn2doZ2ZH/7QNBBHHIZn5RxstmWbGtGPlwhDE7UUpbSW6uvQ7KKfZflZ+6oh0Is5xvjOSYa96kohRGM2hwPLSqbENE5hq3RV7PlzXPcWrQZZ0+0tzHK6fqnj99mEIThw/zuxyydS5vWoRylSovur7L+Nnvg11xngBIg8AQI9RcUmq0jhHu1JLyI2il/+z2Lk2N676cc4FpFZ/a0a53XqDXAdHSvAcTnrbg9q9NqqrQmiutxemrTKw4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from DM5PR07CA0033.namprd07.prod.outlook.com (2603:10b6:3:16::19) by PH0PR02MB8454.namprd02.prod.outlook.com (2603:10b6:510:100::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.16; Wed, 30 Mar 2022 18:09:21 +0000 Received: from DM3NAM02FT057.eop-nam02.prod.protection.outlook.com (2603:10b6:3:16:cafe::c6) by DM5PR07CA0033.outlook.office365.com (2603:10b6:3:16::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:09:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT057.mail.protection.outlook.com (10.13.5.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:09:21 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:09:20 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:09:20 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcky-000CCQ-Bf; Wed, 30 Mar 2022 11:09:20 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min , , , , CC: , , , , , , , , Subject: [PATCH v2 05/19] vdpa: introduce virtqueue groups Date: Wed, 30 Mar 2022 23:33:45 +0530 Message-ID: <20220330180436.24644-6-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 48860585-0813-46e2-22cf-08da12786c63 X-MS-TrafficTypeDiagnostic: PH0PR02MB8454:EE_|DM3NAM02FT019:EE_|SN1PR02MB3711:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FpPiosj1aGPHhS6kMT9Bi74w750KaD2UkXTQQum/JuFqoUusBo9r+6F+qzzOmG67lZsKARznjpxzLaVu5Qu8WS+41z34bWnm93tIibL03HYgLlRjwXmjWrcGBqMPi7fP9IGHLUINv7u5aY6EL9Ni5MjkAirPCSEJwNYpeFTaOaKmO/WF7pa5PBMCGcb9v3qgArL6C6zaWP2rsGoqjOTiDMPyXOEIik2vL5F/WO0c5oXR5njoczJWh30JVGdRvuu+L9j+GPg3NOmK7uaUvrZBFnQDW0PJ7cLBGsa8uyvEkYzqR4JyxqtxCYfBz/lrI05lTB+Fjs1ea+gKekw9ew7IQTfvVfjZryd4Ci107smVKJWeX8UQIVuMwhPuJ4TP28uW8FQl+O3ZATzTuGF1UtmzTbzZ+0z6+f3nxBhqSFEI/55xkytUQeSCbm5IW4zP5DwVtAcQXl35tssSXUvBTnI9JzYu07ifSyvWg2VShueUoK9NQGFYqytTclrI4wv9K27j56sdGTXewRNnFtpV1XJgwe0xeJd1Ir2hCOM4S+b8yUKxFhTvu8XgZsrUzHmXlPruILYEWiW0wPf2kVvSx4443+obvG7dozf/UtwHsqYRsbHm1GA2JQFHGIteZBptqqNnV+8tCQqRF52HQtzTDPTTfYMbXV/3FvFjQqe4yLPWaW7jgMsZVgBcXj4J2pZKyv2ek9EZauu525WNCdtW9dIaF9+XjGVIvhSnBM4Hq5c5ynM= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(83380400001)(2616005)(44832011)(186003)(9786002)(36860700001)(47076005)(426003)(7696005)(6666004)(336012)(26005)(1076003)(36756003)(30864003)(4326008)(82310400004)(110136005)(7416002)(5660300002)(40460700003)(70206006)(8676002)(508600001)(2906002)(316002)(70586007)(8936002)(54906003)(7636003)(921005)(356005)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8454 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT019.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9c9a1863-dbc8-4bca-9f5b-08da12786a50 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0VCbF2jdXoRRQYFMA29tbxwOC/SBcFNqw9610FGxM+MFTvTIWsLE0Y+AfzowCGLMc/iaGziISBZpPX0ZzTymaXyJQSb4tFeqtp6xnr4/JyOc/F+01hjCAWkFYuQlj/Meu7zmIvjcnZI9C5GMuNqkI1/i0MdzYpwPfVW24hLTvXnGPDdN476Y+IkwBz/2N6xfO7yNYJqVspcW/lCWiJ0pKQMJtJwxhVvuDQzjmswF7RA7Z2ctfu93c9KBd8UrLLzUw8Ie77e1EsgZAPkhcwdiAKm1Sk3oMpOFIuNuQP2ms6/5yBXLeVfaNs1BjFbSN44eLPF8vApl+89UgcMRwnrpt9FDLO3yjEqDZ3q2LLXYezdOPx5ObwjLKVavkZBbI+rzi2+cXGL95IFE2qP2Uv4xFdlLXk38+ixaRBPl2gvq3bFTyr/DPsx2rDr1LYe5TK18aZcvgNcYIrL2Yszr1XZd4DuMT0pXxoO9FWTqSmfW2hhJ+s0wstWjU26sS/1/66ewnM+5bS2yY3yADT76fSSdW8UKZf+RaXY9NkCVHdm2vgue4zs+0angaZ19HHKVJ19AObBPyy7SYaTtndvJvOacxkc1Tk+nzAyqSiY4mqu/cF5wNnu13SdJOen0t0AcyWVfJqQzBiuNvc08pEbWvVCY2gyDeZ0SRS3q8fo5VO6IRoMFrtBAF1aPvodUZPPbgqwNI7G2kL4H7Fo9VBQUWHpL8opuQuWw60paU+7DzL8b7JoXzC3T6AiA74ov1UV01tq/z4mdVVgQpZIsssK29eMSkg== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(7696005)(6666004)(47076005)(36860700001)(508600001)(5660300002)(921005)(8936002)(26005)(30864003)(44832011)(7416002)(1076003)(336012)(2616005)(186003)(9786002)(426003)(82310400004)(2906002)(40460700003)(36756003)(4326008)(8676002)(70206006)(81166007)(83380400001)(316002)(54906003)(110136005)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:09:24.8908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48860585-0813-46e2-22cf-08da12786c63 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT019.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR02MB3711 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch introduces virtqueue groups to vDPA device. The virtqueue group is the minimal set of virtqueues that must share an address space. And the address space identifier could only be attached to a specific virtqueue group. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vdpa/alibaba/eni_vdpa.c | 2 +- drivers/vdpa/ifcvf/ifcvf_main.c | 8 +++++++- drivers/vdpa/mlx5/net/mlx5_vnet.c | 8 +++++++- drivers/vdpa/vdpa.c | 3 +++ drivers/vdpa/vdpa_sim/vdpa_sim.c | 9 ++++++++- drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vdpa/virtio_pci/vp_vdpa.c | 2 +- include/linux/vdpa.h | 16 ++++++++++++---- 9 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/vdpa/alibaba/eni_vdpa.c b/drivers/vdpa/alibaba/eni_vdpa.c index f480d54f308c..3e93c5eb0cf9 100644 --- a/drivers/vdpa/alibaba/eni_vdpa.c +++ b/drivers/vdpa/alibaba/eni_vdpa.c @@ -470,7 +470,7 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) return ret; eni_vdpa = vdpa_alloc_device(struct eni_vdpa, vdpa, - dev, &eni_vdpa_ops, NULL, false); + dev, &eni_vdpa_ops, 1, NULL, false); if (IS_ERR(eni_vdpa)) { ENI_ERR(pdev, "failed to allocate vDPA structure\n"); return PTR_ERR(eni_vdpa); diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index 4366320fb68d..fde33e143246 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -626,6 +626,11 @@ static size_t ifcvf_vdpa_get_config_size(struct vdpa_device *vdpa_dev) return vf->config_size; } +static u32 ifcvf_vdpa_get_vq_group(struct vdpa_device *vdpa, u16 idx) +{ + return 0; +} + static void ifcvf_vdpa_get_config(struct vdpa_device *vdpa_dev, unsigned int offset, void *buf, unsigned int len) @@ -704,6 +709,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = { .get_device_id = ifcvf_vdpa_get_device_id, .get_vendor_id = ifcvf_vdpa_get_vendor_id, .get_vq_align = ifcvf_vdpa_get_vq_align, + .get_vq_group = ifcvf_vdpa_get_vq_group, .get_config_size = ifcvf_vdpa_get_config_size, .get_config = ifcvf_vdpa_get_config, .set_config = ifcvf_vdpa_set_config, @@ -758,7 +764,7 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, pdev = ifcvf_mgmt_dev->pdev; dev = &pdev->dev; adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa, - dev, &ifc_vdpa_ops, name, false); + dev, &ifc_vdpa_ops, 1, name, false); if (IS_ERR(adapter)) { IFCVF_ERR(pdev, "Failed to allocate vDPA structure"); return PTR_ERR(adapter); diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 79001301b383..89874624eb2a 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1910,6 +1910,11 @@ static u32 mlx5_vdpa_get_vq_align(struct vdpa_device *vdev) return PAGE_SIZE; } +static u32 mlx5_vdpa_get_vq_group(struct vdpa_device *vdpa, u16 idx) +{ + return 0; +} + enum { MLX5_VIRTIO_NET_F_GUEST_CSUM = 1 << 9, MLX5_VIRTIO_NET_F_CSUM = 1 << 10, MLX5_VIRTIO_NET_F_HOST_TSO6 = 1 << 11, @@ -2454,6 +2459,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = { .get_vq_notification = mlx5_get_vq_notification, .get_vq_irq = mlx5_get_vq_irq, .get_vq_align = mlx5_vdpa_get_vq_align, + .get_vq_group = mlx5_vdpa_get_vq_group, .get_device_features = mlx5_vdpa_get_device_features, .set_driver_features = mlx5_vdpa_set_driver_features, .get_driver_features = mlx5_vdpa_get_driver_features, @@ -2688,7 +2694,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, } ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops, - name, false); + 1, name, false); if (IS_ERR(ndev)) return PTR_ERR(ndev); diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 2b75c00b1005..946cc536078c 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -159,6 +159,7 @@ static void vdpa_release_dev(struct device *d) * initialized but before registered. * @parent: the parent device * @config: the bus operations that is supported by this device + * @ngroups: number of groups supported by this device * @size: size of the parent structure that contains private data * @name: name of the vdpa device; optional. * @use_va: indicate whether virtual address must be used by this device @@ -171,6 +172,7 @@ static void vdpa_release_dev(struct device *d) */ struct vdpa_device *__vdpa_alloc_device(struct device *parent, const struct vdpa_config_ops *config, + unsigned int ngroups, size_t size, const char *name, bool use_va) { @@ -203,6 +205,7 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, vdev->config = config; vdev->features_valid = false; vdev->use_va = use_va; + vdev->ngroups = ngroups; if (name) err = dev_set_name(&vdev->dev, "%s", name); diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index ddbe142af09a..c98cb1f869fa 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -250,7 +250,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr) else ops = &vdpasim_config_ops; - vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, + vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, 1, dev_attr->name, false); if (IS_ERR(vdpasim)) { ret = PTR_ERR(vdpasim); @@ -399,6 +399,11 @@ static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa) return VDPASIM_QUEUE_ALIGN; } +static u32 vdpasim_get_vq_group(struct vdpa_device *vdpa, u16 idx) +{ + return 0; +} + static u64 vdpasim_get_device_features(struct vdpa_device *vdpa) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); @@ -620,6 +625,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { .set_vq_state = vdpasim_set_vq_state, .get_vq_state = vdpasim_get_vq_state, .get_vq_align = vdpasim_get_vq_align, + .get_vq_group = vdpasim_get_vq_group, .get_device_features = vdpasim_get_device_features, .set_driver_features = vdpasim_set_driver_features, .get_driver_features = vdpasim_get_driver_features, @@ -650,6 +656,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { .set_vq_state = vdpasim_set_vq_state, .get_vq_state = vdpasim_get_vq_state, .get_vq_align = vdpasim_get_vq_align, + .get_vq_group = vdpasim_get_vq_group, .get_device_features = vdpasim_get_device_features, .set_driver_features = vdpasim_set_driver_features, .get_driver_features = vdpasim_get_driver_features, diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h index cd58e888bcf3..0be7c1e7ef80 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.h +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h @@ -63,6 +63,7 @@ struct vdpasim { u32 status; u32 generation; u64 features; + u32 groups; /* spinlock to synchronize iommu table */ spinlock_t iommu_lock; }; diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index f85d1a08ed87..4ee6850b9a68 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1495,7 +1495,7 @@ static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) return -EEXIST; vdev = vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev, - &vduse_vdpa_config_ops, name, true); + &vduse_vdpa_config_ops, 1, name, true); if (IS_ERR(vdev)) return PTR_ERR(vdev); diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c index cce101e6a940..e18dfe993901 100644 --- a/drivers/vdpa/virtio_pci/vp_vdpa.c +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c @@ -466,7 +466,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) return ret; vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa, - dev, &vp_vdpa_ops, NULL, false); + dev, &vp_vdpa_ops, 1, NULL, false); if (IS_ERR(vp_vdpa)) { dev_err(dev, "vp_vdpa: Failed to allocate vDPA structure\n"); return PTR_ERR(vp_vdpa); diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 8943a209202e..f7764e097bab 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -85,6 +85,7 @@ struct vdpa_device { bool use_va; u32 nvqs; struct vdpa_mgmt_dev *mdev; + unsigned int ngroups; }; /** @@ -172,6 +173,10 @@ struct vdpa_map_file { * for the device * @vdev: vdpa device * Returns virtqueue algin requirement + * @get_vq_group: Get the group id for a specific virtqueue + * @vdev: vdpa device + * @idx: virtqueue index + * Returns u32: group id for this virtqueue * @get_device_features: Get virtio features supported by the device * @vdev: vdpa device * Returns the virtio features support by the @@ -283,6 +288,7 @@ struct vdpa_config_ops { /* Device ops */ u32 (*get_vq_align)(struct vdpa_device *vdev); + u32 (*get_vq_group)(struct vdpa_device *vdev, u16 idx); u64 (*get_device_features)(struct vdpa_device *vdev); int (*set_driver_features)(struct vdpa_device *vdev, u64 features); u64 (*get_driver_features)(struct vdpa_device *vdev); @@ -315,6 +321,7 @@ struct vdpa_config_ops { struct vdpa_device *__vdpa_alloc_device(struct device *parent, const struct vdpa_config_ops *config, + unsigned int ngroups, size_t size, const char *name, bool use_va); @@ -325,17 +332,18 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, * @member: the name of struct vdpa_device within the @dev_struct * @parent: the parent device * @config: the bus operations that is supported by this device + * @ngroups: the number of virtqueue groups supported by this device * @name: name of the vdpa device * @use_va: indicate whether virtual address must be used by this device * * Return allocated data structure or ERR_PTR upon error */ -#define vdpa_alloc_device(dev_struct, member, parent, config, name, use_va) \ - container_of(__vdpa_alloc_device( \ - parent, config, \ +#define vdpa_alloc_device(dev_struct, member, parent, config, ngroups, name, use_va) \ + container_of((__vdpa_alloc_device( \ + parent, config, ngroups, \ sizeof(dev_struct) + \ BUILD_BUG_ON_ZERO(offsetof( \ - dev_struct, member)), name, use_va), \ + dev_struct, member)), name, use_va)), \ dev_struct, member) int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs); From patchwork Wed Mar 30 18:03:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A2BC433FE for ; Wed, 30 Mar 2022 18:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349805AbiC3SMe (ORCPT ); Wed, 30 Mar 2022 14:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349752AbiC3SM2 (ORCPT ); Wed, 30 Mar 2022 14:12:28 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2050.outbound.protection.outlook.com [40.107.100.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AAAE65D4; Wed, 30 Mar 2022 11:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EyixZqeyQvnvr2Bdft565badxBxC5+EO1EWET8/79pk=; b=bYOVaBS43TD7a6gQxH70eam/nd8QgTWq1zkeidtgbFWskTI8D+RjflAz+WLeXO1qu4APO2NFH79EEBMotNXRGjgC+zGkVZBw8mfTEw7ySt9DQqL/SBwfCXzrV62iWdmV7zv1UbwtJjOGoNDBdOKQ2kAUDtds3Zrv6LatWklCVf4= Received: from SA1P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:22c::28) by BL0PR02MB4610.namprd02.prod.outlook.com (2603:10b6:208:4b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Wed, 30 Mar 2022 18:10:39 +0000 Received: from SN1NAM02FT0052.eop-nam02.prod.protection.outlook.com (2603:10b6:806:22c:cafe::a8) by SA1P222CA0021.outlook.office365.com (2603:10b6:806:22c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:10:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0052.mail.protection.outlook.com (10.97.5.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:10:39 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2048.outbound.protection.outlook.com [104.47.51.48]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 34EEF42CBD; Wed, 30 Mar 2022 18:10:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QaZXgYZP39sQ+vOXZm0ZH0YiVx49hWMhBGLTfc4Dqw11kw0tHXdhtM+10v2Cuj1pEe926nM4qyqZX5DwkAJn4o8njf88E84bJHEj6GBmkmP6ZVnkGNh2vCWmgxYv0cRYJr958hCsq5A4Lyhz9Hp8O9DyPAfAm1+AuInn2C+Kjr9XkI+I3JhcVOdRVKA1poDN9xcy3pF4cGRPGpFZ2olxSI5HzO/rwiXpj9AwxqqO2IAmQy4A971HPZx3jiGRQ+ynZ9EeRsLEOTdAAtBIzsrRRdKFPpXCPqtBM8vUFeweyWuPT3ldyVEunKSGV5Y3btVIP7vWfEdUZsel8bkwtDFovw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EyixZqeyQvnvr2Bdft565badxBxC5+EO1EWET8/79pk=; b=ZQt5uqrIz2Ee+kr9rGxpN5FaWvQbjazpykmfJEyJGYBcyW3VaatteAs75yjZ3OpklRexxdij9buk/SzVwkOEEmkVMf49sij1oBnV6pHJmMjWV+pZ15+HNLn3CKW/LV44mwJb8Unp/pS8QCu6c0+O02wHK8wEgkTj2rGkL1eannzzPnGbNkSMBHyzTvBMwlv27WIPuhjGCFoflUzfgVyWV1sHN2jVBzB+VhxdIPJdZ4Fjv6ZWej7oGzSGCOwNCvQc74LCaI4/YaCrnhZ4jr1gXt7UKuNZLzk7C5k8CrbgQ3fv/hpCqg7kmujcnBX4tc9iwhRVrCnufJf9KfTNocyJHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from DS7PR03CA0071.namprd03.prod.outlook.com (2603:10b6:5:3bb::16) by BYAPR02MB5110.namprd02.prod.outlook.com (2603:10b6:a03:62::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.16; Wed, 30 Mar 2022 18:10:33 +0000 Received: from DM3NAM02FT010.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3bb:cafe::e3) by DS7PR03CA0071.outlook.office365.com (2603:10b6:5:3bb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18 via Frontend Transport; Wed, 30 Mar 2022 18:10:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT010.mail.protection.outlook.com (10.13.5.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:10:32 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:10:32 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:10:32 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcm8-000CCQ-1M; Wed, 30 Mar 2022 11:10:32 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min , , , , CC: , , , , , , , , Subject: [PATCH v2 06/19] vdpa: multiple address spaces support Date: Wed, 30 Mar 2022 23:33:46 +0530 Message-ID: <20220330180436.24644-7-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 403a3399-52f9-4a80-db99-08da12789893 X-MS-TrafficTypeDiagnostic: BYAPR02MB5110:EE_|SN1NAM02FT0052:EE_|BL0PR02MB4610:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5Utf/4ccupRfY7qapGhlL6Da2G+w/AXcubSXMzWEkpnFmul5vaXid6EpPECdZ56QfhwStnrXTYAM9QCMDOzNHQQf1HZJjLfQJOPDmlsWCrowFlM6lzMGxYOBDR3t4EaGct2taHEe8g0cvHLJbN/qMpNBi0YAZNbJuFxEOg0AIgw32qLXq/JEOJY7As67Y/N/Kra0oRPXVfTZk1j5L5Zn2LEKLzIO7LJB1ter+d5Qmbl5ssL0V1raEJ3hS3IiAYwOnvcrRCRs46l3c+MhoqFk/64MVbM2M+FscsgrT5oGIHpOtbXuCNNhklDb65QQ595WvsuU1HSXaKEtbBo1qop1MYx9vuSOBaSe3Qkxf1e8gP6QS4LMxZKXvE267uDhNyOc82Ll0PZNbkVoF0py81yIDF+epz43cD78cMhjLgZa3SvDNMSxZ93srIQVr3TFl49CgURHW65eb2tp07s/tos4lrxHzDF1TFT7QA9/9sc5DbJxwNSTo5sTuLqD0GRLyssERZGAw5YDMLTXEgXzgQEycFYWHzJAldv+OzLczF1+UBavxzOXtXQkPYPCUTB5tJn7MdM5xXMCEqx9fYcCzIqL0QOE0fAhbxUY47f7Gk3cOrmB+5MxXBCmfyg9pTwuIIywmPxyTyMXYWfGvt5tUrwAz4YWdsrDkEVgpDznvc8KXNK+Vea4DF6bdKRShLcbHpogfHU+poBJ51GQR7oxwPofXXi3LN35KCzi2jMaUAjDcyA= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(8676002)(26005)(70206006)(316002)(186003)(7696005)(47076005)(4326008)(921005)(356005)(70586007)(82310400004)(40460700003)(7636003)(36860700001)(5660300002)(6666004)(1076003)(54906003)(336012)(30864003)(44832011)(508600001)(426003)(2906002)(2616005)(9786002)(7416002)(8936002)(36756003)(110136005)(83380400001)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB5110 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0052.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 40f3b6c5-0d8d-4688-6d8a-08da127894f0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V8GIGNtyVaz/ldsxv7MfskfJrUShS7XN24Cd29iD6GBbqlcae9uz0DyRFIod7Kb6+oIoTNJJTBiVYr1CoyG9RICriTPzvown6CfZFZp8IJFCtV3HBRanBhkzvNUH/AE7U4+c0gvlZO/M0jHxLR83QkjSHPYSzS4iR8tqXhI+nr5F5OpOkYH1E2a3biXbfUmPPlBGXXHNlQs6+X52bImOhx2L6LxqkvDKM6iZCWP26EpqwrV1F6E0fYz1ZLuGqfBE4sgKeVXKM5ijMVXPbeIXUsm+m8U5UXGZsrvHZ36TKlL0OZk1/8XoQLt82u/p5NplhkzJgQvO1vHEIv9MWzkOA5i3RsIDl1tHcV5zYov6l5SSn58Go4ywa4bGxpMEmEoPQX0E22llOqYHX5cS9GqF/frxEGOVyjUPSB6Sk3g0g3GXLBOj7RAJyxR1WwcVRxBylW15602skAdsOmtSU3M5vKbzJjv7ydlLGFSmt9IQiOaPaZK/KfPqT+UbkHUmqVc3VRnQlqR61HSKReKVP9nVRnVybm1kLmHcQWXqJ5/NwOa41OJt++uG7ghiJ5XPveElLXjHymxvV3ukHvTh1EFhNjkFg/Mknwf6z5dOg0ZHlPKcODAGCcP+qgvjA+E9Jgx+j43esdHT4GIGl2QRA/C3eI0JHew0ixTgyvaH4/VgnkGz7jm64Lvx0GVmePj2N/BBLLNmz5RiIzBr2UdBzNKzMtyoABHq7H9SDVSLYz6U9yLPyeLTzKwLaJTxtnPorWL3KrYT/QVAmg+KReeE1kwnwA== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(70206006)(36756003)(8676002)(4326008)(81166007)(82310400004)(2906002)(40460700003)(36860700001)(921005)(44832011)(7416002)(47076005)(30864003)(5660300002)(7696005)(508600001)(186003)(2616005)(6666004)(316002)(8936002)(9786002)(54906003)(83380400001)(110136005)(1076003)(336012)(426003)(26005)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:10:39.0142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 403a3399-52f9-4a80-db99-08da12789893 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0052.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB4610 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patches introduces the multiple address spaces support for vDPA device. This idea is to identify a specific address space via an dedicated identifier - ASID. During vDPA device allocation, vDPA device driver needs to report the number of address spaces supported by the device then the DMA mapping ops of the vDPA device needs to be extended to support ASID. This helps to isolate the environments for the virtqueue that will not be assigned directly. E.g in the case of virtio-net, the control virtqueue will not be assigned directly to guest. As a start, simply claim 1 virtqueue groups and 1 address spaces for all vDPA devices. And vhost-vDPA will simply reject the device with more than 1 virtqueue groups or address spaces. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vdpa/alibaba/eni_vdpa.c | 2 +- drivers/vdpa/ifcvf/ifcvf_main.c | 2 +- drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 +++-- drivers/vdpa/vdpa.c | 4 +++- drivers/vdpa/vdpa_sim/vdpa_sim.c | 10 ++++++---- drivers/vdpa/vdpa_user/vduse_dev.c | 3 ++- drivers/vdpa/virtio_pci/vp_vdpa.c | 2 +- drivers/vhost/vdpa.c | 14 +++++++++----- include/linux/vdpa.h | 28 +++++++++++++++++++--------- 9 files changed, 45 insertions(+), 25 deletions(-) diff --git a/drivers/vdpa/alibaba/eni_vdpa.c b/drivers/vdpa/alibaba/eni_vdpa.c index 3e93c5eb0cf9..5a09a09cca70 100644 --- a/drivers/vdpa/alibaba/eni_vdpa.c +++ b/drivers/vdpa/alibaba/eni_vdpa.c @@ -470,7 +470,7 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) return ret; eni_vdpa = vdpa_alloc_device(struct eni_vdpa, vdpa, - dev, &eni_vdpa_ops, 1, NULL, false); + dev, &eni_vdpa_ops, 1, 1, NULL, false); if (IS_ERR(eni_vdpa)) { ENI_ERR(pdev, "failed to allocate vDPA structure\n"); return PTR_ERR(eni_vdpa); diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index fde33e143246..c1767a0ce630 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -764,7 +764,7 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, pdev = ifcvf_mgmt_dev->pdev; dev = &pdev->dev; adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa, - dev, &ifc_vdpa_ops, 1, name, false); + dev, &ifc_vdpa_ops, 1, 1, name, false); if (IS_ERR(adapter)) { IFCVF_ERR(pdev, "Failed to allocate vDPA structure"); return PTR_ERR(adapter); diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 89874624eb2a..85dc3e93758e 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2368,7 +2368,8 @@ static u32 mlx5_vdpa_get_generation(struct vdpa_device *vdev) return mvdev->generation; } -static int mlx5_vdpa_set_map(struct vdpa_device *vdev, struct vhost_iotlb *iotlb) +static int mlx5_vdpa_set_map(struct vdpa_device *vdev, unsigned int asid, + struct vhost_iotlb *iotlb) { struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev); struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); @@ -2694,7 +2695,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, } ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops, - 1, name, false); + 1, 1, name, false); if (IS_ERR(ndev)) return PTR_ERR(ndev); diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 946cc536078c..36be04621fb3 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -160,6 +160,7 @@ static void vdpa_release_dev(struct device *d) * @parent: the parent device * @config: the bus operations that is supported by this device * @ngroups: number of groups supported by this device + * @nas: number of address spaces supported by this device * @size: size of the parent structure that contains private data * @name: name of the vdpa device; optional. * @use_va: indicate whether virtual address must be used by this device @@ -172,7 +173,7 @@ static void vdpa_release_dev(struct device *d) */ struct vdpa_device *__vdpa_alloc_device(struct device *parent, const struct vdpa_config_ops *config, - unsigned int ngroups, + unsigned int ngroups, unsigned int nas, size_t size, const char *name, bool use_va) { @@ -206,6 +207,7 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, vdev->features_valid = false; vdev->use_va = use_va; vdev->ngroups = ngroups; + vdev->nas = nas; if (name) err = dev_set_name(&vdev->dev, "%s", name); diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index c98cb1f869fa..659e2e2e4b0c 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -251,7 +251,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr) ops = &vdpasim_config_ops; vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, 1, - dev_attr->name, false); + 1, dev_attr->name, false); if (IS_ERR(vdpasim)) { ret = PTR_ERR(vdpasim); goto err_alloc; @@ -539,7 +539,7 @@ static struct vdpa_iova_range vdpasim_get_iova_range(struct vdpa_device *vdpa) return range; } -static int vdpasim_set_map(struct vdpa_device *vdpa, +static int vdpasim_set_map(struct vdpa_device *vdpa, unsigned int asid, struct vhost_iotlb *iotlb) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); @@ -566,7 +566,8 @@ static int vdpasim_set_map(struct vdpa_device *vdpa, return ret; } -static int vdpasim_dma_map(struct vdpa_device *vdpa, u64 iova, u64 size, +static int vdpasim_dma_map(struct vdpa_device *vdpa, unsigned int asid, + u64 iova, u64 size, u64 pa, u32 perm, void *opaque) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); @@ -580,7 +581,8 @@ static int vdpasim_dma_map(struct vdpa_device *vdpa, u64 iova, u64 size, return ret; } -static int vdpasim_dma_unmap(struct vdpa_device *vdpa, u64 iova, u64 size) +static int vdpasim_dma_unmap(struct vdpa_device *vdpa, unsigned int asid, + u64 iova, u64 size) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 4ee6850b9a68..d503848b3b6e 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -693,6 +693,7 @@ static u32 vduse_vdpa_get_generation(struct vdpa_device *vdpa) } static int vduse_vdpa_set_map(struct vdpa_device *vdpa, + unsigned int asid, struct vhost_iotlb *iotlb) { struct vduse_dev *dev = vdpa_to_vduse(vdpa); @@ -1495,7 +1496,7 @@ static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name) return -EEXIST; vdev = vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev, - &vduse_vdpa_config_ops, 1, name, true); + &vduse_vdpa_config_ops, 1, 1, name, true); if (IS_ERR(vdev)) return PTR_ERR(vdev); diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c index e18dfe993901..35acba0e8d6d 100644 --- a/drivers/vdpa/virtio_pci/vp_vdpa.c +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c @@ -466,7 +466,7 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) return ret; vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa, - dev, &vp_vdpa_ops, 1, NULL, false); + dev, &vp_vdpa_ops, 1, 1, NULL, false); if (IS_ERR(vp_vdpa)) { dev_err(dev, "vp_vdpa: Failed to allocate vDPA structure\n"); return PTR_ERR(vp_vdpa); diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 632c43eb5ecf..9202ff97ddb5 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -633,10 +633,10 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, return r; if (ops->dma_map) { - r = ops->dma_map(vdpa, iova, size, pa, perm, opaque); + r = ops->dma_map(vdpa, 0, iova, size, pa, perm, opaque); } else if (ops->set_map) { if (!v->in_batch) - r = ops->set_map(vdpa, iotlb); + r = ops->set_map(vdpa, 0, iotlb); } else { r = iommu_map(v->domain, iova, pa, size, perm_to_iommu_flags(perm)); @@ -662,10 +662,10 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, vhost_vdpa_iotlb_unmap(v, iotlb, iova, iova + size - 1); if (ops->dma_map) { - ops->dma_unmap(vdpa, iova, size); + ops->dma_unmap(vdpa, 0, iova, size); } else if (ops->set_map) { if (!v->in_batch) - ops->set_map(vdpa, iotlb); + ops->set_map(vdpa, 0, iotlb); } else { iommu_unmap(v->domain, iova, size); } @@ -897,7 +897,7 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, break; case VHOST_IOTLB_BATCH_END: if (v->in_batch && ops->set_map) - ops->set_map(vdpa, iotlb); + ops->set_map(vdpa, 0, iotlb); v->in_batch = false; break; default: @@ -1163,6 +1163,10 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) int minor; int r; + /* Only support 1 address space and 1 groups */ + if (vdpa->ngroups != 1 || vdpa->nas != 1) + return -EOPNOTSUPP; + v = kzalloc(sizeof(*v), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!v) return -ENOMEM; diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index f7764e097bab..7ab0e29ae466 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -69,6 +69,8 @@ struct vdpa_mgmt_dev; * @cf_mutex: Protects get and set access to configuration layout. * @index: device index * @features_valid: were features initialized? for legacy guests + * @ngroups: the number of virtqueue groups + * @nas: the number of address spaces * @use_va: indicate whether virtual address must be used by this device * @nvqs: maximum number of supported virtqueues * @mdev: management device pointer; caller must setup when registering device as part @@ -86,6 +88,7 @@ struct vdpa_device { u32 nvqs; struct vdpa_mgmt_dev *mdev; unsigned int ngroups; + unsigned int nas; }; /** @@ -241,6 +244,7 @@ struct vdpa_map_file { * Needed for device that using device * specific DMA translation (on-chip IOMMU) * @vdev: vdpa device + * @asid: address space identifier * @iotlb: vhost memory mapping to be * used by the vDPA * Returns integer: success (0) or error (< 0) @@ -249,6 +253,7 @@ struct vdpa_map_file { * specific DMA translation (on-chip IOMMU) * and preferring incremental map. * @vdev: vdpa device + * @asid: address space identifier * @iova: iova to be mapped * @size: size of the area * @pa: physical address for the map @@ -260,6 +265,7 @@ struct vdpa_map_file { * specific DMA translation (on-chip IOMMU) * and preferring incremental unmap. * @vdev: vdpa device + * @asid: address space identifier * @iova: iova to be unmapped * @size: size of the area * Returns integer: success (0) or error (< 0) @@ -310,10 +316,12 @@ struct vdpa_config_ops { struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev); /* DMA ops */ - int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb); - int (*dma_map)(struct vdpa_device *vdev, u64 iova, u64 size, - u64 pa, u32 perm, void *opaque); - int (*dma_unmap)(struct vdpa_device *vdev, u64 iova, u64 size); + int (*set_map)(struct vdpa_device *vdev, unsigned int asid, + struct vhost_iotlb *iotlb); + int (*dma_map)(struct vdpa_device *vdev, unsigned int asid, + u64 iova, u64 size, u64 pa, u32 perm, void *opaque); + int (*dma_unmap)(struct vdpa_device *vdev, unsigned int asid, + u64 iova, u64 size); /* Free device resources */ void (*free)(struct vdpa_device *vdev); @@ -321,7 +329,7 @@ struct vdpa_config_ops { struct vdpa_device *__vdpa_alloc_device(struct device *parent, const struct vdpa_config_ops *config, - unsigned int ngroups, + unsigned int ngroups, unsigned int nas, size_t size, const char *name, bool use_va); @@ -333,17 +341,19 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, * @parent: the parent device * @config: the bus operations that is supported by this device * @ngroups: the number of virtqueue groups supported by this device + * @nas: the number of address spaces * @name: name of the vdpa device * @use_va: indicate whether virtual address must be used by this device * * Return allocated data structure or ERR_PTR upon error */ -#define vdpa_alloc_device(dev_struct, member, parent, config, ngroups, name, use_va) \ +#define vdpa_alloc_device(dev_struct, member, parent, config, ngroups, nas, \ + name, use_va) \ container_of((__vdpa_alloc_device( \ - parent, config, ngroups, \ - sizeof(dev_struct) + \ + parent, config, ngroups, nas, \ + (sizeof(dev_struct) + \ BUILD_BUG_ON_ZERO(offsetof( \ - dev_struct, member)), name, use_va)), \ + dev_struct, member))), name, use_va)), \ dev_struct, member) int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs); From patchwork Wed Mar 30 18:03:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 080C2C433EF for ; Wed, 30 Mar 2022 18:11:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349800AbiC3SNf (ORCPT ); Wed, 30 Mar 2022 14:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349934AbiC3SNI (ORCPT ); Wed, 30 Mar 2022 14:13:08 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2040.outbound.protection.outlook.com [40.107.223.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA262B1B9; Wed, 30 Mar 2022 11:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=auTgLIy6xJ7qU6Q8VcqdEXsXj/rc58VS4RHzLmc6MoY=; b=ip0IZPojn2dtoPlf3ehPCrWAH4vlOSnEMU1m9MIqUSxHhXzjTlKCXPi0x4tD954ZY4VPJz2xbeAWnGg0pntmDb/1wPobUoon1ilM+dCcdOcq+iy6dKUZRgHR6dlyLGbobQRagcgdnbgrAElrS3OUPbhoPvl+dtmxGen7QYdieOI= Received: from DM6PR11CA0048.namprd11.prod.outlook.com (2603:10b6:5:14c::25) by BN8PR02MB5731.namprd02.prod.outlook.com (2603:10b6:408:b4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.16; Wed, 30 Mar 2022 18:11:20 +0000 Received: from DM3NAM02FT039.eop-nam02.prod.protection.outlook.com (2603:10b6:5:14c:cafe::29) by DM6PR11CA0048.outlook.office365.com (2603:10b6:5:14c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:11:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT039.mail.protection.outlook.com (10.13.5.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:11:20 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id EE6F041D82; Wed, 30 Mar 2022 18:11:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JSaJSsO1NPydwDpfZ6y79ZvfQGGVCRhWVoB1COMqL2N0JBeJbrFJFOqnUfQyDOnux7huhXCUgu+snfqEjzWBUseNnb+hESnXzbn1KN9ZgRFr9ONK+4DVvV12/D89zkXg4tVFHm4zH5+wHQr/0PnTeTA7AQ0mM5TT7YuKuVKaisfY253oMIx5r/NHTXHpPf5GIcis+2qwAFOMLQg+EDsfn5xfes7jb3u43aFCiEtoGjPqhhbcoDXO55sms2BVWa8sE1p6vI6pUuPieT5+2gOOdR3bCbmnrK8Xm30me6iDfmkEv2uEzR2Upbh396nJlojfSPAgREM38IhaMvTBcTiY1g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=auTgLIy6xJ7qU6Q8VcqdEXsXj/rc58VS4RHzLmc6MoY=; b=c88XS67p6ZCrFIKUzxg4MsDqpb94qnJp5xsZXfV4HAHRgtc0JAd4deRLpSo0SlHOCitzBPsVHqNxi+gRIj5hSNQ7kjXHsW4j3DphdnGVITRKBWvKpd1sviCsGsxEwwp8r+Hx9vVvM1Fn88F99WrQIPeG2Z0E1M9ByiuU1F2eKN+o3KPndJ4QZx7J7ZNPEMD6yBezTWMrbWRkcDNxF4JGCjGSXQ6St0rIdQ5CCI3Hczc2cFYOAAuMMd3REscl7xKCZGbK3pZMoZ7cZfaDo+P2PGLTIqotALWj/ZzUKkMtgdeQv4ZbJuYT5dFBW+AkWwd1KzxZnLg8sI5wue0jwCcCqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from DS7PR03CA0296.namprd03.prod.outlook.com (2603:10b6:5:3ad::31) by SA0PR02MB7131.namprd02.prod.outlook.com (2603:10b6:806:da::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.16; Wed, 30 Mar 2022 18:11:18 +0000 Received: from DM3NAM02FT011.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::db) by DS7PR03CA0296.outlook.office365.com (2603:10b6:5:3ad::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:11:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT011.mail.protection.outlook.com (10.13.5.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:11:18 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:11:17 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:11:17 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcmq-000CCQ-HB; Wed, 30 Mar 2022 11:11:17 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 07/19] vdpa: introduce config operations for associating ASID to a virtqueue group Date: Wed, 30 Mar 2022 23:33:47 +0530 Message-ID: <20220330180436.24644-8-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 78991ad0-12c7-4e76-b9b2-08da1278b147 X-MS-TrafficTypeDiagnostic: SA0PR02MB7131:EE_|DM3NAM02FT039:EE_|BN8PR02MB5731:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ziaREvisbsWZJxOhgmAwDW80WaXpOdR2e4DTtb4bo5mryPO+dJOc6R78f1+x+sRESbEk39U6UnhoHJUGhJeGws6KD/nXl8u5p22jlyIg18Q48QGUt7W9nokr7ODXH8gBR7DYwz58wMHTyNH7vC7DqYWxoSfPj4WE2FCNwXmlXyB7jM9JKOc+NHE6l0ef/21TMULUI15euYn1ZSx5bWb4uj1eI4WQ6p9c8FRClSoVqCaWGOrdsoYhvgbctaY8kSL5SqchBbO46B9GS4Rswn8sVjsjIXnmvzLS3mQCO8hTqpcLy6UxPjbAyR39LtZLw7QRSef+C2OziYkzEJcrusQ0u6G12TCOaHqFr95GhlaV8fz5gGRu6x1CYR//zhP8aYvVbU4PdI1POVXlp6u4kpANGSjMBFOlAursY47RnoIr82Boj+ljlUd6FmrGvBOfB/MVuzI0bK3X6IWkt30q2dLCSp1bWBx9GCc5fqOALV7yjlA4J9ExYlP30htwb5Pmo3YNJjBGvU8nb5EPopZwfCBMbHkZ/yVVrDmpKxaEKNXNQDD8onbrRo+K0qWNUoEVI/pUl6LUPVQE48yUGUCEjCn/LfxWv/Lx6nRVtIjbdoMnn3rxTIrKNbnzZCY81Nt8IQbXew5MuH5wk2IMjGF+K8mGQZbvyxfskaHYWx+geMqjxYqdOLr+gvb+uXbRJEAM6HZFwLaLJHsGiRN4+5bmKW5Obg== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(1076003)(8936002)(336012)(7416002)(186003)(70206006)(508600001)(36860700001)(4326008)(47076005)(70586007)(83380400001)(426003)(2616005)(36756003)(8676002)(26005)(82310400004)(5660300002)(6666004)(7696005)(2906002)(110136005)(7636003)(316002)(54906003)(356005)(9786002)(40460700003)(44832011)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR02MB7131 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT039.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dbad219a-5622-47fa-4b79-08da1278b019 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I261KkhLjzjz9xFujQhMWrlzZ9LVqCCxHu1tSrfn/Kn5mHRc31+m8xn99HXj7wS/552IZxzqtKE5uzNHWsD+bvJmgLLBO1GGLbq1Z8o3oMuUmB/SQ1fnvB9GddHzUyImYjtNOA5qVbghzmKRfyH6HVh9gaOAwuDG2L/rsU4ddD7HxmDnmwllx/KMPaoDL3+6JPhiKHmBTdY4aikEYn1gTkQMx7ct+a1X14DuJZOB+RDw16LDGPJVneq7Ehe5uswrRHahWS8wre9lIikO8+Ua49xCk4nAHPvjMs11S0B0hQGGHEhc1IbEaFvV0mgAZzfIQ7BXauo9UDtoWUn7oGN/wtUuQ8TRb/kZCIPb+NCNm2jJ0OdDJ+YQNLgh6IfZtZexxnwd64bQazW21jA2cO6eznSQo1pyH6yr9upfXYswXI8/nstDTSIUgNb9n353ackOBjbZN9zvT5C+5BcS1yA2Kv4ifW+1ea8vhmwpyTfINic6qHsh6vp0T1JkoWRKYTN3OApzjcuJMup3ZqTifyTPg17+cZNGk04tSxDwNs7qOG24tfiywc34belfecgquCuk6Eun3DZwBdEGC9rYbooCj6UGVHOAPa6l9gfvhtP7wP/WUgpYxsk8qlnqWk9dMT7qBZhp3+vaebkFhF6+JpgY+vHuYDNgpuag7h88DZFDm42/m+HlHy1EwBiv0Id3Fo+a7GetmhCEd+4R3tMqgpmztJ7ure4dH3Pl2kR4DKScRMg0aIwQhGtFmje0PK9Z3FXt X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(2616005)(508600001)(1076003)(70206006)(81166007)(8676002)(316002)(336012)(426003)(26005)(186003)(6666004)(7696005)(36860700001)(4326008)(82310400004)(83380400001)(40460700003)(47076005)(110136005)(2906002)(54906003)(9786002)(7416002)(44832011)(8936002)(36756003)(5660300002)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:11:20.4896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78991ad0-12c7-4e76-b9b2-08da1278b147 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT039.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR02MB5731 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch introduces a new bus operation to allow the vDPA bus driver to associate an ASID to a virtqueue group. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- include/linux/vdpa.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 7ab0e29ae466..f4d8c916e0d8 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -240,6 +240,12 @@ struct vdpa_map_file { * @vdev: vdpa device * Returns the iova range supported by * the device. + * @set_group_asid: Set address space identifier for a + * virtqueue group + * @vdev: vdpa device + * @group: virtqueue group + * @asid: address space id for this group + * Returns integer: success (0) or error (< 0) * @set_map: Set device memory mapping (optional) * Needed for device that using device * specific DMA translation (on-chip IOMMU) @@ -322,6 +328,8 @@ struct vdpa_config_ops { u64 iova, u64 size, u64 pa, u32 perm, void *opaque); int (*dma_unmap)(struct vdpa_device *vdev, unsigned int asid, u64 iova, u64 size); + int (*set_group_asid)(struct vdpa_device *vdev, unsigned int group, + unsigned int asid); /* Free device resources */ void (*free)(struct vdpa_device *vdev); From patchwork Wed Mar 30 18:03:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27764C433EF for ; Wed, 30 Mar 2022 18:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349814AbiC3SOJ (ORCPT ); Wed, 30 Mar 2022 14:14:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349874AbiC3SN6 (ORCPT ); Wed, 30 Mar 2022 14:13:58 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2049.outbound.protection.outlook.com [40.107.243.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199EF3ED16; Wed, 30 Mar 2022 11:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9zenqFNVZNHbyE8ohECsWWLdJRxtHCCmc/O9Ihzlzv8=; b=G/4+WxeKQRqNw/gRwcxQoWxjhBaexVySCdGpDoV+kxkdwE9uuViAaQ62hEaURI1jYt8cAT+7SFgf/D8JQrgnwQAKTUyYsdFi1Z7m4A9nDMSckKxp+7Dz41v0GbhZc8bJ9j5qd+113K8jk85YG8CpSPM5ccAipSMD75Dss7evwpc= Received: from SN4PR0201CA0053.namprd02.prod.outlook.com (2603:10b6:803:20::15) by DM6PR02MB6138.namprd02.prod.outlook.com (2603:10b6:5:1fd::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Wed, 30 Mar 2022 18:12:10 +0000 Received: from SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com (2603:10b6:803:20:cafe::bf) by SN4PR0201CA0053.outlook.office365.com (2603:10b6:803:20::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18 via Frontend Transport; Wed, 30 Mar 2022 18:12:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0031.mail.protection.outlook.com (10.97.4.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:12:10 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 934FB41D82; Wed, 30 Mar 2022 18:12:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=newGDtDHY66MugRK+uw95QIcKbNjzY4/a20ENx0q/r3i8zk70taQlwSFTD4gPZaEAFr6x9IC+fvHkbyGrqqqC3IWr4VjNc8dRGr7ACOpj8tFMebAZXrqAf+BScjfc1RrY3zDJkTyIMvGXkACm04r5DRUtTvQzKVFdUddzO49hfxfaRs+dcGT6ieViEVzmTZbRqaI86wOwmue/cSvj0IweT59N+xBw1wCI4Jd1LR+G6n1DVHcUiLAK89inFtlRismN/vP7OcPhzmKZ+2C+pbgxvNE7fpIe6zRApphFYGMUSXeZMHLZCwQgCr7kWP2kh+IOo0GuvKT1E1Rp3ID8Bv6Bw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9zenqFNVZNHbyE8ohECsWWLdJRxtHCCmc/O9Ihzlzv8=; b=hwimoE+I1ntzHEZaYZDCzlk3wKmt9LOwR9r8n4reebB4DP8Anl0qIgqGsEh1DvpwnGbn+cqRW4j1I4KpZkOcVL8zWMKTnT4Q3P7uIsRNbGWF9ib5bE+NRuiZ7n6bHw+PLvA5Kx4ZRgP+8cuBTSWkKa1+3hbB+8yWQLsHvEopPR792XbAFv0FQOxA1oLRho6DEchLoKCkyTWTwz6rOj451vfU5BlXFEc2SsxXtak4Qru011EhgaFKs134Fx4FCyVqec3PFYeWQB3PyUO9+n4zN3d+o2oKeTF5VMVK6BlSOK9wzAH6kOARXdQGGziA7e1wPux3qXvREFAEiHcM/5D44A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN0PR04CA0107.namprd04.prod.outlook.com (2603:10b6:408:ec::22) by CH0PR02MB7914.namprd02.prod.outlook.com (2603:10b6:610:113::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 30 Mar 2022 18:12:08 +0000 Received: from BN1NAM02FT061.eop-nam02.prod.protection.outlook.com (2603:10b6:408:ec:cafe::1) by BN0PR04CA0107.outlook.office365.com (2603:10b6:408:ec::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:12:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT061.mail.protection.outlook.com (10.13.3.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:12:07 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:11:59 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:11:59 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcnW-000CCQ-G0; Wed, 30 Mar 2022 11:11:58 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 08/19] vhost_iotlb: split out IOTLB initialization Date: Wed, 30 Mar 2022 23:33:48 +0530 Message-ID: <20220330180436.24644-9-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 15c36d53-040e-445a-28cb-08da1278cee1 X-MS-TrafficTypeDiagnostic: CH0PR02MB7914:EE_|SN1NAM02FT0031:EE_|DM6PR02MB6138:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: u43bh7yShunAU5HQboxzlx2dVYriSG0NcP8YFj/c2GvXvp3hV27MI1jIETX6ofrDW0RYoPxy3AC+uUFfdlp66BK6dQ7WpzZKkTNSPbLDelC9xTX1yiq9vJFZgl+kxcZeXmETfXgWCc1vx69ZQeVrzA/+d0+l244Ra3ctgt6Cl45rAxob8VmcEZlIzyIsMSeBL2fzfoQXi6OW5EYipL/nV9a+phyVYqBmmeiSnyqJSfXVhGE+mzC13cPpgQi/odjTasYz+ihSUupf3nL75Ldfe4b3NhNNFJlETl5rTXlLD/sLm/FiSecjJRevaU5KpKduG48Owpj3qZmYrzmdQAzkQhSDHx2zaZt8dczkKA+9QLhfa6IDQq9mFGK7yyS4VXim9+GGWbXZMDYpDXMgKXKAA1ufH+bz83/aXe1qY+DgCG2YK0cWoybYHo+ubZZwrjCocEwklLY+WKi7xuO6Qp6mhYKaRISlB84Zn32aJ2CclaevGmZ/qI99TdXB74UdggN+56wbNzOwOmfLV7CzX42VwYba4xmhdAiJ3OSEcOoJHSDQXPK0GXHBoHuMUua7ZeWMEOQdHUfktymmKQSSQnBw8eH2JD72fj0MfVH5OgYVKztea0zVmKh05BQw+AJI5b3b9dUuRgadfMMLlWWWDmWkMqltLK5x8evWOhaszuPbPTWFySIhpSsJffbz+43dWn91brW+grFNVQ5CAyeIWVaP59FxTq5pBvh3F1gL1hBEoAM= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(110136005)(2906002)(8936002)(70206006)(7416002)(4326008)(7636003)(356005)(186003)(2616005)(26005)(7696005)(316002)(70586007)(8676002)(336012)(6666004)(83380400001)(54906003)(44832011)(1076003)(426003)(508600001)(36860700001)(9786002)(40460700003)(47076005)(5660300002)(82310400004)(36756003)(102446001)(21314003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB7914 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c9e7c293-0860-4ce9-8466-08da1278cd80 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZWyGcwfKu95775rnYbkFzY6oQwXpePX26fLN6WrzR/uqLwS7q4EwQQ6o/SzZYctWO6kf3gLNBt0nCrOcoVLnXbhrxfYgPD6jRSUOKe/rCn+Btr62JpbXdL2+T46rwtwVvVKEpR/vVK472H/ylLmUOA++TjQdOQp0HZzHvpIf1Cr2nmbg2uAnh2rDUjv1rRProvZ3InFaze7AU8GFHkJqlB0t3d4SrwLaQdbEYiTqjtPPAO1B7dgD00Np5oj69KKZp0pjFzNhAJ5J1qxqD8d/4iEmXLOmhqMbR/tEY35pHWN6OBCxs+uznNGZ0bl+Fg0YX6gE6CkzkB/7RzVtuY538o04DCHqTeo2Fo5czXiG0yShcyZULY8VGfAwJhX9QCeSyZogBH9RUEiRCTVGZTc8DI9P4eyDrA2or7XdQwMEb1BIp/zHlCxNn4rnw1xi3pYDAEjBEY/u7aHPl5ZJwh3satAnw8FQoAMuApdyL1iBbyTsNSdCnmXbQ8BOGNeiNagYdLlSwz7xJ7C5AqH9f0xMVkiet1p+UolXGoCf8GzefT0tAEi1y6NGnkhMXN6dyMZjo4LhzYIJ/zwL+mvhbEE1uRUyWFLd16H/aw3+IHXRwIhFumxcRCvGKQw+RE1RICuOg1YaAfIB73+YljaMrtJx9mFKYopyg975ICOB059i33usSiRIWNdSqs8hgrtBii1PgfK/0I3vQPMXj4PPwv/TwEEfXQVfYMS7NU7kK+ulfzLQ+ieQPNTEjanRU3e7Lksg64kDpdSlmn+12CVUWLVB1w== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(44832011)(82310400004)(36756003)(1076003)(336012)(426003)(54906003)(26005)(70206006)(8676002)(40460700003)(81166007)(4326008)(110136005)(6666004)(2616005)(186003)(7696005)(8936002)(9786002)(83380400001)(7416002)(36860700001)(5660300002)(47076005)(508600001)(2906002)(316002)(102446001)(21314003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:12:10.1178 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15c36d53-040e-445a-28cb-08da1278cee1 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6138 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch splits out IOTLB initialization to make sure it could be reused by external modules. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/iotlb.c | 23 ++++++++++++++++++----- include/linux/vhost_iotlb.h | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/iotlb.c b/drivers/vhost/iotlb.c index 5829cf2d0552..ea61330a3431 100644 --- a/drivers/vhost/iotlb.c +++ b/drivers/vhost/iotlb.c @@ -125,6 +125,23 @@ void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last) } EXPORT_SYMBOL_GPL(vhost_iotlb_del_range); +/** + * vhost_iotlb_init - initialize a vhost IOTLB + * @iotlb: the IOTLB that needs to be initialized + * @limit: maximum number of IOTLB entries + * @flags: VHOST_IOTLB_FLAG_XXX + */ +void vhost_iotlb_init(struct vhost_iotlb *iotlb, unsigned int limit, + unsigned int flags) +{ + iotlb->root = RB_ROOT_CACHED; + iotlb->limit = limit; + iotlb->nmaps = 0; + iotlb->flags = flags; + INIT_LIST_HEAD(&iotlb->list); +} +EXPORT_SYMBOL_GPL(vhost_iotlb_init); + /** * vhost_iotlb_alloc - add a new vhost IOTLB * @limit: maximum number of IOTLB entries @@ -139,11 +156,7 @@ struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags) if (!iotlb) return NULL; - iotlb->root = RB_ROOT_CACHED; - iotlb->limit = limit; - iotlb->nmaps = 0; - iotlb->flags = flags; - INIT_LIST_HEAD(&iotlb->list); + vhost_iotlb_init(iotlb, limit, flags); return iotlb; } diff --git a/include/linux/vhost_iotlb.h b/include/linux/vhost_iotlb.h index 2d0e2f52f938..e79a40838998 100644 --- a/include/linux/vhost_iotlb.h +++ b/include/linux/vhost_iotlb.h @@ -36,6 +36,8 @@ int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last, u64 addr, unsigned int perm); void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last); +void vhost_iotlb_init(struct vhost_iotlb *iotlb, unsigned int limit, + unsigned int flags); struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags); void vhost_iotlb_free(struct vhost_iotlb *iotlb); void vhost_iotlb_reset(struct vhost_iotlb *iotlb); From patchwork Wed Mar 30 18:03:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796174 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D58C5C433FE for ; Wed, 30 Mar 2022 18:13:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349845AbiC3SOr (ORCPT ); Wed, 30 Mar 2022 14:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349844AbiC3SOo (ORCPT ); Wed, 30 Mar 2022 14:14:44 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2063.outbound.protection.outlook.com [40.107.100.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78E013EF19; Wed, 30 Mar 2022 11:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+PF5b2AqIQnrYVIjekGVkPHjmQSR1sDeaupLb000SYc=; b=NokGaa4u3sP5zApwGVv+8AnstcYSRUK++Px71TlWL0M3s0cRJgIwfgbj2NkCGIZQI4ydGCW+mWd5p3LLessXf8tiqNueXXRgXwWdS/SFWW/CUWzexEUBomaROFHr0lcC5zGxvwNY8BQ0wQYDhV3ELgdB3+nxLmc0465q9/xktMA= Received: from DM6PR06CA0078.namprd06.prod.outlook.com (2603:10b6:5:336::11) by BYAPR02MB5448.namprd02.prod.outlook.com (2603:10b6:a03:9b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.17; Wed, 30 Mar 2022 18:12:50 +0000 Received: from DM3NAM02FT036.eop-nam02.prod.protection.outlook.com (2603:10b6:5:336:cafe::f9) by DM6PR06CA0078.outlook.office365.com (2603:10b6:5:336::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:12:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT036.mail.protection.outlook.com (10.13.5.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:12:50 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 08C0C41CDE; Wed, 30 Mar 2022 18:12:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=flGkCyV9EthBaJNKKjl54L66IrTNnHeR44m1T+hBb84dgJaagmoCobyCCH0VWSzqKWxKy+RJDdoifNe9fh8gGrhztNIQ/q1U/xW/kyEKbFOlMNEpEJX0+jvEgkEe82mcrWKrqOLo4pLZmDpR3c2a/PgiiVg6hip9/zfVnh7TTH4IutWkR+rOgjLEqHHVhfKMKoN3FF6GGa+P5DnVFjkLbzzdr3x/m5/On9eMVQzy6qovgb+4hmU9lY3W4r8wg2uuUwqDuUYSFLno5rQkPqAZ7P/c8n/gspksalQQab1JB+6q1ioqIlKNoveJk8E2rC63/1dV3Kqc4bhJ+Gt9sGkntw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+PF5b2AqIQnrYVIjekGVkPHjmQSR1sDeaupLb000SYc=; b=FWEqiT8CcF+pxW02hkKsAbEtLqq33ZPFxEc4aM2JA5ln9Kcyirk/AFRyzu6J2YcMowRfzipUTEPyaQiqEh28jQOJ44UvFk5VSWhzXctVP3z8Vwcxk7CmPIp1sVTrfmZw+6Y5LIfhEC9VorzfZugLH1t6QZNhN8gXZT7lH+CGsnKDLc6oq/l9ZeDBx9W84ulqLNhw9fCt9LRYZMDFRHYXr0d9av0hAxvEyLIKUkCSy1s8Z7rrUUp6HbGa5fZy7QBf8ES4ejwgaLvPxwzSLJ9BEMkLVQ0pX7DmeN2j9cjgpSlCSuwd7xvwr8fEVkJBfBky/F6q85riaPmUG+C23qzUdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from DM6PR14CA0045.namprd14.prod.outlook.com (2603:10b6:5:18f::22) by MN2PR02MB6941.namprd02.prod.outlook.com (2603:10b6:208:20a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Wed, 30 Mar 2022 18:12:48 +0000 Received: from DM3NAM02FT017.eop-nam02.prod.protection.outlook.com (2603:10b6:5:18f:cafe::ac) by DM6PR14CA0045.outlook.office365.com (2603:10b6:5:18f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:12:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT017.mail.protection.outlook.com (10.13.5.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:12:48 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:12:46 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:12:46 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcoG-000CCQ-3L; Wed, 30 Mar 2022 11:12:46 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , , , , CC: , , , , , , , , , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 09/19] vhost: support ASID in IOTLB API Date: Wed, 30 Mar 2022 23:33:49 +0530 Message-ID: <20220330180436.24644-10-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: b00e87d0-6966-4e5f-5dca-08da1278e6f6 X-MS-TrafficTypeDiagnostic: MN2PR02MB6941:EE_|DM3NAM02FT036:EE_|BYAPR02MB5448:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: sDgSOgCfnA7H98YV9GI6Tr7KPI25ciwb4zDT7/snQdtd/67b9s9CSN72vT//1yfHaVM6OXfdIxOw2TqFYBGgr53Lxzyxnfw9ld4gq/5d0zrdY9BmzrN89HEFW2z6HHWUFFt46TI+m3KY7pE6Xf9ii3RViBltxsPeeFsBJs2zonwSZ7RYv4oq/ZymsAvetZ1E1LPeJZ0GBGbdvMPbCT/Wj0F0zZgEqnYN15a3qA8iH0YaVXeEsF1CEeLzr7Gzm34HIWmVMaEyUQyNchmiGSfoGBE1Ujq1haWIvaLnAw4oh+sy0EWCt94Gw93wc+7Vg1bdgcKSl6DozmY2Oz0yLg4hiCSxsh8tJFte4T49Klf2BSVbC2o0J7g4hYapiRDmvqTmOLbVo2aAJ8XY+aA2wwHfrDUNvf+wVXj2+mvKu7JxHgi4M5+XNLwUVFZqZZf1Jv4W79E1G4aaAu7vSK3Df1a1tIzjVFxup9lqlBEhNxJmIkqU2zMFCKqM7yObyrY54xFJIw1Inr/lgvjxTREPn/KfvppZJSojtpIkql2gCGiArGk/U1LbPFPO7o5w4NBKu7PJpEUhAsn4ahKbf4MxtgDUGBgogC1euUgK/lxgMje22lbs26+rwc0qAflg4SrofDFt4cqP2jH2wimWUtrU5KaQ/15ymlH8b/B6+A86eeYt0DC1R9tKynizTcitoH2mrEfFAv5vlhsRsvO6ovUWfEOg1w== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(83380400001)(70586007)(2906002)(47076005)(426003)(26005)(186003)(336012)(1076003)(2616005)(356005)(36756003)(70206006)(54906003)(7636003)(110136005)(316002)(82310400004)(8936002)(5660300002)(36860700001)(8676002)(40460700003)(508600001)(4326008)(9786002)(7696005)(7416002)(44832011)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR02MB6941 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT036.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 19ec9c5a-77db-44ce-6b5c-08da1278e579 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dxj9I0evKPETooi1U2EcNRl7mQky934xq1UjIWDCuDo9dR4Pt/CZSj2EJ4buJm/gJcFErLsKDt12ClqmTDF/HoH4SOdbTzbCgBw/tA3JzLpkz7QlXXiflchymrkDpf77iYMAzWwLu6dodp5oPKYmDR1ehQUS9SUApiYtCO17A6WDD7jf66cjjnf1vtwRG9tPy/julDgTyG38+Wriz1GSHfuS6x8LAMSqFJEUntGNL/Bz8B0pzB+Rf2ohnlorXYDhRjotcVMPOf2hNVzg9ABhyMzxEFfuxnzGGSc1rS6xNuqkvjnhiblf2y/ZhdrqFMvxzmXys+7etyciHeTPzyVEjRUtfcW/7ab43+5VGxD9IfmyS2OH3KIlC1phRuefor8gdhQddeYzdBJNjqqevEyT59LDVE1KCYbbDwVZiKVTYRfsmtRFxYganUwRokZd3rED9Rob9q0KJqunbOsfpBdne81LHlNdX/OZxx/K0LLIBx+aUXOApRU6qaHgRgC31VUMx3CRvoNIoPoSjZ/JKcB9afdOWh2SFR7l54z/zlHBYD9tv2iX+9S1/VQq0H3qHqFgUkmd6cJGD0ylhLI/tLcSyDG9PauISEoypXuxUOnVlxEXW8vMacOrZGAF7BgSkRu+15ChU872AVHGPJewt9jk0jN9F/6IB7Zoo1YYNYxtsfILhdvJTrngb0no2DOBaCHiS62NupnguLgEZY8VMQ0ndqhKC2hbwzZHGx11YOfHYtuP5fne2WQMrb0B4RhI5plx X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(316002)(1076003)(8676002)(83380400001)(4326008)(82310400004)(110136005)(2906002)(54906003)(47076005)(70206006)(2616005)(26005)(7416002)(36860700001)(9786002)(8936002)(336012)(81166007)(44832011)(40460700003)(5660300002)(508600001)(36756003)(426003)(7696005)(186003)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:12:50.5377 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b00e87d0-6966-4e5f-5dca-08da1278e6f6 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT036.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB5448 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patches allows userspace to send ASID based IOTLB message to vhost. This idea is to use the reserved u32 field in the existing V2 IOTLB message. Vhost device should advertise this capability via VHOST_BACKEND_F_IOTLB_ASID backend feature. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 5 ++++- drivers/vhost/vhost.c | 23 ++++++++++++++++++----- drivers/vhost/vhost.h | 4 ++-- include/uapi/linux/vhost_types.h | 6 +++++- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 9202ff97ddb5..174c9e81df4e 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -870,7 +870,7 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, msg->perm); } -static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, +static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg) { struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); @@ -879,6 +879,9 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb *iotlb = v->iotlb; int r = 0; + if (asid != 0) + return -EINVAL; + mutex_lock(&dev->mutex); r = vhost_dev_check_owner(dev); diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index d02173fb290c..d1e58f976f6e 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -468,7 +468,7 @@ void vhost_dev_init(struct vhost_dev *dev, struct vhost_virtqueue **vqs, int nvqs, int iov_limit, int weight, int byte_weight, bool use_worker, - int (*msg_handler)(struct vhost_dev *dev, + int (*msg_handler)(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg)) { struct vhost_virtqueue *vq; @@ -1090,11 +1090,14 @@ static bool umem_access_ok(u64 uaddr, u64 size, int access) return true; } -static int vhost_process_iotlb_msg(struct vhost_dev *dev, +static int vhost_process_iotlb_msg(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg) { int ret = 0; + if (asid != 0) + return -EINVAL; + mutex_lock(&dev->mutex); vhost_dev_lock_vqs(dev); switch (msg->type) { @@ -1141,6 +1144,7 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev, struct vhost_iotlb_msg msg; size_t offset; int type, ret; + u32 asid = 0; ret = copy_from_iter(&type, sizeof(type), from); if (ret != sizeof(type)) { @@ -1156,7 +1160,16 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev, offset = offsetof(struct vhost_msg, iotlb) - sizeof(int); break; case VHOST_IOTLB_MSG_V2: - offset = sizeof(__u32); + if (vhost_backend_has_feature(dev->vqs[0], + VHOST_BACKEND_F_IOTLB_ASID)) { + ret = copy_from_iter(&asid, sizeof(asid), from); + if (ret != sizeof(asid)) { + ret = -EINVAL; + goto done; + } + offset = sizeof(__u16); + } else + offset = sizeof(__u32); break; default: ret = -EINVAL; @@ -1178,9 +1191,9 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev, } if (dev->msg_handler) - ret = dev->msg_handler(dev, &msg); + ret = dev->msg_handler(dev, asid, &msg); else - ret = vhost_process_iotlb_msg(dev, &msg); + ret = vhost_process_iotlb_msg(dev, asid, &msg); if (ret) { ret = -EFAULT; goto done; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 638bb640d6b4..9f238d6c7b58 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -161,7 +161,7 @@ struct vhost_dev { int byte_weight; u64 kcov_handle; bool use_worker; - int (*msg_handler)(struct vhost_dev *dev, + int (*msg_handler)(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg); }; @@ -169,7 +169,7 @@ bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len); void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs, int iov_limit, int weight, int byte_weight, bool use_worker, - int (*msg_handler)(struct vhost_dev *dev, + int (*msg_handler)(struct vhost_dev *dev, u32 asid, struct vhost_iotlb_msg *msg)); long vhost_dev_set_owner(struct vhost_dev *dev); bool vhost_dev_has_owner(struct vhost_dev *dev); diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index 76ee7016c501..634cee485abb 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -87,7 +87,7 @@ struct vhost_msg { struct vhost_msg_v2 { __u32 type; - __u32 reserved; + __u32 asid; union { struct vhost_iotlb_msg iotlb; __u8 padding[64]; @@ -157,5 +157,9 @@ struct vhost_vdpa_iova_range { #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 /* IOTLB can accept batching hints */ #define VHOST_BACKEND_F_IOTLB_BATCH 0x2 +/* IOTLB can accept address space identifier through V2 type of IOTLB + * message + */ +#define VHOST_BACKEND_F_IOTLB_ASID 0x3 #endif From patchwork Wed Mar 30 18:03:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D357CC433FE for ; Wed, 30 Mar 2022 18:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349822AbiC3SPu (ORCPT ); Wed, 30 Mar 2022 14:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348842AbiC3SPr (ORCPT ); Wed, 30 Mar 2022 14:15:47 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2068.outbound.protection.outlook.com [40.107.102.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA57DE8; Wed, 30 Mar 2022 11:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1aU/tfL5148tmYWuSmlvrXot1O/2T9HMpWMFEV8qP2Y=; b=myjk+XTlBp+dO0o5uRnX+BnKjO+IYi1Ayu1vGvNRoHs+l1Y2KNLEd4OIlcPiSm9LtQznsawadHMqEBuPjrSMo9sLT4cd0o67cAfjm8cZldVrRF+Qe1trpk/DozXYwODVPnsbljRBGydcii1MPKUdAyqSWiYc7vlpVm0ySZQZrqc= Received: from BN9PR03CA0062.namprd03.prod.outlook.com (2603:10b6:408:fc::7) by SJ0PR02MB8371.namprd02.prod.outlook.com (2603:10b6:a03:3e7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.16; Wed, 30 Mar 2022 18:13:59 +0000 Received: from BN1NAM02FT031.eop-nam02.prod.protection.outlook.com (2603:10b6:408:fc:cafe::b0) by BN9PR03CA0062.outlook.office365.com (2603:10b6:408:fc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:13:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by BN1NAM02FT031.mail.protection.outlook.com (10.13.2.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:13:59 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 669DC41D82; Wed, 30 Mar 2022 18:13:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LOS/gehIuwoEJk1PaSLGpyDi1Tfjs6FZNpWTGZesujA4RJpxTkIDFdpNVXXs7f0/uaAHdEi/bmAnXk5eGExJzXyACw7rt5lLl1q9e5iEqQS+Ou/wdh7PxA9344wzw49ZWPosdjpA9hGnC4RQ+ghUBzACVfkOZzjX2hpuTpYjXcO/O1iLj1Apy/5Zi65zfS5qzGqVpWmu7wv5W/BlrrE6oGU2Jq2xEZcghNNx1lR5ZXeXD68nd24Nz34cBz9uxrAnxEMymIDVvS5/T1CqhHE6SKSrT2Dfe1/uqM3ll0bkfioPmjXPJE1+M8Ze7RgzU0ZliZ8r8cVIlIX5o65kHBZFEg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1aU/tfL5148tmYWuSmlvrXot1O/2T9HMpWMFEV8qP2Y=; b=MigfNuf7ixYnNsgXXZXwVOWVQkBqgT65cj0YOcorq7XPR7LSMqOG7f6h+AT46OZSZjHU8KpLTM16VYuAE2K8Cfnu0rxXlH/DsTzDU4hzFA63NvY6QqiExdHALY10Ew63hN+zV3AobZmXrjZdmnVRuq1B2YcdBfRM8zOHnocJG+Wlz/jzu21qB0bp4Y4UPhsVS4KBtkp1KpeQjp8hZlcfw2tMj3eVy0gjf+2C/gSsDMFcrz/ETxXvok19XqOZQNUw9d5rJnMnIKS5nWRa8JR84nAWb8afITDypwbDGnQ3DKasMRH7tLTEt8d5KW6btPl9C7TihfgsScDgOFzDXVEF1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN9PR03CA0989.namprd03.prod.outlook.com (2603:10b6:408:109::34) by SA0PR02MB7371.namprd02.prod.outlook.com (2603:10b6:806:e7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Wed, 30 Mar 2022 18:13:56 +0000 Received: from BN1NAM02FT063.eop-nam02.prod.protection.outlook.com (2603:10b6:408:109:cafe::94) by BN9PR03CA0989.outlook.office365.com (2603:10b6:408:109::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:13:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT063.mail.protection.outlook.com (10.13.2.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:13:55 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:13:30 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:13:30 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcp0-000CCQ-45; Wed, 30 Mar 2022 11:13:30 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 10/19] vhost-vdpa: introduce asid based IOTLB Date: Wed, 30 Mar 2022 23:33:50 +0530 Message-ID: <20220330180436.24644-11-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 7e80a667-bf71-4624-7b4c-08da12790fe0 X-MS-TrafficTypeDiagnostic: SA0PR02MB7371:EE_|BN1NAM02FT031:EE_|SJ0PR02MB8371:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: f1AFvSFzoeTxdyiXkjN9GINsAwsqR9EmvDfQJfB0L9vWdURrQnnkN0KbCFNb7/gNSZk+mZ+9o/99HIqlzIPOLhJa9tI4VmHQyn02x988+Z49sLjDTFLIsxY89dNCV1l4MrYGOpJQ964SAzTynIjMUi+/+Bo9TLsrGUb43O/uV9mUohZnmJYcOVa4AJI85wym99kjQWnnQiJp6ioTUU59YuwFNsvef6otoSWtHrTuaQjV2VHZHYpolorohOv3JbIPBhDklx7tNdLYNrb5aJeNpHDNCPt6YURpc4ehA/a2UtoskLgwyWEXw81yJXSdmo52E1ZNteTreX51IokewmaKpkkvEHhU5flHdkrGoOq62Pmk0K57x816fcA9V0eTGk0tv4cjTXLVcLvcnRW0ShWKx9J99kDLUkeMK+In1Nq4+/T7c+LHbXM81atYW4bHHHJF8ruoGkJClSXtT1gRyJkbofGOWrtKMZ1TCf4rzKyapYXJ1jIv/uy4TlXnlrdbz1YuFsgsuIRoPlw6pv58jSE65b2G9heEbt/lJ5SskWyRaS347d/SY6YfjUnd+o70gpGhh1uPMt3jrqPD9T9Opcbb1XPXpbqJ4gZ/JAmNUczU+hQpzYczB5MNXDr8fiFT0/tDFHqiO7RavODIcgeS6XyU1/zL+wDwsIyv7bmSZmBG4f0zx04B/arwZ43/M2t1VspHoEwy+lLuACEgFfaE+EcuYg== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(83380400001)(70586007)(2906002)(47076005)(186003)(426003)(26005)(336012)(1076003)(2616005)(356005)(70206006)(54906003)(36756003)(7636003)(110136005)(316002)(82310400004)(5660300002)(36860700001)(40460700003)(8676002)(4326008)(508600001)(9786002)(7696005)(7416002)(44832011)(6666004)(8936002)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR02MB7371 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1NAM02FT031.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a72fa3e3-44f3-42fe-b559-08da12790de0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l1rAP+i6XsJTaMGWe61h0/O5w+l8Mcl539NNxO15NZnGXPpMikrytqFeQkIfCnYim1lsxm4lwvhqik+6p5GVSz9JlMbCHF/jDoRocH9zvNSqhXDvxdlD5Js+owD4VDBuOP2zw624DRDgczNfD8nrBWQmjTGhCeumurbmqhgqxJV7W38rU1MsJnPGQiqhyTVCVkeTZ2H+7rbcscm111qDQQkNAMZJ886C3RpmCdrDl+1YeCmNrVH48Pf1QoKfaZfQjnFYeCpqZXeAEIyEEdGpf0ESXE1gREYRhHP9D8uHvd08xc355nfRe+yJbUgmm425FGaefbpeXCU7gkuR/+C5MpXCiqf7xlV3okNAUfQT10DZ4JCHwHjnseTUe365HeiFI5ZwmAPP3bEzn/OdzAhH7ysqIucYz7fh+GShMTXoS3f5/1tebwV+M3oB56X1U5W4+jojbWY0O2qy+44XGb7/wyHm7eRXzWZvUPBxHPYOIS8MdGVkm5NuN5mwP8tSsYqm4VY0KC13UK/n/xX8pCtWpC1yQZagF0jWNvQWUJTMY3ddVjVza8XijhjYrnnDY1eHbaJrdGArRi5PdTQ4A0iDj9nW/O8rabNDbRI6J3eI7Cx1cHpwWJuA8EOxLp8Mp6lfDSSpIy14StClKnvPzGpiyRo+A8FqM+MUr3LHmWdIqpiM1/yLWx3/oB9fghIJag75p20waOVpoKOD/+FwAgff+hLxFwUh/q9wHhbi+d0kvjsC94l7AmXnn9FUA7TUgbhK X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(1076003)(26005)(186003)(336012)(426003)(81166007)(44832011)(83380400001)(2616005)(4326008)(7416002)(9786002)(2906002)(5660300002)(36756003)(8936002)(47076005)(316002)(82310400004)(54906003)(70206006)(36860700001)(8676002)(7696005)(6666004)(40460700003)(110136005)(508600001)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:13:59.1340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e80a667-bf71-4624-7b4c-08da12790fe0 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-BN1NAM02FT031.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB8371 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch converts the vhost-vDPA device to support multiple IOTLBs tagged via ASID via hlist. This will be used for supporting multiple address spaces in the following patches. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 97 ++++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 174c9e81df4e..cd1bee536c46 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -33,13 +33,21 @@ enum { #define VHOST_VDPA_DEV_MAX (1U << MINORBITS) +#define VHOST_VDPA_IOTLB_BUCKETS 16 + +struct vhost_vdpa_as { + struct hlist_node hash_link; + struct vhost_iotlb iotlb; + u32 id; +}; + struct vhost_vdpa { struct vhost_dev vdev; struct iommu_domain *domain; struct vhost_virtqueue *vqs; struct completion completion; struct vdpa_device *vdpa; - struct vhost_iotlb *iotlb; + struct hlist_head as[VHOST_VDPA_IOTLB_BUCKETS]; struct device dev; struct cdev cdev; atomic_t opened; @@ -55,6 +63,51 @@ static DEFINE_IDA(vhost_vdpa_ida); static dev_t vhost_vdpa_major; +static struct vhost_vdpa_as *asid_to_as(struct vhost_vdpa *v, u32 asid) +{ + struct hlist_head *head = &v->as[asid % VHOST_VDPA_IOTLB_BUCKETS]; + struct vhost_vdpa_as *as; + + hlist_for_each_entry(as, head, hash_link) + if (as->id == asid) + return as; + + return NULL; +} + +static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v, u32 asid) +{ + struct hlist_head *head = &v->as[asid % VHOST_VDPA_IOTLB_BUCKETS]; + struct vhost_vdpa_as *as; + + if (asid_to_as(v, asid)) + return NULL; + + as = kmalloc(sizeof(*as), GFP_KERNEL); + if (!as) + return NULL; + + vhost_iotlb_init(&as->iotlb, 0, 0); + as->id = asid; + hlist_add_head(&as->hash_link, head); + + return as; +} + +static int vhost_vdpa_remove_as(struct vhost_vdpa *v, u32 asid) +{ + struct vhost_vdpa_as *as = asid_to_as(v, asid); + + if (!as) + return -EINVAL; + + hlist_del(&as->hash_link); + vhost_iotlb_reset(&as->iotlb); + kfree(as); + + return 0; +} + static void handle_vq_kick(struct vhost_work *work) { struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, @@ -588,15 +641,6 @@ static void vhost_vdpa_iotlb_unmap(struct vhost_vdpa *v, return vhost_vdpa_pa_unmap(v, iotlb, start, last); } -static void vhost_vdpa_iotlb_free(struct vhost_vdpa *v) -{ - struct vhost_iotlb *iotlb = v->iotlb; - - vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1); - kfree(v->iotlb); - v->iotlb = NULL; -} - static int perm_to_iommu_flags(u32 perm) { int flags = 0; @@ -876,7 +920,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; - struct vhost_iotlb *iotlb = v->iotlb; + struct vhost_vdpa_as *as = asid_to_as(v, 0); + struct vhost_iotlb *iotlb = &as->iotlb; int r = 0; if (asid != 0) @@ -987,6 +1032,13 @@ static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v) } } +static void vhost_vdpa_cleanup(struct vhost_vdpa *v) +{ + vhost_dev_cleanup(&v->vdev); + kfree(v->vdev.vqs); + vhost_vdpa_remove_as(v, 0); +} + static int vhost_vdpa_open(struct inode *inode, struct file *filep) { struct vhost_vdpa *v; @@ -1020,15 +1072,12 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false, vhost_vdpa_process_iotlb_msg); - v->iotlb = vhost_iotlb_alloc(0, 0); - if (!v->iotlb) { - r = -ENOMEM; - goto err_init_iotlb; - } + if (!vhost_vdpa_alloc_as(v, 0)) + goto err_alloc_as; r = vhost_vdpa_alloc_domain(v); if (r) - goto err_alloc_domain; + goto err_alloc_as; vhost_vdpa_set_iova_range(v); @@ -1036,11 +1085,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) return 0; -err_alloc_domain: - vhost_vdpa_iotlb_free(v); -err_init_iotlb: - vhost_dev_cleanup(&v->vdev); - kfree(vqs); +err_alloc_as: + vhost_vdpa_cleanup(v); err: atomic_dec(&v->opened); return r; @@ -1064,11 +1110,9 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep) vhost_vdpa_clean_irq(v); vhost_vdpa_reset(v); vhost_dev_stop(&v->vdev); - vhost_vdpa_iotlb_free(v); vhost_vdpa_free_domain(v); vhost_vdpa_config_put(v); vhost_dev_cleanup(&v->vdev); - kfree(v->vdev.vqs); mutex_unlock(&d->mutex); atomic_dec(&v->opened); @@ -1164,7 +1208,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) const struct vdpa_config_ops *ops = vdpa->config; struct vhost_vdpa *v; int minor; - int r; + int i, r; /* Only support 1 address space and 1 groups */ if (vdpa->ngroups != 1 || vdpa->nas != 1) @@ -1212,6 +1256,9 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) init_completion(&v->completion); vdpa_set_drvdata(vdpa, v); + for (i = 0; i < VHOST_VDPA_IOTLB_BUCKETS; i++) + INIT_HLIST_HEAD(&v->as[i]); + return 0; err: From patchwork Wed Mar 30 18:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41324C433FE for ; Wed, 30 Mar 2022 18:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349791AbiC3SQn (ORCPT ); Wed, 30 Mar 2022 14:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349900AbiC3SQ0 (ORCPT ); Wed, 30 Mar 2022 14:16:26 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DE6D5F94; Wed, 30 Mar 2022 11:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TLeIN+fhq8gkKNXJNNj252Lf+cxl6pHIXlqUJ4toR08=; b=S4sIbPrhGzA45E5zdFaOMSfZQOqcjXdFhI2IqZCUH8ESpxFTSC6/HJGWBo/JXHqHF3luMYRVr3XX9Hof7S6ujoWtgNnvTctVpN5xqyIoMYfzc39V+4QhR3pg+h3r9EJRQrph4dnkPFs6fEgpViQ7x1dIsnVFmLB1WOAoKNCj6BU= Received: from SN4PR0201CA0068.namprd02.prod.outlook.com (2603:10b6:803:20::30) by BN7PR02MB5044.namprd02.prod.outlook.com (2603:10b6:408:25::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:14:39 +0000 Received: from SN1NAM02FT0058.eop-nam02.prod.protection.outlook.com (2603:10b6:803:20:cafe::d7) by SN4PR0201CA0068.outlook.office365.com (2603:10b6:803:20::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:14:39 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=xilinx.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of xilinx.com: DNS Timeout) Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0058.mail.protection.outlook.com (10.97.5.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:14:37 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2048.outbound.protection.outlook.com [104.47.51.48]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id E714741CDF; Wed, 30 Mar 2022 18:14:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HeSI1AxeSPCrJLviLPFlxDat++DJDyxVLFMMWGoQPkaXknZfMTdE3UAtWCJu62anieLZPxfU4aOjlmYFsPJ6gHpOEF8lixd5SsEheR2XXmkr7UPceS3OEL1w1fZ8jqyx9vnZpttDCGSfIaXkWxQPnIvTz0tsiiYkCFIh7AlA9miK1T1K4JWr+Tjf+OFiB6GXa7GwBBmGdfS8uDkU5Ujc0YXaSvuMpjL0J1+15XPgKWKJ04HAlmfXwzTXPlETrTHxL95MtK2Rv7Py+hy+Gcf3QlNMPXp4xg6UDos8h+kkYcokFfVXea+vZYWph5YH8Tz7+RyMx49oQASephHxtxMIEg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TLeIN+fhq8gkKNXJNNj252Lf+cxl6pHIXlqUJ4toR08=; b=J3aoRdD+Sq6upTs4GcOEepr4WxCN3Y4kgjJqIp56ns+NV4l5w8G448fDkhO4k1YzOfx3qXKFstBvYIQri1zKMSs5cYFKWm3gEu7Lq/R7S/fNojayx4/RS7M1xok1I4zjyXD+L4Hpkj3FM2T778343TwRp3or2+WXYbpuhRL8e8fQJ7qO5ZW8rJJIoJ5w9FD8/eoPVeydIYTjRxtPfmKFuO8gz9XVF1DwWVA0bzQcruGH9RCAAjJ2QvBntZnEVw+YhI2QZnmYy8xCRIFtXIgfR2VK8OI4hgoNyxZMoUR26aH7awr12c8tK+IXVosN95RSxGmjia7ezPilt0RHYYimlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN0PR07CA0011.namprd07.prod.outlook.com (2603:10b6:408:141::32) by SN6PR02MB3982.namprd02.prod.outlook.com (2603:10b6:805:2d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:14:34 +0000 Received: from BN1NAM02FT020.eop-nam02.prod.protection.outlook.com (2603:10b6:408:141:cafe::50) by BN0PR07CA0011.outlook.office365.com (2603:10b6:408:141::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:14:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT020.mail.protection.outlook.com (10.13.2.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:14:33 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:14:13 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:14:13 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcpg-000CCQ-JZ; Wed, 30 Mar 2022 11:14:13 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 11/19] vhost-vdpa: introduce uAPI to get the number of virtqueue groups Date: Wed, 30 Mar 2022 23:33:51 +0530 Message-ID: <20220330180436.24644-12-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 9fad284a-04f6-4aaf-fb31-08da127926ab X-MS-TrafficTypeDiagnostic: SN6PR02MB3982:EE_|SN1NAM02FT0058:EE_|BN7PR02MB5044:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: EMT/v+O+q6R0I+fKZKym2boRLOuqvSsV7byxcDl6rd7vqwF+4YWrjN3cRbZPXSwv6roh7mGNglcQJ1/yLHq7kHIhkM+mgLhLkW5xw7QTLQ+VmXZx4WtC6TD9zTfszFZF3geZxW1KO5K1TPTfFdZPENHbGIb3JH2QqLlopHxZIy+01YEpNCnzVA5Sm3oGzk1cCTuUpx1WQtS7sARMmO4+KCJN9pC6NdAyd94pczLsrM5xne1MjPQYyC5FkEalZ9aGvZcBNhXuvtSrd+qhwHmmb52hDCW8TidXKLgyfaVBnLmslxC7CRQxkoTDHzJh6cJDXty8ZwtZifylbCZuEi02v59FtPfWeEHZQtRoi5ZvKDNn3BaPyvHG2YG5Pdr1Jf6hRWp2xF4oXmpesR8SqR0TfoTjSb1MwubYIP76B5dyXQTGk8BGdrtO51zCRhVkx7EknEbMydqeQcZSSuNAI7+HMjUXs2ogaZ5xgnfiLJY5DYADMe41VYoWflLbMXrW3DKUnSu/iB7tDhhuXZ6l6Jr/08JXV4+SG72WYPDX5L3TN3Enhsqpf7V60ln1U0cWM5LnKsZ1E+2O1wQgwL9C58yHTSa2XS+zfdDSX7/T3HcEHRgi1Ms7q1a8UkOMxzWHEUPy+ni878PFfw0QGdNDnpIcml7/HI+u6WYitmSdCcV8eteZ9AzwYwjvJG3ajALUOXMFi8Xa0O4q31HaoZsD0TguzJZSiHLhse8Nql1oFWhWJVo= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(36756003)(356005)(7636003)(70586007)(7696005)(2906002)(4326008)(316002)(8676002)(70206006)(83380400001)(6666004)(40460700003)(36860700001)(44832011)(426003)(54906003)(47076005)(2616005)(336012)(5660300002)(110136005)(7416002)(9786002)(186003)(82310400004)(26005)(8936002)(1076003)(508600001)(102446001)(15583001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB3982 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0058.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 51078932-8b67-45c7-b08b-08da12792496 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xnO0Pi4PFbMHchD/D9IlMh9dRveupeG4lMpsWbFi19vY0FNvp8ES2p2TMT9vs65D4cSi6Ge6SAotY4GoE02lQXZeYlwl/v9EIQENWl8LJHpas9rgvm8EJguXiBZjUAIorsH+GfAT9g7bXuIpr5fFC6zMBrYm6U7nzX1xL2fKTknhq37ZQ8BBLJhaxWAzO22WKV8LPes9aYEM7cJo1aTg3Uvu9pK3xYX93cTAZ9UDUg73OwXqLyPai/b0QGOorYlk9N1pmYaR95wuyeKteGE3917PyOYxoRttOKqQDivaf5WCKUn3Wr4uSNAV9eLbbUGUCTLuzV/B+kqHiZk0nm0XRbEzvzJj1lGZPC9FoPqOrbuVSNqrYC2X6grJEIm8VtpUGBv3FAl4/JeaT2K5dBBKdW/Wj/DEqslWuBrwjexoGQ/f+Cuzr7jN8hooZKpF3LeTO+ddIM7JuTvsJ075e1XifTDvxICujo49OSWOXpH32Px/tLyHpuDZwpt1Z6JcRQQk2f2EShro7ds4ljSk3zuaKRl72TQ1MXTa0EZ6pZMrvLKPnwtnOxVPfFS10zb7HLLwg/IcfChkyuvbAD+jZh0yAPRhiMRNMUoKyHy59GH2JkYj+LZnRQKfan/hhScq8a8nY0v97ua19RYm2LKFLFFHTW6Kj8n/MUeFAfFpZOkSTYntO5Rl8+nrBgigGAqM0wDYLXSx5zF4vSKraMvJ2uTn5czN+PkvXj1Rw933KemJp/SmJ2vt/Sz3cEkQTTzPVJbk4fw1JMoybkokJwzFiRqxuA== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(4326008)(8676002)(36860700001)(81166007)(54906003)(110136005)(2906002)(40460700003)(316002)(336012)(186003)(5660300002)(8936002)(63350400001)(9786002)(426003)(36756003)(1076003)(83380400001)(63370400001)(70206006)(47076005)(44832011)(7416002)(6666004)(26005)(2616005)(7696005)(508600001)(82310400004)(102446001)(15583001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:14:37.4244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fad284a-04f6-4aaf-fb31-08da127926ab X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0058.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR02MB5044 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Follows the vDPA support for multiple address spaces, this patch introduce uAPI for the userspace to know the number of virtqueue groups supported by the vDPA device. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 4 ++++ include/uapi/linux/vhost.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index cd1bee536c46..92f78df0f685 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -559,6 +559,10 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, case VHOST_VDPA_GET_VRING_NUM: r = vhost_vdpa_get_vring_num(v, argp); break; + case VHOST_VDPA_GET_GROUP_NUM: + r = copy_to_user(argp, &v->vdpa->ngroups, + sizeof(v->vdpa->ngroups)); + break; case VHOST_SET_LOG_BASE: case VHOST_SET_LOG_FD: r = -ENOIOCTLCMD; diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 8f7b4a95d6f9..61317c61d768 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -145,11 +145,13 @@ /* Get the valid iova range */ #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ struct vhost_vdpa_iova_range) - /* Get the config size */ #define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) /* Get the count of all virtqueues */ #define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) +/* Get the number of virtqueue groups. */ +#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) + #endif From patchwork Wed Mar 30 18:03:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D749AC433F5 for ; Wed, 30 Mar 2022 18:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349915AbiC3SR2 (ORCPT ); Wed, 30 Mar 2022 14:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349918AbiC3SRS (ORCPT ); Wed, 30 Mar 2022 14:17:18 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2083.outbound.protection.outlook.com [40.107.243.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03FE8654B3; Wed, 30 Mar 2022 11:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7NFbMzJTO3OxwwdIRZlHDzzTQ4bZkkWtfHEDZBHx9i0=; b=floVBQVGrsnPFDa+3v7rqE9FSH+Pu4h4oSpqZX1aRP/2ZMhORY8f/Faqx2hiNeDdY5TuwFdMrMppxCcuF1kws/N3ruZefD70BO44+gk9s3saNgjcEUnCQEGmRPpJjKfwqLP/aofQUBkxAoHpwfLHL4FkOE3q2yfvmNCtEbznj2Y= Received: from SA0PR11CA0053.namprd11.prod.outlook.com (2603:10b6:806:d0::28) by SN6PR02MB4014.namprd02.prod.outlook.com (2603:10b6:805:31::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:15:30 +0000 Received: from SN1NAM02FT0053.eop-nam02.prod.protection.outlook.com (2603:10b6:806:d0:cafe::c) by SA0PR11CA0053.outlook.office365.com (2603:10b6:806:d0::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:15:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0053.mail.protection.outlook.com (10.97.4.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:15:30 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 23DED3F03B; Wed, 30 Mar 2022 18:15:30 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qsl270JWNTGRseoXanZmjWwKj09F72Qs2iOEgaie18XHSQjHen/1H2EC5gtGi2VG/nd3RWbaypyKT2idBntvBeLHsv+BdtW394ypj9zKp6rV5/sMQY37va1lPPkDe2W//8n5WjoIchEZRUxcTB/5peHuSYr+thHHB51bmvG/XtPAT0384BIBYA96JI7mErb21ye9s7W5HEslzp5YZygz+l9adBz9V2swHI414rJo8QbqtstDW8fjzptA4SVFsI+aYx4FKA/FXNW/B3IZPSt24Hmsu/7Qv0hysaNCBP3jUufRk0GgTFyfW5xPSrqVHhcqRQ61MKxF/+3MuTeGrF85Bg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7NFbMzJTO3OxwwdIRZlHDzzTQ4bZkkWtfHEDZBHx9i0=; b=gkXCYEVNIJSAa/kx1/TWLz6eMbJxmLo/dcFX922Uc86xXdiS+azt11S+3OiioJJX3qc3FFdmmKkETAlDFIxzzz0MV905mbPShHN5xM2fSw4OdJ/aJHIIytzAREr3+Bc783amRt7JJoHJR/9McnRRVM3Hp3uhUimQrMjJXwSxlo1cj+QDs3yTDQ9s6x110iwD7/0/BHe7ABiHxzvQKCP2vKa+YoF0lg+ExfRJzXt5kcF9e+f0UScGbc+hwRaDLCvNSxyrL11l5I1m7+rjnH4/M8MuF0HgMbJR6BiHZPsUJ33XhOCCdZNsFxkQyfnTVnra8bG+5bh81S6hODzhZ/NXGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN8PR15CA0061.namprd15.prod.outlook.com (2603:10b6:408:80::38) by MW2PR02MB3737.namprd02.prod.outlook.com (2603:10b6:907:3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.21; Wed, 30 Mar 2022 18:15:28 +0000 Received: from BN1NAM02FT036.eop-nam02.prod.protection.outlook.com (2603:10b6:408:80:cafe::fe) by BN8PR15CA0061.outlook.office365.com (2603:10b6:408:80::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:15:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT036.mail.protection.outlook.com (10.13.2.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:15:27 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:14:56 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:14:56 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcqN-000CCQ-RG; Wed, 30 Mar 2022 11:14:56 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 12/19] vhost-vdpa: introduce uAPI to get the number of address spaces Date: Wed, 30 Mar 2022 23:33:52 +0530 Message-ID: <20220330180436.24644-13-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 24bdedf3-0bc8-40f1-7930-08da12794669 X-MS-TrafficTypeDiagnostic: MW2PR02MB3737:EE_|SN1NAM02FT0053:EE_|SN6PR02MB4014:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: y30d15eb3hbsFtrjlCNG8CH7FL0w303i/ccOOIG0Fz2a6Uv1Ym/h/7VB4qUs2sn88en/1WmORjOG97ofD8gheW0auXqVS23GA1VPbMuMmK29O8uPbGqV2pJLP/qWRmadVT8sLyspp1q4GM3teB8gQPPZXnCMiSRQZvTUDTaLTRfniCC/4Iq7Bqg/zQneyvLjT6iHsP94bgSBpjRluqJGBPKa9a1jnT1I2bOEQdprNuWDm+XM6tu3gHAV/67shENU3+QuZLlIUBt8n0Ch3QU7D/KqlEVblu4oHfFz/qp1Az9l2NXS1i3GFkEyaErEC+01dmm0r8xZ6dsSKvpeJ3tzWyByz8tlc21vRLcVT6BsEWTCRUnp3BE2kMP2LckdeuQq/O3bRYQCWCKne4qZYBYpe0hi73j9jO/YqGqtKY58fpw/hKTRDZi4Tg/pRbppVdsKvVexJoG4f11kKJrF43A84mHlZhgSKglbXUrN0dQw5iYfUgNwYcmVMM2W0NutUrqq5INdRonnBOUDILcVKH/zXO5akQU+mX8tFLLCk9SFOUrHGf2bCec31MolEnmWRwtLW+qW1ClEuIOr9/WXE0rvIOWWr+XgrLz4/LTBeLSvQx9SGDsbXpBB5w6e90HarJCpWm7ILzWKD0UStoh2s0SiIrZs/q4dgGiU3XJ2HSx9QvSWY3Uma2T9Y/ri2Hd9AuAa3/MELL6O6+UcFKCqK0dge1ahNDE5+qxskVV3AqUKjnc= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(36756003)(426003)(1076003)(508600001)(83380400001)(356005)(7636003)(36860700001)(336012)(7416002)(70586007)(70206006)(186003)(44832011)(82310400004)(26005)(47076005)(8676002)(6666004)(4326008)(8936002)(316002)(40460700003)(110136005)(9786002)(2906002)(5660300002)(7696005)(2616005)(54906003)(102446001)(15583001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3737 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0053.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e0cf7c2d-401e-4c28-c769-08da127944cd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lL2HnboubD+5gnTx14FKvzLft6eWmxtF5aOaHyrhnEhbbJtitvZySGQ30zaGDHf7a3jtbW1B5Es59cp2SNRHkkpu5EjpYyYap3BFjNBDSbDEogmDOKQSZYjTHLhmsJaqkUyX8McPBVzFA4XcFrTr5qO8xDTbOI+GdPvV8HOX5ch7RJvtJ2gJ/YWmV6XFkZ1AyT64XU2B4Vub7yrDMeTKCWmPiIKDb0EqTaKV7ahnm52g6SOAkjmOn1l8AdQ3MEDfFXHU/sfWDs3FNwXQidB97UoUOJrjntlZnAjs7WxREh7as63touooacCDTjsp2Elfg0njDE8W5EGZ4iot23SCpACyvvUJgA1al+KmpQdIX6KCnjEdT7wlry/XdCW1knMBqkneRvjjHOc8uLXCmh6QOl8b5TTT5FmzLR/9FsMnRLjeBxhewcKw28dOmjriOikkSIO0lmkhUZ6I0t/C+hzOvsZF9dwEe/XHdZnyzvlkeNIAKEcn4O+hWoKXiL6r7mEnY/h72+zbOeEH+UiOrt7H16amMYrHyMygtnCQyYiHWVkZkZiYk7e/wNPOnwydfzWG48eht0xphKoqU6c/dUK0BkesfzvyZYRV8w+iFVYNiIJu+qxPEF98vlYfda16zm7FxO0pPHz0z5rjgF/kbZ2OMmr0SeY7zdYdoP8XHxe/F9BI6uOHeBhec2PclFqlEmlo289xZ9hxS3Yd63SVM2AsvOtRsWQmMo4cBlOUhaQGHOpk7wT2JAnpbpWZCdad+paxJ8z8lej7/kRGiTaDgpkE2w== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(47076005)(316002)(36860700001)(54906003)(8936002)(426003)(5660300002)(336012)(36756003)(81166007)(508600001)(110136005)(4326008)(70206006)(26005)(6666004)(82310400004)(8676002)(40460700003)(186003)(7696005)(9786002)(83380400001)(7416002)(2616005)(2906002)(44832011)(1076003)(102446001)(15583001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:15:30.6756 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24bdedf3-0bc8-40f1-7930-08da12794669 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0053.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB4014 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch introduces the uAPI for getting the number of address spaces supported by this vDPA device. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 3 +++ include/uapi/linux/vhost.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 92f78df0f685..a017011ad1f5 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -563,6 +563,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, r = copy_to_user(argp, &v->vdpa->ngroups, sizeof(v->vdpa->ngroups)); break; + case VHOST_VDPA_GET_AS_NUM: + r = copy_to_user(argp, &v->vdpa->nas, sizeof(v->vdpa->nas)); + break; case VHOST_SET_LOG_BASE: case VHOST_SET_LOG_FD: r = -ENOIOCTLCMD; diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 61317c61d768..51322008901a 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -154,4 +154,6 @@ /* Get the number of virtqueue groups. */ #define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) +/* Get the number of address spaces. */ +#define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int) #endif From patchwork Wed Mar 30 18:03:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51DE8C433F5 for ; Wed, 30 Mar 2022 18:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349941AbiC3STw (ORCPT ); Wed, 30 Mar 2022 14:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350028AbiC3SSA (ORCPT ); Wed, 30 Mar 2022 14:18:00 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C0960A82; Wed, 30 Mar 2022 11:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L0BsGdQsZOVSkg/wQOptjKuV2l1vscjGpi+dmt8KFR4=; b=pJ+IXe8bU+krPKpceMc/XE9XWbQLyw+l4ZPIDtAbXXbD4B/kdYofIMXLV69j91ggHoHAY0HZkjd5hCLGLMvAMMKY0Ju2lfVhgaNKU/9cQLO7RpTwyTA9Ca04JbcdTqiqDCcN99pHSFBpJldMIDtl32u5xuRKDPSbK6Y5hi3pzuk= Received: from SA9PR13CA0025.namprd13.prod.outlook.com (2603:10b6:806:21::30) by DM6PR02MB6250.namprd02.prod.outlook.com (2603:10b6:5:1f5::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.20; Wed, 30 Mar 2022 18:16:06 +0000 Received: from SN1NAM02FT0056.eop-nam02.prod.protection.outlook.com (2603:10b6:806:21:cafe::c7) by SA9PR13CA0025.outlook.office365.com (2603:10b6:806:21::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.12 via Frontend Transport; Wed, 30 Mar 2022 18:16:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by SN1NAM02FT0056.mail.protection.outlook.com (10.97.4.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:16:05 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 035CA3F03C; Wed, 30 Mar 2022 18:16:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=moInRE4BZLRt01ALn+HNfqtqFzvCj8AoJEtEj6XDQ38PukVkClp98jo7qyCkY5kkhTDBPAk6d6UPdluUYhjwILzVNWiwFarLawE8Okptl2OWC5d1+Tp0Iopu2YZI7rVPLi50ETZ6mPceNhaNsEL1TBh8dY3qWU5QFYi+NI+Jr5fytC/ovYyKLoTY7pPXPw3g8X16R4Uz714L6YxsGSu5uexuZmXM1VChjfMrfi8K6aXMv11uDYO6n56fjYa/cvo2jPGFOFn8QEwpLunzgjFUCEVIJihHi0sjXjAF7RJYLzG/DqMoP3UgOMNhToi63vuHmwZoaPQazpySU27wROZ68g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L0BsGdQsZOVSkg/wQOptjKuV2l1vscjGpi+dmt8KFR4=; b=FJjfmrfzEa9Nw0u9E7kLfp4Re5sMGLe4SvfHW4BWShYtfsjeWBeYnqQfLNTjg5EmQdmpzAxY6KBzCuLmLw7QVf9zSaSzn6CeWOpPDVpjivCcVqd3gxnK8yy2ep79tla7NWqOwZaLp9HxgbUd2hkkTuswJ6EcApsaamSEAvwnYpXhi6UKtALuggSCqbp/63uuT+6L445J7HAJYDYEQ6O2MXwg8Pm5QSMRv9ElUEKltwfZLkerFQBeC2S96Y6ndYkx637FoAp8rmQFQjip95m16vDKumILR+3A/JPbIGbVGQ2ckznWtFlxMjcy+XxJguFOlF0/hEMkABAme+R/86xe3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN6PR1201CA0023.namprd12.prod.outlook.com (2603:10b6:405:4c::33) by BYAPR02MB5349.namprd02.prod.outlook.com (2603:10b6:a03:67::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 18:16:02 +0000 Received: from BN1NAM02FT047.eop-nam02.prod.protection.outlook.com (2603:10b6:405:4c:cafe::6c) by BN6PR1201CA0023.outlook.office365.com (2603:10b6:405:4c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:16:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT047.mail.protection.outlook.com (10.13.3.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:16:01 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:15:40 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:15:40 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcr5-000CCQ-OK; Wed, 30 Mar 2022 11:15:40 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 13/19] vhost-vdpa: uAPI to get virtqueue group id Date: Wed, 30 Mar 2022 23:33:53 +0530 Message-ID: <20220330180436.24644-14-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: dea6366e-9682-4bd8-44ca-08da12795b4d X-MS-TrafficTypeDiagnostic: BYAPR02MB5349:EE_|SN1NAM02FT0056:EE_|DM6PR02MB6250:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: THE+A/iX12LrmClIWmokAcNMtVS8k2vPs7NdPThaMSDkB+Sw/cGVX4WE1Yn9DZ9sFrCivz2k5mkhvSNHKoOSOjbGkhryQDhZkDmuISEcadg6qwhKRFoecPthAsdQFEzuz2dm58xPadmjWJTGIW9wWpy3xOMAt1ANQY9W+s+AQlgPw+MtkYDg1s/PZEzJobWhQY2O6h7eIWNHsMs/io2tLTRJ5GwTSmw3PxeMlg2tkRLSmUm6yhrRZOzx0T9ta5mXjBAKrxdVApiGE27E7zq0DUqH1BvfrFWGAJkzUU/HWXltfNXTVx0MxoUs8N06Pi+NHtbe4gdj5x79zlg36nFGd2LvQbWTbBgmMeB+ze+ETdMC3udOonmUu6MJVKk5CM0CIv1sXdL/7iXGO0MV0IaY0xJk0FnfyjL8I9Hk5a3LMHDM6lfk63TKGI/aLK+ocOFp6j273sVC4uGF3J2eCI3q7qCGFvaYsh+zMCxJpSZ7rb+7pIULnC37HjR17/wkAYS6XoiC/Mr00JNDawrm+sfRIExx6ZGvTrEB4BmCZl0Tig4J88AFOHF7knBcbW8WjhWZfWtQCzrDy+3QdfwuSa3BMIMsoCMzliYwFIU8b3Hx3Dcns1DiiSkEpAirJqSJXSCzp8fglFCwzT0l6zgP4aqosd1HD70nWXTn+iNy+7tHyzqYkxla170FyHYIx9LvADDPZ6tCYZqa5Cg0LmIQ67g0ng== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(7696005)(44832011)(8676002)(83380400001)(36860700001)(4326008)(82310400004)(1076003)(26005)(186003)(336012)(426003)(2616005)(47076005)(2906002)(70586007)(70206006)(508600001)(316002)(5660300002)(6666004)(110136005)(7636003)(9786002)(54906003)(36756003)(7416002)(40460700003)(356005)(8936002)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB5349 X-MS-Exchange-Transport-CrossTenantHeadersStripped: SN1NAM02FT0056.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0dacc4f6-2aa1-45af-38e5-08da127958a5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zub0LPYc7gNas1MYTMbZXB4zGt+K05oX8ZqJcb33mkDl0ZD0m06h2fwDm6DYuOg4BpeV2iYL2VHeKzfTjTduJEBfVgebKIszoN3vTxwo1cD6f1RM5f3zRN6sdlRJ3OiTHG6dTf5PlWhtO4vJkCD2mvbn6RdDH9wKE6lSNc1Mr/nsrTD3FyWIUNrG8KPklO6xE9e9NwWjfrKRCdb1L65pp367vpEHMYX58oF23Z5YDCk+3J26PPrwGt+nLPrBRjHGTtktBO0DNTCx0N+LDEbbfRrJUkS6qtU3VOJ5iR0JrhEgHwpN4bJjzjsH/zU8aK++pGlLhqmpGRlzhZnSUZ83vfx9ERzXulVPGbER1mSj9ZCFSmn/1qCt/O5v7POavxXuCaChwSedXKuCClVF0gwX3IvaErQwc0Hi9KUL36mUagoNBq3RcGzud3h5fYle0vn4nU+OusmH9RmHXsu3gAgzJzIC8fMOYuH6fVfGpbOqKAe5wI2Ym0EuR4H9vR8T3t6+Wd8AdnTb6i2oS5nEzy4bMdnRonNZrWeCClXXB0Hgo4E1MhuHUf6fNt/ye9bPJhj8Yo4sjZG/9hdJhYzX5N7JXMZOTS+/wvWW9SzTsh72AdukO+xAYQRb0PiKTthYGZXL1oEb363Cu9Pq58LywGG7m7htHLPNlpLO5ECesgpJxsvajLEn25AnkvNjJK2/11ln4yrLpqovDTt/gEpPn1mFti7SLVDo3g8MzUNWkNr2FRlEoZyxjseCZx3p9xZddDlG X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(7416002)(2906002)(7696005)(5660300002)(83380400001)(26005)(1076003)(186003)(44832011)(9786002)(36860700001)(36756003)(8936002)(6666004)(2616005)(47076005)(70206006)(81166007)(316002)(508600001)(40460700003)(426003)(336012)(54906003)(82310400004)(4326008)(110136005)(8676002)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:16:05.6761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dea6366e-9682-4bd8-44ca-08da12795b4d X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-SN1NAM02FT0056.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6250 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Follows the support for virtqueue group in vDPA. This patches introduces uAPI to get the virtqueue group ID for a specific virtqueue in vhost-vdpa. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 8 ++++++++ include/uapi/linux/vhost.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index a017011ad1f5..aa5cacdc5263 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -465,6 +465,14 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, return -EFAULT; ops->set_vq_ready(vdpa, idx, s.num); return 0; + case VHOST_VDPA_GET_VRING_GROUP: + s.index = idx; + s.num = ops->get_vq_group(vdpa, idx); + if (s.num >= vdpa->ngroups) + return -EIO; + else if (copy_to_user(argp, &s, sizeof(s))) + return -EFAULT; + return 0; case VHOST_GET_VRING_BASE: r = ops->get_vq_state(v->vdpa, idx, &vq_state); if (r) diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 51322008901a..668914c87f74 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -156,4 +156,12 @@ /* Get the number of address spaces. */ #define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int) + +/* Get the group for a virtqueue: read index, write group in num, + * The virtqueue index is stored in the index field of + * vhost_vring_state. The group for this specific virtqueue is + * returned via num field of vhost_vring_state. + */ +#define VHOST_VDPA_GET_VRING_GROUP _IOWR(VHOST_VIRTIO, 0x7B, \ + struct vhost_vring_state) #endif From patchwork Wed Mar 30 18:03:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 123C8C433F5 for ; Wed, 30 Mar 2022 18:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349893AbiC3SSb (ORCPT ); Wed, 30 Mar 2022 14:18:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349829AbiC3SSa (ORCPT ); Wed, 30 Mar 2022 14:18:30 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2041.outbound.protection.outlook.com [40.107.95.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD5F2018A; Wed, 30 Mar 2022 11:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UxXkC4kjw0lLUqHoJHRLT3ulv/WeAZoKimJhPTcmMaU=; b=C57pLAQsPigqoR3YrVUZSjC3lQ2nNNhByz7f+6Gt9Xv/ttAjDLzsMMo6vUx28Lga051cLXV0m5RXK2PmL9XU0FUgvD/EEEngDE/pG5wFbKPusggxmiopX5oNiBZJkon28aHz2sXoS2EK3xYx6q6b5dF2mdu5Eqs3KFxh+765SIU= Received: from DM3PR12CA0094.namprd12.prod.outlook.com (2603:10b6:0:55::14) by DM6PR02MB5339.namprd02.prod.outlook.com (2603:10b6:5:51::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.22; Wed, 30 Mar 2022 18:16:41 +0000 Received: from DM3NAM02FT049.eop-nam02.prod.protection.outlook.com (2603:10b6:0:55:cafe::b4) by DM3PR12CA0094.outlook.office365.com (2603:10b6:0:55::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:16:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT049.mail.protection.outlook.com (10.13.5.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:16:41 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id EB18E3F03B; Wed, 30 Mar 2022 18:16:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjNtiwn/VTVCSJN27k90QULY02xcXJr6PK0VB1sFiUIkFWFCJTeTguDw7mUjHqvto+IFTEjOoa//AiGg4m7EWixmpyXd0dTCX3nvQ6uLWSQHoFxZTU2wLD9vxFwhO7lzBnizETOVI8Xkxzw/SEcjg88ZpKk1Y6zzTSX+tZwG8Rj6UTD15qaQ7Kv4Z/UrJtoc1UQ/Z9aYjGp8KER7DBWgJDkne57bR2250ibcdK79x4d07mSO08MuyezcvXV/8UJcS9y00BrFl1QvpyvYGruOU40fZ5yannM8ztrYhRB4X2MBdDFzBeblLhxI1+cuO3Qmz0ax9mtlof1s0H8j/+x7bw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UxXkC4kjw0lLUqHoJHRLT3ulv/WeAZoKimJhPTcmMaU=; b=N2/4a0/0ooZUIdlERPMqzRJSo3xwQQwhaJKoHnb0KNwipkemFKZgONqtgGhi7XqXeVtPGsbXTmtsQ3WmyTegvW/9pcj7R3GGRDj3m9gyE7+3FOBMiskgG2yFDJKfxHnaSVvFM04idlObjOHKdAPjUUsIjBpaS9ri4ykilr+glKhow1NjvPo/LyMBZsLY/lUD3vcwMx8iCi3kQRn++R8oHmCVnnpW+Nqt0jgsfbE/W08sduXeUenUHuMSlhJnjsvAUdA6bIGxP/DJU+cvm3R707ee2u0XhkhXONVMZTzmn/BKsGnYFrA66x6dzyI7aPG1sToivz9eWKcCF5BI2H4yow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN8PR15CA0052.namprd15.prod.outlook.com (2603:10b6:408:80::29) by DM6PR02MB6395.namprd02.prod.outlook.com (2603:10b6:5:1d0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 30 Mar 2022 18:16:39 +0000 Received: from BN1NAM02FT003.eop-nam02.prod.protection.outlook.com (2603:10b6:408:80:cafe::18) by BN8PR15CA0052.outlook.office365.com (2603:10b6:408:80::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:16:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT003.mail.protection.outlook.com (10.13.2.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:16:38 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:16:22 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:16:22 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcrm-000CCQ-BY; Wed, 30 Mar 2022 11:16:22 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 14/19] vhost-vdpa: introduce uAPI to set group ASID Date: Wed, 30 Mar 2022 23:33:54 +0530 Message-ID: <20220330180436.24644-15-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 8168ee60-2600-4614-6ed5-08da12797098 X-MS-TrafficTypeDiagnostic: DM6PR02MB6395:EE_|DM3NAM02FT049:EE_|DM6PR02MB5339:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: SwPQuvXORl0jYuzuxeF4swueniFiKM1sHdLH2boMy98X+FTKaai6F5LYhzLQALBcbz1EATrtrz0OfyZDK2Xq+YNn1Y0eozVQYF61f6r1zj3jkI3lm4XZpOTwGaiX9n1urjrl2BrpzjsgJa9waGjwg/mvtzGgrs6nsuuaS3G/Ic+nr0PL2D3ywQQkE5eW9PDbvsBQOy/UsPX3G1IOqMTy3qK8H3ohpSMl5WYTuNlPdyRyknSuLsMfeIKjihEg4qL6iafHh0RceE/nKt4m3DDOjxKipFClOmI7foxpF3P2oSqNiDliNI/gNAgzMZOiz7WJKjkWvdVQOl06WRGkyT9hKgC1fuQWoD43ubehN+B/9u3WsWl1eYuNROgUM8wGRXMqSPlf7Gi5pA9aX6t5BORjnsuJG0YXBGowTPCQxELTUhF6tuebpjYy7tWrXRGbJ1+b+HfRh8LESEgF2BZyQKeDpkAjD+DIp/XznW99MGqpZRsZ7Eq+n4Cxt75h2JG6BgLzIGIZZBgtgBtbI2IYuK9zFRebz/pVq3hLQa4L8kDzxQXoEsk2bVPP/SbKRmGD+9Ps/e2Q9iNJ0+/A/Kx2Pq8nQHaKt+njXzbbOkHix8VIYxZ/zzCWf0klKzn3tvWtUxT9NokGPkI8Lrq1hY+yxm2ZMhuC/JNbvTaqcbEX0rGM5Q7Rd5iZKHRsFxRcfRzxx34jXdkGjrL2aaPK7nBcDJo/wQ== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(336012)(8936002)(36756003)(7636003)(26005)(36860700001)(356005)(9786002)(1076003)(5660300002)(186003)(44832011)(2616005)(47076005)(7416002)(426003)(2906002)(70586007)(4326008)(110136005)(6666004)(8676002)(508600001)(70206006)(7696005)(82310400004)(54906003)(316002)(83380400001)(40460700003)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6395 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT049.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 75007473-c973-4a45-5541-08da12796f0a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KpJD2OrJEgpPReIPhLJkVLhFl9qGxcKqzCgJi6S36UIbfm9Bl0njxaVLKONcAoVhi6jdFvtWO5Qj/Cnq0wyeEpez/7GvyAFARU7qtYlRLNH2Qmam7E4jLZZcpL6RA5q6dbiK+kY6b99Jc7f7BzpprHwsTDqGdl+a5IxHSnmhANsUifMvrigmcV1Ay5gCX1al12QIIVAm1WdRdPdRjG2de25Yx/BwMji1Gdc+NOivR3piHRqd/u5o9oDUGB0RunOfGGDiFxo2Ws7uKg3V/Ulv8JKv446Peze5HiKHH41nFNLHucEY2ca0iQpSy7OZc514ANUjqR6+ILSctE3OJMb+cXkDTvWbEnKCRBYhYkIYMzPQED70FCVxS0PxuWzWcIRDbbk7lHUkvR+Q7zogw+I6ADUzngsE2fPPWILop2pUYbgOXz2OTimkozLOr7tZaYBi/EvsQM1ThBe/EcSCX0n0S8XvoDZv5pF9CaqiTW62fKqn68ue2u1YYkLNJ4eqwMWJ0zGlJotzm9CUkfUbme/AGY7HfCTX0COfIV/Zmoo5SdgbbyBpoCwUvbF7e42hYBfak/RzI/6Th6gZ512FCVOyktfBWiBR1Obh3ExQWgNQ5G6JuxORq8LPcXKcd6rPBxHOjI65GuT1Dzb53Inr6SZA5aPNtT4n4pQ+588aP/5hEslQJrznXrh9t9YZmBiqUVNLTD3xwm9H9TywmbtmW7yJIHcMamON7cvK7b0RzIyqOhP36tsRGrsD3z0EpUCndlbL X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(81166007)(82310400004)(9786002)(1076003)(4326008)(44832011)(6666004)(47076005)(36860700001)(110136005)(26005)(8936002)(2906002)(36756003)(7696005)(186003)(8676002)(83380400001)(426003)(2616005)(5660300002)(7416002)(336012)(508600001)(54906003)(70206006)(316002)(40460700003)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:16:41.4477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8168ee60-2600-4614-6ed5-08da12797098 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT049.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB5339 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Follows the vDPA support for associating ASID to a specific virtqueue group. This patch adds a uAPI to support setting them from userspace. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 8 ++++++++ include/uapi/linux/vhost.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index aa5cacdc5263..6c7ee0f18892 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -473,6 +473,14 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, else if (copy_to_user(argp, &s, sizeof(s))) return -EFAULT; return 0; + case VHOST_VDPA_SET_GROUP_ASID: + if (copy_from_user(&s, argp, sizeof(s))) + return -EFAULT; + if (s.num >= vdpa->nas) + return -EINVAL; + if (!ops->set_group_asid) + return -EOPNOTSUPP; + return ops->set_group_asid(vdpa, idx, s.num); case VHOST_GET_VRING_BASE: r = ops->get_vq_state(v->vdpa, idx, &vq_state); if (r) diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 668914c87f74..cab645d4a645 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -164,4 +164,11 @@ */ #define VHOST_VDPA_GET_VRING_GROUP _IOWR(VHOST_VIRTIO, 0x7B, \ struct vhost_vring_state) +/* Set the ASID for a virtqueue group. The group index is stored in + * the index field of vhost_vring_state, the ASID associated with this + * group is stored at num field of vhost_vring_state. + */ +#define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ + struct vhost_vring_state) + #endif From patchwork Wed Mar 30 18:03:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32CBFC433F5 for ; Wed, 30 Mar 2022 18:17:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349951AbiC3STM (ORCPT ); Wed, 30 Mar 2022 14:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349922AbiC3STF (ORCPT ); Wed, 30 Mar 2022 14:19:05 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04926580DF; Wed, 30 Mar 2022 11:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=esJHknQdTo2+BZfwxrgZ/rhILZWgCmUGuSy0sCnrq2A=; b=X/QBkIQ2KX6Gt9014Y2sIevaSLrayWdzJ4YJubt9ICJhw9SNdOA+I/XmFBySuXh9P9LdVXd2PtURxBy5ZNlY/sEtdu8IkKjVA7+EF+aGzn6+B6nJrVZnpbaIYzf4f0MGzMkRyhceluxRL0tfdoqOQoaE+WlKqy91i3HSt/TuVaY= Received: from BN9PR03CA0497.namprd03.prod.outlook.com (2603:10b6:408:130::22) by BN7PR02MB3971.namprd02.prod.outlook.com (2603:10b6:406:fe::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 18:17:14 +0000 Received: from BN1NAM02FT024.eop-nam02.prod.protection.outlook.com (2603:10b6:408:130:cafe::e) by BN9PR03CA0497.outlook.office365.com (2603:10b6:408:130::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:17:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by BN1NAM02FT024.mail.protection.outlook.com (10.13.2.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:17:13 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 03E8A41D82; Wed, 30 Mar 2022 18:17:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oChnJHB7qyHoTp7LJQOhcat8kgMU4Ko4/UBXtJHX/YM6nikCNiEOPPEWPEG7GFQHurJhzcjN7FPYz3QBNd7un0fxJ4RoDr+CtgUZQslGC1dWGkT1Ba9kWZcyimyU2L5Id8XHWuPL6ipYdkxoUmi+T6ynnXWbUxsTjr8IJUNYrHwg+ijB9uuTf9GIW/sh2y5NBhanQaxn/AwonSpgsliho7TBfJJrsnNK4tY+uS2gAlOGs34r1r0DVzIeZ/BuUIab9ttDmJcM9SUjUmkyc7Ond3I7DGnnHR8qL8rlBYQk26IpClT4Sigikk7mPMD71PtHPRPaNoDJJM2XhI60qPhv2Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=esJHknQdTo2+BZfwxrgZ/rhILZWgCmUGuSy0sCnrq2A=; b=S0HWMi4oNr8vzLg83qlcDRq7Y8JKmwxuqUOgMy0v2vgFgiMGXOl4QSrPdhjhSF6H0n/I9oGMYkf96Dv2tghLeTcv7La9lyRctWW8xnR+2z3A7QoCLtQOhu9mGmJsUry2CFuxKJAtr54YVs6A4HGVXLPh/K4pWohiJB5hCOG17wDbbh1PAPARSoEKUXR3dxYvb8mWlOzvrufgQpznRdIQ7x4PiEP82D2Ai5n22pWfeJSgqoOHazYiklv6jEyGyYybU2zEZIbBq/Atcme6w1ZQmsCiJ65P6Bb91keKAcDYio1IfHfj3Tjoous9BYtXTX9PBJlaMQi3NNYdsADau0GkcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN6PR19CA0070.namprd19.prod.outlook.com (2603:10b6:404:e3::32) by CO1PR02MB8619.namprd02.prod.outlook.com (2603:10b6:303:15e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.18; Wed, 30 Mar 2022 18:17:10 +0000 Received: from BN1NAM02FT054.eop-nam02.prod.protection.outlook.com (2603:10b6:404:e3:cafe::b8) by BN6PR19CA0070.outlook.office365.com (2603:10b6:404:e3::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:17:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT054.mail.protection.outlook.com (10.13.2.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:17:10 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:17:06 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:17:06 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, elic@nvidia.com, lingshan.zhu@intel.com, sgarzare@redhat.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, parav@nvidia.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcsU-000CCQ-5v; Wed, 30 Mar 2022 11:17:06 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , , , , CC: , , , , , , , , , Gautam Dawar , Wu Zongyong , Christophe JAILLET , Eli Cohen , Zhu Lingshan , Stefano Garzarella , Xie Yongji , Si-Wei Liu , Parav Pandit , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 15/19] vhost-vdpa: support ASID based IOTLB API Date: Wed, 30 Mar 2022 23:33:55 +0530 Message-ID: <20220330180436.24644-16-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 0f5aa748-db1d-4962-7dcd-08da127983d7 X-MS-TrafficTypeDiagnostic: CO1PR02MB8619:EE_|BN1NAM02FT024:EE_|BN7PR02MB3971:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: uMqXjwAtSEvSMUU+chXdXT8tBDmsEZUMLGwhcLVoHFThSOX4z8nfpdtbRMD+0Wj+vmyLsfRuBoFGPRUG+YhJR03XJB/S/4G/+xZo140SiVS8DNRYulP+mV9eTYfHqvuk14HrKF6as71nakvimFzS3/c/8UIctHHYGRsLEEiOswN1aavpWoS/aLYiSWB4MmLnBt4gx1iybWlRmePDSAN6bo3G5DAqLcyJZVSv6Gxl2SKKgPNuKkAkx0O9NX/+kzFbtdcRlHyvgbE/toE2RWwEZz1nNgAXbJvfn4+bWQlePto75R4lMBIVmX+Jmfn0K7yiicPBzFaAtRvgvSbJE7fqadF7gf3IUyRRleSDu8zI08o60gyEp0MCk3DwFx7qe3LcM5DgP6/Dncr2NG7SQKznIqTao2nlhwY0OjMKF++D8ZJu8wVzipsGWK+/iTzNtm8IaO/jxWWInwPLZWafYnhgcgApYNy7U2rkcV7uRwqy/+QpLdc+rLS96b+dBgQhX1MnUmo/PXmGXZDz+ZCKt/9vOAy9GhhL/Vtdcvcz40Uv5nr/dQcvVnJoKxaFvdhHYGjlRPIO7tB89NdkRdtCwuSvhecpR1BvdsXpEw4rKZs+eNqQffX0WN7b7GD4f62CKvo/SL3egr0GoWcz219rQUAMTXSXzsTX6qdu6ZtxGDEyQOYEIjEDtuxPM0s0rnKcJMQQFlEuJoJcH/4CJH5wdO6pcA== X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(36756003)(36860700001)(4326008)(316002)(70586007)(54906003)(6666004)(7696005)(83380400001)(82310400004)(70206006)(8676002)(5660300002)(110136005)(40460700003)(2906002)(2616005)(336012)(1076003)(426003)(186003)(508600001)(26005)(44832011)(356005)(47076005)(7416002)(9786002)(8936002)(7636003)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR02MB8619 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1NAM02FT024.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0ea5c464-ed9d-410e-4bb1-08da127981a8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MEJEnW42WgknA574EAJn7fi0/y80SMSipoMQ2k6IyHQh5MdgSd7CeV4gqBr/hqSb5A15C8S+VJI19Cyzfa/aAaYpeo6g2g6FEaMaBkDZ3YB5MAUPlkOTxMWCPa3nFCqzjYPqJHh48GnUhc4y9Zc0D9Hf4XTH71eyjK/NnZEYz+HVEc/d5OR9RwCYT1va/BTQ8PYSV18GvQBgHZfTMUQgX2/7bkdHhrzHFlZjXN48D77yyU1d5U4Oakplw05ddnnFLKE2ZxsDHeguQoTiuobJ8rDICkXH+zxmeBbmnWcTAlL9hdgBr63ziqVh/KIgee6cYMBunj2cz8w4ZVLiaPbRdn2h6WVOhdeRh/YzXoD07VRLhSV25ErAFpveZj2zFU3OpFBtMfslKLUOhxby3kcr0erjbuyn1GPIZbLRLY305yNjyMmW7dGHiYI2pLYaeDJNMcbjrVMmVvok557My6v9iDRCxzSIV2D/cRRhr+e5/MnWCRb4b1Sh2fMLpqx6oS4lMg6JfCd/WwkriuhczQ8HLQ7HfWWA8vST2wx9G6iMOIg6B/PKxZr62vY9AzCoJq+jISmQvYj5IRC4rTr4uMWKZKEX/Xn3ow4ideGIxWrvVHqkxWhpP3ntyoDiwaOnVmLL1Tvmf8XjiisBuOajykqDDwrBQMUtcF7VVzS3/3Nzl0qzNA94pND+xATV2SuOazY9ZHCZ+KTRjOjaUpu1Dsel4cp7jC9z8M1pteMt4vjd3ZWrx+D/lahlr82m9Ote0KE3 X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(47076005)(5660300002)(70206006)(8676002)(110136005)(54906003)(40460700003)(82310400004)(81166007)(4326008)(316002)(36860700001)(7416002)(2616005)(2906002)(26005)(8936002)(186003)(6666004)(83380400001)(44832011)(508600001)(336012)(1076003)(426003)(36756003)(9786002)(7696005)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:17:13.6908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f5aa748-db1d-4962-7dcd-08da127983d7 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-BN1NAM02FT024.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR02MB3971 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch extends the vhost-vdpa to support ASID based IOTLB API. The vhost-vdpa device will allocated multiple IOTLBs for vDPA device that supports multiple address spaces. The IOTLBs and vDPA device memory mappings is determined and maintained through ASID. Note that we still don't support vDPA device with more than one address spaces that depends on platform IOMMU. This work will be done by moving the IOMMU logic from vhost-vDPA to vDPA device driver. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vhost/vdpa.c | 109 ++++++++++++++++++++++++++++++++++-------- drivers/vhost/vhost.c | 2 +- 2 files changed, 91 insertions(+), 20 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 6c7ee0f18892..1f1d1c425573 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -28,7 +28,8 @@ enum { VHOST_VDPA_BACKEND_FEATURES = (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2) | - (1ULL << VHOST_BACKEND_F_IOTLB_BATCH), + (1ULL << VHOST_BACKEND_F_IOTLB_BATCH) | + (1ULL << VHOST_BACKEND_F_IOTLB_ASID), }; #define VHOST_VDPA_DEV_MAX (1U << MINORBITS) @@ -57,12 +58,20 @@ struct vhost_vdpa { struct eventfd_ctx *config_ctx; int in_batch; struct vdpa_iova_range range; + u32 batch_asid; }; static DEFINE_IDA(vhost_vdpa_ida); static dev_t vhost_vdpa_major; +static inline u32 iotlb_to_asid(struct vhost_iotlb *iotlb) +{ + struct vhost_vdpa_as *as = container_of(iotlb, struct + vhost_vdpa_as, iotlb); + return as->id; +} + static struct vhost_vdpa_as *asid_to_as(struct vhost_vdpa *v, u32 asid) { struct hlist_head *head = &v->as[asid % VHOST_VDPA_IOTLB_BUCKETS]; @@ -75,6 +84,16 @@ static struct vhost_vdpa_as *asid_to_as(struct vhost_vdpa *v, u32 asid) return NULL; } +static struct vhost_iotlb *asid_to_iotlb(struct vhost_vdpa *v, u32 asid) +{ + struct vhost_vdpa_as *as = asid_to_as(v, asid); + + if (!as) + return NULL; + + return &as->iotlb; +} + static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v, u32 asid) { struct hlist_head *head = &v->as[asid % VHOST_VDPA_IOTLB_BUCKETS]; @@ -83,6 +102,9 @@ static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v, u32 asid) if (asid_to_as(v, asid)) return NULL; + if (asid >= v->vdpa->nas) + return NULL; + as = kmalloc(sizeof(*as), GFP_KERNEL); if (!as) return NULL; @@ -94,6 +116,17 @@ static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v, u32 asid) return as; } +static struct vhost_vdpa_as *vhost_vdpa_find_alloc_as(struct vhost_vdpa *v, + u32 asid) +{ + struct vhost_vdpa_as *as = asid_to_as(v, asid); + + if (as) + return as; + + return vhost_vdpa_alloc_as(v, asid); +} + static int vhost_vdpa_remove_as(struct vhost_vdpa *v, u32 asid) { struct vhost_vdpa_as *as = asid_to_as(v, asid); @@ -692,6 +725,7 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, struct vhost_dev *dev = &v->vdev; struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; + u32 asid = iotlb_to_asid(iotlb); int r = 0; r = vhost_iotlb_add_range_ctx(iotlb, iova, iova + size - 1, @@ -700,10 +734,10 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, return r; if (ops->dma_map) { - r = ops->dma_map(vdpa, 0, iova, size, pa, perm, opaque); + r = ops->dma_map(vdpa, asid, iova, size, pa, perm, opaque); } else if (ops->set_map) { if (!v->in_batch) - r = ops->set_map(vdpa, 0, iotlb); + r = ops->set_map(vdpa, asid, iotlb); } else { r = iommu_map(v->domain, iova, pa, size, perm_to_iommu_flags(perm)); @@ -725,17 +759,24 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, { struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; + u32 asid = iotlb_to_asid(iotlb); vhost_vdpa_iotlb_unmap(v, iotlb, iova, iova + size - 1); if (ops->dma_map) { - ops->dma_unmap(vdpa, 0, iova, size); + ops->dma_unmap(vdpa, asid, iova, size); } else if (ops->set_map) { if (!v->in_batch) - ops->set_map(vdpa, 0, iotlb); + ops->set_map(vdpa, asid, iotlb); } else { iommu_unmap(v->domain, iova, size); } + + /* If we are in the middle of batch processing, delay the free + * of AS until BATCH_END. + */ + if (!v->in_batch && !iotlb->nmaps) + vhost_vdpa_remove_as(v, asid); } static int vhost_vdpa_va_map(struct vhost_vdpa *v, @@ -943,19 +984,38 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; - struct vhost_vdpa_as *as = asid_to_as(v, 0); - struct vhost_iotlb *iotlb = &as->iotlb; + struct vhost_iotlb *iotlb = NULL; + struct vhost_vdpa_as *as = NULL; int r = 0; - if (asid != 0) - return -EINVAL; - mutex_lock(&dev->mutex); r = vhost_dev_check_owner(dev); if (r) goto unlock; + if (msg->type == VHOST_IOTLB_UPDATE || + msg->type == VHOST_IOTLB_BATCH_BEGIN) { + as = vhost_vdpa_find_alloc_as(v, asid); + if (!as) { + dev_err(&v->dev, "can't find and alloc asid %d\n", + asid); + return -EINVAL; + } + iotlb = &as->iotlb; + } else + iotlb = asid_to_iotlb(v, asid); + + if ((v->in_batch && v->batch_asid != asid) || !iotlb) { + if (v->in_batch && v->batch_asid != asid) { + dev_info(&v->dev, "batch id %d asid %d\n", + v->batch_asid, asid); + } + if (!iotlb) + dev_err(&v->dev, "no iotlb for asid %d\n", asid); + return -EINVAL; + } + switch (msg->type) { case VHOST_IOTLB_UPDATE: r = vhost_vdpa_process_iotlb_update(v, iotlb, msg); @@ -964,12 +1024,15 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, vhost_vdpa_unmap(v, iotlb, msg->iova, msg->size); break; case VHOST_IOTLB_BATCH_BEGIN: + v->batch_asid = asid; v->in_batch = true; break; case VHOST_IOTLB_BATCH_END: if (v->in_batch && ops->set_map) - ops->set_map(vdpa, 0, iotlb); + ops->set_map(vdpa, asid, iotlb); v->in_batch = false; + if (!iotlb->nmaps) + vhost_vdpa_remove_as(v, asid); break; default: r = -EINVAL; @@ -1057,9 +1120,17 @@ static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v) static void vhost_vdpa_cleanup(struct vhost_vdpa *v) { + struct vhost_vdpa_as *as; + u32 asid; + vhost_dev_cleanup(&v->vdev); kfree(v->vdev.vqs); - vhost_vdpa_remove_as(v, 0); + + for (asid = 0; asid < v->vdpa->nas; asid++) { + as = asid_to_as(v, asid); + if (as) + vhost_vdpa_remove_as(v, asid); + } } static int vhost_vdpa_open(struct inode *inode, struct file *filep) @@ -1095,12 +1166,9 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false, vhost_vdpa_process_iotlb_msg); - if (!vhost_vdpa_alloc_as(v, 0)) - goto err_alloc_as; - r = vhost_vdpa_alloc_domain(v); if (r) - goto err_alloc_as; + goto err_alloc_domain; vhost_vdpa_set_iova_range(v); @@ -1108,7 +1176,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) return 0; -err_alloc_as: +err_alloc_domain: vhost_vdpa_cleanup(v); err: atomic_dec(&v->opened); @@ -1233,8 +1301,11 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa) int minor; int i, r; - /* Only support 1 address space and 1 groups */ - if (vdpa->ngroups != 1 || vdpa->nas != 1) + /* We can't support platform IOMMU device with more than 1 + * group or as + */ + if (!ops->set_map && !ops->dma_map && + (vdpa->ngroups > 1 || vdpa->nas > 1)) return -EOPNOTSUPP; v = kzalloc(sizeof(*v), GFP_KERNEL | __GFP_RETRY_MAYFAIL); diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index d1e58f976f6e..5022c648d9c0 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1167,7 +1167,7 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev, ret = -EINVAL; goto done; } - offset = sizeof(__u16); + offset = 0; } else offset = sizeof(__u32); break; From patchwork Wed Mar 30 18:03:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98F60C433EF for ; Wed, 30 Mar 2022 18:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350040AbiC3SZN (ORCPT ); Wed, 30 Mar 2022 14:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350049AbiC3SU7 (ORCPT ); Wed, 30 Mar 2022 14:20:59 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2085.outbound.protection.outlook.com [40.107.94.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065692DD55; Wed, 30 Mar 2022 11:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xJw3odgIIm4wktl69JEsN4AFSv2MdB7sBlfl9Y7IHTQ=; b=XAiaRbE6aWg481xuOPWHEv1Ika/3P8UCGsjcDEvlrIQ5QVSg/2iNaOnKVobcJmnclUPozhy3fqy1daauniHbui85zjmfGkU1mRHFdesw87vKiKyyklHyOaSorI0P1mqscBfBipoB4gP6dLH4iZAYH4jHeywXyZQpKW8SacBgZJ0= Received: from DM5PR15CA0037.namprd15.prod.outlook.com (2603:10b6:4:4b::23) by BL3PR02MB8018.namprd02.prod.outlook.com (2603:10b6:208:359::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Wed, 30 Mar 2022 18:18:57 +0000 Received: from DM3NAM02FT012.eop-nam02.prod.protection.outlook.com (2603:10b6:4:4b:cafe::4d) by DM5PR15CA0037.outlook.office365.com (2603:10b6:4:4b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:18:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT012.mail.protection.outlook.com (10.13.5.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:18:57 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2045.outbound.protection.outlook.com [104.47.57.45]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 91BD541D82; Wed, 30 Mar 2022 18:18:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D9/PXX76sAqIyCyyJnjxPx+TKl/QbO3CwkviFakIIHaqlPdSYOoqxbHvEjFvV9fdDMH5lsujk5gqnT4e1kTQkvGur7S7U+TVRbSe9rx75rB+abqKYVpBvY+i68LmclyNFoJ4BF4+SJFTQT4K+QrZy9CZX/1pOqGOK5vSizahrExWXoAGNT96fC0f43a3GNHD2cuOak9og6YC4O43Ub5wI2kA7BWfqpxb7qbzCRyUnm85PylAaa7CV0uQ6GdbJIAIn7wApg/MlETTFkzPsrs+t4XkuveXT7lAsWnawk3EqeZDRWezxy3g8nm3SLi+Vx7pSZnu8euqPkX6DH764kcjww== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xJw3odgIIm4wktl69JEsN4AFSv2MdB7sBlfl9Y7IHTQ=; b=mIzfAr1fbNIl3opj30MEu72Dz3KpCdG341UV7kYrFWWdCd1T8bMOgejwnl43GGUqXHs7cnf0ULve8XxRzGkN6V4ObsRPAsB3p71kHsPM6uAkDlGXiFsuEU2LOvojn8FCywu5i7dt/DnMNdsM1659/pswmxtuekJOfrggZ0MlZe3ab+TO2T6i0CQ0k95KHOeK1NSqbbEXO0feXuZoPrrGYv9VCzA0r3qjqR6MRJYTtD1yZoBlj8WGhhYtPcbVquyBml41h3CkbdUOo/zvTikWdpC/5PcEd8MiFeffTUe3RFu+nJpnABb9EXmGwigSz4AMtgw7HNHDTRxSU/tko38ngg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN9P220CA0025.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::30) by DM5PR02MB2571.namprd02.prod.outlook.com (2603:10b6:3:3f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.22; Wed, 30 Mar 2022 18:17:55 +0000 Received: from BN1NAM02FT008.eop-nam02.prod.protection.outlook.com (2603:10b6:408:13e:cafe::7d) by BN9P220CA0025.outlook.office365.com (2603:10b6:408:13e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:17:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT008.mail.protection.outlook.com (10.13.2.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:17:54 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:17:51 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:17:51 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, elic@nvidia.com, sgarzare@redhat.com, parav@nvidia.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, lingshan.zhu@intel.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZctD-000CCQ-B8; Wed, 30 Mar 2022 11:17:51 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Eli Cohen , Stefano Garzarella , Parav Pandit , , , , CC: , , , , , , , , , Wu Zongyong , Christophe JAILLET , Zhu Lingshan , Xie Yongji , Si-Wei Liu , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 16/19] vdpa_sim: advertise VIRTIO_NET_F_MTU Date: Wed, 30 Mar 2022 23:33:56 +0530 Message-ID: <20220330180436.24644-17-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 8e0ed0cd-8855-4a77-e804-08da1279c173 X-MS-TrafficTypeDiagnostic: DM5PR02MB2571:EE_|DM3NAM02FT012:EE_|BL3PR02MB8018:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: THz0EbVUgHtl7YBV348Ixyr54sT45F3yW9ZZYZrr0cnRFv4/6bg5d28WyZAsxLEzVcpq+9toT05UaSlR0nGqao6sR58p6Ey0Y8afSr3+42HZce9xXfBZKIfidlnCEhb9NbzTFGnNZLEUTRUxS96YLaw0s6hR0wF7uxFQZhBaiGPnYas15BKhUNGdwlJoT0WTw9DLggS47L31u0tzzkOvZRm2xyA9/2+G3VVO6N5t9Zebi1fUInRK6hwdtQCAv5bxc27G6Q6TVzTrcXHgknyA5JZ12vPNSRgXp1tidp66VtPks8kso+UXE8mnHtYtrrMxaY0pzgiBPyRFvrnZhYgNuwvEIh1/UVtdbFGlrB5XvaaORESgZtFFqfGBNA6Ya2tkPU3hgnWo9ErNDi8jBb23rLOi1N9vVAI81ec74WuCjLTyJiztnHmM2G4i5/C+MZSN4nP1Pl5RNjv9TlpBvI9sKPGmvVfkIXTDUN8KtICQDnetJnU30ao8XVVspeN3B1b72/IXChLGFGDLroxSwcl4qNwJ0S8hp69eChoLgiWA46YYEJ4ZhLztSuTqR7pdEbQiKEvQIbJesnLnKY8bsmzU3sGD6j66valribcoS6bct1gDvyJihIWkeWJ72XbNaGUrqYb+uzLC97B8JY8EGleaNT+LsE/cG1G5bxKQceftPprnnF8F0pJ4eUsyQV5LPMs+o5Z6BC5a8u4jPH6CSmNGhXAkPH2ApGTR685e8IroF6o= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(5660300002)(9786002)(1076003)(7696005)(186003)(26005)(4744005)(82310400004)(2906002)(44832011)(8936002)(2616005)(7416002)(508600001)(7636003)(83380400001)(356005)(336012)(8676002)(70206006)(40460700003)(36860700001)(426003)(47076005)(70586007)(316002)(4326008)(36756003)(54906003)(110136005)(921005)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2571 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT012.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 083a709e-5c02-4323-9783-08da12799c3e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTEk/1DzgoTJMMWLrudaIhsDaw3fDRvo9oW/kLLkuZSC0mJYDcST4EJpyfcTGjye3pag9gpIzvt4Ya58GQLyvhWALMACnVb+Hwj6kQVdvurC1lT1sECHUGRn98MwO4Ka2oMp9CKRXwfqroLYR38fNd9ttbriKdqz0hjDBDwIhNmoazs6xzvpMGjZVLd6RhHoB9L4EcQNVCeMoztjZ5cdXlQyqwzMcOEIlM9dNWfK80DFSn3+dJEYbvR7SuiX6I3eshidj6ea09/b9ZDmkegRVqQviffyy9eXkdEcnwNISUzARJXqP7EwHFEodYScscS14Q0i8SL5W3qYMdtzvgC+riU3/8upGppgquwmmCKho8AXURcmDckC4ESylEYKMU1Nd7CR7BFQryL2Qh/4aJ3I6cSfijEWfL7vyr4TDOgrMaGurdhHyCahOxkREhDHYgTFUv8XTPa2cxCuMSyt2FtpMN5TF5e4Bn4tdPvH04vDxRBbMBD4PnjvYe3scaniUQUMGxEQNSp1G6WJpEeMxSbomqpRBLKgIvzcjo3z5D6LU2hfqQI4lLYHgDTG5ba4bvJfgkf7PSE0ngJftczwEprXW3/P9bWtfr9tV+ZPI/4cFgjkZlOYTPIpfanAX9Dp19iLhQH9/7Z2pReWBxqQlr1Oamaoz2jKxvhxJUCeRpr8y0i40Lj/6+YCaJhF+QZaQD2Ur0yQvkUD/7iN15i3K2NZhoBV/V0KQUiqOUDpMG8LbUMoJNJbuc8oDlN5tSuSBKQb2ljaQfnzocOekUS1kzgV7A== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(7696005)(44832011)(8676002)(83380400001)(36860700001)(4326008)(82310400004)(1076003)(26005)(186003)(336012)(426003)(2616005)(4744005)(47076005)(2906002)(70206006)(508600001)(316002)(5660300002)(110136005)(921005)(81166007)(9786002)(54906003)(36756003)(7416002)(40460700003)(8936002)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:18:57.1194 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e0ed0cd-8855-4a77-e804-08da1279c173 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT012.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR02MB8018 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We've already reported maximum mtu via config space, so let's advertise the feature. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c index d5324f6fd8c7..2d1d8c59d0ea 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c @@ -26,7 +26,8 @@ #define DRV_LICENSE "GPL v2" #define VDPASIM_NET_FEATURES (VDPASIM_FEATURES | \ - (1ULL << VIRTIO_NET_F_MAC)) + (1ULL << VIRTIO_NET_F_MAC) | \ + (1ULL << VIRTIO_NET_F_MTU)) #define VDPASIM_NET_VQ_NUM 2 From patchwork Wed Mar 30 18:03:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B23EC433FE for ; Wed, 30 Mar 2022 18:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349944AbiC3SU7 (ORCPT ); Wed, 30 Mar 2022 14:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349964AbiC3SU3 (ORCPT ); Wed, 30 Mar 2022 14:20:29 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2055.outbound.protection.outlook.com [40.107.96.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A116D1B788; Wed, 30 Mar 2022 11:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=haCkwP18Nad3J21+dsXVyG0mNIHtygyZuYjX8yT4nyo=; b=WL7vJpPr9I64NwqU2a5dfNBT+rgf1bir97Szfku88WkYVc5X9HgShDVyVe3m7tpzC5MRs/umqrZAVj1QqDX1K9gCpUpa3a251w2kKIMvN9oT1HyJ432knY4NKIGu5BcsocowTR7cYH/ZfXByHrPd0DZ3/Xo4KBHL2qH2mkG8GRM= Received: from DM6PR07CA0041.namprd07.prod.outlook.com (2603:10b6:5:74::18) by BN6PR02MB2209.namprd02.prod.outlook.com (2603:10b6:404:2e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:18:41 +0000 Received: from DM3NAM02FT063.eop-nam02.prod.protection.outlook.com (2603:10b6:5:74:cafe::92) by DM6PR07CA0041.outlook.office365.com (2603:10b6:5:74::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:18:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by DM3NAM02FT063.mail.protection.outlook.com (10.13.5.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:18:40 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2169.outbound.protection.outlook.com [104.47.73.169]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 265D03F03B; Wed, 30 Mar 2022 18:18:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VGxv8l+jHXkEuz9AX6W96HOBH5S1sZH3tL91PT14V0j99xBtxeeamwk6Z0JLLyduI14nDsYKgBKffQj7woh7DQZE5+N4ZPZsw8DkvlA+eaTMhUrsUEqfNtyu9vz6NGuhdpA+9T8kRvWa7EeyMCojJPqgSATsFh4mWNQcIDcDdsG2XP1Ib1myP0o5bYbZSlfWUIOvkF4jJWCLDqttgqoBTovju3SuYBsn4WiLhFnHgGkSsIjtkf0W34KdbNhpcY9sQhunFxS0AMT+7lOsY8D6Dkd3Ab3acoDrLFbFJmKc2XiUzuBlZKfe7vYf/XHHGJAZ/4xDSU2n1HfYHvqg0Fk4CQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=haCkwP18Nad3J21+dsXVyG0mNIHtygyZuYjX8yT4nyo=; b=bY/owhFz1KiNV6Ml4HgAnOVZ6aKDPo2/lVXSrOYgeZrY0bVxn3znKu7ZDCJFlixd47UmQbUmHx9pntGsYxYzD3LCVjMe9GRdlIAOHuM7O/SHmV1HRg4e2hy6Vv8kNB8/4drY9y030eszS6K7NOMjdmuyhzvZ8ntcKYre3JPzX/Ry1Qp3YKhE/23vZg9FDQAYE1klpC2aP9LHnRbolQAbsU4I1FSftTpdlPSZ3L+4BACnC0AHNM6DccxN5u3niQq4uDauqfU+WPpO9taV2JobpPfD0/3OHqsIoMSs6v8jSDPji2xgIPit21Ww4yVWNsnAg1gWOaG15G8zdiGy/i54DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN6PR13CA0001.namprd13.prod.outlook.com (2603:10b6:404:10a::11) by MN2PR02MB6032.namprd02.prod.outlook.com (2603:10b6:208:182::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:18:38 +0000 Received: from BN1NAM02FT019.eop-nam02.prod.protection.outlook.com (2603:10b6:404:10a:cafe::50) by BN6PR13CA0001.outlook.office365.com (2603:10b6:404:10a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:18:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT019.mail.protection.outlook.com (10.13.3.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:18:38 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:18:37 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:18:37 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, elic@nvidia.com, sgarzare@redhat.com, parav@nvidia.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, lingshan.zhu@intel.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZctw-000CCQ-ON; Wed, 30 Mar 2022 11:18:37 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Eli Cohen , Stefano Garzarella , Parav Pandit , , , , CC: , , , , , , , , , Wu Zongyong , Christophe JAILLET , Zhu Lingshan , Xie Yongji , Si-Wei Liu , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 17/19] vdpa_sim: factor out buffer completion logic Date: Wed, 30 Mar 2022 23:33:57 +0530 Message-ID: <20220330180436.24644-18-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 643f9a95-0fd5-41a5-2015-08da1279b7a0 X-MS-TrafficTypeDiagnostic: MN2PR02MB6032:EE_|DM3NAM02FT063:EE_|BN6PR02MB2209:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jS8kHlFKTzzimra0VoeU7hLXRgw8BUwT0rIg7oMpsFb2xt7SITRtRXcaL8OVOBHb+h/FuwPX4LWg0FYK7OUfhzyrY0zSatWdGl0o71VGs2LUVmgYxilkqd+IC03RbEBT3s+ukKe4ERPzY5ZWFM1ez3oO2f6eEL2Mmu095JjIYotzwETGCNbtf6i2t6jjgYhvb18Q4PdxVrwdBvlWseto13KjAhWNsfdeqI+mNA8tSg2cYjY1EQ5hgoHnuULGSJTR+G7kkVTl7c0ar1gAU4P2GpKX3ALEEPmYLAFmfhdFM8SXbVRvD1cB60qmt725Mlfy0DdrgrsSCHrsM/GZRKdayf/Hj+xaXT+RPTFaEDgFH55UAZod+yxJcUKYePrdvRcQLEyxbOMHXQN+ej4Jb5id12MSQytD/XWn9nX8LNcAJfg7AH607sZGFw8Uk5RXKkd579hlvBTz0uCsdf8U/WEIXW3Q4Jr3Lye8F7834iqW66E2GVaVHMCvxKItNFVhJnOb34Hu3KINPEStkoMMykZbOMOgo3eIAJ0W0/58a+v5khX82zXIV2pU3iYKK79OSTTktWfEtBNBNFD7UZ/nGzjqgbvRSrvHrI2Fvhi8SJFGIclevUNVI3WQWDVKlVLnhQ9w3Bwhk4jFOLXEecdKEbktkUZBf1HgBKK91cx8TsZ+f/cCVR+158OGiG9nrjF5WwAbm+iFC1gOodaH0COw7e7pftacHWpXn67mRd9ajwHcurU= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(7416002)(5660300002)(7636003)(356005)(921005)(336012)(426003)(8936002)(36756003)(6666004)(316002)(508600001)(4326008)(40460700003)(9786002)(54906003)(70206006)(70586007)(110136005)(8676002)(44832011)(7696005)(82310400004)(36860700001)(2616005)(1076003)(26005)(186003)(2906002)(83380400001)(47076005)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR02MB6032 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DM3NAM02FT063.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c0770f92-0c06-4d7c-19a8-08da1279b64a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3h0Rcy29Qk7pr9gG+CwF1L+nrkucY6Dp15+budo+76/KRaym9ywdwnos/oVlzehpHdYYSq3npuPvq3mOhgW3jHRpgbSPV1j7wYsI7j6hrC4Jn3p4osQz+l7euyYvIrIx+0IfGF3joteL32nVJDeKaci0Y3qzEoEiKC2kN/fRTcfDshCyPUOLTs0mN9P0ByXYzN3xlSRZBVo8jpV9L3cDxuJixV8Gi9DKkrZAhTEA00XuholWAPxh5tp2bC+mcYg2SUGXPxC5YdV14S+QTQkzoRksRd2CTEBEiwgPV+1vWdhvCuzwvXconoPhylJ2akDcU0Z48Mm2yAoxy2eb76C2IWKjAHNw/X4FYEL5qA31vn38wGVFkhDRKnX/Dp56ffLSGBFoWJt+JPqaOOhXVkXWgoMvCF8ifqsgslGveqjJBKW9KhQRK7IPUahQpHF+zd9Ia0yyRv6nD16UcwBm2BTuhUwlEAAEsG+Z7I5+SpFVPAxkZLK1DzFBFlcpHr2izxf+wGTvw6Rfc5TnHTuLTDRO8PH8Gby5A8L23g+C3MwVLdP27pUbFbSWwaFLYyAAzJKuJtw7NFbysNELZgPYi2oQiZkdjFLgNvBPmPyO2ZQy7tZLNXFt0okPm7kWHbArR9VCfjpSboaA5M0OXDfPXb6oDr9Hc30plVLnMecnIWabtjnBfqORKhQMmcA4h5aIzOKuKsJFiU6prxzyIbAgHfrc0jQvVfMMSn4kUopYl3EjPgWkGXrWnwDQMhKmOk0B9q2gnM+LTFah212Ln6fD6kGfSg== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(70206006)(8676002)(40460700003)(8936002)(4326008)(316002)(2906002)(44832011)(508600001)(7416002)(6666004)(7696005)(82310400004)(5660300002)(9786002)(26005)(186003)(83380400001)(426003)(36756003)(336012)(47076005)(81166007)(54906003)(110136005)(921005)(2616005)(36860700001)(1076003)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:18:40.6007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 643f9a95-0fd5-41a5-2015-08da1279b7a0 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-DM3NAM02FT063.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB2209 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Wrap up common buffer completion logic in to vdpasim_net_complete Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 33 +++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c index 2d1d8c59d0ea..f4607172b0b8 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c @@ -31,6 +31,22 @@ #define VDPASIM_NET_VQ_NUM 2 +static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len) +{ + /* Make sure data is wrote before advancing index */ + smp_wmb(); + + vringh_complete_iotlb(&vq->vring, vq->head, len); + + /* Make sure used is visible before rasing the interrupt. */ + smp_wmb(); + + local_bh_disable(); + if (vringh_need_notify_iotlb(&vq->vring) > 0) + vringh_notify(&vq->vring); + local_bh_enable(); +} + static void vdpasim_net_work(struct work_struct *work) { struct vdpasim *vdpasim = container_of(work, struct vdpasim, work); @@ -78,21 +94,8 @@ static void vdpasim_net_work(struct work_struct *work) total_write += write; } - /* Make sure data is wrote before advancing index */ - smp_wmb(); - - vringh_complete_iotlb(&txq->vring, txq->head, 0); - vringh_complete_iotlb(&rxq->vring, rxq->head, total_write); - - /* Make sure used is visible before rasing the interrupt. */ - smp_wmb(); - - local_bh_disable(); - if (vringh_need_notify_iotlb(&txq->vring) > 0) - vringh_notify(&txq->vring); - if (vringh_need_notify_iotlb(&rxq->vring) > 0) - vringh_notify(&rxq->vring); - local_bh_enable(); + vdpasim_net_complete(txq, 0); + vdpasim_net_complete(rxq, total_write); if (++pkts > 4) { schedule_work(&vdpasim->work); From patchwork Wed Mar 30 18:03:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FE4BC433EF for ; Wed, 30 Mar 2022 18:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350200AbiC3SV7 (ORCPT ); Wed, 30 Mar 2022 14:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239182AbiC3SVr (ORCPT ); Wed, 30 Mar 2022 14:21:47 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2085.outbound.protection.outlook.com [40.107.244.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9F942A21; Wed, 30 Mar 2022 11:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s3G6k8sUWSn6lI6j7WyZONhDugw0wYLK9Gjpmdqufjo=; b=QMtGUGmZ0g5d0Xk047t2zxsKxH/tmfQpyHUVLoFgKMnLU8V9vCDayzbLP7qvVMGvxxuLH5OGfJKOU2ehdnq1m9o1FPVBqlHvnMPJB4/NlbqfLfI8cDvklJQJxl6xdQdn4O/b1pjoE3lL8g1m3Qo2eQ3OTCHTYDXnGtNUE/TEwyQ= Received: from BN6PR22CA0040.namprd22.prod.outlook.com (2603:10b6:404:37::26) by SJ0PR02MB8625.namprd02.prod.outlook.com (2603:10b6:a03:3f8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 30 Mar 2022 18:19:33 +0000 Received: from BN1NAM02FT018.eop-nam02.prod.protection.outlook.com (2603:10b6:404:37:cafe::42) by BN6PR22CA0040.outlook.office365.com (2603:10b6:404:37::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:19:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by BN1NAM02FT018.mail.protection.outlook.com (10.13.3.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:19:32 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id EE82A3F03B; Wed, 30 Mar 2022 18:19:31 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XCkfKGDvNepUo6xup2zi1W9vPmGEqvc6ZPWvTfDrOtw5TZoT+DO5UuBD+kOrFWF+wNdB84MLm+TeNIkFsmR3yPWkSyJrf0dXtUHeQlmyHWYfK1hxPoRekxc1hjmnQ7Jr71ktfiXniOQzRS+io+uDQKrAbz491ZWQoFzDepDLJ81e4aOwwh6uRTIAuczJS+OjDo3tRvwezqicd8JjY+ZfN13k8Xdofw3kJ5hsJaZaMNfIFVXY2yTu23vEidZiVn1IlFnR+161YCxfNvogrhXWNSl17go7EjxK9JGQF1Ft9iw2bETzULE5Lgt4pfpv2b5eVtloHZpBHOo5tfFUFQbyTA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s3G6k8sUWSn6lI6j7WyZONhDugw0wYLK9Gjpmdqufjo=; b=kLFVm4Znr+k31QTkcjnv55eG1BAOVvxtJkuvNRMWYKCm2y4Tk0tPHs7utOJtm0wmmMa9P8qS56qnfLIxp199kwVny+UtoS9jHIXxdqj4pSElvTFk3258HyTPAMfNPO7naQ7PFFm/Ryj3XOsYeUQkyl1lDXtjzHcHK0uZKXklnk0Fhwq1SDGWlRhtcoMkDBTLAmgfQr6EdqNz7hkIa3ihzQXTS9minswc/HU4LCdhdAxjBeMjIRHC5/y4BIjQ6JXnZyLJgHLEIarHcLS8YczwZtRRj+OjDryvBVQ2uboMjOwkr5VdPv0KUo1zXTEJHfn5tSDERpR7gmi1HSTudvnirA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN6PR14CA0012.namprd14.prod.outlook.com (2603:10b6:404:79::22) by DM6PR02MB5513.namprd02.prod.outlook.com (2603:10b6:5:75::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Wed, 30 Mar 2022 18:19:28 +0000 Received: from BN1NAM02FT049.eop-nam02.prod.protection.outlook.com (2603:10b6:404:79:cafe::f7) by BN6PR14CA0012.outlook.office365.com (2603:10b6:404:79::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:19:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT049.mail.protection.outlook.com (10.13.2.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:19:28 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:19:22 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:19:22 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, elic@nvidia.com, sgarzare@redhat.com, parav@nvidia.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, lingshan.zhu@intel.com, xieyongji@bytedance.com, si-wei.liu@oracle.com, longpeng2@huawei.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcug-000CCQ-4X; Wed, 30 Mar 2022 11:19:22 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Gautam Dawar , Eli Cohen , Stefano Garzarella , Parav Pandit , , , , CC: , , , , , , , , , Wu Zongyong , Christophe JAILLET , Zhu Lingshan , Xie Yongji , Si-Wei Liu , Longpeng , Dan Carpenter , Zhang Min Subject: [PATCH v2 18/19] vdpa_sim: filter destination mac address Date: Wed, 30 Mar 2022 23:33:58 +0530 Message-ID: <20220330180436.24644-19-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: dd2b96ef-58ef-419b-b4a5-08da1279d6ba X-MS-TrafficTypeDiagnostic: DM6PR02MB5513:EE_|BN1NAM02FT018:EE_|SJ0PR02MB8625:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: kKBWQEh/y9Eglx/mNQHVs1YuIJvqgdWkLjTn3yuJWVnV4PZIapgixIBgPL7pjtSH8oW5IDmYiTGC5v/ZjgVqClsiY+RVLguviNUMuV/2ZqCJKPbqH4wwoIFyjdowgQQ3xaDg8w0+FwC+RCoj6G5jkvt6m9MedZwn0p7fn/HfgIr2F53NxWkVus4XaO1TLHTnVIDmOzTu+cyiX8StwMqq5+Tas13BAhTGgd3YsXpz/BMAVRbu7LENWPpZLsGuZOfBn1ZaEGMH81Sxu+Hsdgfn5GWS0GZ8ehvS5oC4QxXAYxPwQxgGX7QEsT6k7Ej3LQ54kVGWE8l9R5w2y6vzy2zkH7eH410Rdd81v/zOEk2ilMa22iPcbJH5dyASLp2mLWRwslMCsLLmhLgVcNnS3mG4Vmfr28jbgnqWFU777mdzosv1ruAskHUIuCmRbMJwQxQsh+3rk9GNSFjOkS/h/XZ3dTg5fwQclcK1JZHj8J3FpmNdywJX30MQElQJ35YSULGWIx1bpr3dc6AjkTAgcqSi6/ExdFmB2wHsRFzbbtxyNwwqbGMtpSmh7Cui2C6y2Hbz09bGLlbRJKyYAfZ8cZvLnI876gqDx73DTKgiLGr4r0ggEGJZj1Ay8aU1a9GiccGzvEoh7MM3ln4GirvO9SJEbQfHgMRMLOz790BSgsLCrx/FHPKf/7gbTAmOpa4ty7p8hEqMKgjiTrGwGYJsj+nL02Hn4dMxktt3LFW/e8LiRH8= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(44832011)(7416002)(921005)(9786002)(8936002)(82310400004)(5660300002)(356005)(1076003)(2616005)(186003)(40460700003)(110136005)(316002)(54906003)(336012)(426003)(26005)(7636003)(508600001)(6666004)(36860700001)(4326008)(47076005)(8676002)(83380400001)(70586007)(70206006)(7696005)(36756003)(2906002)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB5513 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1NAM02FT018.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: de3a5c75-1a5f-4121-8313-08da1279d429 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QTYtF7bk19GuhW3ymDN69FqvR7UTuFQQE9mxXDZS29Pqdp0YMbCpmycsHm/XNvtnIj20JpyIj3Mc/X1Z05PMnLsIdHn3G5nknULS4MNGeWPW25cWWhFy1M/TFNeubW4XFzQXxmU+cPXfewSggbMVjwIbwVHb40JpXJo3tDGaNxQv6BlhdPytT9ogHOOi6h0AtYV9tahRlSgtTu1CBlkBk+BHLDAKyuL3zlreNJhabvzrzyeyj2JDZkYSIza3cAFSV9ZGmmo2ZriOev4ageebZB5d+pqg+igK8a3mS7IFSCx+Cp5oqwwB0DDsi51dDSz3jah2spTk0AS/I7Thu96lWqxSil33nqFqErWbG3/7rLkHIXFbhpuouMrF7Yw+9Eof4/ggfpKLzUg8a3eaRCfO+W3cYOnIZTNCLH+sbb/5KzSCzXBvFpTlyozWrUqW/2TxBlEO9vACoyH3haIRVCZK4+QEcJNQJXr5STqx8l9mXa7YRWKgDg3gi78+i/kz0P51o3aXqwP/phk6MDZZ9M1fjeWW5phm/KdTPxbK70ADigQbZ+Qjr3C7Q4nc40hk1hzRwmGZNvP85gAG5BL2yPZ/E/7OlpLMSCRLVSS0CVHX8pcTHOTNhAjswTFk6pRc7cIS/Sd+JHNlEZABLCO8BxVwHO6jFR90mP2115L7ozwBsKNb3F8bx4K5B5i/dAy1UMK7jTOdlrzu9paPfkICqfnsCwcU3pAnO+RY5cuSUV7es+m06xmkg5md8QCRLwZCwLIb79qOpY5BA9zC5xeUXTyD2Q== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(82310400004)(6666004)(44832011)(81166007)(508600001)(8936002)(47076005)(70206006)(2906002)(7416002)(316002)(9786002)(83380400001)(7696005)(921005)(5660300002)(8676002)(40460700003)(26005)(36860700001)(4326008)(1076003)(336012)(2616005)(186003)(36756003)(426003)(54906003)(110136005)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:19:32.7374 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd2b96ef-58ef-419b-b4a5-08da1279d6ba X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000001.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-BN1NAM02FT018.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR02MB8625 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch implements a simple unicast filter for vDPA simulator. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 49 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c index f4607172b0b8..5fa59d4fddc8 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c @@ -47,13 +47,28 @@ static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len) local_bh_enable(); } +static bool receive_filter(struct vdpasim *vdpasim, size_t len) +{ + bool modern = vdpasim->features & (1ULL << VIRTIO_F_VERSION_1); + size_t hdr_len = modern ? sizeof(struct virtio_net_hdr_v1) : + sizeof(struct virtio_net_hdr); + struct virtio_net_config *vio_config = vdpasim->config; + + if (len < ETH_ALEN + hdr_len) + return false; + + if (!strncmp(vdpasim->buffer + hdr_len, vio_config->mac, ETH_ALEN)) + return true; + + return false; +} + static void vdpasim_net_work(struct work_struct *work) { struct vdpasim *vdpasim = container_of(work, struct vdpasim, work); struct vdpasim_virtqueue *txq = &vdpasim->vqs[1]; struct vdpasim_virtqueue *rxq = &vdpasim->vqs[0]; ssize_t read, write; - size_t total_write; int pkts = 0; int err; @@ -66,36 +81,34 @@ static void vdpasim_net_work(struct work_struct *work) goto out; while (true) { - total_write = 0; err = vringh_getdesc_iotlb(&txq->vring, &txq->out_iov, NULL, &txq->head, GFP_ATOMIC); if (err <= 0) break; + read = vringh_iov_pull_iotlb(&txq->vring, &txq->out_iov, + vdpasim->buffer, + PAGE_SIZE); + + if (!receive_filter(vdpasim, read)) { + vdpasim_net_complete(txq, 0); + continue; + } + err = vringh_getdesc_iotlb(&rxq->vring, NULL, &rxq->in_iov, &rxq->head, GFP_ATOMIC); if (err <= 0) { - vringh_complete_iotlb(&txq->vring, txq->head, 0); + vdpasim_net_complete(txq, 0); break; } - while (true) { - read = vringh_iov_pull_iotlb(&txq->vring, &txq->out_iov, - vdpasim->buffer, - PAGE_SIZE); - if (read <= 0) - break; - - write = vringh_iov_push_iotlb(&rxq->vring, &rxq->in_iov, - vdpasim->buffer, read); - if (write <= 0) - break; - - total_write += write; - } + write = vringh_iov_push_iotlb(&rxq->vring, &rxq->in_iov, + vdpasim->buffer, read); + if (write <= 0) + break; vdpasim_net_complete(txq, 0); - vdpasim_net_complete(rxq, total_write); + vdpasim_net_complete(rxq, write); if (++pkts > 4) { schedule_work(&vdpasim->work); From patchwork Wed Mar 30 18:03:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gautam Dawar X-Patchwork-Id: 12796212 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69EFEC433F5 for ; Wed, 30 Mar 2022 18:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349989AbiC3SZJ (ORCPT ); Wed, 30 Mar 2022 14:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350732AbiC3SXe (ORCPT ); Wed, 30 Mar 2022 14:23:34 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2087.outbound.protection.outlook.com [40.107.92.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4348B427FD; Wed, 30 Mar 2022 11:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8itKTQ6u0J3QOLhLr7DljYEqd3evEFdPyLdYcUFr9g=; b=isXyoyAOOFowTejZvujY6fF1Stz16sWO+4ekoFB7HnYpGQ9GeaInYiJAL42hvyLTG16tvaCYWpoCDF6DI/ZkHKbLABNCArR+L5E2d3y4zxK9IxAT/7hcAYJziqtxfeprV9rFXeLNHQEpbP6FAI90WsuFUXSzQHB+83PcuF991/k= Received: from BN0PR07CA0011.namprd07.prod.outlook.com (2603:10b6:408:141::32) by SN4PR0201MB3407.namprd02.prod.outlook.com (2603:10b6:803:4f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Wed, 30 Mar 2022 18:20:53 +0000 Received: from BN1NAM02FT057.eop-nam02.prod.protection.outlook.com (2603:10b6:408:141:cafe::19) by BN0PR07CA0011.outlook.office365.com (2603:10b6:408:141::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:20:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.83.241.18) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 20.83.241.18 as permitted sender) receiver=protection.outlook.com; client-ip=20.83.241.18; helo=mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net; Received: from mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (20.83.241.18) by BN1NAM02FT057.mail.protection.outlook.com (10.13.2.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:20:53 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net (Postfix) with ESMTPS id 8883F3F03C; Wed, 30 Mar 2022 18:20:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKo+S5kf4IBaEE/wh7ZlZNeK6jtbloWHjKX/0jw2trvT1Mys3FDQgExRgfGaI5Bu/PugaBuaa9aGsuUo0Wfz091JNyqVeQLJz/FsssmBBg2483DceMjqf4X5cll7465GUFrj24sN2a1CWNrUadG7YXm5B72ZOALaAyHwoMfho7AqNFZJV6KoHcxgRELHmMjstC3NeRD2VWs/TqSh5LXS52YMgAncHzEa2HeLOKndBUjn6edVPYKdUa9osTUevne4BWBDcfO6kbEmy/g45f3WQv2Qqjxw+jLbjtS2r6aZnXmDMvAfg95fz1AREYQYshPvbrjReOxWfl0EVN4BH1T1+A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W8itKTQ6u0J3QOLhLr7DljYEqd3evEFdPyLdYcUFr9g=; b=DHeRMm6ifoayU1Vcuq5yUlvXLhSHtP36V9cw2y/73MsIEWLR1a/Lf1hOIaDa/NHk375z4QpKmGO5wmtZzyfiwrfuxfZbOlWtTo6WcYrLA0gFM2YXNY0VeMWC1lPPmJ4cGpl0n43/i40LXt6Ic5+Wo/lXaQuBlGGx+PGqd/sXVvfZamq6wN9jVf6t4m3Qi8PP0ZGNzIIVGxfPFGpH8I/nGuIv/KdPCk1HW2Xe8UaCR/xVuUCpgGKUpRv6Xd+fy2ZvD3rqFs1jjLV40P+u/m7Y3CpxMEPp2FSLU/moR5On3JFjvMqXVh6y+DUx/qPJ3o7H3lCPBl5AR2y2Lcn5Ea66uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 149.199.62.198) smtp.rcpttodomain=redhat.com smtp.mailfrom=xilinx.com; dmarc=temperror action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BN9PR03CA0414.namprd03.prod.outlook.com (2603:10b6:408:111::29) by SN4PR0201MB8726.namprd02.prod.outlook.com (2603:10b6:806:1e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 30 Mar 2022 18:20:50 +0000 Received: from BN1NAM02FT044.eop-nam02.prod.protection.outlook.com (2603:10b6:408:111:cafe::a) by BN9PR03CA0414.outlook.office365.com (2603:10b6:408:111::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 18:20:49 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT044.mail.protection.outlook.com (10.13.2.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 18:20:48 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 30 Mar 2022 11:20:13 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 30 Mar 2022 11:20:13 -0700 Envelope-to: mst@redhat.com, jasowang@redhat.com, sgarzare@redhat.com, xieyongji@bytedance.com, longpeng2@huawei.com, elic@nvidia.com, parav@nvidia.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, habetsm.xilinx@gmail.com, ecree.xilinx@gmail.com, eperezma@redhat.com, wuzongyong@linux.alibaba.com, christophe.jaillet@wanadoo.fr, lingshan.zhu@intel.com, si-wei.liu@oracle.com, dan.carpenter@oracle.com, zhang.min9@zte.com.cn Received: from [10.170.66.102] (port=44662 helo=xndengvm004102.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nZcvU-000CCQ-NM; Wed, 30 Mar 2022 11:20:13 -0700 From: Gautam Dawar To: "Michael S. Tsirkin" , Jason Wang , Stefano Garzarella , Xie Yongji , Gautam Dawar , Longpeng , Eli Cohen , Parav Pandit , , , , CC: , , , , , , , , , Wu Zongyong , Christophe JAILLET , Zhu Lingshan , Si-Wei Liu , Dan Carpenter , Zhang Min Subject: [PATCH v2 19/19] vdpasim: control virtqueue support Date: Wed, 30 Mar 2022 23:33:59 +0530 Message-ID: <20220330180436.24644-20-gdawar@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20220330180436.24644-1-gdawar@xilinx.com> References: <20220330180436.24644-1-gdawar@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 4ac9a35f-1ac5-49a3-ccb1-08da127a06bf X-MS-TrafficTypeDiagnostic: SN4PR0201MB8726:EE_|BN1NAM02FT057:EE_|SN4PR0201MB3407:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: e+cJUaoCIrL84JDSNKOqK7ptcZdnhEIRz5w+sCVH5WsJH+gw+AwkFdt/eypN64vaGntKuJfdyVJYV1QJ2ng68sxRaI/3E0tJWYDYEWzubPfUFq6cZ5vi/J1ngS8tHi6XBT3AFhEuaqfPCECyeOc/o1/LeJPVJouLSfQqBxuyo0k7E/kL+qIBTu564tfaT2VEHhhsNsffKg2g2xTB7Fc7yXLaYyEBHjAKSdOKnKseZBruQzDty8wyR9Ca7Dnio+7h6OVL8m1K0gwtXvW3jQduSEKvqXgFC6XVMWdF7DnVnHXG8iucgNjMdSUxvOzvz1/q34ibNamC4yB4nUVXr70/DYp9A3Q19qKwJyM3I4nwHfX7niDaSG93Z3cRCK4jNv7Zo+dqSpaJS/GNS+RIkrrAv1A2dVBAGBNSH56mJ6Z3XBML5rnhWmbUQGLMAK/1UQx8nMGbf/8aI9jFVBgK/RO/Dg8Or6rolP6osPB8YQMuAk67x5lhBVSS8zLN7qfQzmqDb2plim9Y/68inIXLVVGNd3rBYkO/dWxO1bCS+ZZD4xMfh9P75TLnVTHFFzkItwaHQWnS3ARHFl/4je9J9pi1h0HT/JXwkSa6gO5wJqsXeJ777AMWQQO2dVu0m5rRZja91+q9jsJkDop4gruDkxAEUTyAcyOZnGkErv3zsES6AZCNBN2gbVMG/gIEi11MVc0BLr98h1muW9gYO+BaZBPe88K7dH0Ze0RqgQ8dkO9JrXc= X-Forefront-Antispam-Report-Untrusted: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(426003)(336012)(83380400001)(63350400001)(110136005)(47076005)(8936002)(7416002)(54906003)(63370400001)(82310400004)(5660300002)(508600001)(36860700001)(7636003)(921005)(356005)(316002)(70206006)(30864003)(6666004)(2616005)(2906002)(40460700003)(44832011)(36756003)(70586007)(186003)(1076003)(4326008)(7696005)(8676002)(9786002)(26005)(102446001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB8726 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1NAM02FT057.eop-nam02.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2aa0ec82-c7a5-446c-948b-08da127a03f6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mGw3B6CVmemVNvzm+2eY8bwF4hwDCLnMBahXSfLTtwWj/hsmeijfhNuZipoOMHV79LJVgWBdb+4L8NaDXFxzhWFo7qnlaxcJEMBJgfD0sVjjaSKwhXrkx8VfiKB8sSSkLqRXygTlrVZ1xGpUEA2eZWfY/mzMw1RpsBUmw7zg/hkvtGFIJwo/ZlDt7Qml9asU6Dw0kohReshErGTqENVxmBZLOmIiHEf6/pYAJjeGhQkP3vZSD/XC9UT8Oo9mU7vuY/j3IECCuBZMV1chFa2+q2r87R25OkjQup+smVXENqlTmTsjB9CyCWdLB6k2Rkb72EQAq2xgsRhk9aRKdqe6cWJColXaZFcNwLpwu+UbAMZ5TnFN96DxjVzEr6i4iDzVpsfvR8QNshbqJiJPk0BtTHs7M9FIODJZg5Xjc/EF27kt0ZooAwSDkctKDbqXjkn1Kf+xO4rkJ7aQijX40+jLwwKiijURWY6szP1wWhYhfviI9t6/ehaI77F46IGff15a3pxManQAFLL4zx+kid9cpEP9C5oSU11aqpzI5D1S2M1PjaWwdRLB7SbgJ0y03QoaJh5M6FmwCMq69IbCmJS4BvEG8o7pHl90Hseewmy47eZwRdg5V2xtvYRqTqBd8JfJBCO20ums3DYA9U1u5La8YlovhmdI5yecIHfQpXINo6W3fpfphOKf2AgkD629tvebGC/9IWBtFoiV8mNuWGFJZld7JOrqDdLQF+qfxV/CHMR+yZWVo+nk5eIbBsHvMUliiKIQBoxCfiNFvCz/usqP2A== X-Forefront-Antispam-Report: CIP:20.83.241.18;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2616005)(47076005)(110136005)(44832011)(36860700001)(426003)(54906003)(82310400004)(7696005)(8936002)(1076003)(186003)(336012)(26005)(508600001)(9786002)(7416002)(5660300002)(30864003)(40460700003)(81166007)(921005)(36756003)(6666004)(83380400001)(8676002)(4326008)(316002)(70206006)(2906002)(102446001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 18:20:53.3171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ac9a35f-1ac5-49a3-ccb1-08da127a06bf X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[20.83.241.18];Helo=[mailrelay000000.14r1f435wfvunndds3vy4cdalc.xx.internal.cloudapp.net] X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TreatMessagesAsInternal-BN1NAM02FT057.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB3407 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch introduces the control virtqueue support for vDPA simulator. This is a requirement for supporting advanced features like multiqueue. A requirement for control virtqueue is to isolate its memory access from the rx/tx virtqueues. This is because when using vDPA device for VM, the control virqueue is not directly assigned to VM. Userspace (Qemu) will present a shadow control virtqueue to control for recording the device states. The isolation is done via the virtqueue groups and ASID support in vDPA through vhost-vdpa. The simulator is extended to have: 1) three virtqueues: RXVQ, TXVQ and CVQ (control virtqueue) 2) two virtqueue groups: group 0 contains RXVQ and TXVQ; group 1 contains CVQ 3) two address spaces and the simulator simply implements the address spaces by mapping it 1:1 to IOTLB. For the VM use cases, userspace(Qemu) may set AS 0 to group 0 and AS 1 to group 1. So we have: 1) The IOTLB for virtqueue group 0 contains the mappings of guest, so RX and TX can be assigned to guest directly. 2) The IOTLB for virtqueue group 1 contains the mappings of CVQ which is the buffers that allocated and managed by VMM only. So CVQ of vhost-vdpa is visible to VMM only. And Guest can not access the CVQ of vhost-vdpa. For the other use cases, since AS 0 is associated to all virtqueue groups by default. All virtqueues share the same mapping by default. To demonstrate the function, VIRITO_NET_F_CTRL_MACADDR is implemented in the simulator for the driver to set mac address. Signed-off-by: Jason Wang Signed-off-by: Gautam Dawar --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 91 ++++++++++++++++++++++------ drivers/vdpa/vdpa_sim/vdpa_sim.h | 2 + drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 88 ++++++++++++++++++++++++++- 3 files changed, 161 insertions(+), 20 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 659e2e2e4b0c..51bd0bafce06 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -96,11 +96,17 @@ static void vdpasim_do_reset(struct vdpasim *vdpasim) { int i; - for (i = 0; i < vdpasim->dev_attr.nvqs; i++) + spin_lock(&vdpasim->iommu_lock); + + for (i = 0; i < vdpasim->dev_attr.nvqs; i++) { vdpasim_vq_reset(vdpasim, &vdpasim->vqs[i]); + vringh_set_iotlb(&vdpasim->vqs[i].vring, &vdpasim->iommu[0], + &vdpasim->iommu_lock); + } + + for (i = 0; i < vdpasim->dev_attr.nas; i++) + vhost_iotlb_reset(&vdpasim->iommu[i]); - spin_lock(&vdpasim->iommu_lock); - vhost_iotlb_reset(vdpasim->iommu); spin_unlock(&vdpasim->iommu_lock); vdpasim->features = 0; @@ -145,7 +151,7 @@ static dma_addr_t vdpasim_map_range(struct vdpasim *vdpasim, phys_addr_t paddr, dma_addr = iova_dma_addr(&vdpasim->iova, iova); spin_lock(&vdpasim->iommu_lock); - ret = vhost_iotlb_add_range(vdpasim->iommu, (u64)dma_addr, + ret = vhost_iotlb_add_range(&vdpasim->iommu[0], (u64)dma_addr, (u64)dma_addr + size - 1, (u64)paddr, perm); spin_unlock(&vdpasim->iommu_lock); @@ -161,7 +167,7 @@ static void vdpasim_unmap_range(struct vdpasim *vdpasim, dma_addr_t dma_addr, size_t size) { spin_lock(&vdpasim->iommu_lock); - vhost_iotlb_del_range(vdpasim->iommu, (u64)dma_addr, + vhost_iotlb_del_range(&vdpasim->iommu[0], (u64)dma_addr, (u64)dma_addr + size - 1); spin_unlock(&vdpasim->iommu_lock); @@ -250,8 +256,9 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr) else ops = &vdpasim_config_ops; - vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, 1, - 1, dev_attr->name, false); + vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, + dev_attr->ngroups, dev_attr->nas, + dev_attr->name, false); if (IS_ERR(vdpasim)) { ret = PTR_ERR(vdpasim); goto err_alloc; @@ -278,16 +285,20 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr) if (!vdpasim->vqs) goto err_iommu; - vdpasim->iommu = vhost_iotlb_alloc(max_iotlb_entries, 0); + vdpasim->iommu = kmalloc_array(vdpasim->dev_attr.nas, + sizeof(*vdpasim->iommu), GFP_KERNEL); if (!vdpasim->iommu) goto err_iommu; + for (i = 0; i < vdpasim->dev_attr.nas; i++) + vhost_iotlb_init(&vdpasim->iommu[i], 0, 0); + vdpasim->buffer = kvmalloc(dev_attr->buffer_size, GFP_KERNEL); if (!vdpasim->buffer) goto err_iommu; for (i = 0; i < dev_attr->nvqs; i++) - vringh_set_iotlb(&vdpasim->vqs[i].vring, vdpasim->iommu, + vringh_set_iotlb(&vdpasim->vqs[i].vring, &vdpasim->iommu[0], &vdpasim->iommu_lock); ret = iova_cache_get(); @@ -401,7 +412,11 @@ static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa) static u32 vdpasim_get_vq_group(struct vdpa_device *vdpa, u16 idx) { - return 0; + /* RX and TX belongs to group 0, CVQ belongs to group 1 */ + if (idx == 2) + return 1; + else + return 0; } static u64 vdpasim_get_device_features(struct vdpa_device *vdpa) @@ -539,20 +554,53 @@ static struct vdpa_iova_range vdpasim_get_iova_range(struct vdpa_device *vdpa) return range; } +static int vdpasim_set_group_asid(struct vdpa_device *vdpa, unsigned int group, + unsigned int asid) +{ + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + struct vhost_iotlb *iommu; + int i; + + if (group > vdpasim->dev_attr.ngroups) + return -EINVAL; + + if (asid > vdpasim->dev_attr.nas) + return -EINVAL; + + iommu = &vdpasim->iommu[asid]; + + spin_lock(&vdpasim->lock); + + for (i = 0; i < vdpasim->dev_attr.nvqs; i++) + if (vdpasim_get_vq_group(vdpa, i) == group) + vringh_set_iotlb(&vdpasim->vqs[i].vring, iommu, + &vdpasim->iommu_lock); + + spin_unlock(&vdpasim->lock); + + return 0; +} + static int vdpasim_set_map(struct vdpa_device *vdpa, unsigned int asid, struct vhost_iotlb *iotlb) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); struct vhost_iotlb_map *map; + struct vhost_iotlb *iommu; u64 start = 0ULL, last = 0ULL - 1; int ret; + if (asid >= vdpasim->dev_attr.nas) + return -EINVAL; + spin_lock(&vdpasim->iommu_lock); - vhost_iotlb_reset(vdpasim->iommu); + + iommu = &vdpasim->iommu[asid]; + vhost_iotlb_reset(iommu); for (map = vhost_iotlb_itree_first(iotlb, start, last); map; map = vhost_iotlb_itree_next(map, start, last)) { - ret = vhost_iotlb_add_range(vdpasim->iommu, map->start, + ret = vhost_iotlb_add_range(iommu, map->start, map->last, map->addr, map->perm); if (ret) goto err; @@ -561,7 +609,7 @@ static int vdpasim_set_map(struct vdpa_device *vdpa, unsigned int asid, return 0; err: - vhost_iotlb_reset(vdpasim->iommu); + vhost_iotlb_reset(iommu); spin_unlock(&vdpasim->iommu_lock); return ret; } @@ -573,9 +621,12 @@ static int vdpasim_dma_map(struct vdpa_device *vdpa, unsigned int asid, struct vdpasim *vdpasim = vdpa_to_sim(vdpa); int ret; + if (asid >= vdpasim->dev_attr.nas) + return -EINVAL; + spin_lock(&vdpasim->iommu_lock); - ret = vhost_iotlb_add_range_ctx(vdpasim->iommu, iova, iova + size - 1, - pa, perm, opaque); + ret = vhost_iotlb_add_range_ctx(&vdpasim->iommu[asid], iova, + iova + size - 1, pa, perm, opaque); spin_unlock(&vdpasim->iommu_lock); return ret; @@ -586,8 +637,11 @@ static int vdpasim_dma_unmap(struct vdpa_device *vdpa, unsigned int asid, { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + if (asid >= vdpasim->dev_attr.nas) + return -EINVAL; + spin_lock(&vdpasim->iommu_lock); - vhost_iotlb_del_range(vdpasim->iommu, iova, iova + size - 1); + vhost_iotlb_del_range(&vdpasim->iommu[asid], iova, iova + size - 1); spin_unlock(&vdpasim->iommu_lock); return 0; @@ -611,8 +665,7 @@ static void vdpasim_free(struct vdpa_device *vdpa) } kvfree(vdpasim->buffer); - if (vdpasim->iommu) - vhost_iotlb_free(vdpasim->iommu); + vhost_iotlb_free(vdpasim->iommu); kfree(vdpasim->vqs); kfree(vdpasim->config); } @@ -643,6 +696,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { .set_config = vdpasim_set_config, .get_generation = vdpasim_get_generation, .get_iova_range = vdpasim_get_iova_range, + .set_group_asid = vdpasim_set_group_asid, .dma_map = vdpasim_dma_map, .dma_unmap = vdpasim_dma_unmap, .free = vdpasim_free, @@ -674,6 +728,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { .set_config = vdpasim_set_config, .get_generation = vdpasim_get_generation, .get_iova_range = vdpasim_get_iova_range, + .set_group_asid = vdpasim_set_group_asid, .set_map = vdpasim_set_map, .free = vdpasim_free, }; diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h index 0be7c1e7ef80..622782e92239 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.h +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h @@ -41,6 +41,8 @@ struct vdpasim_dev_attr { size_t buffer_size; int nvqs; u32 id; + u32 ngroups; + u32 nas; work_func_t work_fn; void (*get_config)(struct vdpasim *vdpasim, void *config); diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c index 5fa59d4fddc8..5125976a4df8 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c @@ -27,9 +27,14 @@ #define VDPASIM_NET_FEATURES (VDPASIM_FEATURES | \ (1ULL << VIRTIO_NET_F_MAC) | \ - (1ULL << VIRTIO_NET_F_MTU)) + (1ULL << VIRTIO_NET_F_MTU) | \ + (1ULL << VIRTIO_NET_F_CTRL_VQ) | \ + (1ULL << VIRTIO_NET_F_CTRL_MAC_ADDR)) -#define VDPASIM_NET_VQ_NUM 2 +/* 3 virtqueues, 2 address spaces, 2 virtqueue groups */ +#define VDPASIM_NET_VQ_NUM 3 +#define VDPASIM_NET_AS_NUM 2 +#define VDPASIM_NET_GROUP_NUM 2 static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len) { @@ -63,6 +68,81 @@ static bool receive_filter(struct vdpasim *vdpasim, size_t len) return false; } +static virtio_net_ctrl_ack vdpasim_handle_ctrl_mac(struct vdpasim *vdpasim, + u8 cmd) +{ + struct virtio_net_config *vio_config = vdpasim->config; + struct vdpasim_virtqueue *cvq = &vdpasim->vqs[2]; + virtio_net_ctrl_ack status = VIRTIO_NET_ERR; + size_t read; + + switch (cmd) { + case VIRTIO_NET_CTRL_MAC_ADDR_SET: + read = vringh_iov_pull_iotlb(&cvq->vring, &cvq->in_iov, + vio_config->mac, ETH_ALEN); + if (read == ETH_ALEN) + status = VIRTIO_NET_OK; + break; + default: + break; + } + + return status; +} + +static void vdpasim_handle_cvq(struct vdpasim *vdpasim) +{ + struct vdpasim_virtqueue *cvq = &vdpasim->vqs[2]; + virtio_net_ctrl_ack status = VIRTIO_NET_ERR; + struct virtio_net_ctrl_hdr ctrl; + size_t read, write; + int err; + + if (!(vdpasim->features & (1ULL << VIRTIO_NET_F_CTRL_VQ))) + return; + + if (!cvq->ready) + return; + + while (true) { + err = vringh_getdesc_iotlb(&cvq->vring, &cvq->in_iov, + &cvq->out_iov, + &cvq->head, GFP_ATOMIC); + if (err <= 0) + break; + + read = vringh_iov_pull_iotlb(&cvq->vring, &cvq->in_iov, &ctrl, + sizeof(ctrl)); + if (read != sizeof(ctrl)) + break; + + switch (ctrl.class) { + case VIRTIO_NET_CTRL_MAC: + status = vdpasim_handle_ctrl_mac(vdpasim, ctrl.cmd); + break; + default: + break; + } + + /* Make sure data is wrote before advancing index */ + smp_wmb(); + + write = vringh_iov_push_iotlb(&cvq->vring, &cvq->out_iov, + &status, sizeof(status)); + vringh_complete_iotlb(&cvq->vring, cvq->head, write); + vringh_kiov_cleanup(&cvq->in_iov); + vringh_kiov_cleanup(&cvq->out_iov); + + /* Make sure used is visible before rasing the interrupt. */ + smp_wmb(); + + local_bh_disable(); + if (cvq->cb) + cvq->cb(cvq->private); + local_bh_enable(); + } +} + static void vdpasim_net_work(struct work_struct *work) { struct vdpasim *vdpasim = container_of(work, struct vdpasim, work); @@ -77,6 +157,8 @@ static void vdpasim_net_work(struct work_struct *work) if (!(vdpasim->status & VIRTIO_CONFIG_S_DRIVER_OK)) goto out; + vdpasim_handle_cvq(vdpasim); + if (!txq->ready || !rxq->ready) goto out; @@ -162,6 +244,8 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, dev_attr.id = VIRTIO_ID_NET; dev_attr.supported_features = VDPASIM_NET_FEATURES; dev_attr.nvqs = VDPASIM_NET_VQ_NUM; + dev_attr.ngroups = VDPASIM_NET_GROUP_NUM; + dev_attr.nas = VDPASIM_NET_AS_NUM; dev_attr.config_size = sizeof(struct virtio_net_config); dev_attr.get_config = vdpasim_net_get_config; dev_attr.work_fn = vdpasim_net_work;