aq_hw.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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: Declaraion 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. /* NIC H/W capabilities */
  16. struct aq_hw_caps_s {
  17. u64 hw_features;
  18. u64 link_speed_msk;
  19. unsigned int hw_priv_flags;
  20. u32 rxds;
  21. u32 txds;
  22. u32 txhwb_alignment;
  23. u32 irq_mask;
  24. u32 vecs;
  25. u32 mtu;
  26. u32 mac_regs_count;
  27. u8 ports;
  28. u8 msix_irqs;
  29. u8 tcs;
  30. u8 rxd_alignment;
  31. u8 rxd_size;
  32. u8 txd_alignment;
  33. u8 txd_size;
  34. u8 tx_rings;
  35. u8 rx_rings;
  36. bool flow_control;
  37. bool is_64_dma;
  38. u32 fw_ver_expected;
  39. };
  40. struct aq_hw_link_status_s {
  41. unsigned int mbps;
  42. };
  43. #define AQ_HW_IRQ_INVALID 0U
  44. #define AQ_HW_IRQ_LEGACY 1U
  45. #define AQ_HW_IRQ_MSI 2U
  46. #define AQ_HW_IRQ_MSIX 3U
  47. #define AQ_HW_POWER_STATE_D0 0U
  48. #define AQ_HW_POWER_STATE_D3 3U
  49. #define AQ_HW_FLAG_STARTED 0x00000004U
  50. #define AQ_HW_FLAG_STOPPING 0x00000008U
  51. #define AQ_HW_FLAG_RESETTING 0x00000010U
  52. #define AQ_HW_FLAG_CLOSING 0x00000020U
  53. #define AQ_HW_LINK_DOWN 0x04000000U
  54. #define AQ_HW_FLAG_ERR_UNPLUG 0x40000000U
  55. #define AQ_HW_FLAG_ERR_HW 0x80000000U
  56. #define AQ_HW_FLAG_ERRORS (AQ_HW_FLAG_ERR_HW | AQ_HW_FLAG_ERR_UNPLUG)
  57. struct aq_hw_s {
  58. struct aq_obj_s header;
  59. struct aq_nic_cfg_s *aq_nic_cfg;
  60. struct aq_pci_func_s *aq_pci_func;
  61. void __iomem *mmio;
  62. unsigned int not_ff_addr;
  63. struct aq_hw_link_status_s aq_link_status;
  64. };
  65. struct aq_ring_s;
  66. struct aq_ring_param_s;
  67. struct aq_nic_cfg_s;
  68. struct sk_buff;
  69. struct aq_hw_ops {
  70. struct aq_hw_s *(*create)(struct aq_pci_func_s *aq_pci_func,
  71. unsigned int port, struct aq_hw_ops *ops);
  72. void (*destroy)(struct aq_hw_s *self);
  73. int (*get_hw_caps)(struct aq_hw_s *self,
  74. struct aq_hw_caps_s *aq_hw_caps);
  75. int (*hw_ring_tx_xmit)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
  76. unsigned int frags);
  77. int (*hw_ring_rx_receive)(struct aq_hw_s *self,
  78. struct aq_ring_s *aq_ring);
  79. int (*hw_ring_rx_fill)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
  80. unsigned int sw_tail_old);
  81. int (*hw_ring_tx_head_update)(struct aq_hw_s *self,
  82. struct aq_ring_s *aq_ring);
  83. int (*hw_get_mac_permanent)(struct aq_hw_s *self,
  84. struct aq_hw_caps_s *aq_hw_caps,
  85. u8 *mac);
  86. int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
  87. int (*hw_get_link_status)(struct aq_hw_s *self,
  88. struct aq_hw_link_status_s *link_status);
  89. int (*hw_set_link_speed)(struct aq_hw_s *self, u32 speed);
  90. int (*hw_reset)(struct aq_hw_s *self);
  91. int (*hw_init)(struct aq_hw_s *self, struct aq_nic_cfg_s *aq_nic_cfg,
  92. u8 *mac_addr);
  93. int (*hw_start)(struct aq_hw_s *self);
  94. int (*hw_stop)(struct aq_hw_s *self);
  95. int (*hw_ring_tx_init)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
  96. struct aq_ring_param_s *aq_ring_param);
  97. int (*hw_ring_tx_start)(struct aq_hw_s *self,
  98. struct aq_ring_s *aq_ring);
  99. int (*hw_ring_tx_stop)(struct aq_hw_s *self,
  100. struct aq_ring_s *aq_ring);
  101. int (*hw_ring_rx_init)(struct aq_hw_s *self,
  102. struct aq_ring_s *aq_ring,
  103. struct aq_ring_param_s *aq_ring_param);
  104. int (*hw_ring_rx_start)(struct aq_hw_s *self,
  105. struct aq_ring_s *aq_ring);
  106. int (*hw_ring_rx_stop)(struct aq_hw_s *self,
  107. struct aq_ring_s *aq_ring);
  108. int (*hw_irq_enable)(struct aq_hw_s *self, u64 mask);
  109. int (*hw_irq_disable)(struct aq_hw_s *self, u64 mask);
  110. int (*hw_irq_read)(struct aq_hw_s *self, u64 *mask);
  111. int (*hw_packet_filter_set)(struct aq_hw_s *self,
  112. unsigned int packet_filter);
  113. int (*hw_multicast_list_set)(struct aq_hw_s *self,
  114. u8 ar_mac[AQ_CFG_MULTICAST_ADDRESS_MAX]
  115. [ETH_ALEN],
  116. u32 count);
  117. int (*hw_interrupt_moderation_set)(struct aq_hw_s *self,
  118. bool itr_enabled);
  119. int (*hw_rss_set)(struct aq_hw_s *self,
  120. struct aq_rss_parameters *rss_params);
  121. int (*hw_rss_hash_set)(struct aq_hw_s *self,
  122. struct aq_rss_parameters *rss_params);
  123. int (*hw_get_regs)(struct aq_hw_s *self,
  124. struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff);
  125. int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data,
  126. unsigned int *p_count);
  127. int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version);
  128. int (*hw_deinit)(struct aq_hw_s *self);
  129. int (*hw_set_power)(struct aq_hw_s *self, unsigned int power_state);
  130. };
  131. #endif /* AQ_HW_H */