From nobody Fri Dec 19 02:49:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1574763984; cv=none; d=zohomail.com; s=zohoarc; b=PEhs/SCmP+edyyLgsMQ9xEu1YysAaz5WGII6QaGkBFiHMi7vET2zd4t8NOkuev+okMD0LxzGfzg9PxvAmm19KONaBo+t8Nr2uKLc6BVvmH+WJyNrBgET5LCe/RxK4SX9wi/pRJCqtdBQJntb0y3T2aXbOPBgJJigkYpqqCl3ZN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574763984; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+QD4/vKzpUKJ7oAMMcWF4SBVUkQv/vIBx+F+3VPKSIM=; b=iBuaKL5Gs+G3eJE/qKq4x4XWmT1CUUyOQc7a9cxeJX0vdpQ+V6L+YpTK0EyAqJ8N65KPFh/awpj76jnW4hGFgRSrBt5WJ5P+ls42277qpq7hnhiUXNk05daEkmqCeFaOkmNkhicJy8AIKOIgx0WVDhhN9Piv9JoQoaSiz6XU2uk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574763984967204.096712445462; Tue, 26 Nov 2019 02:26:24 -0800 (PST) Received: from localhost ([::1]:52306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZY35-0002hm-6k for importer@patchew.org; Tue, 26 Nov 2019 05:26:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57426) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZXsL-0005eM-Pg for qemu-devel@nongnu.org; Tue, 26 Nov 2019 05:15:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZXmM-000341-RC for qemu-devel@nongnu.org; Tue, 26 Nov 2019 05:09:08 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:40799) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iZXmM-00033Z-Ld for qemu-devel@nongnu.org; Tue, 26 Nov 2019 05:09:06 -0500 Received: by mail-pl1-x644.google.com with SMTP id f9so7935164plr.7 for ; Tue, 26 Nov 2019 02:09:06 -0800 (PST) Received: from localhost.localdomain ([222.151.198.97]) by smtp.gmail.com with ESMTPSA id s24sm11848485pfh.108.2019.11.26.02.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 02:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+QD4/vKzpUKJ7oAMMcWF4SBVUkQv/vIBx+F+3VPKSIM=; b=Dad2fXqh5PjlpIH3rO+thxIGofHNhYZUm+ZLETyge4e7luum6aCm1A3AI5ThMS310E R4Xj/8Eh+TByGj7pfweNNFqDHyqQKsaKv7ujNrigl64aOA5ORPDVuVwF8DBwlLQA/xsN 2ICt4DG1Q+3waVVvDBsMLEigv3rmbn1vXvQDRuRdH7w2/jXjlYjlC09XERU2kaL7p9Db MEY1/8o4irNqzMaJuU5BozHQ9JT/4oEIQ6655AN0p1nRUuGHXJHKBb/VYgmPs+Bzrcx6 VcfSImSIuac8mJWcGQMOg8yxKY4j1WneWZfogz3EYkU6dkoWEiuYjotAtqoP44jBGAOe Utcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+QD4/vKzpUKJ7oAMMcWF4SBVUkQv/vIBx+F+3VPKSIM=; b=c5IVbOu1bAatxLIg2Zo7eiadI3gbFci0LQgUhhJi68XQzjb4TXakVbUqTC4DTzL4Od F4LFX7qBYu3XJC6S3KTJSmlRGuP2JiyiXtF4nqA8Pg4OM6Dterfg/9AbrmW+ye5A6MH6 c1lJVt6ZRhEozsbUfRqAZzBCs2rQY1uNthddT3n4vqSXZgRHJLESiQwH7tBKKOtBAlx4 A2peNmnmzhoGjptkU1KHjc3fGpz+0R269cwCepsTU6imh9yNIF/IlI04WBnzTAMKxnRq vbOVX5UPJ19ulQjn49f6ffEzXOqrBwn4nhwTnznKQ6yd/+Cd+AfZuamWfxtNNz2lCEMK QiUg== X-Gm-Message-State: APjAAAVl6NIrgXEZNGN7qK4BmTk1QzVm7/a/oEyFra1w9poELh0ca508 Q2dw+mb1oEatlr5fsb20Ho4= X-Google-Smtp-Source: APXvYqxxHoIpfqZB5NCqWS+mIJcFEPH5D91ww1dQwvhntGuceZdTfPynWee8zZHRxK2/XD+OeSmwNA== X-Received: by 2002:a17:902:9891:: with SMTP id s17mr33484924plp.101.1574762945278; Tue, 26 Nov 2019 02:09:05 -0800 (PST) From: Prashant Bhole To: "David S . Miller" , "Michael S . Tsirkin" Subject: [RFC net-next 06/18] tuntap: remove usage of ptr ring in vhost_net Date: Tue, 26 Nov 2019 19:07:32 +0900 Message-Id: <20191126100744.5083-7-prashantbhole.linux@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191126100744.5083-1-prashantbhole.linux@gmail.com> References: <20191126100744.5083-1-prashantbhole.linux@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , Jakub Kicinski , Jesper Dangaard Brouer , Daniel Borkmann , netdev@vger.kernel.org, Jason Wang , John Fastabend , Alexei Starovoitov , qemu-devel@nongnu.org, Prashant Bhole , kvm@vger.kernel.org, Yonghong Song , Andrii Nakryiko , Martin KaFai Lau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Remove usage of ptr ring of tuntap in vhost_net and remove the functions exported from tuntap drivers to get ptr ring. Signed-off-by: Prashant Bhole --- drivers/net/tap.c | 13 ------------- drivers/net/tun.c | 13 ------------- drivers/vhost/net.c | 31 ++++--------------------------- include/linux/if_tap.h | 5 ----- include/linux/if_tun.h | 5 ----- 5 files changed, 4 insertions(+), 63 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 8635cdfd7aa4..6426501b8d0e 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -1298,19 +1298,6 @@ struct socket *tap_get_socket(struct file *file) } EXPORT_SYMBOL_GPL(tap_get_socket); =20 -struct ptr_ring *tap_get_ptr_ring(struct file *file) -{ - struct tap_queue *q; - - if (file->f_op !=3D &tap_fops) - return ERR_PTR(-EINVAL); - q =3D file->private_data; - if (!q) - return ERR_PTR(-EBADFD); - return &q->ring; -} -EXPORT_SYMBOL_GPL(tap_get_ptr_ring); - int tap_queue_resize(struct tap_dev *tap) { struct net_device *dev =3D tap->dev; diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 4f28f2387435..d078b4659897 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3750,19 +3750,6 @@ struct socket *tun_get_socket(struct file *file) } EXPORT_SYMBOL_GPL(tun_get_socket); =20 -struct ptr_ring *tun_get_tx_ring(struct file *file) -{ - struct tun_file *tfile; - - if (file->f_op !=3D &tun_fops) - return ERR_PTR(-EINVAL); - tfile =3D file->private_data; - if (!tfile) - return ERR_PTR(-EBADFD); - return &tfile->tx_ring; -} -EXPORT_SYMBOL_GPL(tun_get_tx_ring); - module_init(tun_init); module_exit(tun_cleanup); MODULE_DESCRIPTION(DRV_DESCRIPTION); diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 0f91b374a558..2e069d1ef946 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -122,7 +122,6 @@ struct vhost_net_virtqueue { /* Reference counting for outstanding ubufs. * Protected by vq mutex. Writers must also take device mutex. */ struct vhost_net_ubuf_ref *ubufs; - struct ptr_ring *rx_ring; struct vhost_net_buf rxq; /* Batched XDP buffs */ struct xdp_buff *xdp; @@ -997,8 +996,9 @@ static int peek_head_len(struct vhost_net_virtqueue *rv= q, struct sock *sk) int len =3D 0; unsigned long flags; =20 - if (rvq->rx_ring) - return vhost_net_buf_peek(rvq); + len =3D vhost_net_buf_peek(rvq); + if (len) + return len; =20 spin_lock_irqsave(&sk->sk_receive_queue.lock, flags); head =3D skb_peek(&sk->sk_receive_queue); @@ -1187,7 +1187,7 @@ static void handle_rx(struct vhost_net *net) goto out; } busyloop_intr =3D false; - if (nvq->rx_ring) { + if (!vhost_net_buf_is_empty(&nvq->rxq)) { ctl.type =3D TUN_MSG_PKT; ctl.ptr =3D vhost_net_buf_consume(&nvq->rxq); msg.msg_control =3D &ctl; @@ -1343,7 +1343,6 @@ static int vhost_net_open(struct inode *inode, struct= file *f) n->vqs[i].batched_xdp =3D 0; n->vqs[i].vhost_hlen =3D 0; n->vqs[i].sock_hlen =3D 0; - n->vqs[i].rx_ring =3D NULL; vhost_net_buf_init(&n->vqs[i].rxq); } vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX, @@ -1372,7 +1371,6 @@ static struct socket *vhost_net_stop_vq(struct vhost_= net *n, vhost_net_disable_vq(n, vq); vhost_net_buf_unproduce(nvq); vq->private_data =3D NULL; - nvq->rx_ring =3D NULL; mutex_unlock(&vq->mutex); return sock; } @@ -1468,25 +1466,6 @@ static struct socket *get_raw_socket(int fd) return ERR_PTR(r); } =20 -static struct ptr_ring *get_tap_ptr_ring(int fd) -{ - struct ptr_ring *ring; - struct file *file =3D fget(fd); - - if (!file) - return NULL; - ring =3D tun_get_tx_ring(file); - if (!IS_ERR(ring)) - goto out; - ring =3D tap_get_ptr_ring(file); - if (!IS_ERR(ring)) - goto out; - ring =3D NULL; -out: - fput(file); - return ring; -} - static struct socket *get_tap_socket(int fd) { struct file *file =3D fget(fd); @@ -1570,8 +1549,6 @@ static long vhost_net_set_backend(struct vhost_net *n= , unsigned index, int fd) r =3D vhost_net_enable_vq(n, vq); if (r) goto err_used; - if (index =3D=3D VHOST_NET_VQ_RX) - nvq->rx_ring =3D get_tap_ptr_ring(fd); =20 oldubufs =3D nvq->ubufs; nvq->ubufs =3D ubufs; diff --git a/include/linux/if_tap.h b/include/linux/if_tap.h index 915a187cfabd..68fe366fb185 100644 --- a/include/linux/if_tap.h +++ b/include/linux/if_tap.h @@ -4,7 +4,6 @@ =20 #if IS_ENABLED(CONFIG_TAP) struct socket *tap_get_socket(struct file *); -struct ptr_ring *tap_get_ptr_ring(struct file *file); #else #include #include @@ -14,10 +13,6 @@ static inline struct socket *tap_get_socket(struct file = *f) { return ERR_PTR(-EINVAL); } -static inline struct ptr_ring *tap_get_ptr_ring(struct file *f) -{ - return ERR_PTR(-EINVAL); -} #endif /* CONFIG_TAP */ =20 #include diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h index bb94843e3829..f01a255e076d 100644 --- a/include/linux/if_tun.h +++ b/include/linux/if_tun.h @@ -44,7 +44,6 @@ struct tun_xdp_hdr { =20 #if defined(CONFIG_TUN) || defined(CONFIG_TUN_MODULE) struct socket *tun_get_socket(struct file *); -struct ptr_ring *tun_get_tx_ring(struct file *file); bool tun_is_xdp_frame(void *ptr); void *tun_xdp_to_ptr(void *ptr); void *tun_ptr_to_xdp(void *ptr); @@ -58,10 +57,6 @@ static inline struct socket *tun_get_socket(struct file = *f) { return ERR_PTR(-EINVAL); } -static inline struct ptr_ring *tun_get_tx_ring(struct file *f) -{ - return ERR_PTR(-EINVAL); -} static inline bool tun_is_xdp_frame(void *ptr) { return false; --=20 2.20.1