1 #ifndef _UAPI_LINUX_VIRTIO_NET_H 2 #define _UAPI_LINUX_VIRTIO_NET_H 3 /* This header is BSD licensed so anyone can use the definitions to implement 4 * compatible drivers/servers. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of IBM nor the names of its contributors 15 * may be used to endorse or promote products derived from this software 16 * without specific prior written permission. 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. */ 28 #include <linux/types.h> 29 #include <linux/virtio_ids.h> 30 #include <linux/virtio_config.h> 31 #include <linux/virtio_types.h> 32 #include <linux/if_ether.h> 33 34 /* The feature bitmap for virtio net */ 35 #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ 36 #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ 37 #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */ 38 #define VIRTIO_NET_F_MTU 3 /* Initial MTU advice */ 39 #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ 40 #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ 41 #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ 42 #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ 43 #define VIRTIO_NET_F_GUEST_UFO 10 /* Guest can handle UFO in. */ 44 #define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */ 45 #define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */ 46 #define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */ 47 #define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */ 48 #define VIRTIO_NET_F_MRG_RXBUF 15 /* Host can merge receive buffers. */ 49 #define VIRTIO_NET_F_STATUS 16 /* virtio_net_config.status available */ 50 #define VIRTIO_NET_F_CTRL_VQ 17 /* Control channel available */ 51 #define VIRTIO_NET_F_CTRL_RX 18 /* Control channel RX mode support */ 52 #define VIRTIO_NET_F_CTRL_VLAN 19 /* Control channel VLAN filtering */ 53 #define VIRTIO_NET_F_CTRL_RX_EXTRA 20 /* Extra RX mode control support */ 54 #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 /* Guest can announce device on the 55 * network */ 56 #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow 57 * Steering */ 58 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ 59 #define VIRTIO_NET_F_DEVICE_STATS 50 /* Device can provide device-level statistics. */ 60 #define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notification coalescing */ 61 #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */ 62 #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ 63 #define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */ 64 #define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */ 65 #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ 66 #define VIRTIO_NET_F_GUEST_HDRLEN 59 /* Guest provides the exact hdr_len value. */ 67 #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ 68 #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ 69 #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device 70 * with the same MAC. 71 */ 72 #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */ 73 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO 65 /* Driver can receive 74 * GSO-over-UDP-tunnel packets 75 */ 76 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM 66 /* Driver handles 77 * GSO-over-UDP-tunnel 78 * packets with partial csum 79 * for the outer header 80 */ 81 #define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO 67 /* Device can receive 82 * GSO-over-UDP-tunnel packets 83 */ 84 #define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM 68 /* Device handles 85 * GSO-over-UDP-tunnel 86 * packets with partial csum 87 * for the outer header 88 */ 89 90 /* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM} 91 * features 92 */ 93 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED 46 94 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED 47 95 96 #ifndef VIRTIO_NET_NO_LEGACY 97 #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ 98 #endif /* VIRTIO_NET_NO_LEGACY */ 99 100 #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ 101 #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ 102 103 /* supported/enabled hash types */ 104 #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) 105 #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) 106 #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) 107 #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) 108 #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) 109 #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) 110 #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) 111 #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) 112 #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) 113 114 struct virtio_net_config { 115 /* The config defining mac address (if VIRTIO_NET_F_MAC) */ 116 __u8 mac[ETH_ALEN]; 117 /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ 118 __virtio16 status; 119 /* Maximum number of each of transmit and receive queues; 120 * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. 121 * Legal values are between 1 and 0x8000 122 */ 123 __virtio16 max_virtqueue_pairs; 124 /* Default maximum transmit unit advice */ 125 __virtio16 mtu; 126 /* 127 * speed, in units of 1Mb. All values 0 to INT_MAX are legal. 128 * Any other value stands for unknown. 129 */ 130 __le32 speed; 131 /* 132 * 0x00 - half duplex 133 * 0x01 - full duplex 134 * Any other value stands for unknown. 135 */ 136 __u8 duplex; 137 /* maximum size of RSS key */ 138 __u8 rss_max_key_size; 139 /* maximum number of indirection table entries */ 140 __le16 rss_max_indirection_table_length; 141 /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ 142 __le32 supported_hash_types; 143 } __attribute__((packed)); 144 145 /* 146 * This header comes first in the scatter-gather list. If you don't 147 * specify GSO or CSUM features, you can simply ignore the header. 148 * 149 * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf, 150 * only flattened. 151 */ 152 struct virtio_net_hdr_v1 { 153 #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ 154 #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ 155 #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ 156 #define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8 /* UDP tunnel csum offload */ 157 __u8 flags; 158 #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ 159 #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ 160 #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ 161 #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ 162 #define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */ 163 #define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 0x20 /* UDPv4 tunnel present */ 164 #define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 0x40 /* UDPv6 tunnel present */ 165 #define VIRTIO_NET_HDR_GSO_UDP_TUNNEL (VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 | \ 166 VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6) 167 #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ 168 __u8 gso_type; 169 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 170 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 171 union { 172 struct { 173 __virtio16 csum_start; 174 __virtio16 csum_offset; 175 }; 176 /* Checksum calculation */ 177 struct { 178 /* Position to start checksumming from */ 179 __virtio16 start; 180 /* Offset after that to place checksum */ 181 __virtio16 offset; 182 } csum; 183 /* Receive Segment Coalescing */ 184 struct { 185 /* Number of coalesced segments */ 186 __le16 segments; 187 /* Number of duplicated acks */ 188 __le16 dup_acks; 189 } rsc; 190 }; 191 __virtio16 num_buffers; /* Number of merged rx buffers */ 192 }; 193 194 struct virtio_net_hdr_v1_hash { 195 struct virtio_net_hdr_v1 hdr; 196 __le32 hash_value; 197 #define VIRTIO_NET_HASH_REPORT_NONE 0 198 #define VIRTIO_NET_HASH_REPORT_IPv4 1 199 #define VIRTIO_NET_HASH_REPORT_TCPv4 2 200 #define VIRTIO_NET_HASH_REPORT_UDPv4 3 201 #define VIRTIO_NET_HASH_REPORT_IPv6 4 202 #define VIRTIO_NET_HASH_REPORT_TCPv6 5 203 #define VIRTIO_NET_HASH_REPORT_UDPv6 6 204 #define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 205 #define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 206 #define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 207 __le16 hash_report; 208 __le16 padding; 209 }; 210 211 struct virtio_net_hdr_v1_hash_tunnel { 212 struct virtio_net_hdr_v1_hash hash_hdr; 213 __le16 outer_th_offset; 214 __le16 inner_nh_offset; 215 }; 216 217 #ifndef VIRTIO_NET_NO_LEGACY 218 /* This header comes first in the scatter-gather list. 219 * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must 220 * be the first element of the scatter-gather list. If you don't 221 * specify GSO or CSUM features, you can simply ignore the header. */ 222 struct virtio_net_hdr { 223 /* See VIRTIO_NET_HDR_F_* */ 224 __u8 flags; 225 /* See VIRTIO_NET_HDR_GSO_* */ 226 __u8 gso_type; 227 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 228 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 229 __virtio16 csum_start; /* Position to start checksumming from */ 230 __virtio16 csum_offset; /* Offset after that to place checksum */ 231 }; 232 233 /* This is the version of the header to use when the MRG_RXBUF 234 * feature has been negotiated. */ 235 struct virtio_net_hdr_mrg_rxbuf { 236 struct virtio_net_hdr hdr; 237 __virtio16 num_buffers; /* Number of merged rx buffers */ 238 }; 239 #endif /* ...VIRTIO_NET_NO_LEGACY */ 240 241 /* 242 * Control virtqueue data structures 243 * 244 * The control virtqueue expects a header in the first sg entry 245 * and an ack/status response in the last entry. Data for the 246 * command goes in between. 247 */ 248 struct virtio_net_ctrl_hdr { 249 __u8 class; 250 __u8 cmd; 251 } __attribute__((packed)); 252 253 typedef __u8 virtio_net_ctrl_ack; 254 255 #define VIRTIO_NET_OK 0 256 #define VIRTIO_NET_ERR 1 257 258 /* 259 * Control the RX mode, ie. promisucous, allmulti, etc... 260 * All commands require an "out" sg entry containing a 1 byte 261 * state value, zero = disable, non-zero = enable. Commands 262 * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature. 263 * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA. 264 */ 265 #define VIRTIO_NET_CTRL_RX 0 266 #define VIRTIO_NET_CTRL_RX_PROMISC 0 267 #define VIRTIO_NET_CTRL_RX_ALLMULTI 1 268 #define VIRTIO_NET_CTRL_RX_ALLUNI 2 269 #define VIRTIO_NET_CTRL_RX_NOMULTI 3 270 #define VIRTIO_NET_CTRL_RX_NOUNI 4 271 #define VIRTIO_NET_CTRL_RX_NOBCAST 5 272 273 /* 274 * Control the MAC 275 * 276 * The MAC filter table is managed by the hypervisor, the guest should 277 * assume the size is infinite. Filtering should be considered 278 * non-perfect, ie. based on hypervisor resources, the guest may 279 * received packets from sources not specified in the filter list. 280 * 281 * In addition to the class/cmd header, the TABLE_SET command requires 282 * two out scatterlists. Each contains a 4 byte count of entries followed 283 * by a concatenated byte stream of the ETH_ALEN MAC addresses. The 284 * first sg list contains unicast addresses, the second is for multicast. 285 * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature 286 * is available. 287 * 288 * The ADDR_SET command requests one out scatterlist, it contains a 289 * 6 bytes MAC address. This functionality is present if the 290 * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. 291 */ 292 struct virtio_net_ctrl_mac { 293 __virtio32 entries; 294 __u8 macs[][ETH_ALEN]; 295 } __attribute__((packed)); 296 297 #define VIRTIO_NET_CTRL_MAC 1 298 #define VIRTIO_NET_CTRL_MAC_TABLE_SET 0 299 #define VIRTIO_NET_CTRL_MAC_ADDR_SET 1 300 301 /* 302 * Control VLAN filtering 303 * 304 * The VLAN filter table is controlled via a simple ADD/DEL interface. 305 * VLAN IDs not added may be filterd by the hypervisor. Del is the 306 * opposite of add. Both commands expect an out entry containing a 2 307 * byte VLAN ID. VLAN filterting is available with the 308 * VIRTIO_NET_F_CTRL_VLAN feature bit. 309 */ 310 #define VIRTIO_NET_CTRL_VLAN 2 311 #define VIRTIO_NET_CTRL_VLAN_ADD 0 312 #define VIRTIO_NET_CTRL_VLAN_DEL 1 313 314 /* 315 * Control link announce acknowledgement 316 * 317 * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that 318 * driver has recevied the notification; device would clear the 319 * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives 320 * this command. 321 */ 322 #define VIRTIO_NET_CTRL_ANNOUNCE 3 323 #define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0 324 325 /* 326 * Control Receive Flow Steering 327 */ 328 #define VIRTIO_NET_CTRL_MQ 4 329 /* 330 * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 331 * enables Receive Flow Steering, specifying the number of the transmit and 332 * receive queues that will be used. After the command is consumed and acked by 333 * the device, the device will not steer new packets on receive virtqueues 334 * other than specified nor read from transmit virtqueues other than specified. 335 * Accordingly, driver should not transmit new packets on virtqueues other than 336 * specified. 337 */ 338 struct virtio_net_ctrl_mq { 339 __virtio16 virtqueue_pairs; 340 }; 341 342 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 343 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 344 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 345 346 /* 347 * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as 348 * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures 349 * the receive steering to use a hash calculated for incoming packet 350 * to decide on receive virtqueue to place the packet. The command 351 * also provides parameters to calculate a hash and receive virtqueue. 352 */ 353 struct virtio_net_rss_config { 354 __le32 hash_types; 355 __le16 indirection_table_mask; 356 __le16 unclassified_queue; 357 __le16 indirection_table[1/* + indirection_table_mask */]; 358 __le16 max_tx_vq; 359 __u8 hash_key_length; 360 __u8 hash_key_data[/* hash_key_length */]; 361 }; 362 363 struct virtio_net_rss_config_hdr { 364 __le32 hash_types; 365 __le16 indirection_table_mask; 366 __le16 unclassified_queue; 367 __le16 indirection_table[/* 1 + indirection_table_mask */]; 368 }; 369 370 struct virtio_net_rss_config_trailer { 371 __le16 max_tx_vq; 372 __u8 hash_key_length; 373 __u8 hash_key_data[/* hash_key_length */]; 374 }; 375 376 #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 377 378 /* 379 * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device 380 * to include in the virtio header of the packet the value of the 381 * calculated hash and the report type of hash. It also provides 382 * parameters for hash calculation. The command requires feature 383 * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the 384 * layout of virtio header as defined in virtio_net_hdr_v1_hash. 385 */ 386 struct virtio_net_hash_config { 387 __le32 hash_types; 388 /* for compatibility with virtio_net_rss_config */ 389 __le16 reserved[4]; 390 __u8 hash_key_length; 391 __u8 hash_key_data[/* hash_key_length */]; 392 }; 393 394 #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 395 396 /* 397 * Control network offloads 398 * 399 * Reconfigures the network offloads that Guest can handle. 400 * 401 * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. 402 * 403 * Command data format matches the feature bit mask exactly. 404 * 405 * See VIRTIO_NET_F_GUEST_* for the list of offloads 406 * that can be enabled/disabled. 407 */ 408 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 409 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 410 411 /* 412 * Control notifications coalescing. 413 * 414 * Request the device to change the notifications coalescing parameters. 415 * 416 * Available with the VIRTIO_NET_F_NOTF_COAL feature bit. 417 */ 418 #define VIRTIO_NET_CTRL_NOTF_COAL 6 419 /* 420 * Set the tx-usecs/tx-max-packets parameters. 421 */ 422 struct virtio_net_ctrl_coal_tx { 423 /* Maximum number of packets to send before a TX notification */ 424 __le32 tx_max_packets; 425 /* Maximum number of usecs to delay a TX notification */ 426 __le32 tx_usecs; 427 }; 428 429 #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0 430 431 /* 432 * Set the rx-usecs/rx-max-packets parameters. 433 */ 434 struct virtio_net_ctrl_coal_rx { 435 /* Maximum number of packets to receive before a RX notification */ 436 __le32 rx_max_packets; 437 /* Maximum number of usecs to delay a RX notification */ 438 __le32 rx_usecs; 439 }; 440 441 #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1 442 #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2 443 #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3 444 445 struct virtio_net_ctrl_coal { 446 __le32 max_packets; 447 __le32 max_usecs; 448 }; 449 450 struct virtio_net_ctrl_coal_vq { 451 __le16 vqn; 452 __le16 reserved; 453 struct virtio_net_ctrl_coal coal; 454 }; 455 456 /* 457 * Device Statistics 458 */ 459 #define VIRTIO_NET_CTRL_STATS 8 460 #define VIRTIO_NET_CTRL_STATS_QUERY 0 461 #define VIRTIO_NET_CTRL_STATS_GET 1 462 463 struct virtio_net_stats_capabilities { 464 465 #define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32) 466 467 #define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0) 468 #define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1) 469 #define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2) 470 #define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3) 471 472 #define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16) 473 #define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17) 474 #define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18) 475 #define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19) 476 477 __le64 supported_stats_types[1]; 478 }; 479 480 struct virtio_net_ctrl_queue_stats { 481 struct { 482 __le16 vq_index; 483 __le16 reserved[3]; 484 __le64 types_bitmap[1]; 485 } stats[1]; 486 }; 487 488 struct virtio_net_stats_reply_hdr { 489 #define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32 490 491 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0 492 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1 493 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2 494 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3 495 496 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16 497 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17 498 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18 499 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19 500 __u8 type; 501 __u8 reserved; 502 __le16 vq_index; 503 __le16 reserved1; 504 __le16 size; 505 }; 506 507 struct virtio_net_stats_cvq { 508 struct virtio_net_stats_reply_hdr hdr; 509 510 __le64 command_num; 511 __le64 ok_num; 512 }; 513 514 struct virtio_net_stats_rx_basic { 515 struct virtio_net_stats_reply_hdr hdr; 516 517 __le64 rx_notifications; 518 519 __le64 rx_packets; 520 __le64 rx_bytes; 521 522 __le64 rx_interrupts; 523 524 __le64 rx_drops; 525 __le64 rx_drop_overruns; 526 }; 527 528 struct virtio_net_stats_tx_basic { 529 struct virtio_net_stats_reply_hdr hdr; 530 531 __le64 tx_notifications; 532 533 __le64 tx_packets; 534 __le64 tx_bytes; 535 536 __le64 tx_interrupts; 537 538 __le64 tx_drops; 539 __le64 tx_drop_malformed; 540 }; 541 542 struct virtio_net_stats_rx_csum { 543 struct virtio_net_stats_reply_hdr hdr; 544 545 __le64 rx_csum_valid; 546 __le64 rx_needs_csum; 547 __le64 rx_csum_none; 548 __le64 rx_csum_bad; 549 }; 550 551 struct virtio_net_stats_tx_csum { 552 struct virtio_net_stats_reply_hdr hdr; 553 554 __le64 tx_csum_none; 555 __le64 tx_needs_csum; 556 }; 557 558 struct virtio_net_stats_rx_gso { 559 struct virtio_net_stats_reply_hdr hdr; 560 561 __le64 rx_gso_packets; 562 __le64 rx_gso_bytes; 563 __le64 rx_gso_packets_coalesced; 564 __le64 rx_gso_bytes_coalesced; 565 }; 566 567 struct virtio_net_stats_tx_gso { 568 struct virtio_net_stats_reply_hdr hdr; 569 570 __le64 tx_gso_packets; 571 __le64 tx_gso_bytes; 572 __le64 tx_gso_segments; 573 __le64 tx_gso_segments_bytes; 574 __le64 tx_gso_packets_noseg; 575 __le64 tx_gso_bytes_noseg; 576 }; 577 578 struct virtio_net_stats_rx_speed { 579 struct virtio_net_stats_reply_hdr hdr; 580 581 /* rx_{packets,bytes}_allowance_exceeded are too long. So rename to 582 * short name. 583 */ 584 __le64 rx_ratelimit_packets; 585 __le64 rx_ratelimit_bytes; 586 }; 587 588 struct virtio_net_stats_tx_speed { 589 struct virtio_net_stats_reply_hdr hdr; 590 591 /* tx_{packets,bytes}_allowance_exceeded are too long. So rename to 592 * short name. 593 */ 594 __le64 tx_ratelimit_packets; 595 __le64 tx_ratelimit_bytes; 596 }; 597 598 #endif /* _UAPI_LINUX_VIRTIO_NET_H */ 599