]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/sfxge/common/siena_impl.h
MFhead @ r293815
[FreeBSD/FreeBSD.git] / sys / dev / sfxge / common / siena_impl.h
1 /*-
2  * Copyright (c) 2009-2015 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  * $FreeBSD$
31  */
32
33 #ifndef _SYS_SIENA_IMPL_H
34 #define _SYS_SIENA_IMPL_H
35
36 #include "efx.h"
37 #include "efx_regs.h"
38 #include "efx_mcdi.h"
39 #include "siena_flash.h"
40
41 #ifdef  __cplusplus
42 extern "C" {
43 #endif
44
45 #if EFSYS_OPT_PHY_PROPS
46
47 /* START MKCONFIG GENERATED SienaPhyHeaderPropsBlock a8db1f8eb5106efd */
48 typedef enum siena_phy_prop_e {
49         SIENA_PHY_NPROPS
50 } siena_phy_prop_t;
51
52 /* END MKCONFIG GENERATED SienaPhyHeaderPropsBlock */
53
54 #endif  /* EFSYS_OPT_PHY_PROPS */
55
56 #define SIENA_NVRAM_CHUNK 0x80
57
58 extern  __checkReturn   efx_rc_t
59 siena_nic_probe(
60         __in            efx_nic_t *enp);
61
62 #if EFSYS_OPT_PCIE_TUNE
63
64 extern  __checkReturn   efx_rc_t
65 siena_nic_pcie_extended_sync(
66         __in            efx_nic_t *enp);
67
68 #endif
69
70 extern  __checkReturn   efx_rc_t
71 siena_nic_reset(
72         __in            efx_nic_t *enp);
73
74 extern  __checkReturn   efx_rc_t
75 siena_nic_init(
76         __in            efx_nic_t *enp);
77
78 #if EFSYS_OPT_DIAG
79
80 extern  __checkReturn   efx_rc_t
81 siena_nic_register_test(
82         __in            efx_nic_t *enp);
83
84 #endif  /* EFSYS_OPT_DIAG */
85
86 extern                  void
87 siena_nic_fini(
88         __in            efx_nic_t *enp);
89
90 extern                  void
91 siena_nic_unprobe(
92         __in            efx_nic_t *enp);
93
94 #define SIENA_SRAM_ROWS 0x12000
95
96 extern                  void
97 siena_sram_init(
98         __in            efx_nic_t *enp);
99
100 #if EFSYS_OPT_DIAG
101
102 extern  __checkReturn   efx_rc_t
103 siena_sram_test(
104         __in            efx_nic_t *enp,
105         __in            efx_sram_pattern_fn_t func);
106
107 #endif  /* EFSYS_OPT_DIAG */
108
109 #if EFSYS_OPT_MCDI
110
111 extern  __checkReturn   efx_rc_t
112 siena_mcdi_init(
113         __in            efx_nic_t *enp,
114         __in            const efx_mcdi_transport_t *mtp);
115
116 extern                  void
117 siena_mcdi_request_copyin(
118         __in            efx_nic_t *enp,
119         __in            efx_mcdi_req_t *emrp,
120         __in            unsigned int seq,
121         __in            boolean_t ev_cpl,
122         __in            boolean_t new_epoch);
123
124 extern  __checkReturn   boolean_t
125 siena_mcdi_poll_response(
126         __in            efx_nic_t *enp);
127
128 extern                  void
129 siena_mcdi_read_response(
130         __in            efx_nic_t *enp,
131         __out           void *bufferp,
132         __in            size_t offset,
133         __in            size_t length);
134
135 extern                  void
136 siena_mcdi_request_copyout(
137         __in            efx_nic_t *enp,
138         __in            efx_mcdi_req_t *emrp);
139
140 extern                  efx_rc_t
141 siena_mcdi_poll_reboot(
142         __in            efx_nic_t *enp);
143
144 extern                  void
145 siena_mcdi_fini(
146         __in            efx_nic_t *enp);
147
148 extern  __checkReturn   efx_rc_t
149 siena_mcdi_feature_supported(
150         __in            efx_nic_t *enp,
151         __in            efx_mcdi_feature_id_t id,
152         __out           boolean_t *supportedp);
153
154 #endif /* EFSYS_OPT_MCDI */
155
156 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
157
158 extern  __checkReturn           efx_rc_t
159 siena_nvram_partn_size(
160         __in                    efx_nic_t *enp,
161         __in                    uint32_t partn,
162         __out                   size_t *sizep);
163
164 extern  __checkReturn           efx_rc_t
165 siena_nvram_partn_lock(
166         __in                    efx_nic_t *enp,
167         __in                    uint32_t partn);
168
169 extern  __checkReturn           efx_rc_t
170 siena_nvram_partn_read(
171         __in                    efx_nic_t *enp,
172         __in                    uint32_t partn,
173         __in                    unsigned int offset,
174         __out_bcount(size)      caddr_t data,
175         __in                    size_t size);
176
177 extern  __checkReturn           efx_rc_t
178 siena_nvram_partn_erase(
179         __in                    efx_nic_t *enp,
180         __in                    uint32_t partn,
181         __in                    unsigned int offset,
182         __in                    size_t size);
183
184 extern  __checkReturn           efx_rc_t
185 siena_nvram_partn_write(
186         __in                    efx_nic_t *enp,
187         __in                    uint32_t partn,
188         __in                    unsigned int offset,
189         __out_bcount(size)      caddr_t data,
190         __in                    size_t size);
191
192 extern                          void
193 siena_nvram_partn_unlock(
194         __in                    efx_nic_t *enp,
195         __in                    uint32_t partn);
196
197 extern  __checkReturn           efx_rc_t
198 siena_nvram_get_dynamic_cfg(
199         __in                    efx_nic_t *enp,
200         __in                    uint32_t partn,
201         __in                    boolean_t vpd,
202         __out                   siena_mc_dynamic_config_hdr_t **dcfgp,
203         __out                   size_t *sizep);
204
205 #endif  /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
206
207 #if EFSYS_OPT_NVRAM
208
209 #if EFSYS_OPT_DIAG
210
211 extern  __checkReturn           efx_rc_t
212 siena_nvram_test(
213         __in                    efx_nic_t *enp);
214
215 #endif  /* EFSYS_OPT_DIAG */
216
217 extern  __checkReturn           efx_rc_t
218 siena_nvram_size(
219         __in                    efx_nic_t *enp,
220         __in                    efx_nvram_type_t type,
221         __out                   size_t *sizep);
222
223 extern  __checkReturn           efx_rc_t
224 siena_nvram_get_subtype(
225         __in                    efx_nic_t *enp,
226         __in                    uint32_t partn,
227         __out                   uint32_t *subtypep);
228
229 extern  __checkReturn           efx_rc_t
230 siena_nvram_get_version(
231         __in                    efx_nic_t *enp,
232         __in                    efx_nvram_type_t type,
233         __out                   uint32_t *subtypep,
234         __out_ecount(4)         uint16_t version[4]);
235
236 extern  __checkReturn           efx_rc_t
237 siena_nvram_rw_start(
238         __in                    efx_nic_t *enp,
239         __in                    efx_nvram_type_t type,
240         __out                   size_t *pref_chunkp);
241
242 extern  __checkReturn           efx_rc_t
243 siena_nvram_read_chunk(
244         __in                    efx_nic_t *enp,
245         __in                    efx_nvram_type_t type,
246         __in                    unsigned int offset,
247         __out_bcount(size)      caddr_t data,
248         __in                    size_t size);
249
250 extern   __checkReturn          efx_rc_t
251 siena_nvram_erase(
252         __in                    efx_nic_t *enp,
253         __in                    efx_nvram_type_t type);
254
255 extern  __checkReturn           efx_rc_t
256 siena_nvram_write_chunk(
257         __in                    efx_nic_t *enp,
258         __in                    efx_nvram_type_t type,
259         __in                    unsigned int offset,
260         __in_bcount(size)       caddr_t data,
261         __in                    size_t size);
262
263 extern                          void
264 siena_nvram_rw_finish(
265         __in                    efx_nic_t *enp,
266         __in                    efx_nvram_type_t type);
267
268 extern  __checkReturn           efx_rc_t
269 siena_nvram_set_version(
270         __in                    efx_nic_t *enp,
271         __in                    efx_nvram_type_t type,
272         __in_ecount(4)          uint16_t version[4]);
273
274 extern  __checkReturn           efx_rc_t
275 siena_nvram_type_to_partn(
276         __in                    efx_nic_t *enp,
277         __in                    efx_nvram_type_t type,
278         __out                   uint32_t *partnp);
279
280 #endif  /* EFSYS_OPT_NVRAM */
281
282 #if EFSYS_OPT_VPD
283
284 extern  __checkReturn           efx_rc_t
285 siena_vpd_init(
286         __in                    efx_nic_t *enp);
287
288 extern  __checkReturn           efx_rc_t
289 siena_vpd_size(
290         __in                    efx_nic_t *enp,
291         __out                   size_t *sizep);
292
293 extern  __checkReturn           efx_rc_t
294 siena_vpd_read(
295         __in                    efx_nic_t *enp,
296         __out_bcount(size)      caddr_t data,
297         __in                    size_t size);
298
299 extern  __checkReturn           efx_rc_t
300 siena_vpd_verify(
301         __in                    efx_nic_t *enp,
302         __in_bcount(size)       caddr_t data,
303         __in                    size_t size);
304
305 extern  __checkReturn           efx_rc_t
306 siena_vpd_reinit(
307         __in                    efx_nic_t *enp,
308         __in_bcount(size)       caddr_t data,
309         __in                    size_t size);
310
311 extern  __checkReturn           efx_rc_t
312 siena_vpd_get(
313         __in                    efx_nic_t *enp,
314         __in_bcount(size)       caddr_t data,
315         __in                    size_t size,
316         __inout                 efx_vpd_value_t *evvp);
317
318 extern  __checkReturn           efx_rc_t
319 siena_vpd_set(
320         __in                    efx_nic_t *enp,
321         __in_bcount(size)       caddr_t data,
322         __in                    size_t size,
323         __in                    efx_vpd_value_t *evvp);
324
325 extern  __checkReturn           efx_rc_t
326 siena_vpd_next(
327         __in                    efx_nic_t *enp,
328         __in_bcount(size)       caddr_t data,
329         __in                    size_t size,
330         __out                   efx_vpd_value_t *evvp,
331         __inout                 unsigned int *contp);
332
333 extern __checkReturn            efx_rc_t
334 siena_vpd_write(
335         __in                    efx_nic_t *enp,
336         __in_bcount(size)       caddr_t data,
337         __in                    size_t size);
338
339 extern                          void
340 siena_vpd_fini(
341         __in                    efx_nic_t *enp);
342
343 #endif  /* EFSYS_OPT_VPD */
344
345 typedef struct siena_link_state_s {
346         uint32_t                sls_adv_cap_mask;
347         uint32_t                sls_lp_cap_mask;
348         unsigned int            sls_fcntl;
349         efx_link_mode_t         sls_link_mode;
350 #if EFSYS_OPT_LOOPBACK
351         efx_loopback_type_t     sls_loopback;
352 #endif
353         boolean_t               sls_mac_up;
354 } siena_link_state_t;
355
356 extern                  void
357 siena_phy_link_ev(
358         __in            efx_nic_t *enp,
359         __in            efx_qword_t *eqp,
360         __out           efx_link_mode_t *link_modep);
361
362 extern  __checkReturn   efx_rc_t
363 siena_phy_get_link(
364         __in            efx_nic_t *enp,
365         __out           siena_link_state_t *slsp);
366
367 extern  __checkReturn   efx_rc_t
368 siena_phy_power(
369         __in            efx_nic_t *enp,
370         __in            boolean_t on);
371
372 extern  __checkReturn   efx_rc_t
373 siena_phy_reconfigure(
374         __in            efx_nic_t *enp);
375
376 extern  __checkReturn   efx_rc_t
377 siena_phy_verify(
378         __in            efx_nic_t *enp);
379
380 extern  __checkReturn   efx_rc_t
381 siena_phy_oui_get(
382         __in            efx_nic_t *enp,
383         __out           uint32_t *ouip);
384
385 #if EFSYS_OPT_PHY_STATS
386
387 extern                                          void
388 siena_phy_decode_stats(
389         __in                                    efx_nic_t *enp,
390         __in                                    uint32_t vmask,
391         __in_opt                                efsys_mem_t *esmp,
392         __out_opt                               uint64_t *smaskp,
393         __inout_ecount_opt(EFX_PHY_NSTATS)      uint32_t *stat);
394
395 extern  __checkReturn                   efx_rc_t
396 siena_phy_stats_update(
397         __in                            efx_nic_t *enp,
398         __in                            efsys_mem_t *esmp,
399         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
400
401 #endif  /* EFSYS_OPT_PHY_STATS */
402
403 #if EFSYS_OPT_PHY_PROPS
404
405 #if EFSYS_OPT_NAMES
406
407 extern          const char *
408 siena_phy_prop_name(
409         __in    efx_nic_t *enp,
410         __in    unsigned int id);
411
412 #endif  /* EFSYS_OPT_NAMES */
413
414 extern  __checkReturn   efx_rc_t
415 siena_phy_prop_get(
416         __in            efx_nic_t *enp,
417         __in            unsigned int id,
418         __in            uint32_t flags,
419         __out           uint32_t *valp);
420
421 extern  __checkReturn   efx_rc_t
422 siena_phy_prop_set(
423         __in            efx_nic_t *enp,
424         __in            unsigned int id,
425         __in            uint32_t val);
426
427 #endif  /* EFSYS_OPT_PHY_PROPS */
428
429 #if EFSYS_OPT_BIST
430
431 extern  __checkReturn           efx_rc_t
432 siena_phy_bist_start(
433         __in                    efx_nic_t *enp,
434         __in                    efx_bist_type_t type);
435
436 extern  __checkReturn           efx_rc_t
437 siena_phy_bist_poll(
438         __in                    efx_nic_t *enp,
439         __in                    efx_bist_type_t type,
440         __out                   efx_bist_result_t *resultp,
441         __out_opt __drv_when(count > 0, __notnull)
442         uint32_t        *value_maskp,
443         __out_ecount_opt(count) __drv_when(count > 0, __notnull)
444         unsigned long   *valuesp,
445         __in                    size_t count);
446
447 extern                          void
448 siena_phy_bist_stop(
449         __in                    efx_nic_t *enp,
450         __in                    efx_bist_type_t type);
451
452 #endif  /* EFSYS_OPT_BIST */
453
454 extern  __checkReturn   efx_rc_t
455 siena_mac_poll(
456         __in            efx_nic_t *enp,
457         __out           efx_link_mode_t *link_modep);
458
459 extern  __checkReturn   efx_rc_t
460 siena_mac_up(
461         __in            efx_nic_t *enp,
462         __out           boolean_t *mac_upp);
463
464 extern  __checkReturn   efx_rc_t
465 siena_mac_reconfigure(
466         __in    efx_nic_t *enp);
467
468 #if EFSYS_OPT_LOOPBACK
469
470 extern  __checkReturn   efx_rc_t
471 siena_mac_loopback_set(
472         __in            efx_nic_t *enp,
473         __in            efx_link_mode_t link_mode,
474         __in            efx_loopback_type_t loopback_type);
475
476 #endif  /* EFSYS_OPT_LOOPBACK */
477
478 #if EFSYS_OPT_MAC_STATS
479
480 extern  __checkReturn                   efx_rc_t
481 siena_mac_stats_update(
482         __in                            efx_nic_t *enp,
483         __in                            efsys_mem_t *esmp,
484         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
485         __inout_opt                     uint32_t *generationp);
486
487 #endif  /* EFSYS_OPT_MAC_STATS */
488
489 #ifdef  __cplusplus
490 }
491 #endif
492
493 #endif  /* _SYS_SIENA_IMPL_H */