net: aquantia: styling fixes on ptp related functions
[linux-block.git] / drivers / net / ethernet / aquantia / atlantic / aq_hw.h
CommitLineData
75a6faf6 1/* SPDX-License-Identifier: GPL-2.0-only */
753f4783
DV
2/*
3 * aQuantia Corporation Network Driver
910479a9 4 * Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved
753f4783
DV
5 */
6
1a713f87 7/* File aq_hw.h: Declaration of abstract interface for NIC hardware specific
753f4783
DV
8 * functions.
9 */
10
11#ifndef AQ_HW_H
12#define AQ_HW_H
13
14#include "aq_common.h"
db550615 15#include "aq_rss.h"
1a713f87 16#include "hw_atl/hw_atl_utils.h"
753f4783 17
910479a9
EP
18#define AQ_HW_MAC_COUNTER_HZ 312500000ll
19#define AQ_HW_PHY_COUNTER_HZ 160000000ll
20
54bcb3d1
DB
21#define AQ_RX_FIRST_LOC_FVLANID 0U
22#define AQ_RX_LAST_LOC_FVLANID 15U
9a8cac4b
DB
23#define AQ_RX_FIRST_LOC_FETHERT 16U
24#define AQ_RX_LAST_LOC_FETHERT 31U
a6ed6f22
DB
25#define AQ_RX_FIRST_LOC_FL3L4 32U
26#define AQ_RX_LAST_LOC_FL3L4 39U
27#define AQ_RX_MAX_RXNFC_LOC AQ_RX_LAST_LOC_FL3L4
54bcb3d1
DB
28#define AQ_VLAN_MAX_FILTERS \
29 (AQ_RX_LAST_LOC_FVLANID - AQ_RX_FIRST_LOC_FVLANID + 1U)
7975d2af 30#define AQ_RX_QUEUE_NOT_ASSIGNED 0xFFU
a6ed6f22 31
753f4783
DV
32/* NIC H/W capabilities */
33struct aq_hw_caps_s {
34 u64 hw_features;
35 u64 link_speed_msk;
36 unsigned int hw_priv_flags;
4948293f 37 u32 media_type;
c1af5427
AM
38 u32 rxds_max;
39 u32 txds_max;
40 u32 rxds_min;
41 u32 txds_min;
753f4783
DV
42 u32 txhwb_alignment;
43 u32 irq_mask;
44 u32 vecs;
45 u32 mtu;
46 u32 mac_regs_count;
76c19c6c 47 u32 hw_alive_check_addr;
753f4783
DV
48 u8 msix_irqs;
49 u8 tcs;
50 u8 rxd_alignment;
51 u8 rxd_size;
52 u8 txd_alignment;
53 u8 txd_size;
54 u8 tx_rings;
55 u8 rx_rings;
56 bool flow_control;
57 bool is_64_dma;
753f4783
DV
58};
59
60struct aq_hw_link_status_s {
61 unsigned int mbps;
62};
63
be08d839
IR
64struct aq_stats_s {
65 u64 uprc;
66 u64 mprc;
67 u64 bprc;
68 u64 erpt;
69 u64 uptc;
70 u64 mptc;
71 u64 bptc;
72 u64 erpr;
73 u64 mbtc;
74 u64 bbtc;
75 u64 mbrc;
76 u64 bbrc;
77 u64 ubrc;
78 u64 ubtc;
79 u64 dpc;
80 u64 dma_pkt_rc;
81 u64 dma_pkt_tc;
82 u64 dma_oct_rc;
83 u64 dma_oct_tc;
84};
85
753f4783
DV
86#define AQ_HW_IRQ_INVALID 0U
87#define AQ_HW_IRQ_LEGACY 1U
88#define AQ_HW_IRQ_MSI 2U
89#define AQ_HW_IRQ_MSIX 3U
90
3dd3e236
IR
91#define AQ_HW_SERVICE_IRQS 1U
92
753f4783
DV
93#define AQ_HW_POWER_STATE_D0 0U
94#define AQ_HW_POWER_STATE_D3 3U
95
96#define AQ_HW_FLAG_STARTED 0x00000004U
97#define AQ_HW_FLAG_STOPPING 0x00000008U
98#define AQ_HW_FLAG_RESETTING 0x00000010U
99#define AQ_HW_FLAG_CLOSING 0x00000020U
910479a9 100#define AQ_HW_PTP_AVAILABLE 0x01000000U
753f4783
DV
101#define AQ_HW_LINK_DOWN 0x04000000U
102#define AQ_HW_FLAG_ERR_UNPLUG 0x40000000U
103#define AQ_HW_FLAG_ERR_HW 0x80000000U
104
105#define AQ_HW_FLAG_ERRORS (AQ_HW_FLAG_ERR_HW | AQ_HW_FLAG_ERR_UNPLUG)
106
db550615
IR
107#define AQ_NIC_FLAGS_IS_NOT_READY (AQ_NIC_FLAG_STOPPING | \
108 AQ_NIC_FLAG_RESETTING | AQ_NIC_FLAG_CLOSING | \
109 AQ_NIC_FLAG_ERR_UNPLUG | AQ_NIC_FLAG_ERR_HW)
110
111#define AQ_NIC_FLAGS_IS_NOT_TX_READY (AQ_NIC_FLAGS_IS_NOT_READY | \
112 AQ_NIC_LINK_DOWN)
113
4948293f
IR
114#define AQ_HW_MEDIA_TYPE_TP 1U
115#define AQ_HW_MEDIA_TYPE_FIBRE 2U
116
c1af5427
AM
117#define AQ_HW_TXD_MULTIPLE 8U
118#define AQ_HW_RXD_MULTIPLE 8U
119
94b3b542
IR
120#define AQ_HW_MULTICAST_ADDRESS_MAX 32U
121
753f4783 122struct aq_hw_s {
78f5193d 123 atomic_t flags;
c8c82eb3 124 u8 rbl_enabled:1;
753f4783 125 struct aq_nic_cfg_s *aq_nic_cfg;
0c58c35f 126 const struct aq_fw_ops *aq_fw_ops;
753f4783 127 void __iomem *mmio;
753f4783 128 struct aq_hw_link_status_s aq_link_status;
8f60f762 129 struct hw_atl_utils_mbox mbox;
1a713f87
IR
130 struct hw_atl_stats_s last_stats;
131 struct aq_stats_s curr_stats;
132 u64 speed;
133 u32 itr_tx;
134 u32 itr_rx;
135 unsigned int chip_features;
136 u32 fw_ver_actual;
137 atomic_t dpc;
138 u32 mbox_addr;
139 u32 rpc_addr;
140 u32 rpc_tid;
8f60f762 141 struct hw_atl_utils_fw_rpc rpc;
910479a9 142 s64 ptp_clk_offset;
753f4783
DV
143};
144
145struct aq_ring_s;
146struct aq_ring_param_s;
753f4783 147struct sk_buff;
a6ed6f22 148struct aq_rx_filter_l3l4;
753f4783
DV
149
150struct aq_hw_ops {
753f4783 151
753f4783
DV
152 int (*hw_ring_tx_xmit)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
153 unsigned int frags);
154
155 int (*hw_ring_rx_receive)(struct aq_hw_s *self,
156 struct aq_ring_s *aq_ring);
157
158 int (*hw_ring_rx_fill)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
159 unsigned int sw_tail_old);
160
161 int (*hw_ring_tx_head_update)(struct aq_hw_s *self,
162 struct aq_ring_s *aq_ring);
163
753f4783
DV
164 int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
165
753f4783
DV
166 int (*hw_reset)(struct aq_hw_s *self);
167
1a713f87 168 int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
753f4783
DV
169
170 int (*hw_start)(struct aq_hw_s *self);
171
172 int (*hw_stop)(struct aq_hw_s *self);
173
174 int (*hw_ring_tx_init)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
175 struct aq_ring_param_s *aq_ring_param);
176
177 int (*hw_ring_tx_start)(struct aq_hw_s *self,
178 struct aq_ring_s *aq_ring);
179
180 int (*hw_ring_tx_stop)(struct aq_hw_s *self,
181 struct aq_ring_s *aq_ring);
182
183 int (*hw_ring_rx_init)(struct aq_hw_s *self,
184 struct aq_ring_s *aq_ring,
185 struct aq_ring_param_s *aq_ring_param);
186
187 int (*hw_ring_rx_start)(struct aq_hw_s *self,
188 struct aq_ring_s *aq_ring);
189
190 int (*hw_ring_rx_stop)(struct aq_hw_s *self,
191 struct aq_ring_s *aq_ring);
192
193 int (*hw_irq_enable)(struct aq_hw_s *self, u64 mask);
194
195 int (*hw_irq_disable)(struct aq_hw_s *self, u64 mask);
196
197 int (*hw_irq_read)(struct aq_hw_s *self, u64 *mask);
198
199 int (*hw_packet_filter_set)(struct aq_hw_s *self,
200 unsigned int packet_filter);
201
a6ed6f22
DB
202 int (*hw_filter_l3l4_set)(struct aq_hw_s *self,
203 struct aq_rx_filter_l3l4 *data);
204
205 int (*hw_filter_l3l4_clear)(struct aq_hw_s *self,
206 struct aq_rx_filter_l3l4 *data);
207
9a8cac4b
DB
208 int (*hw_filter_l2_set)(struct aq_hw_s *self,
209 struct aq_rx_filter_l2 *data);
210
211 int (*hw_filter_l2_clear)(struct aq_hw_s *self,
212 struct aq_rx_filter_l2 *data);
213
54bcb3d1
DB
214 int (*hw_filter_vlan_set)(struct aq_hw_s *self,
215 struct aq_rx_filter_vlan *aq_vlans);
216
217 int (*hw_filter_vlan_ctrl)(struct aq_hw_s *self, bool enable);
218
753f4783 219 int (*hw_multicast_list_set)(struct aq_hw_s *self,
94b3b542 220 u8 ar_mac[AQ_HW_MULTICAST_ADDRESS_MAX]
753f4783
DV
221 [ETH_ALEN],
222 u32 count);
223
b82ee71a 224 int (*hw_interrupt_moderation_set)(struct aq_hw_s *self);
753f4783
DV
225
226 int (*hw_rss_set)(struct aq_hw_s *self,
227 struct aq_rss_parameters *rss_params);
228
229 int (*hw_rss_hash_set)(struct aq_hw_s *self,
230 struct aq_rss_parameters *rss_params);
231
232 int (*hw_get_regs)(struct aq_hw_s *self,
4cbc9f92
IR
233 const struct aq_hw_caps_s *aq_hw_caps,
234 u32 *regs_buff);
753f4783 235
be08d839 236 struct aq_stats_s *(*hw_get_hw_stats)(struct aq_hw_s *self);
753f4783
DV
237
238 int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version);
239
bbb67a44
DB
240 int (*hw_set_offload)(struct aq_hw_s *self,
241 struct aq_nic_cfg_s *aq_nic_cfg);
242
94ad9455
EP
243 int (*hw_tx_tc_mode_get)(struct aq_hw_s *self, u32 *tc_mode);
244
245 int (*hw_rx_tc_mode_get)(struct aq_hw_s *self, u32 *tc_mode);
246
910479a9
EP
247 void (*hw_get_ptp_ts)(struct aq_hw_s *self, u64 *stamp);
248
249 int (*hw_adj_clock_freq)(struct aq_hw_s *self, s32 delta);
250
251 int (*hw_adj_sys_clock)(struct aq_hw_s *self, s64 delta);
252
253 int (*hw_set_sys_clock)(struct aq_hw_s *self, u64 time, u64 ts);
254
35e8e8b4 255 int (*hw_set_fc)(struct aq_hw_s *self, u32 fc, u32 tc);
753f4783
DV
256};
257
0c58c35f
IR
258struct aq_fw_ops {
259 int (*init)(struct aq_hw_s *self);
260
44e00dd8
IR
261 int (*deinit)(struct aq_hw_s *self);
262
0c58c35f
IR
263 int (*reset)(struct aq_hw_s *self);
264
b8d68b62
AM
265 int (*renegotiate)(struct aq_hw_s *self);
266
0c58c35f
IR
267 int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
268
269 int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
270
44e00dd8
IR
271 int (*set_state)(struct aq_hw_s *self,
272 enum hal_atl_utils_fw_state_e state);
0c58c35f
IR
273
274 int (*update_link_status)(struct aq_hw_s *self);
275
276 int (*update_stats)(struct aq_hw_s *self);
44e00dd8 277
8f894011
YE
278 int (*get_phy_temp)(struct aq_hw_s *self, int *temp);
279
35e8e8b4
IR
280 u32 (*get_flow_control)(struct aq_hw_s *self, u32 *fcmode);
281
44e00dd8 282 int (*set_flow_control)(struct aq_hw_s *self);
a0da96c0
YE
283
284 int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
285 u8 *mac);
92ab6407 286
910479a9
EP
287 int (*send_fw_request)(struct aq_hw_s *self,
288 const struct hw_fw_request_iface *fw_req,
289 size_t size);
290
291 void (*enable_ptp)(struct aq_hw_s *self, int enable);
292
92ab6407
YE
293 int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);
294
295 int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
296 u32 *supported_rates);
0c58c35f
IR
297};
298
753f4783 299#endif /* AQ_HW_H */