public/io/netif.h: support for toeplitz hashing
cover public/io/netif.h: support for toeplitz hashing
This series documents changes needed to support toeplitz hashing in a backend, configurable by the frontend.
Patch #1 is a clean-up patch that clarifies the guest transmit and receive side packet formats.
Patch #2 documents a new 'control ring' for passing bulk data between frontend and backend. This is needed for passing the hash mapping table and hash key. It also documents messages to allow a frontend to configure toeplitz hashing.
Patch #3 documents a new extra info segment that can be used for passing hash values along with packets on both the transmit and receive side.
PATCH 1/3 public/io/netif.h: document transmit and receive wire formats separately
Currently there is no documented wire format for guest receive-side packets but the location of the 'wire format' comment block suggests it is the same as transmit-side. This is almost true but there is a subtle difference in the use of the 'size' field for the first fragment.
For clarity this patch creates separate comment blocks for receive and transmit side packet wire formats, tries to be more clear about the distinction between 'fragments' and 'extras', and documents the subtlety concerning the size field of the first fragment.
--- xen/include/public/io/netif.h | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-)
xen/include/public/io/netif.h +26 -13
@@ -151,22 +151,22 @@*/ /* -* This is the 'wire' format for packets: -* Request 1: netif_tx_request_t -- NETTXF_* (any flags) -* [Request 2: netif_extra_info_t] (only if request 1 has -* NETTXF_extra_info) -* [Request 3: netif_extra_info_t] (only if request 2 has -* XEN_NETIF_EXTRA_MORE) -* Request 4: netif_tx_request_t -- NETTXF_more_data -* Request 5: netif_tx_request_t -- NETTXF_more_data -* ... -* Request N: netif_tx_request_t -- 0 -*/ - -/* * Guest transmit * ============== * +* This is the 'wire' format for packets: +* Fragment 1: netif_tx_request_t - flags = NETTXF_* +* size = total packet size +* [Extra 1: netif_extra_info_t] - (only if fragment 1 flags include +* NETTXF_extra_info) +* [Extra N: netif_extra_info_t] - (only if extra N-1 flags include +* XEN_NETIF_EXTRA_MORE) +* ... +* Fragment N: netif_tx_request_t - (only if fragment N-1 flags include +* NETTXF_more_data) +* flags = 0 +* size = fragment size +* * Ring slot size is 12 octets, however not all request/response * structs use the full size. *
@@ -202,6 +202,19 @@* Guest receive * ============= * +* This is the 'wire' format for packets: +* Fragment 1: netif_rx_request_t - flags = NETRXF_* +* size = fragment size +* [Extra 1: netif_extra_info_t] - (only if fragment 1 flags include +* NETRXF_extra_info) +* [Extra N: netif_extra_info_t] - (only if extra N-1 flags include +* XEN_NETIF_EXTRA_MORE) +* ... +* Fragment N: netif_rx_request_t - (only if fragment N-1 flags include +* NETRXF_more_data) +* flags = 0 +* size = fragment size +* * Ring slot size is 8 octets. * * rx request (netif_rx_request_t)
Signature · 1 line
2.1.4
PATCH 2/3 public/io/netif.h: document control ring and toeplitz hashing
In reply to Paul DurrantThis patch documents a new shared (variable message length) ring between frontend and backend that can be used to pass bulk out-of-band data, such as that required to implement toeplitz hashing in the backend that is configurable by the frontend.
The patch then goes on to document the messages passed over the control ring that can be used to configure toeplitz hashing.
--- xen/include/public/io/netif.h | 320 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+)
xen/include/public/io/netif.h +320 -0
@@ -151,6 +151,326 @@*/ /* +* Control ring: +* +* Some features, such as toeplitz hashing (detailed below), require a +* significant amount of out-of-band data to be passed from frontend to +* backend. Use of xenstore is not suitable for large quantities of data +* because of quota limitations and so a dedicated 'control ring' is used. +* The ability of the backend to use a control ring is advertised by +* setting: +* +* /local/domain/X/backend/<domid>/<vif>/feature-control-ring = "1" +* +* The frontend provides a control ring to the backend by setting: +* +* /local/domain/<domid>/device/vif/<vif>/ctrl-ring-ref = <gref> +* /local/domain/<domid>/device/vif/<vif>/event-channel-ctrl = <port> +* +* where <gref> is the grant reference of the shared page used to +* implement the control ring and <port> is an event channel to be used +* as a mailbox interrupt, before the frontend moves into the connected +* state. +* +* The layout of the shared page is as follows: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | req_cons | req_prod | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | rsp_cons | rsp_prod | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | | +* + + +* | req[1024] | +* . +* . +* | | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | | +* + + +* | rsp[1024] | +* . +* . +* | | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* This provides a 1024 byte request buffer, a 1024 response buffer and +* producer/consumer counts for both. The frontend and backend +* communicate using message structures prefaced with the following +* header: +* +* netif_ctrl_msg_hdr_t: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | type | size | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* The type is one of the NETIF_CTRL_MSG_* values defined below and the +* size field specifies how many octets of payload follow the header +* (hence size may be 0 for messages not requiring a payload). +* +* The frontend makes a request by writing a message into the req buffer +* (at req_cons modulo 1024, taking care to wrap correctly), incrementing +* req_prod by the number of octets written and then sending a mailbox +* event to the backend. +* The message length may exceed the available space in the buffer +* (which can be calculated as req_cons + NETIF_CTRL_RING_SIZE - req_prod) +* in which case, as much data should be written as is possible and +* req_prod should be incremented by the number of octets written. A +* mailbox interrupt should then be sent to the backend to start message +* processing and the frontend should not write any more message data +* into the req buffer until the backend sends a mailbox interrupt +* to the frontend. +* +* The backend receives a request (when triggered to do so by a mailbox +* event) by reading as many octets as it can (which can be calculated +* as req_prod - req_cons) from the req buffer (from offset req_cons +* modulo 1024, taking care to wrap correctly) into a private buffer and +* then incrementing req_cons with the number of octets read. +* If a complete header (8 octets) has been read then the backend can +* determine how many payload octets it should expect and whether they +* have all been read. If they have then the message can be processed. +* If they have not then a mailbox event should be sent to the frontend +* and backend processing should be suspended until the next mailbox +* event arrives). +* +* The backend sends responses to the frontend using the rsp buffer in +* much the same way that the frontend sends requests to the backend and +* frontend processes the responses in much the same way that the backend +* processes requests. +* The protocol allows for a maximum of one outstanding request at any +* point in time. Hence the frontend should not send a new request until it +* has received a complete response for a previous request. Similarly +* the backend need only provide provide buffer space for the maximum size +* of request that it is prepared to handle (see specification of request +* types below). +*/ + +#define NETIF_CTRL_RING_SIZE 1024 + +struct netif_ctrl_ring { +RING_IDX req_cons; +RING_IDX req_prod; +RING_IDX rsp_cons; +RING_IDX rsp_prod; +uint8_t req[NETIF_CTRL_RING_SIZE ]; +uint8_t rsp[NETIF_CTRL_RING_SIZE ]; +}; + +struct xen_netif_ctrl_msg_hdr { +uint16_t type; +uint16_t len; +}; + +#define NETIF_CTRL_MSG_ACK 1 +#define NETIF_CTRL_MSG_GET_TOEPLITZ_FLAGS 2 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_FLAGS 3 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_KEY 4 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_MAPPING 5 + +/* Control messages: */ + +/* +* NETIF_CTRL_MSG_ACK: +* +* This is the only valid type of message sent by the backend to the +* frontend. It carries a payload of the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | status | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | | +* + + +* | data[] | +* . +* . +* | | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* The status field is always present and the correct size of the data +* field is determined by the type of request message and the value of the +* status field. +* If the backend receives a request from a frontend that it does not +* implement then it should respond with an ack message containing no +* data and status set to NETIF_CTRL_STATUS_NOT_SUPPORTED. +*/ + +#define NETIF_CTRL_STATUS_SUCCESS 0 +#define NETIF_CTRL_STATUS_NOT_SUPPORTED 1 +#define NETIF_CTRL_STATUS_INVALID_PARAMETER 2 +#define NETIF_CTRL_STATUS_BUFFER_OVERFLOW 3 + +/* +* NETIF_CTRL_MSG_GET_TOEPLITZ_FLAGS: +* +* This is sent by the frontend to query the types of toeplitz +* hash supported by the backend. It carries no payload. +* +* A successful ack message has the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | NETIF_CTRL_STATUS_SUCCESS | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | flags | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* where flags is a bitwise OR of NETIF_CTRL_TOEPLITZ_FLAG_* values +* defined below. +* An unsuccessful ack message carries no data, only a status value. +*/ + +/* +* For the purposes of the definitions below, 'Packet[]' is an array of +* octets containing an IP packet without options, 'Array[X..Y]' means a +* sub-array of 'Array' containing bytes X thru Y inclusive, and '+' is +* used to indicate concatenation of arrays. +*/ + +/* +* A hash calculated over an IP version 4 header as follows: +* +* Buffer[0..8] = Packet[12..15] + Packet[16..19] +* Result = ToeplitzHash(Buffer, 8) +*/ +#define _NETIF_CTRL_TOEPLITZ_FLAG_IPV4 0 +#define NETIF_CTRL_TOEPLITZ_FLAG_IPV4 (1 << _NETIF_CTRL_TOEPLITZ_FLAG_IPV4) + +/* +* A hash calculated over an IP version 4 header and TCP header as +* follows: +* +* Buffer[0..12] = Packet[12..15] + Packet[16..19] + +* Packet[20..21] + Packet[22..23] +* Result = ToeplitzHash(Buffer, 12) +*/ +#define _NETIF_CTRL_TOEPLITZ_FLAG_IPV4_TCP 1 +#define NETIF_CTRL_TOEPLITZ_FLAG_IPV4_TCP (1 << _NETIF_CTRL_TOEPLITZ_FLAG_IPV4_TCP) + +/* +* A hash calculated over an IP version 6 header as follows: +* +* Buffer[0..32] = Packet[8..23] + Packet[24..39] +* Result = ToeplitzHash(Buffer, 32) +*/ +#define _NETIF_CTRL_TOEPLITZ_FLAG_IPV6 2 +#define NETIF_CTRL_TOEPLITZ_FLAG_IPV6 (1 << _NETIF_CTRL_TOEPLITZ_FLAG_IPV4) + +/* +* A hash calculated over an IP version 6 header and TCP header as +* follows: +* +* Buffer[0..36] = Packet[8..23] + Packet[24..39] + +* Packet[40..41] + Packet[42..43] +* Result = ToeplitzHash(Buffer, 36) +*/ +#define _NETIF_CTRL_TOEPLITZ_FLAG_IPV6_TCP 3 +#define NETIF_CTRL_TOEPLITZ_FLAG_IPV6_TCP (1 << _NETIF_CTRL_TOEPLITZ_FLAG_IPV4_TCP) + +/* +* NETIF_CTRL_MSG_SET_TOEPLITZ_FLAGS: +* +* This is sent by the frontend to set the types of toeplitz hash that +* the backend should calculate. Note that the 'maximal' type of hash +* should always be chosen. For example, if the frontend sets both IPV4 +* and IPV4_TCP hash types then the latter hash type should be calculated +* for any TCP packet and the former only calculated for non-TCP packets. +* The message carries a payload of the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | flags | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* where flags is a bitwise OR of NETIF_CTRL_TOEPLITZ_FLAG_* values +* defined above. +* +* NOTE: Setting flags to 0 disables toeplitz hashing and the backend +* is free to choose how it steers packets to queues (which is the +* default state). +* +* A successful or unsuccessful ack message carries no data, only a +* status value. +*/ + +/* +* NETIF_CTRL_MSG_SET_TOEPLITZ_KEY: +* +* This is sent by the frontend to set the key of toeplitz hash that +* the backend should calculate. The toeplitz algorithm is illustrated +* by the following pseudo-code: +* +* (Buffer[] and Key[] are treated as shift-registers where the MSB of +* Buffer/Key[0] is considered 'left-most' and the LSB of Buffer/Key[N-1] +* is the 'right-most'). +* +* Value = 0 +* For number of bits in Buffer[] +* If (left-most bit of Buffer[] is 1) +* Value ^= left-most 32 bits of Key[] +* Key[] << 1 +* Buffer[] << 1 +* +* Key[] is always 40 octets in length and so the message carries a +* payload of the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | | +* + + +* | | +* + + +* | key[40] | +* + + +* | | +* + + +* | | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* A successful or unsuccessful ack message carries no data, only a +* status value. +*/ + +/* +* NETIF_CTRL_MSG_SET_TOEPLITZ_MAPPING: +* +* This is sent by the frontend to set the mapping of toeplitz hash to +* queue number to be applied by the backend. +* The message carries a payload of the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | queue[0] | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | queue[1] | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | queue[2] | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | queue[3] | +* . +* . +* | queue[N-1] | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* N can be calculated from the payload length and only power-of-2 +* values are valid. +* +* NOTE: Before a specific mapping is set using this request, the backend +* should map all toeplitz hash values to queue 0 (which is the only +* queue guaranteed to exist in all cases). +* +* A successful or unsuccessful ack message carries no data, only a +* status value. If the value of N is not a power of 2 or any of the +* queue values exceeds the number of queues in operation then status +* should be set to NETIF_CTRL_STATUS_INVALID_PARAMETER. If N is larger +* than the backend's maximal size of mapping table then status should +* be set to NETIF_CTRL_STATUS_BUFFER_OVERFLOW. +*/ + +/* * Guest transmit * ============== *
Signature · 1 line
2.1.4
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
xen/include/public/io/netif.h line 259
Quoted 9 lines · Paul Durrant
xen/include/public/io/netif.h +9
-0+#define NETIF_CTRL_RING_SIZE 1024 + +struct netif_ctrl_ring { +RING_IDX req_cons; +RING_IDX req_prod; +RING_IDX rsp_cons; +RING_IDX rsp_prod; +uint8_t req[NETIF_CTRL_RING_SIZE ]; +uint8_t rsp[NETIF_CTRL_RING_SIZE ];
To avoid making the same mistake as the xenstore ring, this at the very minimum needs a defined reset protocol. It should also at least have a version number (currently expected to be zero) which is used to delineate the use of the remaining space in the page.
xen/include/public/io/netif.h line 264
Quoted 5 lines
xen/include/public/io/netif.h +5
-0+}; + +struct xen_netif_ctrl_msg_hdr { +uint16_t type; +uint16_t len;
These don't match your documentation above. uint32_t's ?
xen/include/public/io/netif.h line 271
Quoted 7 lines
xen/include/public/io/netif.h +7
-0+}; + +#define NETIF_CTRL_MSG_ACK 1 +#define NETIF_CTRL_MSG_GET_TOEPLITZ_FLAGS 2 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_FLAGS 3 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_KEY 4 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_MAPPING 5
What about 0? Again learning from the xenstore case, can we define 0 as explicitly an invalid value, so a page of zeroes doesn't appear to be a valid sequence of messages.
xen/include/public/io/netif.h line 282
Quoted 11 lines
xen/include/public/io/netif.h +11
-0+ +/* Control messages: */ + +/* +* NETIF_CTRL_MSG_ACK: +* +* This is the only valid type of message sent by the backend to the +* frontend. It carries a payload of the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+
Can I recommend that all ack packets contain the control type they are responding to. In the normal case, it indeed shouldn't be needed, but if the front and back ever get out of sync, it will make debugging far easier.
~Andrew
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 10 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]] On Behalf Of Andrew Cooper
Sent: 23 December 2015 11:45
To: Paul Durrant; [email protected]
Cc: Keir (Xen.org); Ian Campbell; Tim (Xen.org); Ian Jackson; Jan Beulich
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingOn 23/12/2015 10:06, Paul Durrant wrote:
Quoted 14 lines
xen/include/public/io/netif.h line 259
Quoted 9 lines
xen/include/public/io/netif.h +9
-0+#define NETIF_CTRL_RING_SIZE 1024 + +struct netif_ctrl_ring { +RING_IDX req_cons; +RING_IDX req_prod; +RING_IDX rsp_cons; +RING_IDX rsp_prod; +uint8_t req[NETIF_CTRL_RING_SIZE ]; +uint8_t rsp[NETIF_CTRL_RING_SIZE ];To avoid making the same mistake as the xenstore ring, this at the very minimum needs a defined reset protocol. It should also at least have a version number (currently expected to be zero) which is used to delineate the use of the remaining space in the page.
It doesn't need a reset protocol any more than the rx or tx rings do. xenstore is a special case, because you can't use xenstore to handle (re)connection (as you can in this case) ;-) Given the boolean feature flag in xenstore then I agree a version number could be useful... or the xenstore flag could be changed into a version number.
Quoted 8 lines
xen/include/public/io/netif.h line 264
Quoted 6 lines
xen/include/public/io/netif.h +5
-0+}; + +struct xen_netif_ctrl_msg_hdr { +uint16_t type; +uint16_t len;These don't match your documentation above. uint32_t's ?
Yikes, you're right. They should be uint32_ts.
Quoted 12 lines
xen/include/public/io/netif.h line 271
Quoted 8 lines
xen/include/public/io/netif.h +7
-0+}; + +#define NETIF_CTRL_MSG_ACK 1 +#define NETIF_CTRL_MSG_GET_TOEPLITZ_FLAGS 2 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_FLAGS 3 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_KEY 4 +#define NETIF_CTRL_MSG_SET_TOEPLITZ_MAPPING 5What about 0? Again learning from the xenstore case, can we define 0 as explicitly an invalid value, so a page of zeroes doesn't appear to be a valid sequence of messages.
I thought 0 being invalid was kind of obvious from the fact I started at 1, but I'll make it explicit.
Quoted 17 lines
xen/include/public/io/netif.h line 282
Quoted 12 lines
xen/include/public/io/netif.h +11
-0+ +/* Control messages: */ + +/* +* NETIF_CTRL_MSG_ACK: +* +* This is the only valid type of message sent by the backend to the +* frontend. It carries a payload of the following format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ Can I recommend that all ack packets contain the control type they are responding to. In the normal case, it indeed shouldn't be needed, but if the front and back ever get out of sync, it will make debugging far easier.
Yep, that's a good idea.
Paul
Quoted 2 lines
~Andrew
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
In reply to Paul DurrantQuoted 6 lines · Paul Durrant
This patch documents a new shared (variable message length) ring between frontend and backend that can be used to pass bulk out-of-band data, such as that required to implement toeplitz hashing in the backend that is configurable by the frontend.
The patch then goes on to document the messages passed over the control
[...]
Quoted 8 lines
ring that can be used to configure toeplitz hashing.
xen/include/public/io/netif.h +1
-0@@ -151,6 +151,326 @@*/ /* +* Control ring:
[...]
Quoted 16 lines
+ *
+ * The layout of the shared page is as follows:
+ *
+ * 0 1 2 3 4 5 6 7 octet
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |req_cons|req_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |rsp_cons|rsp_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----++ * | | + * + + + * | req[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
Quoted 7 lines
+ * | | + * + + + * | rsp[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
You should use the standard ring format and infrastructure.
David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 50 lines
-----Original Message-----
From: David Vrabel [mailto:[email protected]]
Sent: 23 December 2015 13:28
To: Paul Durrant; [email protected]
Cc: Keir (Xen.org); Ian Campbell; Tim (Xen.org); Ian Jackson; Jan Beulich
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 1 line · Paul Durrant
This patch documents a new shared (variable message length) ring
between
Quoted 5 lines
frontend and backend that can be used to pass bulk out-of-band data, such as that required to implement toeplitz hashing in the backend that is configurable by the frontend.
The patch then goes on to document the messages passed over the control
[...]
Quoted 8 lines
ring that can be used to configure toeplitz hashing.
xen/include/public/io/netif.h +1
-0@@ -151,6 +151,326 @@*/ /* +* Control ring: [...]
Quoted 16 lines
+ *
+ * The layout of the shared page is as follows:
+ *
+ * 0 1 2 3 4 5 6 7 octet
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |req_cons|req_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |rsp_cons|rsp_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----++ * | | + * + + + * | req[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----+Quoted 7 lines
+ * | | + * + + + * | rsp[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Paul
Quoted 2 lines
David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 23 lines · Paul Durrant
Quoted 23 lines
Quoted 22 lines
+ * The layout of the shared page is as follows:
+ *
+ * 0 1 2 3 4 5 6 7 octet
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |req_cons|req_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |rsp_cons|rsp_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----++ * | | + * + + + * | req[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----++ * | | + * + + + * | rsp[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
Quoted 5 lines
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Perhaps union the request/response message types with a uint8_t pad[1024] and use this as the request/response type?
You can use the standard macros like so (to avoid copying the full 1024 bytes every time):
hdr = RING_GET_REQUEST(...);
switch (READ_ONCE(hdr->type)) {
case FOO:
{
struct foo foo;
RING_COPY_REQUEST(ring, cons, &foo);
handle_foo(&foo);
}
break;
case ...:
...
}David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 32 lines
-----Original Message-----
From: David Vrabel [mailto:[email protected]]
Sent: 04 January 2016 10:56
To: Paul Durrant; David Vrabel; [email protected]
Cc: Tim (Xen.org); Keir (Xen.org); Ian Campbell; Jan Beulich; Ian Jackson
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 23 lines · Paul Durrant
Quoted 23 lines
Quoted 22 lines
+ * The layout of the shared page is as follows:
+ *
+ * 0 1 2 3 4 5 6 7 octet
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |req_cons|req_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
+ * |rsp_cons|rsp_prod|
+ * +-----+-----+-----+-----+-----+-----+-----+-----++ * | | + * + + + * | req[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----++ * | | + * + + + * | rsp[1024] |+ * .
+ * .
+ * | |
+ * +-----+-----+-----+-----+-----+-----+-----+-----+
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Perhaps union the request/response message types with a
uint8_tpad[1024] and use this as the request/response type?
The problem is that this places a 1k limit on the message size, which is not there in the scheme I'm proposing. I'd rather not bake that limit in if I don't have to.
Paul
Quoted 17 lines
You can use the standard macros like so (to avoid copying the full 1024 bytes every time):
hdr =
RING_GET_REQUEST(...);
switch (READ_ONCE(hdr->type)) {
case FOO:{ struct foo foo; RING_COPY_REQUEST(ring, cons, &foo); handle_foo(&foo); } break; case ...: ... }David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 6 lines · Paul Durrant
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Quoted 10 lines
Quoted 3 lines
Perhaps union the request/response message types with a
uint8_tpad[1024] and use this as the request/response type?The problem is that this places a 1k limit on the message size, which
is not there in the scheme I'm proposing. I'd rather not bake that limit in if I don't have to.Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ * | req[1024] |
^^^^^^^^^
Surely this limits your size to 1024 bytes?
Also if you need bigger messages you can grant those areas separately and pass a grant ref through the ring, or you can chunk the message to fit in several requests/responses.
David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 19 lines
-----Original Message-----
From: David Vrabel [mailto:[email protected]]
Sent: 04 January 2016 11:18
To: Paul Durrant; [email protected]
Cc: Tim (Xen.org); Keir (Xen.org); Ian Campbell; Jan Beulich; Ian Jackson
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 10 lines · Paul Durrant
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Perhaps union the request/response message types with a
uint8_tpad[1024] and use this as the request/response type?
Quoted 8 lines
Quoted 6 lines
The problem is that this places a 1k limit on the message size, which
is not there in the scheme I'm proposing. I'd rather not bake that limit in if I don't have to.Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ * | req[1024] |
^^^^^^^^^Surely this limits your size to 1024 bytes?
No, I've already got prototype code that can pass 4k messages. Nothing in the protocol says the whole message has to fit in the buffer. In fact I've explicitly documented how to handle partial messages.
Quoted 4 lines
Also if you need bigger messages you can grant those areas separately and pass a grant ref through the ring, or you can chunk the message to fit in several requests/responses.
Why go to that trouble to wedge a square peg into a round hole? What is the fundamental problem with what I've proposed that you want to avoid?
Paul
Quoted 2 lines
David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 24 lines · Paul Durrant
Quoted 24 lines
-----Original Message-----
From: David Vrabel [mailto:[email protected]]
Sent: 04 January 2016 11:18
To: Paul Durrant; [email protected]
Cc: Tim (Xen.org); Keir (Xen.org); Ian Campbell; Jan Beulich; Ian Jackson
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 14 lines · Paul Durrant
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Perhaps union the request/response message types with a
uint8_tpad[1024] and use this as the request/response type?The problem is that this places a 1k limit on the message size, which
is not there in the scheme I'm proposing. I'd rather not bake that limit in if I don't have to.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ * | req[1024] |
^^^^^^^^^Surely this limits your size to 1024 bytes?
No, I've already got prototype code that can pass 4k messages. Nothing in the protocol says the whole message has to fit in the buffer. In fact I've explicitly documented how to handle partial messages.
Then the standard ring infrastructure will work just fine.
Quoted 5 lines
Quoted 3 lines
Also if you need bigger messages you can grant those areas separately and pass a grant ref through the ring, or you can chunk the message to fit in several requests/responses.
Why go to that trouble to wedge a square peg into a round hole? What is the fundamental problem with what I've proposed that you want to avoid?
You've put the consumer values into the shared page. I'd rather not have to scrutinize your shared ring implementation for other security bugs. Similarly, if there's another security issues like XSA-155 I'd rather not have to look at another non-standard shared ring implementation.
IMO, it's you who should be presenting compelling reasons for /not/ using the standard infrastructure, not the other way around.
David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 47 lines
-----Original Message-----
From: David Vrabel [mailto:[email protected]]
Sent: 04 January 2016 11:29
To: Paul Durrant; [email protected]
Cc: Tim (Xen.org); Keir (Xen.org); Ian Campbell; Jan Beulich; Ian Jackson
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 24 lines · Paul Durrant
Quoted 24 lines
-----Original Message-----
From: David Vrabel [mailto:[email protected]]
Sent: 04 January 2016 11:18
To: Paul Durrant; [email protected]
Cc: Tim (Xen.org); Keir (Xen.org); Ian Campbell; Jan Beulich; Ian Jackson
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 14 lines · Paul Durrant
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
You should use the standard ring format and infrastructure.
Is there one for variable message size rings? I didn't find one. I don't want to use the fixed size balanced ring macros for control messages as fixed size messages really aren't appropriate in this case.
Perhaps union the request/response message types with a
uint8_tpad[1024] and use this as the request/response type?The problem is that this places a 1k limit on the message size, which
is not there in the scheme I'm proposing. I'd rather not bake that limit in if I don't have to.Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ * | req[1024] |
^^^^^^^^^Surely this limits your size to 1024 bytes?
No, I've already got prototype code that can pass 4k messages. Nothing in
the protocol says the whole message has to fit in the buffer. In fact I've explicitly documented how to handle partial messages.
Then the standard ring infrastructure will work just fine.
Quoted 4 lines
Quoted 3 lines
Also if you need bigger messages you can grant those areas separately and pass a grant ref through the ring, or you can chunk the message to fit in several requests/responses.
Quoted 7 lines
Quoted 1 line
Why go to that trouble to wedge a square peg into a round hole? What is
the fundamental problem with what I've proposed that you want to avoid?
You've put the consumer values into the shared page. I'd rather not have to scrutinize your shared ring implementation for other security bugs. Similarly, if there's another security issues like XSA-155 I'd rather not have to look at another non-standard shared ring implementation.
Ok. That's a good enough reason. I'll come up with a new prototype.
Quoted 4 lines
IMO, it's you who should be presenting compelling reasons for /not/ using the standard infrastructure, not the other way around.
There is no 'standard' here though. There's convention, but that's a different thing. If we're going to have a 'no more variable size message protocols' policy than that needs writing down somewhere.
Paul
Quoted 1 line
David
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 6 lines
Quoted 4 lines
You've put the consumer values into the shared page. I'd rather not have to scrutinize your shared ring implementation for other security bugs. Similarly, if there's another security issues like XSA-155 I'd rather not have to look at another non-standard shared ring implementation.
Ok. That's a good enough reason. I'll come up with a new prototype.
Could I suggest that you make this a more generic one? That is not just limited to network out of band - but other drivers could use it as well.
Quoted 16 lines
Quoted 5 lines
IMO, it's you who should be presenting compelling reasons for /not/ using the standard infrastructure, not the other way around.
There is no 'standard' here though. There's convention, but that's a different thing. If we're going to have a 'no more variable size message protocols' policy than that needs writing down somewhere.
Paul
Quoted 1 line
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/3] public/io/netif.h: document control ring and toeplitz hashing
Quoted 15 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Konrad Rzeszutek Wilk
Sent: 04 January 2016 20:19
To: Paul Durrant
Cc: Keir (Xen.org); Ian Campbell; Tim (Xen.org); David Vrabel; Jan Beulich; Ian Jackson; [email protected]
Subject: Re: [Xen-devel] [PATCH 2/3]public/io/netif.h: document control ring and toeplitz hashingQuoted 5 lines
Quoted 4 lines
You've put the consumer values into the shared page. I'd rather not have to scrutinize your shared ring implementation for other security bugs. Similarly, if there's another security issues like XSA-155 I'd rather not have to look at another non-standard shared ring implementation.
Quoted 6 lines
Quoted 1 line
Ok. That's a good enough reason. I'll come up with a new prototype.
Could I suggest that you make this a more generic one? That is not just limited to network out of band - but other drivers could use it as well.
Well, if I use the usual balanced ring macros then they are already common. The next level is the actual message format and content, which is clearly going to be specific to a particular use-case.
Paul
Quoted 24 lines
Quoted 8 lines
Quoted 6 lines
IMO, it's you who should be presenting compelling reasons for /not/ using the standard infrastructure, not the other way around.
There is no 'standard' here though. There's convention, but that's a
different thing. If we're going to have a 'no more variable size message protocols' policy than that needs writing down somewhere.
Quoted 9 lines
Paul
Quoted 1 line
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 3/3 public/io/netif.h: document new extra info for passing hash values
In reply to Paul DurrantTo properly support NDIS RSS, the Windows frontend PV driver needs the toeplitz hash value calculated by the backend (otherwise it would have to duplicate the calculation).
This patch adds documentation for "feature-hash" and a definition of a new XEN_NETIF_EXTRA_TYPE_HASH extra info segment which both frontends and backends can use to pass hash values to the other end.
--- xen/include/public/io/netif.h | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
xen/include/public/io/netif.h +35 -1
@@ -151,6 +151,12 @@*/ /* +* "feature-hash" advertises the capability to accept extra info slots of +* type XEN_NETIF_EXTRA_TYPE_HASH. They will not be sent by either end +* unless the other end advertises this feature. +*/ + +/* * Control ring: * * Some features, such as toeplitz hashing (detailed below), require a
@@ -630,6 +636,18 @@ struct xen_netif_ctrl_msg_hdr {* type: Must be XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} * flags: XEN_NETIF_EXTRA_FLAG_* * addr: address to add/remove +* +* XEN_NETIF_EXTRA_TYPE_HASH: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags|htype| pad |LSB ---- value ---- MSB| +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* type: Must be XEN_NETIF_EXTRA_TYPE_HASH +* flags: XEN_NETIF_EXTRA_FLAG_* +* htype: XEN_NETIF_HASH_TYPE_* +* value: Hash value */ /* Protocol checksum field is blank in the packet (hardware offload)? */
@@ -663,7 +681,8 @@ typedef struct netif_tx_request netif_tx_request_t;#define XEN_NETIF_EXTRA_TYPE_GSO (1)/* u.gso */ #define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2)/* u.mcast */ #define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3)/* u.mcast */ -#define XEN_NETIF_EXTRA_TYPE_MAX (4) +#define XEN_NETIF_EXTRA_TYPE_HASH (4)/* u.hash */ +#define XEN_NETIF_EXTRA_TYPE_MAX (5)/* netif_extra_info_t flags. */ #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
@@ -675,6 +694,16 @@ typedef struct netif_tx_request netif_tx_request_t;#define XEN_NETIF_GSO_TYPE_TCPV6 (2)/* +* Hash types. (See NETIF_CTRL_TOEPLITZ_FLAG_* definitions above +* for more information). +*/ +#define XEN_NETIF_HASH_TYPE_NONE 0 +#define XEN_NETIF_HASH_TYPE_IPV4 1 +#define XEN_NETIF_HASH_TYPE_IPV4_TCP 2 +#define XEN_NETIF_HASH_TYPE_IPV6 3 +#define XEN_NETIF_HASH_TYPE_IPV6_TCP 4 + +/* * This structure needs to fit within both netif_tx_request_t and * netif_rx_response_t for compatibility. */
@@ -691,6 +720,11 @@ struct netif_extra_info {struct {uint8_t addr[6 ]; } mcast; +struct { +uint8_t type; +uint8_t pad; +uint8_t value[4 ]; + } hash;uint16_t pad[3 ]; } u; };
Signature · 1 line
2.1.4