From patchwork Tue Jul 25 21:22:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9863837 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 B95D86038C for ; Tue, 25 Jul 2017 21:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1B8B26E97 for ; Tue, 25 Jul 2017 21:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9367B2860F; Tue, 25 Jul 2017 21:24: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 3B81D26E97 for ; Tue, 25 Jul 2017 21:24: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 1da7Ha-0004b7-Sf; Tue, 25 Jul 2017 21:22:22 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da7HZ-0004Xm-BJ for xen-devel@lists.xen.org; Tue, 25 Jul 2017 21:22:21 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 70/F4-02177-C86B7795; Tue, 25 Jul 2017 21:22:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42I5NlE2Wbd7W3m kwcHLVhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aaL03MBY+EK65cvsjWwLhAsIuRi0NIYB2T RMPeX4xdjJwcLAIOElO3tzF3MXJwMArESDz4YQ0SZhQIk5h8eQkriM0mYCjx98kmNhBbREBa4 trny4wgc5gFJjNKvH73ixkkISxgL/H702aomaoShxt6wGxeATeJ6Yu3gNVICMhJnDw2GWwop4 C7xPyZ21kgDmpnlPi49TTzBEbeBYwMqxg1ilOLylKLdI2M9JKKMtMzSnITM3N0DQ2M9XJTi4s T01NzEpOK9ZLzczcxAgOinoGBcQfj1BN+hxglOZiURHm/6ZZHCvEl5adUZiQWZ8QXleakFh9i lOHgUJLg/bYFKCdYlJqeWpGWmQMMTZi0BAePkgjvHZA0b3FBYm5xZjpE6hSjMceG1eu/MHG8m vD/G5MQS15+XqqUOO8ckFIBkNKM0jy4QbCYucQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmF dhK9AUnsy8Erh9r4BOYQI6Zc6MUpBTShIRUlINjDrsv1f2L7qxuWrptlN/SrQnRs3XE6u+Knd 8v5n4vwjprS+vb378loVrz4NqAZFTpYcMDENc96yv2aq5ODbG6PdmZqm3/Ydel3WFr925cs6l nR3+72ReNtzZcUkgIHmyqPrkRxs/HOaWX2fk+OdS6tZ7047pZPSH8514HHK46szyov37Vwlov K5QYinOSDTUYi4qTgQAYi6GVpQCAAA= X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1501017738!76216173!1 X-Originating-IP: [198.145.29.99] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29781 invoked from network); 25 Jul 2017 21:22:19 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.99) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Jul 2017 21:22:19 -0000 Received: from localhost.localdomain (162-198-228-33.lightspeed.wlfrct.sbcglobal.net [162.198.228.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF11922CAB; Tue, 25 Jul 2017 21:22:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF11922CAB From: Stefano Stabellini To: xen-devel@lists.xen.org Date: Tue, 25 Jul 2017 14:22:03 -0700 Message-Id: <1501017730-12797-6-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501017730-12797-1-git-send-email-sstabellini@kernel.org> References: <1501017730-12797-1-git-send-email-sstabellini@kernel.org> Cc: jgross@suse.com, Stefano Stabellini , boris.ostrovsky@oracle.com, sstabellini@kernel.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH v2 06/13] xen/pvcalls: implement listen command 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 Send PVCALLS_LISTEN to the backend. Signed-off-by: Stefano Stabellini CC: boris.ostrovsky@oracle.com CC: jgross@suse.com --- drivers/xen/pvcalls-front.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ drivers/xen/pvcalls-front.h | 1 + 2 files changed, 49 insertions(+) diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index af2ce20..3b5d50e 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c @@ -365,6 +365,54 @@ int pvcalls_front_bind(struct socket *sock, struct sockaddr *addr, int addr_len) return 0; } +int pvcalls_front_listen(struct socket *sock, int backlog) +{ + struct pvcalls_bedata *bedata; + struct sock_mapping *map; + struct xen_pvcalls_request *req; + int notify, req_id, ret; + + if (!pvcalls_front_dev) + return -ENOTCONN; + bedata = dev_get_drvdata(&pvcalls_front_dev->dev); + + map = (struct sock_mapping *) READ_ONCE(sock->sk->sk_send_head); + if (!map) + return -ENOTSOCK; + + if (map->passive.status != PVCALLS_STATUS_BIND) + return -EOPNOTSUPP; + + spin_lock(&bedata->pvcallss_lock); + req_id = bedata->ring.req_prod_pvt & (RING_SIZE(&bedata->ring) - 1); + if (RING_FULL(&bedata->ring) || + bedata->rsp[req_id].req_id != PVCALLS_INVALID_ID) { + spin_unlock(&bedata->pvcallss_lock); + return -EAGAIN; + } + req = RING_GET_REQUEST(&bedata->ring, req_id); + req->req_id = req_id; + req->cmd = PVCALLS_LISTEN; + req->u.listen.id = (uint64_t) sock; + req->u.listen.backlog = backlog; + + bedata->ring.req_prod_pvt++; + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&bedata->ring, notify); + spin_unlock(&bedata->pvcallss_lock); + if (notify) + notify_remote_via_irq(bedata->irq); + + wait_event(bedata->inflight_req, + READ_ONCE(bedata->rsp[req_id].req_id) == req_id); + + map->passive.status = PVCALLS_STATUS_LISTEN; + ret = bedata->rsp[req_id].ret; + /* read ret, then set this rsp slot to be reused */ + smp_mb(); + WRITE_ONCE(bedata->rsp[req_id].req_id, PVCALLS_INVALID_ID); + return ret; +} + static const struct xenbus_device_id pvcalls_front_ids[] = { { "pvcalls" }, { "" } diff --git a/drivers/xen/pvcalls-front.h b/drivers/xen/pvcalls-front.h index 8b0a274..aa8fe10 100644 --- a/drivers/xen/pvcalls-front.h +++ b/drivers/xen/pvcalls-front.h @@ -9,5 +9,6 @@ int pvcalls_front_connect(struct socket *sock, struct sockaddr *addr, int pvcalls_front_bind(struct socket *sock, struct sockaddr *addr, int addr_len); +int pvcalls_front_listen(struct socket *sock, int backlog); #endif