From patchwork Wed Dec 4 05:13:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 63547 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 2FBCCA04B5; Wed, 4 Dec 2019 06:13:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 62BDC4CA6; Wed, 4 Dec 2019 06:13:20 +0100 (CET) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id D9C104C9D for ; Wed, 4 Dec 2019 06:13:18 +0100 (CET) Received: by mail-pg1-f195.google.com with SMTP id x7so2740340pgl.11 for ; Tue, 03 Dec 2019 21:13:18 -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=LIVe9YLX4H4z40J1lilfdukJn+zdQPBdOiLiD3rqPd0=; b=VauGe5ZmsImvVZuLCCVYx9ynQhIoecadhsIUMOVGK+NIJiPZe4mofPqAufGx3hvB8M YyjY5sskzVWZvLV/9UTKSdwyLSvGzJ+2fkFJJMweyzwBXHehHNOMpgT+cir9vk0hRzmb +r9E2tGWWSualcE/RCx5HiQCNmtnfoyT3faqCyr0004i6/6OnRPti+Qhggy5LRP5x1nq sHOAL6DOMH/O0Wpd4F1ogPWuCAdQ7ivn8YDR1qfu5vzsFlBxYlmg2S5zqpteF9Ar7mAk nsxCWGnlRd/t6i7UaPDtUgjDGPqpv/PkRX3hSTs2JeAtRuoXCNev4ITdtjicm5KCNaBz L6AQ== 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=LIVe9YLX4H4z40J1lilfdukJn+zdQPBdOiLiD3rqPd0=; b=bSaPBad1g23KW1D2c4qZD2yOpVfGItPUNgnbXLS2ETnUcj8yMKiTH83YGo9MOMRc6B 7nyJdLRuSHmxgy11LBt856trnP9uwW57Apd3rguLERpzRQEgGwtHkA3uPLgmOqiT0oZ3 fbYGuh9WjCAnWHp8mtwWBowqyud8tcd/0NnjHbLGmQ7WV3K++AM8pcpcM8MR63J50fPB QlckqcuOAHGCH1Txp36QVImAxqwYOKHMhIrMJhnLipBmmHxkU6FqWRuZTMJa6TycrCQT ulUTL8hgdRhnk13ZhTbS35JPH+29R3JA/T5BAUZVMjInHbllk4fzOmooRtyQlygMigg2 R8kw== MIME-Version: 1.0 X-Gm-Message-State: APjAAAVnayoFp3kd4GWgUpy8GWcR8OyAyUZuPjmEAhS5VBpsA6odld9x RsyNSdVx9LEHFwn+sVxkEyW3TTbdJSYVd7G0vrsr5pqErjAeGWiZ/PXcnFhxDs4LDPlXPwFn X-Google-Smtp-Source: APXvYqyzu8BRlPNJ+eZGFVJsT8y4De+Z01PGOGzerJrUSMw5YKJ3IFvo3+VWvVcXFs1sv4TiWA+hpg== X-Received: by 2002:a63:3d4f:: with SMTP id k76mr1613891pga.310.1575436397789; Tue, 03 Dec 2019 21:13:17 -0800 (PST) Received: from 31_216.localdomain ([23.98.38.159]) by smtp.gmail.com with ESMTPSA id r193sm210966pfr.100.2019.12.03.21.13.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2019 21:13:16 -0800 (PST) From: Li Feng To: Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: dev@dpdk.org, Li Feng Date: Wed, 4 Dec 2019 13:13:20 +0800 Message-Id: <20191204051320.26326-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 v2] 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 --- v2: * Fix a little log typo. lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++ lib/librte_vhost/vhost_user.h | 2 ++ 2 files changed, 33 insertions(+) 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..5c1bb2138 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; @@ -158,6 +159,7 @@ typedef struct VhostUserMsg { /* vhost_user.c */ int vhost_user_msg_handler(int vid, int fd); int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm); +int rte_vhost_user_slave_config_change(int vid); /* socket.c */ int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,