Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp456725pxa; Tue, 4 Aug 2020 09:27:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMop2DuFA30wc44e5gth2ir4tb5zJvpRHEgsRBIcfaGpdr77XU3crCy+L27FAABnf5L86U X-Received: by 2002:a17:906:858:: with SMTP id f24mr22057481ejd.543.1596558457831; Tue, 04 Aug 2020 09:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596558457; cv=none; d=google.com; s=arc-20160816; b=XNC4kAxhY453D3vMDzW8iQol23sMEt6zyXRRXnD30RwKXMscKXmQEOHGVjVz/bgbD6 i8wiWfMO2LKyzYxsfKC231UQCh9trCdXM7rnC/GX4PYZU4AyW/rRgXJ0ezexIbgGykyH 3QVV5OnBsS77lgRp5dYX3RXSh2T0W2n7MNLiAsedW4Xx6VRrNo4o1L9Gm99TfMpyDZ8Q RdjbUkLYIELminxkXF5GzcnOk2zCle67byqGCnuJdGt+UqaW4dTTgHqoWeGD4MMslN4w SxIS5GCsJGclHWBGyDQkv4T+MEDR8HANSHvMZDAIsqxSejxRJQDI9wlhDq+xtLiK9sIX 9p8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RODLbTzAHQmvvsZ/3yJ7ajaMZAtTzTh97mD57Mh3yVs=; b=ZqBYDbVlUS1K0fXMI27aIEbe5Lxv09vXDz/KUSTa2CbrdlTDO9tbsavGZ2WfG/n4KC s2QXSfF7cK0FBk51732mYt7P4FTYqVYq3ppm31E+gXGefG6krhsplIqx+s2d6uDQOO8l QDEP3PgdXT0NKp1rpCZuHgWhM2S6mdsNv7vCy9q9Y0nUyezTwbvfYVhnBRRVWF5pdTNC ivLeG696sdZxBnZvc51e+srGgt1QuXeQQ7Tg+SRGWot+GAqhklqqg/1rLKtfS7mbuU2D hsTHTKdvOU2Z1t6kjvtqdzLqBhpuWyvgxSDo6uelRGZkpVczBfyb7nG3yK0hAU+rpgZR cGcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si12555812edv.199.2020.08.04.09.27.15; Tue, 04 Aug 2020 09:27:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729990AbgHDQZw (ORCPT + 99 others); Tue, 4 Aug 2020 12:25:52 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:43867 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729610AbgHDQU6 (ORCPT ); Tue, 4 Aug 2020 12:20:58 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 4 Aug 2020 19:20:52 +0300 Received: from nps-server-21.mtl.labs.mlnx (nps-server-21.mtl.labs.mlnx [10.237.240.120]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 074GKqTE023997; Tue, 4 Aug 2020 19:20:52 +0300 Received: from nps-server-21.mtl.labs.mlnx (localhost [127.0.0.1]) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 074GKq0N022636; Tue, 4 Aug 2020 19:20:52 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 074GKqKD022635; Tue, 4 Aug 2020 19:20:52 +0300 From: Eli Cohen To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, saeedm@mellanox.com, parav@mellanox.com Subject: [PATCH V4 linux-next 02/12] vhost: generialize backend features setting/getting Date: Tue, 4 Aug 2020 19:20:38 +0300 Message-Id: <20200804162048.22587-3-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200804162048.22587-1-eli@mellanox.com> References: <20200804162048.22587-1-eli@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Wang Move the backend features setting/getting from net.c to vhost.c to be reused by vhost-vdpa. Signed-off-by: Jason Wang --- drivers/vhost/net.c | 18 ++---------------- drivers/vhost/vhost.c | 15 +++++++++++++++ drivers/vhost/vhost.h | 2 ++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 8e0921d3805d..bfbbe5c876f9 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -1615,21 +1615,6 @@ static long vhost_net_reset_owner(struct vhost_net *n) return err; } -static int vhost_net_set_backend_features(struct vhost_net *n, u64 features) -{ - int i; - - mutex_lock(&n->dev.mutex); - for (i = 0; i < VHOST_NET_VQ_MAX; ++i) { - mutex_lock(&n->vqs[i].vq.mutex); - n->vqs[i].vq.acked_backend_features = features; - mutex_unlock(&n->vqs[i].vq.mutex); - } - mutex_unlock(&n->dev.mutex); - - return 0; -} - static int vhost_net_set_features(struct vhost_net *n, u64 features) { size_t vhost_hlen, sock_hlen, hdr_len; @@ -1730,7 +1715,8 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl, return -EFAULT; if (features & ~VHOST_NET_BACKEND_FEATURES) return -EOPNOTSUPP; - return vhost_net_set_backend_features(n, features); + vhost_set_backend_features(&n->dev, features); + return 0; case VHOST_RESET_OWNER: return vhost_net_reset_owner(n); case VHOST_SET_OWNER: diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 8f622064b3e8..5e5cc3dd983e 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2591,6 +2591,21 @@ struct vhost_msg_node *vhost_dequeue_msg(struct vhost_dev *dev, } EXPORT_SYMBOL_GPL(vhost_dequeue_msg); +void vhost_set_backend_features(struct vhost_dev *dev, u64 features) +{ + struct vhost_virtqueue *vq; + int i; + + mutex_lock(&dev->mutex); + for (i = 0; i < dev->nvqs; ++i) { + vq = dev->vqs[i]; + mutex_lock(&vq->mutex); + vq->acked_backend_features = features; + mutex_unlock(&vq->mutex); + } + mutex_unlock(&dev->mutex); +} +EXPORT_SYMBOL_GPL(vhost_set_backend_features); static int __init vhost_init(void) { diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 38eb1aa3b68d..9032d3c2a9f4 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -214,6 +214,8 @@ void vhost_enqueue_msg(struct vhost_dev *dev, struct vhost_msg_node *node); struct vhost_msg_node *vhost_dequeue_msg(struct vhost_dev *dev, struct list_head *head); +void vhost_set_backend_features(struct vhost_dev *dev, u64 features); + __poll_t vhost_chr_poll(struct file *file, struct vhost_dev *dev, poll_table *wait); ssize_t vhost_chr_read_iter(struct vhost_dev *dev, struct iov_iter *to, -- 2.26.0