net/sfc/base: improve PS credits push function name
[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         __out_opt               uint32_t *verify_resultp);
148
149 extern  __checkReturn           efx_rc_t
150 siena_nvram_get_dynamic_cfg(
151         __in                    efx_nic_t *enp,
152         __in                    uint32_t partn,
153         __in                    boolean_t vpd,
154         __out                   siena_mc_dynamic_config_hdr_t **dcfgp,
155         __out                   size_t *sizep);
156
157 #endif  /* EFSYS_OPT_VPD || EFSYS_OPT_NVRAM */
158
159 #if EFSYS_OPT_NVRAM
160
161 #if EFSYS_OPT_DIAG
162
163 extern  __checkReturn           efx_rc_t
164 siena_nvram_test(
165         __in                    efx_nic_t *enp);
166
167 #endif  /* EFSYS_OPT_DIAG */
168
169 extern  __checkReturn           efx_rc_t
170 siena_nvram_get_subtype(
171         __in                    efx_nic_t *enp,
172         __in                    uint32_t partn,
173         __out                   uint32_t *subtypep);
174
175 extern  __checkReturn           efx_rc_t
176 siena_nvram_type_to_partn(
177         __in                    efx_nic_t *enp,
178         __in                    efx_nvram_type_t type,
179         __out                   uint32_t *partnp);
180
181 extern  __checkReturn           efx_rc_t
182 siena_nvram_partn_size(
183         __in                    efx_nic_t *enp,
184         __in                    uint32_t partn,
185         __out                   size_t *sizep);
186
187 extern  __checkReturn           efx_rc_t
188 siena_nvram_partn_rw_start(
189         __in                    efx_nic_t *enp,
190         __in                    uint32_t partn,
191         __out                   size_t *chunk_sizep);
192
193 extern  __checkReturn           efx_rc_t
194 siena_nvram_partn_read(
195         __in                    efx_nic_t *enp,
196         __in                    uint32_t partn,
197         __in                    unsigned int offset,
198         __out_bcount(size)      caddr_t data,
199         __in                    size_t size);
200
201 extern  __checkReturn           efx_rc_t
202 siena_nvram_partn_erase(
203         __in                    efx_nic_t *enp,
204         __in                    uint32_t partn,
205         __in                    unsigned int offset,
206         __in                    size_t size);
207
208 extern  __checkReturn           efx_rc_t
209 siena_nvram_partn_write(
210         __in                    efx_nic_t *enp,
211         __in                    uint32_t partn,
212         __in                    unsigned int offset,
213         __out_bcount(size)      caddr_t data,
214         __in                    size_t size);
215
216 extern  __checkReturn           efx_rc_t
217 siena_nvram_partn_rw_finish(
218         __in                    efx_nic_t *enp,
219         __in                    uint32_t partn,
220         __out_opt               uint32_t *verify_resultp);
221
222 extern  __checkReturn           efx_rc_t
223 siena_nvram_partn_get_version(
224         __in                    efx_nic_t *enp,
225         __in                    uint32_t partn,
226         __out                   uint32_t *subtypep,
227         __out_ecount(4)         uint16_t version[4]);
228
229 extern  __checkReturn           efx_rc_t
230 siena_nvram_partn_set_version(
231         __in                    efx_nic_t *enp,
232         __in                    uint32_t partn,
233         __in_ecount(4)          uint16_t version[4]);
234
235 #endif  /* EFSYS_OPT_NVRAM */
236
237 #if EFSYS_OPT_VPD
238
239 extern  __checkReturn           efx_rc_t
240 siena_vpd_init(
241         __in                    efx_nic_t *enp);
242
243 extern  __checkReturn           efx_rc_t
244 siena_vpd_size(
245         __in                    efx_nic_t *enp,
246         __out                   size_t *sizep);
247
248 extern  __checkReturn           efx_rc_t
249 siena_vpd_read(
250         __in                    efx_nic_t *enp,
251         __out_bcount(size)      caddr_t data,
252         __in                    size_t size);
253
254 extern  __checkReturn           efx_rc_t
255 siena_vpd_verify(
256         __in                    efx_nic_t *enp,
257         __in_bcount(size)       caddr_t data,
258         __in                    size_t size);
259
260 extern  __checkReturn           efx_rc_t
261 siena_vpd_reinit(
262         __in                    efx_nic_t *enp,
263         __in_bcount(size)       caddr_t data,
264         __in                    size_t size);
265
266 extern  __checkReturn           efx_rc_t
267 siena_vpd_get(
268         __in                    efx_nic_t *enp,
269         __in_bcount(size)       caddr_t data,
270         __in                    size_t size,
271         __inout                 efx_vpd_value_t *evvp);
272
273 extern  __checkReturn           efx_rc_t
274 siena_vpd_set(
275         __in                    efx_nic_t *enp,
276         __in_bcount(size)       caddr_t data,
277         __in                    size_t size,
278         __in                    efx_vpd_value_t *evvp);
279
280 extern  __checkReturn           efx_rc_t
281 siena_vpd_next(
282         __in                    efx_nic_t *enp,
283         __in_bcount(size)       caddr_t data,
284         __in                    size_t size,
285         __out                   efx_vpd_value_t *evvp,
286         __inout                 unsigned int *contp);
287
288 extern __checkReturn            efx_rc_t
289 siena_vpd_write(
290         __in                    efx_nic_t *enp,
291         __in_bcount(size)       caddr_t data,
292         __in                    size_t size);
293
294 extern                          void
295 siena_vpd_fini(
296         __in                    efx_nic_t *enp);
297
298 #endif  /* EFSYS_OPT_VPD */
299
300 typedef struct siena_link_state_s {
301         uint32_t                sls_adv_cap_mask;
302         uint32_t                sls_lp_cap_mask;
303         unsigned int            sls_fcntl;
304         efx_link_mode_t         sls_link_mode;
305 #if EFSYS_OPT_LOOPBACK
306         efx_loopback_type_t     sls_loopback;
307 #endif
308         boolean_t               sls_mac_up;
309 } siena_link_state_t;
310
311 extern                  void
312 siena_phy_link_ev(
313         __in            efx_nic_t *enp,
314         __in            efx_qword_t *eqp,
315         __out           efx_link_mode_t *link_modep);
316
317 extern  __checkReturn   efx_rc_t
318 siena_phy_get_link(
319         __in            efx_nic_t *enp,
320         __out           siena_link_state_t *slsp);
321
322 extern  __checkReturn   efx_rc_t
323 siena_phy_power(
324         __in            efx_nic_t *enp,
325         __in            boolean_t on);
326
327 extern  __checkReturn   efx_rc_t
328 siena_phy_reconfigure(
329         __in            efx_nic_t *enp);
330
331 extern  __checkReturn   efx_rc_t
332 siena_phy_verify(
333         __in            efx_nic_t *enp);
334
335 extern  __checkReturn   efx_rc_t
336 siena_phy_oui_get(
337         __in            efx_nic_t *enp,
338         __out           uint32_t *ouip);
339
340 #if EFSYS_OPT_PHY_STATS
341
342 extern                                          void
343 siena_phy_decode_stats(
344         __in                                    efx_nic_t *enp,
345         __in                                    uint32_t vmask,
346         __in_opt                                efsys_mem_t *esmp,
347         __out_opt                               uint64_t *smaskp,
348         __inout_ecount_opt(EFX_PHY_NSTATS)      uint32_t *stat);
349
350 extern  __checkReturn                   efx_rc_t
351 siena_phy_stats_update(
352         __in                            efx_nic_t *enp,
353         __in                            efsys_mem_t *esmp,
354         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
355
356 #endif  /* EFSYS_OPT_PHY_STATS */
357
358 #if EFSYS_OPT_BIST
359
360 extern  __checkReturn           efx_rc_t
361 siena_phy_bist_start(
362         __in                    efx_nic_t *enp,
363         __in                    efx_bist_type_t type);
364
365 extern  __checkReturn           efx_rc_t
366 siena_phy_bist_poll(
367         __in                    efx_nic_t *enp,
368         __in                    efx_bist_type_t type,
369         __out                   efx_bist_result_t *resultp,
370         __out_opt __drv_when(count > 0, __notnull)
371         uint32_t        *value_maskp,
372         __out_ecount_opt(count) __drv_when(count > 0, __notnull)
373         unsigned long   *valuesp,
374         __in                    size_t count);
375
376 extern                          void
377 siena_phy_bist_stop(
378         __in                    efx_nic_t *enp,
379         __in                    efx_bist_type_t type);
380
381 #endif  /* EFSYS_OPT_BIST */
382
383 extern  __checkReturn   efx_rc_t
384 siena_mac_poll(
385         __in            efx_nic_t *enp,
386         __out           efx_link_mode_t *link_modep);
387
388 extern  __checkReturn   efx_rc_t
389 siena_mac_up(
390         __in            efx_nic_t *enp,
391         __out           boolean_t *mac_upp);
392
393 extern  __checkReturn   efx_rc_t
394 siena_mac_reconfigure(
395         __in    efx_nic_t *enp);
396
397 extern  __checkReturn   efx_rc_t
398 siena_mac_pdu_get(
399         __in    efx_nic_t *enp,
400         __out   size_t *pdu);
401
402 #if EFSYS_OPT_LOOPBACK
403
404 extern  __checkReturn   efx_rc_t
405 siena_mac_loopback_set(
406         __in            efx_nic_t *enp,
407         __in            efx_link_mode_t link_mode,
408         __in            efx_loopback_type_t loopback_type);
409
410 #endif  /* EFSYS_OPT_LOOPBACK */
411
412 #if EFSYS_OPT_MAC_STATS
413
414 extern  __checkReturn                   efx_rc_t
415 siena_mac_stats_get_mask(
416         __in                            efx_nic_t *enp,
417         __inout_bcount(mask_size)       uint32_t *maskp,
418         __in                            size_t mask_size);
419
420 extern  __checkReturn                   efx_rc_t
421 siena_mac_stats_update(
422         __in                            efx_nic_t *enp,
423         __in                            efsys_mem_t *esmp,
424         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
425         __inout_opt                     uint32_t *generationp);
426
427 #endif  /* EFSYS_OPT_MAC_STATS */
428
429 #ifdef  __cplusplus
430 }
431 #endif
432
433 #endif  /* _SYS_SIENA_IMPL_H */