ea6de98314bebe90f95fe4d07c91d918ae123340
[deb_dpdk.git] / drivers / net / sfc / base / siena_impl.h
1 /*
2  * Copyright (c) 2009-2016 Solarflare Communications Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  *    this list of conditions and the following disclaimer in the documentation
12  *    and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * The views and conclusions contained in the software and documentation are
27  * those of the authors and should not be interpreted as representing official
28  * policies, either expressed or implied, of the FreeBSD Project.
29  */
30
31 #ifndef _SYS_SIENA_IMPL_H
32 #define _SYS_SIENA_IMPL_H
33
34 #include "efx.h"
35 #include "efx_regs.h"
36 #include "efx_mcdi.h"
37 #include "siena_flash.h"
38
39 #ifdef  __cplusplus
40 extern "C" {
41 #endif
42
43 #define SIENA_NVRAM_CHUNK 0x80
44
45 extern  __checkReturn   efx_rc_t
46 siena_nic_probe(
47         __in            efx_nic_t *enp);
48
49 extern  __checkReturn   efx_rc_t
50 siena_nic_reset(
51         __in            efx_nic_t *enp);
52
53 extern  __checkReturn   efx_rc_t
54 siena_nic_init(
55         __in            efx_nic_t *enp);
56
57 #if EFSYS_OPT_DIAG
58
59 extern  __checkReturn   efx_rc_t
60 siena_nic_register_test(
61         __in            efx_nic_t *enp);
62
63 #endif  /* EFSYS_OPT_DIAG */
64
65 extern                  void
66 siena_nic_fini(
67         __in            efx_nic_t *enp);
68
69 extern                  void
70 siena_nic_unprobe(
71         __in            efx_nic_t *enp);
72
73 #define SIENA_SRAM_ROWS 0x12000
74
75 extern                  void
76 siena_sram_init(
77         __in            efx_nic_t *enp);
78
79 #if EFSYS_OPT_DIAG
80
81 extern  __checkReturn   efx_rc_t
82 siena_sram_test(
83         __in            efx_nic_t *enp,
84         __in            efx_sram_pattern_fn_t func);
85
86 #endif  /* EFSYS_OPT_DIAG */
87
88 #if EFSYS_OPT_MCDI
89
90 extern  __checkReturn   efx_rc_t
91 siena_mcdi_init(
92         __in            efx_nic_t *enp,
93         __in            const efx_mcdi_transport_t *mtp);
94
95 extern                  void
96 siena_mcdi_send_request(
97         __in                    efx_nic_t *enp,
98         __in_bcount(hdr_len)    void *hdrp,
99         __in                    size_t hdr_len,
100         __in_bcount(sdu_len)    void *sdup,
101         __in                    size_t sdu_len);
102
103 extern  __checkReturn   boolean_t
104 siena_mcdi_poll_response(
105         __in            efx_nic_t *enp);
106
107 extern                  void
108 siena_mcdi_read_response(
109         __in                    efx_nic_t *enp,
110         __out_bcount(length)    void *bufferp,
111         __in                    size_t offset,
112         __in                    size_t length);
113
114 extern                  efx_rc_t
115 siena_mcdi_poll_reboot(
116         __in            efx_nic_t *enp);
117
118 extern                  void
119 siena_mcdi_fini(
120         __in            efx_nic_t *enp);
121
122 extern  __checkReturn   efx_rc_t
123 siena_mcdi_feature_supported(
124         __in            efx_nic_t *enp,
125         __in            efx_mcdi_feature_id_t id,
126         __out           boolean_t *supportedp);
127
128 extern                  void
129 siena_mcdi_get_timeout(
130         __in            efx_nic_t *enp,
131         __in            efx_mcdi_req_t *emrp,
132         __out           uint32_t *timeoutp);
133
134 #endif /* EFSYS_OPT_MCDI */
135
136 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
137
138 extern  __checkReturn           efx_rc_t
139 siena_nvram_partn_lock(
140         __in                    efx_nic_t *enp,
141         __in                    uint32_t partn);
142
143 extern  __checkReturn           efx_rc_t
144 siena_nvram_partn_unlock(
145         __in                    efx_nic_t *enp,
146         __in                    uint32_t partn);
147
148 extern  __checkReturn           efx_rc_t
149 siena_nvram_get_dynamic_cfg(
150         __in                    efx_nic_t *enp,
151         __in                    uint32_t partn,
152         __in                    boolean_t vpd,
153         __out                   siena_mc_dynamic_config_hdr_t **dcfgp,
154         __out                   size_t *sizep);
155
156 #endif  /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
157
158 #if EFSYS_OPT_NVRAM
159
160 #if EFSYS_OPT_DIAG
161
162 extern  __checkReturn           efx_rc_t
163 siena_nvram_test(
164         __in                    efx_nic_t *enp);
165
166 #endif  /* EFSYS_OPT_DIAG */
167
168 extern  __checkReturn           efx_rc_t
169 siena_nvram_get_subtype(
170         __in                    efx_nic_t *enp,
171         __in                    uint32_t partn,
172         __out                   uint32_t *subtypep);
173
174 extern  __checkReturn           efx_rc_t
175 siena_nvram_type_to_partn(
176         __in                    efx_nic_t *enp,
177         __in                    efx_nvram_type_t type,
178         __out                   uint32_t *partnp);
179
180 extern  __checkReturn           efx_rc_t
181 siena_nvram_partn_size(
182         __in                    efx_nic_t *enp,
183         __in                    uint32_t partn,
184         __out                   size_t *sizep);
185
186 extern  __checkReturn           efx_rc_t
187 siena_nvram_partn_rw_start(
188         __in                    efx_nic_t *enp,
189         __in                    uint32_t partn,
190         __out                   size_t *chunk_sizep);
191
192 extern  __checkReturn           efx_rc_t
193 siena_nvram_partn_read(
194         __in                    efx_nic_t *enp,
195         __in                    uint32_t partn,
196         __in                    unsigned int offset,
197         __out_bcount(size)      caddr_t data,
198         __in                    size_t size);
199
200 extern  __checkReturn           efx_rc_t
201 siena_nvram_partn_erase(
202         __in                    efx_nic_t *enp,
203         __in                    uint32_t partn,
204         __in                    unsigned int offset,
205         __in                    size_t size);
206
207 extern  __checkReturn           efx_rc_t
208 siena_nvram_partn_write(
209         __in                    efx_nic_t *enp,
210         __in                    uint32_t partn,
211         __in                    unsigned int offset,
212         __out_bcount(size)      caddr_t data,
213         __in                    size_t size);
214
215 extern  __checkReturn           efx_rc_t
216 siena_nvram_partn_rw_finish(
217         __in                    efx_nic_t *enp,
218         __in                    uint32_t partn);
219
220 extern  __checkReturn           efx_rc_t
221 siena_nvram_partn_get_version(
222         __in                    efx_nic_t *enp,
223         __in                    uint32_t partn,
224         __out                   uint32_t *subtypep,
225         __out_ecount(4)         uint16_t version[4]);
226
227 extern  __checkReturn           efx_rc_t
228 siena_nvram_partn_set_version(
229         __in                    efx_nic_t *enp,
230         __in                    uint32_t partn,
231         __in_ecount(4)          uint16_t version[4]);
232
233 #endif  /* EFSYS_OPT_NVRAM */
234
235 #if EFSYS_OPT_VPD
236
237 extern  __checkReturn           efx_rc_t
238 siena_vpd_init(
239         __in                    efx_nic_t *enp);
240
241 extern  __checkReturn           efx_rc_t
242 siena_vpd_size(
243         __in                    efx_nic_t *enp,
244         __out                   size_t *sizep);
245
246 extern  __checkReturn           efx_rc_t
247 siena_vpd_read(
248         __in                    efx_nic_t *enp,
249         __out_bcount(size)      caddr_t data,
250         __in                    size_t size);
251
252 extern  __checkReturn           efx_rc_t
253 siena_vpd_verify(
254         __in                    efx_nic_t *enp,
255         __in_bcount(size)       caddr_t data,
256         __in                    size_t size);
257
258 extern  __checkReturn           efx_rc_t
259 siena_vpd_reinit(
260         __in                    efx_nic_t *enp,
261         __in_bcount(size)       caddr_t data,
262         __in                    size_t size);
263
264 extern  __checkReturn           efx_rc_t
265 siena_vpd_get(
266         __in                    efx_nic_t *enp,
267         __in_bcount(size)       caddr_t data,
268         __in                    size_t size,
269         __inout                 efx_vpd_value_t *evvp);
270
271 extern  __checkReturn           efx_rc_t
272 siena_vpd_set(
273         __in                    efx_nic_t *enp,
274         __in_bcount(size)       caddr_t data,
275         __in                    size_t size,
276         __in                    efx_vpd_value_t *evvp);
277
278 extern  __checkReturn           efx_rc_t
279 siena_vpd_next(
280         __in                    efx_nic_t *enp,
281         __in_bcount(size)       caddr_t data,
282         __in                    size_t size,
283         __out                   efx_vpd_value_t *evvp,
284         __inout                 unsigned int *contp);
285
286 extern __checkReturn            efx_rc_t
287 siena_vpd_write(
288         __in                    efx_nic_t *enp,
289         __in_bcount(size)       caddr_t data,
290         __in                    size_t size);
291
292 extern                          void
293 siena_vpd_fini(
294         __in                    efx_nic_t *enp);
295
296 #endif  /* EFSYS_OPT_VPD */
297
298 typedef struct siena_link_state_s {
299         uint32_t                sls_adv_cap_mask;
300         uint32_t                sls_lp_cap_mask;
301         unsigned int            sls_fcntl;
302         efx_link_mode_t         sls_link_mode;
303 #if EFSYS_OPT_LOOPBACK
304         efx_loopback_type_t     sls_loopback;
305 #endif
306         boolean_t               sls_mac_up;
307 } siena_link_state_t;
308
309 extern                  void
310 siena_phy_link_ev(
311         __in            efx_nic_t *enp,
312         __in            efx_qword_t *eqp,
313         __out           efx_link_mode_t *link_modep);
314
315 extern  __checkReturn   efx_rc_t
316 siena_phy_get_link(
317         __in            efx_nic_t *enp,
318         __out           siena_link_state_t *slsp);
319
320 extern  __checkReturn   efx_rc_t
321 siena_phy_power(
322         __in            efx_nic_t *enp,
323         __in            boolean_t on);
324
325 extern  __checkReturn   efx_rc_t
326 siena_phy_reconfigure(
327         __in            efx_nic_t *enp);
328
329 extern  __checkReturn   efx_rc_t
330 siena_phy_verify(
331         __in            efx_nic_t *enp);
332
333 extern  __checkReturn   efx_rc_t
334 siena_phy_oui_get(
335         __in            efx_nic_t *enp,
336         __out           uint32_t *ouip);
337
338 #if EFSYS_OPT_PHY_STATS
339
340 extern                                          void
341 siena_phy_decode_stats(
342         __in                                    efx_nic_t *enp,
343         __in                                    uint32_t vmask,
344         __in_opt                                efsys_mem_t *esmp,
345         __out_opt                               uint64_t *smaskp,
346         __inout_ecount_opt(EFX_PHY_NSTATS)      uint32_t *stat);
347
348 extern  __checkReturn                   efx_rc_t
349 siena_phy_stats_update(
350         __in                            efx_nic_t *enp,
351         __in                            efsys_mem_t *esmp,
352         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
353
354 #endif  /* EFSYS_OPT_PHY_STATS */
355
356 #if EFSYS_OPT_BIST
357
358 extern  __checkReturn           efx_rc_t
359 siena_phy_bist_start(
360         __in                    efx_nic_t *enp,
361         __in                    efx_bist_type_t type);
362
363 extern  __checkReturn           efx_rc_t
364 siena_phy_bist_poll(
365         __in                    efx_nic_t *enp,
366         __in                    efx_bist_type_t type,
367         __out                   efx_bist_result_t *resultp,
368         __out_opt __drv_when(count > 0, __notnull)
369         uint32_t        *value_maskp,
370         __out_ecount_opt(count) __drv_when(count > 0, __notnull)
371         unsigned long   *valuesp,
372         __in                    size_t count);
373
374 extern                          void
375 siena_phy_bist_stop(
376         __in                    efx_nic_t *enp,
377         __in                    efx_bist_type_t type);
378
379 #endif  /* EFSYS_OPT_BIST */
380
381 extern  __checkReturn   efx_rc_t
382 siena_mac_poll(
383         __in            efx_nic_t *enp,
384         __out           efx_link_mode_t *link_modep);
385
386 extern  __checkReturn   efx_rc_t
387 siena_mac_up(
388         __in            efx_nic_t *enp,
389         __out           boolean_t *mac_upp);
390
391 extern  __checkReturn   efx_rc_t
392 siena_mac_reconfigure(
393         __in    efx_nic_t *enp);
394
395 extern  __checkReturn   efx_rc_t
396 siena_mac_pdu_get(
397         __in    efx_nic_t *enp,
398         __out   size_t *pdu);
399
400 #if EFSYS_OPT_LOOPBACK
401
402 extern  __checkReturn   efx_rc_t
403 siena_mac_loopback_set(
404         __in            efx_nic_t *enp,
405         __in            efx_link_mode_t link_mode,
406         __in            efx_loopback_type_t loopback_type);
407
408 #endif  /* EFSYS_OPT_LOOPBACK */
409
410 #if EFSYS_OPT_MAC_STATS
411
412 extern  __checkReturn                   efx_rc_t
413 siena_mac_stats_get_mask(
414         __in                            efx_nic_t *enp,
415         __inout_bcount(mask_size)       uint32_t *maskp,
416         __in                            size_t mask_size);
417
418 extern  __checkReturn                   efx_rc_t
419 siena_mac_stats_update(
420         __in                            efx_nic_t *enp,
421         __in                            efsys_mem_t *esmp,
422         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
423         __inout_opt                     uint32_t *generationp);
424
425 #endif  /* EFSYS_OPT_MAC_STATS */
426
427 #ifdef  __cplusplus
428 }
429 #endif
430
431 #endif  /* _SYS_SIENA_IMPL_H */