da03098e7ab8a423c510072e38cc24607ebb066a
[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 typedef struct siena_link_state_s {
137         uint32_t                sls_adv_cap_mask;
138         uint32_t                sls_lp_cap_mask;
139         unsigned int            sls_fcntl;
140         efx_link_mode_t         sls_link_mode;
141 #if EFSYS_OPT_LOOPBACK
142         efx_loopback_type_t     sls_loopback;
143 #endif
144         boolean_t               sls_mac_up;
145 } siena_link_state_t;
146
147 extern                  void
148 siena_phy_link_ev(
149         __in            efx_nic_t *enp,
150         __in            efx_qword_t *eqp,
151         __out           efx_link_mode_t *link_modep);
152
153 extern  __checkReturn   efx_rc_t
154 siena_phy_get_link(
155         __in            efx_nic_t *enp,
156         __out           siena_link_state_t *slsp);
157
158 extern  __checkReturn   efx_rc_t
159 siena_phy_power(
160         __in            efx_nic_t *enp,
161         __in            boolean_t on);
162
163 extern  __checkReturn   efx_rc_t
164 siena_phy_reconfigure(
165         __in            efx_nic_t *enp);
166
167 extern  __checkReturn   efx_rc_t
168 siena_phy_verify(
169         __in            efx_nic_t *enp);
170
171 extern  __checkReturn   efx_rc_t
172 siena_phy_oui_get(
173         __in            efx_nic_t *enp,
174         __out           uint32_t *ouip);
175
176 #if EFSYS_OPT_PHY_STATS
177
178 extern                                          void
179 siena_phy_decode_stats(
180         __in                                    efx_nic_t *enp,
181         __in                                    uint32_t vmask,
182         __in_opt                                efsys_mem_t *esmp,
183         __out_opt                               uint64_t *smaskp,
184         __inout_ecount_opt(EFX_PHY_NSTATS)      uint32_t *stat);
185
186 extern  __checkReturn                   efx_rc_t
187 siena_phy_stats_update(
188         __in                            efx_nic_t *enp,
189         __in                            efsys_mem_t *esmp,
190         __inout_ecount(EFX_PHY_NSTATS)  uint32_t *stat);
191
192 #endif  /* EFSYS_OPT_PHY_STATS */
193
194 #if EFSYS_OPT_BIST
195
196 extern  __checkReturn           efx_rc_t
197 siena_phy_bist_start(
198         __in                    efx_nic_t *enp,
199         __in                    efx_bist_type_t type);
200
201 extern  __checkReturn           efx_rc_t
202 siena_phy_bist_poll(
203         __in                    efx_nic_t *enp,
204         __in                    efx_bist_type_t type,
205         __out                   efx_bist_result_t *resultp,
206         __out_opt __drv_when(count > 0, __notnull)
207         uint32_t        *value_maskp,
208         __out_ecount_opt(count) __drv_when(count > 0, __notnull)
209         unsigned long   *valuesp,
210         __in                    size_t count);
211
212 extern                          void
213 siena_phy_bist_stop(
214         __in                    efx_nic_t *enp,
215         __in                    efx_bist_type_t type);
216
217 #endif  /* EFSYS_OPT_BIST */
218
219 extern  __checkReturn   efx_rc_t
220 siena_mac_poll(
221         __in            efx_nic_t *enp,
222         __out           efx_link_mode_t *link_modep);
223
224 extern  __checkReturn   efx_rc_t
225 siena_mac_up(
226         __in            efx_nic_t *enp,
227         __out           boolean_t *mac_upp);
228
229 extern  __checkReturn   efx_rc_t
230 siena_mac_reconfigure(
231         __in    efx_nic_t *enp);
232
233 extern  __checkReturn   efx_rc_t
234 siena_mac_pdu_get(
235         __in    efx_nic_t *enp,
236         __out   size_t *pdu);
237
238 #if EFSYS_OPT_LOOPBACK
239
240 extern  __checkReturn   efx_rc_t
241 siena_mac_loopback_set(
242         __in            efx_nic_t *enp,
243         __in            efx_link_mode_t link_mode,
244         __in            efx_loopback_type_t loopback_type);
245
246 #endif  /* EFSYS_OPT_LOOPBACK */
247
248 #if EFSYS_OPT_MAC_STATS
249
250 extern  __checkReturn                   efx_rc_t
251 siena_mac_stats_get_mask(
252         __in                            efx_nic_t *enp,
253         __inout_bcount(mask_size)       uint32_t *maskp,
254         __in                            size_t mask_size);
255
256 extern  __checkReturn                   efx_rc_t
257 siena_mac_stats_update(
258         __in                            efx_nic_t *enp,
259         __in                            efsys_mem_t *esmp,
260         __inout_ecount(EFX_MAC_NSTATS)  efsys_stat_t *stat,
261         __inout_opt                     uint32_t *generationp);
262
263 #endif  /* EFSYS_OPT_MAC_STATS */
264
265 #ifdef  __cplusplus
266 }
267 #endif
268
269 #endif  /* _SYS_SIENA_IMPL_H */