netmap_virt.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2013-2016 Luigi Rizzo
  3. * Copyright (C) 2013-2016 Giuseppe Lettieri
  4. * Copyright (C) 2013-2018 Vincenzo Maffione
  5. * Copyright (C) 2015 Stefano Garzarella
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR 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. */
  29. #ifndef NETMAP_VIRT_H
  30. #define NETMAP_VIRT_H
  31. /*
  32. * Register offsets and other macros for the ptnetmap paravirtual devices:
  33. * ptnetmap-memdev: device used to expose memory into the guest
  34. * ptnet: paravirtualized NIC exposing a netmap port in the guest
  35. *
  36. * These macros are used in the hypervisor frontend (QEMU, bhyve) and in the
  37. * guest device driver.
  38. */
  39. /* PCI identifiers and PCI BARs for ptnetmap-memdev and ptnet. */
  40. #define PTNETMAP_MEMDEV_NAME "ptnetmap-memdev"
  41. #define PTNETMAP_PCI_VENDOR_ID 0x1b36 /* QEMU virtual devices */
  42. #define PTNETMAP_PCI_DEVICE_ID 0x000c /* memory device */
  43. #define PTNETMAP_PCI_NETIF_ID 0x000d /* ptnet network interface */
  44. #define PTNETMAP_IO_PCI_BAR 0
  45. #define PTNETMAP_MEM_PCI_BAR 1
  46. #define PTNETMAP_MSIX_PCI_BAR 2
  47. /* Device registers for ptnetmap-memdev */
  48. #define PTNET_MDEV_IO_MEMSIZE_LO 0 /* netmap memory size (low) */
  49. #define PTNET_MDEV_IO_MEMSIZE_HI 4 /* netmap_memory_size (high) */
  50. #define PTNET_MDEV_IO_MEMID 8 /* memory allocator ID in the host */
  51. #define PTNET_MDEV_IO_IF_POOL_OFS 64
  52. #define PTNET_MDEV_IO_IF_POOL_OBJNUM 68
  53. #define PTNET_MDEV_IO_IF_POOL_OBJSZ 72
  54. #define PTNET_MDEV_IO_RING_POOL_OFS 76
  55. #define PTNET_MDEV_IO_RING_POOL_OBJNUM 80
  56. #define PTNET_MDEV_IO_RING_POOL_OBJSZ 84
  57. #define PTNET_MDEV_IO_BUF_POOL_OFS 88
  58. #define PTNET_MDEV_IO_BUF_POOL_OBJNUM 92
  59. #define PTNET_MDEV_IO_BUF_POOL_OBJSZ 96
  60. #define PTNET_MDEV_IO_END 100
  61. /* ptnetmap features */
  62. #define PTNETMAP_F_VNET_HDR 1
  63. /* Device registers for the ptnet network device. */
  64. #define PTNET_IO_PTFEAT 0
  65. #define PTNET_IO_PTCTL 4
  66. #define PTNET_IO_MAC_LO 8
  67. #define PTNET_IO_MAC_HI 12
  68. #define PTNET_IO_CSBBAH 16 /* deprecated */
  69. #define PTNET_IO_CSBBAL 20 /* deprecated */
  70. #define PTNET_IO_NIFP_OFS 24
  71. #define PTNET_IO_NUM_TX_RINGS 28
  72. #define PTNET_IO_NUM_RX_RINGS 32
  73. #define PTNET_IO_NUM_TX_SLOTS 36
  74. #define PTNET_IO_NUM_RX_SLOTS 40
  75. #define PTNET_IO_VNET_HDR_LEN 44
  76. #define PTNET_IO_HOSTMEMID 48
  77. #define PTNET_IO_CSB_GH_BAH 52
  78. #define PTNET_IO_CSB_GH_BAL 56
  79. #define PTNET_IO_CSB_HG_BAH 60
  80. #define PTNET_IO_CSB_HG_BAL 64
  81. #define PTNET_IO_END 68
  82. #define PTNET_IO_KICK_BASE 128
  83. #define PTNET_IO_MASK 0xff
  84. /* ptnet control commands (values for PTCTL register):
  85. * - CREATE starts the host sync-kloop
  86. * - DELETE stops the host sync-kloop
  87. */
  88. #define PTNETMAP_PTCTL_CREATE 1
  89. #define PTNETMAP_PTCTL_DELETE 2
  90. #endif /* NETMAP_VIRT_H */