From patchwork Mon Oct 26 07:25:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 82168 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8EA8CA04B5; Mon, 26 Oct 2020 08:25:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E72F32B9E; Mon, 26 Oct 2020 08:25:15 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id EFD921E2B for ; Mon, 26 Oct 2020 08:25:14 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 26 Oct 2020 09:25:11 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09Q7PBvP009355; Mon, 26 Oct 2020 09:25:11 +0200 From: Xueming Li To: Maxime Coquelin , Chenbo Xia Cc: dev@dpdk.org, Matan Azrad , xuemingl@nvidia.com, Asaf Penso Date: Mon, 26 Oct 2020 07:25:01 +0000 Message-Id: <1603697101-8947-1-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [RFC] vhost: support raising device error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" According to virtio spec, The device SHOULD set DEVICE_NEEDS_RESET when it enters an error state that a reset is needed. If DRIVER_OK is set, after it sets DEVICE_NEEDS_RESET, the device MUST send a device configuration change notification to the driver. This patch introduces new api to raise vDPA hardware error and escalates configuration change to vhost via client message VHOST_USER_SLAVE_CONFIG_CHANGE_MSG. The vhost should check DRIVER_OK and decide whether to notify driver. Signed-off-by: Xueming Li --- lib/librte_vhost/rte_vdpa_dev.h | 12 ++++++++++++ lib/librte_vhost/version.map | 1 + lib/librte_vhost/vhost_user.c | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/lib/librte_vhost/rte_vdpa_dev.h b/lib/librte_vhost/rte_vdpa_dev.h index a60183f780..87b7397c6f 100644 --- a/lib/librte_vhost/rte_vdpa_dev.h +++ b/lib/librte_vhost/rte_vdpa_dev.h @@ -117,6 +117,18 @@ rte_vdpa_unregister_device(struct rte_vdpa_device *dev); int rte_vhost_host_notifier_ctrl(int vid, uint16_t qid, bool enable); +/** + * Set device hardware error and notify host. + * + * @param vid + * vhost device id + * @return + * 0 on success, -1 on failure + */ +__rte_experimental +int +rte_vhost_host_raise_error(int vid); + /** * Synchronize the used ring from mediated ring to guest, log dirty * page for each writeable buffer, caller should handle the used diff --git a/lib/librte_vhost/version.map b/lib/librte_vhost/version.map index 9183d6f2fc..5a4c5dc818 100644 --- a/lib/librte_vhost/version.map +++ b/lib/librte_vhost/version.map @@ -76,4 +76,5 @@ EXPERIMENTAL { rte_vhost_async_channel_unregister; rte_vhost_submit_enqueue_burst; rte_vhost_poll_enqueue_completed; + rte_vhost_host_raise_error; }; diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index d20c8c57ad..d8353176f2 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2992,6 +2992,20 @@ rte_vhost_slave_config_change(int vid, bool need_reply) return vhost_user_slave_config_change(dev, need_reply); } +int +rte_vhost_host_raise_error(int vid) +{ + struct virtio_net *dev; + + dev = get_device(vid); + if (!dev) + return -ENODEV; + + dev->status |= VIRTIO_DEVICE_STATUS_DEV_NEED_RESET; + + return vhost_user_slave_config_change(dev, 0); +} + static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev, int index, int fd, uint64_t offset,