From patchwork Tue Sep 19 19:08:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9960031 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 F2D98601E9 for ; Tue, 19 Sep 2017 19:11:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E325828EA4 for ; Tue, 19 Sep 2017 19:11:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D78FB28EC0; Tue, 19 Sep 2017 19:11:15 +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, UNPARSEABLE_RELAY 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 A6FBB28EA4 for ; Tue, 19 Sep 2017 19:11:14 +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 1duNt3-000458-6T; Tue, 19 Sep 2017 19:08:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duNt2-00044w-5C for xen-devel@lists.xen.org; Tue, 19 Sep 2017 19:08:48 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 95/B5-02046-F3B61C95; Tue, 19 Sep 2017 19:08:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42KZM10+UNc2+2C kwamDuhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0b/8k72guumFUduvGNrYFyp2cXIxSEkMJlJ orVhAiuE85tR4krjVRYIZyOjxPpnv4AynEBOI6PE5tf5IDabgJ5E6/nPzCC2iIC6xOmOi2Ddz AKbGSXmHm8CaxAW8JE4MWcvmM0ioCpx5uxzsAZeATuJN8eXg8UlBOQldrVdBLM5BewlDixcyw KxzE7i5MtL7BA1xhLtby+yTWDkW8DIsIpRozi1qCy1SNfISC+pKDM9oyQ3MTNH19DAWC83tbg 4MT01JzGpWC85P3cTIzBY6hkYGHcwTj3hd4hRkoNJSZS3NvZgpBBfUn5KZUZicUZ8UWlOavEh RhkODiUJ3r+ZQDnBotT01Iq0zBxg2MKkJTh4lER41bOA0rzFBYm5xZnpEKlTjMYcxzZd/sPE0 XHz7h8mIZa8/LxUKXFeL5BSAZDSjNI8uEGweLrEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZ hXB2QKT2ZeCdy+V0CnMAGdkr3hAMgpJYkIKakGRoeIFe+u39nctjRfn9Oe5XyW6WLBafPfC7s /Y78zdfui8mlfy7Ki1s/e0HTDpUtKWOVJ4utmJ3mFpX68NVK75lzVT1vgK+mfWhMTfHvzyfBJ JSnzGz2cnvxz8FIWWKnVcmpGqvSpUieRdxdCnt/XXf/OJJBj5qXCe8r+V23mH7BsUyp5OZ1lk RJLcUaioRZzUXEiAJKQ0H6iAgAA X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1505848123!111510104!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49065 invoked from network); 19 Sep 2017 19:08:45 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-15.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 19 Sep 2017 19:08:45 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v8JJ8fNi017051 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Sep 2017 19:08:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v8JJ8fvD019669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Sep 2017 19:08:41 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v8JJ8exa022350; Tue, 19 Sep 2017 19:08:40 GMT Received: from paddy.lan (/94.61.137.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Sep 2017 12:08:40 -0700 From: Joao Martins To: Xen-devel Date: Tue, 19 Sep 2017 20:08:24 +0100 Message-Id: <20170919190824.23155-2-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170919190824.23155-1-joao.m.martins@oracle.com> References: <20170919190824.23155-1-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Joao Martins , Paul Durrant , Wei Liu Subject: [Xen-devel] [PATCH v4 1/1] public/io/netif.h: add gref mapping control messages 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 Adds 3 messages to allow guest to let backend keep grants mapped, such that 1) guests allowing fast recycling of pages can avoid doing grant ops for those cases, or otherwise 2) preferring copies over grants and 3) always using a fixed set of pages for network I/O. The three control ring messages added are: - Add grefs to be mapped by backend - Remove grefs mappings (If they are not in use) - Get maximum amount of grefs kept mapped. Signed-off-by: Joao Martins Reviewed-by: Paul Durrant Reviewed-by: Konrad Rzeszutek Wilk --- v4: * Declare xen_netif_gref parameters are input or output. * Clarify status field and that it doesn't require to be set to zero prior to its usage. * Clarify on ADD_GREF_MAPPING is 'all or nothing' * Improve last paragraph of DEL_GREF_MAPPING v3: * Use DEL for unmapping grefs instead of PUT * Rname from xen_netif_gref_alloc to xen_netif_gref * Add 'status' field on xen_netif_gref * Clarify what 'inflight' means * Use "beginning of the page" instead of "beginning of the grant" * Mention that page needs to be r/w (as it will have to modify \.status) --- xen/include/public/io/netif.h | 123 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/xen/include/public/io/netif.h b/xen/include/public/io/netif.h index ca0061410d..2454448baa 100644 --- a/xen/include/public/io/netif.h +++ b/xen/include/public/io/netif.h @@ -353,6 +353,9 @@ struct xen_netif_ctrl_request { #define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 5 #define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 6 #define XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 7 +#define XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE 8 +#define XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING 9 +#define XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING 10 uint32_t data[3]; }; @@ -391,6 +394,44 @@ struct xen_netif_ctrl_response { }; /* + * Static Grants (struct xen_netif_gref) + * ===================================== + * + * A frontend may provide a fixed set of grant references to be mapped on + * the backend. The message of type XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING + * prior its usage in the command ring allows for creation of these mappings. + * The backend will maintain a fixed amount of these mappings. + * + * XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE lets a frontend query how many + * of these mappings can be kept. + * + * Each entry in the XEN_NETIF_CTRL_TYPE_{ADD,DEL}_GREF_MAPPING input table has + * the following format: + * + * 0 1 2 3 4 5 6 7 octet + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * | grant ref | flags | status | + * +-----+-----+-----+-----+-----+-----+-----+-----+ + * + * grant ref: grant reference (IN) + * flags: flags describing the control operation (IN) + * status: XEN_NETIF_CTRL_STATUS_* (OUT) + * + * 'status' is an output parameter which does not require to be set to zero + * prior to its usage in the corresponding control messages. + */ + +struct xen_netif_gref { + grant_ref_t ref; + uint16_t flags; + +#define _XEN_NETIF_CTRLF_GREF_readonly 0 +#define XEN_NETIF_CTRLF_GREF_readonly (1U<<_XEN_NETIF_CTRLF_GREF_readonly) + + uint16_t status; +}; + +/* * Control messages * ================ * @@ -609,6 +650,88 @@ struct xen_netif_ctrl_response { * invalidate any table data outside that range. * The grant reference may be read-only and must remain valid until * the response has been processed. + * + * XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE + * ----------------------------------------- + * + * This is sent by the frontend to fetch the number of grefs that can be kept + * mapped in the backend. + * + * Request: + * + * type = XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE + * data[0] = queue index (assumed 0 for single queue) + * data[1] = 0 + * data[2] = 0 + * + * Response: + * + * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not + * supported + * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - The queue index is + * out of range + * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful + * data = maximum number of entries allowed in the gref mapping table + * (if operation was successful) or zero if it is not supported. + * + * XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING + * ------------------------------------ + * + * This is sent by the frontend for backend to map a list of grant + * references. + * + * Request: + * + * type = XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING + * data[0] = queue index + * data[1] = grant reference of page containing the mapping list + * (r/w and assumed to start at beginning of page) + * data[2] = size of list in entries + * + * Response: + * + * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not + * supported + * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Operation failed + * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful + * + * NOTE: Each entry in the input table has the format outlined + * in struct xen_netif_gref. + * Contrary to XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING, the struct + * xen_netif_gref 'status' field is not used and therefore the response + * 'status' determines the success of this operation. In case of + * failure none of grants mappings get added in the backend. + * + * XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING + * ------------------------------------ + * + * This is sent by the frontend for backend to unmap a list of grant + * references. + * + * Request: + * + * type = XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING + * data[0] = queue index + * data[1] = grant reference of page containing the mapping list + * (r/w and assumed to start at beginning of page) + * data[2] = size of list in entries + * + * Response: + * + * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not + * supported + * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Operation failed + * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful + * data = number of entries that were unmapped + * + * NOTE: Each entry in the input table has the format outlined in struct + * xen_netif_gref. + * The struct xen_netif_gref 'status' field determines if the entry + * was successfully removed. + * The entries used are only the ones representing grant references that + * were previously the subject of a XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING + * operation. Any other entries will have their status set to + * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER upon completion. */ DEFINE_RING_TYPES(xen_netif_ctrl,