2 * Copyright (c) 2015-2016 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
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.
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.
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.
31 #ifndef _SYS_EF10_IMPL_H
32 #define _SYS_EF10_IMPL_H
38 #if (EFSYS_OPT_HUNTINGTON && EFSYS_OPT_MEDFORD)
39 #define EF10_MAX_PIOBUF_NBUFS MAX(HUNT_PIOBUF_NBUFS, MEDFORD_PIOBUF_NBUFS)
40 #elif EFSYS_OPT_HUNTINGTON
41 #define EF10_MAX_PIOBUF_NBUFS HUNT_PIOBUF_NBUFS
42 #elif EFSYS_OPT_MEDFORD
43 #define EF10_MAX_PIOBUF_NBUFS MEDFORD_PIOBUF_NBUFS
47 * FIXME: This is just a power of 2 which fits in an MCDI v1 message, and could
48 * possibly be increased, or the write size reported by newer firmware used
51 #define EF10_NVRAM_CHUNK 0x80
53 /* Alignment requirement for value written to RX WPTR:
54 * the WPTR must be aligned to an 8 descriptor boundary
56 #define EF10_RX_WPTR_ALIGN 8
59 * Max byte offset into the packet the TCP header must start for the hardware
60 * to be able to parse the packet correctly.
62 #define EF10_TCP_HEADER_OFFSET_LIMIT 208
64 /* Invalid RSS context handle */
65 #define EF10_RSS_CONTEXT_INVALID (0xffffffff)
70 __checkReturn efx_rc_t
78 __checkReturn efx_rc_t
81 __in unsigned int index,
82 __in efsys_mem_t *esmp,
93 __checkReturn efx_rc_t
96 __in unsigned int count);
103 __checkReturn efx_rc_t
106 __in unsigned int us);
110 ef10_ev_qstats_update(
112 __inout_ecount(EV_NQSTATS) efsys_stat_t *stat);
113 #endif /* EFSYS_OPT_QSTATS */
116 ef10_ev_rxlabel_init(
119 __in unsigned int label,
120 __in boolean_t packed_stream);
123 ef10_ev_rxlabel_fini(
125 __in unsigned int label);
129 __checkReturn efx_rc_t
132 __in efx_intr_type_t type,
133 __in efsys_mem_t *esmp);
137 __in efx_nic_t *enp);
141 __in efx_nic_t *enp);
144 ef10_intr_disable_unlocked(
145 __in efx_nic_t *enp);
147 __checkReturn efx_rc_t
150 __in unsigned int level);
153 ef10_intr_status_line(
155 __out boolean_t *fatalp,
156 __out uint32_t *qmaskp);
159 ef10_intr_status_message(
161 __in unsigned int message,
162 __out boolean_t *fatalp);
166 __in efx_nic_t *enp);
169 __in efx_nic_t *enp);
173 extern __checkReturn efx_rc_t
175 __in efx_nic_t *enp);
177 extern __checkReturn efx_rc_t
178 ef10_nic_set_drv_limits(
179 __inout efx_nic_t *enp,
180 __in efx_drv_limits_t *edlp);
182 extern __checkReturn efx_rc_t
183 ef10_nic_get_vi_pool(
185 __out uint32_t *vi_countp);
187 extern __checkReturn efx_rc_t
188 ef10_nic_get_bar_region(
190 __in efx_nic_region_t region,
191 __out uint32_t *offsetp,
192 __out size_t *sizep);
194 extern __checkReturn efx_rc_t
196 __in efx_nic_t *enp);
198 extern __checkReturn efx_rc_t
200 __in efx_nic_t *enp);
204 extern __checkReturn efx_rc_t
205 ef10_nic_register_test(
206 __in efx_nic_t *enp);
208 #endif /* EFSYS_OPT_DIAG */
212 __in efx_nic_t *enp);
216 __in efx_nic_t *enp);
221 extern __checkReturn efx_rc_t
224 __out efx_link_mode_t *link_modep);
226 extern __checkReturn efx_rc_t
229 __out boolean_t *mac_upp);
231 extern __checkReturn efx_rc_t
233 __in efx_nic_t *enp);
235 extern __checkReturn efx_rc_t
237 __in efx_nic_t *enp);
239 extern __checkReturn efx_rc_t
244 extern __checkReturn efx_rc_t
245 ef10_mac_reconfigure(
246 __in efx_nic_t *enp);
248 extern __checkReturn efx_rc_t
249 ef10_mac_multicast_list_set(
250 __in efx_nic_t *enp);
252 extern __checkReturn efx_rc_t
253 ef10_mac_filter_default_rxq_set(
256 __in boolean_t using_rss);
259 ef10_mac_filter_default_rxq_clear(
260 __in efx_nic_t *enp);
267 extern __checkReturn efx_rc_t
270 __in const efx_mcdi_transport_t *mtp);
274 __in efx_nic_t *enp);
277 ef10_mcdi_send_request(
279 __in_bcount(hdr_len) void *hdrp,
281 __in_bcount(sdu_len) void *sdup,
282 __in size_t sdu_len);
284 extern __checkReturn boolean_t
285 ef10_mcdi_poll_response(
286 __in efx_nic_t *enp);
289 ef10_mcdi_read_response(
291 __out_bcount(length) void *bufferp,
296 ef10_mcdi_poll_reboot(
297 __in efx_nic_t *enp);
299 extern __checkReturn efx_rc_t
300 ef10_mcdi_feature_supported(
302 __in efx_mcdi_feature_id_t id,
303 __out boolean_t *supportedp);
306 ef10_mcdi_get_timeout(
308 __in efx_mcdi_req_t *emrp,
309 __out uint32_t *timeoutp);
311 #endif /* EFSYS_OPT_MCDI */
318 typedef struct ef10_link_state_s {
319 uint32_t els_adv_cap_mask;
320 uint32_t els_lp_cap_mask;
321 unsigned int els_fcntl;
322 efx_link_mode_t els_link_mode;
323 boolean_t els_mac_up;
329 __in efx_qword_t *eqp,
330 __out efx_link_mode_t *link_modep);
332 extern __checkReturn efx_rc_t
335 __out ef10_link_state_t *elsp);
337 extern __checkReturn efx_rc_t
342 extern __checkReturn efx_rc_t
343 ef10_phy_reconfigure(
344 __in efx_nic_t *enp);
346 extern __checkReturn efx_rc_t
348 __in efx_nic_t *enp);
350 extern __checkReturn efx_rc_t
353 __out uint32_t *ouip);
355 #if EFSYS_OPT_PHY_STATS
357 extern __checkReturn efx_rc_t
358 ef10_phy_stats_update(
360 __in efsys_mem_t *esmp,
361 __inout_ecount(EFX_PHY_NSTATS) uint32_t *stat);
363 #endif /* EFSYS_OPT_PHY_STATS */
367 extern __checkReturn efx_rc_t
368 ef10_bist_enable_offline(
369 __in efx_nic_t *enp);
371 extern __checkReturn efx_rc_t
374 __in efx_bist_type_t type);
376 extern __checkReturn efx_rc_t
379 __in efx_bist_type_t type,
380 __out efx_bist_result_t *resultp,
381 __out_opt __drv_when(count > 0, __notnull)
382 uint32_t *value_maskp,
383 __out_ecount_opt(count) __drv_when(count > 0, __notnull)
384 unsigned long *valuesp,
390 __in efx_bist_type_t type);
392 #endif /* EFSYS_OPT_BIST */
396 extern __checkReturn efx_rc_t
398 __in efx_nic_t *enp);
402 __in efx_nic_t *enp);
404 extern __checkReturn efx_rc_t
407 __in unsigned int index,
408 __in unsigned int label,
409 __in efsys_mem_t *esmp,
415 __out unsigned int *addedp);
419 __in efx_txq_t *etp);
421 extern __checkReturn efx_rc_t
424 __in_ecount(n) efx_buffer_t *eb,
426 __in unsigned int completed,
427 __inout unsigned int *addedp);
432 __in unsigned int added,
433 __in unsigned int pushed);
435 extern __checkReturn efx_rc_t
438 __in unsigned int ns);
440 extern __checkReturn efx_rc_t
442 __in efx_txq_t *etp);
446 __in efx_txq_t *etp);
448 extern __checkReturn efx_rc_t
450 __in efx_txq_t *etp);
453 ef10_tx_qpio_disable(
454 __in efx_txq_t *etp);
456 extern __checkReturn efx_rc_t
459 __in_ecount(buf_length) uint8_t *buffer,
460 __in size_t buf_length,
461 __in size_t pio_buf_offset);
463 extern __checkReturn efx_rc_t
466 __in size_t pkt_length,
467 __in unsigned int completed,
468 __inout unsigned int *addedp);
470 extern __checkReturn efx_rc_t
473 __in_ecount(n) efx_desc_t *ed,
475 __in unsigned int completed,
476 __inout unsigned int *addedp);
479 ef10_tx_qdesc_dma_create(
481 __in efsys_dma_addr_t addr,
484 __out efx_desc_t *edp);
487 ef10_tx_qdesc_tso_create(
489 __in uint16_t ipv4_id,
490 __in uint32_t tcp_seq,
491 __in uint8_t tcp_flags,
492 __out efx_desc_t *edp);
495 ef10_tx_qdesc_tso2_create(
497 __in uint16_t ipv4_id,
498 __in uint32_t tcp_seq,
499 __in uint16_t tcp_mss,
500 __out_ecount(count) efx_desc_t *edp,
504 ef10_tx_qdesc_vlantci_create(
506 __in uint16_t vlan_tci,
507 __out efx_desc_t *edp);
513 ef10_tx_qstats_update(
515 __inout_ecount(TX_NQSTATS) efsys_stat_t *stat);
517 #endif /* EFSYS_OPT_QSTATS */
519 typedef uint32_t efx_piobuf_handle_t;
521 #define EFX_PIOBUF_HANDLE_INVALID ((efx_piobuf_handle_t) -1)
523 extern __checkReturn efx_rc_t
525 __inout efx_nic_t *enp,
526 __out uint32_t *bufnump,
527 __out efx_piobuf_handle_t *handlep,
528 __out uint32_t *blknump,
529 __out uint32_t *offsetp,
530 __out size_t *sizep);
532 extern __checkReturn efx_rc_t
534 __inout efx_nic_t *enp,
535 __in uint32_t bufnum,
536 __in uint32_t blknum);
538 extern __checkReturn efx_rc_t
540 __inout efx_nic_t *enp,
541 __in uint32_t vi_index,
542 __in efx_piobuf_handle_t handle);
544 extern __checkReturn efx_rc_t
546 __inout efx_nic_t *enp,
547 __in uint32_t vi_index);
555 extern __checkReturn efx_rc_t
557 __in efx_nic_t *enp);
560 extern __checkReturn efx_rc_t
561 ef10_rx_prefix_pktlen(
563 __in uint8_t *buffer,
564 __out uint16_t *lengthp);
569 __in_ecount(n) efsys_dma_addr_t *addrp,
572 __in unsigned int completed,
573 __in unsigned int added);
578 __in unsigned int added,
579 __inout unsigned int *pushedp);
581 extern __checkReturn efx_rc_t
583 __in efx_rxq_t *erp);
587 __in efx_rxq_t *erp);
589 extern __checkReturn efx_rc_t
592 __in unsigned int index,
593 __in unsigned int label,
594 __in efx_rxq_type_t type,
595 __in efsys_mem_t *esmp,
599 __in efx_rxq_t *erp);
603 __in efx_rxq_t *erp);
607 __in efx_nic_t *enp);
611 typedef struct ef10_filter_handle_s {
614 } ef10_filter_handle_t;
616 typedef struct ef10_filter_entry_s {
617 uintptr_t efe_spec; /* pointer to filter spec plus busy bit */
618 ef10_filter_handle_t efe_handle;
619 } ef10_filter_entry_t;
622 * BUSY flag indicates that an update is in progress.
623 * AUTO_OLD flag is used to mark and sweep MAC packet filters.
625 #define EFX_EF10_FILTER_FLAG_BUSY 1U
626 #define EFX_EF10_FILTER_FLAG_AUTO_OLD 2U
627 #define EFX_EF10_FILTER_FLAGS 3U
630 * Size of the hash table used by the driver. Doesn't need to be the
631 * same size as the hardware's table.
633 #define EFX_EF10_FILTER_TBL_ROWS 8192
635 /* Only need to allow for one directed and one unknown unicast filter */
636 #define EFX_EF10_FILTER_UNICAST_FILTERS_MAX 2
638 /* Allow for the broadcast address to be added to the multicast list */
639 #define EFX_EF10_FILTER_MULTICAST_FILTERS_MAX (EFX_MAC_MULTICAST_LIST_MAX + 1)
641 typedef struct ef10_filter_table_s {
642 ef10_filter_entry_t eft_entry[EFX_EF10_FILTER_TBL_ROWS];
643 efx_rxq_t *eft_default_rxq;
644 boolean_t eft_using_rss;
645 uint32_t eft_unicst_filter_indexes[
646 EFX_EF10_FILTER_UNICAST_FILTERS_MAX];
647 uint32_t eft_unicst_filter_count;
648 uint32_t eft_mulcst_filter_indexes[
649 EFX_EF10_FILTER_MULTICAST_FILTERS_MAX];
650 uint32_t eft_mulcst_filter_count;
651 boolean_t eft_using_all_mulcst;
652 } ef10_filter_table_t;
654 __checkReturn efx_rc_t
656 __in efx_nic_t *enp);
660 __in efx_nic_t *enp);
662 __checkReturn efx_rc_t
664 __in efx_nic_t *enp);
666 __checkReturn efx_rc_t
669 __inout efx_filter_spec_t *spec,
670 __in boolean_t may_replace);
672 __checkReturn efx_rc_t
675 __inout efx_filter_spec_t *spec);
677 extern __checkReturn efx_rc_t
678 ef10_filter_supported_filters(
680 __out uint32_t *list,
681 __out size_t *length);
683 extern __checkReturn efx_rc_t
684 ef10_filter_reconfigure(
686 __in_ecount(6) uint8_t const *mac_addr,
687 __in boolean_t all_unicst,
688 __in boolean_t mulcst,
689 __in boolean_t all_mulcst,
690 __in boolean_t brdcst,
691 __in_ecount(6*count) uint8_t const *addrs,
692 __in uint32_t count);
695 ef10_filter_get_default_rxq(
697 __out efx_rxq_t **erpp,
698 __out boolean_t *using_rss);
701 ef10_filter_default_rxq_set(
704 __in boolean_t using_rss);
707 ef10_filter_default_rxq_clear(
708 __in efx_nic_t *enp);
711 #endif /* EFSYS_OPT_FILTER */
713 extern __checkReturn efx_rc_t
714 efx_mcdi_get_function_info(
717 __out_opt uint32_t *vfp);
719 extern __checkReturn efx_rc_t
720 efx_mcdi_privilege_mask(
724 __out uint32_t *maskp);
726 extern __checkReturn efx_rc_t
727 efx_mcdi_get_port_assignment(
729 __out uint32_t *portp);
731 extern __checkReturn efx_rc_t
732 efx_mcdi_get_port_modes(
734 __out uint32_t *modesp,
735 __out_opt uint32_t *current_modep);
737 extern __checkReturn efx_rc_t
738 ef10_nic_get_port_mode_bandwidth(
739 __in uint32_t port_mode,
740 __out uint32_t *bandwidth_mbpsp);
742 extern __checkReturn efx_rc_t
743 efx_mcdi_get_mac_address_pf(
745 __out_ecount_opt(6) uint8_t mac_addrp[6]);
747 extern __checkReturn efx_rc_t
748 efx_mcdi_get_mac_address_vf(
750 __out_ecount_opt(6) uint8_t mac_addrp[6]);
752 extern __checkReturn efx_rc_t
755 __out uint32_t *sys_freqp,
756 __out uint32_t *dpcpu_freqp);
759 extern __checkReturn efx_rc_t
760 efx_mcdi_get_vector_cfg(
762 __out_opt uint32_t *vec_basep,
763 __out_opt uint32_t *pf_nvecp,
764 __out_opt uint32_t *vf_nvecp);
766 extern __checkReturn efx_rc_t
767 ef10_get_datapath_caps(
768 __in efx_nic_t *enp);
770 extern __checkReturn efx_rc_t
771 ef10_get_privilege_mask(
773 __out uint32_t *maskp);
775 extern __checkReturn efx_rc_t
776 ef10_external_port_mapping(
779 __out uint8_t *external_portp);
785 #endif /* _SYS_EF10_IMPL_H */