1a3434a2dSAnthony PERARD /****************************************************************************** 2a3434a2dSAnthony PERARD * netif.h 3a3434a2dSAnthony PERARD * 4a3434a2dSAnthony PERARD * Unified network-device I/O interface for Xen guest OSes. 5a3434a2dSAnthony PERARD * 6a3434a2dSAnthony PERARD * Permission is hereby granted, free of charge, to any person obtaining a copy 7a3434a2dSAnthony PERARD * of this software and associated documentation files (the "Software"), to 8a3434a2dSAnthony PERARD * deal in the Software without restriction, including without limitation the 9a3434a2dSAnthony PERARD * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10a3434a2dSAnthony PERARD * sell copies of the Software, and to permit persons to whom the Software is 11a3434a2dSAnthony PERARD * furnished to do so, subject to the following conditions: 12a3434a2dSAnthony PERARD * 13a3434a2dSAnthony PERARD * The above copyright notice and this permission notice shall be included in 14a3434a2dSAnthony PERARD * all copies or substantial portions of the Software. 15a3434a2dSAnthony PERARD * 16a3434a2dSAnthony PERARD * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17a3434a2dSAnthony PERARD * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18a3434a2dSAnthony PERARD * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19a3434a2dSAnthony PERARD * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20a3434a2dSAnthony PERARD * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21a3434a2dSAnthony PERARD * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22a3434a2dSAnthony PERARD * DEALINGS IN THE SOFTWARE. 23a3434a2dSAnthony PERARD * 24a3434a2dSAnthony PERARD * Copyright (c) 2003-2004, Keir Fraser 25a3434a2dSAnthony PERARD */ 26a3434a2dSAnthony PERARD 27a3434a2dSAnthony PERARD #ifndef __XEN_PUBLIC_IO_NETIF_H__ 28a3434a2dSAnthony PERARD #define __XEN_PUBLIC_IO_NETIF_H__ 29a3434a2dSAnthony PERARD 30a3434a2dSAnthony PERARD #include "ring.h" 31a3434a2dSAnthony PERARD #include "../grant_table.h" 32a3434a2dSAnthony PERARD 33a3434a2dSAnthony PERARD /* 34a3434a2dSAnthony PERARD * Older implementation of Xen network frontend / backend has an 35a3434a2dSAnthony PERARD * implicit dependency on the MAX_SKB_FRAGS as the maximum number of 36a3434a2dSAnthony PERARD * ring slots a skb can use. Netfront / netback may not work as 37a3434a2dSAnthony PERARD * expected when frontend and backend have different MAX_SKB_FRAGS. 38a3434a2dSAnthony PERARD * 39a3434a2dSAnthony PERARD * A better approach is to add mechanism for netfront / netback to 40a3434a2dSAnthony PERARD * negotiate this value. However we cannot fix all possible 41a3434a2dSAnthony PERARD * frontends, so we need to define a value which states the minimum 42a3434a2dSAnthony PERARD * slots backend must support. 43a3434a2dSAnthony PERARD * 44a3434a2dSAnthony PERARD * The minimum value derives from older Linux kernel's MAX_SKB_FRAGS 45a3434a2dSAnthony PERARD * (18), which is proved to work with most frontends. Any new backend 46a3434a2dSAnthony PERARD * which doesn't negotiate with frontend should expect frontend to 47a3434a2dSAnthony PERARD * send a valid packet using slots up to this value. 48a3434a2dSAnthony PERARD */ 49a3434a2dSAnthony PERARD #define XEN_NETIF_NR_SLOTS_MIN 18 50a3434a2dSAnthony PERARD 51a3434a2dSAnthony PERARD /* 52a3434a2dSAnthony PERARD * Notifications after enqueuing any type of message should be conditional on 53a3434a2dSAnthony PERARD * the appropriate req_event or rsp_event field in the shared ring. 54a3434a2dSAnthony PERARD * If the client sends notification for rx requests then it should specify 55a3434a2dSAnthony PERARD * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume 56a3434a2dSAnthony PERARD * that it cannot safely queue packets (as it may not be kicked to send them). 57a3434a2dSAnthony PERARD */ 58a3434a2dSAnthony PERARD 59a3434a2dSAnthony PERARD /* 60a3434a2dSAnthony PERARD * "feature-split-event-channels" is introduced to separate guest TX 61a3434a2dSAnthony PERARD * and RX notification. Backend either doesn't support this feature or 62a3434a2dSAnthony PERARD * advertises it via xenstore as 0 (disabled) or 1 (enabled). 63a3434a2dSAnthony PERARD * 64a3434a2dSAnthony PERARD * To make use of this feature, frontend should allocate two event 65a3434a2dSAnthony PERARD * channels for TX and RX, advertise them to backend as 66a3434a2dSAnthony PERARD * "event-channel-tx" and "event-channel-rx" respectively. If frontend 67a3434a2dSAnthony PERARD * doesn't want to use this feature, it just writes "event-channel" 68a3434a2dSAnthony PERARD * node as before. 69a3434a2dSAnthony PERARD */ 70a3434a2dSAnthony PERARD 71a3434a2dSAnthony PERARD /* 72a3434a2dSAnthony PERARD * Multiple transmit and receive queues: 73a3434a2dSAnthony PERARD * If supported, the backend will write the key "multi-queue-max-queues" to 74a3434a2dSAnthony PERARD * the directory for that vif, and set its value to the maximum supported 75a3434a2dSAnthony PERARD * number of queues. 76a3434a2dSAnthony PERARD * Frontends that are aware of this feature and wish to use it can write the 77a3434a2dSAnthony PERARD * key "multi-queue-num-queues", set to the number they wish to use, which 78a3434a2dSAnthony PERARD * must be greater than zero, and no more than the value reported by the backend 79a3434a2dSAnthony PERARD * in "multi-queue-max-queues". 80a3434a2dSAnthony PERARD * 81a3434a2dSAnthony PERARD * Queues replicate the shared rings and event channels. 82a3434a2dSAnthony PERARD * "feature-split-event-channels" may optionally be used when using 83a3434a2dSAnthony PERARD * multiple queues, but is not mandatory. 84a3434a2dSAnthony PERARD * 85a3434a2dSAnthony PERARD * Each queue consists of one shared ring pair, i.e. there must be the same 86a3434a2dSAnthony PERARD * number of tx and rx rings. 87a3434a2dSAnthony PERARD * 88a3434a2dSAnthony PERARD * For frontends requesting just one queue, the usual event-channel and 89a3434a2dSAnthony PERARD * ring-ref keys are written as before, simplifying the backend processing 90a3434a2dSAnthony PERARD * to avoid distinguishing between a frontend that doesn't understand the 91a3434a2dSAnthony PERARD * multi-queue feature, and one that does, but requested only one queue. 92a3434a2dSAnthony PERARD * 93a3434a2dSAnthony PERARD * Frontends requesting two or more queues must not write the toplevel 94a3434a2dSAnthony PERARD * event-channel (or event-channel-{tx,rx}) and {tx,rx}-ring-ref keys, 95a3434a2dSAnthony PERARD * instead writing those keys under sub-keys having the name "queue-N" where 96a3434a2dSAnthony PERARD * N is the integer ID of the queue for which those keys belong. Queues 97a3434a2dSAnthony PERARD * are indexed from zero. For example, a frontend with two queues and split 98a3434a2dSAnthony PERARD * event channels must write the following set of queue-related keys: 99a3434a2dSAnthony PERARD * 100a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/multi-queue-num-queues = "2" 101a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-0 = "" 102a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-0/tx-ring-ref = "<ring-ref-tx0>" 103a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-0/rx-ring-ref = "<ring-ref-rx0>" 104a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-0/event-channel-tx = "<evtchn-tx0>" 105a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-0/event-channel-rx = "<evtchn-rx0>" 106a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-1 = "" 107a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-1/tx-ring-ref = "<ring-ref-tx1>" 108a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-1/rx-ring-ref = "<ring-ref-rx1" 109a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-1/event-channel-tx = "<evtchn-tx1>" 110a3434a2dSAnthony PERARD * /local/domain/1/device/vif/0/queue-1/event-channel-rx = "<evtchn-rx1>" 111a3434a2dSAnthony PERARD * 112a3434a2dSAnthony PERARD * If there is any inconsistency in the XenStore data, the backend may 113a3434a2dSAnthony PERARD * choose not to connect any queues, instead treating the request as an 114a3434a2dSAnthony PERARD * error. This includes scenarios where more (or fewer) queues were 115a3434a2dSAnthony PERARD * requested than the frontend provided details for. 116a3434a2dSAnthony PERARD * 117a3434a2dSAnthony PERARD * Mapping of packets to queues is considered to be a function of the 118a3434a2dSAnthony PERARD * transmitting system (backend or frontend) and is not negotiated 119a3434a2dSAnthony PERARD * between the two. Guests are free to transmit packets on any queue 120a3434a2dSAnthony PERARD * they choose, provided it has been set up correctly. Guests must be 121a3434a2dSAnthony PERARD * prepared to receive packets on any queue they have requested be set up. 122a3434a2dSAnthony PERARD */ 123a3434a2dSAnthony PERARD 124a3434a2dSAnthony PERARD /* 125a3434a2dSAnthony PERARD * "feature-no-csum-offload" should be used to turn IPv4 TCP/UDP checksum 126a3434a2dSAnthony PERARD * offload off or on. If it is missing then the feature is assumed to be on. 127a3434a2dSAnthony PERARD * "feature-ipv6-csum-offload" should be used to turn IPv6 TCP/UDP checksum 128a3434a2dSAnthony PERARD * offload on or off. If it is missing then the feature is assumed to be off. 129a3434a2dSAnthony PERARD */ 130a3434a2dSAnthony PERARD 131a3434a2dSAnthony PERARD /* 132a3434a2dSAnthony PERARD * "feature-gso-tcpv4" and "feature-gso-tcpv6" advertise the capability to 133a3434a2dSAnthony PERARD * handle large TCP packets (in IPv4 or IPv6 form respectively). Neither 134a3434a2dSAnthony PERARD * frontends nor backends are assumed to be capable unless the flags are 135a3434a2dSAnthony PERARD * present. 136a3434a2dSAnthony PERARD */ 137a3434a2dSAnthony PERARD 138a3434a2dSAnthony PERARD /* 139a3434a2dSAnthony PERARD * "feature-multicast-control" and "feature-dynamic-multicast-control" 140a3434a2dSAnthony PERARD * advertise the capability to filter ethernet multicast packets in the 141a3434a2dSAnthony PERARD * backend. If the frontend wishes to take advantage of this feature then 142a3434a2dSAnthony PERARD * it may set "request-multicast-control". If the backend only advertises 143a3434a2dSAnthony PERARD * "feature-multicast-control" then "request-multicast-control" must be set 144a3434a2dSAnthony PERARD * before the frontend moves into the connected state. The backend will 145a3434a2dSAnthony PERARD * sample the value on this state transition and any subsequent change in 146a3434a2dSAnthony PERARD * value will have no effect. However, if the backend also advertises 147a3434a2dSAnthony PERARD * "feature-dynamic-multicast-control" then "request-multicast-control" 148a3434a2dSAnthony PERARD * may be set by the frontend at any time. In this case, the backend will 149a3434a2dSAnthony PERARD * watch the value and re-sample on watch events. 150a3434a2dSAnthony PERARD * 151a3434a2dSAnthony PERARD * If the sampled value of "request-multicast-control" is set then the 152a3434a2dSAnthony PERARD * backend transmit side should no longer flood multicast packets to the 153a3434a2dSAnthony PERARD * frontend, it should instead drop any multicast packet that does not 154a3434a2dSAnthony PERARD * match in a filter list. 155a3434a2dSAnthony PERARD * The list is amended by the frontend by sending dummy transmit requests 156a3434a2dSAnthony PERARD * containing XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} extra-info fragments as 157a3434a2dSAnthony PERARD * specified below. 158a3434a2dSAnthony PERARD * Note that the filter list may be amended even if the sampled value of 159a3434a2dSAnthony PERARD * "request-multicast-control" is not set, however the filter should only 160a3434a2dSAnthony PERARD * be applied if it is set. 161a3434a2dSAnthony PERARD */ 162a3434a2dSAnthony PERARD 163a3434a2dSAnthony PERARD /* 164a3434a2dSAnthony PERARD * Control ring 165a3434a2dSAnthony PERARD * ============ 166a3434a2dSAnthony PERARD * 167a3434a2dSAnthony PERARD * Some features, such as hashing (detailed below), require a 168a3434a2dSAnthony PERARD * significant amount of out-of-band data to be passed from frontend to 169a3434a2dSAnthony PERARD * backend. Use of xenstore is not suitable for large quantities of data 170a3434a2dSAnthony PERARD * because of quota limitations and so a dedicated 'control ring' is used. 171a3434a2dSAnthony PERARD * The ability of the backend to use a control ring is advertised by 172a3434a2dSAnthony PERARD * setting: 173a3434a2dSAnthony PERARD * 174*50c88402SJoao Martins * /local/domain/X/backend/vif/<domid>/<vif>/feature-ctrl-ring = "1" 175a3434a2dSAnthony PERARD * 176a3434a2dSAnthony PERARD * The frontend provides a control ring to the backend by setting: 177a3434a2dSAnthony PERARD * 178a3434a2dSAnthony PERARD * /local/domain/<domid>/device/vif/<vif>/ctrl-ring-ref = <gref> 179a3434a2dSAnthony PERARD * /local/domain/<domid>/device/vif/<vif>/event-channel-ctrl = <port> 180a3434a2dSAnthony PERARD * 181a3434a2dSAnthony PERARD * where <gref> is the grant reference of the shared page used to 182a3434a2dSAnthony PERARD * implement the control ring and <port> is an event channel to be used 183a3434a2dSAnthony PERARD * as a mailbox interrupt. These keys must be set before the frontend 184a3434a2dSAnthony PERARD * moves into the connected state. 185a3434a2dSAnthony PERARD * 186a3434a2dSAnthony PERARD * The control ring uses a fixed request/response message size and is 187a3434a2dSAnthony PERARD * balanced (i.e. one request to one response), so operationally it is much 188a3434a2dSAnthony PERARD * the same as a transmit or receive ring. 189a3434a2dSAnthony PERARD * Note that there is no requirement that responses are issued in the same 190a3434a2dSAnthony PERARD * order as requests. 191a3434a2dSAnthony PERARD */ 192a3434a2dSAnthony PERARD 193a3434a2dSAnthony PERARD /* 194*50c88402SJoao Martins * Link state 195*50c88402SJoao Martins * ========== 196*50c88402SJoao Martins * 197*50c88402SJoao Martins * The backend can advertise its current link (carrier) state to the 198*50c88402SJoao Martins * frontend using the /local/domain/X/backend/vif/<domid>/<vif>/carrier 199*50c88402SJoao Martins * node. If this node is not present, then the frontend should assume that 200*50c88402SJoao Martins * the link is up (for compatibility with backends that do not implement 201*50c88402SJoao Martins * this feature). If this node is present, then a value of "0" should be 202*50c88402SJoao Martins * interpreted by the frontend as the link being down (no carrier) and a 203*50c88402SJoao Martins * value of "1" should be interpreted as the link being up (carrier 204*50c88402SJoao Martins * present). 205*50c88402SJoao Martins */ 206*50c88402SJoao Martins 207*50c88402SJoao Martins /* 208*50c88402SJoao Martins * MTU 209*50c88402SJoao Martins * === 210*50c88402SJoao Martins * 211*50c88402SJoao Martins * The toolstack may set a value of MTU for the frontend by setting the 212*50c88402SJoao Martins * /local/domain/<domid>/device/vif/<vif>/mtu node with the MTU value in 213*50c88402SJoao Martins * octets. If this node is absent the frontend should assume an MTU value 214*50c88402SJoao Martins * of 1500 octets. A frontend is also at liberty to ignore this value so 215*50c88402SJoao Martins * it is only suitable for informing the frontend that a packet payload 216*50c88402SJoao Martins * >1500 octets is permitted. 217*50c88402SJoao Martins */ 218*50c88402SJoao Martins 219*50c88402SJoao Martins /* 220a3434a2dSAnthony PERARD * Hash types 221a3434a2dSAnthony PERARD * ========== 222a3434a2dSAnthony PERARD * 223a3434a2dSAnthony PERARD * For the purposes of the definitions below, 'Packet[]' is an array of 224a3434a2dSAnthony PERARD * octets containing an IP packet without options, 'Array[X..Y]' means a 225a3434a2dSAnthony PERARD * sub-array of 'Array' containing bytes X thru Y inclusive, and '+' is 226a3434a2dSAnthony PERARD * used to indicate concatenation of arrays. 227a3434a2dSAnthony PERARD */ 228a3434a2dSAnthony PERARD 229a3434a2dSAnthony PERARD /* 230a3434a2dSAnthony PERARD * A hash calculated over an IP version 4 header as follows: 231a3434a2dSAnthony PERARD * 232a3434a2dSAnthony PERARD * Buffer[0..8] = Packet[12..15] (source address) + 233a3434a2dSAnthony PERARD * Packet[16..19] (destination address) 234a3434a2dSAnthony PERARD * 235a3434a2dSAnthony PERARD * Result = Hash(Buffer, 8) 236a3434a2dSAnthony PERARD */ 237a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV4 0 238a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV4 \ 239a3434a2dSAnthony PERARD (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV4) 240a3434a2dSAnthony PERARD 241a3434a2dSAnthony PERARD /* 242a3434a2dSAnthony PERARD * A hash calculated over an IP version 4 header and TCP header as 243a3434a2dSAnthony PERARD * follows: 244a3434a2dSAnthony PERARD * 245a3434a2dSAnthony PERARD * Buffer[0..12] = Packet[12..15] (source address) + 246a3434a2dSAnthony PERARD * Packet[16..19] (destination address) + 247a3434a2dSAnthony PERARD * Packet[20..21] (source port) + 248a3434a2dSAnthony PERARD * Packet[22..23] (destination port) 249a3434a2dSAnthony PERARD * 250a3434a2dSAnthony PERARD * Result = Hash(Buffer, 12) 251a3434a2dSAnthony PERARD */ 252a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP 1 253a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP \ 254a3434a2dSAnthony PERARD (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP) 255a3434a2dSAnthony PERARD 256a3434a2dSAnthony PERARD /* 257a3434a2dSAnthony PERARD * A hash calculated over an IP version 6 header as follows: 258a3434a2dSAnthony PERARD * 259a3434a2dSAnthony PERARD * Buffer[0..32] = Packet[8..23] (source address ) + 260a3434a2dSAnthony PERARD * Packet[24..39] (destination address) 261a3434a2dSAnthony PERARD * 262a3434a2dSAnthony PERARD * Result = Hash(Buffer, 32) 263a3434a2dSAnthony PERARD */ 264a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV6 2 265a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV6 \ 266a3434a2dSAnthony PERARD (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV6) 267a3434a2dSAnthony PERARD 268a3434a2dSAnthony PERARD /* 269a3434a2dSAnthony PERARD * A hash calculated over an IP version 6 header and TCP header as 270a3434a2dSAnthony PERARD * follows: 271a3434a2dSAnthony PERARD * 272a3434a2dSAnthony PERARD * Buffer[0..36] = Packet[8..23] (source address) + 273a3434a2dSAnthony PERARD * Packet[24..39] (destination address) + 274a3434a2dSAnthony PERARD * Packet[40..41] (source port) + 275a3434a2dSAnthony PERARD * Packet[42..43] (destination port) 276a3434a2dSAnthony PERARD * 277a3434a2dSAnthony PERARD * Result = Hash(Buffer, 36) 278a3434a2dSAnthony PERARD */ 279a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP 3 280a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP \ 281a3434a2dSAnthony PERARD (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP) 282a3434a2dSAnthony PERARD 283a3434a2dSAnthony PERARD /* 284a3434a2dSAnthony PERARD * Hash algorithms 285a3434a2dSAnthony PERARD * =============== 286a3434a2dSAnthony PERARD */ 287a3434a2dSAnthony PERARD 288a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_ALGORITHM_NONE 0 289a3434a2dSAnthony PERARD 290a3434a2dSAnthony PERARD /* 291a3434a2dSAnthony PERARD * Toeplitz hash: 292a3434a2dSAnthony PERARD */ 293a3434a2dSAnthony PERARD 294a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_ALGORITHM_TOEPLITZ 1 295a3434a2dSAnthony PERARD 296a3434a2dSAnthony PERARD /* 297*50c88402SJoao Martins * This algorithm uses a 'key' as well as the data buffer itself. 298*50c88402SJoao Martins * (Buffer[] and Key[] are treated as shift-registers where the MSB of 299*50c88402SJoao Martins * Buffer/Key[0] is considered 'left-most' and the LSB of Buffer/Key[N-1] 300*50c88402SJoao Martins * is the 'right-most'). 301*50c88402SJoao Martins * 302*50c88402SJoao Martins * Value = 0 303*50c88402SJoao Martins * For number of bits in Buffer[] 304*50c88402SJoao Martins * If (left-most bit of Buffer[] is 1) 305*50c88402SJoao Martins * Value ^= left-most 32 bits of Key[] 306*50c88402SJoao Martins * Key[] << 1 307*50c88402SJoao Martins * Buffer[] << 1 308*50c88402SJoao Martins * 309*50c88402SJoao Martins * The code below is provided for convenience where an operating system 310*50c88402SJoao Martins * does not already provide an implementation. 311*50c88402SJoao Martins */ 312*50c88402SJoao Martins #ifdef XEN_NETIF_DEFINE_TOEPLITZ 313*50c88402SJoao Martins static uint32_t xen_netif_toeplitz_hash(const uint8_t *key, 314*50c88402SJoao Martins unsigned int keylen, 315*50c88402SJoao Martins const uint8_t *buf, 316*50c88402SJoao Martins unsigned int buflen) 317*50c88402SJoao Martins { 318*50c88402SJoao Martins unsigned int keyi, bufi; 319*50c88402SJoao Martins uint64_t prefix = 0; 320*50c88402SJoao Martins uint64_t hash = 0; 321*50c88402SJoao Martins 322*50c88402SJoao Martins /* Pre-load prefix with the first 8 bytes of the key */ 323*50c88402SJoao Martins for (keyi = 0; keyi < 8; keyi++) { 324*50c88402SJoao Martins prefix <<= 8; 325*50c88402SJoao Martins prefix |= (keyi < keylen) ? key[keyi] : 0; 326*50c88402SJoao Martins } 327*50c88402SJoao Martins 328*50c88402SJoao Martins for (bufi = 0; bufi < buflen; bufi++) { 329*50c88402SJoao Martins uint8_t byte = buf[bufi]; 330*50c88402SJoao Martins unsigned int bit; 331*50c88402SJoao Martins 332*50c88402SJoao Martins for (bit = 0; bit < 8; bit++) { 333*50c88402SJoao Martins if (byte & 0x80) 334*50c88402SJoao Martins hash ^= prefix; 335*50c88402SJoao Martins prefix <<= 1; 336*50c88402SJoao Martins byte <<=1; 337*50c88402SJoao Martins } 338*50c88402SJoao Martins 339*50c88402SJoao Martins /* 340*50c88402SJoao Martins * 'prefix' has now been left-shifted by 8, so 341*50c88402SJoao Martins * OR in the next byte. 342*50c88402SJoao Martins */ 343*50c88402SJoao Martins prefix |= (keyi < keylen) ? key[keyi] : 0; 344*50c88402SJoao Martins keyi++; 345*50c88402SJoao Martins } 346*50c88402SJoao Martins 347*50c88402SJoao Martins /* The valid part of the hash is in the upper 32 bits. */ 348*50c88402SJoao Martins return hash >> 32; 349*50c88402SJoao Martins } 350*50c88402SJoao Martins #endif /* XEN_NETIF_DEFINE_TOEPLITZ */ 351*50c88402SJoao Martins 352*50c88402SJoao Martins /* 353a3434a2dSAnthony PERARD * Control requests (struct xen_netif_ctrl_request) 354a3434a2dSAnthony PERARD * ================================================ 355a3434a2dSAnthony PERARD * 356a3434a2dSAnthony PERARD * All requests have the following format: 357a3434a2dSAnthony PERARD * 358a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 359a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 360a3434a2dSAnthony PERARD * | id | type | data[0] | 361a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 362a3434a2dSAnthony PERARD * | data[1] | data[2] | 363a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----------------------+ 364a3434a2dSAnthony PERARD * 365a3434a2dSAnthony PERARD * id: the request identifier, echoed in response. 366a3434a2dSAnthony PERARD * type: the type of request (see below) 367a3434a2dSAnthony PERARD * data[]: any data associated with the request (determined by type) 368a3434a2dSAnthony PERARD */ 369a3434a2dSAnthony PERARD 370a3434a2dSAnthony PERARD struct xen_netif_ctrl_request { 371a3434a2dSAnthony PERARD uint16_t id; 372a3434a2dSAnthony PERARD uint16_t type; 373a3434a2dSAnthony PERARD 374a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_INVALID 0 375a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS 1 376a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS 2 377a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_KEY 3 378a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 4 379a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 5 380a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 6 381a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 7 382a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE 8 383a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING 9 384a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING 10 385a3434a2dSAnthony PERARD 386a3434a2dSAnthony PERARD uint32_t data[3]; 387a3434a2dSAnthony PERARD }; 388a3434a2dSAnthony PERARD 389a3434a2dSAnthony PERARD /* 390a3434a2dSAnthony PERARD * Control responses (struct xen_netif_ctrl_response) 391a3434a2dSAnthony PERARD * ================================================== 392a3434a2dSAnthony PERARD * 393a3434a2dSAnthony PERARD * All responses have the following format: 394a3434a2dSAnthony PERARD * 395a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 396a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 397a3434a2dSAnthony PERARD * | id | type | status | 398a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 399a3434a2dSAnthony PERARD * | data | 400a3434a2dSAnthony PERARD * +-----+-----+-----+-----+ 401a3434a2dSAnthony PERARD * 402a3434a2dSAnthony PERARD * id: the corresponding request identifier 403a3434a2dSAnthony PERARD * type: the type of the corresponding request 404a3434a2dSAnthony PERARD * status: the status of request processing 405a3434a2dSAnthony PERARD * data: any data associated with the response (determined by type and 406a3434a2dSAnthony PERARD * status) 407a3434a2dSAnthony PERARD */ 408a3434a2dSAnthony PERARD 409a3434a2dSAnthony PERARD struct xen_netif_ctrl_response { 410a3434a2dSAnthony PERARD uint16_t id; 411a3434a2dSAnthony PERARD uint16_t type; 412a3434a2dSAnthony PERARD uint32_t status; 413a3434a2dSAnthony PERARD 414a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_SUCCESS 0 415a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED 1 416a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER 2 417a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW 3 418a3434a2dSAnthony PERARD 419a3434a2dSAnthony PERARD uint32_t data; 420a3434a2dSAnthony PERARD }; 421a3434a2dSAnthony PERARD 422a3434a2dSAnthony PERARD /* 423a3434a2dSAnthony PERARD * Static Grants (struct xen_netif_gref) 424a3434a2dSAnthony PERARD * ===================================== 425a3434a2dSAnthony PERARD * 426a3434a2dSAnthony PERARD * A frontend may provide a fixed set of grant references to be mapped on 427a3434a2dSAnthony PERARD * the backend. The message of type XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING 428a3434a2dSAnthony PERARD * prior its usage in the command ring allows for creation of these mappings. 429a3434a2dSAnthony PERARD * The backend will maintain a fixed amount of these mappings. 430a3434a2dSAnthony PERARD * 431a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE lets a frontend query how many 432a3434a2dSAnthony PERARD * of these mappings can be kept. 433a3434a2dSAnthony PERARD * 434a3434a2dSAnthony PERARD * Each entry in the XEN_NETIF_CTRL_TYPE_{ADD,DEL}_GREF_MAPPING input table has 435a3434a2dSAnthony PERARD * the following format: 436a3434a2dSAnthony PERARD * 437a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 438a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 439a3434a2dSAnthony PERARD * | grant ref | flags | status | 440a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 441a3434a2dSAnthony PERARD * 442a3434a2dSAnthony PERARD * grant ref: grant reference (IN) 443a3434a2dSAnthony PERARD * flags: flags describing the control operation (IN) 444a3434a2dSAnthony PERARD * status: XEN_NETIF_CTRL_STATUS_* (OUT) 445a3434a2dSAnthony PERARD * 446a3434a2dSAnthony PERARD * 'status' is an output parameter which does not require to be set to zero 447a3434a2dSAnthony PERARD * prior to its usage in the corresponding control messages. 448a3434a2dSAnthony PERARD */ 449a3434a2dSAnthony PERARD 450a3434a2dSAnthony PERARD struct xen_netif_gref { 451a3434a2dSAnthony PERARD grant_ref_t ref; 452a3434a2dSAnthony PERARD uint16_t flags; 453a3434a2dSAnthony PERARD 454a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRLF_GREF_readonly 0 455a3434a2dSAnthony PERARD #define XEN_NETIF_CTRLF_GREF_readonly (1U<<_XEN_NETIF_CTRLF_GREF_readonly) 456a3434a2dSAnthony PERARD 457a3434a2dSAnthony PERARD uint16_t status; 458a3434a2dSAnthony PERARD }; 459a3434a2dSAnthony PERARD 460a3434a2dSAnthony PERARD /* 461a3434a2dSAnthony PERARD * Control messages 462a3434a2dSAnthony PERARD * ================ 463a3434a2dSAnthony PERARD * 464a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 465a3434a2dSAnthony PERARD * -------------------------------------- 466a3434a2dSAnthony PERARD * 467a3434a2dSAnthony PERARD * This is sent by the frontend to set the desired hash algorithm. 468a3434a2dSAnthony PERARD * 469a3434a2dSAnthony PERARD * Request: 470a3434a2dSAnthony PERARD * 471a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM 472a3434a2dSAnthony PERARD * data[0] = a XEN_NETIF_CTRL_HASH_ALGORITHM_* value 473a3434a2dSAnthony PERARD * data[1] = 0 474a3434a2dSAnthony PERARD * data[2] = 0 475a3434a2dSAnthony PERARD * 476a3434a2dSAnthony PERARD * Response: 477a3434a2dSAnthony PERARD * 478a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 479a3434a2dSAnthony PERARD * supported 480a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - The algorithm is not 481a3434a2dSAnthony PERARD * supported 482a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 483a3434a2dSAnthony PERARD * 484a3434a2dSAnthony PERARD * NOTE: Setting data[0] to XEN_NETIF_CTRL_HASH_ALGORITHM_NONE disables 485a3434a2dSAnthony PERARD * hashing and the backend is free to choose how it steers packets 486a3434a2dSAnthony PERARD * to queues (which is the default behaviour). 487a3434a2dSAnthony PERARD * 488a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS 489a3434a2dSAnthony PERARD * ---------------------------------- 490a3434a2dSAnthony PERARD * 491a3434a2dSAnthony PERARD * This is sent by the frontend to query the types of hash supported by 492a3434a2dSAnthony PERARD * the backend. 493a3434a2dSAnthony PERARD * 494a3434a2dSAnthony PERARD * Request: 495a3434a2dSAnthony PERARD * 496a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS 497a3434a2dSAnthony PERARD * data[0] = 0 498a3434a2dSAnthony PERARD * data[1] = 0 499a3434a2dSAnthony PERARD * data[2] = 0 500a3434a2dSAnthony PERARD * 501a3434a2dSAnthony PERARD * Response: 502a3434a2dSAnthony PERARD * 503a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not supported 504a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 505a3434a2dSAnthony PERARD * data = supported hash types (if operation was successful) 506a3434a2dSAnthony PERARD * 507a3434a2dSAnthony PERARD * NOTE: A valid hash algorithm must be selected before this operation can 508a3434a2dSAnthony PERARD * succeed. 509a3434a2dSAnthony PERARD * 510a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS 511a3434a2dSAnthony PERARD * ---------------------------------- 512a3434a2dSAnthony PERARD * 513a3434a2dSAnthony PERARD * This is sent by the frontend to set the types of hash that the backend 514a3434a2dSAnthony PERARD * should calculate. (See above for hash type definitions). 515a3434a2dSAnthony PERARD * Note that the 'maximal' type of hash should always be chosen. For 516a3434a2dSAnthony PERARD * example, if the frontend sets both IPV4 and IPV4_TCP hash types then 517a3434a2dSAnthony PERARD * the latter hash type should be calculated for any TCP packet and the 518a3434a2dSAnthony PERARD * former only calculated for non-TCP packets. 519a3434a2dSAnthony PERARD * 520a3434a2dSAnthony PERARD * Request: 521a3434a2dSAnthony PERARD * 522a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS 523a3434a2dSAnthony PERARD * data[0] = bitwise OR of XEN_NETIF_CTRL_HASH_TYPE_* values 524a3434a2dSAnthony PERARD * data[1] = 0 525a3434a2dSAnthony PERARD * data[2] = 0 526a3434a2dSAnthony PERARD * 527a3434a2dSAnthony PERARD * Response: 528a3434a2dSAnthony PERARD * 529a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 530a3434a2dSAnthony PERARD * supported 531a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - One or more flag 532a3434a2dSAnthony PERARD * value is invalid or 533a3434a2dSAnthony PERARD * unsupported 534a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 535a3434a2dSAnthony PERARD * data = 0 536a3434a2dSAnthony PERARD * 537a3434a2dSAnthony PERARD * NOTE: A valid hash algorithm must be selected before this operation can 538a3434a2dSAnthony PERARD * succeed. 539a3434a2dSAnthony PERARD * Also, setting data[0] to zero disables hashing and the backend 540a3434a2dSAnthony PERARD * is free to choose how it steers packets to queues. 541a3434a2dSAnthony PERARD * 542a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_SET_HASH_KEY 543a3434a2dSAnthony PERARD * -------------------------------- 544a3434a2dSAnthony PERARD * 545a3434a2dSAnthony PERARD * This is sent by the frontend to set the key of the hash if the algorithm 546a3434a2dSAnthony PERARD * requires it. (See hash algorithms above). 547a3434a2dSAnthony PERARD * 548a3434a2dSAnthony PERARD * Request: 549a3434a2dSAnthony PERARD * 550a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_SET_HASH_KEY 551a3434a2dSAnthony PERARD * data[0] = grant reference of page containing the key (assumed to 552a3434a2dSAnthony PERARD * start at beginning of grant) 553a3434a2dSAnthony PERARD * data[1] = size of key in octets 554a3434a2dSAnthony PERARD * data[2] = 0 555a3434a2dSAnthony PERARD * 556a3434a2dSAnthony PERARD * Response: 557a3434a2dSAnthony PERARD * 558a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 559a3434a2dSAnthony PERARD * supported 560a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Key size is invalid 561a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW - Key size is larger 562a3434a2dSAnthony PERARD * than the backend 563a3434a2dSAnthony PERARD * supports 564a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 565a3434a2dSAnthony PERARD * data = 0 566a3434a2dSAnthony PERARD * 567a3434a2dSAnthony PERARD * NOTE: Any key octets not specified are assumed to be zero (the key 568a3434a2dSAnthony PERARD * is assumed to be empty by default) and specifying a new key 569a3434a2dSAnthony PERARD * invalidates any previous key, hence specifying a key size of 570a3434a2dSAnthony PERARD * zero will clear the key (which ensures that the calculated hash 571a3434a2dSAnthony PERARD * will always be zero). 572a3434a2dSAnthony PERARD * The maximum size of key is algorithm and backend specific, but 573a3434a2dSAnthony PERARD * is also limited by the single grant reference. 574a3434a2dSAnthony PERARD * The grant reference may be read-only and must remain valid until 575a3434a2dSAnthony PERARD * the response has been processed. 576a3434a2dSAnthony PERARD * 577a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 578a3434a2dSAnthony PERARD * ----------------------------------------- 579a3434a2dSAnthony PERARD * 580a3434a2dSAnthony PERARD * This is sent by the frontend to query the maximum size of mapping 581a3434a2dSAnthony PERARD * table supported by the backend. The size is specified in terms of 582a3434a2dSAnthony PERARD * table entries. 583a3434a2dSAnthony PERARD * 584a3434a2dSAnthony PERARD * Request: 585a3434a2dSAnthony PERARD * 586a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 587a3434a2dSAnthony PERARD * data[0] = 0 588a3434a2dSAnthony PERARD * data[1] = 0 589a3434a2dSAnthony PERARD * data[2] = 0 590a3434a2dSAnthony PERARD * 591a3434a2dSAnthony PERARD * Response: 592a3434a2dSAnthony PERARD * 593a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not supported 594a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 595a3434a2dSAnthony PERARD * data = maximum number of entries allowed in the mapping table 596a3434a2dSAnthony PERARD * (if operation was successful) or zero if a mapping table is 597a3434a2dSAnthony PERARD * not supported (i.e. hash mapping is done only by modular 598a3434a2dSAnthony PERARD * arithmetic). 599a3434a2dSAnthony PERARD * 600a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 601a3434a2dSAnthony PERARD * ------------------------------------- 602a3434a2dSAnthony PERARD * 603a3434a2dSAnthony PERARD * This is sent by the frontend to set the actual size of the mapping 604a3434a2dSAnthony PERARD * table to be used by the backend. The size is specified in terms of 605a3434a2dSAnthony PERARD * table entries. 606a3434a2dSAnthony PERARD * Any previous table is invalidated by this message and any new table 607a3434a2dSAnthony PERARD * is assumed to be zero filled. 608a3434a2dSAnthony PERARD * 609a3434a2dSAnthony PERARD * Request: 610a3434a2dSAnthony PERARD * 611a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 612a3434a2dSAnthony PERARD * data[0] = number of entries in mapping table 613a3434a2dSAnthony PERARD * data[1] = 0 614a3434a2dSAnthony PERARD * data[2] = 0 615a3434a2dSAnthony PERARD * 616a3434a2dSAnthony PERARD * Response: 617a3434a2dSAnthony PERARD * 618a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 619a3434a2dSAnthony PERARD * supported 620a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Table size is invalid 621a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 622a3434a2dSAnthony PERARD * data = 0 623a3434a2dSAnthony PERARD * 624a3434a2dSAnthony PERARD * NOTE: Setting data[0] to 0 means that hash mapping should be done 625a3434a2dSAnthony PERARD * using modular arithmetic. 626a3434a2dSAnthony PERARD * 627a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 628a3434a2dSAnthony PERARD * ------------------------------------ 629a3434a2dSAnthony PERARD * 630a3434a2dSAnthony PERARD * This is sent by the frontend to set the content of the table mapping 631a3434a2dSAnthony PERARD * hash value to queue number. The backend should calculate the hash from 632a3434a2dSAnthony PERARD * the packet header, use it as an index into the table (modulo the size 633a3434a2dSAnthony PERARD * of the table) and then steer the packet to the queue number found at 634a3434a2dSAnthony PERARD * that index. 635a3434a2dSAnthony PERARD * 636a3434a2dSAnthony PERARD * Request: 637a3434a2dSAnthony PERARD * 638a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING 639a3434a2dSAnthony PERARD * data[0] = grant reference of page containing the mapping (sub-)table 640a3434a2dSAnthony PERARD * (assumed to start at beginning of grant) 641a3434a2dSAnthony PERARD * data[1] = size of (sub-)table in entries 642a3434a2dSAnthony PERARD * data[2] = offset, in entries, of sub-table within overall table 643a3434a2dSAnthony PERARD * 644a3434a2dSAnthony PERARD * Response: 645a3434a2dSAnthony PERARD * 646a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 647a3434a2dSAnthony PERARD * supported 648a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Table size or content 649a3434a2dSAnthony PERARD * is invalid 650a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW - Table size is larger 651a3434a2dSAnthony PERARD * than the backend 652a3434a2dSAnthony PERARD * supports 653a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 654a3434a2dSAnthony PERARD * data = 0 655a3434a2dSAnthony PERARD * 656a3434a2dSAnthony PERARD * NOTE: The overall table has the following format: 657a3434a2dSAnthony PERARD * 658a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 659a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 660a3434a2dSAnthony PERARD * | mapping[0] | mapping[1] | 661a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 662a3434a2dSAnthony PERARD * | . | 663a3434a2dSAnthony PERARD * | . | 664a3434a2dSAnthony PERARD * | . | 665a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 666a3434a2dSAnthony PERARD * | mapping[N-2] | mapping[N-1] | 667a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 668a3434a2dSAnthony PERARD * 669a3434a2dSAnthony PERARD * where N is specified by a XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 670a3434a2dSAnthony PERARD * message and each mapping must specifies a queue between 0 and 671a3434a2dSAnthony PERARD * "multi-queue-num-queues" (see above). 672a3434a2dSAnthony PERARD * The backend may support a mapping table larger than can be 673a3434a2dSAnthony PERARD * mapped by a single grant reference. Thus sub-tables within a 674a3434a2dSAnthony PERARD * larger table can be individually set by sending multiple messages 675a3434a2dSAnthony PERARD * with differing offset values. Specifying a new sub-table does not 676a3434a2dSAnthony PERARD * invalidate any table data outside that range. 677a3434a2dSAnthony PERARD * The grant reference may be read-only and must remain valid until 678a3434a2dSAnthony PERARD * the response has been processed. 679a3434a2dSAnthony PERARD * 680a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE 681a3434a2dSAnthony PERARD * ----------------------------------------- 682a3434a2dSAnthony PERARD * 683a3434a2dSAnthony PERARD * This is sent by the frontend to fetch the number of grefs that can be kept 684a3434a2dSAnthony PERARD * mapped in the backend. 685a3434a2dSAnthony PERARD * 686a3434a2dSAnthony PERARD * Request: 687a3434a2dSAnthony PERARD * 688a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE 689a3434a2dSAnthony PERARD * data[0] = queue index (assumed 0 for single queue) 690a3434a2dSAnthony PERARD * data[1] = 0 691a3434a2dSAnthony PERARD * data[2] = 0 692a3434a2dSAnthony PERARD * 693a3434a2dSAnthony PERARD * Response: 694a3434a2dSAnthony PERARD * 695a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 696a3434a2dSAnthony PERARD * supported 697a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - The queue index is 698a3434a2dSAnthony PERARD * out of range 699a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 700a3434a2dSAnthony PERARD * data = maximum number of entries allowed in the gref mapping table 701a3434a2dSAnthony PERARD * (if operation was successful) or zero if it is not supported. 702a3434a2dSAnthony PERARD * 703a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING 704a3434a2dSAnthony PERARD * ------------------------------------ 705a3434a2dSAnthony PERARD * 706a3434a2dSAnthony PERARD * This is sent by the frontend for backend to map a list of grant 707a3434a2dSAnthony PERARD * references. 708a3434a2dSAnthony PERARD * 709a3434a2dSAnthony PERARD * Request: 710a3434a2dSAnthony PERARD * 711a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING 712a3434a2dSAnthony PERARD * data[0] = queue index 713a3434a2dSAnthony PERARD * data[1] = grant reference of page containing the mapping list 714a3434a2dSAnthony PERARD * (r/w and assumed to start at beginning of page) 715a3434a2dSAnthony PERARD * data[2] = size of list in entries 716a3434a2dSAnthony PERARD * 717a3434a2dSAnthony PERARD * Response: 718a3434a2dSAnthony PERARD * 719a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 720a3434a2dSAnthony PERARD * supported 721a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Operation failed 722a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 723a3434a2dSAnthony PERARD * 724a3434a2dSAnthony PERARD * NOTE: Each entry in the input table has the format outlined 725a3434a2dSAnthony PERARD * in struct xen_netif_gref. 726a3434a2dSAnthony PERARD * Contrary to XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING, the struct 727a3434a2dSAnthony PERARD * xen_netif_gref 'status' field is not used and therefore the response 728a3434a2dSAnthony PERARD * 'status' determines the success of this operation. In case of 729a3434a2dSAnthony PERARD * failure none of grants mappings get added in the backend. 730a3434a2dSAnthony PERARD * 731a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING 732a3434a2dSAnthony PERARD * ------------------------------------ 733a3434a2dSAnthony PERARD * 734a3434a2dSAnthony PERARD * This is sent by the frontend for backend to unmap a list of grant 735a3434a2dSAnthony PERARD * references. 736a3434a2dSAnthony PERARD * 737a3434a2dSAnthony PERARD * Request: 738a3434a2dSAnthony PERARD * 739a3434a2dSAnthony PERARD * type = XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING 740a3434a2dSAnthony PERARD * data[0] = queue index 741a3434a2dSAnthony PERARD * data[1] = grant reference of page containing the mapping list 742a3434a2dSAnthony PERARD * (r/w and assumed to start at beginning of page) 743a3434a2dSAnthony PERARD * data[2] = size of list in entries 744a3434a2dSAnthony PERARD * 745a3434a2dSAnthony PERARD * Response: 746a3434a2dSAnthony PERARD * 747a3434a2dSAnthony PERARD * status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not 748a3434a2dSAnthony PERARD * supported 749a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Operation failed 750a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_SUCCESS - Operation successful 751a3434a2dSAnthony PERARD * data = number of entries that were unmapped 752a3434a2dSAnthony PERARD * 753a3434a2dSAnthony PERARD * NOTE: Each entry in the input table has the format outlined in struct 754a3434a2dSAnthony PERARD * xen_netif_gref. 755a3434a2dSAnthony PERARD * The struct xen_netif_gref 'status' field determines if the entry 756a3434a2dSAnthony PERARD * was successfully removed. 757a3434a2dSAnthony PERARD * The entries used are only the ones representing grant references that 758a3434a2dSAnthony PERARD * were previously the subject of a XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING 759a3434a2dSAnthony PERARD * operation. Any other entries will have their status set to 760a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER upon completion. 761a3434a2dSAnthony PERARD */ 762a3434a2dSAnthony PERARD 763a3434a2dSAnthony PERARD DEFINE_RING_TYPES(xen_netif_ctrl, 764a3434a2dSAnthony PERARD struct xen_netif_ctrl_request, 765a3434a2dSAnthony PERARD struct xen_netif_ctrl_response); 766a3434a2dSAnthony PERARD 767a3434a2dSAnthony PERARD /* 768a3434a2dSAnthony PERARD * Guest transmit 769a3434a2dSAnthony PERARD * ============== 770a3434a2dSAnthony PERARD * 771a3434a2dSAnthony PERARD * This is the 'wire' format for transmit (frontend -> backend) packets: 772a3434a2dSAnthony PERARD * 773a3434a2dSAnthony PERARD * Fragment 1: netif_tx_request_t - flags = NETTXF_* 774a3434a2dSAnthony PERARD * size = total packet size 775a3434a2dSAnthony PERARD * [Extra 1: netif_extra_info_t] - (only if fragment 1 flags include 776a3434a2dSAnthony PERARD * NETTXF_extra_info) 777a3434a2dSAnthony PERARD * ... 778a3434a2dSAnthony PERARD * [Extra N: netif_extra_info_t] - (only if extra N-1 flags include 779a3434a2dSAnthony PERARD * XEN_NETIF_EXTRA_MORE) 780a3434a2dSAnthony PERARD * ... 781a3434a2dSAnthony PERARD * Fragment N: netif_tx_request_t - (only if fragment N-1 flags include 782a3434a2dSAnthony PERARD * NETTXF_more_data - flags on preceding 783a3434a2dSAnthony PERARD * extras are not relevant here) 784a3434a2dSAnthony PERARD * flags = 0 785a3434a2dSAnthony PERARD * size = fragment size 786a3434a2dSAnthony PERARD * 787a3434a2dSAnthony PERARD * NOTE: 788a3434a2dSAnthony PERARD * 789a3434a2dSAnthony PERARD * This format slightly is different from that used for receive 790a3434a2dSAnthony PERARD * (backend -> frontend) packets. Specifically, in a multi-fragment 791a3434a2dSAnthony PERARD * packet the actual size of fragment 1 can only be determined by 792a3434a2dSAnthony PERARD * subtracting the sizes of fragments 2..N from the total packet size. 793a3434a2dSAnthony PERARD * 794a3434a2dSAnthony PERARD * Ring slot size is 12 octets, however not all request/response 795a3434a2dSAnthony PERARD * structs use the full size. 796a3434a2dSAnthony PERARD * 797a3434a2dSAnthony PERARD * tx request data (netif_tx_request_t) 798a3434a2dSAnthony PERARD * ------------------------------------ 799a3434a2dSAnthony PERARD * 800a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 801a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 802a3434a2dSAnthony PERARD * | grant ref | offset | flags | 803a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 804a3434a2dSAnthony PERARD * | id | size | 805a3434a2dSAnthony PERARD * +-----+-----+-----+-----+ 806a3434a2dSAnthony PERARD * 807a3434a2dSAnthony PERARD * grant ref: Reference to buffer page. 808a3434a2dSAnthony PERARD * offset: Offset within buffer page. 809a3434a2dSAnthony PERARD * flags: NETTXF_*. 810a3434a2dSAnthony PERARD * id: request identifier, echoed in response. 811a3434a2dSAnthony PERARD * size: packet size in bytes. 812a3434a2dSAnthony PERARD * 813a3434a2dSAnthony PERARD * tx response (netif_tx_response_t) 814a3434a2dSAnthony PERARD * --------------------------------- 815a3434a2dSAnthony PERARD * 816a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 817a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 818a3434a2dSAnthony PERARD * | id | status | unused | 819a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 820a3434a2dSAnthony PERARD * | unused | 821a3434a2dSAnthony PERARD * +-----+-----+-----+-----+ 822a3434a2dSAnthony PERARD * 823a3434a2dSAnthony PERARD * id: reflects id in transmit request 824a3434a2dSAnthony PERARD * status: NETIF_RSP_* 825a3434a2dSAnthony PERARD * 826a3434a2dSAnthony PERARD * Guest receive 827a3434a2dSAnthony PERARD * ============= 828a3434a2dSAnthony PERARD * 829a3434a2dSAnthony PERARD * This is the 'wire' format for receive (backend -> frontend) packets: 830a3434a2dSAnthony PERARD * 831a3434a2dSAnthony PERARD * Fragment 1: netif_rx_request_t - flags = NETRXF_* 832a3434a2dSAnthony PERARD * size = fragment size 833a3434a2dSAnthony PERARD * [Extra 1: netif_extra_info_t] - (only if fragment 1 flags include 834a3434a2dSAnthony PERARD * NETRXF_extra_info) 835a3434a2dSAnthony PERARD * ... 836a3434a2dSAnthony PERARD * [Extra N: netif_extra_info_t] - (only if extra N-1 flags include 837a3434a2dSAnthony PERARD * XEN_NETIF_EXTRA_MORE) 838a3434a2dSAnthony PERARD * ... 839a3434a2dSAnthony PERARD * Fragment N: netif_rx_request_t - (only if fragment N-1 flags include 840a3434a2dSAnthony PERARD * NETRXF_more_data - flags on preceding 841a3434a2dSAnthony PERARD * extras are not relevant here) 842a3434a2dSAnthony PERARD * flags = 0 843a3434a2dSAnthony PERARD * size = fragment size 844a3434a2dSAnthony PERARD * 845a3434a2dSAnthony PERARD * NOTE: 846a3434a2dSAnthony PERARD * 847a3434a2dSAnthony PERARD * This format slightly is different from that used for transmit 848a3434a2dSAnthony PERARD * (frontend -> backend) packets. Specifically, in a multi-fragment 849a3434a2dSAnthony PERARD * packet the size of the packet can only be determined by summing the 850a3434a2dSAnthony PERARD * sizes of fragments 1..N. 851a3434a2dSAnthony PERARD * 852a3434a2dSAnthony PERARD * Ring slot size is 8 octets. 853a3434a2dSAnthony PERARD * 854a3434a2dSAnthony PERARD * rx request (netif_rx_request_t) 855a3434a2dSAnthony PERARD * ------------------------------- 856a3434a2dSAnthony PERARD * 857a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 858a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 859a3434a2dSAnthony PERARD * | id | pad | gref | 860a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 861a3434a2dSAnthony PERARD * 862a3434a2dSAnthony PERARD * id: request identifier, echoed in response. 863a3434a2dSAnthony PERARD * gref: reference to incoming granted frame. 864a3434a2dSAnthony PERARD * 865a3434a2dSAnthony PERARD * rx response (netif_rx_response_t) 866a3434a2dSAnthony PERARD * --------------------------------- 867a3434a2dSAnthony PERARD * 868a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 869a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 870a3434a2dSAnthony PERARD * | id | offset | flags | status | 871a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 872a3434a2dSAnthony PERARD * 873a3434a2dSAnthony PERARD * id: reflects id in receive request 874a3434a2dSAnthony PERARD * offset: offset in page of start of received packet 875a3434a2dSAnthony PERARD * flags: NETRXF_* 876a3434a2dSAnthony PERARD * status: -ve: NETIF_RSP_*; +ve: Rx'ed pkt size. 877a3434a2dSAnthony PERARD * 878a3434a2dSAnthony PERARD * NOTE: Historically, to support GSO on the frontend receive side, Linux 879a3434a2dSAnthony PERARD * netfront does not make use of the rx response id (because, as 880a3434a2dSAnthony PERARD * described below, extra info structures overlay the id field). 881a3434a2dSAnthony PERARD * Instead it assumes that responses always appear in the same ring 882a3434a2dSAnthony PERARD * slot as their corresponding request. Thus, to maintain 883a3434a2dSAnthony PERARD * compatibility, backends must make sure this is the case. 884a3434a2dSAnthony PERARD * 885a3434a2dSAnthony PERARD * Extra Info 886a3434a2dSAnthony PERARD * ========== 887a3434a2dSAnthony PERARD * 888a3434a2dSAnthony PERARD * Can be present if initial request or response has NET{T,R}XF_extra_info, 889a3434a2dSAnthony PERARD * or previous extra request has XEN_NETIF_EXTRA_MORE. 890a3434a2dSAnthony PERARD * 891a3434a2dSAnthony PERARD * The struct therefore needs to fit into either a tx or rx slot and 892a3434a2dSAnthony PERARD * is therefore limited to 8 octets. 893a3434a2dSAnthony PERARD * 894a3434a2dSAnthony PERARD * NOTE: Because extra info data overlays the usual request/response 895a3434a2dSAnthony PERARD * structures, there is no id information in the opposite direction. 896a3434a2dSAnthony PERARD * So, if an extra info overlays an rx response the frontend can 897a3434a2dSAnthony PERARD * assume that it is in the same ring slot as the request that was 898a3434a2dSAnthony PERARD * consumed to make the slot available, and the backend must ensure 899a3434a2dSAnthony PERARD * this assumption is true. 900a3434a2dSAnthony PERARD * 901a3434a2dSAnthony PERARD * extra info (netif_extra_info_t) 902a3434a2dSAnthony PERARD * ------------------------------- 903a3434a2dSAnthony PERARD * 904a3434a2dSAnthony PERARD * General format: 905a3434a2dSAnthony PERARD * 906a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 907a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 908a3434a2dSAnthony PERARD * |type |flags| type specific data | 909a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 910a3434a2dSAnthony PERARD * | padding for tx | 911a3434a2dSAnthony PERARD * +-----+-----+-----+-----+ 912a3434a2dSAnthony PERARD * 913a3434a2dSAnthony PERARD * type: XEN_NETIF_EXTRA_TYPE_* 914a3434a2dSAnthony PERARD * flags: XEN_NETIF_EXTRA_FLAG_* 915a3434a2dSAnthony PERARD * padding for tx: present only in the tx case due to 8 octet limit 916a3434a2dSAnthony PERARD * from rx case. Not shown in type specific entries 917a3434a2dSAnthony PERARD * below. 918a3434a2dSAnthony PERARD * 919a3434a2dSAnthony PERARD * XEN_NETIF_EXTRA_TYPE_GSO: 920a3434a2dSAnthony PERARD * 921a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 922a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 923a3434a2dSAnthony PERARD * |type |flags| size |type | pad | features | 924a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 925a3434a2dSAnthony PERARD * 926a3434a2dSAnthony PERARD * type: Must be XEN_NETIF_EXTRA_TYPE_GSO 927a3434a2dSAnthony PERARD * flags: XEN_NETIF_EXTRA_FLAG_* 928a3434a2dSAnthony PERARD * size: Maximum payload size of each segment. For example, 929a3434a2dSAnthony PERARD * for TCP this is just the path MSS. 930a3434a2dSAnthony PERARD * type: XEN_NETIF_GSO_TYPE_*: This determines the protocol of 931a3434a2dSAnthony PERARD * the packet and any extra features required to segment the 932a3434a2dSAnthony PERARD * packet properly. 933a3434a2dSAnthony PERARD * features: EN_NETIF_GSO_FEAT_*: This specifies any extra GSO 934a3434a2dSAnthony PERARD * features required to process this packet, such as ECN 935a3434a2dSAnthony PERARD * support for TCPv4. 936a3434a2dSAnthony PERARD * 937a3434a2dSAnthony PERARD * XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}: 938a3434a2dSAnthony PERARD * 939a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 940a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 941a3434a2dSAnthony PERARD * |type |flags| addr | 942a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 943a3434a2dSAnthony PERARD * 944a3434a2dSAnthony PERARD * type: Must be XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} 945a3434a2dSAnthony PERARD * flags: XEN_NETIF_EXTRA_FLAG_* 946a3434a2dSAnthony PERARD * addr: address to add/remove 947a3434a2dSAnthony PERARD * 948a3434a2dSAnthony PERARD * XEN_NETIF_EXTRA_TYPE_HASH: 949a3434a2dSAnthony PERARD * 950a3434a2dSAnthony PERARD * A backend that supports teoplitz hashing is assumed to accept 951a3434a2dSAnthony PERARD * this type of extra info in transmit packets. 952a3434a2dSAnthony PERARD * A frontend that enables hashing is assumed to accept 953a3434a2dSAnthony PERARD * this type of extra info in receive packets. 954a3434a2dSAnthony PERARD * 955a3434a2dSAnthony PERARD * 0 1 2 3 4 5 6 7 octet 956a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 957a3434a2dSAnthony PERARD * |type |flags|htype| alg |LSB ---- value ---- MSB| 958a3434a2dSAnthony PERARD * +-----+-----+-----+-----+-----+-----+-----+-----+ 959a3434a2dSAnthony PERARD * 960a3434a2dSAnthony PERARD * type: Must be XEN_NETIF_EXTRA_TYPE_HASH 961a3434a2dSAnthony PERARD * flags: XEN_NETIF_EXTRA_FLAG_* 962a3434a2dSAnthony PERARD * htype: Hash type (one of _XEN_NETIF_CTRL_HASH_TYPE_* - see above) 963a3434a2dSAnthony PERARD * alg: The algorithm used to calculate the hash (one of 964a3434a2dSAnthony PERARD * XEN_NETIF_CTRL_HASH_TYPE_ALGORITHM_* - see above) 965a3434a2dSAnthony PERARD * value: Hash value 966a3434a2dSAnthony PERARD */ 967a3434a2dSAnthony PERARD 968a3434a2dSAnthony PERARD /* Protocol checksum field is blank in the packet (hardware offload)? */ 969a3434a2dSAnthony PERARD #define _NETTXF_csum_blank (0) 970a3434a2dSAnthony PERARD #define NETTXF_csum_blank (1U<<_NETTXF_csum_blank) 971a3434a2dSAnthony PERARD 972a3434a2dSAnthony PERARD /* Packet data has been validated against protocol checksum. */ 973a3434a2dSAnthony PERARD #define _NETTXF_data_validated (1) 974a3434a2dSAnthony PERARD #define NETTXF_data_validated (1U<<_NETTXF_data_validated) 975a3434a2dSAnthony PERARD 976a3434a2dSAnthony PERARD /* Packet continues in the next request descriptor. */ 977a3434a2dSAnthony PERARD #define _NETTXF_more_data (2) 978a3434a2dSAnthony PERARD #define NETTXF_more_data (1U<<_NETTXF_more_data) 979a3434a2dSAnthony PERARD 980a3434a2dSAnthony PERARD /* Packet to be followed by extra descriptor(s). */ 981a3434a2dSAnthony PERARD #define _NETTXF_extra_info (3) 982a3434a2dSAnthony PERARD #define NETTXF_extra_info (1U<<_NETTXF_extra_info) 983a3434a2dSAnthony PERARD 984a3434a2dSAnthony PERARD #define XEN_NETIF_MAX_TX_SIZE 0xFFFF 985a3434a2dSAnthony PERARD struct netif_tx_request { 986a3434a2dSAnthony PERARD grant_ref_t gref; 987a3434a2dSAnthony PERARD uint16_t offset; 988a3434a2dSAnthony PERARD uint16_t flags; 989a3434a2dSAnthony PERARD uint16_t id; 990a3434a2dSAnthony PERARD uint16_t size; 991a3434a2dSAnthony PERARD }; 992a3434a2dSAnthony PERARD typedef struct netif_tx_request netif_tx_request_t; 993a3434a2dSAnthony PERARD 994a3434a2dSAnthony PERARD /* Types of netif_extra_info descriptors. */ 995a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */ 996a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */ 997a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2) /* u.mcast */ 998a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3) /* u.mcast */ 999a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_HASH (4) /* u.hash */ 1000a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_MAX (5) 1001a3434a2dSAnthony PERARD 1002a3434a2dSAnthony PERARD /* netif_extra_info_t flags. */ 1003a3434a2dSAnthony PERARD #define _XEN_NETIF_EXTRA_FLAG_MORE (0) 1004a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE) 1005a3434a2dSAnthony PERARD 1006a3434a2dSAnthony PERARD /* GSO types */ 1007a3434a2dSAnthony PERARD #define XEN_NETIF_GSO_TYPE_NONE (0) 1008a3434a2dSAnthony PERARD #define XEN_NETIF_GSO_TYPE_TCPV4 (1) 1009a3434a2dSAnthony PERARD #define XEN_NETIF_GSO_TYPE_TCPV6 (2) 1010a3434a2dSAnthony PERARD 1011a3434a2dSAnthony PERARD /* 1012a3434a2dSAnthony PERARD * This structure needs to fit within both netif_tx_request_t and 1013a3434a2dSAnthony PERARD * netif_rx_response_t for compatibility. 1014a3434a2dSAnthony PERARD */ 1015a3434a2dSAnthony PERARD struct netif_extra_info { 1016a3434a2dSAnthony PERARD uint8_t type; 1017a3434a2dSAnthony PERARD uint8_t flags; 1018a3434a2dSAnthony PERARD union { 1019a3434a2dSAnthony PERARD struct { 1020a3434a2dSAnthony PERARD uint16_t size; 1021a3434a2dSAnthony PERARD uint8_t type; 1022a3434a2dSAnthony PERARD uint8_t pad; 1023a3434a2dSAnthony PERARD uint16_t features; 1024a3434a2dSAnthony PERARD } gso; 1025a3434a2dSAnthony PERARD struct { 1026a3434a2dSAnthony PERARD uint8_t addr[6]; 1027a3434a2dSAnthony PERARD } mcast; 1028a3434a2dSAnthony PERARD struct { 1029a3434a2dSAnthony PERARD uint8_t type; 1030a3434a2dSAnthony PERARD uint8_t algorithm; 1031a3434a2dSAnthony PERARD uint8_t value[4]; 1032a3434a2dSAnthony PERARD } hash; 1033a3434a2dSAnthony PERARD uint16_t pad[3]; 1034a3434a2dSAnthony PERARD } u; 1035a3434a2dSAnthony PERARD }; 1036a3434a2dSAnthony PERARD typedef struct netif_extra_info netif_extra_info_t; 1037a3434a2dSAnthony PERARD 1038a3434a2dSAnthony PERARD struct netif_tx_response { 1039a3434a2dSAnthony PERARD uint16_t id; 1040a3434a2dSAnthony PERARD int16_t status; 1041a3434a2dSAnthony PERARD }; 1042a3434a2dSAnthony PERARD typedef struct netif_tx_response netif_tx_response_t; 1043a3434a2dSAnthony PERARD 1044a3434a2dSAnthony PERARD struct netif_rx_request { 1045a3434a2dSAnthony PERARD uint16_t id; /* Echoed in response message. */ 1046a3434a2dSAnthony PERARD uint16_t pad; 1047a3434a2dSAnthony PERARD grant_ref_t gref; 1048a3434a2dSAnthony PERARD }; 1049a3434a2dSAnthony PERARD typedef struct netif_rx_request netif_rx_request_t; 1050a3434a2dSAnthony PERARD 1051a3434a2dSAnthony PERARD /* Packet data has been validated against protocol checksum. */ 1052a3434a2dSAnthony PERARD #define _NETRXF_data_validated (0) 1053a3434a2dSAnthony PERARD #define NETRXF_data_validated (1U<<_NETRXF_data_validated) 1054a3434a2dSAnthony PERARD 1055a3434a2dSAnthony PERARD /* Protocol checksum field is blank in the packet (hardware offload)? */ 1056a3434a2dSAnthony PERARD #define _NETRXF_csum_blank (1) 1057a3434a2dSAnthony PERARD #define NETRXF_csum_blank (1U<<_NETRXF_csum_blank) 1058a3434a2dSAnthony PERARD 1059a3434a2dSAnthony PERARD /* Packet continues in the next request descriptor. */ 1060a3434a2dSAnthony PERARD #define _NETRXF_more_data (2) 1061a3434a2dSAnthony PERARD #define NETRXF_more_data (1U<<_NETRXF_more_data) 1062a3434a2dSAnthony PERARD 1063a3434a2dSAnthony PERARD /* Packet to be followed by extra descriptor(s). */ 1064a3434a2dSAnthony PERARD #define _NETRXF_extra_info (3) 1065a3434a2dSAnthony PERARD #define NETRXF_extra_info (1U<<_NETRXF_extra_info) 1066a3434a2dSAnthony PERARD 1067a3434a2dSAnthony PERARD /* Packet has GSO prefix. Deprecated but included for compatibility */ 1068a3434a2dSAnthony PERARD #define _NETRXF_gso_prefix (4) 1069a3434a2dSAnthony PERARD #define NETRXF_gso_prefix (1U<<_NETRXF_gso_prefix) 1070a3434a2dSAnthony PERARD 1071a3434a2dSAnthony PERARD struct netif_rx_response { 1072a3434a2dSAnthony PERARD uint16_t id; 1073a3434a2dSAnthony PERARD uint16_t offset; 1074a3434a2dSAnthony PERARD uint16_t flags; 1075a3434a2dSAnthony PERARD int16_t status; 1076a3434a2dSAnthony PERARD }; 1077a3434a2dSAnthony PERARD typedef struct netif_rx_response netif_rx_response_t; 1078a3434a2dSAnthony PERARD 1079a3434a2dSAnthony PERARD /* 1080a3434a2dSAnthony PERARD * Generate netif ring structures and types. 1081a3434a2dSAnthony PERARD */ 1082a3434a2dSAnthony PERARD 1083a3434a2dSAnthony PERARD DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response); 1084a3434a2dSAnthony PERARD DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response); 1085a3434a2dSAnthony PERARD 1086a3434a2dSAnthony PERARD #define NETIF_RSP_DROPPED -2 1087a3434a2dSAnthony PERARD #define NETIF_RSP_ERROR -1 1088a3434a2dSAnthony PERARD #define NETIF_RSP_OKAY 0 1089a3434a2dSAnthony PERARD /* No response: used for auxiliary requests (e.g., netif_extra_info_t). */ 1090a3434a2dSAnthony PERARD #define NETIF_RSP_NULL 1 1091a3434a2dSAnthony PERARD 1092a3434a2dSAnthony PERARD #endif 1093*50c88402SJoao Martins 1094*50c88402SJoao Martins /* 1095*50c88402SJoao Martins * Local variables: 1096*50c88402SJoao Martins * mode: C 1097*50c88402SJoao Martins * c-file-style: "BSD" 1098*50c88402SJoao Martins * c-basic-offset: 4 1099*50c88402SJoao Martins * tab-width: 4 1100*50c88402SJoao Martins * indent-tabs-mode: nil 1101*50c88402SJoao Martins * End: 1102*50c88402SJoao Martins */ 1103