2 * aQuantia Corporation Network Driver
3 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
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.
10 /* File hw_atl_utils.h: Declaration of common functions for Atlantic hardware
14 #ifndef HW_ATL_UTILS_H
15 #define HW_ATL_UTILS_H
17 #include "../aq_common.h"
19 #define HW_ATL_FLUSH() { (void)aq_hw_read_reg(self, 0x10); }
21 struct __packed hw_atl_stats_s {
39 union __packed ip_addr {
49 struct __packed hw_aq_atl_utils_fw_rpc {
75 u16 friendly_name_len;
76 u16 friendly_name[65];
78 u32 next_wol_pattern_offset;
83 u8 ipv4_source_address[4];
84 u8 ipv4_dest_address[4];
85 u16 tcp_source_port_number;
86 u16 tcp_dest_port_number;
87 } ipv4_tcp_syn_parameters;
91 u8 ipv6_source_address[16];
92 u8 ipv6_dest_address[16];
93 u16 tcp_source_port_number;
94 u16 tcp_dest_port_number;
95 } ipv6_tcp_syn_parameters;
99 } eapol_request_id_message_parameters;
107 } wol_bit_map_pattern;
112 u32 is_wake_on_link_down;
113 u32 is_wake_on_link_up;
118 struct __packed hw_aq_atl_utils_mbox_header {
124 struct __packed hw_aq_atl_utils_mbox {
125 struct hw_aq_atl_utils_mbox_header header;
126 struct hw_atl_stats_s stats;
129 struct __packed hw_atl_s {
131 struct hw_atl_stats_s last_stats;
132 struct hw_atl_stats_s curr_stats;
134 unsigned int chip_features;
140 struct hw_aq_atl_utils_fw_rpc rpc;
143 #define SELF ((struct hw_atl_s *)self)
145 #define PHAL_ATLANTIC ((struct hw_atl_s *)((void *)(self)))
146 #define PHAL_ATLANTIC_A0 ((struct hw_atl_s *)((void *)(self)))
147 #define PHAL_ATLANTIC_B0 ((struct hw_atl_s *)((void *)(self)))
149 #define HAL_ATLANTIC_UTILS_CHIP_MIPS 0x00000001U
150 #define HAL_ATLANTIC_UTILS_CHIP_TPO2 0x00000002U
151 #define HAL_ATLANTIC_UTILS_CHIP_RPF2 0x00000004U
152 #define HAL_ATLANTIC_UTILS_CHIP_MPI_AQ 0x00000010U
153 #define HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 0x01000000U
154 #define HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 0x02000000U
156 #define IS_CHIP_FEATURE(_F_) (HAL_ATLANTIC_UTILS_CHIP_##_F_ & \
157 PHAL_ATLANTIC->chip_features)
159 enum hal_atl_utils_fw_state_e {
166 #define HAL_ATLANTIC_RATE_10G BIT(0)
167 #define HAL_ATLANTIC_RATE_5G BIT(1)
168 #define HAL_ATLANTIC_RATE_5GSR BIT(2)
169 #define HAL_ATLANTIC_RATE_2GS BIT(3)
170 #define HAL_ATLANTIC_RATE_1G BIT(4)
171 #define HAL_ATLANTIC_RATE_100M BIT(5)
172 #define HAL_ATLANTIC_RATE_INVALID BIT(6)
174 void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p);
176 int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
177 struct hw_aq_atl_utils_mbox_header *pmbox);
179 void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
180 struct hw_aq_atl_utils_mbox *pmbox);
182 void hw_atl_utils_mpi_set(struct aq_hw_s *self,
183 enum hal_atl_utils_fw_state_e state,
186 int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed,
187 enum hal_atl_utils_fw_state_e state);
189 int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self);
191 int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,
192 struct aq_hw_caps_s *aq_hw_caps,
195 unsigned int hw_atl_utils_mbps_2_speed_index(unsigned int mbps);
197 int hw_atl_utils_hw_get_regs(struct aq_hw_s *self,
198 struct aq_hw_caps_s *aq_hw_caps,
201 int hw_atl_utils_hw_set_power(struct aq_hw_s *self,
202 unsigned int power_state);
204 int hw_atl_utils_hw_deinit(struct aq_hw_s *self);
206 int hw_atl_utils_get_fw_version(struct aq_hw_s *self, u32 *fw_version);
208 int hw_atl_utils_update_stats(struct aq_hw_s *self);
210 int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
212 unsigned int *p_count);
214 #endif /* HW_ATL_UTILS_H */