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 10 /* File aq_hw.h: Declaraion of abstract interface for NIC hardware specific 11 * functions. 12 */ 13 14 #ifndef AQ_HW_H 15 #define AQ_HW_H 16 17 #include "aq_common.h" 18 19 /* NIC H/W capabilities */ 20 struct aq_hw_caps_s { 21 u64 hw_features; 22 u64 link_speed_msk; 23 unsigned int hw_priv_flags; 24 u32 rxds; 25 u32 txds; 26 u32 txhwb_alignment; 27 u32 irq_mask; 28 u32 vecs; 29 u32 mtu; 30 u32 mac_regs_count; 31 u8 ports; 32 u8 msix_irqs; 33 u8 tcs; 34 u8 rxd_alignment; 35 u8 rxd_size; 36 u8 txd_alignment; 37 u8 txd_size; 38 u8 tx_rings; 39 u8 rx_rings; 40 bool flow_control; 41 bool is_64_dma; 42 u32 fw_ver_expected; 43 }; 44 45 struct aq_hw_link_status_s { 46 unsigned int mbps; 47 }; 48 49 struct aq_stats_s { 50 u64 uprc; 51 u64 mprc; 52 u64 bprc; 53 u64 erpt; 54 u64 uptc; 55 u64 mptc; 56 u64 bptc; 57 u64 erpr; 58 u64 mbtc; 59 u64 bbtc; 60 u64 mbrc; 61 u64 bbrc; 62 u64 ubrc; 63 u64 ubtc; 64 u64 dpc; 65 u64 dma_pkt_rc; 66 u64 dma_pkt_tc; 67 u64 dma_oct_rc; 68 u64 dma_oct_tc; 69 }; 70 71 #define AQ_HW_IRQ_INVALID 0U 72 #define AQ_HW_IRQ_LEGACY 1U 73 #define AQ_HW_IRQ_MSI 2U 74 #define AQ_HW_IRQ_MSIX 3U 75 76 #define AQ_HW_POWER_STATE_D0 0U 77 #define AQ_HW_POWER_STATE_D3 3U 78 79 #define AQ_HW_FLAG_STARTED 0x00000004U 80 #define AQ_HW_FLAG_STOPPING 0x00000008U 81 #define AQ_HW_FLAG_RESETTING 0x00000010U 82 #define AQ_HW_FLAG_CLOSING 0x00000020U 83 #define AQ_HW_LINK_DOWN 0x04000000U 84 #define AQ_HW_FLAG_ERR_UNPLUG 0x40000000U 85 #define AQ_HW_FLAG_ERR_HW 0x80000000U 86 87 #define AQ_HW_FLAG_ERRORS (AQ_HW_FLAG_ERR_HW | AQ_HW_FLAG_ERR_UNPLUG) 88 89 struct aq_hw_s { 90 struct aq_obj_s header; 91 struct aq_nic_cfg_s *aq_nic_cfg; 92 struct aq_pci_func_s *aq_pci_func; 93 void __iomem *mmio; 94 unsigned int not_ff_addr; 95 struct aq_hw_link_status_s aq_link_status; 96 }; 97 98 struct aq_ring_s; 99 struct aq_ring_param_s; 100 struct aq_nic_cfg_s; 101 struct sk_buff; 102 103 struct aq_hw_ops { 104 struct aq_hw_s *(*create)(struct aq_pci_func_s *aq_pci_func, 105 unsigned int port, struct aq_hw_ops *ops); 106 107 void (*destroy)(struct aq_hw_s *self); 108 109 int (*get_hw_caps)(struct aq_hw_s *self, 110 struct aq_hw_caps_s *aq_hw_caps, 111 unsigned short device, 112 unsigned short subsystem_device); 113 114 int (*hw_ring_tx_xmit)(struct aq_hw_s *self, struct aq_ring_s *aq_ring, 115 unsigned int frags); 116 117 int (*hw_ring_rx_receive)(struct aq_hw_s *self, 118 struct aq_ring_s *aq_ring); 119 120 int (*hw_ring_rx_fill)(struct aq_hw_s *self, struct aq_ring_s *aq_ring, 121 unsigned int sw_tail_old); 122 123 int (*hw_ring_tx_head_update)(struct aq_hw_s *self, 124 struct aq_ring_s *aq_ring); 125 126 int (*hw_get_mac_permanent)(struct aq_hw_s *self, 127 struct aq_hw_caps_s *aq_hw_caps, 128 u8 *mac); 129 130 int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr); 131 132 int (*hw_get_link_status)(struct aq_hw_s *self); 133 134 int (*hw_set_link_speed)(struct aq_hw_s *self, u32 speed); 135 136 int (*hw_reset)(struct aq_hw_s *self); 137 138 int (*hw_init)(struct aq_hw_s *self, struct aq_nic_cfg_s *aq_nic_cfg, 139 u8 *mac_addr); 140 141 int (*hw_start)(struct aq_hw_s *self); 142 143 int (*hw_stop)(struct aq_hw_s *self); 144 145 int (*hw_ring_tx_init)(struct aq_hw_s *self, struct aq_ring_s *aq_ring, 146 struct aq_ring_param_s *aq_ring_param); 147 148 int (*hw_ring_tx_start)(struct aq_hw_s *self, 149 struct aq_ring_s *aq_ring); 150 151 int (*hw_ring_tx_stop)(struct aq_hw_s *self, 152 struct aq_ring_s *aq_ring); 153 154 int (*hw_ring_rx_init)(struct aq_hw_s *self, 155 struct aq_ring_s *aq_ring, 156 struct aq_ring_param_s *aq_ring_param); 157 158 int (*hw_ring_rx_start)(struct aq_hw_s *self, 159 struct aq_ring_s *aq_ring); 160 161 int (*hw_ring_rx_stop)(struct aq_hw_s *self, 162 struct aq_ring_s *aq_ring); 163 164 int (*hw_irq_enable)(struct aq_hw_s *self, u64 mask); 165 166 int (*hw_irq_disable)(struct aq_hw_s *self, u64 mask); 167 168 int (*hw_irq_read)(struct aq_hw_s *self, u64 *mask); 169 170 int (*hw_packet_filter_set)(struct aq_hw_s *self, 171 unsigned int packet_filter); 172 173 int (*hw_multicast_list_set)(struct aq_hw_s *self, 174 u8 ar_mac[AQ_CFG_MULTICAST_ADDRESS_MAX] 175 [ETH_ALEN], 176 u32 count); 177 178 int (*hw_interrupt_moderation_set)(struct aq_hw_s *self); 179 180 int (*hw_rss_set)(struct aq_hw_s *self, 181 struct aq_rss_parameters *rss_params); 182 183 int (*hw_rss_hash_set)(struct aq_hw_s *self, 184 struct aq_rss_parameters *rss_params); 185 186 int (*hw_get_regs)(struct aq_hw_s *self, 187 struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff); 188 189 int (*hw_update_stats)(struct aq_hw_s *self); 190 191 struct aq_stats_s *(*hw_get_hw_stats)(struct aq_hw_s *self); 192 193 int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version); 194 195 int (*hw_deinit)(struct aq_hw_s *self); 196 197 int (*hw_set_power)(struct aq_hw_s *self, unsigned int power_state); 198 }; 199 200 #endif /* AQ_HW_H */ 201