| .. | .. |
|---|
| 57 | 57 | * Steering */ |
|---|
| 58 | 58 | #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ |
|---|
| 59 | 59 | |
|---|
| 60 | +#define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ |
|---|
| 61 | +#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ |
|---|
| 62 | +#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ |
|---|
| 60 | 63 | #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device |
|---|
| 61 | 64 | * with the same MAC. |
|---|
| 62 | 65 | */ |
|---|
| .. | .. |
|---|
| 69 | 72 | #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ |
|---|
| 70 | 73 | #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ |
|---|
| 71 | 74 | |
|---|
| 75 | +/* supported/enabled hash types */ |
|---|
| 76 | +#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) |
|---|
| 77 | +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) |
|---|
| 78 | +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) |
|---|
| 79 | +#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) |
|---|
| 80 | +#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) |
|---|
| 81 | +#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) |
|---|
| 82 | +#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) |
|---|
| 83 | +#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) |
|---|
| 84 | +#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) |
|---|
| 85 | + |
|---|
| 72 | 86 | struct virtio_net_config { |
|---|
| 73 | 87 | /* The config defining mac address (if VIRTIO_NET_F_MAC) */ |
|---|
| 74 | 88 | __u8 mac[ETH_ALEN]; |
|---|
| 75 | 89 | /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ |
|---|
| 76 | | - __u16 status; |
|---|
| 90 | + __virtio16 status; |
|---|
| 77 | 91 | /* Maximum number of each of transmit and receive queues; |
|---|
| 78 | 92 | * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. |
|---|
| 79 | 93 | * Legal values are between 1 and 0x8000 |
|---|
| 80 | 94 | */ |
|---|
| 81 | | - __u16 max_virtqueue_pairs; |
|---|
| 95 | + __virtio16 max_virtqueue_pairs; |
|---|
| 82 | 96 | /* Default maximum transmit unit advice */ |
|---|
| 83 | | - __u16 mtu; |
|---|
| 97 | + __virtio16 mtu; |
|---|
| 84 | 98 | /* |
|---|
| 85 | 99 | * speed, in units of 1Mb. All values 0 to INT_MAX are legal. |
|---|
| 86 | 100 | * Any other value stands for unknown. |
|---|
| 87 | 101 | */ |
|---|
| 88 | | - __u32 speed; |
|---|
| 102 | + __le32 speed; |
|---|
| 89 | 103 | /* |
|---|
| 90 | 104 | * 0x00 - half duplex |
|---|
| 91 | 105 | * 0x01 - full duplex |
|---|
| 92 | 106 | * Any other value stands for unknown. |
|---|
| 93 | 107 | */ |
|---|
| 94 | 108 | __u8 duplex; |
|---|
| 109 | + /* maximum size of RSS key */ |
|---|
| 110 | + __u8 rss_max_key_size; |
|---|
| 111 | + /* maximum number of indirection table entries */ |
|---|
| 112 | + __le16 rss_max_indirection_table_length; |
|---|
| 113 | + /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ |
|---|
| 114 | + __le32 supported_hash_types; |
|---|
| 95 | 115 | } __attribute__((packed)); |
|---|
| 96 | 116 | |
|---|
| 97 | 117 | /* |
|---|
| .. | .. |
|---|
| 104 | 124 | struct virtio_net_hdr_v1 { |
|---|
| 105 | 125 | #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ |
|---|
| 106 | 126 | #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ |
|---|
| 127 | +#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ |
|---|
| 107 | 128 | __u8 flags; |
|---|
| 108 | 129 | #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ |
|---|
| 109 | 130 | #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ |
|---|
| .. | .. |
|---|
| 113 | 134 | __u8 gso_type; |
|---|
| 114 | 135 | __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ |
|---|
| 115 | 136 | __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ |
|---|
| 116 | | - __virtio16 csum_start; /* Position to start checksumming from */ |
|---|
| 117 | | - __virtio16 csum_offset; /* Offset after that to place checksum */ |
|---|
| 137 | + union { |
|---|
| 138 | + struct { |
|---|
| 139 | + __virtio16 csum_start; |
|---|
| 140 | + __virtio16 csum_offset; |
|---|
| 141 | + }; |
|---|
| 142 | + /* Checksum calculation */ |
|---|
| 143 | + struct { |
|---|
| 144 | + /* Position to start checksumming from */ |
|---|
| 145 | + __virtio16 start; |
|---|
| 146 | + /* Offset after that to place checksum */ |
|---|
| 147 | + __virtio16 offset; |
|---|
| 148 | + } csum; |
|---|
| 149 | + /* Receive Segment Coalescing */ |
|---|
| 150 | + struct { |
|---|
| 151 | + /* Number of coalesced segments */ |
|---|
| 152 | + __le16 segments; |
|---|
| 153 | + /* Number of duplicated acks */ |
|---|
| 154 | + __le16 dup_acks; |
|---|
| 155 | + } rsc; |
|---|
| 156 | + }; |
|---|
| 118 | 157 | __virtio16 num_buffers; /* Number of merged rx buffers */ |
|---|
| 158 | +}; |
|---|
| 159 | + |
|---|
| 160 | +struct virtio_net_hdr_v1_hash { |
|---|
| 161 | + struct virtio_net_hdr_v1 hdr; |
|---|
| 162 | + __le32 hash_value; |
|---|
| 163 | +#define VIRTIO_NET_HASH_REPORT_NONE 0 |
|---|
| 164 | +#define VIRTIO_NET_HASH_REPORT_IPv4 1 |
|---|
| 165 | +#define VIRTIO_NET_HASH_REPORT_TCPv4 2 |
|---|
| 166 | +#define VIRTIO_NET_HASH_REPORT_UDPv4 3 |
|---|
| 167 | +#define VIRTIO_NET_HASH_REPORT_IPv6 4 |
|---|
| 168 | +#define VIRTIO_NET_HASH_REPORT_TCPv6 5 |
|---|
| 169 | +#define VIRTIO_NET_HASH_REPORT_UDPv6 6 |
|---|
| 170 | +#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 |
|---|
| 171 | +#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 |
|---|
| 172 | +#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 |
|---|
| 173 | + __le16 hash_report; |
|---|
| 174 | + __le16 padding; |
|---|
| 119 | 175 | }; |
|---|
| 120 | 176 | |
|---|
| 121 | 177 | #ifndef VIRTIO_NET_NO_LEGACY |
|---|
| .. | .. |
|---|
| 228 | 284 | |
|---|
| 229 | 285 | /* |
|---|
| 230 | 286 | * Control Receive Flow Steering |
|---|
| 231 | | - * |
|---|
| 287 | + */ |
|---|
| 288 | +#define VIRTIO_NET_CTRL_MQ 4 |
|---|
| 289 | +/* |
|---|
| 232 | 290 | * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET |
|---|
| 233 | 291 | * enables Receive Flow Steering, specifying the number of the transmit and |
|---|
| 234 | 292 | * receive queues that will be used. After the command is consumed and acked by |
|---|
| .. | .. |
|---|
| 241 | 299 | __virtio16 virtqueue_pairs; |
|---|
| 242 | 300 | }; |
|---|
| 243 | 301 | |
|---|
| 244 | | -#define VIRTIO_NET_CTRL_MQ 4 |
|---|
| 245 | 302 | #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 |
|---|
| 246 | 303 | #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 |
|---|
| 247 | 304 | #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 |
|---|
| 248 | 305 | |
|---|
| 249 | 306 | /* |
|---|
| 307 | + * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as |
|---|
| 308 | + * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures |
|---|
| 309 | + * the receive steering to use a hash calculated for incoming packet |
|---|
| 310 | + * to decide on receive virtqueue to place the packet. The command |
|---|
| 311 | + * also provides parameters to calculate a hash and receive virtqueue. |
|---|
| 312 | + */ |
|---|
| 313 | +struct virtio_net_rss_config { |
|---|
| 314 | + __le32 hash_types; |
|---|
| 315 | + __le16 indirection_table_mask; |
|---|
| 316 | + __le16 unclassified_queue; |
|---|
| 317 | + __le16 indirection_table[1/* + indirection_table_mask */]; |
|---|
| 318 | + __le16 max_tx_vq; |
|---|
| 319 | + __u8 hash_key_length; |
|---|
| 320 | + __u8 hash_key_data[/* hash_key_length */]; |
|---|
| 321 | +}; |
|---|
| 322 | + |
|---|
| 323 | + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 |
|---|
| 324 | + |
|---|
| 325 | +/* |
|---|
| 326 | + * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device |
|---|
| 327 | + * to include in the virtio header of the packet the value of the |
|---|
| 328 | + * calculated hash and the report type of hash. It also provides |
|---|
| 329 | + * parameters for hash calculation. The command requires feature |
|---|
| 330 | + * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the |
|---|
| 331 | + * layout of virtio header as defined in virtio_net_hdr_v1_hash. |
|---|
| 332 | + */ |
|---|
| 333 | +struct virtio_net_hash_config { |
|---|
| 334 | + __le32 hash_types; |
|---|
| 335 | + /* for compatibility with virtio_net_rss_config */ |
|---|
| 336 | + __le16 reserved[4]; |
|---|
| 337 | + __u8 hash_key_length; |
|---|
| 338 | + __u8 hash_key_data[/* hash_key_length */]; |
|---|
| 339 | +}; |
|---|
| 340 | + |
|---|
| 341 | + #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 |
|---|
| 342 | + |
|---|
| 343 | +/* |
|---|
| 250 | 344 | * Control network offloads |
|---|
| 251 | 345 | * |
|---|
| 252 | 346 | * Reconfigures the network offloads that Guest can handle. |
|---|