vf.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 1999 - 2018 Intel Corporation. */
  3. #ifndef __IXGBE_VF_H__
  4. #define __IXGBE_VF_H__
  5. #include <linux/pci.h>
  6. #include <linux/delay.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/if_ether.h>
  9. #include <linux/netdevice.h>
  10. #include "defines.h"
  11. #include "regs.h"
  12. #include "mbx.h"
  13. struct ixgbe_hw;
  14. struct ixgbe_mac_operations {
  15. s32 (*init_hw)(struct ixgbe_hw *);
  16. s32 (*reset_hw)(struct ixgbe_hw *);
  17. s32 (*start_hw)(struct ixgbe_hw *);
  18. s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
  19. enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
  20. s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
  21. s32 (*stop_adapter)(struct ixgbe_hw *);
  22. s32 (*get_bus_info)(struct ixgbe_hw *);
  23. s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
  24. /* Link */
  25. s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
  26. s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
  27. s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
  28. bool *);
  29. /* RAR, Multicast, VLAN */
  30. s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
  31. s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
  32. s32 (*init_rx_addrs)(struct ixgbe_hw *);
  33. s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
  34. s32 (*update_xcast_mode)(struct ixgbe_hw *, int);
  35. s32 (*get_link_state)(struct ixgbe_hw *hw, bool *link_state);
  36. s32 (*enable_mc)(struct ixgbe_hw *);
  37. s32 (*disable_mc)(struct ixgbe_hw *);
  38. s32 (*clear_vfta)(struct ixgbe_hw *);
  39. s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
  40. s32 (*set_rlpml)(struct ixgbe_hw *, u16);
  41. };
  42. enum ixgbe_mac_type {
  43. ixgbe_mac_unknown = 0,
  44. ixgbe_mac_82599_vf,
  45. ixgbe_mac_X540_vf,
  46. ixgbe_mac_X550_vf,
  47. ixgbe_mac_X550EM_x_vf,
  48. ixgbe_mac_x550em_a_vf,
  49. ixgbe_num_macs
  50. };
  51. struct ixgbe_mac_info {
  52. struct ixgbe_mac_operations ops;
  53. u8 addr[6];
  54. u8 perm_addr[6];
  55. enum ixgbe_mac_type type;
  56. s32 mc_filter_type;
  57. bool get_link_status;
  58. u32 max_tx_queues;
  59. u32 max_rx_queues;
  60. u32 max_msix_vectors;
  61. };
  62. struct ixgbe_mbx_operations {
  63. s32 (*init_params)(struct ixgbe_hw *hw);
  64. void (*release)(struct ixgbe_hw *hw);
  65. s32 (*read)(struct ixgbe_hw *, u32 *, u16);
  66. s32 (*write)(struct ixgbe_hw *, u32 *, u16);
  67. s32 (*check_for_msg)(struct ixgbe_hw *);
  68. s32 (*check_for_ack)(struct ixgbe_hw *);
  69. s32 (*check_for_rst)(struct ixgbe_hw *);
  70. };
  71. struct ixgbe_mbx_stats {
  72. u32 msgs_tx;
  73. u32 msgs_rx;
  74. u32 acks;
  75. u32 reqs;
  76. u32 rsts;
  77. };
  78. struct ixgbe_mbx_info {
  79. struct ixgbe_mbx_operations ops;
  80. struct ixgbe_mbx_stats stats;
  81. u32 timeout;
  82. u32 udelay;
  83. u32 vf_mailbox;
  84. u16 size;
  85. };
  86. struct ixgbe_hw {
  87. void *back;
  88. u8 __iomem *hw_addr;
  89. struct ixgbe_mac_info mac;
  90. struct ixgbe_mbx_info mbx;
  91. u16 device_id;
  92. u16 subsystem_vendor_id;
  93. u16 subsystem_device_id;
  94. u16 vendor_id;
  95. u8 revision_id;
  96. bool adapter_stopped;
  97. int api_version;
  98. };
  99. struct ixgbevf_hw_stats {
  100. u64 base_vfgprc;
  101. u64 base_vfgptc;
  102. u64 base_vfgorc;
  103. u64 base_vfgotc;
  104. u64 base_vfmprc;
  105. u64 last_vfgprc;
  106. u64 last_vfgptc;
  107. u64 last_vfgorc;
  108. u64 last_vfgotc;
  109. u64 last_vfmprc;
  110. u64 vfgprc;
  111. u64 vfgptc;
  112. u64 vfgorc;
  113. u64 vfgotc;
  114. u64 vfmprc;
  115. u64 saved_reset_vfgprc;
  116. u64 saved_reset_vfgptc;
  117. u64 saved_reset_vfgorc;
  118. u64 saved_reset_vfgotc;
  119. u64 saved_reset_vfmprc;
  120. };
  121. struct ixgbevf_info {
  122. enum ixgbe_mac_type mac;
  123. const struct ixgbe_mac_operations *mac_ops;
  124. };
  125. #define IXGBE_FAILED_READ_REG 0xffffffffU
  126. #define IXGBE_REMOVED(a) unlikely(!(a))
  127. static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
  128. {
  129. u8 __iomem *reg_addr = READ_ONCE(hw->hw_addr);
  130. if (IXGBE_REMOVED(reg_addr))
  131. return;
  132. writel(value, reg_addr + reg);
  133. }
  134. #define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
  135. u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
  136. #define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
  137. static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
  138. u32 offset, u32 value)
  139. {
  140. ixgbe_write_reg(hw, reg + (offset << 2), value);
  141. }
  142. #define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
  143. static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
  144. u32 offset)
  145. {
  146. return ixgbevf_read_reg(hw, reg + (offset << 2));
  147. }
  148. #define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
  149. int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
  150. unsigned int *default_tc);
  151. int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues);
  152. int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key);
  153. #endif /* __IXGBE_VF_H__ */