aq_hw.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * aQuantia Corporation Network Driver
  3. * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. */
  9. /* File aq_hw.h: Declaration of abstract interface for NIC hardware specific
  10. * functions.
  11. */
  12. #ifndef AQ_HW_H
  13. #define AQ_HW_H
  14. #include "aq_common.h"
  15. #include "aq_rss.h"
  16. #include "hw_atl/hw_atl_utils.h"
  17. /* NIC H/W capabilities */
  18. struct aq_hw_caps_s {
  19. u64 hw_features;
  20. u64 link_speed_msk;
  21. unsigned int hw_priv_flags;
  22. u32 media_type;
  23. u32 rxds;
  24. u32 txds;
  25. u32 txhwb_alignment;
  26. u32 irq_mask;
  27. u32 vecs;
  28. u32 mtu;
  29. u32 mac_regs_count;
  30. u32 hw_alive_check_addr;
  31. u8 msix_irqs;
  32. u8 tcs;
  33. u8 rxd_alignment;
  34. u8 rxd_size;
  35. u8 txd_alignment;
  36. u8 txd_size;
  37. u8 tx_rings;
  38. u8 rx_rings;
  39. bool flow_control;
  40. bool is_64_dma;
  41. };
  42. struct aq_hw_link_status_s {
  43. unsigned int mbps;
  44. };
  45. struct aq_stats_s {
  46. u64 uprc;
  47. u64 mprc;
  48. u64 bprc;
  49. u64 erpt;
  50. u64 uptc;
  51. u64 mptc;
  52. u64 bptc;
  53. u64 erpr;
  54. u64 mbtc;
  55. u64 bbtc;
  56. u64 mbrc;
  57. u64 bbrc;
  58. u64 ubrc;
  59. u64 ubtc;
  60. u64 dpc;
  61. u64 dma_pkt_rc;
  62. u64 dma_pkt_tc;
  63. u64 dma_oct_rc;
  64. u64 dma_oct_tc;
  65. };
  66. #define AQ_HW_IRQ_INVALID 0U
  67. #define AQ_HW_IRQ_LEGACY 1U
  68. #define AQ_HW_IRQ_MSI 2U
  69. #define AQ_HW_IRQ_MSIX 3U
  70. #define AQ_HW_POWER_STATE_D0 0U
  71. #define AQ_HW_POWER_STATE_D3 3U
  72. #define AQ_HW_FLAG_STARTED 0x00000004U
  73. #define AQ_HW_FLAG_STOPPING 0x00000008U
  74. #define AQ_HW_FLAG_RESETTING 0x00000010U
  75. #define AQ_HW_FLAG_CLOSING 0x00000020U
  76. #define AQ_HW_LINK_DOWN 0x04000000U
  77. #define AQ_HW_FLAG_ERR_UNPLUG 0x40000000U
  78. #define AQ_HW_FLAG_ERR_HW 0x80000000U
  79. #define AQ_HW_FLAG_ERRORS (AQ_HW_FLAG_ERR_HW | AQ_HW_FLAG_ERR_UNPLUG)
  80. #define AQ_NIC_FLAGS_IS_NOT_READY (AQ_NIC_FLAG_STOPPING | \
  81. AQ_NIC_FLAG_RESETTING | AQ_NIC_FLAG_CLOSING | \
  82. AQ_NIC_FLAG_ERR_UNPLUG | AQ_NIC_FLAG_ERR_HW)
  83. #define AQ_NIC_FLAGS_IS_NOT_TX_READY (AQ_NIC_FLAGS_IS_NOT_READY | \
  84. AQ_NIC_LINK_DOWN)
  85. #define AQ_HW_MEDIA_TYPE_TP 1U
  86. #define AQ_HW_MEDIA_TYPE_FIBRE 2U
  87. #define AQ_HW_MULTICAST_ADDRESS_MAX 32U
  88. struct aq_hw_s {
  89. atomic_t flags;
  90. u8 rbl_enabled:1;
  91. struct aq_nic_cfg_s *aq_nic_cfg;
  92. const struct aq_fw_ops *aq_fw_ops;
  93. void __iomem *mmio;
  94. struct aq_hw_link_status_s aq_link_status;
  95. struct hw_aq_atl_utils_mbox mbox;
  96. struct hw_atl_stats_s last_stats;
  97. struct aq_stats_s curr_stats;
  98. u64 speed;
  99. u32 itr_tx;
  100. u32 itr_rx;
  101. unsigned int chip_features;
  102. u32 fw_ver_actual;
  103. atomic_t dpc;
  104. u32 mbox_addr;
  105. u32 rpc_addr;
  106. u32 rpc_tid;
  107. struct hw_aq_atl_utils_fw_rpc rpc;
  108. };
  109. struct aq_ring_s;
  110. struct aq_ring_param_s;
  111. struct sk_buff;
  112. struct aq_hw_ops {
  113. int (*hw_ring_tx_xmit)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
  114. unsigned int frags);
  115. int (*hw_ring_rx_receive)(struct aq_hw_s *self,
  116. struct aq_ring_s *aq_ring);
  117. int (*hw_ring_rx_fill)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
  118. unsigned int sw_tail_old);
  119. int (*hw_ring_tx_head_update)(struct aq_hw_s *self,
  120. struct aq_ring_s *aq_ring);
  121. int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
  122. int (*hw_reset)(struct aq_hw_s *self);
  123. int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
  124. int (*hw_start)(struct aq_hw_s *self);
  125. int (*hw_stop)(struct aq_hw_s *self);
  126. int (*hw_ring_tx_init)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
  127. struct aq_ring_param_s *aq_ring_param);
  128. int (*hw_ring_tx_start)(struct aq_hw_s *self,
  129. struct aq_ring_s *aq_ring);
  130. int (*hw_ring_tx_stop)(struct aq_hw_s *self,
  131. struct aq_ring_s *aq_ring);
  132. int (*hw_ring_rx_init)(struct aq_hw_s *self,
  133. struct aq_ring_s *aq_ring,
  134. struct aq_ring_param_s *aq_ring_param);
  135. int (*hw_ring_rx_start)(struct aq_hw_s *self,
  136. struct aq_ring_s *aq_ring);
  137. int (*hw_ring_rx_stop)(struct aq_hw_s *self,
  138. struct aq_ring_s *aq_ring);
  139. int (*hw_irq_enable)(struct aq_hw_s *self, u64 mask);
  140. int (*hw_irq_disable)(struct aq_hw_s *self, u64 mask);
  141. int (*hw_irq_read)(struct aq_hw_s *self, u64 *mask);
  142. int (*hw_packet_filter_set)(struct aq_hw_s *self,
  143. unsigned int packet_filter);
  144. int (*hw_multicast_list_set)(struct aq_hw_s *self,
  145. u8 ar_mac[AQ_HW_MULTICAST_ADDRESS_MAX]
  146. [ETH_ALEN],
  147. u32 count);
  148. int (*hw_interrupt_moderation_set)(struct aq_hw_s *self);
  149. int (*hw_rss_set)(struct aq_hw_s *self,
  150. struct aq_rss_parameters *rss_params);
  151. int (*hw_rss_hash_set)(struct aq_hw_s *self,
  152. struct aq_rss_parameters *rss_params);
  153. int (*hw_get_regs)(struct aq_hw_s *self,
  154. const struct aq_hw_caps_s *aq_hw_caps,
  155. u32 *regs_buff);
  156. struct aq_stats_s *(*hw_get_hw_stats)(struct aq_hw_s *self);
  157. int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version);
  158. int (*hw_deinit)(struct aq_hw_s *self);
  159. int (*hw_set_power)(struct aq_hw_s *self, unsigned int power_state);
  160. };
  161. struct aq_fw_ops {
  162. int (*init)(struct aq_hw_s *self);
  163. int (*reset)(struct aq_hw_s *self);
  164. int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
  165. int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
  166. int (*set_state)(struct aq_hw_s *self, enum hal_atl_utils_fw_state_e state);
  167. int (*update_link_status)(struct aq_hw_s *self);
  168. int (*update_stats)(struct aq_hw_s *self);
  169. };
  170. #endif /* AQ_HW_H */