1257c5577SDavid E. O'Brien /* $OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $ */ 2257c5577SDavid E. O'Brien 3257c5577SDavid E. O'Brien /*- 4257c5577SDavid E. O'Brien * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> 5257c5577SDavid E. O'Brien * 6257c5577SDavid E. O'Brien * Permission to use, copy, modify, and distribute this software for any 7257c5577SDavid E. O'Brien * purpose with or without fee is hereby granted, provided that the above 8257c5577SDavid E. O'Brien * copyright notice and this permission notice appear in all copies. 9257c5577SDavid E. O'Brien * 10257c5577SDavid E. O'Brien * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11257c5577SDavid E. O'Brien * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12257c5577SDavid E. O'Brien * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13257c5577SDavid E. O'Brien * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14257c5577SDavid E. O'Brien * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15257c5577SDavid E. O'Brien * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16257c5577SDavid E. O'Brien * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17257c5577SDavid E. O'Brien */ 18257c5577SDavid E. O'Brien 19257c5577SDavid E. O'Brien struct nfe_tx_data { 20bfc788c2SDavid E. O'Brien bus_dmamap_t tx_data_map; 21257c5577SDavid E. O'Brien struct mbuf *m; 22257c5577SDavid E. O'Brien }; 23257c5577SDavid E. O'Brien 24257c5577SDavid E. O'Brien struct nfe_tx_ring { 25aab5582fSPyun YongHyeon bus_dma_tag_t tx_desc_tag; 26bfc788c2SDavid E. O'Brien bus_dmamap_t tx_desc_map; 27257c5577SDavid E. O'Brien bus_addr_t physaddr; 28257c5577SDavid E. O'Brien struct nfe_desc32 *desc32; 29257c5577SDavid E. O'Brien struct nfe_desc64 *desc64; 30aab5582fSPyun YongHyeon bus_dma_tag_t tx_data_tag; 31257c5577SDavid E. O'Brien struct nfe_tx_data data[NFE_TX_RING_COUNT]; 32257c5577SDavid E. O'Brien int queued; 33257c5577SDavid E. O'Brien int cur; 34257c5577SDavid E. O'Brien int next; 35257c5577SDavid E. O'Brien }; 36257c5577SDavid E. O'Brien 37257c5577SDavid E. O'Brien struct nfe_rx_data { 38bfc788c2SDavid E. O'Brien bus_dmamap_t rx_data_map; 39aab5582fSPyun YongHyeon bus_addr_t paddr; 40257c5577SDavid E. O'Brien struct mbuf *m; 41257c5577SDavid E. O'Brien }; 42257c5577SDavid E. O'Brien 43257c5577SDavid E. O'Brien struct nfe_rx_ring { 44bfc788c2SDavid E. O'Brien bus_dma_tag_t rx_desc_tag; 45aab5582fSPyun YongHyeon bus_dmamap_t rx_desc_map; 46257c5577SDavid E. O'Brien bus_addr_t physaddr; 47257c5577SDavid E. O'Brien struct nfe_desc32 *desc32; 48257c5577SDavid E. O'Brien struct nfe_desc64 *desc64; 49aab5582fSPyun YongHyeon bus_dma_tag_t rx_data_tag; 50aab5582fSPyun YongHyeon bus_dmamap_t rx_spare_map; 51257c5577SDavid E. O'Brien struct nfe_rx_data data[NFE_RX_RING_COUNT]; 52257c5577SDavid E. O'Brien int cur; 53257c5577SDavid E. O'Brien int next; 54257c5577SDavid E. O'Brien }; 55257c5577SDavid E. O'Brien 56aab5582fSPyun YongHyeon struct nfe_jrx_ring { 57aab5582fSPyun YongHyeon bus_dma_tag_t jrx_desc_tag; 58aab5582fSPyun YongHyeon bus_dmamap_t jrx_desc_map; 59aab5582fSPyun YongHyeon bus_dma_tag_t jrx_jumbo_tag; 60aab5582fSPyun YongHyeon bus_dmamap_t jrx_jumbo_map; 61aab5582fSPyun YongHyeon bus_addr_t jphysaddr; 62aab5582fSPyun YongHyeon struct nfe_desc32 *jdesc32; 63aab5582fSPyun YongHyeon struct nfe_desc64 *jdesc64; 64aab5582fSPyun YongHyeon bus_dma_tag_t jrx_data_tag; 65aab5582fSPyun YongHyeon bus_dmamap_t jrx_spare_map; 66aab5582fSPyun YongHyeon struct nfe_rx_data jdata[NFE_JUMBO_RX_RING_COUNT]; 67aab5582fSPyun YongHyeon int jcur; 68aab5582fSPyun YongHyeon int jnext; 69aab5582fSPyun YongHyeon }; 70aab5582fSPyun YongHyeon 7117d022beSPyun YongHyeon struct nfe_hw_stats { 7217d022beSPyun YongHyeon uint64_t rx_octets; 7317d022beSPyun YongHyeon uint32_t rx_frame_errors; 7417d022beSPyun YongHyeon uint32_t rx_extra_bytes; 7517d022beSPyun YongHyeon uint32_t rx_late_cols; 7617d022beSPyun YongHyeon uint32_t rx_runts; 7717d022beSPyun YongHyeon uint32_t rx_jumbos; 7817d022beSPyun YongHyeon uint32_t rx_fifo_overuns; 7917d022beSPyun YongHyeon uint32_t rx_crc_errors; 8017d022beSPyun YongHyeon uint32_t rx_fae; 8117d022beSPyun YongHyeon uint32_t rx_len_errors; 8217d022beSPyun YongHyeon uint32_t rx_unicast; 8317d022beSPyun YongHyeon uint32_t rx_multicast; 8417d022beSPyun YongHyeon uint32_t rx_broadcast; 8517d022beSPyun YongHyeon uint32_t rx_pause; 8617d022beSPyun YongHyeon uint32_t rx_drops; 8717d022beSPyun YongHyeon uint64_t tx_octets; 8817d022beSPyun YongHyeon uint32_t tx_zero_rexmits; 8917d022beSPyun YongHyeon uint32_t tx_one_rexmits; 9017d022beSPyun YongHyeon uint32_t tx_multi_rexmits; 9117d022beSPyun YongHyeon uint32_t tx_late_cols; 9217d022beSPyun YongHyeon uint32_t tx_fifo_underuns; 9317d022beSPyun YongHyeon uint32_t tx_carrier_losts; 9417d022beSPyun YongHyeon uint32_t tx_excess_deferals; 9517d022beSPyun YongHyeon uint32_t tx_retry_errors; 9617d022beSPyun YongHyeon uint32_t tx_deferals; 9717d022beSPyun YongHyeon uint32_t tx_frames; 9817d022beSPyun YongHyeon uint32_t tx_pause; 9917d022beSPyun YongHyeon uint32_t tx_unicast; 10017d022beSPyun YongHyeon uint32_t tx_multicast; 10117d022beSPyun YongHyeon uint32_t tx_broadcast; 10217d022beSPyun YongHyeon }; 10317d022beSPyun YongHyeon 104257c5577SDavid E. O'Brien struct nfe_softc { 105*ec22a3a2SJustin Hibbits if_t nfe_ifp; 106bfc788c2SDavid E. O'Brien device_t nfe_dev; 107aab5582fSPyun YongHyeon uint16_t nfe_devid; 108aab5582fSPyun YongHyeon uint16_t nfe_revid; 109bfc788c2SDavid E. O'Brien device_t nfe_miibus; 110bfc788c2SDavid E. O'Brien struct mtx nfe_mtx; 111aab5582fSPyun YongHyeon struct resource *nfe_res[1]; 112aab5582fSPyun YongHyeon struct resource *nfe_msix_res; 113aab5582fSPyun YongHyeon struct resource *nfe_msix_pba_res; 114aab5582fSPyun YongHyeon struct resource *nfe_irq[NFE_MSI_MESSAGES]; 115aab5582fSPyun YongHyeon void *nfe_intrhand[NFE_MSI_MESSAGES]; 116bfc788c2SDavid E. O'Brien struct callout nfe_stat_ch; 117aab5582fSPyun YongHyeon int nfe_watchdog_timer; 118257c5577SDavid E. O'Brien 119bfc788c2SDavid E. O'Brien bus_dma_tag_t nfe_parent_tag; 120bfc788c2SDavid E. O'Brien 121bfc788c2SDavid E. O'Brien int nfe_if_flags; 122aab5582fSPyun YongHyeon uint32_t nfe_flags; 123aab5582fSPyun YongHyeon #define NFE_JUMBO_SUP 0x0001 124aab5582fSPyun YongHyeon #define NFE_40BIT_ADDR 0x0002 125aab5582fSPyun YongHyeon #define NFE_HW_CSUM 0x0004 126aab5582fSPyun YongHyeon #define NFE_HW_VLAN 0x0008 127aab5582fSPyun YongHyeon #define NFE_PWR_MGMT 0x0010 128aab5582fSPyun YongHyeon #define NFE_CORRECT_MACADDR 0x0020 129aab5582fSPyun YongHyeon #define NFE_TX_FLOW_CTRL 0x0040 13017d022beSPyun YongHyeon #define NFE_MIB_V1 0x0080 13117d022beSPyun YongHyeon #define NFE_MIB_V2 0x0100 13217d022beSPyun YongHyeon #define NFE_MIB_V3 0x0200 1338b590ad2SPyun YongHyeon int nfe_jumbo_disable; 134aab5582fSPyun YongHyeon uint32_t rxtxctl; 135aab5582fSPyun YongHyeon uint8_t mii_phyaddr; 136aab5582fSPyun YongHyeon uint8_t eaddr[ETHER_ADDR_LEN]; 13717d022beSPyun YongHyeon struct nfe_hw_stats nfe_stats; 138aab5582fSPyun YongHyeon struct taskqueue *nfe_tq; 139aab5582fSPyun YongHyeon struct task nfe_int_task; 140bfc788c2SDavid E. O'Brien int nfe_link; 141aab5582fSPyun YongHyeon int nfe_suspended; 142aab5582fSPyun YongHyeon int nfe_framesize; 143aab5582fSPyun YongHyeon int nfe_process_limit; 144aab5582fSPyun YongHyeon int nfe_force_tx; 145aab5582fSPyun YongHyeon uint32_t nfe_irq_status; 146aab5582fSPyun YongHyeon uint32_t nfe_irq_mask; 147aab5582fSPyun YongHyeon uint32_t nfe_intrs; 148aab5582fSPyun YongHyeon uint32_t nfe_nointrs; 149aab5582fSPyun YongHyeon uint32_t nfe_msi; 150aab5582fSPyun YongHyeon uint32_t nfe_msix; 151257c5577SDavid E. O'Brien 152257c5577SDavid E. O'Brien struct nfe_tx_ring txq; 153257c5577SDavid E. O'Brien struct nfe_rx_ring rxq; 154aab5582fSPyun YongHyeon struct nfe_jrx_ring jrxq; 155bfc788c2SDavid E. O'Brien }; 156bfc788c2SDavid E. O'Brien 157bfc788c2SDavid E. O'Brien struct nfe_type { 158aab5582fSPyun YongHyeon uint16_t vid_id; 159aab5582fSPyun YongHyeon uint16_t dev_id; 160bfc788c2SDavid E. O'Brien char *name; 161257c5577SDavid E. O'Brien }; 162