From patchwork Tue Mar 7 02:12:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9607983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1D5A604DD for ; Tue, 7 Mar 2017 02:15:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9042E28477 for ; Tue, 7 Mar 2017 02:15:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84A9D28499; Tue, 7 Mar 2017 02:15:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8CE3D28491 for ; Tue, 7 Mar 2017 02:15:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cl4cf-00023G-JU; Tue, 07 Mar 2017 02:13:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cl4ce-000226-27 for xen-devel@lists.xenproject.org; Tue, 07 Mar 2017 02:13:08 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 32/59-13095-3371EB85; Tue, 07 Mar 2017 02:13:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnkeJIrShJLcpLzFFi42I5NlG2Q9dIfF+ EwZJ1Zhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aldwIFswQrNvyYz9jA+J+3i5GLQ0hgKqPE m8aV7F2MnEDOQSaJ5b/DQWw2AUOJv082sYHYIgKSEr+7TjODNDALvGCU2P9yNRNIQljAUWLP3 WusIDaLgKpE5+QFYIN4BVwllq75CtYsISAncfLYZLAaTgE3ib69bYwQm9sYJW5c+cYKUZQhMa 9nDpTtJbHoxiUoW03i6rlNzBMY+RYwMqxi1ChOLSpLLdI1MtRLKspMzyjJTczM0TU0MNPLTS0 uTkxPzUlMKtZLzs/dxAgMFAYg2MH4Z1nAIUZJDiYlUV6ppL0RQnxJ+SmVGYnFGfFFpTmpxYcY ZTg4lCR4hacA5QSLUtNTK9Iyc4AhC5OW4OBREuFdPAkozVtckJhbnJkOkTrFqMsxZ/buN0xCL Hn5ealS4rxCIDMEQIoySvPgRsDi5xKjrJQwLyPQUUI8BalFuZklqPKvGMU5GJWEebUmA03hyc wrgdv0CugIJqAjtF3BjihJREhJNTCauD6Vz1j+419Om8vycyfinlmvzV/2bn6c2vK30zezfNl bscZvlcdpsdotPPPcjxdN5jPpW/aVM+SDw/PCX8Vm7lMUJH7tlmTYGRBYdscuLXNWVp3MbGX9 J819K6XzpqQnsf05dfovF3t/zF+m3FtF996r9OgFPi60myeuVJd+NGL/Trb0zGtKLMUZiYZaz EXFiQAA9+NFmgIAAA== X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-4.tower-21.messagelabs.com!1488852785!54794439!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45173 invoked from network); 7 Mar 2017 02:13:06 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-4.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Mar 2017 02:13:06 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 438472024D; Tue, 7 Mar 2017 02:13:01 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hsd1.ca.comcast.net (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0849C2021F; Tue, 7 Mar 2017 02:12:59 +0000 (UTC) From: Stefano Stabellini To: qemu-devel@nongnu.org Date: Mon, 6 Mar 2017 18:12:45 -0800 Message-Id: <1488852768-8935-5-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1488852768-8935-1-git-send-email-sstabellini@kernel.org> References: <1488852768-8935-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: jgross@suse.com, sstabellini@kernel.org, Greg Kurz , Stefano Stabellini , "Aneesh Kumar K.V" , anthony.perard@citrix.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 5/8] xen/9pfs: receive requests from the frontend X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Upon receiving an event channel notification from the frontend, schedule the bottom half. From the bottom half, read one request from the ring, create a pdu and call pdu_submit to handle it. For now, only handle one request per ring at a time. Signed-off-by: Stefano Stabellini CC: anthony.perard@citrix.com CC: jgross@suse.com CC: Aneesh Kumar K.V CC: Greg Kurz --- hw/9pfs/xen-9p-backend.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 59e89fd..d4c3d36 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -94,12 +94,59 @@ static int xen_9pfs_init(struct XenDevice *xendev) return 0; } +static int xen_9pfs_receive(struct Xen9pfsRing *ring) +{ + struct xen_9pfs_header h; + RING_IDX cons, prod, masked_prod, masked_cons; + V9fsPDU *pdu; + + if (ring->inprogress) { + return 0; + } + + cons = ring->intf->out_cons; + prod = ring->intf->out_prod; + xen_rmb(); + + if (xen_9pfs_queued(prod, cons, XEN_9PFS_RING_SIZE) < sizeof(h)) { + return 0; + } + ring->inprogress = true; + + masked_prod = xen_9pfs_mask(prod, XEN_9PFS_RING_SIZE); + masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE); + + xen_9pfs_read_packet(ring->ring.out, masked_prod, &masked_cons, + XEN_9PFS_RING_SIZE, (uint8_t*) &h, sizeof(h)); + + pdu = pdu_alloc(&ring->priv->state); + pdu->size = h.size; + pdu->id = h.id; + pdu->tag = h.tag; + ring->out_size = h.size; + ring->out_cons = cons + h.size; + + qemu_co_queue_init(&pdu->complete); + pdu_submit(pdu); + + return 0; +} + static void xen_9pfs_bh(void *opaque) { + struct Xen9pfsRing *ring = opaque; + xen_9pfs_receive(ring); } static void xen_9pfs_evtchn_event(void *opaque) { + struct Xen9pfsRing *ring = opaque; + evtchn_port_t port; + + port = xenevtchn_pending(ring->evtchndev); + xenevtchn_unmask(ring->evtchndev, port); + + qemu_bh_schedule(ring->bh); } static int xen_9pfs_free(struct XenDevice *xendev)