2e3d390d4542d79fea96cefd6d59e8173dbe0bfa
[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 #ifndef EFX_TXQ_DC_SIZE
44 #define EFX_TXQ_DC_SIZE 1 /* 16 descriptors */
45 #endif
46 #ifndef EFX_RXQ_DC_SIZE
47 #define EFX_RXQ_DC_SIZE 3 /* 64 descriptors */
48 #endif
49 #define EFX_TXQ_DC_NDESCS(_dcsize)      (8 << (_dcsize))
50
51 #define SIENA_NVRAM_CHUNK 0x80
52
53
54 extern  __checkReturn   efx_rc_t
55 siena_nic_probe(
56         __in            efx_nic_t *enp);
57
58 extern  __checkReturn   efx_rc_t
59 siena_nic_reset(
60         __in            efx_nic_t *enp);
61
62 extern  __checkReturn   efx_rc_t
63 siena_nic_init(
64         __in            efx_nic_t *enp);
65
66 #if EFSYS_OPT_DIAG
67
68 extern  efx_sram_pattern_fn_t   __efx_sram_pattern_fns[];
69
70 typedef struct siena_register_set_s {
71         unsigned int            address;
72         unsigned int            step;
73         unsigned int            rows;
74         efx_oword_t             mask;
75 } siena_register_set_t;
76
77 extern  __checkReturn   efx_rc_t
78 siena_nic_register_test(
79         __in            efx_nic_t *enp);
80
81 #endif  /* EFSYS_OPT_DIAG */
82
83 extern                  void
84 siena_nic_fini(
85         __in            efx_nic_t *enp);
86
87 extern                  void
88 siena_nic_unprobe(
89         __in            efx_nic_t *enp);
90
91 #define SIENA_SRAM_ROWS 0x12000
92
93 extern                  void
94 siena_sram_init(
95         __in            efx_nic_t *enp);
96
97 #if EFSYS_OPT_DIAG
98
99 extern  __checkReturn   efx_rc_t
100 siena_sram_test(
101         __in            efx_nic_t *enp,
102         __in            efx_sram_pattern_fn_t func);
103
104 #endif  /* EFSYS_OPT_DIAG */
105
106 #if EFSYS_OPT_MCDI
107
108 extern  __checkReturn   efx_rc_t
109 siena_mcdi_init(
110         __in            efx_nic_t *enp,
111         __in            const efx_mcdi_transport_t *mtp);
112
113 extern                  void
114 siena_mcdi_send_request(
115         __in                    efx_nic_t *enp,
116         __in_bcount(hdr_len)    void *hdrp,
117         __in                    size_t hdr_len,
118         __in_bcount(sdu_len)    void *sdup,
119         __in                    size_t sdu_len);
120
121 extern  __checkReturn   boolean_t
122 siena_mcdi_poll_response(
123         __in            efx_nic_t *enp);
124
125 extern                  void
126 siena_mcdi_read_response(
127         __in                    efx_nic_t *enp,
128         __out_bcount(length)    void *bufferp,
129         __in                    size_t offset,
130         __in                    size_t length);
131
132 extern                  efx_rc_t
133 siena_mcdi_poll_reboot(
134         __in            efx_nic_t *enp);
135
136 extern                  void
137 siena_mcdi_fini(
138         __in            efx_nic_t *enp);
139
140 extern  __checkReturn   efx_rc_t
141 siena_mcdi_feature_supported(
142         __in            efx_nic_t *enp,
143         __in            efx_mcdi_feature_id_t id,
144         __out           boolean_t *supportedp);
145
146 extern                  void
147 siena_mcdi_get_timeout(
148         __in            efx_nic_t *enp,
149         __in            efx_mcdi_req_t *emrp,
150         __out           uint32_t *timeoutp);
151
152 #endif /* EFSYS_OPT_MCDI */
153
154 #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD
155
156 extern  __checkReturn           efx_rc_t
157 siena_nvram_partn_lock(
158         __in                    efx_nic_t *enp,
159         __in                    uint32_t partn);
160
161 extern  __checkReturn           efx_rc_t
162 siena_nvram_partn_unlock(
163         __in                    efx_nic_t *enp,
164         __in                    uint32_t partn,
165         __out_opt               uint32_t *verify_resultp);
166
167 extern  __checkReturn           efx_rc_t
168 siena_nvram_get_dynamic_cfg(
169         __in                    efx_nic_t *enp,
170         __in                    uint32_t partn,
171         __in                    boolean_t vpd,
172         __out                   siena_mc_dynamic_config_hdr_t **dcfgp,
173         __out                   size_t *sizep);
174
175 #endif  /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
176
177 #if EFSYS_OPT_NVRAM
178
179 #if EFSYS_OPT_DIAG
180
181 extern  __checkReturn           efx_rc_t
182 siena_nvram_test(
183         __in                    efx_nic_t *enp);
184
185 #endif  /* EFSYS_OPT_DIAG */
186
187 extern  __checkReturn           efx_rc_t
188 siena_nvram_get_subtype(
189         __in                    efx_nic_t *enp,
190         __in                    uint32_t partn,
191         __out                   uint32_t *subtypep);
192
193 extern  __checkReturn           efx_rc_t
194 siena_nvram_type_to_partn(
195         __in                    efx_nic_t *enp,
196         __in                    efx_nvram_type_t type,
197         __out                   uint32_t *partnp);
198
199 extern  __checkReturn           efx_rc_t
200 siena_nvram_partn_size(
201         __in                    efx_nic_t *enp,
202         __in                    uint32_t partn,
203         __out                   size_t *sizep);
204
205 extern  __checkReturn           efx_rc_t
206 siena_nvram_partn_rw_start(
207         __in                    efx_nic_t *enp,
208         __in                    uint32_t partn,
209         __out                   size_t *chunk_sizep);
210
211 extern  __checkReturn           efx_rc_t
212 siena_nvram_partn_read(
213         __in                    efx_nic_t *enp,
214         __in                    uint32_t partn,
215         __in                    unsigned int offset,
216         __out_bcount(size)      caddr_t data,
217         __in                    size_t size);
218
219 extern  __checkReturn           efx_rc_t
220 siena_nvram_partn_erase(
221         __in                    efx_nic_t *enp,
222         __in                    uint32_t partn,
223         __in                    unsigned int offset,
224         __in                    size_t size);
225
226 extern  __checkReturn           efx_rc_t
227 siena_nvram_partn_write(
228         __in                    efx_nic_t *enp,
229         __in                    uint32_t partn,
230         __in                    unsigned int offset,
231         __out_bcount(size)      caddr_t data,
232         __in                    size_t size);
233
234 extern  __checkReturn           efx_rc_t
235 siena_nvram_partn_rw_finish(
236         __in                    efx_nic_t *enp,
237         __in                    uint32_t partn,
238         __out_opt               uint32_t *verify_resultp);
239
240 extern  __checkReturn           efx_rc_t
241 siena_nvram_partn_get_version(
242         __in                    efx_nic_t *enp,
243         __in                    uint32_t partn,
244         __out                   uint32_t *subtypep,
245         __out_ecount(4)         uint16_t version[4]);
246
247 extern  __checkReturn           efx_rc_t
248 siena_nvram_partn_set_version(
249         __in                    efx_nic_t *enp,
250         __in                    uint32_t partn,
251         __in_ecount(4)          uint16_t version[4]);
252
253 #endif  /* EFSYS_OPT_NVRAM */
254
255 #if EFSYS_OPT_VPD
256
257 extern  __checkReturn           efx_rc_t
258 siena_vpd_init(
259         __in                    efx_nic_t *enp);
260
261 extern  __checkReturn           efx_rc_t
262 siena_vpd_size(
263         __in                    efx_nic_t *enp,
264         __out                   size_t *sizep);
265
266 extern  __checkReturn           efx_rc_t
267 siena_vpd_read(
268         __in                    efx_nic_t *enp,
269         __out_bcount(size)      caddr_t data,
270         __in                    size_t size);
271
272 extern  __checkReturn           efx_rc_t
273 siena_vpd_verify(
274         __in                    efx_nic_t *enp,
275         __in_bcount(size)       caddr_t data,
276         __in                    size_t size);
277
278 extern  __checkReturn           efx_rc_t
279 siena_vpd_reinit(
280         __in                    efx_nic_t *enp,
281         __in_bcount(size)       caddr_t data,
282         __in                    size_t size);
283
284 extern  __checkReturn           efx_rc_t
285 siena_vpd_get(
286         __in                    efx_nic_t *enp,
287         __in_bcount(size)       caddr_t data,
288         __in                    size_t size,
289         __inout                 efx_vpd_value_t *evvp);
290
291 extern  __checkReturn           efx_rc_t
292 siena_vpd_set(
293         __in                    efx_nic_t *enp,
294         __in_bcount(size)       caddr_t data,
295         __in                    size_t size,
296         __in                    efx_vpd_value_t *evvp);
297
298 extern  __checkReturn           efx_rc_t
299 siena_vpd_next(
300         __in                    efx_nic_t *enp,
301         __in_bcount(size)       caddr_t data,
302         __in                    size_t size,
303         __out                   efx_vpd_value_t *evvp,
304         __inout                 unsigned int *contp);
305
306 extern __checkReturn            efx_rc_t
307 siena_vpd_write(
308         __in                    efx_nic_t *enp,
309         __in_bcount(size)       caddr_t data,
310         __in                    size_t size);
311
312 extern                          void
313 siena_vpd_fini(
314         __in                    efx_nic_t *enp);
315
316 #endif  /* EFSYS_OPT_VPD */
317
318 typedef struct siena_link_state_s {
319         uint32_t                sls_adv_cap_mask;
320         uint32_t                sls_lp_cap_mask;
321         unsigned int            sls_fcntl;
322         efx_link_mode_t         sls_link_mode;
323 #if EFSYS_OPT_LOOPBACK
324         efx_loopback_type_t     sls_loopback;
325 #endif
326         boolean_t               sls_mac_up;
327 } siena_link_state_t;
328
329 extern                  void
330 siena_phy_link_ev(
331         __in            efx_nic_t *enp,
332         __in            efx_qword_t *eqp,
333         __out           efx_link_mode_t *link_modep);
334
335 extern  __checkReturn   efx_rc_t
336 siena_phy_get_link(
337         __in            efx_nic_t *enp,
338         __out           siena_link_state_t *slsp);
339
340 extern  __checkReturn   efx_rc_t
341 siena_phy_power(
342         __in            efx_nic_t *enp,
343         __in            boolean_t on);
344
345 extern  __checkReturn   efx_rc_t
346 siena_phy_reconfigure(
347         __in            efx_nic_t *enp);
348
349 extern  __checkReturn   efx_rc_t
350 siena_phy_verify(
351         __in            efx_nic_t *enp);
352
353 extern  __checkReturn   efx_rc_t
354 siena_phy_oui_get(
355         __in            efx_nic_t *enp,
356         __out           uint32_t *ouip);
357
358 #if EFSYS_OPT_PHY_STATS
359
360 extern                                          void
361 siena_phy_decode_stats(
362         __in                                    efx_nic_t *enp,
363         __in                                    uint32_t vmask,
364         __in_opt                                efsys_mem_t *esmp,
365         __out_opt                               uint64_t *smaskp,
366         __inout_ecount_opt(EFX_PHY_NSTATS)      uint32_t *stat);
367
368 extern  __checkReturn                   efx_rc_t
369 siena_phy_stats_update(
370         __in                            efx_nic_t *enp,
371         __in                            efsys_mem_t *esmp,
372         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
373
374 #endif  /* EFSYS_OPT_PHY_STATS */
375
376 #if EFSYS_OPT_BIST
377
378 extern  __checkReturn           efx_rc_t
379 siena_phy_bist_start(
380         __in                    efx_nic_t *enp,
381         __in                    efx_bist_type_t type);
382
383 extern  __checkReturn           efx_rc_t
384 siena_phy_bist_poll(
385         __in                    efx_nic_t *enp,
386         __in                    efx_bist_type_t type,
387         __out                   efx_bist_result_t *resultp,
388         __out_opt __drv_when(count > 0, __notnull)
389         uint32_t        *value_maskp,
390         __out_ecount_opt(count) __drv_when(count > 0, __notnull)
391         unsigned long   *valuesp,
392         __in                    size_t count);
393
394 extern                          void
395 siena_phy_bist_stop(
396         __in                    efx_nic_t *enp,
397         __in                    efx_bist_type_t type);
398
399 #endif  /* EFSYS_OPT_BIST */
400
401 extern  __checkReturn   efx_rc_t
402 siena_mac_poll(
403         __in            efx_nic_t *enp,
404         __out           efx_link_mode_t *link_modep);
405
406 extern  __checkReturn   efx_rc_t
407 siena_mac_up(
408         __in            efx_nic_t *enp,
409         __out           boolean_t *mac_upp);
410
411 extern  __checkReturn   efx_rc_t
412 siena_mac_reconfigure(
413         __in    efx_nic_t *enp);
414
415 extern  __checkReturn   efx_rc_t
416 siena_mac_pdu_get(
417         __in    efx_nic_t *enp,
418         __out   size_t *pdu);
419
420 #if EFSYS_OPT_LOOPBACK
421
422 extern  __checkReturn   efx_rc_t
423 siena_mac_loopback_set(
424         __in            efx_nic_t *enp,
425         __in            efx_link_mode_t link_mode,
426         __in            efx_loopback_type_t loopback_type);
427
428 #endif  /* EFSYS_OPT_LOOPBACK */
429
430 #if EFSYS_OPT_MAC_STATS
431
432 extern  __checkReturn                   efx_rc_t
433 siena_mac_stats_get_mask(
434         __in                            efx_nic_t *enp,
435         __inout_bcount(mask_size)       uint32_t *maskp,
436         __in                            size_t mask_size);
437
438 extern  __checkReturn                   efx_rc_t
439 siena_mac_stats_update(
440         __in                            efx_nic_t *enp,
441         __in                            efsys_mem_t *esmp,
442         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
443         __inout_opt                     uint32_t *generationp);
444
445 #endif  /* EFSYS_OPT_MAC_STATS */
446
447 #ifdef  __cplusplus
448 }
449 #endif
450
451 #endif  /* _SYS_SIENA_IMPL_H */