Yuri Benditovich
2020-Mar-01 14:32 UTC
[PATCH v3 0/3] virtio-net: introduce features defined in the spec
This series introduce virtio-net features VIRTIO_NET_F_RSC_EXT, VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. Changes from v2: reformatted structure in patch 1 Yuri Benditovich (3): virtio-net: Introduce extended RSC feature virtio-net: Introduce RSS receive steering feature virtio-net: Introduce hash report feature include/uapi/linux/virtio_net.h | 100 ++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) -- 2.17.1
Yuri Benditovich
2020-Mar-01 14:33 UTC
[PATCH v3 1/3] virtio-net: Introduce extended RSC feature
VIRTIO_NET_F_RSC_EXT feature bit indicates that the device is able to provide extended RSC information. When the feature is negotiatede and 'gso_type' field in received packet is not GSO_NONE, the device reports number of coalesced packets in 'csum_start' field and number of duplicated acks in 'csum_offset' field and sets VIRTIO_NET_HDR_F_RSC_INFO in 'flags' field. Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- include/uapi/linux/virtio_net.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index a3715a3224c1..19e76b3e3a64 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -57,6 +57,7 @@ * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device * with the same MAC. */ @@ -104,6 +105,7 @@ struct virtio_net_config { struct virtio_net_hdr_v1 { #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ +#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ __u8 flags; #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ @@ -113,8 +115,24 @@ struct virtio_net_hdr_v1 { __u8 gso_type; __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ - __virtio16 csum_start; /* Position to start checksumming from */ - __virtio16 csum_offset; /* Offset after that to place checksum */ + union { + struct { + __virtio16 csum_start; + __virtio16 csum_offset; + }; + struct { + /* Position to start checksumming from */ + __virtio16 start; + /* Offset after that to place checksum */ + __virtio16 offset; + } csum; + struct { + /* num of coalesced packets */ + __le16 packets; + /* num of duplicated acks */ + __le16 dup_acks; + } rsc; + }; __virtio16 num_buffers; /* Number of merged rx buffers */ }; -- 2.17.1
Yuri Benditovich
2020-Mar-01 14:33 UTC
[PATCH v3 2/3] virtio-net: Introduce RSS receive steering feature
RSS (Receive-side scaling) defines hash calculation rules and decision on receive virtqueue according to the calculated hash, provided mask to apply and provided indirection table containing indices of receive virqueues. The driver sends the control command to enable multiqueue and provide parameters for receive steering. Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- include/uapi/linux/virtio_net.h | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index 19e76b3e3a64..188ad3eecdc8 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -57,6 +57,7 @@ * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device * with the same MAC. @@ -70,6 +71,17 @@ #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ +/* supported/enabled hash types */ +#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) +#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) +#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) +#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) +#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) + struct virtio_net_config { /* The config defining mac address (if VIRTIO_NET_F_MAC) */ __u8 mac[ETH_ALEN]; @@ -93,6 +105,12 @@ struct virtio_net_config { * Any other value stands for unknown. */ __u8 duplex; + /* maximum size of RSS key */ + __u8 rss_max_key_size; + /* maximum number of indirection table entries */ + __le16 rss_max_indirection_table_length; + /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ + __le32 supported_hash_types; } __attribute__((packed)); /* @@ -246,7 +264,9 @@ struct virtio_net_ctrl_mac { /* * Control Receive Flow Steering - * + */ +#define VIRTIO_NET_CTRL_MQ 4 +/* * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET * enables Receive Flow Steering, specifying the number of the transmit and * receive queues that will be used. After the command is consumed and acked by @@ -259,11 +279,29 @@ struct virtio_net_ctrl_mq { __virtio16 virtqueue_pairs; }; -#define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 +/* + * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as + * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures + * the receive steering to use a hash calculated for incoming packet + * to decide on receive virtqueue to place the packet. The command + * also provides parameters to calculate a hash and receive virtqueue. + */ +struct virtio_net_rss_config { + __le32 hash_types; + __le16 indirection_table_mask; + __le16 unclassified_queue; + __le16 indirection_table[1/* + indirection_table_mask */]; + __le16 max_tx_vq; + __u8 hash_key_length; + __u8 hash_key_data[/* hash_key_length */]; +}; + + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 + /* * Control network offloads * -- 2.17.1
Yuri Benditovich
2020-Mar-01 14:33 UTC
[PATCH v3 3/3] virtio-net: Introduce hash report feature
The feature VIRTIO_NET_F_HASH_REPORT extends the layout of the packet and requests the device to calculate hash on incoming packets and report it in the packet header. Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- include/uapi/linux/virtio_net.h | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index 188ad3eecdc8..4bd940501ba6 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -57,6 +57,7 @@ * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device @@ -154,6 +155,23 @@ struct virtio_net_hdr_v1 { __virtio16 num_buffers; /* Number of merged rx buffers */ }; +struct virtio_net_hdr_v1_hash { + struct virtio_net_hdr_v1 hdr; + __le32 hash_value; +#define VIRTIO_NET_HASH_REPORT_NONE 0 +#define VIRTIO_NET_HASH_REPORT_IPv4 1 +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 +#define VIRTIO_NET_HASH_REPORT_IPv6 4 +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 + __le16 hash_report; + __le16 padding; +}; + #ifndef VIRTIO_NET_NO_LEGACY /* This header comes first in the scatter-gather list. * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must @@ -302,6 +320,24 @@ struct virtio_net_rss_config { #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 +/* + * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device + * to include in the virtio header of the packet the value of the + * calculated hash and the report type of hash. It also provides + * parameters for hash calculation. The command requires feature + * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the + * layout of virtio header as defined in virtio_net_hdr_v1_hash. + */ +struct virtio_net_hash_config { + __le32 hash_types; + /* for compatibility with virtio_net_rss_config */ + __le16 reserved[4]; + __u8 hash_key_length; + __u8 hash_key_data[/* hash_key_length */]; +}; + + #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 + /* * Control network offloads * -- 2.17.1
Michael S. Tsirkin
2020-Mar-01 19:58 UTC
[PATCH v3 2/3] virtio-net: Introduce RSS receive steering feature
On Sun, Mar 01, 2020 at 04:33:01PM +0200, Yuri Benditovich wrote:> RSS (Receive-side scaling) defines hash calculation > rules and decision on receive virtqueue according to > the calculated hash, provided mask to apply and > provided indirection table containing indices of > receive virqueues. The driver sends the control > command to enable multiqueue and provide parameters > for receive steering. > > Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> > --- > include/uapi/linux/virtio_net.h | 42 +++++++++++++++++++++++++++++++-- > 1 file changed, 40 insertions(+), 2 deletions(-) > > diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h > index 19e76b3e3a64..188ad3eecdc8 100644 > --- a/include/uapi/linux/virtio_net.h > +++ b/include/uapi/linux/virtio_net.h > @@ -57,6 +57,7 @@ > * Steering */ > #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ > > +#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ > #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ > #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device > * with the same MAC. > @@ -70,6 +71,17 @@ > #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ > #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ > > +/* supported/enabled hash types */ > +#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) > +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) > +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) > +#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) > +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) > +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) > +#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) > +#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) > +#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) > + > struct virtio_net_config { > /* The config defining mac address (if VIRTIO_NET_F_MAC) */ > __u8 mac[ETH_ALEN]; > @@ -93,6 +105,12 @@ struct virtio_net_config { > * Any other value stands for unknown. > */ > __u8 duplex; > + /* maximum size of RSS key */ > + __u8 rss_max_key_size; > + /* maximum number of indirection table entries */ > + __le16 rss_max_indirection_table_length; > + /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ > + __le32 supported_hash_types; > } __attribute__((packed)); > > /* > @@ -246,7 +264,9 @@ struct virtio_net_ctrl_mac { > > /* > * Control Receive Flow Steering > - * > + */ > +#define VIRTIO_NET_CTRL_MQ 4 > +/* > * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET > * enables Receive Flow Steering, specifying the number of the transmit and > * receive queues that will be used. After the command is consumed and acked by > @@ -259,11 +279,29 @@ struct virtio_net_ctrl_mq { > __virtio16 virtqueue_pairs; > }; > > -#define VIRTIO_NET_CTRL_MQ 4 > #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 > #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 > #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 > > +/* > + * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as > + * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures > + * the receive steering to use a hash calculated for incoming packet > + * to decide on receive virtqueue to place the packet. The command > + * also provides parameters to calculate a hash and receive virtqueue. > + */ > +struct virtio_net_rss_config { > + __le32 hash_types; > + __le16 indirection_table_mask; > + __le16 unclassified_queue; > + __le16 indirection_table[1/* + indirection_table_mask */]; > + __le16 max_tx_vq; > + __u8 hash_key_length; > + __u8 hash_key_data[/* hash_key_length */]; > +}; > + > + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 > +Extra space here.> /* > * Control network offloads > * > -- > 2.17.1
Michael S. Tsirkin
2020-Mar-01 20:06 UTC
[PATCH v3 1/3] virtio-net: Introduce extended RSC feature
On Sun, Mar 01, 2020 at 04:33:00PM +0200, Yuri Benditovich wrote:> VIRTIO_NET_F_RSC_EXT feature bit indicates that the device > is able to provide extended RSC information. When the feature > is negotiatede and 'gso_type' field in received packet is not > GSO_NONE, the device reports number of coalesced packets in > 'csum_start' field and number of duplicated acks in 'csum_offset' > field and sets VIRTIO_NET_HDR_F_RSC_INFO in 'flags' field. > > Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> > --- > include/uapi/linux/virtio_net.h | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > > diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h > index a3715a3224c1..19e76b3e3a64 100644 > --- a/include/uapi/linux/virtio_net.h > +++ b/include/uapi/linux/virtio_net.h > @@ -57,6 +57,7 @@ > * Steering */ > #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ > > +#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ > #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device > * with the same MAC. > */ > @@ -104,6 +105,7 @@ struct virtio_net_config { > struct virtio_net_hdr_v1 { > #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ > #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ > +#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ > __u8 flags; > #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ > #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ > @@ -113,8 +115,24 @@ struct virtio_net_hdr_v1 { > __u8 gso_type; > __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ > __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ > - __virtio16 csum_start; /* Position to start checksumming from */ > - __virtio16 csum_offset; /* Offset after that to place checksum */ > + union { > + struct { > + __virtio16 csum_start; > + __virtio16 csum_offset; > + };Pls add comments for this one as well.> + struct { > + /* Position to start checksumming from */ > + __virtio16 start; > + /* Offset after that to place checksum */ > + __virtio16 offset; > + } csum;Can we add a comment for csum field pls? E.g. /* Checksum calculation */> + struct { > + /* num of coalesced packets */num -> Number? Don't abbreviate and upper case for consistency.> + __le16 packets;packets -> coalesced_packets? Or is coalesced segments in fact better?> + /* num of duplicated acks */num -> Number? Don't abbreviate and upper case for consistency.> + __le16 dup_acks; > + } rsc;/* Receive Segment Coalescing report */> + }; > __virtio16 num_buffers; /* Number of merged rx buffers */ > }; > > -- > 2.17.1
Michael S. Tsirkin
2020-Mar-01 20:06 UTC
[PATCH v3 0/3] virtio-net: introduce features defined in the spec
On Sun, Mar 01, 2020 at 04:32:59PM +0200, Yuri Benditovich wrote:> This series introduce virtio-net features VIRTIO_NET_F_RSC_EXT, > VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. > > Changes from v2: reformatted structure in patch 1Looks good but I cound a couple more nits. Sorry I missed them on the previous read.> Yuri Benditovich (3): > virtio-net: Introduce extended RSC feature > virtio-net: Introduce RSS receive steering feature > virtio-net: Introduce hash report feature > > include/uapi/linux/virtio_net.h | 100 ++++++++++++++++++++++++++++++-- > 1 file changed, 96 insertions(+), 4 deletions(-) > > -- > 2.17.1
Jason Wang
2020-Mar-02 04:31 UTC
[PATCH v3 0/3] virtio-net: introduce features defined in the spec
On 2020/3/2 ??4:06, Michael S. Tsirkin wrote:> On Sun, Mar 01, 2020 at 04:32:59PM +0200, Yuri Benditovich wrote: >> This series introduce virtio-net features VIRTIO_NET_F_RSC_EXT, >> VIRTIO_NET_F_RSS and VIRTIO_NET_F_HASH_REPORT. >> >> Changes from v2: reformatted structure in patch 1 > > Looks good but I cound a couple more nits. Sorry I missed them > on the previous read.Do we want to merge this without the actual users in kernel? Thanks> >> Yuri Benditovich (3): >> virtio-net: Introduce extended RSC feature >> virtio-net: Introduce RSS receive steering feature >> virtio-net: Introduce hash report feature >> >> include/uapi/linux/virtio_net.h | 100 ++++++++++++++++++++++++++++++-- >> 1 file changed, 96 insertions(+), 4 deletions(-) >> >> -- >> 2.17.1
Seemingly Similar Threads
- [PATCH v3 2/3] virtio-net: Introduce RSS receive steering feature
- [PATCH v3 2/3] virtio-net: Introduce RSS receive steering feature
- [PATCH v3 2/3] virtio-net: Introduce RSS receive steering feature
- [PATCH v3 0/3] virtio-net: introduce features defined in the spec
- [PATCH v3 0/3] virtio-net: introduce features defined in the spec