vf.h 4.6 KB

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