vmxnet3_defs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * QEMU VMWARE VMXNET3 paravirtual NIC
  3. *
  4. * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
  5. *
  6. * Developed by Daynix Computing LTD (http://www.daynix.com)
  7. *
  8. * Authors:
  9. * Dmitry Fleytman <dmitry@daynix.com>
  10. * Tamir Shomer <tamirs@daynix.com>
  11. * Yan Vugenfirer <yan@daynix.com>
  12. *
  13. * This work is licensed under the terms of the GNU GPL, version 2.
  14. * See the COPYING file in the top-level directory.
  15. */
  16. #ifndef HW_NET_VMXNET3_DEFS_H
  17. #define HW_NET_VMXNET3_DEFS_H
  18. #include "net/net.h"
  19. #include "hw/net/vmxnet3.h"
  20. #include "hw/pci/pci_device.h"
  21. #define TYPE_VMXNET3 "vmxnet3"
  22. typedef struct VMXNET3State VMXNET3State;
  23. DECLARE_INSTANCE_CHECKER(VMXNET3State, VMXNET3,
  24. TYPE_VMXNET3)
  25. /* Device state and helper functions */
  26. #define VMXNET3_RX_RINGS_PER_QUEUE (2)
  27. /* Cyclic ring abstraction */
  28. typedef struct {
  29. hwaddr pa;
  30. uint32_t size;
  31. uint32_t cell_size;
  32. uint32_t next;
  33. uint8_t gen;
  34. } Vmxnet3Ring;
  35. typedef struct {
  36. Vmxnet3Ring tx_ring;
  37. Vmxnet3Ring comp_ring;
  38. uint8_t intr_idx;
  39. hwaddr tx_stats_pa;
  40. struct UPT1_TxStats txq_stats;
  41. } Vmxnet3TxqDescr;
  42. typedef struct {
  43. Vmxnet3Ring rx_ring[VMXNET3_RX_RINGS_PER_QUEUE];
  44. Vmxnet3Ring comp_ring;
  45. uint8_t intr_idx;
  46. hwaddr rx_stats_pa;
  47. struct UPT1_RxStats rxq_stats;
  48. } Vmxnet3RxqDescr;
  49. typedef struct {
  50. bool is_masked;
  51. bool is_pending;
  52. bool is_asserted;
  53. } Vmxnet3IntState;
  54. struct VMXNET3State {
  55. PCIDevice parent_obj;
  56. NICState *nic;
  57. NICConf conf;
  58. MemoryRegion bar0;
  59. MemoryRegion bar1;
  60. MemoryRegion msix_bar;
  61. Vmxnet3RxqDescr rxq_descr[VMXNET3_DEVICE_MAX_RX_QUEUES];
  62. Vmxnet3TxqDescr txq_descr[VMXNET3_DEVICE_MAX_TX_QUEUES];
  63. /* Whether MSI-X support was installed successfully */
  64. bool msix_used;
  65. hwaddr drv_shmem;
  66. hwaddr temp_shared_guest_driver_memory;
  67. uint8_t txq_num;
  68. /* This boolean tells whether RX packet being indicated has to */
  69. /* be split into head and body chunks from different RX rings */
  70. bool rx_packets_compound;
  71. bool rx_vlan_stripping;
  72. bool lro_supported;
  73. uint8_t rxq_num;
  74. /* Network MTU */
  75. uint32_t mtu;
  76. /* Maximum number of fragments for indicated TX packets */
  77. uint32_t max_tx_frags;
  78. /* Maximum number of fragments for indicated RX packets */
  79. uint16_t max_rx_frags;
  80. /* Index for events interrupt */
  81. uint8_t event_int_idx;
  82. /* Whether automatic interrupts masking enabled */
  83. bool auto_int_masking;
  84. bool peer_has_vhdr;
  85. /* TX packets to QEMU interface */
  86. struct NetTxPkt *tx_pkt;
  87. uint32_t offload_mode;
  88. uint32_t cso_or_gso_size;
  89. uint16_t tci;
  90. bool needs_vlan;
  91. struct NetRxPkt *rx_pkt;
  92. bool tx_sop;
  93. bool skip_current_tx_pkt;
  94. uint32_t device_active;
  95. uint32_t last_command;
  96. uint32_t link_status_and_speed;
  97. Vmxnet3IntState interrupt_states[VMXNET3_MAX_INTRS];
  98. uint32_t temp_mac; /* To store the low part first */
  99. MACAddr perm_mac;
  100. uint32_t vlan_table[VMXNET3_VFT_SIZE];
  101. uint32_t rx_mode;
  102. MACAddr *mcast_list;
  103. uint32_t mcast_list_len;
  104. uint32_t mcast_list_buff_size; /* needed for live migration. */
  105. /* Compatibility flags for migration */
  106. uint32_t compat_flags;
  107. };
  108. #endif