xen-netback/core: packet hashing
Subsystems (7)
PATCH 4/8 xen-netback: accept an L4 or L3 skb hash value from the frontend
In reply to Paul DurrantThis patch adds an indication that netback is capable of handling hash values passed from the frontend (see netif.h for details), and the code necessary to process the additional xen_netif_extra_info segment and set a hash on the skb.
--- drivers/net/xen-netback/netback.c | 25 +++++++++++++++++++++++++ drivers/net/xen-netback/xenbus.c | 8 ++++++++ 2 files changed, 33 insertions(+)
drivers/net/xen-netback/netback.c +25 -0
@@ -1383,6 +1383,28 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, } } +if (extras[XEN_NETIF_EXTRA_TYPE_HASH -1 ].type) { +struct xen_netif_extra_info *extra; +u32 hash = *(u32 *)extra->u.hash.value; + + extra = &extras[XEN_NETIF_EXTRA_TYPE_HASH -1 ]; + +switch (extra->u.hash.type) { +case XEN_NETIF_HASH_TYPE_TCPV4 : +case XEN_NETIF_HASH_TYPE_TCPV6 : +skb_set_hash (skb, hash,PKT_HASH_TYPE_L4 ); +break ; + +case XEN_NETIF_HASH_TYPE_IPV4 : +case XEN_NETIF_HASH_TYPE_IPV6 : +skb_set_hash (skb, hash,PKT_HASH_TYPE_L3 ); +break ; + +default : +break ; + } + } +XENVIF_TX_CB (skb)->pending_idx = pending_idx;__skb_put (skb, data_len);
@@ -1416,6 +1438,9 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,if (extras[XEN_NETIF_EXTRA_TYPE_GSO -1 ].type) queue->pending_tx_info[pending_idx].extra_count++; +if (extras[XEN_NETIF_EXTRA_TYPE_HASH -1 ].type) + queue->pending_tx_info[pending_idx].extra_count++; + queue->pending_cons++; gop = xenvif_get_requests(queue, skb, txfrags, gop,
drivers/net/xen-netback/xenbus.c +8 -0
@@ -335,6 +335,14 @@ static int netback_probe(struct xenbus_device *dev, goto abort_transaction; } +/* We support hash values. */ + err =xenbus_printf (xbt, dev->nodename, +"feature-hash" ,"%d" ,1 ); +if (err) { + message ="writing feature-hash" ; + goto abort_transaction; + } + err =xenbus_transaction_end (xbt,0 ); }while (err == -EAGAIN );
Signature · 1 line
2.1.4
PATCH 2/8 xen-netback: remove GSO information from xenvif_rx_meta
In reply to Paul DurrantThe code in net_rx_action() that builds rx responses has direct access to the skb so there is no need to copy this information into the meta structure.
This patch removes the extraneous fields, saves space in the array and removes many lines of code.
--- drivers/net/xen-netback/common.h | 2 -- drivers/net/xen-netback/netback.c | 75 +++++++++++++++------------------------ 2 files changed, 29 insertions(+), 48 deletions(-)
drivers/net/xen-netback/common.h +0 -2
@@ -70,8 +70,6 @@ struct pending_tx_info {struct xenvif_rx_meta {int id;int size; -int gso_type; -int gso_size; };#define GSO_BIT (type) \
drivers/net/xen-netback/netback.c +29 -46
156 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 3/8 xen-netback: support multiple extra info segments passed from frontend
In reply to Paul DurrantThe code does not currently allow a frontend to pass multiple extra info segments to the backend in a tx request. A subsequent patch in this series needs this functionality so it is added here, without any other modification, for better bisectability.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/netback.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -51,6 +51,7 @@ typedef unsigned int pending_ring_idx_t;struct pending_tx_info {struct xen_netif_tx_request req;/* tx request */ +unsigned int extra_count;/* Number of extras following the request */ /* Callback data for released SKBs. The callback is always * xenvif_zerocopy_callback, desc contains the pending_idx, which is * also an index in pending_tx_info array. It is initialized in
drivers/net/xen-netback/netback.c +19 -8
@@ -95,7 +95,8 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,static void make_tx_response (struct xenvif_queue *queue,struct xen_netif_tx_request *txp, -s8 st); +s8 st, +unsigned int extra_count);static void push_tx_responses (struct xenvif_queue *queue);static inline int tx_work_todo (struct xenvif_queue *queue);
@@ -646,7 +647,7 @@ static void xenvif_tx_err(struct xenvif_queue *queue, do { spin_lock_irqsave(&queue->response_lock, flags); - make_tx_response(queue, txp, XEN_NETIF_RSP_ERROR); + make_tx_response(queue, txp, XEN_NETIF_RSP_ERROR, 0); push_tx_responses(queue); spin_unlock_irqrestore(&queue->response_lock, flags); if (cons == end)
@@ -1292,7 +1293,8 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,make_tx_response (queue, &txreq, (ret ==0 ) ?XEN_NETIF_RSP_OKAY : -XEN_NETIF_RSP_ERROR ); +XEN_NETIF_RSP_ERROR , +1 );push_tx_responses (queue);continue ; }
@@ -1303,7 +1305,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, extra = &extras[XEN_NETIF_EXTRA_TYPE_MCAST_DEL -1 ];xenvif_mcast_del (queue->vif, extra->u.mcast.addr); -make_tx_response (queue, &txreq,XEN_NETIF_RSP_OKAY ); +make_tx_response (queue, &txreq,XEN_NETIF_RSP_OKAY ,1 );push_tx_responses (queue);continue ; }
@@ -1411,6 +1413,9 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, sizeof(txreq)); } +if (extras[XEN_NETIF_EXTRA_TYPE_GSO -1 ].type) + queue->pending_tx_info[pending_idx].extra_count++; + queue->pending_cons++; gop = xenvif_get_requests(queue, skb, txfrags, gop,
@@ -1749,7 +1754,9 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,spin_lock_irqsave (&queue->response_lock, flags); -make_tx_response (queue, &pending_tx_info->req, status); +make_tx_response (queue, &pending_tx_info->req, status, + pending_tx_info->extra_count); +memset (pending_tx_info,0 ,sizeof (*pending_tx_info));/* Release the pending index before pusing the Tx response so * its available before a new Tx request is pushed by the
@@ -1766,7 +1773,8 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,static void make_tx_response (struct xenvif_queue *queue,struct xen_netif_tx_request *txp, -s8 st) +s8 st, +unsigned int extra_count) {RING_IDX i = queue->tx.rsp_prod_pvt;struct xen_netif_tx_response *resp;
@@ -1775,8 +1783,11 @@ static void make_tx_response(struct xenvif_queue *queue, resp->id = txp->id; resp->status = st; -if (txp->flags & XEN_NETTXF_extra_info) -RING_GET_RESPONSE (&queue->tx, ++i)->status =XEN_NETIF_RSP_NULL ; +WARN_ON (!(txp->flags & XEN_NETTXF_extra_info) != !extra_count); + +while (extra_count-- !=0 ) +RING_GET_RESPONSE (&queue->tx, ++i)->status = +XEN_NETIF_RSP_NULL ; queue->tx.rsp_prod_pvt = ++i; }
Signature · 1 line
2.1.4
PATCH 1/8 xen-netback: re-import canonical netif header
In reply to Paul DurrantThe canonical netif header (in the Xen source repo) and the Linux variant have diverged significantly. Recently much documentation has been added to the canonical header and new definitions and types to support packet hash configuration. Subsequent patches in this series add support for packet hash configuration in xen-netback so this patch re-imports the canonical header in readiness.
To maintain compatibility and some style consistency with the old Linux variant, the header was stripped of its emacs boilerplate, and post-processed and copied into place with the following commands:
ed -s netif.h << EOF
H
,s/NETTXF_/XEN_NETTXF_/g
,s/NETRXF_/XEN_NETRXF_/g
,s/NETIF_RSP/XEN_NETIF_RSP/g
,s/netif_tx/xen_netif_tx/g
,s/netif_rx/xen_netif_rx/g
,s/netif_extra_info/xen_netif_extra_info/g
w
EOF
indent --linux-style netif.h -o include/xen/interface/io/netif.h
---
Whilst awaiting review of my patches to the canonical netif.h, import has been done from my staging branch using:
--- include/xen/interface/io/netif.h | 475 +++++++++++++++++++++++++++++++-------- 1 file changed, 381 insertions(+), 94 deletions(-)
include/xen/interface/io/netif.h +381 -94
@@ -3,14 +3,32 @@* * Unified network-device I/O interface for Xen guest OSes. * +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* * Copyright (c) 2003-2004, Keir Fraser */ #ifndef __XEN_PUBLIC_IO_NETIF_H__#define __XEN_PUBLIC_IO_NETIF_H__ -#include <xen/interface/io/ring.h> -#include <xen/interface/grant_table.h> +#include "ring.h" +#include "../grant_table.h" /* * Older implementation of Xen network frontend / backend has an
@@ -38,10 +56,10 @@* that it cannot safely queue packets (as it may not be kicked to send them). */ -/* +/* * "feature-split-event-channels" is introduced to separate guest TX -* and RX notificaion. Backend either doesn't support this feature or -* advertise it via xenstore as 0 (disabled) or 1 (enabled). +* and RX notification. Backend either doesn't support this feature or +* advertises it via xenstore as 0 (disabled) or 1 (enabled). * * To make use of this feature, frontend should allocate two event * channels for TX and RX, advertise them to backend as
@@ -96,11 +114,112 @@* error. This includes scenarios where more (or fewer) queues were * requested than the frontend provided details for. * -* Mapping of packets to queues is considered to be a function of the -* transmitting system (backend or frontend) and is not negotiated -* between the two. Guests are free to transmit packets on any queue -* they choose, provided it has been set up correctly. Guests must be -* prepared to receive packets on any queue they have requested be set up. +* Unless a hash algorithm or mapping of packet hash to queues has been +* negotiated (see below), queue selection is considered to be a function of +* the transmitting system (backend or frontend) and either end is free to +* transmit packets on any queue, provided it has been set up correctly. +* Guests must therefore be prepared to receive packets on any queue they +* have requested be set up. +*/ + +/* +* Hash negotiation (only applicable if using multiple queues): +* +* A backend can advertise a set of hash algorithms that it can perform by +* naming it in a space separated list in the "multi-queue-hash-list" +* xenstore key. For example, if the backend supports the 'foo' and 'bar' +* algorithms it would set: +* +* /local/domain/X/backend/vif/Y/Z/multi-queue-hash-list = "foo bar" +* +* Additionally, in supporting a particular algorithm, it may be necessary +* for the backend to specify the capabilities of its implementation of +* that algorithm, e.g. what sections of packet header it can hash. +* To do that it can set algorithm-specific keys under a parent capabilities +* key. For example, if the 'bar' algorithm implementation in the backend +* is capable of hashing over an IP version 4 header and a TCP header, the +* backend might set: +* +* /local/domain/X/backend/vif/Y/Z/multi-queue-hash-caps-bar/types = "ipv4+tcp" +* +* The backend should set all such keys before it moves into the initwait +* state. +* +* The frontend can select a hash algorithm at any time after it moves into +* the connected state by setting the "multi-queue-hash" key. The backend +* must therefore watch this key and be prepared to change hash algorithms +* at any time whilst in the connected state. So, for example, if the +* frontend wants 'foo' hashing, it should set: +* +* /local/domain/Y/device/vif/Z/multi-queue-hash = "foo" +* +* Additionally it may set parameters for that algorithm by setting +* algorithm-specific keys under a parent parameters key. For example, if +* the 'foo' algorithm implementation in the backend is capable of hashing +* over an IP version 4 header, a TCP header or both but the frontend only +* wants it to hash over only the IP version 4 header then it might set: +* +* /local/domain/Y/device/vif/Z/multi-queue-hash-params-foo/types = "ipv4" +* +* The backend must also watch the parameters key as the frontend may +* change the parameters at any time whilst in the connected state. +* +* (Capabilities and parameters documentation for specific algorithms is +* below). +* +* TOEPLITZ: +* +* If the backend supports Toeplitz hashing then it should include +* the algorithm name 'toeplitz' in its "multi-queue-hash-list" key. +* It should also advertise the following capabilities: +* +* types: a space separated list containing any or all of 'ipv4', 'tcpv4', +* 'ipv6', 'tcpv6', indicating over which headers the hash algorithm +* is capable of being performed. +* +* max-key-length: an integer value indicating the maximum key length (in +* octets) that the frontend may supply. +* +* Upon selecting this algorithm, the frontend may supply the following +* parameters. +* +* types: a space separated list containing none, any or all of the type +* names included in the types list in the capabilities. +* When the backend encounters a packet type not in this list it +* will assign a hash value of 0. +* +* key: a ':' separated list of octets (up to the maximum length specified +* in the capabilities) expressed in hexadecimal indicating the key +* that should be used in the hash calculation. +* +* For more information on Toeplitz hash calculation see: +* +* https://msdn.microsoft.com/en-us/library/windows/hardware/ff570725.aspx +*/ + +/* +* Hash mapping (only applicable if using multiple queues): +* +* If the backend is not capable, or no mapping is specified by the frontend +* then it is assumed that the hash -> queue mapping is done by simple +* modular arithmetic. +* +* To advertise that it is capable of accepting a specific mapping from the +* frontend the backend should set the "multi-queue-max-hash-mapping-length" +* key to a non-zero value. The frontend may then specify a mapping (up to +* the maximum specified length) as a ',' separated list of decimal queue +* numbers in the "multi-queue-hash-mapping" key. +* +* The backend should parse this list into an array and perform the mapping +* as follows: +* +* queue = mapping[hash % length-of-list] +* +* If any of the queue values specified in the list is not connected then +* the backend is free to choose a connected queue arbitrarily. +* +* The backend must be prepared to handle updates the mapping list at any +* time whilst in the connected state. */ /*
@@ -118,151 +237,319 @@*/ /* +* "feature-multicast-control" advertises the capability to filter ethernet +* multicast packets in the backend. To enable use of this capability the +* frontend must set "request-multicast-control" before moving into the +* connected state. +* +* If "request-multicast-control" is set then the backend transmit side should +* no longer flood multicast packets to the frontend, it should instead drop any +* multicast packet that does not match in a filter list. The list is +* amended by the frontend by sending dummy transmit requests containing +* XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} extra-info fragments as specified below. +* Once enabled by the frontend, the feature cannot be disabled except by +* closing and re-connecting to the backend. +*/ + +/* +* "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. +*/ + +/* * This is the 'wire' format for packets: -* Request 1: xen_netif_tx_request -- XEN_NETTXF_* (any flags) -* [Request 2: xen_netif_extra_info] (only if request 1 has XEN_NETTXF_extra_info) -* [Request 3: xen_netif_extra_info] (only if request 2 has XEN_NETIF_EXTRA_MORE) -* Request 4: xen_netif_tx_request -- XEN_NETTXF_more_data -* Request 5: xen_netif_tx_request -- XEN_NETTXF_more_data +* Request 1: xen_netif_tx_request_t -- XEN_NETTXF_* (any flags) +* [Request 2: xen_netif_extra_info_t] (only if request 1 has +* XEN_NETTXF_extra_info) +* [Request 3: xen_netif_extra_info_t] (only if request 2 has +* XEN_NETIF_EXTRA_MORE) +* Request 4: xen_netif_tx_request_t -- XEN_NETTXF_more_data +* Request 5: xen_netif_tx_request_t -- XEN_NETTXF_more_data * ... -* Request N: xen_netif_tx_request -- 0 +* Request N: xen_netif_tx_request_t -- 0 +*/ + +/* +* Guest transmit +* ============== +* +* Ring slot size is 12 octets, however not all request/response +* structs use the full size. +* +* tx request data (xen_netif_tx_request_t) +* ------------------------------------ +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | grant ref | offset | flags | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | size | +* +-----+-----+-----+-----+ +* +* grant ref: Reference to buffer page. +* offset: Offset within buffer page. +* flags: XEN_NETTXF_*. +* id: request identifier, echoed in response. +* size: packet size in bytes. +* +* tx response (xen_netif_tx_response_t) +* --------------------------------- +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | status | unused | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | unused | +* +-----+-----+-----+-----+ +* +* id: reflects id in transmit request +* status: XEN_NETIF_RSP_* +* +* Guest receive +* ============= +* +* Ring slot size is 8 octets. +* +* rx request (xen_netif_rx_request_t) +* ------------------------------- +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | pad | gref | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* id: request identifier, echoed in response. +* gref: reference to incoming granted frame. +* +* rx response (xen_netif_rx_response_t) +* --------------------------------- +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | offset | flags | status | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* id: reflects id in receive request +* offset: offset in page of start of received packet +* flags: XEN_NETRXF_* +* status: -ve: XEN_NETIF_RSP_*; +ve: Rx'ed pkt size. +* +* NOTE: Historically, to support GSO on the frontend receive side, Linux +* netfront does not make use of the rx response id (because, as +* described below, extra info structures overlay the id field). +* Instead it assumes that responses always appear in the same ring +* slot as their corresponding request. Thus, to maintain +* compatibility, backends must make sure this is the case. +* +* Extra Info +* ========== +* +* Can be present if initial request or response has NET{T,R}XF_extra_info, +* or previous extra request has XEN_NETIF_EXTRA_MORE. +* +* The struct therefore needs to fit into either a tx or rx slot and +* is therefore limited to 8 octets. +* +* NOTE: Because extra info data overlays the usual request/response +* structures, there is no id information in the opposite direction. +* So, if an extra info overlays an rx response the frontend can +* assume that it is in the same ring slot as the request that was +* consumed to make the slot available, and the backend must ensure +* this assumption is true. +* +* extra info (xen_netif_extra_info_t) +* ------------------------------- +* +* General format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags| type specific data | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | padding for tx | +* +-----+-----+-----+-----+ +* +* type: XEN_NETIF_EXTRA_TYPE_* +* flags: XEN_NETIF_EXTRA_FLAG_* +* padding for tx: present only in the tx case due to 8 octet limit +* from rx case. Not shown in type specific entries +* below. +* +* XEN_NETIF_EXTRA_TYPE_GSO: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags| size |type | pad | features | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* type: Must be XEN_NETIF_EXTRA_TYPE_GSO +* flags: XEN_NETIF_EXTRA_FLAG_* +* size: Maximum payload size of each segment. For example, +* for TCP this is just the path MSS. +* type: XEN_NETIF_GSO_TYPE_*: This determines the protocol of +* the packet and any extra features required to segment the +* packet properly. +* features: EN_NETIF_GSO_FEAT_*: This specifies any extra GSO +* features required to process this packet, such as ECN +* support for TCPv4. +* +* XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags| addr | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* 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)? */ -#define _XEN_NETTXF_csum_blank (0) -#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank) +#define _XEN_NETTXF_csum_blank (0) +#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank)/* Packet data has been validated against protocol checksum. */ -#define _XEN_NETTXF_data_validated (1) -#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated) +#define _XEN_NETTXF_data_validated (1) +#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated)/* Packet continues in the next request descriptor. */ -#define _XEN_NETTXF_more_data (2) -#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data) +#define _XEN_NETTXF_more_data (2) +#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data)/* Packet to be followed by extra descriptor(s). */ -#define _XEN_NETTXF_extra_info (3) -#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info) +#define _XEN_NETTXF_extra_info (3) +#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info)#define XEN_NETIF_MAX_TX_SIZE 0xFFFFstruct xen_netif_tx_request { -grant_ref_t gref;/* Reference to buffer page */ -uint16_t offset;/* Offset within buffer page */ -uint16_t flags;/* XEN_NETTXF_* */ -uint16_t id;/* Echoed in response message. */ -uint16_t size;/* Packet size in bytes. */ +grant_ref_t gref; +uint16_t offset; +uint16_t flags; +uint16_t id; +uint16_t size; }; +typedef struct xen_netif_tx_request xen_netif_tx_request_t ;/* Types of xen_netif_extra_info descriptors. */ -#define XEN_NETIF_EXTRA_TYPE_NONE (0)/* Never used - invalid */ -#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_NONE (0)/* Never used - invalid */ +#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_HASH (4)/* u.hash */ +#define XEN_NETIF_EXTRA_TYPE_MAX (5) -/* xen_netif_extra_info flags. */ -#define _XEN_NETIF_EXTRA_FLAG_MORE (0) -#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE) +/* xen_netif_extra_info_t flags. */ +#define _XEN_NETIF_EXTRA_FLAG_MORE (0) +#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)/* GSO types */ -#define XEN_NETIF_GSO_TYPE_NONE (0) -#define XEN_NETIF_GSO_TYPE_TCPV4 (1) -#define XEN_NETIF_GSO_TYPE_TCPV6 (2) +#define XEN_NETIF_GSO_TYPE_NONE (0) +#define XEN_NETIF_GSO_TYPE_TCPV4 (1) +#define XEN_NETIF_GSO_TYPE_TCPV6 (2) + +/* Hash types */ +#define XEN_NETIF_HASH_TYPE_NONE (0) +#define XEN_NETIF_HASH_TYPE_TCPV4 (1) +#define XEN_NETIF_HASH_TYPE_IPV4 (2) +#define XEN_NETIF_HASH_TYPE_TCPV6 (3) +#define XEN_NETIF_HASH_TYPE_IPV6 (4)/* -* This structure needs to fit within both netif_tx_request and -* netif_rx_response for compatibility. +* This structure needs to fit within both xen_netif_tx_request_t and +* xen_netif_rx_response_t for compatibility. */ struct xen_netif_extra_info { -uint8_t type;/* XEN_NETIF_EXTRA_TYPE_* */ -uint8_t flags;/* XEN_NETIF_EXTRA_FLAG_* */ - +uint8_t type; +uint8_t flags;union {struct { -/* -* Maximum payload size of each segment. For -* example, for TCP this is just the path MSS. -*/ uint16_t size; - -/* -* GSO type. This determines the protocol of -* the packet and any extra features required -* to segment the packet properly. -*/ -uint8_t type;/* XEN_NETIF_GSO_TYPE_* */ - -/* Future expansion. */ +uint8_t type;uint8_t pad; - -/* -* GSO features. This specifies any extra GSO -* features required to process this packet, -* such as ECN support for TCPv4. -*/ -uint16_t features;/* XEN_NETIF_GSO_FEAT_* */ +uint16_t features; } gso; -struct { -uint8_t addr[6 ];/* Address to add/remove. */ +uint8_t addr[6 ]; } mcast; +struct { +uint8_t type; +uint8_t pad; +uint8_t value[4 ]; + } hash;uint16_t pad[3 ]; } u; }; +typedef struct xen_netif_extra_info xen_netif_extra_info_t ;struct xen_netif_tx_response {uint16_t id; -int16_t status;/* XEN_NETIF_RSP_* */ +int16_t status; }; +typedef struct xen_netif_tx_response xen_netif_tx_response_t ;struct xen_netif_rx_request { -uint16_t id;/* Echoed in response message. */ -grant_ref_t gref;/* Reference to incoming granted frame */ +uint16_t id; +uint16_t pad; +grant_ref_t gref; }; +typedef struct xen_netif_rx_request xen_netif_rx_request_t ;/* Packet data has been validated against protocol checksum. */ -#define _XEN_NETRXF_data_validated (0) -#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated) +#define _XEN_NETRXF_data_validated (0) +#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated)/* Protocol checksum field is blank in the packet (hardware offload)? */ -#define _XEN_NETRXF_csum_blank (1) -#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank) +#define _XEN_NETRXF_csum_blank (1) +#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank)/* Packet continues in the next request descriptor. */ -#define _XEN_NETRXF_more_data (2) -#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data) +#define _XEN_NETRXF_more_data (2) +#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data)/* Packet to be followed by extra descriptor(s). */ -#define _XEN_NETRXF_extra_info (3) -#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info) +#define _XEN_NETRXF_extra_info (3) +#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info) -/* GSO Prefix descriptor. */ -#define _XEN_NETRXF_gso_prefix (4) -#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix) +/* Packet has GSO prefix. Deprecated but included for compatibility */ +#define _XEN_NETRXF_gso_prefix (4) +#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix)struct xen_netif_rx_response { -uint16_t id; -uint16_t offset;/* Offset in page of start of received packet */ -uint16_t flags;/* XEN_NETRXF_* */ -int16_t status;/* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */ +uint16_t id; +uint16_t offset; +uint16_t flags; +int16_t status; }; +typedef struct xen_netif_rx_response xen_netif_rx_response_t ;/* * Generate netif ring structures and types. */ -DEFINE_RING_TYPES (xen_netif_tx, - struct xen_netif_tx_request, +DEFINE_RING_TYPES(xen_netif_tx, struct xen_netif_tx_request, struct xen_netif_tx_response); -DEFINE_RING_TYPES (xen_netif_rx, - struct xen_netif_rx_request, +DEFINE_RING_TYPES(xen_netif_rx, struct xen_netif_rx_request, struct xen_netif_rx_response); -#define XEN_NETIF_RSP_DROPPED -2 -#define XEN_NETIF_RSP_ERROR -1 -#define XEN_NETIF_RSP_OKAY 0 -/* No response: used for auxiliary requests (e.g., xen_netif_extra_info). */ -#define XEN_NETIF_RSP_NULL 1 +#define XEN_NETIF_RSP_DROPPED -2 +#define XEN_NETIF_RSP_ERROR -1 +#define XEN_NETIF_RSP_OKAY 0 +/* No response: used for auxiliary requests (e.g., xen_netif_extra_info_t). */ +#define XEN_NETIF_RSP_NULL 1#endif
Signature · 1 line
2.1.4
PATCH 4/8 xen-netback: accept an L4 or L3 skb hash value from the frontend
In reply to Paul DurrantThis patch adds an indication that netback is capable of handling hash values passed from the frontend (see netif.h for details), and the code necessary to process the additional xen_netif_extra_info segment and set a hash on the skb.
--- drivers/net/xen-netback/netback.c | 25 +++++++++++++++++++++++++ drivers/net/xen-netback/xenbus.c | 8 ++++++++ 2 files changed, 33 insertions(+)
drivers/net/xen-netback/netback.c +25 -0
@@ -1383,6 +1383,28 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, } } +if (extras[XEN_NETIF_EXTRA_TYPE_HASH -1 ].type) { +struct xen_netif_extra_info *extra; +u32 hash = *(u32 *)extra->u.hash.value; + + extra = &extras[XEN_NETIF_EXTRA_TYPE_HASH -1 ]; + +switch (extra->u.hash.type) { +case XEN_NETIF_HASH_TYPE_TCPV4 : +case XEN_NETIF_HASH_TYPE_TCPV6 : +skb_set_hash (skb, hash,PKT_HASH_TYPE_L4 ); +break ; + +case XEN_NETIF_HASH_TYPE_IPV4 : +case XEN_NETIF_HASH_TYPE_IPV6 : +skb_set_hash (skb, hash,PKT_HASH_TYPE_L3 ); +break ; + +default : +break ; + } + } +XENVIF_TX_CB (skb)->pending_idx = pending_idx;__skb_put (skb, data_len);
@@ -1416,6 +1438,9 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,if (extras[XEN_NETIF_EXTRA_TYPE_GSO -1 ].type) queue->pending_tx_info[pending_idx].extra_count++; +if (extras[XEN_NETIF_EXTRA_TYPE_HASH -1 ].type) + queue->pending_tx_info[pending_idx].extra_count++; + queue->pending_cons++; gop = xenvif_get_requests(queue, skb, txfrags, gop,
drivers/net/xen-netback/xenbus.c +8 -0
@@ -335,6 +335,14 @@ static int netback_probe(struct xenbus_device *dev, goto abort_transaction; } +/* We support hash values. */ + err =xenbus_printf (xbt, dev->nodename, +"feature-hash" ,"%d" ,1 ); +if (err) { + message ="writing feature-hash" ; + goto abort_transaction; + } + err =xenbus_transaction_end (xbt,0 ); }while (err == -EAGAIN );
Signature · 1 line
2.1.4
cover xen-netback/core: packet hashing
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Patch #1 re-imports the canonical netif header from Xen, which contains the necessary definitions and a type required by subsequent patches. (Note that this patch is not completely style-clean since the header includes typedefs).
Patch #2 is some cleanup in xen-netback.
Patch #3 adds code to allow multiple extra_info segments to be passed from a frontend to xen-netback.
Patch #4 adds code to allow xen-netback to accept new hash extra_info segments from a frontend and set the skb hash information appropriately.
Patch #5 makes a change to struct sk_buff: one extra bit is used to allow full hash type information to be stored, rather than just the l4_hash boolean value.
Patch #6 adds code to xen-netback to pass L3 or L4 skb hash values to capable frontends.
Patch #7 adds code to xen-netback to provide a configurable (by the frontend) mapping from hash values to queue numbers.
Patch #8 adds code to xen-netback to provide toeplitz hashing of skbs.
PATCH 3/8 xen-netback: support multiple extra info segments passed from frontend
The code does not currently allow a frontend to pass multiple extra info segments to the backend in a tx request. A subsequent patch in this series needs this functionality so it is added here, without any other modification, for better bisectability.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/netback.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -51,6 +51,7 @@ typedef unsigned int pending_ring_idx_t;struct pending_tx_info {struct xen_netif_tx_request req;/* tx request */ +unsigned int extra_count;/* Number of extras following the request */ /* Callback data for released SKBs. The callback is always * xenvif_zerocopy_callback, desc contains the pending_idx, which is * also an index in pending_tx_info array. It is initialized in
drivers/net/xen-netback/netback.c +19 -8
@@ -95,7 +95,8 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,static void make_tx_response (struct xenvif_queue *queue,struct xen_netif_tx_request *txp, -s8 st); +s8 st, +unsigned int extra_count);static void push_tx_responses (struct xenvif_queue *queue);static inline int tx_work_todo (struct xenvif_queue *queue);
@@ -646,7 +647,7 @@ static void xenvif_tx_err(struct xenvif_queue *queue, do { spin_lock_irqsave(&queue->response_lock, flags); - make_tx_response(queue, txp, XEN_NETIF_RSP_ERROR); + make_tx_response(queue, txp, XEN_NETIF_RSP_ERROR, 0); push_tx_responses(queue); spin_unlock_irqrestore(&queue->response_lock, flags); if (cons == end)
@@ -1292,7 +1293,8 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,make_tx_response (queue, &txreq, (ret ==0 ) ?XEN_NETIF_RSP_OKAY : -XEN_NETIF_RSP_ERROR ); +XEN_NETIF_RSP_ERROR , +1 );push_tx_responses (queue);continue ; }
@@ -1303,7 +1305,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, extra = &extras[XEN_NETIF_EXTRA_TYPE_MCAST_DEL -1 ];xenvif_mcast_del (queue->vif, extra->u.mcast.addr); -make_tx_response (queue, &txreq,XEN_NETIF_RSP_OKAY ); +make_tx_response (queue, &txreq,XEN_NETIF_RSP_OKAY ,1 );push_tx_responses (queue);continue ; }
@@ -1411,6 +1413,9 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, sizeof(txreq)); } +if (extras[XEN_NETIF_EXTRA_TYPE_GSO -1 ].type) + queue->pending_tx_info[pending_idx].extra_count++; + queue->pending_cons++; gop = xenvif_get_requests(queue, skb, txfrags, gop,
@@ -1749,7 +1754,9 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,spin_lock_irqsave (&queue->response_lock, flags); -make_tx_response (queue, &pending_tx_info->req, status); +make_tx_response (queue, &pending_tx_info->req, status, + pending_tx_info->extra_count); +memset (pending_tx_info,0 ,sizeof (*pending_tx_info));/* Release the pending index before pusing the Tx response so * its available before a new Tx request is pushed by the
@@ -1766,7 +1773,8 @@ static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,static void make_tx_response (struct xenvif_queue *queue,struct xen_netif_tx_request *txp, -s8 st) +s8 st, +unsigned int extra_count) {RING_IDX i = queue->tx.rsp_prod_pvt;struct xen_netif_tx_response *resp;
@@ -1775,8 +1783,11 @@ static void make_tx_response(struct xenvif_queue *queue, resp->id = txp->id; resp->status = st; -if (txp->flags & XEN_NETTXF_extra_info) -RING_GET_RESPONSE (&queue->tx, ++i)->status =XEN_NETIF_RSP_NULL ; +WARN_ON (!(txp->flags & XEN_NETTXF_extra_info) != !extra_count); + +while (extra_count-- !=0 ) +RING_GET_RESPONSE (&queue->tx, ++i)->status = +XEN_NETIF_RSP_NULL ; queue->tx.rsp_prod_pvt = ++i; }
Signature · 1 line
2.1.4
PATCH 5/8 skbuff: store hash type in socket buffer...
In reply to Paul Durrant...rather than a boolean merely indicating a canonical L4 hash.
skb_set_hash() takes a hash type (from enum pkt_hash_types) as an argument but information is lost since only a single bit in the skb stores whether that hash type is PKT_HASH_TYPE_L4 or not.
By using two bits it's possible to store the complete hash type information for use by drivers, such as xen-netback when forwarding network packets to VM frontend drivers.
--- drivers/net/bonding/bond_main.c | 2 +- include/linux/skbuff.h | 53 ++++++++++++++++++++++++++++------------- include/net/flow_dissector.h | 5 ++++ include/net/sock.h | 2 +- include/trace/events/net.h | 2 +- net/core/flow_dissector.c | 27 ++++++++++++++++----- 6 files changed, 65 insertions(+), 26 deletions(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -3137,7 +3137,7 @@ u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)u32 hash;if (bond->params.xmit_policy ==BOND_XMIT_POLICY_ENCAP34 && - skb->l4_hash) +skb_has_l4_hash (skb))return skb->hash; if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 ||
include/linux/skbuff.h +36 -17
131 lines not on this page · raw message
include/net/flow_dissector.h +5 -0
@@ -182,6 +182,11 @@ static inline bool flow_keys_have_l4(struct flow_keys *keys) return (keys->ports.ports || keys->tags.flow_label); } +static inline bool flow_keys_have_l3 (struct flow_keys *keys) +{ +return !!keys->control.addr_type; +} +u32 flow_hash_from_keys (struct flow_keys *keys);#endif
include/net/sock.h +1 -1
@@ -1938,7 +1938,7 @@ static inline void sock_poll_wait(struct file *filp,static inline void skb_set_hash_from_sk (struct sk_buff *skb,struct sock *sk) {if (sk->sk_txhash) { - skb->l4_hash =1 ; + skb->hash_type =PKT_HASH_TYPE_L4 ; skb->hash = sk->sk_txhash; } }
include/trace/events/net.h +1 -1
@@ -180,7 +180,7 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template, __entry->protocol =ntohs (skb->protocol); __entry->ip_summed = skb->ip_summed; __entry->hash = skb->hash; - __entry->l4_hash = skb->l4_hash; + __entry->l4_hash = skb->hash_type ==PKT_HASH_TYPE_L4 ; __entry->len = skb->len; __entry->data_len = skb->data_len; __entry->truesize = skb->truesize;
net/core/flow_dissector.c +21 -6
@@ -658,17 +658,30 @@ EXPORT_SYMBOL(make_flow_keys_digest);* * This function calculates a flow hash based on src/dst addresses * and src/dst port numbers. Sets hash in skb to non-zero hash value -* on success, zero indicates no valid hash. Also, sets l4_hash in skb -* if hash is a canonical 4-tuple hash over transport ports. +* on success, zero indicates no valid hash in which case the hash type +* is set to NONE. If the hash is a canonical 4-tuple hash over transport +* ports then type is set to L4. If the hash did not include transport +* then type is set to L3, otherwise it is assumed to be L2 only. */ void __skb_get_hash (struct sk_buff *skb) {struct flow_keys keys; +u32 hash; +enum pkt_hash_types type;__flow_hash_secret_init (); -__skb_set_sw_hash (skb,___skb_get_hash (skb, &keys, hashrnd), -flow_keys_have_l4 (&keys)); + hash =___skb_get_hash (skb, &keys, hashrnd); +if (hash ==0 ) + type =PKT_HASH_TYPE_NONE ; +else if (flow_keys_have_l4 (&keys)) + type =PKT_HASH_TYPE_L4 ; +else if (flow_keys_have_l3 (&keys)) + type =PKT_HASH_TYPE_L3 ; +else + type =PKT_HASH_TYPE_L2 ; + +__skb_set_sw_hash (skb, hash, type); }EXPORT_SYMBOL (__skb_get_hash);
@@ -698,7 +711,8 @@ __u32 __skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6 *fl6) keys.basic.ip_proto = fl6->flowi6_proto;__skb_set_sw_hash (skb,flow_hash_from_keys (&keys), -flow_keys_have_l4 (&keys)); +flow_keys_have_l4 (&keys) ? +PKT_HASH_TYPE_L4 :PKT_HASH_TYPE_L3 );return skb->hash; }
@@ -719,7 +733,8 @@ __u32 __skb_get_hash_flowi4(struct sk_buff *skb, const struct flowi4 *fl4) keys.basic.ip_proto = fl4->flowi4_proto;__skb_set_sw_hash (skb,flow_hash_from_keys (&keys), -flow_keys_have_l4 (&keys)); +flow_keys_have_l4 (&keys) ? +PKT_HASH_TYPE_L4 :PKT_HASH_TYPE_L3 );return skb->hash; }
Signature · 1 line
2.1.4
PATCH 1/8 xen-netback: re-import canonical netif header
In reply to Paul DurrantThe canonical netif header (in the Xen source repo) and the Linux variant have diverged significantly. Recently much documentation has been added to the canonical header and new definitions and types to support packet hash configuration. Subsequent patches in this series add support for packet hash configuration in xen-netback so this patch re-imports the canonical header in readiness.
To maintain compatibility and some style consistency with the old Linux variant, the header was stripped of its emacs boilerplate, and post-processed and copied into place with the following commands:
ed -s netif.h << EOF
H
,s/NETTXF_/XEN_NETTXF_/g
,s/NETRXF_/XEN_NETRXF_/g
,s/NETIF_RSP/XEN_NETIF_RSP/g
,s/netif_tx/xen_netif_tx/g
,s/netif_rx/xen_netif_rx/g
,s/netif_extra_info/xen_netif_extra_info/g
w
EOF
indent --linux-style netif.h -o include/xen/interface/io/netif.h
---
Whilst awaiting review of my patches to the canonical netif.h, import has been done from my staging branch using:
--- include/xen/interface/io/netif.h | 475 +++++++++++++++++++++++++++++++-------- 1 file changed, 381 insertions(+), 94 deletions(-)
include/xen/interface/io/netif.h +381 -94
@@ -3,14 +3,32 @@* * Unified network-device I/O interface for Xen guest OSes. * +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* * Copyright (c) 2003-2004, Keir Fraser */ #ifndef __XEN_PUBLIC_IO_NETIF_H__#define __XEN_PUBLIC_IO_NETIF_H__ -#include <xen/interface/io/ring.h> -#include <xen/interface/grant_table.h> +#include "ring.h" +#include "../grant_table.h" /* * Older implementation of Xen network frontend / backend has an
@@ -38,10 +56,10 @@* that it cannot safely queue packets (as it may not be kicked to send them). */ -/* +/* * "feature-split-event-channels" is introduced to separate guest TX -* and RX notificaion. Backend either doesn't support this feature or -* advertise it via xenstore as 0 (disabled) or 1 (enabled). +* and RX notification. Backend either doesn't support this feature or +* advertises it via xenstore as 0 (disabled) or 1 (enabled). * * To make use of this feature, frontend should allocate two event * channels for TX and RX, advertise them to backend as
@@ -96,11 +114,112 @@* error. This includes scenarios where more (or fewer) queues were * requested than the frontend provided details for. * -* Mapping of packets to queues is considered to be a function of the -* transmitting system (backend or frontend) and is not negotiated -* between the two. Guests are free to transmit packets on any queue -* they choose, provided it has been set up correctly. Guests must be -* prepared to receive packets on any queue they have requested be set up. +* Unless a hash algorithm or mapping of packet hash to queues has been +* negotiated (see below), queue selection is considered to be a function of +* the transmitting system (backend or frontend) and either end is free to +* transmit packets on any queue, provided it has been set up correctly. +* Guests must therefore be prepared to receive packets on any queue they +* have requested be set up. +*/ + +/* +* Hash negotiation (only applicable if using multiple queues): +* +* A backend can advertise a set of hash algorithms that it can perform by +* naming it in a space separated list in the "multi-queue-hash-list" +* xenstore key. For example, if the backend supports the 'foo' and 'bar' +* algorithms it would set: +* +* /local/domain/X/backend/vif/Y/Z/multi-queue-hash-list = "foo bar" +* +* Additionally, in supporting a particular algorithm, it may be necessary +* for the backend to specify the capabilities of its implementation of +* that algorithm, e.g. what sections of packet header it can hash. +* To do that it can set algorithm-specific keys under a parent capabilities +* key. For example, if the 'bar' algorithm implementation in the backend +* is capable of hashing over an IP version 4 header and a TCP header, the +* backend might set: +* +* /local/domain/X/backend/vif/Y/Z/multi-queue-hash-caps-bar/types = "ipv4+tcp" +* +* The backend should set all such keys before it moves into the initwait +* state. +* +* The frontend can select a hash algorithm at any time after it moves into +* the connected state by setting the "multi-queue-hash" key. The backend +* must therefore watch this key and be prepared to change hash algorithms +* at any time whilst in the connected state. So, for example, if the +* frontend wants 'foo' hashing, it should set: +* +* /local/domain/Y/device/vif/Z/multi-queue-hash = "foo" +* +* Additionally it may set parameters for that algorithm by setting +* algorithm-specific keys under a parent parameters key. For example, if +* the 'foo' algorithm implementation in the backend is capable of hashing +* over an IP version 4 header, a TCP header or both but the frontend only +* wants it to hash over only the IP version 4 header then it might set: +* +* /local/domain/Y/device/vif/Z/multi-queue-hash-params-foo/types = "ipv4" +* +* The backend must also watch the parameters key as the frontend may +* change the parameters at any time whilst in the connected state. +* +* (Capabilities and parameters documentation for specific algorithms is +* below). +* +* TOEPLITZ: +* +* If the backend supports Toeplitz hashing then it should include +* the algorithm name 'toeplitz' in its "multi-queue-hash-list" key. +* It should also advertise the following capabilities: +* +* types: a space separated list containing any or all of 'ipv4', 'tcpv4', +* 'ipv6', 'tcpv6', indicating over which headers the hash algorithm +* is capable of being performed. +* +* max-key-length: an integer value indicating the maximum key length (in +* octets) that the frontend may supply. +* +* Upon selecting this algorithm, the frontend may supply the following +* parameters. +* +* types: a space separated list containing none, any or all of the type +* names included in the types list in the capabilities. +* When the backend encounters a packet type not in this list it +* will assign a hash value of 0. +* +* key: a ':' separated list of octets (up to the maximum length specified +* in the capabilities) expressed in hexadecimal indicating the key +* that should be used in the hash calculation. +* +* For more information on Toeplitz hash calculation see: +* +* https://msdn.microsoft.com/en-us/library/windows/hardware/ff570725.aspx +*/ + +/* +* Hash mapping (only applicable if using multiple queues): +* +* If the backend is not capable, or no mapping is specified by the frontend +* then it is assumed that the hash -> queue mapping is done by simple +* modular arithmetic. +* +* To advertise that it is capable of accepting a specific mapping from the +* frontend the backend should set the "multi-queue-max-hash-mapping-length" +* key to a non-zero value. The frontend may then specify a mapping (up to +* the maximum specified length) as a ',' separated list of decimal queue +* numbers in the "multi-queue-hash-mapping" key. +* +* The backend should parse this list into an array and perform the mapping +* as follows: +* +* queue = mapping[hash % length-of-list] +* +* If any of the queue values specified in the list is not connected then +* the backend is free to choose a connected queue arbitrarily. +* +* The backend must be prepared to handle updates the mapping list at any +* time whilst in the connected state. */ /*
@@ -118,151 +237,319 @@*/ /* +* "feature-multicast-control" advertises the capability to filter ethernet +* multicast packets in the backend. To enable use of this capability the +* frontend must set "request-multicast-control" before moving into the +* connected state. +* +* If "request-multicast-control" is set then the backend transmit side should +* no longer flood multicast packets to the frontend, it should instead drop any +* multicast packet that does not match in a filter list. The list is +* amended by the frontend by sending dummy transmit requests containing +* XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} extra-info fragments as specified below. +* Once enabled by the frontend, the feature cannot be disabled except by +* closing and re-connecting to the backend. +*/ + +/* +* "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. +*/ + +/* * This is the 'wire' format for packets: -* Request 1: xen_netif_tx_request -- XEN_NETTXF_* (any flags) -* [Request 2: xen_netif_extra_info] (only if request 1 has XEN_NETTXF_extra_info) -* [Request 3: xen_netif_extra_info] (only if request 2 has XEN_NETIF_EXTRA_MORE) -* Request 4: xen_netif_tx_request -- XEN_NETTXF_more_data -* Request 5: xen_netif_tx_request -- XEN_NETTXF_more_data +* Request 1: xen_netif_tx_request_t -- XEN_NETTXF_* (any flags) +* [Request 2: xen_netif_extra_info_t] (only if request 1 has +* XEN_NETTXF_extra_info) +* [Request 3: xen_netif_extra_info_t] (only if request 2 has +* XEN_NETIF_EXTRA_MORE) +* Request 4: xen_netif_tx_request_t -- XEN_NETTXF_more_data +* Request 5: xen_netif_tx_request_t -- XEN_NETTXF_more_data * ... -* Request N: xen_netif_tx_request -- 0 +* Request N: xen_netif_tx_request_t -- 0 +*/ + +/* +* Guest transmit +* ============== +* +* Ring slot size is 12 octets, however not all request/response +* structs use the full size. +* +* tx request data (xen_netif_tx_request_t) +* ------------------------------------ +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | grant ref | offset | flags | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | size | +* +-----+-----+-----+-----+ +* +* grant ref: Reference to buffer page. +* offset: Offset within buffer page. +* flags: XEN_NETTXF_*. +* id: request identifier, echoed in response. +* size: packet size in bytes. +* +* tx response (xen_netif_tx_response_t) +* --------------------------------- +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | status | unused | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | unused | +* +-----+-----+-----+-----+ +* +* id: reflects id in transmit request +* status: XEN_NETIF_RSP_* +* +* Guest receive +* ============= +* +* Ring slot size is 8 octets. +* +* rx request (xen_netif_rx_request_t) +* ------------------------------- +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | pad | gref | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* id: request identifier, echoed in response. +* gref: reference to incoming granted frame. +* +* rx response (xen_netif_rx_response_t) +* --------------------------------- +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | id | offset | flags | status | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* id: reflects id in receive request +* offset: offset in page of start of received packet +* flags: XEN_NETRXF_* +* status: -ve: XEN_NETIF_RSP_*; +ve: Rx'ed pkt size. +* +* NOTE: Historically, to support GSO on the frontend receive side, Linux +* netfront does not make use of the rx response id (because, as +* described below, extra info structures overlay the id field). +* Instead it assumes that responses always appear in the same ring +* slot as their corresponding request. Thus, to maintain +* compatibility, backends must make sure this is the case. +* +* Extra Info +* ========== +* +* Can be present if initial request or response has NET{T,R}XF_extra_info, +* or previous extra request has XEN_NETIF_EXTRA_MORE. +* +* The struct therefore needs to fit into either a tx or rx slot and +* is therefore limited to 8 octets. +* +* NOTE: Because extra info data overlays the usual request/response +* structures, there is no id information in the opposite direction. +* So, if an extra info overlays an rx response the frontend can +* assume that it is in the same ring slot as the request that was +* consumed to make the slot available, and the backend must ensure +* this assumption is true. +* +* extra info (xen_netif_extra_info_t) +* ------------------------------- +* +* General format: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags| type specific data | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* | padding for tx | +* +-----+-----+-----+-----+ +* +* type: XEN_NETIF_EXTRA_TYPE_* +* flags: XEN_NETIF_EXTRA_FLAG_* +* padding for tx: present only in the tx case due to 8 octet limit +* from rx case. Not shown in type specific entries +* below. +* +* XEN_NETIF_EXTRA_TYPE_GSO: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags| size |type | pad | features | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* type: Must be XEN_NETIF_EXTRA_TYPE_GSO +* flags: XEN_NETIF_EXTRA_FLAG_* +* size: Maximum payload size of each segment. For example, +* for TCP this is just the path MSS. +* type: XEN_NETIF_GSO_TYPE_*: This determines the protocol of +* the packet and any extra features required to segment the +* packet properly. +* features: EN_NETIF_GSO_FEAT_*: This specifies any extra GSO +* features required to process this packet, such as ECN +* support for TCPv4. +* +* XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}: +* +* 0 1 2 3 4 5 6 7 octet +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* |type |flags| addr | +* +-----+-----+-----+-----+-----+-----+-----+-----+ +* +* 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)? */ -#define _XEN_NETTXF_csum_blank (0) -#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank) +#define _XEN_NETTXF_csum_blank (0) +#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank)/* Packet data has been validated against protocol checksum. */ -#define _XEN_NETTXF_data_validated (1) -#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated) +#define _XEN_NETTXF_data_validated (1) +#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated)/* Packet continues in the next request descriptor. */ -#define _XEN_NETTXF_more_data (2) -#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data) +#define _XEN_NETTXF_more_data (2) +#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data)/* Packet to be followed by extra descriptor(s). */ -#define _XEN_NETTXF_extra_info (3) -#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info) +#define _XEN_NETTXF_extra_info (3) +#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info)#define XEN_NETIF_MAX_TX_SIZE 0xFFFFstruct xen_netif_tx_request { -grant_ref_t gref;/* Reference to buffer page */ -uint16_t offset;/* Offset within buffer page */ -uint16_t flags;/* XEN_NETTXF_* */ -uint16_t id;/* Echoed in response message. */ -uint16_t size;/* Packet size in bytes. */ +grant_ref_t gref; +uint16_t offset; +uint16_t flags; +uint16_t id; +uint16_t size; }; +typedef struct xen_netif_tx_request xen_netif_tx_request_t ;/* Types of xen_netif_extra_info descriptors. */ -#define XEN_NETIF_EXTRA_TYPE_NONE (0)/* Never used - invalid */ -#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_NONE (0)/* Never used - invalid */ +#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_HASH (4)/* u.hash */ +#define XEN_NETIF_EXTRA_TYPE_MAX (5) -/* xen_netif_extra_info flags. */ -#define _XEN_NETIF_EXTRA_FLAG_MORE (0) -#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE) +/* xen_netif_extra_info_t flags. */ +#define _XEN_NETIF_EXTRA_FLAG_MORE (0) +#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)/* GSO types */ -#define XEN_NETIF_GSO_TYPE_NONE (0) -#define XEN_NETIF_GSO_TYPE_TCPV4 (1) -#define XEN_NETIF_GSO_TYPE_TCPV6 (2) +#define XEN_NETIF_GSO_TYPE_NONE (0) +#define XEN_NETIF_GSO_TYPE_TCPV4 (1) +#define XEN_NETIF_GSO_TYPE_TCPV6 (2) + +/* Hash types */ +#define XEN_NETIF_HASH_TYPE_NONE (0) +#define XEN_NETIF_HASH_TYPE_TCPV4 (1) +#define XEN_NETIF_HASH_TYPE_IPV4 (2) +#define XEN_NETIF_HASH_TYPE_TCPV6 (3) +#define XEN_NETIF_HASH_TYPE_IPV6 (4)/* -* This structure needs to fit within both netif_tx_request and -* netif_rx_response for compatibility. +* This structure needs to fit within both xen_netif_tx_request_t and +* xen_netif_rx_response_t for compatibility. */ struct xen_netif_extra_info { -uint8_t type;/* XEN_NETIF_EXTRA_TYPE_* */ -uint8_t flags;/* XEN_NETIF_EXTRA_FLAG_* */ - +uint8_t type; +uint8_t flags;union {struct { -/* -* Maximum payload size of each segment. For -* example, for TCP this is just the path MSS. -*/ uint16_t size; - -/* -* GSO type. This determines the protocol of -* the packet and any extra features required -* to segment the packet properly. -*/ -uint8_t type;/* XEN_NETIF_GSO_TYPE_* */ - -/* Future expansion. */ +uint8_t type;uint8_t pad; - -/* -* GSO features. This specifies any extra GSO -* features required to process this packet, -* such as ECN support for TCPv4. -*/ -uint16_t features;/* XEN_NETIF_GSO_FEAT_* */ +uint16_t features; } gso; -struct { -uint8_t addr[6 ];/* Address to add/remove. */ +uint8_t addr[6 ]; } mcast; +struct { +uint8_t type; +uint8_t pad; +uint8_t value[4 ]; + } hash;uint16_t pad[3 ]; } u; }; +typedef struct xen_netif_extra_info xen_netif_extra_info_t ;struct xen_netif_tx_response {uint16_t id; -int16_t status;/* XEN_NETIF_RSP_* */ +int16_t status; }; +typedef struct xen_netif_tx_response xen_netif_tx_response_t ;struct xen_netif_rx_request { -uint16_t id;/* Echoed in response message. */ -grant_ref_t gref;/* Reference to incoming granted frame */ +uint16_t id; +uint16_t pad; +grant_ref_t gref; }; +typedef struct xen_netif_rx_request xen_netif_rx_request_t ;/* Packet data has been validated against protocol checksum. */ -#define _XEN_NETRXF_data_validated (0) -#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated) +#define _XEN_NETRXF_data_validated (0) +#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated)/* Protocol checksum field is blank in the packet (hardware offload)? */ -#define _XEN_NETRXF_csum_blank (1) -#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank) +#define _XEN_NETRXF_csum_blank (1) +#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank)/* Packet continues in the next request descriptor. */ -#define _XEN_NETRXF_more_data (2) -#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data) +#define _XEN_NETRXF_more_data (2) +#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data)/* Packet to be followed by extra descriptor(s). */ -#define _XEN_NETRXF_extra_info (3) -#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info) +#define _XEN_NETRXF_extra_info (3) +#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info) -/* GSO Prefix descriptor. */ -#define _XEN_NETRXF_gso_prefix (4) -#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix) +/* Packet has GSO prefix. Deprecated but included for compatibility */ +#define _XEN_NETRXF_gso_prefix (4) +#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix)struct xen_netif_rx_response { -uint16_t id; -uint16_t offset;/* Offset in page of start of received packet */ -uint16_t flags;/* XEN_NETRXF_* */ -int16_t status;/* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */ +uint16_t id; +uint16_t offset; +uint16_t flags; +int16_t status; }; +typedef struct xen_netif_rx_response xen_netif_rx_response_t ;/* * Generate netif ring structures and types. */ -DEFINE_RING_TYPES (xen_netif_tx, - struct xen_netif_tx_request, +DEFINE_RING_TYPES(xen_netif_tx, struct xen_netif_tx_request, struct xen_netif_tx_response); -DEFINE_RING_TYPES (xen_netif_rx, - struct xen_netif_rx_request, +DEFINE_RING_TYPES(xen_netif_rx, struct xen_netif_rx_request, struct xen_netif_rx_response); -#define XEN_NETIF_RSP_DROPPED -2 -#define XEN_NETIF_RSP_ERROR -1 -#define XEN_NETIF_RSP_OKAY 0 -/* No response: used for auxiliary requests (e.g., xen_netif_extra_info). */ -#define XEN_NETIF_RSP_NULL 1 +#define XEN_NETIF_RSP_DROPPED -2 +#define XEN_NETIF_RSP_ERROR -1 +#define XEN_NETIF_RSP_OKAY 0 +/* No response: used for auxiliary requests (e.g., xen_netif_extra_info_t). */ +#define XEN_NETIF_RSP_NULL 1#endif
Signature · 1 line
2.1.4
PATCH 2/8 xen-netback: remove GSO information from xenvif_rx_meta
In reply to Paul DurrantThe code in net_rx_action() that builds rx responses has direct access to the skb so there is no need to copy this information into the meta structure.
This patch removes the extraneous fields, saves space in the array and removes many lines of code.
--- drivers/net/xen-netback/common.h | 2 -- drivers/net/xen-netback/netback.c | 75 +++++++++++++++------------------------ 2 files changed, 29 insertions(+), 48 deletions(-)
drivers/net/xen-netback/common.h +0 -2
@@ -70,8 +70,6 @@ struct pending_tx_info {struct xenvif_rx_meta {int id;int size; -int gso_type; -int gso_size; };#define GSO_BIT (type) \
drivers/net/xen-netback/netback.c +29 -46
156 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 5/8 skbuff: store hash type in socket buffer...
In reply to Paul Durrant...rather than a boolean merely indicating a canonical L4 hash.
skb_set_hash() takes a hash type (from enum pkt_hash_types) as an argument but information is lost since only a single bit in the skb stores whether that hash type is PKT_HASH_TYPE_L4 or not.
By using two bits it's possible to store the complete hash type information for use by drivers, such as xen-netback when forwarding network packets to VM frontend drivers.
--- drivers/net/bonding/bond_main.c | 2 +- include/linux/skbuff.h | 53 ++++++++++++++++++++++++++++------------- include/net/flow_dissector.h | 5 ++++ include/net/sock.h | 2 +- include/trace/events/net.h | 2 +- net/core/flow_dissector.c | 27 ++++++++++++++++----- 6 files changed, 65 insertions(+), 26 deletions(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -3137,7 +3137,7 @@ u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)u32 hash;if (bond->params.xmit_policy ==BOND_XMIT_POLICY_ENCAP34 && - skb->l4_hash) +skb_has_l4_hash (skb))return skb->hash; if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 ||
include/linux/skbuff.h +36 -17
131 lines not on this page · raw message
include/net/flow_dissector.h +5 -0
@@ -182,6 +182,11 @@ static inline bool flow_keys_have_l4(struct flow_keys *keys) return (keys->ports.ports || keys->tags.flow_label); } +static inline bool flow_keys_have_l3 (struct flow_keys *keys) +{ +return !!keys->control.addr_type; +} +u32 flow_hash_from_keys (struct flow_keys *keys);#endif
include/net/sock.h +1 -1
@@ -1938,7 +1938,7 @@ static inline void sock_poll_wait(struct file *filp,static inline void skb_set_hash_from_sk (struct sk_buff *skb,struct sock *sk) {if (sk->sk_txhash) { - skb->l4_hash =1 ; + skb->hash_type =PKT_HASH_TYPE_L4 ; skb->hash = sk->sk_txhash; } }
include/trace/events/net.h +1 -1
@@ -180,7 +180,7 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template, __entry->protocol =ntohs (skb->protocol); __entry->ip_summed = skb->ip_summed; __entry->hash = skb->hash; - __entry->l4_hash = skb->l4_hash; + __entry->l4_hash = skb->hash_type ==PKT_HASH_TYPE_L4 ; __entry->len = skb->len; __entry->data_len = skb->data_len; __entry->truesize = skb->truesize;
net/core/flow_dissector.c +21 -6
@@ -658,17 +658,30 @@ EXPORT_SYMBOL(make_flow_keys_digest);* * This function calculates a flow hash based on src/dst addresses * and src/dst port numbers. Sets hash in skb to non-zero hash value -* on success, zero indicates no valid hash. Also, sets l4_hash in skb -* if hash is a canonical 4-tuple hash over transport ports. +* on success, zero indicates no valid hash in which case the hash type +* is set to NONE. If the hash is a canonical 4-tuple hash over transport +* ports then type is set to L4. If the hash did not include transport +* then type is set to L3, otherwise it is assumed to be L2 only. */ void __skb_get_hash (struct sk_buff *skb) {struct flow_keys keys; +u32 hash; +enum pkt_hash_types type;__flow_hash_secret_init (); -__skb_set_sw_hash (skb,___skb_get_hash (skb, &keys, hashrnd), -flow_keys_have_l4 (&keys)); + hash =___skb_get_hash (skb, &keys, hashrnd); +if (hash ==0 ) + type =PKT_HASH_TYPE_NONE ; +else if (flow_keys_have_l4 (&keys)) + type =PKT_HASH_TYPE_L4 ; +else if (flow_keys_have_l3 (&keys)) + type =PKT_HASH_TYPE_L3 ; +else + type =PKT_HASH_TYPE_L2 ; + +__skb_set_sw_hash (skb, hash, type); }EXPORT_SYMBOL (__skb_get_hash);
@@ -698,7 +711,8 @@ __u32 __skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6 *fl6) keys.basic.ip_proto = fl6->flowi6_proto;__skb_set_sw_hash (skb,flow_hash_from_keys (&keys), -flow_keys_have_l4 (&keys)); +flow_keys_have_l4 (&keys) ? +PKT_HASH_TYPE_L4 :PKT_HASH_TYPE_L3 );return skb->hash; }
@@ -719,7 +733,8 @@ __u32 __skb_get_hash_flowi4(struct sk_buff *skb, const struct flowi4 *fl4) keys.basic.ip_proto = fl4->flowi4_proto;__skb_set_sw_hash (skb,flow_hash_from_keys (&keys), -flow_keys_have_l4 (&keys)); +flow_keys_have_l4 (&keys) ? +PKT_HASH_TYPE_L4 :PKT_HASH_TYPE_L3 );return skb->hash; }
Signature · 1 line
2.1.4
PATCH 6/8 xen-netback: pass an L4 or L3 skb hash value to the frontend
In reply to Paul DurrantIf the frontend indicates it's capable (see netif.h for details) and an skb has an L4 or L3 hash value then pass the value to the frontend in a xen_netif_extra_info segment.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/netback.c | 85 +++++++++++++++++++++++++++++++-------- drivers/net/xen-netback/xenbus.c | 5 +++ 3 files changed, 75 insertions(+), 16 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -229,6 +229,7 @@ struct xenvif { u8 ip_csum:1; u8 ipv6_csum:1; u8 multicast_control:1; + u8 hash_extra:1;/* Is this interface disabled? True when backend discovers * frontend is rogue.
drivers/net/xen-netback/netback.c +69 -16
117 lines not on this page · raw message
drivers/net/xen-netback/xenbus.c +5 -0
@@ -1037,6 +1037,11 @@ static int read_xenbus_vif_flags(struct backend_info *be) val =0 ; vif->multicast_control = !!val; +if (xenbus_scanf (XBT_NIL , dev->otherend,"feature-hash" , +"%d" , &val) <0 ) + val =0 ; + vif->hash_extra = !!val; +return 0 ; }
Signature · 1 line
2.1.4
PATCH 7/8 xen-netback: add support for a multi-queue hash mapping table
In reply to Paul DurrantAdvertise the capability to handle a hash mapping specified by the frontend (see netif.h for details).
Add an ndo_select() entry point so that, of the frontend does specify a hash mapping, the skb hash is extracted and mapped to a queue. If no mapping is specified then the fallback queue selection function is called so there is no change in behaviour.
--- drivers/net/xen-netback/common.h | 7 ++ drivers/net/xen-netback/interface.c | 14 ++++ drivers/net/xen-netback/xenbus.c | 154 ++++++++++++++++++++++++++++++------ 3 files changed, 152 insertions(+), 23 deletions(-)
drivers/net/xen-netback/common.h +7 -0
@@ -212,6 +212,8 @@ struct xenvif_mcast_addr {#define XEN_NETBK_MCAST_MAX 64 +#define XEN_NETBK_MAX_HASH_MAPPING_SIZE 128 +struct xenvif {/* Unique identifier for this interface. */ domid_t domid;
@@ -244,7 +246,12 @@ struct xenvif {unsigned int num_queues;/* active queues, resource allocated */ unsigned int stalled_queues; +struct { +unsigned int table[XEN_NETBK_MAX_HASH_MAPPING_SIZE ]; +unsigned int length; + } hash_mapping;struct xenbus_watch credit_watch; +struct xenbus_watch hash_mapping_watch;spinlock_t lock;
drivers/net/xen-netback/interface.c +14 -0
@@ -142,6 +142,19 @@ void xenvif_wake_queue(struct xenvif_queue *queue)netif_tx_wake_queue (netdev_get_tx_queue (dev, id)); } +static u16 xenvif_select_queue (struct net_device *dev,struct sk_buff *skb, +void *accel_priv, +select_queue_fallback_t fallback) +{ +struct xenvif *vif =netdev_priv (dev); + +if (vif->hash_mapping.length ==0 ) +return fallback (dev, skb) % dev->real_num_tx_queues; + +return vif->hash_mapping.table[skb_get_hash_raw (skb) % + vif->hash_mapping.length]; +} +static int xenvif_start_xmit (struct sk_buff *skb,struct net_device *dev) {struct xenvif *vif =netdev_priv (dev);
@@ -386,6 +399,7 @@ static const struct ethtool_ops xenvif_ethtool_ops = { };static const struct net_device_ops xenvif_netdev_ops = { + .ndo_select_queue = xenvif_select_queue, .ndo_start_xmit = xenvif_start_xmit, .ndo_get_stats = xenvif_get_stats, .ndo_open = xenvif_open,
drivers/net/xen-netback/xenbus.c +131 -23
193 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 6/8 xen-netback: pass an L4 or L3 skb hash value to the frontend
In reply to Paul DurrantIf the frontend indicates it's capable (see netif.h for details) and an skb has an L4 or L3 hash value then pass the value to the frontend in a xen_netif_extra_info segment.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/netback.c | 85 +++++++++++++++++++++++++++++++-------- drivers/net/xen-netback/xenbus.c | 5 +++ 3 files changed, 75 insertions(+), 16 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -229,6 +229,7 @@ struct xenvif { u8 ip_csum:1; u8 ipv6_csum:1; u8 multicast_control:1; + u8 hash_extra:1;/* Is this interface disabled? True when backend discovers * frontend is rogue.
drivers/net/xen-netback/netback.c +69 -16
117 lines not on this page · raw message
drivers/net/xen-netback/xenbus.c +5 -0
@@ -1037,6 +1037,11 @@ static int read_xenbus_vif_flags(struct backend_info *be) val =0 ; vif->multicast_control = !!val; +if (xenbus_scanf (XBT_NIL , dev->otherend,"feature-hash" , +"%d" , &val) <0 ) + val =0 ; + vif->hash_extra = !!val; +return 0 ; }
Signature · 1 line
2.1.4
PATCH 7/8 xen-netback: add support for a multi-queue hash mapping table
In reply to Paul DurrantAdvertise the capability to handle a hash mapping specified by the frontend (see netif.h for details).
Add an ndo_select() entry point so that, of the frontend does specify a hash mapping, the skb hash is extracted and mapped to a queue. If no mapping is specified then the fallback queue selection function is called so there is no change in behaviour.
--- drivers/net/xen-netback/common.h | 7 ++ drivers/net/xen-netback/interface.c | 14 ++++ drivers/net/xen-netback/xenbus.c | 154 ++++++++++++++++++++++++++++++------ 3 files changed, 152 insertions(+), 23 deletions(-)
drivers/net/xen-netback/common.h +7 -0
@@ -212,6 +212,8 @@ struct xenvif_mcast_addr {#define XEN_NETBK_MCAST_MAX 64 +#define XEN_NETBK_MAX_HASH_MAPPING_SIZE 128 +struct xenvif {/* Unique identifier for this interface. */ domid_t domid;
@@ -244,7 +246,12 @@ struct xenvif {unsigned int num_queues;/* active queues, resource allocated */ unsigned int stalled_queues; +struct { +unsigned int table[XEN_NETBK_MAX_HASH_MAPPING_SIZE ]; +unsigned int length; + } hash_mapping;struct xenbus_watch credit_watch; +struct xenbus_watch hash_mapping_watch;spinlock_t lock;
drivers/net/xen-netback/interface.c +14 -0
@@ -142,6 +142,19 @@ void xenvif_wake_queue(struct xenvif_queue *queue)netif_tx_wake_queue (netdev_get_tx_queue (dev, id)); } +static u16 xenvif_select_queue (struct net_device *dev,struct sk_buff *skb, +void *accel_priv, +select_queue_fallback_t fallback) +{ +struct xenvif *vif =netdev_priv (dev); + +if (vif->hash_mapping.length ==0 ) +return fallback (dev, skb) % dev->real_num_tx_queues; + +return vif->hash_mapping.table[skb_get_hash_raw (skb) % + vif->hash_mapping.length]; +} +static int xenvif_start_xmit (struct sk_buff *skb,struct net_device *dev) {struct xenvif *vif =netdev_priv (dev);
@@ -386,6 +399,7 @@ static const struct ethtool_ops xenvif_ethtool_ops = { };static const struct net_device_ops xenvif_netdev_ops = { + .ndo_select_queue = xenvif_select_queue, .ndo_start_xmit = xenvif_start_xmit, .ndo_get_stats = xenvif_get_stats, .ndo_open = xenvif_open,
drivers/net/xen-netback/xenbus.c +131 -23
193 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 8/8 xen-netback: add support for toeplitz hashing
In reply to Paul DurrantThis patch adds all the necessary infrastructure to allow a frontend to specify toeplitz hashing of network packets on its receive side. (See netif.h for details of the xenbus protocol).
The toeplitz hash algorithm itself was based on pseudo-code provided by Microsoft at:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff570725.aspx
--- drivers/net/xen-netback/common.h | 32 ++++++ drivers/net/xen-netback/interface.c | 111 +++++++++++++++++++- drivers/net/xen-netback/xenbus.c | 195 ++++++++++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+), 3 deletions(-)
drivers/net/xen-netback/common.h +32 -0
@@ -214,6 +214,31 @@ struct xenvif_mcast_addr {#define XEN_NETBK_MAX_HASH_MAPPING_SIZE 128 +enum xenvif_hash_alg { +XEN_NETBK_HASH_UNSPECIFIED , +XEN_NETBK_HASH_TOEPLITZ , +}; + +#define XEN_NETBK_MAX_TOEPLITZ_KEY_LENGTH 40 + +struct xenvif_toeplitz_params { +union { +struct { +u8 ipv4_enabled:1 ; +u8 ipv4_tcp_enabled:1 ; +u8 ipv6_enabled:1 ; +u8 ipv6_tcp_enabled:1 ; + }; +u8 types; + }; + +u8 key[XEN_NETBK_MAX_TOEPLITZ_KEY_LENGTH ]; +}; + +union xenvif_hash_params { +struct xenvif_toeplitz_params toeplitz; +}; +struct xenvif {/* Unique identifier for this interface. */ domid_t domid;
@@ -250,8 +275,15 @@ struct xenvif {unsigned int table[XEN_NETBK_MAX_HASH_MAPPING_SIZE ];unsigned int length; } hash_mapping; + +/* Hash */ +enum xenvif_hash_alg hash_alg; +union xenvif_hash_params hash_params; +struct xenbus_watch credit_watch;struct xenbus_watch hash_mapping_watch; +struct xenbus_watch hash_watch; +struct xenbus_watch hash_params_watch;spinlock_t lock;
drivers/net/xen-netback/interface.c +108 -3
125 lines not on this page · raw message
drivers/net/xen-netback/xenbus.c +195 -0
229 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 8/8 xen-netback: add support for toeplitz hashing
In reply to Paul DurrantThis patch adds all the necessary infrastructure to allow a frontend to specify toeplitz hashing of network packets on its receive side. (See netif.h for details of the xenbus protocol).
The toeplitz hash algorithm itself was based on pseudo-code provided by Microsoft at:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff570725.aspx
--- drivers/net/xen-netback/common.h | 32 ++++++ drivers/net/xen-netback/interface.c | 111 +++++++++++++++++++- drivers/net/xen-netback/xenbus.c | 195 ++++++++++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+), 3 deletions(-)
drivers/net/xen-netback/common.h +32 -0
@@ -214,6 +214,31 @@ struct xenvif_mcast_addr {#define XEN_NETBK_MAX_HASH_MAPPING_SIZE 128 +enum xenvif_hash_alg { +XEN_NETBK_HASH_UNSPECIFIED , +XEN_NETBK_HASH_TOEPLITZ , +}; + +#define XEN_NETBK_MAX_TOEPLITZ_KEY_LENGTH 40 + +struct xenvif_toeplitz_params { +union { +struct { +u8 ipv4_enabled:1 ; +u8 ipv4_tcp_enabled:1 ; +u8 ipv6_enabled:1 ; +u8 ipv6_tcp_enabled:1 ; + }; +u8 types; + }; + +u8 key[XEN_NETBK_MAX_TOEPLITZ_KEY_LENGTH ]; +}; + +union xenvif_hash_params { +struct xenvif_toeplitz_params toeplitz; +}; +struct xenvif {/* Unique identifier for this interface. */ domid_t domid;
@@ -250,8 +275,15 @@ struct xenvif {unsigned int table[XEN_NETBK_MAX_HASH_MAPPING_SIZE ];unsigned int length; } hash_mapping; + +/* Hash */ +enum xenvif_hash_alg hash_alg; +union xenvif_hash_params hash_params; +struct xenbus_watch credit_watch;struct xenbus_watch hash_mapping_watch; +struct xenbus_watch hash_watch; +struct xenbus_watch hash_params_watch;spinlock_t lock;
drivers/net/xen-netback/interface.c +108 -3
125 lines not on this page · raw message
drivers/net/xen-netback/xenbus.c +195 -0
229 lines not on this page · raw message
Signature · 1 line
2.1.4
David Miller
maintainerFrom: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100
Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
I'd definitely like to see some XEN networking experts review this before I apply it.
David Miller
maintainerFrom: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100
Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
I'd definitely like to see some XEN networking experts review this before I apply it.
David Miller
maintainerFrom: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100
Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Ping, I want to see some review from some other xen networking folks.
Thanks.
David Miller
maintainerFrom: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100
Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Ping, I want to see some review from some other xen networking folks.
Thanks.
Quoted 8 lines · David Miller
From: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Ping, I want to see some review from some other xen networking folks.
There's been some review of the front/back protocol (on a different thread) and some significant changes have been suggested.
David
Quoted 8 lines · David Miller
From: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Ping, I want to see some review from some other xen networking folks.
There's been some review of the front/back protocol (on a different thread) and some significant changes have been suggested.
David
David Miller
maintainerFrom: David Vrabel <[email protected]>
Date: Mon, 26 Oct 2015 10:38:50 +0000
Quoted 12 lines · David Miller
Quoted 8 lines
From: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Ping, I want to see some review from some other xen networking folks.
There's been some review of the front/back protocol (on a different thread) and some significant changes have been suggested.
Ok, I'll mark this series as "changes requested" then, thanks.
David Miller
maintainerFrom: David Vrabel <[email protected]>
Date: Mon, 26 Oct 2015 10:38:50 +0000
Quoted 12 lines · David Miller
Quoted 8 lines
From: Paul Durrant <[email protected]>
Date: Wed, 21 Oct 2015 11:36:17 +0100Quoted 3 lines
This series adds xen-netback support for hash negotiation with a frontend driver, and an implementation of toeplitz hashing as the initial negotiable algorithm.
Ping, I want to see some review from some other xen networking folks.
There's been some review of the front/back protocol (on a different thread) and some significant changes have been suggested.
Ok, I'll mark this series as "changes requested" then, thanks.
Re: [PATCH net-next 4/8] xen-netback: accept an L4 or L3 skb hash value from the frontend
In reply to Paul DurrantQuoted 8 lines · Paul Durrant
This patch adds an indication that netback is capable of handling hash values passed from the frontend (see
netif.hfor details), and the code necessary to process the additionalxen_netif_extra_infosegment and set a hash on the skb.Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
[...]
drivers/net/xen-netback/xenbus.c static int netback_probe(struct xenbus_device *dev, · line 343
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +6
-0+/* We support hash values. */ + err =xenbus_printf (xbt, dev->nodename, +"feature-hash" ,"%d" ,1 ); +if (err) { + message ="writing feature-hash" ; + goto abort_transaction;
Feel free to retain my reviewed-by if this changes in next version.
Wei.
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +2
-0+ } + err =xenbus_transaction_end (xbt,0 ); }while (err == -EAGAIN );Signature · 2 lines
-- 2.1.4
Re: [PATCH net-next 4/8] xen-netback: accept an L4 or L3 skb hash value from the frontend
In reply to Paul DurrantQuoted 8 lines · Paul Durrant
This patch adds an indication that netback is capable of handling hash values passed from the frontend (see
netif.hfor details), and the code necessary to process the additionalxen_netif_extra_infosegment and set a hash on the skb.Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
[...]
drivers/net/xen-netback/xenbus.c static int netback_probe(struct xenbus_device *dev, · line 343
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +6
-0+/* We support hash values. */ + err =xenbus_printf (xbt, dev->nodename, +"feature-hash" ,"%d" ,1 ); +if (err) { + message ="writing feature-hash" ; + goto abort_transaction;
Feel free to retain my reviewed-by if this changes in next version.
Wei.
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +2
-0+ } + err =xenbus_transaction_end (xbt,0 ); }while (err == -EAGAIN );Signature · 2 lines
-- 2.1.4
Re: [PATCH net-next 7/8] xen-netback: add support for a multi-queue hash mapping table
In reply to Paul DurrantQuoted 4 lines · Paul Durrant
Advertise the capability to handle a hash mapping specified by the frontend (see
netif.hfor details).Add an
ndo_select()entry point so that, of the frontend does specify a
"if the frontend ..."
Quoted 5 lines
hash mapping, the skb hash is extracted and mapped to a queue. If no mapping is specified then the fallback queue selection function is called so there is no change in behaviour.
Signed-off-by Paul Durrant <[email protected]>
[...]
drivers/net/xen-netback/xenbus.c static void xen_net_rate_changed(struct xenbus_watch *watch, · line 771
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +7
-0+static void xen_hash_mapping_changed (struct xenbus_watch *watch, +const char **vec,unsigned int len) +{ + struct xenvif *vif = container_of(watch, struct xenvif, + hash_mapping_watch); + +xen_net_read_multi_queue_hash_mapping (vif);
Is it safe / correct to not stop the vif before changing mapping table?
Wei.
Re: [PATCH net-next 7/8] xen-netback: add support for a multi-queue hash mapping table
In reply to Paul DurrantQuoted 4 lines · Paul Durrant
Advertise the capability to handle a hash mapping specified by the frontend (see
netif.hfor details).Add an
ndo_select()entry point so that, of the frontend does specify a
"if the frontend ..."
Quoted 5 lines
hash mapping, the skb hash is extracted and mapped to a queue. If no mapping is specified then the fallback queue selection function is called so there is no change in behaviour.
Signed-off-by Paul Durrant <[email protected]>
[...]
drivers/net/xen-netback/xenbus.c static void xen_net_rate_changed(struct xenbus_watch *watch, · line 771
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +7
-0+static void xen_hash_mapping_changed (struct xenbus_watch *watch, +const char **vec,unsigned int len) +{ + struct xenvif *vif = container_of(watch, struct xenvif, + hash_mapping_watch); + +xen_net_read_multi_queue_hash_mapping (vif);
Is it safe / correct to not stop the vif before changing mapping table?
Wei.
Re: [PATCH net-next 1/8] xen-netback: re-import canonical netif header
In reply to Paul DurrantQuoted 29 lines · Paul Durrant
The canonical netif header (in the Xen source repo) and the Linux variant have diverged significantly. Recently much documentation has been added to the canonical header and new definitions and types to support packet hash configuration. Subsequent patches in this series add support for packet hash configuration in xen-netback so this patch re-imports the canonical header in readiness.
To maintain compatibility and some style consistency with the old Linux variant, the header was stripped of its emacs boilerplate, and post-processed and copied into place with the following commands:
ed -s
netif.h<< EOF
H
,s/NETTXF_/XEN_NETTXF_/g
,s/NETRXF_/XEN_NETRXF_/g
,s/NETIF_RSP/XEN_NETIF_RSP/g
,s/netif_tx/xen_netif_tx/g
,s/netif_rx/xen_netif_rx/g
,s/netif_extra_info/xen_netif_extra_info/g
w
EOFindent --linux-style
netif.h-oinclude/xen/interface/io/netif.hSigned-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>Cc Wei Liu <[email protected]>
Quoted 6 lines
---
Whilst awaiting review of my patches to the canonical
netif.h, import has been done from my staging branch using:
There is on-going discussion on this so I'm going to skip this patch for now.
Wei.
Re: [PATCH net-next 1/8] xen-netback: re-import canonical netif header
In reply to Paul DurrantQuoted 29 lines · Paul Durrant
The canonical netif header (in the Xen source repo) and the Linux variant have diverged significantly. Recently much documentation has been added to the canonical header and new definitions and types to support packet hash configuration. Subsequent patches in this series add support for packet hash configuration in xen-netback so this patch re-imports the canonical header in readiness.
To maintain compatibility and some style consistency with the old Linux variant, the header was stripped of its emacs boilerplate, and post-processed and copied into place with the following commands:
ed -s
netif.h<< EOF
H
,s/NETTXF_/XEN_NETTXF_/g
,s/NETRXF_/XEN_NETRXF_/g
,s/NETIF_RSP/XEN_NETIF_RSP/g
,s/netif_tx/xen_netif_tx/g
,s/netif_rx/xen_netif_rx/g
,s/netif_extra_info/xen_netif_extra_info/g
w
EOFindent --linux-style
netif.h-oinclude/xen/interface/io/netif.hSigned-off-by Paul Durrant <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc David Vrabel <[email protected]>Cc Wei Liu <[email protected]>
Quoted 6 lines
---
Whilst awaiting review of my patches to the canonical
netif.h, import has been done from my staging branch using:
There is on-going discussion on this so I'm going to skip this patch for now.
Wei.
Re: [PATCH net-next 2/8] xen-netback: remove GSO information from xenvif_rx_meta
In reply to Paul DurrantQuoted 10 lines · Paul Durrant
The code in
net_rx_action()that builds rx responses has direct access to the skb so there is no need to copy this information into the meta structure.This patch removes the extraneous fields, saves space in the array and removes many lines of code.
Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Re: [PATCH net-next 2/8] xen-netback: remove GSO information from xenvif_rx_meta
In reply to Paul DurrantQuoted 10 lines · Paul Durrant
The code in
net_rx_action()that builds rx responses has direct access to the skb so there is no need to copy this information into the meta structure.This patch removes the extraneous fields, saves space in the array and removes many lines of code.
Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Re: [PATCH net-next 3/8] xen-netback: support multiple extra info segments passed from frontend
In reply to Paul DurrantQuoted 8 lines · Paul Durrant
The code does not currently allow a frontend to pass multiple extra info segments to the backend in a tx request. A subsequent patch in this series needs this functionality so it is added here, without any other modification, for better bisectability.
Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Re: [PATCH net-next 3/8] xen-netback: support multiple extra info segments passed from frontend
In reply to Paul DurrantQuoted 8 lines · Paul Durrant
The code does not currently allow a frontend to pass multiple extra info segments to the backend in a tx request. A subsequent patch in this series needs this functionality so it is added here, without any other modification, for better bisectability.
Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Re: [PATCH net-next 6/8] xen-netback: pass an L4 or L3 skb hash value to the frontend
In reply to Paul DurrantQuoted 7 lines · Paul Durrant
If the frontend indicates it's capable (see
netif.hfor details) and an skb has an L4 or L3 hash value then pass the value to the frontend in axen_netif_extra_infosegment.Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
drivers/net/xen-netback/netback.c static inline pending_ring_idx_t pending_index(unsigned i) · line 157
Quoted 7 lines
static int
xenvif_rx_ring_slots_needed(struct xenvif *vif){drivers/net/xen-netback/netback.c +3
-2-if (vif->gso_mask) -return DIV_ROUND_UP (vif->dev->gso_max_size,PAGE_SIZE ) +1 ; +int needed; + +if (vif->gso_mask || vif->gso_prefix_mask)
It seems like this line should become a patch for -stable?
drivers/net/xen-netback/xenbus.c static int read_xenbus_vif_flags(struct backend_info *be) · line 1042
Quoted 12 lines
drivers/net/xen-netback/netback.c +0
-0xenvif_add_frag_responses(queue, status,drivers/net/xen-netback/xenbus.c +3
-0@@ -1037,6 +1037,11 @@ static int read_xenbus_vif_flags(struct backend_info *be) val =0 ; vif->multicast_control = !!val; +if (xenbus_scanf (XBT_NIL , dev->otherend,"feature-hash" , +"%d" , &val) <0 ) + val =0 ;
Again, feel free to retain my reviewed-by if this changes in next version.
Wei.
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +2
-0+ vif->hash_extra = !!val; +return 0 ; }Signature · 1 line
2.1.4
Re: [PATCH net-next 6/8] xen-netback: pass an L4 or L3 skb hash value to the frontend
In reply to Paul DurrantQuoted 7 lines · Paul Durrant
If the frontend indicates it's capable (see
netif.hfor details) and an skb has an L4 or L3 hash value then pass the value to the frontend in axen_netif_extra_infosegment.Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
drivers/net/xen-netback/netback.c static inline pending_ring_idx_t pending_index(unsigned i) · line 157
Quoted 7 lines
static int
xenvif_rx_ring_slots_needed(struct xenvif *vif){drivers/net/xen-netback/netback.c +3
-2-if (vif->gso_mask) -return DIV_ROUND_UP (vif->dev->gso_max_size,PAGE_SIZE ) +1 ; +int needed; + +if (vif->gso_mask || vif->gso_prefix_mask)
It seems like this line should become a patch for -stable?
drivers/net/xen-netback/xenbus.c static int read_xenbus_vif_flags(struct backend_info *be) · line 1042
Quoted 12 lines
drivers/net/xen-netback/netback.c +0
-0xenvif_add_frag_responses(queue, status,drivers/net/xen-netback/xenbus.c +3
-0@@ -1037,6 +1037,11 @@ static int read_xenbus_vif_flags(struct backend_info *be) val =0 ; vif->multicast_control = !!val; +if (xenbus_scanf (XBT_NIL , dev->otherend,"feature-hash" , +"%d" , &val) <0 ) + val =0 ;
Again, feel free to retain my reviewed-by if this changes in next version.
Wei.
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +2
-0+ vif->hash_extra = !!val; +return 0 ; }Signature · 1 line
2.1.4
Re: [PATCH net-next 8/8] xen-netback: add support for toeplitz hashing
In reply to Paul DurrantQuoted 12 lines · Paul Durrant
This patch adds all the necessary infrastructure to allow a frontend to specify toeplitz hashing of network packets on its receive side. (See
netif.hfor details of the xenbus protocol).The toeplitz hash algorithm itself was based on pseudo-code provided by Microsoft at:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff570725.aspx
Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
[...]
drivers/net/xen-netback/interface.c void xenvif_wake_queue(struct xenvif_queue *queue) · line 144
Quoted 9 lines
drivers/net/xen-netback/interface.c +0
-0@@ -142,17 +142,122 @@ void xenvif_wake_queue(struct xenvif_queue *queue)netif_tx_wake_queue (netdev_get_tx_queue (dev, id)); }
I skipped the hash implementation because I don't think I know enough to tell if it is correct or not, and protocol negotiation because I think that's going to change in next version.
drivers/net/xen-netback/interface.c void xenvif_wake_queue(struct xenvif_queue *queue) · line 152
Quoted 8 lines
drivers/net/xen-netback/interface.c +8
-0+ + +static void xen_net_read_toeplitz_key (struct xenvif *vif, +const char *node) +{ +struct xenbus_device *dev =xenvif_to_xenbus_device (vif); +char *str, *token; +u8 key[40 ];
This should use the macro.
Quoted 40 lines
drivers/net/xen-netback/interface.c +40
-0+unsigned int n, i; + + str =xenbus_read (XBT_NIL , node,"key" ,NULL ); +if (IS_ERR (str)) + goto fail1; + +memset (key,0 ,sizeof (key)); + + n =0 ; +while ((token =strsep (&str,"," )) !=NULL ) { +int rc; + +if (n >=ARRAY_SIZE (vif->hash_params.toeplitz.key)) { +pr_err ("%s: key too big\n" , + dev->nodename); + goto fail2; + } + + rc =kstrtou8 (token,0 , &key[n]); +if (rc <0 ) { +pr_err ("%s: invalid key value (%s at index %u)\n" , + dev->nodename, token, n); + goto fail2; + } + + n++; + } + +for (i =0 ; i <ARRAY_SIZE (vif->hash_params.toeplitz.key); i++) + vif->hash_params.toeplitz.key[i] = key[i]; + +kfree (str); +return ; + +fail2: +kfree (str); +fail1: + vif->hash_params.toeplitz.types =0 ; +} +
[...]
drivers/net/xen-netback/interface.c
Quoted 7 lines
drivers/net/xen-netback/interface.c +7
-0+ +static void xen_hash_changed (struct xenbus_watch *watch, +const char **vec,unsigned int len) +{ + struct xenvif *vif = container_of(watch, struct xenvif, hash_watch); + +xen_net_read_hash (vif);
I think the same question for previous patch applies here, too.
Is there any concern of correctness and security implication that you just change the hash without stopping the vif?
Wei.
Re: [PATCH net-next 8/8] xen-netback: add support for toeplitz hashing
In reply to Paul DurrantQuoted 12 lines · Paul Durrant
This patch adds all the necessary infrastructure to allow a frontend to specify toeplitz hashing of network packets on its receive side. (See
netif.hfor details of the xenbus protocol).The toeplitz hash algorithm itself was based on pseudo-code provided by Microsoft at:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff570725.aspx
Signed-off-by Paul Durrant <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
[...]
drivers/net/xen-netback/interface.c void xenvif_wake_queue(struct xenvif_queue *queue) · line 144
Quoted 9 lines
drivers/net/xen-netback/interface.c +0
-0@@ -142,17 +142,122 @@ void xenvif_wake_queue(struct xenvif_queue *queue)netif_tx_wake_queue (netdev_get_tx_queue (dev, id)); }
I skipped the hash implementation because I don't think I know enough to tell if it is correct or not, and protocol negotiation because I think that's going to change in next version.
drivers/net/xen-netback/interface.c void xenvif_wake_queue(struct xenvif_queue *queue) · line 152
Quoted 8 lines
drivers/net/xen-netback/interface.c +8
-0+ + +static void xen_net_read_toeplitz_key (struct xenvif *vif, +const char *node) +{ +struct xenbus_device *dev =xenvif_to_xenbus_device (vif); +char *str, *token; +u8 key[40 ];
This should use the macro.
Quoted 40 lines
drivers/net/xen-netback/interface.c +40
-0+unsigned int n, i; + + str =xenbus_read (XBT_NIL , node,"key" ,NULL ); +if (IS_ERR (str)) + goto fail1; + +memset (key,0 ,sizeof (key)); + + n =0 ; +while ((token =strsep (&str,"," )) !=NULL ) { +int rc; + +if (n >=ARRAY_SIZE (vif->hash_params.toeplitz.key)) { +pr_err ("%s: key too big\n" , + dev->nodename); + goto fail2; + } + + rc =kstrtou8 (token,0 , &key[n]); +if (rc <0 ) { +pr_err ("%s: invalid key value (%s at index %u)\n" , + dev->nodename, token, n); + goto fail2; + } + + n++; + } + +for (i =0 ; i <ARRAY_SIZE (vif->hash_params.toeplitz.key); i++) + vif->hash_params.toeplitz.key[i] = key[i]; + +kfree (str); +return ; + +fail2: +kfree (str); +fail1: + vif->hash_params.toeplitz.types =0 ; +} +
[...]
drivers/net/xen-netback/interface.c
Quoted 7 lines
drivers/net/xen-netback/interface.c +7
-0+ +static void xen_hash_changed (struct xenbus_watch *watch, +const char **vec,unsigned int len) +{ + struct xenvif *vif = container_of(watch, struct xenvif, hash_watch); + +xen_net_read_hash (vif);
I think the same question for previous patch applies here, too.
Is there any concern of correctness and security implication that you just change the hash without stopping the vif?
Wei.