2 * Copyright (c) 2006-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.
35 #include "efx_check.h"
36 #include "efx_phy_ids.h"
42 #define EFX_STATIC_ASSERT(_cond) \
43 ((void)sizeof(char[(_cond) ? 1 : -1]))
45 #define EFX_ARRAY_SIZE(_array) \
46 (sizeof(_array) / sizeof((_array)[0]))
48 #define EFX_FIELD_OFFSET(_type, _field) \
49 ((size_t) &(((_type *)0)->_field))
53 typedef __success(return == 0) int efx_rc_t;
58 typedef enum efx_family_e {
60 EFX_FAMILY_FALCON, /* Obsolete and not supported */
62 EFX_FAMILY_HUNTINGTON,
67 extern __checkReturn efx_rc_t
71 __out efx_family_t *efp);
74 #define EFX_PCI_VENID_SFC 0x1924
76 #define EFX_PCI_DEVID_FALCON 0x0710 /* SFC4000 */
78 #define EFX_PCI_DEVID_BETHPAGE 0x0803 /* SFC9020 */
79 #define EFX_PCI_DEVID_SIENA 0x0813 /* SFL9021 */
80 #define EFX_PCI_DEVID_SIENA_F1_UNINIT 0x0810
82 #define EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT 0x0901
83 #define EFX_PCI_DEVID_FARMINGDALE 0x0903 /* SFC9120 PF */
84 #define EFX_PCI_DEVID_GREENPORT 0x0923 /* SFC9140 PF */
86 #define EFX_PCI_DEVID_FARMINGDALE_VF 0x1903 /* SFC9120 VF */
87 #define EFX_PCI_DEVID_GREENPORT_VF 0x1923 /* SFC9140 VF */
89 #define EFX_PCI_DEVID_MEDFORD_PF_UNINIT 0x0913
90 #define EFX_PCI_DEVID_MEDFORD 0x0A03 /* SFC9240 PF */
91 #define EFX_PCI_DEVID_MEDFORD_VF 0x1A03 /* SFC9240 VF */
100 EFX_ERR_BUFID_DC_OOB,
113 /* Calculate the IEEE 802.3 CRC32 of a MAC addr */
114 extern __checkReturn uint32_t
116 __in uint32_t crc_init,
117 __in_ecount(length) uint8_t const *input,
121 /* Type prototypes */
123 typedef struct efx_rxq_s efx_rxq_t;
127 typedef struct efx_nic_s efx_nic_t;
129 extern __checkReturn efx_rc_t
131 __in efx_family_t family,
132 __in efsys_identifier_t *esip,
133 __in efsys_bar_t *esbp,
134 __in efsys_lock_t *eslp,
135 __deref_out efx_nic_t **enpp);
137 extern __checkReturn efx_rc_t
139 __in efx_nic_t *enp);
141 extern __checkReturn efx_rc_t
143 __in efx_nic_t *enp);
145 extern __checkReturn efx_rc_t
147 __in efx_nic_t *enp);
151 extern __checkReturn efx_rc_t
152 efx_nic_register_test(
153 __in efx_nic_t *enp);
155 #endif /* EFSYS_OPT_DIAG */
159 __in efx_nic_t *enp);
163 __in efx_nic_t *enp);
167 __in efx_nic_t *enp);
169 #define EFX_PCIE_LINK_SPEED_GEN1 1
170 #define EFX_PCIE_LINK_SPEED_GEN2 2
171 #define EFX_PCIE_LINK_SPEED_GEN3 3
173 typedef enum efx_pcie_link_performance_e {
174 EFX_PCIE_LINK_PERFORMANCE_UNKNOWN_BANDWIDTH,
175 EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_BANDWIDTH,
176 EFX_PCIE_LINK_PERFORMANCE_SUBOPTIMAL_LATENCY,
177 EFX_PCIE_LINK_PERFORMANCE_OPTIMAL
178 } efx_pcie_link_performance_t;
180 extern __checkReturn efx_rc_t
181 efx_nic_calculate_pcie_link_bandwidth(
182 __in uint32_t pcie_link_width,
183 __in uint32_t pcie_link_gen,
184 __out uint32_t *bandwidth_mbpsp);
186 extern __checkReturn efx_rc_t
187 efx_nic_check_pcie_link_speed(
189 __in uint32_t pcie_link_width,
190 __in uint32_t pcie_link_gen,
191 __out efx_pcie_link_performance_t *resultp);
195 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
196 /* Huntington and Medford require MCDIv2 commands */
197 #define WITH_MCDI_V2 1
200 typedef struct efx_mcdi_req_s efx_mcdi_req_t;
202 typedef enum efx_mcdi_exception_e {
203 EFX_MCDI_EXCEPTION_MC_REBOOT,
204 EFX_MCDI_EXCEPTION_MC_BADASSERT,
205 } efx_mcdi_exception_t;
207 #if EFSYS_OPT_MCDI_LOGGING
208 typedef enum efx_log_msg_e {
210 EFX_LOG_MCDI_REQUEST,
211 EFX_LOG_MCDI_RESPONSE,
213 #endif /* EFSYS_OPT_MCDI_LOGGING */
215 typedef struct efx_mcdi_transport_s {
217 efsys_mem_t *emt_dma_mem;
218 void (*emt_execute)(void *, efx_mcdi_req_t *);
219 void (*emt_ev_cpl)(void *);
220 void (*emt_exception)(void *, efx_mcdi_exception_t);
221 #if EFSYS_OPT_MCDI_LOGGING
222 void (*emt_logger)(void *, efx_log_msg_t,
223 void *, size_t, void *, size_t);
224 #endif /* EFSYS_OPT_MCDI_LOGGING */
225 #if EFSYS_OPT_MCDI_PROXY_AUTH
226 void (*emt_ev_proxy_response)(void *, uint32_t, efx_rc_t);
227 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
228 } efx_mcdi_transport_t;
230 extern __checkReturn efx_rc_t
233 __in const efx_mcdi_transport_t *mtp);
235 extern __checkReturn efx_rc_t
237 __in efx_nic_t *enp);
241 __in efx_nic_t *enp);
244 efx_mcdi_get_timeout(
246 __in efx_mcdi_req_t *emrp,
247 __out uint32_t *usec_timeoutp);
250 efx_mcdi_request_start(
252 __in efx_mcdi_req_t *emrp,
253 __in boolean_t ev_cpl);
255 extern __checkReturn boolean_t
256 efx_mcdi_request_poll(
257 __in efx_nic_t *enp);
259 extern __checkReturn boolean_t
260 efx_mcdi_request_abort(
261 __in efx_nic_t *enp);
265 __in efx_nic_t *enp);
267 #endif /* EFSYS_OPT_MCDI */
271 #define EFX_NINTR_SIENA 1024
273 typedef enum efx_intr_type_e {
274 EFX_INTR_INVALID = 0,
280 #define EFX_INTR_SIZE (sizeof (efx_oword_t))
282 extern __checkReturn efx_rc_t
285 __in efx_intr_type_t type,
286 __in efsys_mem_t *esmp);
290 __in efx_nic_t *enp);
294 __in efx_nic_t *enp);
297 efx_intr_disable_unlocked(
298 __in efx_nic_t *enp);
300 #define EFX_INTR_NEVQS 32
302 extern __checkReturn efx_rc_t
305 __in unsigned int level);
308 efx_intr_status_line(
310 __out boolean_t *fatalp,
311 __out uint32_t *maskp);
314 efx_intr_status_message(
316 __in unsigned int message,
317 __out boolean_t *fatalp);
321 __in efx_nic_t *enp);
325 __in efx_nic_t *enp);
329 typedef enum efx_link_mode_e {
330 EFX_LINK_UNKNOWN = 0,
343 #define EFX_MAC_ADDR_LEN 6
345 #define EFX_MAC_ADDR_IS_MULTICAST(_address) (((uint8_t *)_address)[0] & 0x01)
347 #define EFX_MAC_MULTICAST_LIST_MAX 256
349 #define EFX_MAC_SDU_MAX 9202
351 #define EFX_MAC_PDU_ADJUSTMENT \
355 + /* bug16011 */ 16) \
357 #define EFX_MAC_PDU(_sdu) \
358 P2ROUNDUP((_sdu) + EFX_MAC_PDU_ADJUSTMENT, 8)
361 * Due to the P2ROUNDUP in EFX_MAC_PDU(), EFX_MAC_SDU_FROM_PDU() may give
362 * the SDU rounded up slightly.
364 #define EFX_MAC_SDU_FROM_PDU(_pdu) ((_pdu) - EFX_MAC_PDU_ADJUSTMENT)
366 #define EFX_MAC_PDU_MIN 60
367 #define EFX_MAC_PDU_MAX EFX_MAC_PDU(EFX_MAC_SDU_MAX)
369 extern __checkReturn efx_rc_t
374 extern __checkReturn efx_rc_t
379 extern __checkReturn efx_rc_t
384 extern __checkReturn efx_rc_t
387 __in boolean_t all_unicst,
388 __in boolean_t mulcst,
389 __in boolean_t all_mulcst,
390 __in boolean_t brdcst);
392 extern __checkReturn efx_rc_t
393 efx_mac_multicast_list_set(
395 __in_ecount(6*count) uint8_t const *addrs,
398 extern __checkReturn efx_rc_t
399 efx_mac_filter_default_rxq_set(
402 __in boolean_t using_rss);
405 efx_mac_filter_default_rxq_clear(
406 __in efx_nic_t *enp);
408 extern __checkReturn efx_rc_t
411 __in boolean_t enabled);
413 extern __checkReturn efx_rc_t
416 __out boolean_t *mac_upp);
418 #define EFX_FCNTL_RESPOND 0x00000001
419 #define EFX_FCNTL_GENERATE 0x00000002
421 extern __checkReturn efx_rc_t
424 __in unsigned int fcntl,
425 __in boolean_t autoneg);
430 __out unsigned int *fcntl_wantedp,
431 __out unsigned int *fcntl_linkp);
436 typedef enum efx_mon_type_e {
448 __in efx_nic_t *enp);
450 #endif /* EFSYS_OPT_NAMES */
452 extern __checkReturn efx_rc_t
454 __in efx_nic_t *enp);
458 __in efx_nic_t *enp);
462 extern __checkReturn efx_rc_t
464 __in efx_nic_t *enp);
466 extern __checkReturn efx_rc_t
468 __in efx_nic_t *enp);
470 extern __checkReturn efx_rc_t
473 __out_opt efx_link_mode_t *link_modep);
477 __in efx_nic_t *enp);
479 typedef enum efx_phy_cap_type_e {
480 EFX_PHY_CAP_INVALID = 0,
487 EFX_PHY_CAP_10000FDX,
491 EFX_PHY_CAP_40000FDX,
493 } efx_phy_cap_type_t;
496 #define EFX_PHY_CAP_CURRENT 0x00000000
497 #define EFX_PHY_CAP_DEFAULT 0x00000001
498 #define EFX_PHY_CAP_PERM 0x00000002
504 __out uint32_t *maskp);
506 extern __checkReturn efx_rc_t
514 __out uint32_t *maskp);
516 extern __checkReturn efx_rc_t
519 __out uint32_t *ouip);
521 typedef enum efx_phy_media_type_e {
522 EFX_PHY_MEDIA_INVALID = 0,
527 EFX_PHY_MEDIA_SFP_PLUS,
528 EFX_PHY_MEDIA_BASE_T,
529 EFX_PHY_MEDIA_QSFP_PLUS,
531 } efx_phy_media_type_t;
533 /* Get the type of medium currently used. If the board has ports for
534 * modules, a module is present, and we recognise the media type of
535 * the module, then this will be the media type of the module.
536 * Otherwise it will be the media type of the port.
539 efx_phy_media_type_get(
541 __out efx_phy_media_type_t *typep);
544 efx_phy_module_get_info(
546 __in uint8_t dev_addr,
549 __out_bcount(len) uint8_t *data);
554 typedef enum efx_bist_type_e {
555 EFX_BIST_TYPE_UNKNOWN,
556 EFX_BIST_TYPE_PHY_NORMAL,
557 EFX_BIST_TYPE_PHY_CABLE_SHORT,
558 EFX_BIST_TYPE_PHY_CABLE_LONG,
559 EFX_BIST_TYPE_MC_MEM, /* Test the MC DMEM and IMEM */
560 EFX_BIST_TYPE_SAT_MEM, /* Test the DMEM and IMEM of satellite cpus*/
561 EFX_BIST_TYPE_REG, /* Test the register memories */
562 EFX_BIST_TYPE_NTYPES,
565 typedef enum efx_bist_result_e {
566 EFX_BIST_RESULT_UNKNOWN,
567 EFX_BIST_RESULT_RUNNING,
568 EFX_BIST_RESULT_PASSED,
569 EFX_BIST_RESULT_FAILED,
572 typedef enum efx_phy_cable_status_e {
573 EFX_PHY_CABLE_STATUS_OK,
574 EFX_PHY_CABLE_STATUS_INVALID,
575 EFX_PHY_CABLE_STATUS_OPEN,
576 EFX_PHY_CABLE_STATUS_INTRAPAIRSHORT,
577 EFX_PHY_CABLE_STATUS_INTERPAIRSHORT,
578 EFX_PHY_CABLE_STATUS_BUSY,
579 } efx_phy_cable_status_t;
581 typedef enum efx_bist_value_e {
582 EFX_BIST_PHY_CABLE_LENGTH_A,
583 EFX_BIST_PHY_CABLE_LENGTH_B,
584 EFX_BIST_PHY_CABLE_LENGTH_C,
585 EFX_BIST_PHY_CABLE_LENGTH_D,
586 EFX_BIST_PHY_CABLE_STATUS_A,
587 EFX_BIST_PHY_CABLE_STATUS_B,
588 EFX_BIST_PHY_CABLE_STATUS_C,
589 EFX_BIST_PHY_CABLE_STATUS_D,
591 /* Memory BIST specific values. These match to the MC_CMD_BIST_POLL
599 EFX_BIST_MEM_ECC_PARITY,
600 EFX_BIST_MEM_ECC_FATAL,
604 extern __checkReturn efx_rc_t
605 efx_bist_enable_offline(
606 __in efx_nic_t *enp);
608 extern __checkReturn efx_rc_t
611 __in efx_bist_type_t type);
613 extern __checkReturn efx_rc_t
616 __in efx_bist_type_t type,
617 __out efx_bist_result_t *resultp,
618 __out_opt uint32_t *value_maskp,
619 __out_ecount_opt(count) unsigned long *valuesp,
625 __in efx_bist_type_t type);
627 #endif /* EFSYS_OPT_BIST */
629 #define EFX_FEATURE_IPV6 0x00000001
630 #define EFX_FEATURE_LFSR_HASH_INSERT 0x00000002
631 #define EFX_FEATURE_LINK_EVENTS 0x00000004
632 #define EFX_FEATURE_PERIODIC_MAC_STATS 0x00000008
633 #define EFX_FEATURE_MCDI 0x00000020
634 #define EFX_FEATURE_LOOKAHEAD_SPLIT 0x00000040
635 #define EFX_FEATURE_MAC_HEADER_FILTERS 0x00000080
636 #define EFX_FEATURE_TURBO 0x00000100
637 #define EFX_FEATURE_MCDI_DMA 0x00000200
638 #define EFX_FEATURE_TX_SRC_FILTERS 0x00000400
639 #define EFX_FEATURE_PIO_BUFFERS 0x00000800
640 #define EFX_FEATURE_FW_ASSISTED_TSO 0x00001000
641 #define EFX_FEATURE_FW_ASSISTED_TSO_V2 0x00002000
642 #define EFX_FEATURE_PACKED_STREAM 0x00004000
644 typedef struct efx_nic_cfg_s {
645 uint32_t enc_board_type;
646 uint32_t enc_phy_type;
648 char enc_phy_name[21];
650 char enc_phy_revision[21];
651 efx_mon_type_t enc_mon_type;
652 unsigned int enc_features;
653 uint8_t enc_mac_addr[6];
654 uint8_t enc_port; /* PHY port number */
655 uint32_t enc_intr_vec_base;
656 uint32_t enc_intr_limit;
657 uint32_t enc_evq_limit;
658 uint32_t enc_txq_limit;
659 uint32_t enc_rxq_limit;
660 uint32_t enc_txq_max_ndescs;
661 uint32_t enc_buftbl_limit;
662 uint32_t enc_piobuf_limit;
663 uint32_t enc_piobuf_size;
664 uint32_t enc_piobuf_min_alloc_size;
665 uint32_t enc_evq_timer_quantum_ns;
666 uint32_t enc_evq_timer_max_us;
667 uint32_t enc_clk_mult;
668 uint32_t enc_rx_prefix_size;
669 uint32_t enc_rx_buf_align_start;
670 uint32_t enc_rx_buf_align_end;
672 uint8_t enc_mcdi_mdio_channel;
673 #endif /* EFSYS_OPT_MCDI */
675 uint32_t enc_bist_mask;
676 #endif /* EFSYS_OPT_BIST */
677 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
680 uint32_t enc_privilege_mask;
681 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
682 boolean_t enc_bug26807_workaround;
683 boolean_t enc_bug35388_workaround;
684 boolean_t enc_bug41750_workaround;
685 boolean_t enc_bug61265_workaround;
686 boolean_t enc_rx_batching_enabled;
687 /* Maximum number of descriptors completed in an rx event. */
688 uint32_t enc_rx_batch_max;
689 /* Number of rx descriptors the hardware requires for a push. */
690 uint32_t enc_rx_push_align;
692 * Maximum number of bytes into the packet the TCP header can start for
693 * the hardware to apply TSO packet edits.
695 uint32_t enc_tx_tso_tcp_header_offset_limit;
696 boolean_t enc_fw_assisted_tso_enabled;
697 boolean_t enc_fw_assisted_tso_v2_enabled;
698 /* Number of TSO contexts on the NIC (FATSOv2) */
699 uint32_t enc_fw_assisted_tso_v2_n_contexts;
700 boolean_t enc_hw_tx_insert_vlan_enabled;
701 /* Number of PFs on the NIC */
702 uint32_t enc_hw_pf_count;
703 /* Datapath firmware vadapter/vport/vswitch support */
704 boolean_t enc_datapath_cap_evb;
705 boolean_t enc_rx_disable_scatter_supported;
706 boolean_t enc_allow_set_mac_with_installed_filters;
707 boolean_t enc_enhanced_set_mac_supported;
708 boolean_t enc_init_evq_v2_supported;
709 boolean_t enc_rx_packed_stream_supported;
710 boolean_t enc_rx_var_packed_stream_supported;
711 boolean_t enc_pm_and_rxdp_counters;
712 boolean_t enc_mac_stats_40g_tx_size_bins;
713 /* External port identifier */
714 uint8_t enc_external_port;
715 uint32_t enc_mcdi_max_payload_length;
716 /* VPD may be per-PF or global */
717 boolean_t enc_vpd_is_global;
718 /* Minimum unidirectional bandwidth in Mb/s to max out all ports */
719 uint32_t enc_required_pcie_bandwidth_mbps;
720 uint32_t enc_max_pcie_link_gen;
721 /* Firmware verifies integrity of NVRAM updates */
722 uint32_t enc_fw_verified_nvram_update_required;
725 #define EFX_PCI_FUNCTION_IS_PF(_encp) ((_encp)->enc_vf == 0xffff)
726 #define EFX_PCI_FUNCTION_IS_VF(_encp) ((_encp)->enc_vf != 0xffff)
728 #define EFX_PCI_FUNCTION(_encp) \
729 (EFX_PCI_FUNCTION_IS_PF(_encp) ? (_encp)->enc_pf : (_encp)->enc_vf)
731 #define EFX_PCI_VF_PARENT(_encp) ((_encp)->enc_pf)
733 extern const efx_nic_cfg_t *
735 __in efx_nic_t *enp);
737 /* Driver resource limits (minimum required/maximum usable). */
738 typedef struct efx_drv_limits_s {
739 uint32_t edl_min_evq_count;
740 uint32_t edl_max_evq_count;
742 uint32_t edl_min_rxq_count;
743 uint32_t edl_max_rxq_count;
745 uint32_t edl_min_txq_count;
746 uint32_t edl_max_txq_count;
748 /* PIO blocks (sub-allocated from piobuf) */
749 uint32_t edl_min_pio_alloc_size;
750 uint32_t edl_max_pio_alloc_count;
753 extern __checkReturn efx_rc_t
754 efx_nic_set_drv_limits(
755 __inout efx_nic_t *enp,
756 __in efx_drv_limits_t *edlp);
758 typedef enum efx_nic_region_e {
759 EFX_REGION_VI, /* Memory BAR UC mapping */
760 EFX_REGION_PIO_WRITE_VI, /* Memory BAR WC mapping */
763 extern __checkReturn efx_rc_t
764 efx_nic_get_bar_region(
766 __in efx_nic_region_t region,
767 __out uint32_t *offsetp,
768 __out size_t *sizep);
770 extern __checkReturn efx_rc_t
773 __out uint32_t *evq_countp,
774 __out uint32_t *rxq_countp,
775 __out uint32_t *txq_countp);
782 typedef enum efx_pattern_type_t {
783 EFX_PATTERN_BYTE_INCREMENT = 0,
784 EFX_PATTERN_ALL_THE_SAME,
785 EFX_PATTERN_BIT_ALTERNATE,
786 EFX_PATTERN_BYTE_ALTERNATE,
787 EFX_PATTERN_BYTE_CHANGING,
788 EFX_PATTERN_BIT_SWEEP,
790 } efx_pattern_type_t;
793 (*efx_sram_pattern_fn_t)(
795 __in boolean_t negate,
796 __out efx_qword_t *eqp);
798 extern __checkReturn efx_rc_t
801 __in efx_pattern_type_t type);
803 #endif /* EFSYS_OPT_DIAG */
805 extern __checkReturn efx_rc_t
806 efx_sram_buf_tbl_set(
809 __in efsys_mem_t *esmp,
813 efx_sram_buf_tbl_clear(
818 #define EFX_BUF_TBL_SIZE 0x20000
820 #define EFX_BUF_SIZE 4096
824 typedef struct efx_evq_s efx_evq_t;
826 extern __checkReturn efx_rc_t
828 __in efx_nic_t *enp);
832 __in efx_nic_t *enp);
834 #define EFX_EVQ_MAXNEVS 32768
835 #define EFX_EVQ_MINNEVS 512
837 #define EFX_EVQ_SIZE(_nevs) ((_nevs) * sizeof (efx_qword_t))
838 #define EFX_EVQ_NBUFS(_nevs) (EFX_EVQ_SIZE(_nevs) / EFX_BUF_SIZE)
840 #define EFX_EVQ_FLAGS_TYPE_MASK (0x3)
841 #define EFX_EVQ_FLAGS_TYPE_AUTO (0x0)
842 #define EFX_EVQ_FLAGS_TYPE_THROUGHPUT (0x1)
843 #define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY (0x2)
845 #define EFX_EVQ_FLAGS_NOTIFY_MASK (0xC)
846 #define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT (0x0) /* Interrupting (default) */
847 #define EFX_EVQ_FLAGS_NOTIFY_DISABLED (0x4) /* Non-interrupting */
849 extern __checkReturn efx_rc_t
852 __in unsigned int index,
853 __in efsys_mem_t *esmp,
858 __deref_out efx_evq_t **eepp);
865 typedef __checkReturn boolean_t
866 (*efx_initialized_ev_t)(
869 #define EFX_PKT_UNICAST 0x0004
870 #define EFX_PKT_START 0x0008
872 #define EFX_PKT_VLAN_TAGGED 0x0010
873 #define EFX_CKSUM_TCPUDP 0x0020
874 #define EFX_CKSUM_IPV4 0x0040
875 #define EFX_PKT_CONT 0x0080
877 #define EFX_CHECK_VLAN 0x0100
878 #define EFX_PKT_TCP 0x0200
879 #define EFX_PKT_UDP 0x0400
880 #define EFX_PKT_IPV4 0x0800
882 #define EFX_PKT_IPV6 0x1000
883 #define EFX_PKT_PREFIX_LEN 0x2000
884 #define EFX_ADDR_MISMATCH 0x4000
885 #define EFX_DISCARD 0x8000
888 * The following flags are used only for packed stream
889 * mode. The values for the flags are reused to fit into 16 bit,
890 * since EFX_PKT_START and EFX_PKT_CONT are never used in
893 #define EFX_PKT_PACKED_STREAM_NEW_BUFFER EFX_PKT_START
894 #define EFX_PKT_PACKED_STREAM_PARSE_INCOMPLETE EFX_PKT_CONT
897 #define EFX_EV_RX_NLABELS 32
898 #define EFX_EV_TX_NLABELS 32
900 typedef __checkReturn boolean_t
906 __in uint16_t flags);
908 typedef __checkReturn boolean_t
914 #define EFX_EXCEPTION_RX_RECOVERY 0x00000001
915 #define EFX_EXCEPTION_RX_DSC_ERROR 0x00000002
916 #define EFX_EXCEPTION_TX_DSC_ERROR 0x00000003
917 #define EFX_EXCEPTION_UNKNOWN_SENSOREVT 0x00000004
918 #define EFX_EXCEPTION_FWALERT_SRAM 0x00000005
919 #define EFX_EXCEPTION_UNKNOWN_FWALERT 0x00000006
920 #define EFX_EXCEPTION_RX_ERROR 0x00000007
921 #define EFX_EXCEPTION_TX_ERROR 0x00000008
922 #define EFX_EXCEPTION_EV_ERROR 0x00000009
924 typedef __checkReturn boolean_t
925 (*efx_exception_ev_t)(
930 typedef __checkReturn boolean_t
931 (*efx_rxq_flush_done_ev_t)(
933 __in uint32_t rxq_index);
935 typedef __checkReturn boolean_t
936 (*efx_rxq_flush_failed_ev_t)(
938 __in uint32_t rxq_index);
940 typedef __checkReturn boolean_t
941 (*efx_txq_flush_done_ev_t)(
943 __in uint32_t txq_index);
945 typedef __checkReturn boolean_t
946 (*efx_software_ev_t)(
948 __in uint16_t magic);
950 typedef __checkReturn boolean_t
955 #define EFX_SRAM_CLEAR 0
956 #define EFX_SRAM_UPDATE 1
957 #define EFX_SRAM_ILLEGAL_CLEAR 2
959 typedef __checkReturn boolean_t
962 __in uint32_t label);
964 typedef __checkReturn boolean_t
967 __in uint32_t label);
969 typedef __checkReturn boolean_t
970 (*efx_link_change_ev_t)(
972 __in efx_link_mode_t link_mode);
974 typedef struct efx_ev_callbacks_s {
975 efx_initialized_ev_t eec_initialized;
978 efx_exception_ev_t eec_exception;
979 efx_rxq_flush_done_ev_t eec_rxq_flush_done;
980 efx_rxq_flush_failed_ev_t eec_rxq_flush_failed;
981 efx_txq_flush_done_ev_t eec_txq_flush_done;
982 efx_software_ev_t eec_software;
983 efx_sram_ev_t eec_sram;
984 efx_wake_up_ev_t eec_wake_up;
985 efx_timer_ev_t eec_timer;
986 efx_link_change_ev_t eec_link_change;
987 } efx_ev_callbacks_t;
989 extern __checkReturn boolean_t
992 __in unsigned int count);
997 __inout unsigned int *countp,
998 __in const efx_ev_callbacks_t *eecp,
1001 extern __checkReturn efx_rc_t
1002 efx_ev_usecs_to_ticks(
1003 __in efx_nic_t *enp,
1004 __in unsigned int usecs,
1005 __out unsigned int *ticksp);
1007 extern __checkReturn efx_rc_t
1009 __in efx_evq_t *eep,
1010 __in unsigned int us);
1012 extern __checkReturn efx_rc_t
1014 __in efx_evq_t *eep,
1015 __in unsigned int count);
1019 __in efx_evq_t *eep);
1023 extern __checkReturn efx_rc_t
1025 __inout efx_nic_t *enp);
1029 __in efx_nic_t *enp);
1031 extern __checkReturn efx_rc_t
1032 efx_pseudo_hdr_pkt_length_get(
1033 __in efx_rxq_t *erp,
1034 __in uint8_t *buffer,
1035 __out uint16_t *pkt_lengthp);
1037 #define EFX_RXQ_MAXNDESCS 4096
1038 #define EFX_RXQ_MINNDESCS 512
1040 #define EFX_RXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t))
1041 #define EFX_RXQ_NBUFS(_ndescs) (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
1042 #define EFX_RXQ_LIMIT(_ndescs) ((_ndescs) - 16)
1043 #define EFX_RXQ_DC_NDESCS(_dcsize) (8 << _dcsize)
1045 typedef enum efx_rxq_type_e {
1046 EFX_RXQ_TYPE_DEFAULT,
1047 EFX_RXQ_TYPE_SCATTER,
1048 EFX_RXQ_TYPE_PACKED_STREAM_1M,
1049 EFX_RXQ_TYPE_PACKED_STREAM_512K,
1050 EFX_RXQ_TYPE_PACKED_STREAM_256K,
1051 EFX_RXQ_TYPE_PACKED_STREAM_128K,
1052 EFX_RXQ_TYPE_PACKED_STREAM_64K,
1056 extern __checkReturn efx_rc_t
1058 __in efx_nic_t *enp,
1059 __in unsigned int index,
1060 __in unsigned int label,
1061 __in efx_rxq_type_t type,
1062 __in efsys_mem_t *esmp,
1065 __in efx_evq_t *eep,
1066 __deref_out efx_rxq_t **erpp);
1068 typedef struct efx_buffer_s {
1069 efsys_dma_addr_t eb_addr;
1074 typedef struct efx_desc_s {
1080 __in efx_rxq_t *erp,
1081 __in_ecount(n) efsys_dma_addr_t *addrp,
1083 __in unsigned int n,
1084 __in unsigned int completed,
1085 __in unsigned int added);
1089 __in efx_rxq_t *erp,
1090 __in unsigned int added,
1091 __inout unsigned int *pushedp);
1093 extern __checkReturn efx_rc_t
1095 __in efx_rxq_t *erp);
1099 __in efx_rxq_t *erp);
1103 __in efx_rxq_t *erp);
1107 typedef struct efx_txq_s efx_txq_t;
1109 extern __checkReturn efx_rc_t
1111 __in efx_nic_t *enp);
1115 __in efx_nic_t *enp);
1117 #define EFX_TXQ_MINNDESCS 512
1119 #define EFX_TXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t))
1120 #define EFX_TXQ_NBUFS(_ndescs) (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
1121 #define EFX_TXQ_LIMIT(_ndescs) ((_ndescs) - 16)
1122 #define EFX_TXQ_DC_NDESCS(_dcsize) (8 << _dcsize)
1124 #define EFX_TXQ_MAX_BUFS 8 /* Maximum independent of EFX_BUG35388_WORKAROUND. */
1126 #define EFX_TXQ_CKSUM_IPV4 0x0001
1127 #define EFX_TXQ_CKSUM_TCPUDP 0x0002
1128 #define EFX_TXQ_FATSOV2 0x0004
1130 extern __checkReturn efx_rc_t
1132 __in efx_nic_t *enp,
1133 __in unsigned int index,
1134 __in unsigned int label,
1135 __in efsys_mem_t *esmp,
1138 __in uint16_t flags,
1139 __in efx_evq_t *eep,
1140 __deref_out efx_txq_t **etpp,
1141 __out unsigned int *addedp);
1143 extern __checkReturn efx_rc_t
1145 __in efx_txq_t *etp,
1146 __in_ecount(n) efx_buffer_t *eb,
1147 __in unsigned int n,
1148 __in unsigned int completed,
1149 __inout unsigned int *addedp);
1151 extern __checkReturn efx_rc_t
1153 __in efx_txq_t *etp,
1154 __in unsigned int ns);
1158 __in efx_txq_t *etp,
1159 __in unsigned int added,
1160 __in unsigned int pushed);
1162 extern __checkReturn efx_rc_t
1164 __in efx_txq_t *etp);
1168 __in efx_txq_t *etp);
1170 extern __checkReturn efx_rc_t
1172 __in efx_txq_t *etp);
1175 efx_tx_qpio_disable(
1176 __in efx_txq_t *etp);
1178 extern __checkReturn efx_rc_t
1180 __in efx_txq_t *etp,
1181 __in_ecount(buf_length) uint8_t *buffer,
1182 __in size_t buf_length,
1183 __in size_t pio_buf_offset);
1185 extern __checkReturn efx_rc_t
1187 __in efx_txq_t *etp,
1188 __in size_t pkt_length,
1189 __in unsigned int completed,
1190 __inout unsigned int *addedp);
1192 extern __checkReturn efx_rc_t
1194 __in efx_txq_t *etp,
1195 __in_ecount(n) efx_desc_t *ed,
1196 __in unsigned int n,
1197 __in unsigned int completed,
1198 __inout unsigned int *addedp);
1201 efx_tx_qdesc_dma_create(
1202 __in efx_txq_t *etp,
1203 __in efsys_dma_addr_t addr,
1206 __out efx_desc_t *edp);
1209 efx_tx_qdesc_tso_create(
1210 __in efx_txq_t *etp,
1211 __in uint16_t ipv4_id,
1212 __in uint32_t tcp_seq,
1213 __in uint8_t tcp_flags,
1214 __out efx_desc_t *edp);
1216 /* Number of FATSOv2 option descriptors */
1217 #define EFX_TX_FATSOV2_OPT_NDESCS 2
1219 /* Maximum number of DMA segments per TSO packet (not superframe) */
1220 #define EFX_TX_FATSOV2_DMA_SEGS_PER_PKT_MAX 24
1223 efx_tx_qdesc_tso2_create(
1224 __in efx_txq_t *etp,
1225 __in uint16_t ipv4_id,
1226 __in uint32_t tcp_seq,
1227 __in uint16_t tcp_mss,
1228 __out_ecount(count) efx_desc_t *edp,
1232 efx_tx_qdesc_vlantci_create(
1233 __in efx_txq_t *etp,
1235 __out efx_desc_t *edp);
1239 __in efx_txq_t *etp);
1244 #if EFSYS_OPT_FILTER
1246 #define EFX_ETHER_TYPE_IPV4 0x0800
1247 #define EFX_ETHER_TYPE_IPV6 0x86DD
1249 #define EFX_IPPROTO_TCP 6
1250 #define EFX_IPPROTO_UDP 17
1252 /* Use RSS to spread across multiple queues */
1253 #define EFX_FILTER_FLAG_RX_RSS 0x01
1254 /* Enable RX scatter */
1255 #define EFX_FILTER_FLAG_RX_SCATTER 0x02
1257 * Override an automatic filter (priority EFX_FILTER_PRI_AUTO).
1258 * May only be set by the filter implementation for each type.
1259 * A removal request will restore the automatic filter in its place.
1261 #define EFX_FILTER_FLAG_RX_OVER_AUTO 0x04
1262 /* Filter is for RX */
1263 #define EFX_FILTER_FLAG_RX 0x08
1264 /* Filter is for TX */
1265 #define EFX_FILTER_FLAG_TX 0x10
1267 typedef unsigned int efx_filter_flags_t;
1269 typedef enum efx_filter_match_flags_e {
1270 EFX_FILTER_MATCH_REM_HOST = 0x0001, /* Match by remote IP host
1272 EFX_FILTER_MATCH_LOC_HOST = 0x0002, /* Match by local IP host
1274 EFX_FILTER_MATCH_REM_MAC = 0x0004, /* Match by remote MAC address */
1275 EFX_FILTER_MATCH_REM_PORT = 0x0008, /* Match by remote TCP/UDP port */
1276 EFX_FILTER_MATCH_LOC_MAC = 0x0010, /* Match by remote TCP/UDP port */
1277 EFX_FILTER_MATCH_LOC_PORT = 0x0020, /* Match by local TCP/UDP port */
1278 EFX_FILTER_MATCH_ETHER_TYPE = 0x0040, /* Match by Ether-type */
1279 EFX_FILTER_MATCH_INNER_VID = 0x0080, /* Match by inner VLAN ID */
1280 EFX_FILTER_MATCH_OUTER_VID = 0x0100, /* Match by outer VLAN ID */
1281 EFX_FILTER_MATCH_IP_PROTO = 0x0200, /* Match by IP transport
1283 EFX_FILTER_MATCH_LOC_MAC_IG = 0x0400, /* Match by local MAC address
1284 * I/G bit. Used for RX default
1285 * unicast and multicast/
1286 * broadcast filters. */
1287 } efx_filter_match_flags_t;
1289 typedef enum efx_filter_priority_s {
1290 EFX_FILTER_PRI_HINT = 0, /* Performance hint */
1291 EFX_FILTER_PRI_AUTO, /* Automatic filter based on device
1292 * address list or hardware
1293 * requirements. This may only be used
1294 * by the filter implementation for
1296 EFX_FILTER_PRI_MANUAL, /* Manually configured filter */
1297 EFX_FILTER_PRI_REQUIRED, /* Required for correct behaviour of the
1298 * client (e.g. SR-IOV, HyperV VMQ etc.)
1300 } efx_filter_priority_t;
1303 * FIXME: All these fields are assumed to be in little-endian byte order.
1304 * It may be better for some to be big-endian. See bug42804.
1307 typedef struct efx_filter_spec_s {
1308 uint32_t efs_match_flags:12;
1309 uint32_t efs_priority:2;
1310 uint32_t efs_flags:6;
1311 uint32_t efs_dmaq_id:12;
1312 uint32_t efs_rss_context;
1313 uint16_t efs_outer_vid;
1314 uint16_t efs_inner_vid;
1315 uint8_t efs_loc_mac[EFX_MAC_ADDR_LEN];
1316 uint8_t efs_rem_mac[EFX_MAC_ADDR_LEN];
1317 uint16_t efs_ether_type;
1318 uint8_t efs_ip_proto;
1319 uint16_t efs_loc_port;
1320 uint16_t efs_rem_port;
1321 efx_oword_t efs_rem_host;
1322 efx_oword_t efs_loc_host;
1323 } efx_filter_spec_t;
1326 /* Default values for use in filter specifications */
1327 #define EFX_FILTER_SPEC_RSS_CONTEXT_DEFAULT 0xffffffff
1328 #define EFX_FILTER_SPEC_RX_DMAQ_ID_DROP 0xfff
1329 #define EFX_FILTER_SPEC_VID_UNSPEC 0xffff
1331 extern __checkReturn efx_rc_t
1333 __in efx_nic_t *enp);
1337 __in efx_nic_t *enp);
1339 extern __checkReturn efx_rc_t
1341 __in efx_nic_t *enp,
1342 __inout efx_filter_spec_t *spec);
1344 extern __checkReturn efx_rc_t
1346 __in efx_nic_t *enp,
1347 __inout efx_filter_spec_t *spec);
1349 extern __checkReturn efx_rc_t
1351 __in efx_nic_t *enp);
1353 extern __checkReturn efx_rc_t
1354 efx_filter_supported_filters(
1355 __in efx_nic_t *enp,
1356 __out uint32_t *list,
1357 __out size_t *length);
1360 efx_filter_spec_init_rx(
1361 __out efx_filter_spec_t *spec,
1362 __in efx_filter_priority_t priority,
1363 __in efx_filter_flags_t flags,
1364 __in efx_rxq_t *erp);
1367 efx_filter_spec_init_tx(
1368 __out efx_filter_spec_t *spec,
1369 __in efx_txq_t *etp);
1371 extern __checkReturn efx_rc_t
1372 efx_filter_spec_set_ipv4_local(
1373 __inout efx_filter_spec_t *spec,
1376 __in uint16_t port);
1378 extern __checkReturn efx_rc_t
1379 efx_filter_spec_set_ipv4_full(
1380 __inout efx_filter_spec_t *spec,
1382 __in uint32_t lhost,
1383 __in uint16_t lport,
1384 __in uint32_t rhost,
1385 __in uint16_t rport);
1387 extern __checkReturn efx_rc_t
1388 efx_filter_spec_set_eth_local(
1389 __inout efx_filter_spec_t *spec,
1391 __in const uint8_t *addr);
1393 extern __checkReturn efx_rc_t
1394 efx_filter_spec_set_uc_def(
1395 __inout efx_filter_spec_t *spec);
1397 extern __checkReturn efx_rc_t
1398 efx_filter_spec_set_mc_def(
1399 __inout efx_filter_spec_t *spec);
1401 #endif /* EFSYS_OPT_FILTER */
1405 extern __checkReturn uint32_t
1407 __in_ecount(count) uint32_t const *input,
1409 __in uint32_t init);
1411 extern __checkReturn uint32_t
1413 __in_ecount(length) uint8_t const *input,
1415 __in uint32_t init);
1423 #endif /* _SYS_EFX_H */