From patchwork Mon Mar 20 17:59:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9634835 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 B9FF560132 for ; Mon, 20 Mar 2017 18:02:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B06F426E73 for ; Mon, 20 Mar 2017 18:02:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3BBD27B81; Mon, 20 Mar 2017 18:02:41 +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 4818D26E73 for ; Mon, 20 Mar 2017 18:02:41 +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 1cq1bB-0003wa-Ql; Mon, 20 Mar 2017 18:00:05 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cq1bA-0003od-Gw for xen-devel@lists.xenproject.org; Mon, 20 Mar 2017 18:00:04 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 70/A3-03705-3A810D85; Mon, 20 Mar 2017 18:00:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42I5NlG2Q3exxIU Ig+a5fBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bBZ9NZCl6LVOw+8JSxgfGyYBcjF4eQwFRG iQsPv7J1MXICOQeZJH6eKgKx2QQMJf4+2QQWFxFQkri3ajITiM0s0MQk0fGlqouRg0NYwFji2 dx8kDCLgKrEzqUzWUBsXgE3ib2nNoKVSwjISZw8NpkVxOYUcJd4+24eG8TedkaJnsX7mSGKMi Tm9cxhhbC9JBbduARlq0lcPbeJeQIj3wJGhlWMGsWpRWWpRbpGhnpJRZnpGSW5iZk5uoYGxnq 5qcXFiempOYlJxXrJ+bmbGIFhUs/AwLiDsWev3yFGSQ4mJVHep7fPRwjxJeWnVGYkFmfEF5Xm pBYfYpTh4FCS4J0jeiFCSLAoNT21Ii0zBxiwMGkJDh4lEd4WkDRvcUFibnFmOkTqFKMux5zZu 98wCbHk5eelSonzTgYpEgApyijNgxsBi55LjLJSwryMDAwMQjwFqUW5mSWo8q8YxTkYlYR5U0 Cm8GTmlcBtegV0BBPQEctunAE5oiQRISXVwOjT11mXLLpm9najEEHpsJqkEpHMCS9spjydI2m v/XcHc0bQlbkb710w9FS1/fkqmUdXe8Wu00+VOmu51gq9n/xqde7XA1+dAz3rH3N53/uU25H2 jjHU+17xsR87ZX5waP1eGRUp61bO991sE8Pymqd9p+pvSfT0erSaMp3ep78vaLnK7vAPj5VYi jMSDbWYi4oTAWn0KNmZAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-8.tower-31.messagelabs.com!1490032801!91222584!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 24277 invoked from network); 20 Mar 2017 18:00:02 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Mar 2017 18:00:02 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8674520386; Mon, 20 Mar 2017 18:00:00 +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 3DB0A20392; Mon, 20 Mar 2017 17:59:59 +0000 (UTC) From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 20 Mar 2017 10:59:47 -0700 Message-Id: <1490032788-23471-6-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490032788-23471-1-git-send-email-sstabellini@kernel.org> References: <1490032788-23471-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: jgross@suse.com, Latchesar Ionkov , sstabellini@kernel.org, Eric Van Hensbergen , groug@kaod.org, Stefano Stabellini , v9fs-developer@lists.sourceforge.net, Ron Minnich Subject: [Xen-devel] [PATCH v5 6/7] xen/9pfs: receive responses 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 a notification from the backend, schedule the p9_xen_response work_struct. p9_xen_response checks if any responses are available, if so, it reads them one by one, calling p9_client_cb to send them up to the 9p layer (p9_client_cb completes the request). Handle the ring following the Xen 9pfs specification. Signed-off-by: Stefano Stabellini Reviewed-by: Boris Ostrovsky CC: groug@kaod.org CC: jgross@suse.com CC: Eric Van Hensbergen CC: Ron Minnich CC: Latchesar Ionkov CC: v9fs-developer@lists.sourceforge.net Reviewed-by: Juergen Gross --- net/9p/trans_xen.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index e51edac..4ffe250 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -185,6 +185,62 @@ static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req) static void p9_xen_response(struct work_struct *work) { + struct xen_9pfs_front_priv *priv; + struct xen_9pfs_dataring *ring; + RING_IDX cons, prod, masked_cons, masked_prod; + struct xen_9pfs_header h; + struct p9_req_t *req; + int status; + + ring = container_of(work, struct xen_9pfs_dataring, work); + priv = ring->priv; + + while (1) { + cons = ring->intf->in_cons; + prod = ring->intf->in_prod; + virt_rmb(); + + if (xen_9pfs_queued(prod, cons, XEN_9PFS_RING_SIZE) < + sizeof(h)) { + notify_remote_via_irq(ring->irq); + return; + } + + masked_prod = xen_9pfs_mask(prod, XEN_9PFS_RING_SIZE); + masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE); + + /* First, read just the header */ + xen_9pfs_read_packet(ring->data.in, + masked_prod, &masked_cons, + XEN_9PFS_RING_SIZE, &h, sizeof(h)); + + req = p9_tag_lookup(priv->client, h.tag); + if (!req || req->status != REQ_STATUS_SENT) { + dev_warn(&priv->dev->dev, "Wrong req tag=%x\n", h.tag); + cons += h.size; + virt_mb(); + ring->intf->in_cons = cons; + continue; + } + + memcpy(req->rc, &h, sizeof(h)); + req->rc->offset = 0; + + masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE); + /* Then, read the whole packet (including the header) */ + xen_9pfs_read_packet(ring->data.in, + masked_prod, &masked_cons, + XEN_9PFS_RING_SIZE, req->rc->sdata, h.size); + + virt_mb(); + cons += h.size; + ring->intf->in_cons = cons; + + status = (req->status != REQ_STATUS_ERROR) ? + REQ_STATUS_RCVD : REQ_STATUS_ERROR; + + p9_client_cb(priv->client, req, status); + } } static irqreturn_t xen_9pfs_front_event_handler(int irq, void *r)