Virtio095Net.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /** @file
  2. Virtio Network Device specific type and macro definitions corresponding to
  3. the virtio-0.9.5 specification.
  4. Copyright (C) 2013-2016, Red Hat, Inc.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _VIRTIO_0_9_5_NET_H_
  8. #define _VIRTIO_0_9_5_NET_H_
  9. #include <IndustryStandard/Virtio095.h>
  10. //
  11. // virtio-0.9.5, Appendix C: Network Device
  12. //
  13. #pragma pack(1)
  14. typedef struct {
  15. UINT8 Mac[6];
  16. UINT16 LinkStatus;
  17. } VIRTIO_NET_CONFIG;
  18. #pragma pack()
  19. #define OFFSET_OF_VNET(Field) OFFSET_OF (VIRTIO_NET_CONFIG, Field)
  20. #define SIZE_OF_VNET(Field) (sizeof ((VIRTIO_NET_CONFIG *) 0)->Field)
  21. //
  22. // Queue Identifiers
  23. //
  24. #define VIRTIO_NET_Q_RX 0
  25. #define VIRTIO_NET_Q_TX 1
  26. //
  27. // Feature Bits
  28. //
  29. #define VIRTIO_NET_F_CSUM BIT0 // host to checksum outgoing packets
  30. #define VIRTIO_NET_F_GUEST_CSUM BIT1 // guest to checksum incoming packets
  31. #define VIRTIO_NET_F_MAC BIT5 // MAC available to guest
  32. #define VIRTIO_NET_F_GSO BIT6 // deprecated
  33. #define VIRTIO_NET_F_GUEST_TSO4 BIT7 // guest can receive TSOv4
  34. #define VIRTIO_NET_F_GUEST_TSO6 BIT8 // guest can receive TSOv6
  35. #define VIRTIO_NET_F_GUEST_ECN BIT9 // guest can receive TSO with ECN
  36. #define VIRTIO_NET_F_GUEST_UFO BIT10 // guest can receive UFO
  37. #define VIRTIO_NET_F_HOST_TSO4 BIT11 // host can receive TSOv4
  38. #define VIRTIO_NET_F_HOST_TSO6 BIT12 // host can receive TSOv6
  39. #define VIRTIO_NET_F_HOST_ECN BIT13 // host can receive TSO with ECN
  40. #define VIRTIO_NET_F_HOST_UFO BIT14 // host can receive UFO
  41. #define VIRTIO_NET_F_MRG_RXBUF BIT15 // guest can merge receive buffers
  42. #define VIRTIO_NET_F_STATUS BIT16 // link status available to guest
  43. #define VIRTIO_NET_F_CTRL_VQ BIT17 // control channel available
  44. #define VIRTIO_NET_F_CTRL_RX BIT18 // control channel RX mode support
  45. #define VIRTIO_NET_F_CTRL_VLAN BIT19 // control channel VLAN filtering
  46. #define VIRTIO_NET_F_GUEST_ANNOUNCE BIT21 // guest can send gratuitous pkts
  47. //
  48. // Packet Header
  49. //
  50. #pragma pack(1)
  51. typedef struct {
  52. UINT8 Flags;
  53. UINT8 GsoType;
  54. UINT16 HdrLen;
  55. UINT16 GsoSize;
  56. UINT16 CsumStart;
  57. UINT16 CsumOffset;
  58. } VIRTIO_NET_REQ;
  59. #pragma pack()
  60. //
  61. // Bits in VIRTIO_NET_REQ.Flags
  62. //
  63. #define VIRTIO_NET_HDR_F_NEEDS_CSUM BIT0
  64. //
  65. // Types/Bits for VIRTIO_NET_REQ.GsoType
  66. //
  67. #define VIRTIO_NET_HDR_GSO_NONE 0x00
  68. #define VIRTIO_NET_HDR_GSO_TCPV4 0x01
  69. #define VIRTIO_NET_HDR_GSO_UDP 0x03
  70. #define VIRTIO_NET_HDR_GSO_TCPV6 0x04
  71. #define VIRTIO_NET_HDR_GSO_ECN BIT7
  72. //
  73. // Link Status Bits in VIRTIO_NET_CONFIG.LinkStatus
  74. //
  75. #define VIRTIO_NET_S_LINK_UP BIT0
  76. #define VIRTIO_NET_S_ANNOUNCE BIT1
  77. #endif // _VIRTIO_0_9_5_NET_H_