fm10k_common.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2013 - 2018 Intel Corporation. */
  3. #ifndef _FM10K_COMMON_H_
  4. #define _FM10K_COMMON_H_
  5. #include "fm10k_type.h"
  6. #define FM10K_REMOVED(hw_addr) unlikely(!(hw_addr))
  7. /* PCI configuration read */
  8. u16 fm10k_read_pci_cfg_word(struct fm10k_hw *hw, u32 reg);
  9. /* read operations, indexed using DWORDS */
  10. u32 fm10k_read_reg(struct fm10k_hw *hw, int reg);
  11. /* write operations, indexed using DWORDS */
  12. #define fm10k_write_reg(hw, reg, val) \
  13. do { \
  14. u32 __iomem *hw_addr = READ_ONCE((hw)->hw_addr); \
  15. if (!FM10K_REMOVED(hw_addr)) \
  16. writel((val), &hw_addr[(reg)]); \
  17. } while (0)
  18. /* Switch register write operations, index using DWORDS */
  19. #define fm10k_write_sw_reg(hw, reg, val) \
  20. do { \
  21. u32 __iomem *sw_addr = READ_ONCE((hw)->sw_addr); \
  22. if (!FM10K_REMOVED(sw_addr)) \
  23. writel((val), &sw_addr[(reg)]); \
  24. } while (0)
  25. /* read ctrl register which has no clear on read fields as PCIe flush */
  26. #define fm10k_write_flush(hw) fm10k_read_reg((hw), FM10K_CTRL)
  27. s32 fm10k_get_bus_info_generic(struct fm10k_hw *hw);
  28. s32 fm10k_get_invariants_generic(struct fm10k_hw *hw);
  29. s32 fm10k_disable_queues_generic(struct fm10k_hw *hw, u16 q_cnt);
  30. s32 fm10k_start_hw_generic(struct fm10k_hw *hw);
  31. s32 fm10k_stop_hw_generic(struct fm10k_hw *hw);
  32. u32 fm10k_read_hw_stats_32b(struct fm10k_hw *hw, u32 addr,
  33. struct fm10k_hw_stat *stat);
  34. #define fm10k_update_hw_base_32b(stat, delta) ((stat)->base_l += (delta))
  35. void fm10k_update_hw_stats_q(struct fm10k_hw *hw, struct fm10k_hw_stats_q *q,
  36. u32 idx, u32 count);
  37. #define fm10k_unbind_hw_stats_32b(s) ((s)->base_h = 0)
  38. void fm10k_unbind_hw_stats_q(struct fm10k_hw_stats_q *q, u32 idx, u32 count);
  39. s32 fm10k_get_host_state_generic(struct fm10k_hw *hw, bool *host_ready);
  40. #endif /* _FM10K_COMMON_H_ */