From patchwork Thu Dec 5 05:38:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 63576 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 B3AD6A04F2; Thu, 5 Dec 2019 06:38:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 09E6A1BF7F; Thu, 5 Dec 2019 06:38:54 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 9F8C71BF7B for ; Thu, 5 Dec 2019 06:38:50 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id 2so1023914pfg.12 for ; Wed, 04 Dec 2019 21:38:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:content-transfer-encoding; bh=vc/358DkgxGHhxawomYKDVlgs+GCtf7JIroB1rUwUS0=; b=fq5RfZ49NzK1x3rKRvSu4VKLG4NnGyN+CNIRUg2IzNR4pEgI3dC4MdynO5BvQArBTi cjDh2JigdQ4KgMwlWq15AFjEY77MU9PiOymxzyDXC+7BFfuk5IWP0m5l8lEinl+yKjjX bFeo/ycSMDDrNqLt5jEbjXDiLZGxyXYtUoC0q0vOvfAoCQKfW9cvoB9Jk3XEeyfL75XA /ir6JqsfDzc3FavJVKemzHXjCVjMPP9cv+HFMcw/fhayr4juHlnk0GCRHw27ZvZRjIEk 6TRScgSeAvDDB2JZVxW/FuKI6csWGc1+Kg1Bep24uRP/KubFv6YAQwTiQM+NMBCw9QZ0 gZyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:content-transfer-encoding; bh=vc/358DkgxGHhxawomYKDVlgs+GCtf7JIroB1rUwUS0=; b=JODicLND01Z4OMFYGXFRmLrtWUZlc9VK8+7rfJCJ/DBdoP/k69qUkjW7ripg56rNeK 3r2QGM/7LFYtYqzPPDHjpO2ZBX9mwOJUrWhUoelWhE1ZZEvGVg6RHAmsZcN0RcZNymRw T9b0wt/v3hjMvvipMvcigUXgngHfWB6LjJzqywevhb2P3flQyl/e4M1B93+4D06GaIBp wpgDqshSDwNRisDuEYOMhqejfdt4RsPwSW8DHRT5TtBX1WjNQJ+ZY2XY4/GX/0umpaqI O1uJ+qyASM7DWWm5ckh0L3ntG79PoDLhYzFiG3RG9FmytaLigDRRkZFfb9AaylPvejc6 GpZQ== MIME-Version: 1.0 X-Gm-Message-State: APjAAAXN6NBwZZXcstcmhicyVVhf3RI/TbC/xohqnG8oO03+21EuzWcu qZaOTdY4bEwvCkbVTMCmFr1tUMoemu+OCEjp6OIzGlMeJ4+6QilOav9pvf9y/m5HOLQJpS3s X-Google-Smtp-Source: APXvYqwFFuSLn0gIJy68JdaegLZ/NknUBiBxxp6po/KVzK5hJJcb3SzuHhEI5cqd1SXBmrKWfxv/Uw== X-Received: by 2002:a63:d406:: with SMTP id a6mr7652154pgh.264.1575524329573; Wed, 04 Dec 2019 21:38:49 -0800 (PST) Received: from 31_216.localdomain (199.168.142.16.16clouds.com. [199.168.142.16]) by smtp.gmail.com with ESMTPSA id e27sm10518322pfm.26.2019.12.04.21.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 21:38:48 -0800 (PST) From: Li Feng To: Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: dev@dpdk.org, Li Feng Date: Thu, 5 Dec 2019 13:38:33 +0800 Message-Id: <20191205053833.29068-1-fengli@smartx.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191202145735.9763-1-fengli@smartx.com> References: <20191202145735.9763-1-fengli@smartx.com> Subject: [dpdk-dev] [PATCH v3] vhost: add config change slave msg support 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" This msg is used to notify qemu that should get the config of backend. For example, vhost-user-blk uses this msg to notify guest os the compacity of backend has changed. Signed-off-by: Li Feng --- v3: * Move the declare to rte_vhost.h * Add the symbol in rte_vhost_version.map v2: * Fix a little log typo. lib/librte_vhost/rte_vhost.h | 12 ++++++++++++ lib/librte_vhost/rte_vhost_version.map | 1 + lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++ lib/librte_vhost/vhost_user.h | 1 + 4 files changed, 45 insertions(+) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 7b5dc87c2..fc28da264 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -977,6 +977,18 @@ __rte_experimental int rte_vhost_get_vdpa_device_id(int vid); +/** + * Notify the guest that should get config from backend. + * + * @param vid + * vhost device ID + * @return + * 0 on success, < 0 on failure + */ +__rte_experimental +int +rte_vhost_user_slave_config_change(int vid); + #ifdef __cplusplus } #endif diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map index c512377fe..acf013d6d 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -65,4 +65,5 @@ EXPERIMENTAL { rte_vhost_clr_inflight_desc_packed; rte_vhost_get_vhost_ring_inflight; rte_vhost_get_vring_base_from_inflight; + rte_vhost_user_slave_config_change; }; diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 0cfb8b792..10f2e47d5 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm) return 0; } +static int +vhost_user_slave_config_change(struct virtio_net *dev) +{ + int ret; + struct VhostUserMsg msg = { + .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG, + .flags = VHOST_USER_VERSION, + .size = 0, + }; + + ret = send_vhost_message(dev->slave_req_fd, &msg); + if (ret < 0) { + RTE_LOG(ERR, VHOST_CONFIG, + "Failed to send config change (%d)\n", + ret); + return ret; + } + + return 0; +} + +int +rte_vhost_user_slave_config_change(int vid) +{ + struct virtio_net *dev; + dev = get_device(vid); + if (!dev) + return -ENODEV; + return vhost_user_slave_config_change(dev); +} + static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev, int index, int fd, uint64_t offset, diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h index 6563f7315..86c364a93 100644 --- a/lib/librte_vhost/vhost_user.h +++ b/lib/librte_vhost/vhost_user.h @@ -62,6 +62,7 @@ typedef enum VhostUserRequest { typedef enum VhostUserSlaveRequest { VHOST_USER_SLAVE_NONE = 0, VHOST_USER_SLAVE_IOTLB_MSG = 1, + VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2, VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3, VHOST_USER_SLAVE_MAX } VhostUserSlaveRequest;