vnic_dev.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  3. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  4. *
  5. * This program is free software; you may redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  12. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  13. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  14. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. * SOFTWARE.
  17. */
  18. #ifndef _VNIC_DEV_H_
  19. #define _VNIC_DEV_H_
  20. #include "vnic_resource.h"
  21. #include "vnic_devcmd.h"
  22. /*
  23. * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
  24. * Driver) when both are built with CONFIG options =y
  25. */
  26. #define vnic_dev_priv fnic_dev_priv
  27. #define vnic_dev_get_res_count fnic_dev_get_res_count
  28. #define vnic_dev_get_res fnic_dev_get_res
  29. #define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz
  30. #define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring
  31. #define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring
  32. #define vnic_dev_free_desc_ring fnic_dev_free_desc_ring
  33. #define vnic_dev_cmd fnic_dev_cmd
  34. #define vnic_dev_fw_info fnic_dev_fw_info
  35. #define vnic_dev_spec fnic_dev_spec
  36. #define vnic_dev_stats_clear fnic_dev_stats_clear
  37. #define vnic_dev_stats_dump fnic_dev_stats_dump
  38. #define vnic_dev_hang_notify fnic_dev_hang_notify
  39. #define vnic_dev_packet_filter fnic_dev_packet_filter
  40. #define vnic_dev_add_addr fnic_dev_add_addr
  41. #define vnic_dev_del_addr fnic_dev_del_addr
  42. #define vnic_dev_mac_addr fnic_dev_mac_addr
  43. #define vnic_dev_notify_set fnic_dev_notify_set
  44. #define vnic_dev_notify_unset fnic_dev_notify_unset
  45. #define vnic_dev_link_status fnic_dev_link_status
  46. #define vnic_dev_port_speed fnic_dev_port_speed
  47. #define vnic_dev_msg_lvl fnic_dev_msg_lvl
  48. #define vnic_dev_mtu fnic_dev_mtu
  49. #define vnic_dev_link_down_cnt fnic_dev_link_down_cnt
  50. #define vnic_dev_close fnic_dev_close
  51. #define vnic_dev_enable fnic_dev_enable
  52. #define vnic_dev_disable fnic_dev_disable
  53. #define vnic_dev_open fnic_dev_open
  54. #define vnic_dev_open_done fnic_dev_open_done
  55. #define vnic_dev_init fnic_dev_init
  56. #define vnic_dev_soft_reset fnic_dev_soft_reset
  57. #define vnic_dev_soft_reset_done fnic_dev_soft_reset_done
  58. #define vnic_dev_set_intr_mode fnic_dev_set_intr_mode
  59. #define vnic_dev_get_intr_mode fnic_dev_get_intr_mode
  60. #define vnic_dev_unregister fnic_dev_unregister
  61. #define vnic_dev_register fnic_dev_register
  62. #ifndef VNIC_PADDR_TARGET
  63. #define VNIC_PADDR_TARGET 0x0000000000000000ULL
  64. #endif
  65. #ifndef readq
  66. static inline u64 readq(void __iomem *reg)
  67. {
  68. return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg);
  69. }
  70. static inline void writeq(u64 val, void __iomem *reg)
  71. {
  72. writel(val & 0xffffffff, reg);
  73. writel(val >> 32, reg + 0x4UL);
  74. }
  75. #endif
  76. enum vnic_dev_intr_mode {
  77. VNIC_DEV_INTR_MODE_UNKNOWN,
  78. VNIC_DEV_INTR_MODE_INTX,
  79. VNIC_DEV_INTR_MODE_MSI,
  80. VNIC_DEV_INTR_MODE_MSIX,
  81. };
  82. struct vnic_dev_bar {
  83. void __iomem *vaddr;
  84. dma_addr_t bus_addr;
  85. unsigned long len;
  86. };
  87. struct vnic_dev_ring {
  88. void *descs;
  89. size_t size;
  90. dma_addr_t base_addr;
  91. size_t base_align;
  92. void *descs_unaligned;
  93. size_t size_unaligned;
  94. dma_addr_t base_addr_unaligned;
  95. unsigned int desc_size;
  96. unsigned int desc_count;
  97. unsigned int desc_avail;
  98. };
  99. struct vnic_dev;
  100. struct vnic_stats;
  101. void *vnic_dev_priv(struct vnic_dev *vdev);
  102. unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
  103. enum vnic_res_type type);
  104. void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
  105. unsigned int index);
  106. unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
  107. unsigned int desc_count,
  108. unsigned int desc_size);
  109. void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
  110. int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
  111. unsigned int desc_count, unsigned int desc_size);
  112. void vnic_dev_free_desc_ring(struct vnic_dev *vdev,
  113. struct vnic_dev_ring *ring);
  114. int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
  115. u64 *a0, u64 *a1, int wait);
  116. int vnic_dev_fw_info(struct vnic_dev *vdev,
  117. struct vnic_devcmd_fw_info **fw_info);
  118. int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset,
  119. unsigned int size, void *value);
  120. int vnic_dev_stats_clear(struct vnic_dev *vdev);
  121. int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
  122. int vnic_dev_hang_notify(struct vnic_dev *vdev);
  123. void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast,
  124. int broadcast, int promisc, int allmulti);
  125. void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
  126. void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
  127. int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
  128. int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
  129. void vnic_dev_notify_unset(struct vnic_dev *vdev);
  130. int vnic_dev_link_status(struct vnic_dev *vdev);
  131. u32 vnic_dev_port_speed(struct vnic_dev *vdev);
  132. u32 vnic_dev_msg_lvl(struct vnic_dev *vdev);
  133. u32 vnic_dev_mtu(struct vnic_dev *vdev);
  134. u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev);
  135. int vnic_dev_close(struct vnic_dev *vdev);
  136. int vnic_dev_enable(struct vnic_dev *vdev);
  137. int vnic_dev_disable(struct vnic_dev *vdev);
  138. int vnic_dev_open(struct vnic_dev *vdev, int arg);
  139. int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
  140. int vnic_dev_init(struct vnic_dev *vdev, int arg);
  141. u16 vnic_dev_set_default_vlan(struct vnic_dev *vdev,
  142. u16 new_default_vlan);
  143. int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg);
  144. int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done);
  145. void vnic_dev_set_intr_mode(struct vnic_dev *vdev,
  146. enum vnic_dev_intr_mode intr_mode);
  147. enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev);
  148. void vnic_dev_unregister(struct vnic_dev *vdev);
  149. struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
  150. void *priv, struct pci_dev *pdev,
  151. struct vnic_dev_bar *bar);
  152. #endif /* _VNIC_DEV_H_ */