14c7070dbSScott Long /*- 296fc97c8SStephen Hurd * Copyright (c) 2014-2017, Matthew Macy (mmacy@mattmacy.io) 34c7070dbSScott Long * All rights reserved. 44c7070dbSScott Long * 54c7070dbSScott Long * Redistribution and use in source and binary forms, with or without 64c7070dbSScott Long * modification, are permitted provided that the following conditions are met: 74c7070dbSScott Long * 84c7070dbSScott Long * 1. Redistributions of source code must retain the above copyright notice, 94c7070dbSScott Long * this list of conditions and the following disclaimer. 104c7070dbSScott Long * 114c7070dbSScott Long * 2. Neither the name of Matthew Macy nor the names of its 124c7070dbSScott Long * contributors may be used to endorse or promote products derived from 134c7070dbSScott Long * this software without specific prior written permission. 144c7070dbSScott Long * 154c7070dbSScott Long * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 164c7070dbSScott Long * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 174c7070dbSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 184c7070dbSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 194c7070dbSScott Long * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 204c7070dbSScott Long * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 214c7070dbSScott Long * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 224c7070dbSScott Long * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 234c7070dbSScott Long * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 244c7070dbSScott Long * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 254c7070dbSScott Long * POSSIBILITY OF SUCH DAMAGE. 264c7070dbSScott Long * 274c7070dbSScott Long * $FreeBSD$ 284c7070dbSScott Long */ 294c7070dbSScott Long #ifndef __IFLIB_H_ 304c7070dbSScott Long #define __IFLIB_H_ 314c7070dbSScott Long 324c7070dbSScott Long #include <sys/kobj.h> 334c7070dbSScott Long #include <sys/bus.h> 344c7070dbSScott Long #include <sys/cpuset.h> 354c7070dbSScott Long #include <machine/bus.h> 364c7070dbSScott Long #include <sys/nv.h> 3723ac9029SStephen Hurd #include <sys/gtaskqueue.h> 384c7070dbSScott Long 3909f6ff4fSMatt Macy struct if_clone; 4009f6ff4fSMatt Macy 4195246abbSSean Bruno /* 4295246abbSSean Bruno * The value type for indexing, limits max descriptors 4395246abbSSean Bruno * to 65535 can be conditionally redefined to uint32_t 4495246abbSSean Bruno * in the future if the need arises. 4595246abbSSean Bruno */ 4695246abbSSean Bruno typedef uint16_t qidx_t; 4795246abbSSean Bruno #define QIDX_INVALID 0xFFFF 484c7070dbSScott Long 494c7070dbSScott Long struct iflib_ctx; 504c7070dbSScott Long typedef struct iflib_ctx *if_ctx_t; 514c7070dbSScott Long struct if_shared_ctx; 52ffe3def9SMark Johnston typedef const struct if_shared_ctx *if_shared_ctx_t; 534c7070dbSScott Long struct if_int_delay_info; 544c7070dbSScott Long typedef struct if_int_delay_info *if_int_delay_info_t; 5509f6ff4fSMatt Macy struct if_pseudo; 5609f6ff4fSMatt Macy typedef struct if_pseudo *if_pseudo_t; 574c7070dbSScott Long 584c7070dbSScott Long /* 594c7070dbSScott Long * File organization: 604c7070dbSScott Long * - public structures 614c7070dbSScott Long * - iflib accessors 624c7070dbSScott Long * - iflib utility functions 634c7070dbSScott Long * - iflib core functions 644c7070dbSScott Long */ 654c7070dbSScott Long 664c7070dbSScott Long typedef struct if_rxd_frag { 674c7070dbSScott Long uint8_t irf_flid; 6895246abbSSean Bruno qidx_t irf_idx; 6923ac9029SStephen Hurd uint16_t irf_len; 704c7070dbSScott Long } *if_rxd_frag_t; 714c7070dbSScott Long 728f82136aSPatrick Kelsey /* bnxt supports 64 with hardware LRO enabled */ 738f82136aSPatrick Kelsey #define IFLIB_MAX_RX_SEGS 64 748f82136aSPatrick Kelsey 754c7070dbSScott Long typedef struct if_rxd_info { 764c7070dbSScott Long /* set by iflib */ 774c7070dbSScott Long uint16_t iri_qsidx; /* qset index */ 784c7070dbSScott Long uint16_t iri_vtag; /* vlan tag - if flag set */ 7923ac9029SStephen Hurd /* XXX redundant with the new irf_len field */ 804c7070dbSScott Long uint16_t iri_len; /* packet length */ 8195246abbSSean Bruno qidx_t iri_cidx; /* consumer index of cq */ 821722eeacSMarius Strobl if_t iri_ifp; /* driver may have >1 iface per softc */ 834c7070dbSScott Long 844c7070dbSScott Long /* updated by driver */ 8595246abbSSean Bruno if_rxd_frag_t iri_frags; 864c7070dbSScott Long uint32_t iri_flowid; /* RSS hash for packet */ 874c7070dbSScott Long uint32_t iri_csum_flags; /* m_pkthdr csum flags */ 8895246abbSSean Bruno 894c7070dbSScott Long uint32_t iri_csum_data; /* m_pkthdr csum data */ 9095246abbSSean Bruno uint8_t iri_flags; /* mbuf flags for packet */ 914c7070dbSScott Long uint8_t iri_nfrags; /* number of fragments in packet */ 924c7070dbSScott Long uint8_t iri_rsstype; /* RSS hash type */ 934c7070dbSScott Long uint8_t iri_pad; /* any padding in the received data */ 944c7070dbSScott Long } *if_rxd_info_t; 954c7070dbSScott Long 9695246abbSSean Bruno typedef struct if_rxd_update { 9795246abbSSean Bruno uint64_t *iru_paddrs; 9895246abbSSean Bruno qidx_t *iru_idxs; 9995246abbSSean Bruno qidx_t iru_pidx; 10095246abbSSean Bruno uint16_t iru_qsidx; 10195246abbSSean Bruno uint16_t iru_count; 10295246abbSSean Bruno uint16_t iru_buf_size; 10395246abbSSean Bruno uint8_t iru_flidx; 10495246abbSSean Bruno } *if_rxd_update_t; 10595246abbSSean Bruno 1064c7070dbSScott Long #define IPI_TX_INTR 0x1 /* send an interrupt when this packet is sent */ 1074c7070dbSScott Long #define IPI_TX_IPV4 0x2 /* ethertype IPv4 */ 1084c7070dbSScott Long #define IPI_TX_IPV6 0x4 /* ethertype IPv6 */ 1094c7070dbSScott Long 1104c7070dbSScott Long typedef struct if_pkt_info { 1114c7070dbSScott Long bus_dma_segment_t *ipi_segs; /* physical addresses */ 11295246abbSSean Bruno uint32_t ipi_len; /* packet length */ 1134c7070dbSScott Long uint16_t ipi_qsidx; /* queue set index */ 11495246abbSSean Bruno qidx_t ipi_nsegs; /* number of segments */ 11595246abbSSean Bruno 11695246abbSSean Bruno qidx_t ipi_ndescs; /* number of descriptors used by encap */ 1174c7070dbSScott Long uint16_t ipi_flags; /* iflib per-packet flags */ 11895246abbSSean Bruno qidx_t ipi_pidx; /* start pidx for encap */ 11995246abbSSean Bruno qidx_t ipi_new_pidx; /* next available pidx post-encap */ 1204c7070dbSScott Long /* offload handling */ 1214c7070dbSScott Long uint8_t ipi_ehdrlen; /* ether header length */ 1224c7070dbSScott Long uint8_t ipi_ip_hlen; /* ip header length */ 1234c7070dbSScott Long uint8_t ipi_tcp_hlen; /* tcp header length */ 1244c7070dbSScott Long uint8_t ipi_ipproto; /* ip protocol */ 12595246abbSSean Bruno 12695246abbSSean Bruno uint32_t ipi_csum_flags; /* packet checksum flags */ 12795246abbSSean Bruno uint16_t ipi_tso_segsz; /* tso segment size */ 12895246abbSSean Bruno uint16_t ipi_vtag; /* VLAN tag */ 12995246abbSSean Bruno uint16_t ipi_etype; /* ether header type */ 13095246abbSSean Bruno uint8_t ipi_tcp_hflags; /* tcp header flags */ 13195246abbSSean Bruno uint8_t ipi_mflags; /* packet mbuf flags */ 13295246abbSSean Bruno 1334c7070dbSScott Long uint32_t ipi_tcp_seq; /* tcp seqno */ 134*9c950139SEric Joyner uint8_t ipi_ip_tos; /* IP ToS field data */ 135*9c950139SEric Joyner uint8_t __spare0__; 136*9c950139SEric Joyner uint16_t __spare1__; 1374c7070dbSScott Long } *if_pkt_info_t; 1384c7070dbSScott Long 1394c7070dbSScott Long typedef struct if_irq { 1404c7070dbSScott Long struct resource *ii_res; 141d49e83eaSMarius Strobl int __spare0__; 1424c7070dbSScott Long void *ii_tag; 1434c7070dbSScott Long } *if_irq_t; 1444c7070dbSScott Long 1454c7070dbSScott Long struct if_int_delay_info { 1464c7070dbSScott Long if_ctx_t iidi_ctx; /* Back-pointer to the iflib ctx (softc) */ 1474c7070dbSScott Long int iidi_offset; /* Register offset to read/write */ 1484c7070dbSScott Long int iidi_value; /* Current value in usecs */ 1494c7070dbSScott Long struct sysctl_oid *iidi_oidp; 1504c7070dbSScott Long struct sysctl_req *iidi_req; 1514c7070dbSScott Long }; 1524c7070dbSScott Long 1534c7070dbSScott Long typedef enum { 1544c7070dbSScott Long IFLIB_INTR_LEGACY, 1554c7070dbSScott Long IFLIB_INTR_MSI, 1564c7070dbSScott Long IFLIB_INTR_MSIX 1574c7070dbSScott Long } iflib_intr_mode_t; 1584c7070dbSScott Long 1594c7070dbSScott Long /* 1604c7070dbSScott Long * This really belongs in pciio.h or some place more general 1614c7070dbSScott Long * but this is the only consumer for now. 1624c7070dbSScott Long */ 1634c7070dbSScott Long typedef struct pci_vendor_info { 1644c7070dbSScott Long uint32_t pvi_vendor_id; 1654c7070dbSScott Long uint32_t pvi_device_id; 1664c7070dbSScott Long uint32_t pvi_subvendor_id; 1674c7070dbSScott Long uint32_t pvi_subdevice_id; 1684c7070dbSScott Long uint32_t pvi_rev_id; 1694c7070dbSScott Long uint32_t pvi_class_mask; 170d49e83eaSMarius Strobl const char *pvi_name; 1714c7070dbSScott Long } pci_vendor_info_t; 1724c7070dbSScott Long #define PVID(vendor, devid, name) {vendor, devid, 0, 0, 0, 0, name} 1734c7070dbSScott Long #define PVID_OEM(vendor, devid, svid, sdevid, revid, name) {vendor, devid, svid, sdevid, revid, 0, name} 1744c7070dbSScott Long #define PVID_END {0, 0, 0, 0, 0, 0, NULL} 1754c7070dbSScott Long 176704101ddSConrad Meyer /* No drivers in tree currently match on anything except vendor:device. */ 177704101ddSConrad Meyer #define IFLIB_PNP_DESCR "U32:vendor;U32:device;U32:#;U32:#;" \ 178704101ddSConrad Meyer "U32:#;U32:#;D:#" 179916616c4SConrad Meyer #define IFLIB_PNP_INFO(b, u, t) \ 180329e817fSWarner Losh MODULE_PNP_INFO(IFLIB_PNP_DESCR, b, u, t, nitems(t) - 1) 181916616c4SConrad Meyer 1824c7070dbSScott Long typedef struct if_txrx { 1834c7070dbSScott Long int (*ift_txd_encap) (void *, if_pkt_info_t); 18495246abbSSean Bruno void (*ift_txd_flush) (void *, uint16_t, qidx_t pidx); 18595246abbSSean Bruno int (*ift_txd_credits_update) (void *, uint16_t qsidx, bool clear); 1864c7070dbSScott Long 18795246abbSSean Bruno int (*ift_rxd_available) (void *, uint16_t qsidx, qidx_t pidx, qidx_t budget); 1884c7070dbSScott Long int (*ift_rxd_pkt_get) (void *, if_rxd_info_t ri); 18995246abbSSean Bruno void (*ift_rxd_refill) (void * , if_rxd_update_t iru); 19095246abbSSean Bruno void (*ift_rxd_flush) (void *, uint16_t qsidx, uint8_t flidx, qidx_t pidx); 1914c7070dbSScott Long int (*ift_legacy_intr) (void *); 192213e9139SEric Joyner qidx_t (*ift_txq_select) (void *, struct mbuf *); 193*9c950139SEric Joyner qidx_t (*ift_txq_select_v2) (void *, struct mbuf *, if_pkt_info_t); 1944c7070dbSScott Long } *if_txrx_t; 1954c7070dbSScott Long 1964c7070dbSScott Long typedef struct if_softc_ctx { 1974c7070dbSScott Long int isc_vectors; 1984c7070dbSScott Long int isc_nrxqsets; 1994c7070dbSScott Long int isc_ntxqsets; 200d49e83eaSMarius Strobl uint16_t __spare0__; 201d49e83eaSMarius Strobl uint32_t __spare1__; 2024c7070dbSScott Long int isc_msix_bar; /* can be model specific - initialize in attach_pre */ 2034c7070dbSScott Long int isc_tx_nsegments; /* can be model specific - initialize in attach_pre */ 20423ac9029SStephen Hurd int isc_ntxd[8]; 20523ac9029SStephen Hurd int isc_nrxd[8]; 20623ac9029SStephen Hurd 20723ac9029SStephen Hurd uint32_t isc_txqsizes[8]; 20823ac9029SStephen Hurd uint32_t isc_rxqsizes[8]; 20995246abbSSean Bruno /* is there such thing as a descriptor that is more than 248 bytes ? */ 21095246abbSSean Bruno uint8_t isc_txd_size[8]; 21195246abbSSean Bruno uint8_t isc_rxd_size[8]; 21295246abbSSean Bruno 2134c7070dbSScott Long int isc_tx_tso_segments_max; 2144c7070dbSScott Long int isc_tx_tso_size_max; 2154c7070dbSScott Long int isc_tx_tso_segsize_max; 2161248952aSSean Bruno int isc_tx_csum_flags; 2177f87c040SMarius Strobl int isc_capabilities; 2181248952aSSean Bruno int isc_capenable; 2194c7070dbSScott Long int isc_rss_table_size; 2204c7070dbSScott Long int isc_rss_table_mask; 22123ac9029SStephen Hurd int isc_nrxqsets_max; 22223ac9029SStephen Hurd int isc_ntxqsets_max; 223d49e83eaSMarius Strobl uint32_t __spare2__; 2244c7070dbSScott Long 2254c7070dbSScott Long iflib_intr_mode_t isc_intr; 226b3813609SPatrick Kelsey uint16_t isc_rxd_buf_size[8]; /* set at init time by driver, 0 227b3813609SPatrick Kelsey means use iflib-calculated size 228b3813609SPatrick Kelsey based on isc_max_frame_size */ 2294c7070dbSScott Long uint16_t isc_max_frame_size; /* set at init time by driver */ 230d14c853bSStephen Hurd uint16_t isc_min_frame_size; /* set at init time by driver, only used if 231d14c853bSStephen Hurd IFLIB_NEED_ETHER_PAD is set. */ 23260596476SSean Bruno uint32_t isc_pause_frames; /* set by driver for iflib_timer to detect */ 233d49e83eaSMarius Strobl uint32_t __spare3__; 234d49e83eaSMarius Strobl uint32_t __spare4__; 235d49e83eaSMarius Strobl uint32_t __spare5__; 236d49e83eaSMarius Strobl uint32_t __spare6__; 237d49e83eaSMarius Strobl uint32_t __spare7__; 238d49e83eaSMarius Strobl uint32_t __spare8__; 239d49e83eaSMarius Strobl caddr_t __spare9__; 240ea351d3fSSean Bruno int isc_disable_msix; 2411248952aSSean Bruno if_txrx_t isc_txrx; 242e2621d96SMatt Macy struct ifmedia *isc_media; 2436dd69f00SMarcin Wojtas bus_size_t isc_dma_width; /* device dma width in bits, 0 means 2446dd69f00SMarcin Wojtas use BUS_SPACE_MAXADDR instead */ 2454c7070dbSScott Long } *if_softc_ctx_t; 2464c7070dbSScott Long 2474c7070dbSScott Long /* 2484c7070dbSScott Long * Initialization values for device 2494c7070dbSScott Long */ 2504c7070dbSScott Long struct if_shared_ctx { 25181ad57b1SStephen Hurd unsigned isc_magic; 2524c7070dbSScott Long driver_t *isc_driver; 2534c7070dbSScott Long bus_size_t isc_q_align; 2544c7070dbSScott Long bus_size_t isc_tx_maxsize; 2554c7070dbSScott Long bus_size_t isc_tx_maxsegsize; 2567f87c040SMarius Strobl bus_size_t isc_tso_maxsize; 2577f87c040SMarius Strobl bus_size_t isc_tso_maxsegsize; 2584c7070dbSScott Long bus_size_t isc_rx_maxsize; 2594c7070dbSScott Long bus_size_t isc_rx_maxsegsize; 2604c7070dbSScott Long int isc_rx_nsegments; 2614c7070dbSScott Long int isc_admin_intrcnt; /* # of admin/link interrupts */ 2624c7070dbSScott Long 2634c7070dbSScott Long /* fields necessary for probe */ 264d49e83eaSMarius Strobl const pci_vendor_info_t *isc_vendor_info; 26510a1e981SEric Joyner const char *isc_driver_version; 2664c7070dbSScott Long /* optional function to transform the read values to match the table*/ 2674c7070dbSScott Long void (*isc_parse_devinfo) (uint16_t *device_id, uint16_t *subvendor_id, 2684c7070dbSScott Long uint16_t *subdevice_id, uint16_t *rev_id); 26923ac9029SStephen Hurd int isc_nrxd_min[8]; 27023ac9029SStephen Hurd int isc_nrxd_default[8]; 27123ac9029SStephen Hurd int isc_nrxd_max[8]; 27223ac9029SStephen Hurd int isc_ntxd_min[8]; 27323ac9029SStephen Hurd int isc_ntxd_default[8]; 27423ac9029SStephen Hurd int isc_ntxd_max[8]; 27595246abbSSean Bruno 27695246abbSSean Bruno /* actively used during operation */ 27795246abbSSean Bruno int isc_nfl __aligned(CACHE_LINE_SIZE); 27895246abbSSean Bruno int isc_ntxqs; /* # of tx queues per tx qset - usually 1 */ 27995246abbSSean Bruno int isc_nrxqs; /* # of rx queues per rx qset - intel 1, chelsio 2, broadcom 3 */ 280d49e83eaSMarius Strobl int __spare0__; 28195246abbSSean Bruno int isc_tx_reclaim_thresh; 28295246abbSSean Bruno int isc_flags; 28309f6ff4fSMatt Macy const char *isc_name; 2844c7070dbSScott Long }; 2854c7070dbSScott Long 2864c7070dbSScott Long typedef struct iflib_dma_info { 2874c7070dbSScott Long bus_addr_t idi_paddr; 2884c7070dbSScott Long caddr_t idi_vaddr; 2894c7070dbSScott Long bus_dma_tag_t idi_tag; 2904c7070dbSScott Long bus_dmamap_t idi_map; 2914c7070dbSScott Long uint32_t idi_size; 2924c7070dbSScott Long } *iflib_dma_info_t; 2934c7070dbSScott Long 2944c7070dbSScott Long #define IFLIB_MAGIC 0xCAFEF00D 2954c7070dbSScott Long 2964c7070dbSScott Long typedef enum { 29781be6552SMatt Macy /* Interrupt or softirq handles only receive */ 2984c7070dbSScott Long IFLIB_INTR_RX, 29981be6552SMatt Macy 30081be6552SMatt Macy /* Interrupt or softirq handles only transmit */ 30195246abbSSean Bruno IFLIB_INTR_TX, 30281be6552SMatt Macy 30381be6552SMatt Macy /* 30481be6552SMatt Macy * Interrupt will check for both pending receive 30581be6552SMatt Macy * and available tx credits and dispatch a task 30681be6552SMatt Macy * for one or both depending on the disposition 30781be6552SMatt Macy * of the respective queues. 30881be6552SMatt Macy */ 30995246abbSSean Bruno IFLIB_INTR_RXTX, 31081be6552SMatt Macy 31181be6552SMatt Macy /* 31281be6552SMatt Macy * Other interrupt - typically link status and 31381be6552SMatt Macy * or error conditions. 31481be6552SMatt Macy */ 3154c7070dbSScott Long IFLIB_INTR_ADMIN, 31681be6552SMatt Macy 31781be6552SMatt Macy /* Softirq (task) for iov handling */ 3184c7070dbSScott Long IFLIB_INTR_IOV, 3194c7070dbSScott Long } iflib_intr_type_t; 3204c7070dbSScott Long 3214c7070dbSScott Long /* 3226d84e76aSVincenzo Maffione * Interface has a separate completion queue for RX 3234c7070dbSScott Long */ 3241248952aSSean Bruno #define IFLIB_HAS_RXCQ 0x01 3254c7070dbSScott Long /* 3264c7070dbSScott Long * Driver has already allocated vectors 3274c7070dbSScott Long */ 3281248952aSSean Bruno #define IFLIB_SKIP_MSIX 0x02 3294c7070dbSScott Long /* 3304c7070dbSScott Long * Interface is a virtual function 3314c7070dbSScott Long */ 3321248952aSSean Bruno #define IFLIB_IS_VF 0x04 33323ac9029SStephen Hurd /* 3346d84e76aSVincenzo Maffione * Interface has a separate completion queue for TX 33523ac9029SStephen Hurd */ 3361248952aSSean Bruno #define IFLIB_HAS_TXCQ 0x08 3371248952aSSean Bruno /* 338ab2e3f79SStephen Hurd * Interface does checksum in place 3391248952aSSean Bruno */ 340ab2e3f79SStephen Hurd #define IFLIB_NEED_SCRATCH 0x10 3411248952aSSean Bruno /* 3421248952aSSean Bruno * Interface doesn't expect in_pseudo for th_sum 3431248952aSSean Bruno */ 3441248952aSSean Bruno #define IFLIB_TSO_INIT_IP 0x20 34595246abbSSean Bruno /* 34695246abbSSean Bruno * Interface doesn't align IP header 34795246abbSSean Bruno */ 34895246abbSSean Bruno #define IFLIB_DO_RX_FIXUP 0x40 349c5cf2172SStephen Hurd /* 350c5cf2172SStephen Hurd * Driver needs csum zeroed for offloading 351c5cf2172SStephen Hurd */ 352c5cf2172SStephen Hurd #define IFLIB_NEED_ZERO_CSUM 0x80 353d14c853bSStephen Hurd /* 354d14c853bSStephen Hurd * Driver needs frames padded to some minimum length 355d14c853bSStephen Hurd */ 356d14c853bSStephen Hurd #define IFLIB_NEED_ETHER_PAD 0x100 35709f6ff4fSMatt Macy /* 35809f6ff4fSMatt Macy * Packets can be freed immediately after encap 35909f6ff4fSMatt Macy */ 36009f6ff4fSMatt Macy #define IFLIB_TXD_ENCAP_PIO 0x00200 36109f6ff4fSMatt Macy /* 36209f6ff4fSMatt Macy * Use RX completion handler 36309f6ff4fSMatt Macy */ 36409f6ff4fSMatt Macy #define IFLIB_RX_COMPLETION 0x00400 36509f6ff4fSMatt Macy /* 36609f6ff4fSMatt Macy * Skip refilling cluster free lists 36709f6ff4fSMatt Macy */ 36809f6ff4fSMatt Macy #define IFLIB_SKIP_CLREFILL 0x00800 36909f6ff4fSMatt Macy /* 37009f6ff4fSMatt Macy * Don't reset on hang 37109f6ff4fSMatt Macy */ 37209f6ff4fSMatt Macy #define IFLIB_NO_HANG_RESET 0x01000 37309f6ff4fSMatt Macy /* 37409f6ff4fSMatt Macy * Don't need/want most of the niceties of 37509f6ff4fSMatt Macy * queue management 37609f6ff4fSMatt Macy */ 37709f6ff4fSMatt Macy #define IFLIB_PSEUDO 0x02000 37809f6ff4fSMatt Macy /* 37909f6ff4fSMatt Macy * No DMA support needed / wanted 38009f6ff4fSMatt Macy */ 38109f6ff4fSMatt Macy #define IFLIB_VIRTUAL 0x04000 38209f6ff4fSMatt Macy /* 38309f6ff4fSMatt Macy * autogenerate a MAC address 38409f6ff4fSMatt Macy */ 38509f6ff4fSMatt Macy #define IFLIB_GEN_MAC 0x08000 3861d7ef186SEric Joyner /* 3871d7ef186SEric Joyner * Interface needs admin task to ignore interface up/down status 3881d7ef186SEric Joyner */ 3891d7ef186SEric Joyner #define IFLIB_ADMIN_ALWAYS_RUN 0x10000 390e2621d96SMatt Macy /* 391e2621d96SMatt Macy * Driver will pass the media 392e2621d96SMatt Macy */ 393e2621d96SMatt Macy #define IFLIB_DRIVER_MEDIA 0x20000 39441669133SMark Johnston /* 39541669133SMark Johnston * When using a single hardware interrupt for the interface, only process RX 39641669133SMark Johnston * interrupts instead of doing combined RX/TX processing. 39741669133SMark Johnston */ 39841669133SMark Johnston #define IFLIB_SINGLE_IRQ_RX_ONLY 0x40000 3999aeca213SMatt Macy /* 4009aeca213SMatt Macy * Don't need/want most of the niceties of 4019aeca213SMatt Macy * emulating ethernet 4029aeca213SMatt Macy */ 4039aeca213SMatt Macy #define IFLIB_PSEUDO_ETHER 0x80000 4044c7070dbSScott Long /* 40509c3f04fSMarcin Wojtas * Interface has an admin completion queue 40609c3f04fSMarcin Wojtas */ 40709c3f04fSMarcin Wojtas #define IFLIB_HAS_ADMINCQ 0x100000 40858632fa7SMarcin Wojtas /* 40958632fa7SMarcin Wojtas * Interface needs to preserve TX ring indices across restarts. 41058632fa7SMarcin Wojtas */ 41158632fa7SMarcin Wojtas #define IFLIB_PRESERVE_TX_INDICES 0x200000 41209c3f04fSMarcin Wojtas 413213e9139SEric Joyner /* The following IFLIB_FEATURE_* defines are for driver modules to determine 414213e9139SEric Joyner * what features this version of iflib supports. They shall be defined to the 415213e9139SEric Joyner * first __FreeBSD_version that introduced the feature. 416213e9139SEric Joyner */ 417213e9139SEric Joyner /* 418213e9139SEric Joyner * Driver can set its own TX queue selection function 419213e9139SEric Joyner * as ift_txq_select in struct if_txrx 420213e9139SEric Joyner */ 421213e9139SEric Joyner #define IFLIB_FEATURE_QUEUE_SELECT 1400050 422*9c950139SEric Joyner /* 423*9c950139SEric Joyner * Driver can set its own TX queue selection function 424*9c950139SEric Joyner * as ift_txq_select_v2 in struct if_txrx. This includes 425*9c950139SEric Joyner * having iflib send L3+ extra header information to the 426*9c950139SEric Joyner * function. 427*9c950139SEric Joyner */ 428*9c950139SEric Joyner #define IFLIB_FEATURE_QUEUE_SELECT_V2 1400073 429213e9139SEric Joyner 43009c3f04fSMarcin Wojtas /* 43145818bf1SEric Joyner * These enum values are used in iflib_needs_restart to indicate to iflib 43245818bf1SEric Joyner * functions whether or not the interface needs restarting when certain events 43345818bf1SEric Joyner * happen. 43445818bf1SEric Joyner */ 43545818bf1SEric Joyner enum iflib_restart_event { 43645818bf1SEric Joyner IFLIB_RESTART_VLAN_CONFIG, 43745818bf1SEric Joyner }; 43845818bf1SEric Joyner 43945818bf1SEric Joyner /* 4404c7070dbSScott Long * field accessors 4414c7070dbSScott Long */ 4424c7070dbSScott Long void *iflib_get_softc(if_ctx_t ctx); 4434c7070dbSScott Long 4444c7070dbSScott Long device_t iflib_get_dev(if_ctx_t ctx); 4454c7070dbSScott Long 4464c7070dbSScott Long if_t iflib_get_ifp(if_ctx_t ctx); 4474c7070dbSScott Long 4484c7070dbSScott Long struct ifmedia *iflib_get_media(if_ctx_t ctx); 4494c7070dbSScott Long 4504c7070dbSScott Long if_softc_ctx_t iflib_get_softc_ctx(if_ctx_t ctx); 4514c7070dbSScott Long if_shared_ctx_t iflib_get_sctx(if_ctx_t ctx); 4524c7070dbSScott Long 4534c7070dbSScott Long void iflib_set_mac(if_ctx_t ctx, uint8_t mac[ETHER_ADDR_LEN]); 45477c1fcecSEric Joyner void iflib_request_reset(if_ctx_t ctx); 45577c1fcecSEric Joyner uint8_t iflib_in_detach(if_ctx_t ctx); 4564c7070dbSScott Long 4571b9d9394SEric Joyner uint32_t iflib_get_rx_mbuf_sz(if_ctx_t ctx); 4581b9d9394SEric Joyner 4594c7070dbSScott Long /* 4604c7070dbSScott Long * If the driver can plug cleanly in to newbus use these 4614c7070dbSScott Long */ 4624c7070dbSScott Long int iflib_device_probe(device_t); 4634c7070dbSScott Long int iflib_device_attach(device_t); 4644c7070dbSScott Long int iflib_device_detach(device_t); 4654c7070dbSScott Long int iflib_device_suspend(device_t); 4664c7070dbSScott Long int iflib_device_resume(device_t); 4674c7070dbSScott Long int iflib_device_shutdown(device_t); 4684c7070dbSScott Long 469668d6dbbSEric Joyner /* 470668d6dbbSEric Joyner * Use this instead of iflib_device_probe if the driver should report 471668d6dbbSEric Joyner * BUS_PROBE_VENDOR instead of BUS_PROBE_DEFAULT. (For example, an out-of-tree 472668d6dbbSEric Joyner * driver based on iflib). 473668d6dbbSEric Joyner */ 474668d6dbbSEric Joyner int iflib_device_probe_vendor(device_t); 475668d6dbbSEric Joyner 4764c7070dbSScott Long int iflib_device_iov_init(device_t, uint16_t, const nvlist_t *); 4774c7070dbSScott Long void iflib_device_iov_uninit(device_t); 4784c7070dbSScott Long int iflib_device_iov_add_vf(device_t, uint16_t, const nvlist_t *); 4794c7070dbSScott Long 4804c7070dbSScott Long /* 4814c7070dbSScott Long * If the driver can't plug cleanly in to newbus 4824c7070dbSScott Long * use these 4834c7070dbSScott Long */ 4844c7070dbSScott Long int iflib_device_register(device_t dev, void *softc, if_shared_ctx_t sctx, if_ctx_t *ctxp); 4854c7070dbSScott Long int iflib_device_deregister(if_ctx_t); 4864c7070dbSScott Long 4873e0e6330SStephen Hurd int iflib_irq_alloc(if_ctx_t, if_irq_t, int, driver_filter_t, void *filter_arg, driver_intr_t, void *arg, const char *name); 4884c7070dbSScott Long int iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, 4894c7070dbSScott Long iflib_intr_type_t type, driver_filter_t *filter, 4903e0e6330SStephen Hurd void *filter_arg, int qid, const char *name); 4913e0e6330SStephen Hurd void iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, void *arg, int qid, const char *name); 4924c7070dbSScott Long 4934c7070dbSScott Long void iflib_irq_free(if_ctx_t ctx, if_irq_t irq); 4944c7070dbSScott Long 495d49e83eaSMarius Strobl void iflib_io_tqg_attach(struct grouptask *gt, void *uniq, int cpu, 496d49e83eaSMarius Strobl const char *name); 4974c7070dbSScott Long 498aa8a24d3SStephen Hurd void iflib_config_gtask_init(void *ctx, struct grouptask *gtask, 499aa8a24d3SStephen Hurd gtask_fn_t *fn, const char *name); 50023ac9029SStephen Hurd void iflib_config_gtask_deinit(struct grouptask *gtask); 50123ac9029SStephen Hurd 5024c7070dbSScott Long void iflib_tx_intr_deferred(if_ctx_t ctx, int txqid); 5034c7070dbSScott Long void iflib_rx_intr_deferred(if_ctx_t ctx, int rxqid); 5044c7070dbSScott Long void iflib_admin_intr_deferred(if_ctx_t ctx); 5054c7070dbSScott Long void iflib_iov_intr_deferred(if_ctx_t ctx); 5064c7070dbSScott Long 50723ac9029SStephen Hurd void iflib_link_state_change(if_ctx_t ctx, int linkstate, uint64_t baudrate); 5084c7070dbSScott Long 5094c7070dbSScott Long int iflib_dma_alloc(if_ctx_t ctx, int size, iflib_dma_info_t dma, int mapflags); 5108f82136aSPatrick Kelsey int iflib_dma_alloc_align(if_ctx_t ctx, int size, int align, iflib_dma_info_t dma, int mapflags); 5114c7070dbSScott Long void iflib_dma_free(iflib_dma_info_t dma); 5124c7070dbSScott Long int iflib_dma_alloc_multi(if_ctx_t ctx, int *sizes, iflib_dma_info_t *dmalist, int mapflags, int count); 5134c7070dbSScott Long 5144c7070dbSScott Long void iflib_dma_free_multi(iflib_dma_info_t *dmalist, int count); 5154c7070dbSScott Long 516aa8a24d3SStephen Hurd struct sx *iflib_ctx_lock_get(if_ctx_t); 5174c7070dbSScott Long 5184c7070dbSScott Long void iflib_led_create(if_ctx_t ctx); 5194c7070dbSScott Long 5204c7070dbSScott Long void iflib_add_int_delay_sysctl(if_ctx_t, const char *, const char *, 5214c7070dbSScott Long if_int_delay_info_t, int, int); 5224c7070dbSScott Long 52309f6ff4fSMatt Macy /* 52409f6ff4fSMatt Macy * Pseudo device support 52509f6ff4fSMatt Macy */ 52609f6ff4fSMatt Macy if_pseudo_t iflib_clone_register(if_shared_ctx_t); 52709f6ff4fSMatt Macy void iflib_clone_deregister(if_pseudo_t); 528d49e83eaSMarius Strobl 5294c7070dbSScott Long #endif /* __IFLIB_H_ */ 530