vf.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*******************************************************************************
  2. Intel 82599 Virtual Function driver
  3. Copyright(c) 1999 - 2015 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, see <http://www.gnu.org/licenses/>.
  13. The full GNU General Public License is included in this distribution in
  14. the file called "COPYING".
  15. Contact Information:
  16. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  17. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  18. *******************************************************************************/
  19. #ifndef __IXGBE_VF_H__
  20. #define __IXGBE_VF_H__
  21. #include <linux/pci.h>
  22. #include <linux/delay.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/if_ether.h>
  25. #include <linux/netdevice.h>
  26. #include "defines.h"
  27. #include "regs.h"
  28. #include "mbx.h"
  29. struct ixgbe_hw;
  30. /* iterator type for walking multicast address lists */
  31. typedef u8* (*ixgbe_mc_addr_itr) (struct ixgbe_hw *hw, u8 **mc_addr_ptr,
  32. u32 *vmdq);
  33. struct ixgbe_mac_operations {
  34. s32 (*init_hw)(struct ixgbe_hw *);
  35. s32 (*reset_hw)(struct ixgbe_hw *);
  36. s32 (*start_hw)(struct ixgbe_hw *);
  37. s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
  38. enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
  39. s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
  40. s32 (*stop_adapter)(struct ixgbe_hw *);
  41. s32 (*get_bus_info)(struct ixgbe_hw *);
  42. s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
  43. /* Link */
  44. s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
  45. s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
  46. s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
  47. bool *);
  48. /* RAR, Multicast, VLAN */
  49. s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
  50. s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
  51. s32 (*init_rx_addrs)(struct ixgbe_hw *);
  52. s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
  53. s32 (*update_xcast_mode)(struct ixgbe_hw *, int);
  54. s32 (*enable_mc)(struct ixgbe_hw *);
  55. s32 (*disable_mc)(struct ixgbe_hw *);
  56. s32 (*clear_vfta)(struct ixgbe_hw *);
  57. s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
  58. s32 (*set_rlpml)(struct ixgbe_hw *, u16);
  59. };
  60. enum ixgbe_mac_type {
  61. ixgbe_mac_unknown = 0,
  62. ixgbe_mac_82599_vf,
  63. ixgbe_mac_X540_vf,
  64. ixgbe_mac_X550_vf,
  65. ixgbe_mac_X550EM_x_vf,
  66. ixgbe_mac_x550em_a_vf,
  67. ixgbe_num_macs
  68. };
  69. struct ixgbe_mac_info {
  70. struct ixgbe_mac_operations ops;
  71. u8 addr[6];
  72. u8 perm_addr[6];
  73. enum ixgbe_mac_type type;
  74. s32 mc_filter_type;
  75. bool get_link_status;
  76. u32 max_tx_queues;
  77. u32 max_rx_queues;
  78. u32 max_msix_vectors;
  79. };
  80. struct ixgbe_mbx_operations {
  81. s32 (*init_params)(struct ixgbe_hw *hw);
  82. s32 (*read)(struct ixgbe_hw *, u32 *, u16);
  83. s32 (*write)(struct ixgbe_hw *, u32 *, u16);
  84. s32 (*read_posted)(struct ixgbe_hw *, u32 *, u16);
  85. s32 (*write_posted)(struct ixgbe_hw *, u32 *, u16);
  86. s32 (*check_for_msg)(struct ixgbe_hw *);
  87. s32 (*check_for_ack)(struct ixgbe_hw *);
  88. s32 (*check_for_rst)(struct ixgbe_hw *);
  89. };
  90. struct ixgbe_mbx_stats {
  91. u32 msgs_tx;
  92. u32 msgs_rx;
  93. u32 acks;
  94. u32 reqs;
  95. u32 rsts;
  96. };
  97. struct ixgbe_mbx_info {
  98. struct ixgbe_mbx_operations ops;
  99. struct ixgbe_mbx_stats stats;
  100. u32 timeout;
  101. u32 udelay;
  102. u32 v2p_mailbox;
  103. u16 size;
  104. };
  105. struct ixgbe_hw {
  106. void *back;
  107. u8 __iomem *hw_addr;
  108. struct ixgbe_mac_info mac;
  109. struct ixgbe_mbx_info mbx;
  110. u16 device_id;
  111. u16 subsystem_vendor_id;
  112. u16 subsystem_device_id;
  113. u16 vendor_id;
  114. u8 revision_id;
  115. bool adapter_stopped;
  116. int api_version;
  117. };
  118. struct ixgbevf_hw_stats {
  119. u64 base_vfgprc;
  120. u64 base_vfgptc;
  121. u64 base_vfgorc;
  122. u64 base_vfgotc;
  123. u64 base_vfmprc;
  124. u64 last_vfgprc;
  125. u64 last_vfgptc;
  126. u64 last_vfgorc;
  127. u64 last_vfgotc;
  128. u64 last_vfmprc;
  129. u64 vfgprc;
  130. u64 vfgptc;
  131. u64 vfgorc;
  132. u64 vfgotc;
  133. u64 vfmprc;
  134. u64 saved_reset_vfgprc;
  135. u64 saved_reset_vfgptc;
  136. u64 saved_reset_vfgorc;
  137. u64 saved_reset_vfgotc;
  138. u64 saved_reset_vfmprc;
  139. };
  140. struct ixgbevf_info {
  141. enum ixgbe_mac_type mac;
  142. const struct ixgbe_mac_operations *mac_ops;
  143. };
  144. #define IXGBE_FAILED_READ_REG 0xffffffffU
  145. #define IXGBE_REMOVED(a) unlikely(!(a))
  146. static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
  147. {
  148. u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
  149. if (IXGBE_REMOVED(reg_addr))
  150. return;
  151. writel(value, reg_addr + reg);
  152. }
  153. #define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
  154. u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
  155. #define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
  156. static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
  157. u32 offset, u32 value)
  158. {
  159. ixgbe_write_reg(hw, reg + (offset << 2), value);
  160. }
  161. #define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
  162. static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
  163. u32 offset)
  164. {
  165. return ixgbevf_read_reg(hw, reg + (offset << 2));
  166. }
  167. #define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
  168. int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
  169. unsigned int *default_tc);
  170. int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues);
  171. int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key);
  172. #endif /* __IXGBE_VF_H__ */