From patchwork Wed Sep 13 18:10:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9951837 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 857186038F for ; Wed, 13 Sep 2017 18:12:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BF142893F for ; Wed, 13 Sep 2017 18:12:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70D1A28968; Wed, 13 Sep 2017 18:12:42 +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 C28B92893F for ; Wed, 13 Sep 2017 18:12: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 1dsC7l-0002H4-DM; Wed, 13 Sep 2017 18:10:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsC7j-0002Gn-UI for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:10:56 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 94/88-17770-FA479B95; Wed, 13 Sep 2017 18:10:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42LpnVTnqrumZGe kwc+vahZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aPtZdZCp4YVJzc95m1gXGPahcjF4eQwEQm iV0HvrJCOH8ZJe73vGCGcDYwSqy9upEJwmlklPi86SFQGScHm4CeROv5z8wgtoiAusTpjotg7 cwCmxkl5h5vAnI4OIQFfCTmn04BqWERUJVY8Pw6C4jNK2AnMWXRcbA5EgLyErvaLoLZnAL2Ej +vPAKzhYBqNne3sUDUGEp83riUeQIj3wJGhlWMGsWpRWWpRbpGpnpJRZnpGSW5iZk5uoYGZnq 5qcXFiempOYlJxXrJ+bmbGIHBwgAEOxhXLQg8xCjJwaQkyrtXd2ekEF9SfkplRmJxRnxRaU5q 8SFGGQ4OJQneB8VAOcGi1PTUirTMHGDYwqQlOHiURHgbQdK8xQWJucWZ6RCpU4zGHMc2Xf7Dx NFx8+4fJiGWvPy8VClx3n0gpQIgpRmleXCDYPF0iVFWSpiXEeg0IZ6C1KLczBJU+VeM4hyMSs K8rSBTeDLzSuD2vQI6hQnolDOnd4CcUpKIkJJqYMz5um8a96xgfvWCSW9NHi0w4Vy9pKL0teF ptx+Kxb+WBFjybP69R25Vi+uq+6W71LTZ50s1+G6VtDg9ock2xlHDkm+tq9WspthXzpO2Ku3P 4jm0bM+2iZuSI+8mphYsW//B86PNHvUbZfEGt65o3Sy2Otb4Ru//AdbSzP9xFuw5/d63fF+Gn VViKc5INNRiLipOBAD9PsmYogIAAA== X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1505326251!93414067!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58121 invoked from network); 13 Sep 2017 18:10:52 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-10.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Sep 2017 18:10:52 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v8DIAn2M025118 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Sep 2017 18:10:49 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v8DIAmi6011005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Sep 2017 18:10:48 GMT Received: from ubhmp0017.oracle.com (ubhmp0017.oracle.com [156.151.24.70]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v8DIAmdo016540; Wed, 13 Sep 2017 18:10:48 GMT Received: from paddy.lan (/94.61.137.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Sep 2017 18:10:47 +0000 From: Joao Martins To: Xen-devel Date: Wed, 13 Sep 2017 19:10:34 +0100 Message-Id: <20170913181034.28527-2-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913181034.28527-1-joao.m.martins@oracle.com> References: <20170913181034.28527-1-joao.m.martins@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Joao Martins , Paul Durrant , Wei Liu Subject: [Xen-devel] [PATCH v3 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 --- 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) * `data` on ADD|PUT returns number of entries mapped/unmapped. --- xen/include/public/io/netif.h | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/xen/include/public/io/netif.h b/xen/include/public/io/netif.h index ca0061410d..0080a260fd 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,41 @@ 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 + * flags: flags describing the control operation + * status: XEN_NETIF_CTRL_STATUS_* + */ + +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 +647,83 @@ 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 + * data = number of entries that were mapped + * + * NOTE: Each entry in the input table has the format outlined + * in struct xen_netif_gref. + * + * 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 only valid entries are those previously added with + * message XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING are valid, otherwise + * entries status are set to XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER. + * It will also have the same error for entries inflight i.e. used in + * requests for which haven't been sent responses to the the frontend. */ DEFINE_RING_TYPES(xen_netif_ctrl,