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