Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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