18c2ecf20Sopenharmony_ci/****************************************************************************** 28c2ecf20Sopenharmony_ci * xen_netif.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Unified network-device I/O interface for Xen guest OSes. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 78c2ecf20Sopenharmony_ci * of this software and associated documentation files (the "Software"), to 88c2ecf20Sopenharmony_ci * deal in the Software without restriction, including without limitation the 98c2ecf20Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 108c2ecf20Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is 118c2ecf20Sopenharmony_ci * furnished to do so, subject to the following conditions: 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 148c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 198c2ecf20Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 208c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 218c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 228c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * Copyright (c) 2003-2004, Keir Fraser 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_IO_XEN_NETIF_H__ 288c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_IO_XEN_NETIF_H__ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include "ring.h" 318c2ecf20Sopenharmony_ci#include "../grant_table.h" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* 348c2ecf20Sopenharmony_ci * Older implementation of Xen network frontend / backend has an 358c2ecf20Sopenharmony_ci * implicit dependency on the MAX_SKB_FRAGS as the maximum number of 368c2ecf20Sopenharmony_ci * ring slots a skb can use. Netfront / netback may not work as 378c2ecf20Sopenharmony_ci * expected when frontend and backend have different MAX_SKB_FRAGS. 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * A better approach is to add mechanism for netfront / netback to 408c2ecf20Sopenharmony_ci * negotiate this value. However we cannot fix all possible 418c2ecf20Sopenharmony_ci * frontends, so we need to define a value which states the minimum 428c2ecf20Sopenharmony_ci * slots backend must support. 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * The minimum value derives from older Linux kernel's MAX_SKB_FRAGS 458c2ecf20Sopenharmony_ci * (18), which is proved to work with most frontends. Any new backend 468c2ecf20Sopenharmony_ci * which doesn't negotiate with frontend should expect frontend to 478c2ecf20Sopenharmony_ci * send a valid packet using slots up to this value. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci#define XEN_NETIF_NR_SLOTS_MIN 18 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* 528c2ecf20Sopenharmony_ci * Notifications after enqueuing any type of message should be conditional on 538c2ecf20Sopenharmony_ci * the appropriate req_event or rsp_event field in the shared ring. 548c2ecf20Sopenharmony_ci * If the client sends notification for rx requests then it should specify 558c2ecf20Sopenharmony_ci * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume 568c2ecf20Sopenharmony_ci * that it cannot safely queue packets (as it may not be kicked to send them). 578c2ecf20Sopenharmony_ci */ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/* 608c2ecf20Sopenharmony_ci * "feature-split-event-channels" is introduced to separate guest TX 618c2ecf20Sopenharmony_ci * and RX notification. Backend either doesn't support this feature or 628c2ecf20Sopenharmony_ci * advertises it via xenstore as 0 (disabled) or 1 (enabled). 638c2ecf20Sopenharmony_ci * 648c2ecf20Sopenharmony_ci * To make use of this feature, frontend should allocate two event 658c2ecf20Sopenharmony_ci * channels for TX and RX, advertise them to backend as 668c2ecf20Sopenharmony_ci * "event-channel-tx" and "event-channel-rx" respectively. If frontend 678c2ecf20Sopenharmony_ci * doesn't want to use this feature, it just writes "event-channel" 688c2ecf20Sopenharmony_ci * node as before. 698c2ecf20Sopenharmony_ci */ 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* 728c2ecf20Sopenharmony_ci * Multiple transmit and receive queues: 738c2ecf20Sopenharmony_ci * If supported, the backend will write the key "multi-queue-max-queues" to 748c2ecf20Sopenharmony_ci * the directory for that vif, and set its value to the maximum supported 758c2ecf20Sopenharmony_ci * number of queues. 768c2ecf20Sopenharmony_ci * Frontends that are aware of this feature and wish to use it can write the 778c2ecf20Sopenharmony_ci * key "multi-queue-num-queues", set to the number they wish to use, which 788c2ecf20Sopenharmony_ci * must be greater than zero, and no more than the value reported by the backend 798c2ecf20Sopenharmony_ci * in "multi-queue-max-queues". 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * Queues replicate the shared rings and event channels. 828c2ecf20Sopenharmony_ci * "feature-split-event-channels" may optionally be used when using 838c2ecf20Sopenharmony_ci * multiple queues, but is not mandatory. 848c2ecf20Sopenharmony_ci * 858c2ecf20Sopenharmony_ci * Each queue consists of one shared ring pair, i.e. there must be the same 868c2ecf20Sopenharmony_ci * number of tx and rx rings. 878c2ecf20Sopenharmony_ci * 888c2ecf20Sopenharmony_ci * For frontends requesting just one queue, the usual event-channel and 898c2ecf20Sopenharmony_ci * ring-ref keys are written as before, simplifying the backend processing 908c2ecf20Sopenharmony_ci * to avoid distinguishing between a frontend that doesn't understand the 918c2ecf20Sopenharmony_ci * multi-queue feature, and one that does, but requested only one queue. 928c2ecf20Sopenharmony_ci * 938c2ecf20Sopenharmony_ci * Frontends requesting two or more queues must not write the toplevel 948c2ecf20Sopenharmony_ci * event-channel (or event-channel-{tx,rx}) and {tx,rx}-ring-ref keys, 958c2ecf20Sopenharmony_ci * instead writing those keys under sub-keys having the name "queue-N" where 968c2ecf20Sopenharmony_ci * N is the integer ID of the queue for which those keys belong. Queues 978c2ecf20Sopenharmony_ci * are indexed from zero. For example, a frontend with two queues and split 988c2ecf20Sopenharmony_ci * event channels must write the following set of queue-related keys: 998c2ecf20Sopenharmony_ci * 1008c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/multi-queue-num-queues = "2" 1018c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-0 = "" 1028c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-0/tx-ring-ref = "<ring-ref-tx0>" 1038c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-0/rx-ring-ref = "<ring-ref-rx0>" 1048c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-0/event-channel-tx = "<evtchn-tx0>" 1058c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-0/event-channel-rx = "<evtchn-rx0>" 1068c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-1 = "" 1078c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-1/tx-ring-ref = "<ring-ref-tx1>" 1088c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-1/rx-ring-ref = "<ring-ref-rx1" 1098c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-1/event-channel-tx = "<evtchn-tx1>" 1108c2ecf20Sopenharmony_ci * /local/domain/1/device/vif/0/queue-1/event-channel-rx = "<evtchn-rx1>" 1118c2ecf20Sopenharmony_ci * 1128c2ecf20Sopenharmony_ci * If there is any inconsistency in the XenStore data, the backend may 1138c2ecf20Sopenharmony_ci * choose not to connect any queues, instead treating the request as an 1148c2ecf20Sopenharmony_ci * error. This includes scenarios where more (or fewer) queues were 1158c2ecf20Sopenharmony_ci * requested than the frontend provided details for. 1168c2ecf20Sopenharmony_ci * 1178c2ecf20Sopenharmony_ci * Mapping of packets to queues is considered to be a function of the 1188c2ecf20Sopenharmony_ci * transmitting system (backend or frontend) and is not negotiated 1198c2ecf20Sopenharmony_ci * between the two. Guests are free to transmit packets on any queue 1208c2ecf20Sopenharmony_ci * they choose, provided it has been set up correctly. Guests must be 1218c2ecf20Sopenharmony_ci * prepared to receive packets on any queue they have requested be set up. 1228c2ecf20Sopenharmony_ci */ 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* 1258c2ecf20Sopenharmony_ci * "feature-no-csum-offload" should be used to turn IPv4 TCP/UDP checksum 1268c2ecf20Sopenharmony_ci * offload off or on. If it is missing then the feature is assumed to be on. 1278c2ecf20Sopenharmony_ci * "feature-ipv6-csum-offload" should be used to turn IPv6 TCP/UDP checksum 1288c2ecf20Sopenharmony_ci * offload on or off. If it is missing then the feature is assumed to be off. 1298c2ecf20Sopenharmony_ci */ 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* 1328c2ecf20Sopenharmony_ci * "feature-gso-tcpv4" and "feature-gso-tcpv6" advertise the capability to 1338c2ecf20Sopenharmony_ci * handle large TCP packets (in IPv4 or IPv6 form respectively). Neither 1348c2ecf20Sopenharmony_ci * frontends nor backends are assumed to be capable unless the flags are 1358c2ecf20Sopenharmony_ci * present. 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* 1398c2ecf20Sopenharmony_ci * "feature-multicast-control" and "feature-dynamic-multicast-control" 1408c2ecf20Sopenharmony_ci * advertise the capability to filter ethernet multicast packets in the 1418c2ecf20Sopenharmony_ci * backend. If the frontend wishes to take advantage of this feature then 1428c2ecf20Sopenharmony_ci * it may set "request-multicast-control". If the backend only advertises 1438c2ecf20Sopenharmony_ci * "feature-multicast-control" then "request-multicast-control" must be set 1448c2ecf20Sopenharmony_ci * before the frontend moves into the connected state. The backend will 1458c2ecf20Sopenharmony_ci * sample the value on this state transition and any subsequent change in 1468c2ecf20Sopenharmony_ci * value will have no effect. However, if the backend also advertises 1478c2ecf20Sopenharmony_ci * "feature-dynamic-multicast-control" then "request-multicast-control" 1488c2ecf20Sopenharmony_ci * may be set by the frontend at any time. In this case, the backend will 1498c2ecf20Sopenharmony_ci * watch the value and re-sample on watch events. 1508c2ecf20Sopenharmony_ci * 1518c2ecf20Sopenharmony_ci * If the sampled value of "request-multicast-control" is set then the 1528c2ecf20Sopenharmony_ci * backend transmit side should no longer flood multicast packets to the 1538c2ecf20Sopenharmony_ci * frontend, it should instead drop any multicast packet that does not 1548c2ecf20Sopenharmony_ci * match in a filter list. 1558c2ecf20Sopenharmony_ci * The list is amended by the frontend by sending dummy transmit requests 1568c2ecf20Sopenharmony_ci * containing XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} extra-info fragments as 1578c2ecf20Sopenharmony_ci * specified below. 1588c2ecf20Sopenharmony_ci * Note that the filter list may be amended even if the sampled value of 1598c2ecf20Sopenharmony_ci * "request-multicast-control" is not set, however the filter should only 1608c2ecf20Sopenharmony_ci * be applied if it is set. 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* 1648c2ecf20Sopenharmony_ci * "xdp-headroom" is used to request that extra space is added 1658c2ecf20Sopenharmony_ci * for XDP processing. The value is measured in bytes and passed by 1668c2ecf20Sopenharmony_ci * the frontend to be consistent between both ends. 1678c2ecf20Sopenharmony_ci * If the value is greater than zero that means that 1688c2ecf20Sopenharmony_ci * an RX response is going to be passed to an XDP program for processing. 1698c2ecf20Sopenharmony_ci * XEN_NETIF_MAX_XDP_HEADROOM defines the maximum headroom offset in bytes 1708c2ecf20Sopenharmony_ci * 1718c2ecf20Sopenharmony_ci * "feature-xdp-headroom" is set to "1" by the netback side like other features 1728c2ecf20Sopenharmony_ci * so a guest can check if an XDP program can be processed. 1738c2ecf20Sopenharmony_ci */ 1748c2ecf20Sopenharmony_ci#define XEN_NETIF_MAX_XDP_HEADROOM 0x7FFF 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* 1778c2ecf20Sopenharmony_ci * Control ring 1788c2ecf20Sopenharmony_ci * ============ 1798c2ecf20Sopenharmony_ci * 1808c2ecf20Sopenharmony_ci * Some features, such as hashing (detailed below), require a 1818c2ecf20Sopenharmony_ci * significant amount of out-of-band data to be passed from frontend to 1828c2ecf20Sopenharmony_ci * backend. Use of xenstore is not suitable for large quantities of data 1838c2ecf20Sopenharmony_ci * because of quota limitations and so a dedicated 'control ring' is used. 1848c2ecf20Sopenharmony_ci * The ability of the backend to use a control ring is advertised by 1858c2ecf20Sopenharmony_ci * setting: 1868c2ecf20Sopenharmony_ci * 1878c2ecf20Sopenharmony_ci * /local/domain/X/backend/<domid>/<vif>/feature-ctrl-ring = "1" 1888c2ecf20Sopenharmony_ci * 1898c2ecf20Sopenharmony_ci * The frontend provides a control ring to the backend by setting: 1908c2ecf20Sopenharmony_ci * 1918c2ecf20Sopenharmony_ci * /local/domain/<domid>/device/vif/<vif>/ctrl-ring-ref = <gref> 1928c2ecf20Sopenharmony_ci * /local/domain/<domid>/device/vif/<vif>/event-channel-ctrl = <port> 1938c2ecf20Sopenharmony_ci * 1948c2ecf20Sopenharmony_ci * where <gref> is the grant reference of the shared page used to 1958c2ecf20Sopenharmony_ci * implement the control ring and <port> is an event channel to be used 1968c2ecf20Sopenharmony_ci * as a mailbox interrupt. These keys must be set before the frontend 1978c2ecf20Sopenharmony_ci * moves into the connected state. 1988c2ecf20Sopenharmony_ci * 1998c2ecf20Sopenharmony_ci * The control ring uses a fixed request/response message size and is 2008c2ecf20Sopenharmony_ci * balanced (i.e. one request to one response), so operationally it is much 2018c2ecf20Sopenharmony_ci * the same as a transmit or receive ring. 2028c2ecf20Sopenharmony_ci * Note that there is no requirement that responses are issued in the same 2038c2ecf20Sopenharmony_ci * order as requests. 2048c2ecf20Sopenharmony_ci */ 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci/* 2078c2ecf20Sopenharmony_ci * Hash types 2088c2ecf20Sopenharmony_ci * ========== 2098c2ecf20Sopenharmony_ci * 2108c2ecf20Sopenharmony_ci * For the purposes of the definitions below, 'Packet[]' is an array of 2118c2ecf20Sopenharmony_ci * octets containing an IP packet without options, 'Array[X..Y]' means a 2128c2ecf20Sopenharmony_ci * sub-array of 'Array' containing bytes X thru Y inclusive, and '+' is 2138c2ecf20Sopenharmony_ci * used to indicate concatenation of arrays. 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci/* 2178c2ecf20Sopenharmony_ci * A hash calculated over an IP version 4 header as follows: 2188c2ecf20Sopenharmony_ci * 2198c2ecf20Sopenharmony_ci * Buffer[0..8] = Packet[12..15] (source address) + 2208c2ecf20Sopenharmony_ci * Packet[16..19] (destination address) 2218c2ecf20Sopenharmony_ci * 2228c2ecf20Sopenharmony_ci * Result = Hash(Buffer, 8) 2238c2ecf20Sopenharmony_ci */ 2248c2ecf20Sopenharmony_ci#define _XEN_NETIF_CTRL_HASH_TYPE_IPV4 0 2258c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_HASH_TYPE_IPV4 \ 2268c2ecf20Sopenharmony_ci (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV4) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* 2298c2ecf20Sopenharmony_ci * A hash calculated over an IP version 4 header and TCP header as 2308c2ecf20Sopenharmony_ci * follows: 2318c2ecf20Sopenharmony_ci * 2328c2ecf20Sopenharmony_ci * Buffer[0..12] = Packet[12..15] (source address) + 2338c2ecf20Sopenharmony_ci * Packet[16..19] (destination address) + 2348c2ecf20Sopenharmony_ci * Packet[20..21] (source port) + 2358c2ecf20Sopenharmony_ci * Packet[22..23] (destination port) 2368c2ecf20Sopenharmony_ci * 2378c2ecf20Sopenharmony_ci * Result = Hash(Buffer, 12) 2388c2ecf20Sopenharmony_ci */ 2398c2ecf20Sopenharmony_ci#define _XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP 1 2408c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP \ 2418c2ecf20Sopenharmony_ci (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP) 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* 2448c2ecf20Sopenharmony_ci * A hash calculated over an IP version 6 header as follows: 2458c2ecf20Sopenharmony_ci * 2468c2ecf20Sopenharmony_ci * Buffer[0..32] = Packet[8..23] (source address ) + 2478c2ecf20Sopenharmony_ci * Packet[24..39] (destination address) 2488c2ecf20Sopenharmony_ci * 2498c2ecf20Sopenharmony_ci * Result = Hash(Buffer, 32) 2508c2ecf20Sopenharmony_ci */ 2518c2ecf20Sopenharmony_ci#define _XEN_NETIF_CTRL_HASH_TYPE_IPV6 2 2528c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_HASH_TYPE_IPV6 \ 2538c2ecf20Sopenharmony_ci (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV6) 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci/* 2568c2ecf20Sopenharmony_ci * A hash calculated over an IP version 6 header and TCP header as 2578c2ecf20Sopenharmony_ci * follows: 2588c2ecf20Sopenharmony_ci * 2598c2ecf20Sopenharmony_ci * Buffer[0..36] = Packet[8..23] (source address) + 2608c2ecf20Sopenharmony_ci * Packet[24..39] (destination address) + 2618c2ecf20Sopenharmony_ci * Packet[40..41] (source port) + 2628c2ecf20Sopenharmony_ci * Packet[42..43] (destination port) 2638c2ecf20Sopenharmony_ci * 2648c2ecf20Sopenharmony_ci * Result = Hash(Buffer, 36) 2658c2ecf20Sopenharmony_ci */ 2668c2ecf20Sopenharmony_ci#define _XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP 3 2678c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP \ 2688c2ecf20Sopenharmony_ci (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP) 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* 2718c2ecf20Sopenharmony_ci * Hash algorithms 2728c2ecf20Sopenharmony_ci * =============== 2738c2ecf20Sopenharmony_ci */ 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_HASH_ALGORITHM_NONE 0 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci/* 2788c2ecf20Sopenharmony_ci * Toeplitz hash: 2798c2ecf20Sopenharmony_ci */ 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_HASH_ALGORITHM_TOEPLITZ 1 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci/* 2848c2ecf20Sopenharmony_ci * This algorithm uses a 'key' as well as the data buffer itself. 2858c2ecf20Sopenharmony_ci * (Buffer[] and Key[] are treated as shift-registers where the MSB of 2868c2ecf20Sopenharmony_ci * Buffer/Key[0] is considered 'left-most' and the LSB of Buffer/Key[N-1] 2878c2ecf20Sopenharmony_ci * is the 'right-most'). 2888c2ecf20Sopenharmony_ci * 2898c2ecf20Sopenharmony_ci * Value = 0 2908c2ecf20Sopenharmony_ci * For number of bits in Buffer[] 2918c2ecf20Sopenharmony_ci * If (left-most bit of Buffer[] is 1) 2928c2ecf20Sopenharmony_ci * Value ^= left-most 32 bits of Key[] 2938c2ecf20Sopenharmony_ci * Key[] << 1 2948c2ecf20Sopenharmony_ci * Buffer[] << 1 2958c2ecf20Sopenharmony_ci * 2968c2ecf20Sopenharmony_ci * The code below is provided for convenience where an operating system 2978c2ecf20Sopenharmony_ci * does not already provide an implementation. 2988c2ecf20Sopenharmony_ci */ 2998c2ecf20Sopenharmony_ci#ifdef XEN_NETIF_DEFINE_TOEPLITZ 3008c2ecf20Sopenharmony_cistatic uint32_t xen_netif_toeplitz_hash(const uint8_t *key, 3018c2ecf20Sopenharmony_ci unsigned int keylen, 3028c2ecf20Sopenharmony_ci const uint8_t *buf, unsigned int buflen) 3038c2ecf20Sopenharmony_ci{ 3048c2ecf20Sopenharmony_ci unsigned int keyi, bufi; 3058c2ecf20Sopenharmony_ci uint64_t prefix = 0; 3068c2ecf20Sopenharmony_ci uint64_t hash = 0; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci /* Pre-load prefix with the first 8 bytes of the key */ 3098c2ecf20Sopenharmony_ci for (keyi = 0; keyi < 8; keyi++) { 3108c2ecf20Sopenharmony_ci prefix <<= 8; 3118c2ecf20Sopenharmony_ci prefix |= (keyi < keylen) ? key[keyi] : 0; 3128c2ecf20Sopenharmony_ci } 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci for (bufi = 0; bufi < buflen; bufi++) { 3158c2ecf20Sopenharmony_ci uint8_t byte = buf[bufi]; 3168c2ecf20Sopenharmony_ci unsigned int bit; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci for (bit = 0; bit < 8; bit++) { 3198c2ecf20Sopenharmony_ci if (byte & 0x80) 3208c2ecf20Sopenharmony_ci hash ^= prefix; 3218c2ecf20Sopenharmony_ci prefix <<= 1; 3228c2ecf20Sopenharmony_ci byte <<= 1; 3238c2ecf20Sopenharmony_ci } 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci /* 3268c2ecf20Sopenharmony_ci * 'prefix' has now been left-shifted by 8, so 3278c2ecf20Sopenharmony_ci * OR in the next byte. 3288c2ecf20Sopenharmony_ci */ 3298c2ecf20Sopenharmony_ci prefix |= (keyi < keylen) ? key[keyi] : 0; 3308c2ecf20Sopenharmony_ci keyi++; 3318c2ecf20Sopenharmony_ci } 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci /* The valid part of the hash is in the upper 32 bits. */ 3348c2ecf20Sopenharmony_ci return hash >> 32; 3358c2ecf20Sopenharmony_ci} 3368c2ecf20Sopenharmony_ci#endif /* XEN_NETIF_DEFINE_TOEPLITZ */ 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci/* 3398c2ecf20Sopenharmony_ci * Control requests (struct xen_netif_ctrl_request) 3408c2ecf20Sopenharmony_ci * ================================================ 3418c2ecf20Sopenharmony_ci * 3428c2ecf20Sopenharmony_ci * All requests have the following format: 3438c2ecf20Sopenharmony_ci * 3448c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 3458c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 3468c2ecf20Sopenharmony_ci * | id | type | data[0] | 3478c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 3488c2ecf20Sopenharmony_ci * | data[1] | data[2] | 3498c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----------------------+ 3508c2ecf20Sopenharmony_ci * 3518c2ecf20Sopenharmony_ci * id: the request identifier, echoed in response. 3528c2ecf20Sopenharmony_ci * type: the type of request (see below) 3538c2ecf20Sopenharmony_ci * data[]: any data associated with the request (determined by type) 3548c2ecf20Sopenharmony_ci */ 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_cistruct xen_netif_ctrl_request { 3578c2ecf20Sopenharmony_ci uint16_t id; 3588c2ecf20Sopenharmony_ci uint16_t type; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_INVALID 0 3618c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS 1 3628c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS 2 3638c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_SET_HASH_KEY 3 3648c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 4 3658c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 5 3668c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 6 3678c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 7 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci uint32_t data[3]; 3708c2ecf20Sopenharmony_ci}; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci/* 3738c2ecf20Sopenharmony_ci * Control responses (struct xen_netif_ctrl_response) 3748c2ecf20Sopenharmony_ci * ================================================== 3758c2ecf20Sopenharmony_ci * 3768c2ecf20Sopenharmony_ci * All responses have the following format: 3778c2ecf20Sopenharmony_ci * 3788c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 3798c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 3808c2ecf20Sopenharmony_ci * | id | type | status | 3818c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 3828c2ecf20Sopenharmony_ci * | data | 3838c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+ 3848c2ecf20Sopenharmony_ci * 3858c2ecf20Sopenharmony_ci * id: the corresponding request identifier 3868c2ecf20Sopenharmony_ci * type: the type of the corresponding request 3878c2ecf20Sopenharmony_ci * status: the status of request processing 3888c2ecf20Sopenharmony_ci * data: any data associated with the response (determined by type and 3898c2ecf20Sopenharmony_ci * status) 3908c2ecf20Sopenharmony_ci */ 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_cistruct xen_netif_ctrl_response { 3938c2ecf20Sopenharmony_ci uint16_t id; 3948c2ecf20Sopenharmony_ci uint16_t type; 3958c2ecf20Sopenharmony_ci uint32_t status; 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_STATUS_SUCCESS 0 3988c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED 1 3998c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER 2 4008c2ecf20Sopenharmony_ci#define XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW 3 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci uint32_t data; 4038c2ecf20Sopenharmony_ci}; 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci/* 4068c2ecf20Sopenharmony_ci * Control messages 4078c2ecf20Sopenharmony_ci * ================ 4088c2ecf20Sopenharmony_ci * 4098c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 4108c2ecf20Sopenharmony_ci * -------------------------------------- 4118c2ecf20Sopenharmony_ci * 4128c2ecf20Sopenharmony_ci * This is sent by the frontend to set the desired hash algorithm. 4138c2ecf20Sopenharmony_ci * 4148c2ecf20Sopenharmony_ci * Request: 4158c2ecf20Sopenharmony_ci * 4168c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 4178c2ecf20Sopenharmony_ci * data[0] = a XEN_NETIF_CTRL_HASH_ALGORITHM_* value 4188c2ecf20Sopenharmony_ci * data[1] = 0 4198c2ecf20Sopenharmony_ci * data[2] = 0 4208c2ecf20Sopenharmony_ci * 4218c2ecf20Sopenharmony_ci * Response: 4228c2ecf20Sopenharmony_ci * 4238c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 4248c2ecf20Sopenharmony_ci * supported 4258c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - The algorithm is not 4268c2ecf20Sopenharmony_ci * supported 4278c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 4288c2ecf20Sopenharmony_ci * 4298c2ecf20Sopenharmony_ci * NOTE: Setting data[0] to XEN_NETIF_CTRL_HASH_ALGORITHM_NONE disables 4308c2ecf20Sopenharmony_ci * hashing and the backend is free to choose how it steers packets 4318c2ecf20Sopenharmony_ci * to queues (which is the default behaviour). 4328c2ecf20Sopenharmony_ci * 4338c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS 4348c2ecf20Sopenharmony_ci * ---------------------------------- 4358c2ecf20Sopenharmony_ci * 4368c2ecf20Sopenharmony_ci * This is sent by the frontend to query the types of hash supported by 4378c2ecf20Sopenharmony_ci * the backend. 4388c2ecf20Sopenharmony_ci * 4398c2ecf20Sopenharmony_ci * Request: 4408c2ecf20Sopenharmony_ci * 4418c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS 4428c2ecf20Sopenharmony_ci * data[0] = 0 4438c2ecf20Sopenharmony_ci * data[1] = 0 4448c2ecf20Sopenharmony_ci * data[2] = 0 4458c2ecf20Sopenharmony_ci * 4468c2ecf20Sopenharmony_ci * Response: 4478c2ecf20Sopenharmony_ci * 4488c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not supported 4498c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 4508c2ecf20Sopenharmony_ci * data = supported hash types (if operation was successful) 4518c2ecf20Sopenharmony_ci * 4528c2ecf20Sopenharmony_ci * NOTE: A valid hash algorithm must be selected before this operation can 4538c2ecf20Sopenharmony_ci * succeed. 4548c2ecf20Sopenharmony_ci * 4558c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS 4568c2ecf20Sopenharmony_ci * ---------------------------------- 4578c2ecf20Sopenharmony_ci * 4588c2ecf20Sopenharmony_ci * This is sent by the frontend to set the types of hash that the backend 4598c2ecf20Sopenharmony_ci * should calculate. (See above for hash type definitions). 4608c2ecf20Sopenharmony_ci * Note that the 'maximal' type of hash should always be chosen. For 4618c2ecf20Sopenharmony_ci * example, if the frontend sets both IPV4 and IPV4_TCP hash types then 4628c2ecf20Sopenharmony_ci * the latter hash type should be calculated for any TCP packet and the 4638c2ecf20Sopenharmony_ci * former only calculated for non-TCP packets. 4648c2ecf20Sopenharmony_ci * 4658c2ecf20Sopenharmony_ci * Request: 4668c2ecf20Sopenharmony_ci * 4678c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS 4688c2ecf20Sopenharmony_ci * data[0] = bitwise OR of XEN_NETIF_CTRL_HASH_TYPE_* values 4698c2ecf20Sopenharmony_ci * data[1] = 0 4708c2ecf20Sopenharmony_ci * data[2] = 0 4718c2ecf20Sopenharmony_ci * 4728c2ecf20Sopenharmony_ci * Response: 4738c2ecf20Sopenharmony_ci * 4748c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 4758c2ecf20Sopenharmony_ci * supported 4768c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - One or more flag 4778c2ecf20Sopenharmony_ci * value is invalid or 4788c2ecf20Sopenharmony_ci * unsupported 4798c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 4808c2ecf20Sopenharmony_ci * data = 0 4818c2ecf20Sopenharmony_ci * 4828c2ecf20Sopenharmony_ci * NOTE: A valid hash algorithm must be selected before this operation can 4838c2ecf20Sopenharmony_ci * succeed. 4848c2ecf20Sopenharmony_ci * Also, setting data[0] to zero disables hashing and the backend 4858c2ecf20Sopenharmony_ci * is free to choose how it steers packets to queues. 4868c2ecf20Sopenharmony_ci * 4878c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_SET_HASH_KEY 4888c2ecf20Sopenharmony_ci * -------------------------------- 4898c2ecf20Sopenharmony_ci * 4908c2ecf20Sopenharmony_ci * This is sent by the frontend to set the key of the hash if the algorithm 4918c2ecf20Sopenharmony_ci * requires it. (See hash algorithms above). 4928c2ecf20Sopenharmony_ci * 4938c2ecf20Sopenharmony_ci * Request: 4948c2ecf20Sopenharmony_ci * 4958c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_SET_HASH_KEY 4968c2ecf20Sopenharmony_ci * data[0] = grant reference of page containing the key (assumed to 4978c2ecf20Sopenharmony_ci * start at beginning of grant) 4988c2ecf20Sopenharmony_ci * data[1] = size of key in octets 4998c2ecf20Sopenharmony_ci * data[2] = 0 5008c2ecf20Sopenharmony_ci * 5018c2ecf20Sopenharmony_ci * Response: 5028c2ecf20Sopenharmony_ci * 5038c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 5048c2ecf20Sopenharmony_ci * supported 5058c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Key size is invalid 5068c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW - Key size is larger 5078c2ecf20Sopenharmony_ci * than the backend 5088c2ecf20Sopenharmony_ci * supports 5098c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 5108c2ecf20Sopenharmony_ci * data = 0 5118c2ecf20Sopenharmony_ci * 5128c2ecf20Sopenharmony_ci * NOTE: Any key octets not specified are assumed to be zero (the key 5138c2ecf20Sopenharmony_ci * is assumed to be empty by default) and specifying a new key 5148c2ecf20Sopenharmony_ci * invalidates any previous key, hence specifying a key size of 5158c2ecf20Sopenharmony_ci * zero will clear the key (which ensures that the calculated hash 5168c2ecf20Sopenharmony_ci * will always be zero). 5178c2ecf20Sopenharmony_ci * The maximum size of key is algorithm and backend specific, but 5188c2ecf20Sopenharmony_ci * is also limited by the single grant reference. 5198c2ecf20Sopenharmony_ci * The grant reference may be read-only and must remain valid until 5208c2ecf20Sopenharmony_ci * the response has been processed. 5218c2ecf20Sopenharmony_ci * 5228c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 5238c2ecf20Sopenharmony_ci * ----------------------------------------- 5248c2ecf20Sopenharmony_ci * 5258c2ecf20Sopenharmony_ci * This is sent by the frontend to query the maximum size of mapping 5268c2ecf20Sopenharmony_ci * table supported by the backend. The size is specified in terms of 5278c2ecf20Sopenharmony_ci * table entries. 5288c2ecf20Sopenharmony_ci * 5298c2ecf20Sopenharmony_ci * Request: 5308c2ecf20Sopenharmony_ci * 5318c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 5328c2ecf20Sopenharmony_ci * data[0] = 0 5338c2ecf20Sopenharmony_ci * data[1] = 0 5348c2ecf20Sopenharmony_ci * data[2] = 0 5358c2ecf20Sopenharmony_ci * 5368c2ecf20Sopenharmony_ci * Response: 5378c2ecf20Sopenharmony_ci * 5388c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not supported 5398c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 5408c2ecf20Sopenharmony_ci * data = maximum number of entries allowed in the mapping table 5418c2ecf20Sopenharmony_ci * (if operation was successful) or zero if a mapping table is 5428c2ecf20Sopenharmony_ci * not supported (i.e. hash mapping is done only by modular 5438c2ecf20Sopenharmony_ci * arithmetic). 5448c2ecf20Sopenharmony_ci * 5458c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 5468c2ecf20Sopenharmony_ci * ------------------------------------- 5478c2ecf20Sopenharmony_ci * 5488c2ecf20Sopenharmony_ci * This is sent by the frontend to set the actual size of the mapping 5498c2ecf20Sopenharmony_ci * table to be used by the backend. The size is specified in terms of 5508c2ecf20Sopenharmony_ci * table entries. 5518c2ecf20Sopenharmony_ci * Any previous table is invalidated by this message and any new table 5528c2ecf20Sopenharmony_ci * is assumed to be zero filled. 5538c2ecf20Sopenharmony_ci * 5548c2ecf20Sopenharmony_ci * Request: 5558c2ecf20Sopenharmony_ci * 5568c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 5578c2ecf20Sopenharmony_ci * data[0] = number of entries in mapping table 5588c2ecf20Sopenharmony_ci * data[1] = 0 5598c2ecf20Sopenharmony_ci * data[2] = 0 5608c2ecf20Sopenharmony_ci * 5618c2ecf20Sopenharmony_ci * Response: 5628c2ecf20Sopenharmony_ci * 5638c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 5648c2ecf20Sopenharmony_ci * supported 5658c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Table size is invalid 5668c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 5678c2ecf20Sopenharmony_ci * data = 0 5688c2ecf20Sopenharmony_ci * 5698c2ecf20Sopenharmony_ci * NOTE: Setting data[0] to 0 means that hash mapping should be done 5708c2ecf20Sopenharmony_ci * using modular arithmetic. 5718c2ecf20Sopenharmony_ci * 5728c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 5738c2ecf20Sopenharmony_ci * ------------------------------------ 5748c2ecf20Sopenharmony_ci * 5758c2ecf20Sopenharmony_ci * This is sent by the frontend to set the content of the table mapping 5768c2ecf20Sopenharmony_ci * hash value to queue number. The backend should calculate the hash from 5778c2ecf20Sopenharmony_ci * the packet header, use it as an index into the table (modulo the size 5788c2ecf20Sopenharmony_ci * of the table) and then steer the packet to the queue number found at 5798c2ecf20Sopenharmony_ci * that index. 5808c2ecf20Sopenharmony_ci * 5818c2ecf20Sopenharmony_ci * Request: 5828c2ecf20Sopenharmony_ci * 5838c2ecf20Sopenharmony_ci * type = XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 5848c2ecf20Sopenharmony_ci * data[0] = grant reference of page containing the mapping (sub-)table 5858c2ecf20Sopenharmony_ci * (assumed to start at beginning of grant) 5868c2ecf20Sopenharmony_ci * data[1] = size of (sub-)table in entries 5878c2ecf20Sopenharmony_ci * data[2] = offset, in entries, of sub-table within overall table 5888c2ecf20Sopenharmony_ci * 5898c2ecf20Sopenharmony_ci * Response: 5908c2ecf20Sopenharmony_ci * 5918c2ecf20Sopenharmony_ci * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 5928c2ecf20Sopenharmony_ci * supported 5938c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Table size or content 5948c2ecf20Sopenharmony_ci * is invalid 5958c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW - Table size is larger 5968c2ecf20Sopenharmony_ci * than the backend 5978c2ecf20Sopenharmony_ci * supports 5988c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 5998c2ecf20Sopenharmony_ci * data = 0 6008c2ecf20Sopenharmony_ci * 6018c2ecf20Sopenharmony_ci * NOTE: The overall table has the following format: 6028c2ecf20Sopenharmony_ci * 6038c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 6048c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6058c2ecf20Sopenharmony_ci * | mapping[0] | mapping[1] | 6068c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6078c2ecf20Sopenharmony_ci * | . | 6088c2ecf20Sopenharmony_ci * | . | 6098c2ecf20Sopenharmony_ci * | . | 6108c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6118c2ecf20Sopenharmony_ci * | mapping[N-2] | mapping[N-1] | 6128c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6138c2ecf20Sopenharmony_ci * 6148c2ecf20Sopenharmony_ci * where N is specified by a XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 6158c2ecf20Sopenharmony_ci * message and each mapping must specifies a queue between 0 and 6168c2ecf20Sopenharmony_ci * "multi-queue-num-queues" (see above). 6178c2ecf20Sopenharmony_ci * The backend may support a mapping table larger than can be 6188c2ecf20Sopenharmony_ci * mapped by a single grant reference. Thus sub-tables within a 6198c2ecf20Sopenharmony_ci * larger table can be individually set by sending multiple messages 6208c2ecf20Sopenharmony_ci * with differing offset values. Specifying a new sub-table does not 6218c2ecf20Sopenharmony_ci * invalidate any table data outside that range. 6228c2ecf20Sopenharmony_ci * The grant reference may be read-only and must remain valid until 6238c2ecf20Sopenharmony_ci * the response has been processed. 6248c2ecf20Sopenharmony_ci */ 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ciDEFINE_RING_TYPES(xen_netif_ctrl, 6278c2ecf20Sopenharmony_ci struct xen_netif_ctrl_request, 6288c2ecf20Sopenharmony_ci struct xen_netif_ctrl_response); 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci/* 6318c2ecf20Sopenharmony_ci * Guest transmit 6328c2ecf20Sopenharmony_ci * ============== 6338c2ecf20Sopenharmony_ci * 6348c2ecf20Sopenharmony_ci * This is the 'wire' format for transmit (frontend -> backend) packets: 6358c2ecf20Sopenharmony_ci * 6368c2ecf20Sopenharmony_ci * Fragment 1: xen_netif_tx_request_t - flags = XEN_NETTXF_* 6378c2ecf20Sopenharmony_ci * size = total packet size 6388c2ecf20Sopenharmony_ci * [Extra 1: xen_netif_extra_info_t] - (only if fragment 1 flags include 6398c2ecf20Sopenharmony_ci * XEN_NETTXF_extra_info) 6408c2ecf20Sopenharmony_ci * ... 6418c2ecf20Sopenharmony_ci * [Extra N: xen_netif_extra_info_t] - (only if extra N-1 flags include 6428c2ecf20Sopenharmony_ci * XEN_NETIF_EXTRA_MORE) 6438c2ecf20Sopenharmony_ci * ... 6448c2ecf20Sopenharmony_ci * Fragment N: xen_netif_tx_request_t - (only if fragment N-1 flags include 6458c2ecf20Sopenharmony_ci * XEN_NETTXF_more_data - flags on preceding 6468c2ecf20Sopenharmony_ci * extras are not relevant here) 6478c2ecf20Sopenharmony_ci * flags = 0 6488c2ecf20Sopenharmony_ci * size = fragment size 6498c2ecf20Sopenharmony_ci * 6508c2ecf20Sopenharmony_ci * NOTE: 6518c2ecf20Sopenharmony_ci * 6528c2ecf20Sopenharmony_ci * This format slightly is different from that used for receive 6538c2ecf20Sopenharmony_ci * (backend -> frontend) packets. Specifically, in a multi-fragment 6548c2ecf20Sopenharmony_ci * packet the actual size of fragment 1 can only be determined by 6558c2ecf20Sopenharmony_ci * subtracting the sizes of fragments 2..N from the total packet size. 6568c2ecf20Sopenharmony_ci * 6578c2ecf20Sopenharmony_ci * Ring slot size is 12 octets, however not all request/response 6588c2ecf20Sopenharmony_ci * structs use the full size. 6598c2ecf20Sopenharmony_ci * 6608c2ecf20Sopenharmony_ci * tx request data (xen_netif_tx_request_t) 6618c2ecf20Sopenharmony_ci * ------------------------------------ 6628c2ecf20Sopenharmony_ci * 6638c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 6648c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6658c2ecf20Sopenharmony_ci * | grant ref | offset | flags | 6668c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6678c2ecf20Sopenharmony_ci * | id | size | 6688c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+ 6698c2ecf20Sopenharmony_ci * 6708c2ecf20Sopenharmony_ci * grant ref: Reference to buffer page. 6718c2ecf20Sopenharmony_ci * offset: Offset within buffer page. 6728c2ecf20Sopenharmony_ci * flags: XEN_NETTXF_*. 6738c2ecf20Sopenharmony_ci * id: request identifier, echoed in response. 6748c2ecf20Sopenharmony_ci * size: packet size in bytes. 6758c2ecf20Sopenharmony_ci * 6768c2ecf20Sopenharmony_ci * tx response (xen_netif_tx_response_t) 6778c2ecf20Sopenharmony_ci * --------------------------------- 6788c2ecf20Sopenharmony_ci * 6798c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 6808c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6818c2ecf20Sopenharmony_ci * | id | status | unused | 6828c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 6838c2ecf20Sopenharmony_ci * | unused | 6848c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+ 6858c2ecf20Sopenharmony_ci * 6868c2ecf20Sopenharmony_ci * id: reflects id in transmit request 6878c2ecf20Sopenharmony_ci * status: XEN_NETIF_RSP_* 6888c2ecf20Sopenharmony_ci * 6898c2ecf20Sopenharmony_ci * Guest receive 6908c2ecf20Sopenharmony_ci * ============= 6918c2ecf20Sopenharmony_ci * 6928c2ecf20Sopenharmony_ci * This is the 'wire' format for receive (backend -> frontend) packets: 6938c2ecf20Sopenharmony_ci * 6948c2ecf20Sopenharmony_ci * Fragment 1: xen_netif_rx_request_t - flags = XEN_NETRXF_* 6958c2ecf20Sopenharmony_ci * size = fragment size 6968c2ecf20Sopenharmony_ci * [Extra 1: xen_netif_extra_info_t] - (only if fragment 1 flags include 6978c2ecf20Sopenharmony_ci * XEN_NETRXF_extra_info) 6988c2ecf20Sopenharmony_ci * ... 6998c2ecf20Sopenharmony_ci * [Extra N: xen_netif_extra_info_t] - (only if extra N-1 flags include 7008c2ecf20Sopenharmony_ci * XEN_NETIF_EXTRA_MORE) 7018c2ecf20Sopenharmony_ci * ... 7028c2ecf20Sopenharmony_ci * Fragment N: xen_netif_rx_request_t - (only if fragment N-1 flags include 7038c2ecf20Sopenharmony_ci * XEN_NETRXF_more_data - flags on preceding 7048c2ecf20Sopenharmony_ci * extras are not relevant here) 7058c2ecf20Sopenharmony_ci * flags = 0 7068c2ecf20Sopenharmony_ci * size = fragment size 7078c2ecf20Sopenharmony_ci * 7088c2ecf20Sopenharmony_ci * NOTE: 7098c2ecf20Sopenharmony_ci * 7108c2ecf20Sopenharmony_ci * This format slightly is different from that used for transmit 7118c2ecf20Sopenharmony_ci * (frontend -> backend) packets. Specifically, in a multi-fragment 7128c2ecf20Sopenharmony_ci * packet the size of the packet can only be determined by summing the 7138c2ecf20Sopenharmony_ci * sizes of fragments 1..N. 7148c2ecf20Sopenharmony_ci * 7158c2ecf20Sopenharmony_ci * Ring slot size is 8 octets. 7168c2ecf20Sopenharmony_ci * 7178c2ecf20Sopenharmony_ci * rx request (xen_netif_rx_request_t) 7188c2ecf20Sopenharmony_ci * ------------------------------- 7198c2ecf20Sopenharmony_ci * 7208c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 7218c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7228c2ecf20Sopenharmony_ci * | id | pad | gref | 7238c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7248c2ecf20Sopenharmony_ci * 7258c2ecf20Sopenharmony_ci * id: request identifier, echoed in response. 7268c2ecf20Sopenharmony_ci * gref: reference to incoming granted frame. 7278c2ecf20Sopenharmony_ci * 7288c2ecf20Sopenharmony_ci * rx response (xen_netif_rx_response_t) 7298c2ecf20Sopenharmony_ci * --------------------------------- 7308c2ecf20Sopenharmony_ci * 7318c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 7328c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7338c2ecf20Sopenharmony_ci * | id | offset | flags | status | 7348c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7358c2ecf20Sopenharmony_ci * 7368c2ecf20Sopenharmony_ci * id: reflects id in receive request 7378c2ecf20Sopenharmony_ci * offset: offset in page of start of received packet 7388c2ecf20Sopenharmony_ci * flags: XEN_NETRXF_* 7398c2ecf20Sopenharmony_ci * status: -ve: XEN_NETIF_RSP_*; +ve: Rx'ed pkt size. 7408c2ecf20Sopenharmony_ci * 7418c2ecf20Sopenharmony_ci * NOTE: Historically, to support GSO on the frontend receive side, Linux 7428c2ecf20Sopenharmony_ci * netfront does not make use of the rx response id (because, as 7438c2ecf20Sopenharmony_ci * described below, extra info structures overlay the id field). 7448c2ecf20Sopenharmony_ci * Instead it assumes that responses always appear in the same ring 7458c2ecf20Sopenharmony_ci * slot as their corresponding request. Thus, to maintain 7468c2ecf20Sopenharmony_ci * compatibility, backends must make sure this is the case. 7478c2ecf20Sopenharmony_ci * 7488c2ecf20Sopenharmony_ci * Extra Info 7498c2ecf20Sopenharmony_ci * ========== 7508c2ecf20Sopenharmony_ci * 7518c2ecf20Sopenharmony_ci * Can be present if initial request or response has NET{T,R}XF_extra_info, 7528c2ecf20Sopenharmony_ci * or previous extra request has XEN_NETIF_EXTRA_MORE. 7538c2ecf20Sopenharmony_ci * 7548c2ecf20Sopenharmony_ci * The struct therefore needs to fit into either a tx or rx slot and 7558c2ecf20Sopenharmony_ci * is therefore limited to 8 octets. 7568c2ecf20Sopenharmony_ci * 7578c2ecf20Sopenharmony_ci * NOTE: Because extra info data overlays the usual request/response 7588c2ecf20Sopenharmony_ci * structures, there is no id information in the opposite direction. 7598c2ecf20Sopenharmony_ci * So, if an extra info overlays an rx response the frontend can 7608c2ecf20Sopenharmony_ci * assume that it is in the same ring slot as the request that was 7618c2ecf20Sopenharmony_ci * consumed to make the slot available, and the backend must ensure 7628c2ecf20Sopenharmony_ci * this assumption is true. 7638c2ecf20Sopenharmony_ci * 7648c2ecf20Sopenharmony_ci * extra info (xen_netif_extra_info_t) 7658c2ecf20Sopenharmony_ci * ------------------------------- 7668c2ecf20Sopenharmony_ci * 7678c2ecf20Sopenharmony_ci * General format: 7688c2ecf20Sopenharmony_ci * 7698c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 7708c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7718c2ecf20Sopenharmony_ci * |type |flags| type specific data | 7728c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7738c2ecf20Sopenharmony_ci * | padding for tx | 7748c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+ 7758c2ecf20Sopenharmony_ci * 7768c2ecf20Sopenharmony_ci * type: XEN_NETIF_EXTRA_TYPE_* 7778c2ecf20Sopenharmony_ci * flags: XEN_NETIF_EXTRA_FLAG_* 7788c2ecf20Sopenharmony_ci * padding for tx: present only in the tx case due to 8 octet limit 7798c2ecf20Sopenharmony_ci * from rx case. Not shown in type specific entries 7808c2ecf20Sopenharmony_ci * below. 7818c2ecf20Sopenharmony_ci * 7828c2ecf20Sopenharmony_ci * XEN_NETIF_EXTRA_TYPE_GSO: 7838c2ecf20Sopenharmony_ci * 7848c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 7858c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7868c2ecf20Sopenharmony_ci * |type |flags| size |type | pad | features | 7878c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 7888c2ecf20Sopenharmony_ci * 7898c2ecf20Sopenharmony_ci * type: Must be XEN_NETIF_EXTRA_TYPE_GSO 7908c2ecf20Sopenharmony_ci * flags: XEN_NETIF_EXTRA_FLAG_* 7918c2ecf20Sopenharmony_ci * size: Maximum payload size of each segment. For example, 7928c2ecf20Sopenharmony_ci * for TCP this is just the path MSS. 7938c2ecf20Sopenharmony_ci * type: XEN_NETIF_GSO_TYPE_*: This determines the protocol of 7948c2ecf20Sopenharmony_ci * the packet and any extra features required to segment the 7958c2ecf20Sopenharmony_ci * packet properly. 7968c2ecf20Sopenharmony_ci * features: EN_XEN_NETIF_GSO_FEAT_*: This specifies any extra GSO 7978c2ecf20Sopenharmony_ci * features required to process this packet, such as ECN 7988c2ecf20Sopenharmony_ci * support for TCPv4. 7998c2ecf20Sopenharmony_ci * 8008c2ecf20Sopenharmony_ci * XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}: 8018c2ecf20Sopenharmony_ci * 8028c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 8038c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 8048c2ecf20Sopenharmony_ci * |type |flags| addr | 8058c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 8068c2ecf20Sopenharmony_ci * 8078c2ecf20Sopenharmony_ci * type: Must be XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} 8088c2ecf20Sopenharmony_ci * flags: XEN_NETIF_EXTRA_FLAG_* 8098c2ecf20Sopenharmony_ci * addr: address to add/remove 8108c2ecf20Sopenharmony_ci * 8118c2ecf20Sopenharmony_ci * XEN_NETIF_EXTRA_TYPE_HASH: 8128c2ecf20Sopenharmony_ci * 8138c2ecf20Sopenharmony_ci * A backend that supports teoplitz hashing is assumed to accept 8148c2ecf20Sopenharmony_ci * this type of extra info in transmit packets. 8158c2ecf20Sopenharmony_ci * A frontend that enables hashing is assumed to accept 8168c2ecf20Sopenharmony_ci * this type of extra info in receive packets. 8178c2ecf20Sopenharmony_ci * 8188c2ecf20Sopenharmony_ci * 0 1 2 3 4 5 6 7 octet 8198c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 8208c2ecf20Sopenharmony_ci * |type |flags|htype| alg |LSB ---- value ---- MSB| 8218c2ecf20Sopenharmony_ci * +-----+-----+-----+-----+-----+-----+-----+-----+ 8228c2ecf20Sopenharmony_ci * 8238c2ecf20Sopenharmony_ci * type: Must be XEN_NETIF_EXTRA_TYPE_HASH 8248c2ecf20Sopenharmony_ci * flags: XEN_NETIF_EXTRA_FLAG_* 8258c2ecf20Sopenharmony_ci * htype: Hash type (one of _XEN_NETIF_CTRL_HASH_TYPE_* - see above) 8268c2ecf20Sopenharmony_ci * alg: The algorithm used to calculate the hash (one of 8278c2ecf20Sopenharmony_ci * XEN_NETIF_CTRL_HASH_TYPE_ALGORITHM_* - see above) 8288c2ecf20Sopenharmony_ci * value: Hash value 8298c2ecf20Sopenharmony_ci */ 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_ci/* Protocol checksum field is blank in the packet (hardware offload)? */ 8328c2ecf20Sopenharmony_ci#define _XEN_NETTXF_csum_blank (0) 8338c2ecf20Sopenharmony_ci#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank) 8348c2ecf20Sopenharmony_ci 8358c2ecf20Sopenharmony_ci/* Packet data has been validated against protocol checksum. */ 8368c2ecf20Sopenharmony_ci#define _XEN_NETTXF_data_validated (1) 8378c2ecf20Sopenharmony_ci#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated) 8388c2ecf20Sopenharmony_ci 8398c2ecf20Sopenharmony_ci/* Packet continues in the next request descriptor. */ 8408c2ecf20Sopenharmony_ci#define _XEN_NETTXF_more_data (2) 8418c2ecf20Sopenharmony_ci#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data) 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_ci/* Packet to be followed by extra descriptor(s). */ 8448c2ecf20Sopenharmony_ci#define _XEN_NETTXF_extra_info (3) 8458c2ecf20Sopenharmony_ci#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info) 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_ci#define XEN_NETIF_MAX_TX_SIZE 0xFFFF 8488c2ecf20Sopenharmony_cistruct xen_netif_tx_request { 8498c2ecf20Sopenharmony_ci grant_ref_t gref; 8508c2ecf20Sopenharmony_ci uint16_t offset; 8518c2ecf20Sopenharmony_ci uint16_t flags; 8528c2ecf20Sopenharmony_ci uint16_t id; 8538c2ecf20Sopenharmony_ci uint16_t size; 8548c2ecf20Sopenharmony_ci}; 8558c2ecf20Sopenharmony_ci 8568c2ecf20Sopenharmony_ci/* Types of xen_netif_extra_info descriptors. */ 8578c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */ 8588c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */ 8598c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2) /* u.mcast */ 8608c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3) /* u.mcast */ 8618c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_HASH (4) /* u.hash */ 8628c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_XDP (5) /* u.xdp */ 8638c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_TYPE_MAX (6) 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci/* xen_netif_extra_info_t flags. */ 8668c2ecf20Sopenharmony_ci#define _XEN_NETIF_EXTRA_FLAG_MORE (0) 8678c2ecf20Sopenharmony_ci#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE) 8688c2ecf20Sopenharmony_ci 8698c2ecf20Sopenharmony_ci/* GSO types */ 8708c2ecf20Sopenharmony_ci#define XEN_NETIF_GSO_TYPE_NONE (0) 8718c2ecf20Sopenharmony_ci#define XEN_NETIF_GSO_TYPE_TCPV4 (1) 8728c2ecf20Sopenharmony_ci#define XEN_NETIF_GSO_TYPE_TCPV6 (2) 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci/* 8758c2ecf20Sopenharmony_ci * This structure needs to fit within both xen_netif_tx_request_t and 8768c2ecf20Sopenharmony_ci * xen_netif_rx_response_t for compatibility. 8778c2ecf20Sopenharmony_ci */ 8788c2ecf20Sopenharmony_cistruct xen_netif_extra_info { 8798c2ecf20Sopenharmony_ci uint8_t type; 8808c2ecf20Sopenharmony_ci uint8_t flags; 8818c2ecf20Sopenharmony_ci union { 8828c2ecf20Sopenharmony_ci struct { 8838c2ecf20Sopenharmony_ci uint16_t size; 8848c2ecf20Sopenharmony_ci uint8_t type; 8858c2ecf20Sopenharmony_ci uint8_t pad; 8868c2ecf20Sopenharmony_ci uint16_t features; 8878c2ecf20Sopenharmony_ci } gso; 8888c2ecf20Sopenharmony_ci struct { 8898c2ecf20Sopenharmony_ci uint8_t addr[6]; 8908c2ecf20Sopenharmony_ci } mcast; 8918c2ecf20Sopenharmony_ci struct { 8928c2ecf20Sopenharmony_ci uint8_t type; 8938c2ecf20Sopenharmony_ci uint8_t algorithm; 8948c2ecf20Sopenharmony_ci uint8_t value[4]; 8958c2ecf20Sopenharmony_ci } hash; 8968c2ecf20Sopenharmony_ci struct { 8978c2ecf20Sopenharmony_ci uint16_t headroom; 8988c2ecf20Sopenharmony_ci uint16_t pad[2]; 8998c2ecf20Sopenharmony_ci } xdp; 9008c2ecf20Sopenharmony_ci uint16_t pad[3]; 9018c2ecf20Sopenharmony_ci } u; 9028c2ecf20Sopenharmony_ci}; 9038c2ecf20Sopenharmony_ci 9048c2ecf20Sopenharmony_cistruct xen_netif_tx_response { 9058c2ecf20Sopenharmony_ci uint16_t id; 9068c2ecf20Sopenharmony_ci int16_t status; 9078c2ecf20Sopenharmony_ci}; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_cistruct xen_netif_rx_request { 9108c2ecf20Sopenharmony_ci uint16_t id; /* Echoed in response message. */ 9118c2ecf20Sopenharmony_ci uint16_t pad; 9128c2ecf20Sopenharmony_ci grant_ref_t gref; 9138c2ecf20Sopenharmony_ci}; 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_ci/* Packet data has been validated against protocol checksum. */ 9168c2ecf20Sopenharmony_ci#define _XEN_NETRXF_data_validated (0) 9178c2ecf20Sopenharmony_ci#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated) 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ci/* Protocol checksum field is blank in the packet (hardware offload)? */ 9208c2ecf20Sopenharmony_ci#define _XEN_NETRXF_csum_blank (1) 9218c2ecf20Sopenharmony_ci#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank) 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci/* Packet continues in the next request descriptor. */ 9248c2ecf20Sopenharmony_ci#define _XEN_NETRXF_more_data (2) 9258c2ecf20Sopenharmony_ci#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data) 9268c2ecf20Sopenharmony_ci 9278c2ecf20Sopenharmony_ci/* Packet to be followed by extra descriptor(s). */ 9288c2ecf20Sopenharmony_ci#define _XEN_NETRXF_extra_info (3) 9298c2ecf20Sopenharmony_ci#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info) 9308c2ecf20Sopenharmony_ci 9318c2ecf20Sopenharmony_ci/* Packet has GSO prefix. Deprecated but included for compatibility */ 9328c2ecf20Sopenharmony_ci#define _XEN_NETRXF_gso_prefix (4) 9338c2ecf20Sopenharmony_ci#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix) 9348c2ecf20Sopenharmony_ci 9358c2ecf20Sopenharmony_cistruct xen_netif_rx_response { 9368c2ecf20Sopenharmony_ci uint16_t id; 9378c2ecf20Sopenharmony_ci uint16_t offset; 9388c2ecf20Sopenharmony_ci uint16_t flags; 9398c2ecf20Sopenharmony_ci int16_t status; 9408c2ecf20Sopenharmony_ci}; 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci/* 9438c2ecf20Sopenharmony_ci * Generate xen_netif ring structures and types. 9448c2ecf20Sopenharmony_ci */ 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ciDEFINE_RING_TYPES(xen_netif_tx, struct xen_netif_tx_request, 9478c2ecf20Sopenharmony_ci struct xen_netif_tx_response); 9488c2ecf20Sopenharmony_ciDEFINE_RING_TYPES(xen_netif_rx, struct xen_netif_rx_request, 9498c2ecf20Sopenharmony_ci struct xen_netif_rx_response); 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci#define XEN_NETIF_RSP_DROPPED -2 9528c2ecf20Sopenharmony_ci#define XEN_NETIF_RSP_ERROR -1 9538c2ecf20Sopenharmony_ci#define XEN_NETIF_RSP_OKAY 0 9548c2ecf20Sopenharmony_ci/* No response: used for auxiliary requests (e.g., xen_netif_extra_info_t). */ 9558c2ecf20Sopenharmony_ci#define XEN_NETIF_RSP_NULL 1 9568c2ecf20Sopenharmony_ci 9578c2ecf20Sopenharmony_ci#endif 958