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