]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/IndustryStandard/VirtioNet.h
03dfeb2c594fa76de1f15bd2821c4a76ec5894bb
[mirror_edk2.git] / OvmfPkg / Include / IndustryStandard / VirtioNet.h
1 /** @file
2
3 Virtio Network Device specific type and macro definitions corresponding to
4 the virtio-0.9.5 specification.
5
6 Copyright (C) 2013, Red Hat, Inc.
7
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef _VIRTIO_NET_H_
19 #define _VIRTIO_NET_H_
20
21 #include <IndustryStandard/Virtio.h>
22
23 //
24 // virtio-0.9.5, Appendix C: Network Device
25 //
26 #pragma pack(1)
27 typedef struct {
28 VIRTIO_HDR Generic;
29 UINT8 VhdrMac[6];
30 UINT16 VhdrLinkStatus;
31 } VNET_HDR;
32 #pragma pack()
33
34 #define OFFSET_OF_VNET(Field) OFFSET_OF (VNET_HDR, Field)
35 #define SIZE_OF_VNET(Field) (sizeof ((VNET_HDR *) 0)->Field)
36
37 //
38 // Queue Identifiers
39 //
40 #define VIRTIO_NET_Q_RX 0
41 #define VIRTIO_NET_Q_TX 1
42
43 //
44 // Feature Bits
45 //
46 #define VIRTIO_NET_F_CSUM BIT0 // host to checksum outgoing packets
47 #define VIRTIO_NET_F_GUEST_CSUM BIT1 // guest to checksum incoming packets
48 #define VIRTIO_NET_F_MAC BIT5 // MAC available to guest
49 #define VIRTIO_NET_F_GSO BIT6 // deprecated
50 #define VIRTIO_NET_F_GUEST_TSO4 BIT7 // guest can receive TSOv4
51 #define VIRTIO_NET_F_GUEST_TSO6 BIT8 // guest can receive TSOv6
52 #define VIRTIO_NET_F_GUEST_ECN BIT9 // guest can receive TSO with ECN
53 #define VIRTIO_NET_F_GUEST_UFO BIT10 // guest can receive UFO
54 #define VIRTIO_NET_F_HOST_TSO4 BIT11 // host can receive TSOv4
55 #define VIRTIO_NET_F_HOST_TSO6 BIT12 // host can receive TSOv6
56 #define VIRTIO_NET_F_HOST_ECN BIT13 // host can receive TSO with ECN
57 #define VIRTIO_NET_F_HOST_UFO BIT14 // host can receive UFO
58 #define VIRTIO_NET_F_MRG_RXBUF BIT15 // guest can merge receive buffers
59 #define VIRTIO_NET_F_STATUS BIT16 // link status available to guest
60 #define VIRTIO_NET_F_CTRL_VQ BIT17 // control channel available
61 #define VIRTIO_NET_F_CTRL_RX BIT18 // control channel RX mode support
62 #define VIRTIO_NET_F_CTRL_VLAN BIT19 // control channel VLAN filtering
63 #define VIRTIO_NET_F_GUEST_ANNOUNCE BIT21 // guest can send gratuitous pkts
64
65 //
66 // Packet Header
67 //
68 #pragma pack(1)
69 typedef struct {
70 UINT8 Flags;
71 UINT8 GsoType;
72 UINT16 HdrLen;
73 UINT16 GsoSize;
74 UINT16 CsumStart;
75 UINT16 CsumOffset;
76 } VIRTIO_NET_REQ;
77 #pragma pack()
78
79 //
80 // Bits in VIRTIO_NET_REQ.Flags
81 //
82 #define VIRTIO_NET_HDR_F_NEEDS_CSUM BIT0
83
84 //
85 // Types/Bits for VIRTIO_NET_REQ.GsoType
86 //
87 #define VIRTIO_NET_HDR_GSO_NONE 0x00
88 #define VIRTIO_NET_HDR_GSO_TCPV4 0x01
89 #define VIRTIO_NET_HDR_GSO_UDP 0x03
90 #define VIRTIO_NET_HDR_GSO_TCPV6 0x04
91 #define VIRTIO_NET_HDR_GSO_ECN BIT7
92
93 //
94 // Link Status Bits in VNET_HDR.VhdrLinkStatus
95 //
96 #define VIRTIO_NET_S_LINK_UP BIT0
97 #define VIRTIO_NET_S_ANNOUNCE BIT1
98
99 #endif // _VIRTIO_NET_H_