]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/sfxge/common/siena_impl.h
sfxge: convert nvram rw_finish method to use partition id
[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_send_request(
118         __in            efx_nic_t *enp,
119         __in            void *hdrp,
120         __in            size_t hdr_len,
121         __in            void *sdup,
122         __in            size_t sdu_len);
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_bcount(length)    void *bufferp,
132         __in                    size_t offset,
133         __in                    size_t length);
134
135 extern                  efx_rc_t
136 siena_mcdi_poll_reboot(
137         __in            efx_nic_t *enp);
138
139 extern                  void
140 siena_mcdi_fini(
141         __in            efx_nic_t *enp);
142
143 extern  __checkReturn   efx_rc_t
144 siena_mcdi_feature_supported(
145         __in            efx_nic_t *enp,
146         __in            efx_mcdi_feature_id_t id,
147         __out           boolean_t *supportedp);
148
149 #endif /* EFSYS_OPT_MCDI */
150
151 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
152
153 extern  __checkReturn           efx_rc_t
154 siena_nvram_partn_lock(
155         __in                    efx_nic_t *enp,
156         __in                    uint32_t partn);
157
158 extern                          void
159 siena_nvram_partn_unlock(
160         __in                    efx_nic_t *enp,
161         __in                    uint32_t partn);
162
163 extern  __checkReturn           efx_rc_t
164 siena_nvram_get_dynamic_cfg(
165         __in                    efx_nic_t *enp,
166         __in                    uint32_t partn,
167         __in                    boolean_t vpd,
168         __out                   siena_mc_dynamic_config_hdr_t **dcfgp,
169         __out                   size_t *sizep);
170
171 #endif  /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
172
173 #if EFSYS_OPT_NVRAM
174
175 #if EFSYS_OPT_DIAG
176
177 extern  __checkReturn           efx_rc_t
178 siena_nvram_test(
179         __in                    efx_nic_t *enp);
180
181 #endif  /* EFSYS_OPT_DIAG */
182
183 extern  __checkReturn           efx_rc_t
184 siena_nvram_get_subtype(
185         __in                    efx_nic_t *enp,
186         __in                    uint32_t partn,
187         __out                   uint32_t *subtypep);
188
189 extern  __checkReturn           efx_rc_t
190 siena_nvram_get_version(
191         __in                    efx_nic_t *enp,
192         __in                    efx_nvram_type_t type,
193         __out                   uint32_t *subtypep,
194         __out_ecount(4)         uint16_t version[4]);
195
196 extern  __checkReturn           efx_rc_t
197 siena_nvram_set_version(
198         __in                    efx_nic_t *enp,
199         __in                    efx_nvram_type_t type,
200         __in_ecount(4)          uint16_t version[4]);
201
202 extern  __checkReturn           efx_rc_t
203 siena_nvram_type_to_partn(
204         __in                    efx_nic_t *enp,
205         __in                    efx_nvram_type_t type,
206         __out                   uint32_t *partnp);
207
208 extern  __checkReturn           efx_rc_t
209 siena_nvram_partn_size(
210         __in                    efx_nic_t *enp,
211         __in                    uint32_t partn,
212         __out                   size_t *sizep);
213
214 extern  __checkReturn           efx_rc_t
215 siena_nvram_partn_rw_start(
216         __in                    efx_nic_t *enp,
217         __in                    uint32_t partn,
218         __out                   size_t *chunk_sizep);
219
220 extern  __checkReturn           efx_rc_t
221 siena_nvram_partn_read(
222         __in                    efx_nic_t *enp,
223         __in                    uint32_t partn,
224         __in                    unsigned int offset,
225         __out_bcount(size)      caddr_t data,
226         __in                    size_t size);
227
228 extern  __checkReturn           efx_rc_t
229 siena_nvram_partn_erase(
230         __in                    efx_nic_t *enp,
231         __in                    uint32_t partn,
232         __in                    unsigned int offset,
233         __in                    size_t size);
234
235 extern  __checkReturn           efx_rc_t
236 siena_nvram_partn_write(
237         __in                    efx_nic_t *enp,
238         __in                    uint32_t partn,
239         __in                    unsigned int offset,
240         __out_bcount(size)      caddr_t data,
241         __in                    size_t size);
242
243 extern                          void
244 siena_nvram_partn_rw_finish(
245         __in                    efx_nic_t *enp,
246         __in                    uint32_t partn);
247
248
249 #endif  /* EFSYS_OPT_NVRAM */
250
251 #if EFSYS_OPT_VPD
252
253 extern  __checkReturn           efx_rc_t
254 siena_vpd_init(
255         __in                    efx_nic_t *enp);
256
257 extern  __checkReturn           efx_rc_t
258 siena_vpd_size(
259         __in                    efx_nic_t *enp,
260         __out                   size_t *sizep);
261
262 extern  __checkReturn           efx_rc_t
263 siena_vpd_read(
264         __in                    efx_nic_t *enp,
265         __out_bcount(size)      caddr_t data,
266         __in                    size_t size);
267
268 extern  __checkReturn           efx_rc_t
269 siena_vpd_verify(
270         __in                    efx_nic_t *enp,
271         __in_bcount(size)       caddr_t data,
272         __in                    size_t size);
273
274 extern  __checkReturn           efx_rc_t
275 siena_vpd_reinit(
276         __in                    efx_nic_t *enp,
277         __in_bcount(size)       caddr_t data,
278         __in                    size_t size);
279
280 extern  __checkReturn           efx_rc_t
281 siena_vpd_get(
282         __in                    efx_nic_t *enp,
283         __in_bcount(size)       caddr_t data,
284         __in                    size_t size,
285         __inout                 efx_vpd_value_t *evvp);
286
287 extern  __checkReturn           efx_rc_t
288 siena_vpd_set(
289         __in                    efx_nic_t *enp,
290         __in_bcount(size)       caddr_t data,
291         __in                    size_t size,
292         __in                    efx_vpd_value_t *evvp);
293
294 extern  __checkReturn           efx_rc_t
295 siena_vpd_next(
296         __in                    efx_nic_t *enp,
297         __in_bcount(size)       caddr_t data,
298         __in                    size_t size,
299         __out                   efx_vpd_value_t *evvp,
300         __inout                 unsigned int *contp);
301
302 extern __checkReturn            efx_rc_t
303 siena_vpd_write(
304         __in                    efx_nic_t *enp,
305         __in_bcount(size)       caddr_t data,
306         __in                    size_t size);
307
308 extern                          void
309 siena_vpd_fini(
310         __in                    efx_nic_t *enp);
311
312 #endif  /* EFSYS_OPT_VPD */
313
314 typedef struct siena_link_state_s {
315         uint32_t                sls_adv_cap_mask;
316         uint32_t                sls_lp_cap_mask;
317         unsigned int            sls_fcntl;
318         efx_link_mode_t         sls_link_mode;
319 #if EFSYS_OPT_LOOPBACK
320         efx_loopback_type_t     sls_loopback;
321 #endif
322         boolean_t               sls_mac_up;
323 } siena_link_state_t;
324
325 extern                  void
326 siena_phy_link_ev(
327         __in            efx_nic_t *enp,
328         __in            efx_qword_t *eqp,
329         __out           efx_link_mode_t *link_modep);
330
331 extern  __checkReturn   efx_rc_t
332 siena_phy_get_link(
333         __in            efx_nic_t *enp,
334         __out           siena_link_state_t *slsp);
335
336 extern  __checkReturn   efx_rc_t
337 siena_phy_power(
338         __in            efx_nic_t *enp,
339         __in            boolean_t on);
340
341 extern  __checkReturn   efx_rc_t
342 siena_phy_reconfigure(
343         __in            efx_nic_t *enp);
344
345 extern  __checkReturn   efx_rc_t
346 siena_phy_verify(
347         __in            efx_nic_t *enp);
348
349 extern  __checkReturn   efx_rc_t
350 siena_phy_oui_get(
351         __in            efx_nic_t *enp,
352         __out           uint32_t *ouip);
353
354 #if EFSYS_OPT_PHY_STATS
355
356 extern                                          void
357 siena_phy_decode_stats(
358         __in                                    efx_nic_t *enp,
359         __in                                    uint32_t vmask,
360         __in_opt                                efsys_mem_t *esmp,
361         __out_opt                               uint64_t *smaskp,
362         __inout_ecount_opt(EFX_PHY_NSTATS)      uint32_t *stat);
363
364 extern  __checkReturn                   efx_rc_t
365 siena_phy_stats_update(
366         __in                            efx_nic_t *enp,
367         __in                            efsys_mem_t *esmp,
368         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
369
370 #endif  /* EFSYS_OPT_PHY_STATS */
371
372 #if EFSYS_OPT_PHY_PROPS
373
374 #if EFSYS_OPT_NAMES
375
376 extern          const char *
377 siena_phy_prop_name(
378         __in    efx_nic_t *enp,
379         __in    unsigned int id);
380
381 #endif  /* EFSYS_OPT_NAMES */
382
383 extern  __checkReturn   efx_rc_t
384 siena_phy_prop_get(
385         __in            efx_nic_t *enp,
386         __in            unsigned int id,
387         __in            uint32_t flags,
388         __out           uint32_t *valp);
389
390 extern  __checkReturn   efx_rc_t
391 siena_phy_prop_set(
392         __in            efx_nic_t *enp,
393         __in            unsigned int id,
394         __in            uint32_t val);
395
396 #endif  /* EFSYS_OPT_PHY_PROPS */
397
398 #if EFSYS_OPT_BIST
399
400 extern  __checkReturn           efx_rc_t
401 siena_phy_bist_start(
402         __in                    efx_nic_t *enp,
403         __in                    efx_bist_type_t type);
404
405 extern  __checkReturn           efx_rc_t
406 siena_phy_bist_poll(
407         __in                    efx_nic_t *enp,
408         __in                    efx_bist_type_t type,
409         __out                   efx_bist_result_t *resultp,
410         __out_opt __drv_when(count > 0, __notnull)
411         uint32_t        *value_maskp,
412         __out_ecount_opt(count) __drv_when(count > 0, __notnull)
413         unsigned long   *valuesp,
414         __in                    size_t count);
415
416 extern                          void
417 siena_phy_bist_stop(
418         __in                    efx_nic_t *enp,
419         __in                    efx_bist_type_t type);
420
421 #endif  /* EFSYS_OPT_BIST */
422
423 extern  __checkReturn   efx_rc_t
424 siena_mac_poll(
425         __in            efx_nic_t *enp,
426         __out           efx_link_mode_t *link_modep);
427
428 extern  __checkReturn   efx_rc_t
429 siena_mac_up(
430         __in            efx_nic_t *enp,
431         __out           boolean_t *mac_upp);
432
433 extern  __checkReturn   efx_rc_t
434 siena_mac_reconfigure(
435         __in    efx_nic_t *enp);
436
437 #if EFSYS_OPT_LOOPBACK
438
439 extern  __checkReturn   efx_rc_t
440 siena_mac_loopback_set(
441         __in            efx_nic_t *enp,
442         __in            efx_link_mode_t link_mode,
443         __in            efx_loopback_type_t loopback_type);
444
445 #endif  /* EFSYS_OPT_LOOPBACK */
446
447 #if EFSYS_OPT_MAC_STATS
448
449 extern  __checkReturn                   efx_rc_t
450 siena_mac_stats_update(
451         __in                            efx_nic_t *enp,
452         __in                            efsys_mem_t *esmp,
453         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
454         __inout_opt                     uint32_t *generationp);
455
456 #endif  /* EFSYS_OPT_MAC_STATS */
457
458 #ifdef  __cplusplus
459 }
460 #endif
461
462 #endif  /* _SYS_SIENA_IMPL_H */