From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D37F543F12; Fri, 26 Apr 2024 09:49:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45A0943C81; Fri, 26 Apr 2024 09:49:05 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2118.outbound.protection.outlook.com [40.107.94.118]) by mails.dpdk.org (Postfix) with ESMTP id C5DD143C84 for ; Fri, 26 Apr 2024 09:49:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elKZAEic1Tm/at1O1SgMtX1nTTRmLD1L6GegK7VO/lCSdzqkPYiUm/fgUv3lVQgvYdIQrcQCMzrppfHCsDOvnfr9OwjRfVCXRpAeMnYDdsP6pbis3T0NAe/w26yuMjQmMeJDj31+6Xxi19eyZ49lrB7C5j3u6pwde0BrlNPh7Nmt/cyU8VoX2rIGxSkCyLyCGTb9pFJuzSUxharaNt3N2CkdzJeazHV+8q5utsNCkOuSuVeP94wfC5A70HqVCLO3CuBmXScXxQzVRhE5fAJ9ze6USqNwx0IhTYSjS3Qtu5TdlerxlbOsDD48SB6JooDYXKQbjHKd80P/p0XUm8lcJA== 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=IxrO70/0MoJrzhVMhVhlAI0hBVXUPvSYpeqWnz4+MZU=; b=dc3GqIMJDSBBLmy0C/0/mSbQfMprqpR3TxlDHXOjx4/7VWlgOfZjyAddvBEq9Q5uaw0aDFn8iMt0mUJ/WjnGOF+7Raa0xIEGMWNaBlJAkpoODByECe2YZttLP/J4l1cyW0ukgoSex4AGiweKxx8/ffqh/iSkLjhoP7pI2rSNzEzz8l2cghHzMCTZO4hbvTN1S+qGwWM72IU4bTixrX0gGDQxSdIkC3kiS3pphTicgicMhe5SClBPP13k3xkEs3RMN4gEiF1nFW/x2Q/vSAi0wVBcMtUnnb0I4TTKxzQfeSetLUxMx2eThL4fINwFCDkGEdyoEYzZNpno9z4qjB7CXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IxrO70/0MoJrzhVMhVhlAI0hBVXUPvSYpeqWnz4+MZU=; b=Hlpl7+cs/kda8rj7/6MnLNy/4L7yqtqS8s447U9jjWXWOdfLOYJqhn16NM0qmMg0ux1eXtbqKu5SRivXtjNCfO5Dx1pZrUY+6aSTpxRVQG/AQSEsiOzGExVGxEXsDedLRvmrang8vxINnZY1WUFG/RKs++XO9sqvjLH/VY1swg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by SN4PR13MB5279.namprd13.prod.outlook.com (2603:10b6:806:206::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Fri, 26 Apr 2024 07:49:02 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7544.010; Fri, 26 Apr 2024 07:49:02 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Xinying Yu , Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 05/10] vdpa/nfp: add the live migration logic Date: Fri, 26 Apr 2024 15:48:26 +0800 Message-Id: <20240426074831.1729792-6-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240426074831.1729792-1-chaoyong.he@corigine.com> References: <20240426074831.1729792-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR02CA0007.namprd02.prod.outlook.com (2603:10b6:a02:ee::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SN4PR13MB5279:EE_ X-MS-Office365-Filtering-Correlation-Id: d7b1d3ef-48b3-4c55-50d4-08dc65c556d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|52116005|1800799015|366007|376005|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZlWmSuhGU1hU8EUFFJ2JPbwC28OdSDdU49h00+d37REjfN9dpsbpTS+Nnf2L?= =?us-ascii?Q?pVVuU2fBFq3JVIemmGmyx9Lch2fDQjz84rXl7xuXjixqAmlBE3UYHZ8cB6Xv?= =?us-ascii?Q?9Qac5SI5Nd4Lauf0kV2K/KtZEBO/paYNwU0PmDsI+22FYQRRw49MTAfS+jhE?= =?us-ascii?Q?mxLVwBPXb20PJ0M1E23hHo0tZG/QDcNgrqm589NmX/GBYsYHQu+qR1vvr3R2?= =?us-ascii?Q?kroxN6Pn8Cx1UsARPi2e9qw6kO5Z7yuN8U07Sm38zg15gMPHnuz/DPJU1lsA?= =?us-ascii?Q?W2Yz/77Jfzs/ZWFxvhCYyIpe8xubcOzL0HF6z+UGHmbyLVvhQ0s8qB5vWmvu?= =?us-ascii?Q?KCR8g90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Fv90lsQacY/+v4wNAa9FHZg+mG?= =?us-ascii?Q?ls51kPTC3hnjwP4RLGCT+J3BvKeYN8HKL2ZN6gnNTJvPXJcHtrEiwiLg5cQF?= =?us-ascii?Q?hZ5WXm3uByGbj9vkGv8Ec6PoGBpgKLoAv4B+q6jrM1Dc2A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(366007)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?f5VVqHVNJzxyLqNKEiQ79/6ZlpW2KfwxB9jJusE/MxKuNEmU5tyjRANseQyk?= =?us-ascii?Q?dU4/cPH5Sub74h7apR0mIfuU+o4orfbciq+fcTrDtpGlFamC/l4cqXqMX844?= =?us-ascii?Q?RaH9+7lnmfCnjyFMaOppXPW43Dl6SAwMuMch7LiWd1IKR96u8NcwWa2jpnbG?= =?us-ascii?Q?HPfZCkw6/BnxB4tiv/8pd2docQ4+XpSorgveRHRX2LezTY658EPWQA8TXHM/?= =?us-ascii?Q?EfPV8n1pllflndadMGBdaZYQAGmgH/NcV5lwbmXynUuJDodjHZxpphbbL0L1?= =?us-ascii?Q?zlHkzZGJ5nA474WlRPl+uyCnX7g+ge1WVSlP2kSTlbLFojYxrEzEoZlf7emD?= =?us-ascii?Q?Xq4SGZFC5H6smxW8Tuug7wE3wnXlc2Uw4lQp5c5SOMlgUtjTStr/fFLEYg9h?= =?us-ascii?Q?jBULR5QP2SuF6gYuW6cgXLq/IR0K35d83lfJ74ATWx4Kv8qhAr9oFO2lpn79?= =?us-ascii?Q?7uQ/zUKVQAY8BkG+udl376LwN/Ezb3p3a4+rrw/BJN5avFR41immI2dmPOEm?= =?us-ascii?Q?ecx4941To413howY6QI05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v3T8x4aegJ9RrwfHmoaWIpUYfLMmnCXV8qJWff9W81T5qrVkZsCc7uAWkwy?= =?us-ascii?Q?H9R5AqK42240jnZul5KcIUqyIWG6EB4XBc8yI/f4GPQO1GqQJp59d8vcih7Y?= =?us-ascii?Q?6HxPk1Q96fkdjs/kD/WIRnhbk2oQNbdo8Z99/6Z6seeBEB6CBen++/DUbso7?= =?us-ascii?Q?lg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7b1d3ef-48b3-4c55-50d4-08dc65c556d7 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 07:49:02.2261 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oJ2ohAS33ogk056j2ifG4uOqfsOkJe7k7Rso5boEO6duMLWrocn/unSMRNcS9yXGOGS/6O7kCDSaj3bVPE7cq9wlHBXn65RUqztInqRfi94= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR13MB5279 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Xinying Yu Add the basic logic of software live migration. Unset the ring notify area to stop the direct IO datapath if the device support, then we can setup the vring relay to help the live migration. Signed-off-by: Xinying Yu Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/vdpa/nfp/nfp_vdpa.c | 66 +++++++++++++++++++++++++++++++- drivers/vdpa/nfp/nfp_vdpa_core.c | 3 ++ drivers/vdpa/nfp/nfp_vdpa_core.h | 4 ++ 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c index cef80b5476..45092cb0af 100644 --- a/drivers/vdpa/nfp/nfp_vdpa.c +++ b/drivers/vdpa/nfp/nfp_vdpa.c @@ -603,6 +603,30 @@ update_datapath(struct nfp_vdpa_dev *device) return ret; } +static int +nfp_vdpa_sw_fallback(struct nfp_vdpa_dev *device) +{ + int ret; + int vid = device->vid; + + /* Stop the direct IO data path */ + nfp_vdpa_unset_notify_relay(device); + nfp_vdpa_disable_vfio_intr(device); + + ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, false); + if ((ret != 0) && (ret != -ENOTSUP)) { + DRV_VDPA_LOG(ERR, "Unset the host notifier failed."); + goto error; + } + + device->hw.sw_fallback_running = true; + + return 0; + +error: + return ret; +} + static int nfp_vdpa_dev_config(int vid) { @@ -646,8 +670,18 @@ nfp_vdpa_dev_close(int vid) } device = node->device; - rte_atomic_store_explicit(&device->dev_attached, 0, rte_memory_order_relaxed); - update_datapath(device); + if (device->hw.sw_fallback_running) { + device->hw.sw_fallback_running = false; + + rte_atomic_store_explicit(&device->dev_attached, 0, + rte_memory_order_relaxed); + rte_atomic_store_explicit(&device->running, 0, + rte_memory_order_relaxed); + } else { + rte_atomic_store_explicit(&device->dev_attached, 0, + rte_memory_order_relaxed); + update_datapath(device); + } return 0; } @@ -770,7 +804,35 @@ nfp_vdpa_get_protocol_features(struct rte_vdpa_device *vdev __rte_unused, static int nfp_vdpa_set_features(int32_t vid) { + int ret; + uint64_t features = 0; + struct nfp_vdpa_dev *device; + struct rte_vdpa_device *vdev; + struct nfp_vdpa_dev_node *node; + DRV_VDPA_LOG(DEBUG, "Start vid=%d", vid); + + vdev = rte_vhost_get_vdpa_device(vid); + node = nfp_vdpa_find_node_by_vdev(vdev); + if (node == NULL) { + DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev); + return -ENODEV; + } + + rte_vhost_get_negotiated_features(vid, &features); + + if (RTE_VHOST_NEED_LOG(features) == 0) + return 0; + + device = node->device; + if (device->hw.sw_lm) { + ret = nfp_vdpa_sw_fallback(device); + if (ret != 0) { + DRV_VDPA_LOG(ERR, "Software fallback start failed"); + return -1; + } + } + return 0; } diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c index 79ecd2b4fc..82a323a6d0 100644 --- a/drivers/vdpa/nfp/nfp_vdpa_core.c +++ b/drivers/vdpa/nfp/nfp_vdpa_core.c @@ -91,8 +91,11 @@ nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off; hw->qcp_cfg = tx_bar + NFP_QCP_QUEUE_ADDR_SZ; + vdpa_hw->sw_lm = true; + vdpa_hw->features = (1ULL << VIRTIO_F_VERSION_1) | (1ULL << VIRTIO_F_IN_ORDER) | + (1ULL << VHOST_F_LOG_ALL) | (1ULL << VHOST_USER_F_PROTOCOL_FEATURES); return 0; diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h index a8e0d6dd70..0f880fc0c6 100644 --- a/drivers/vdpa/nfp/nfp_vdpa_core.h +++ b/drivers/vdpa/nfp/nfp_vdpa_core.h @@ -36,6 +36,10 @@ struct nfp_vdpa_hw { uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; uint8_t notify_region; uint8_t nr_vring; + + /** Software Live Migration */ + bool sw_lm; + bool sw_fallback_running; }; int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev); -- 2.39.1