sys/dev/netif/ale/if_alevar.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | /*- * Copyright (c) 2008, Pyun YongHyeon <yongari@FreeBSD.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice unmodified, this list of conditions, and the following * disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ale/if_alevar.h,v 1.1 2008/11/12 09:52:06 yongari Exp $ */ #ifndef _IF_ALEVAR_H #define _IF_ALEVAR_H #define ALE_TX_RING_CNT 256 /* Should be multiple of 4. */ #define ALE_TX_RING_CNT_MIN 32 #define ALE_TX_RING_CNT_MAX 1020 #define ALE_TX_RING_ALIGN 8 #define ALE_RX_PAGE_ALIGN 32 #define ALE_RX_PAGES 2 #define ALE_CMB_ALIGN 32 #define ALE_TSO_MAXSEGSIZE 4096 #define ALE_TSO_MAXSIZE (65535 + sizeof(struct ether_vlan_header)) #define ALE_MAXTXSEGS 32 #define ALE_ADDR_LO(x) ((uint64_t) (x) & 0xFFFFFFFF) #define ALE_ADDR_HI(x) ((uint64_t) (x) >> 32) /* Water mark to kick reclaiming Tx buffers. */ #define ALE_TX_DESC_HIWAT (ALE_TX_RING_CNT - ((ALE_TX_RING_CNT * 4) / 10)) #define ALE_MSI_MESSAGES 1 #define ALE_MSIX_MESSAGES 1 /* * TODO : Should get real jumbo MTU size. * The hardware seems to have trouble in dealing with large * frame length. If you encounter unstability issue, use * lower MTU size. */ #define ALE_JUMBO_FRAMELEN 8132 #define ALE_JUMBO_MTU \ (ALE_JUMBO_FRAMELEN - sizeof(struct ether_vlan_header) - ETHER_CRC_LEN) #define ALE_MAX_FRAMELEN (ETHER_MAX_LEN + EVL_ENCAPLEN) #define ALE_DESC_INC(x, y) ((x) = ((x) + 1) % (y)) struct ale_txdesc { struct mbuf *tx_m; bus_dmamap_t tx_dmamap; }; struct ale_rx_page { bus_dma_tag_t page_tag; bus_dmamap_t page_map; uint8_t *page_addr; bus_addr_t page_paddr; bus_dma_tag_t cmb_tag; bus_dmamap_t cmb_map; uint32_t *cmb_addr; bus_addr_t cmb_paddr; uint32_t cons; }; struct ale_chain_data{ bus_dma_tag_t ale_parent_tag; bus_dma_tag_t ale_buffer_tag; bus_dma_tag_t ale_tx_tag; struct ale_txdesc ale_txdesc[ALE_TX_RING_CNT]; bus_dma_tag_t ale_tx_ring_tag; bus_dmamap_t ale_tx_ring_map; bus_dma_tag_t ale_rx_mblock_tag[ALE_RX_PAGES]; bus_dmamap_t ale_rx_mblock_map[ALE_RX_PAGES]; struct tx_desc *ale_tx_ring; bus_addr_t ale_tx_ring_paddr; uint32_t *ale_tx_cmb; bus_addr_t ale_tx_cmb_paddr; bus_dma_tag_t ale_tx_cmb_tag; bus_dmamap_t ale_tx_cmb_map; uint32_t ale_tx_prod; uint32_t ale_tx_cons; int ale_tx_cnt; struct ale_rx_page ale_rx_page[ALE_RX_PAGES]; int ale_rx_curp; uint16_t ale_rx_seqno; }; #define ALE_TX_RING_SZ \ (sizeof(struct tx_desc) * ALE_TX_RING_CNT) #define ALE_RX_PAGE_SZ_MIN (8 * 1024) #define ALE_RX_PAGE_SZ_MAX (1024 * 1024) #define ALE_RX_FRAMES_PAGE 128 #define ALE_RX_PAGE_SZ \ (roundup(ALE_MAX_FRAMELEN, ALE_RX_PAGE_ALIGN) * ALE_RX_FRAMES_PAGE) #define ALE_TX_CMB_SZ (sizeof(uint32_t)) #define ALE_RX_CMB_SZ (sizeof(uint32_t)) #define ALE_PROC_MIN (ALE_RX_FRAMES_PAGE / 4) #define ALE_PROC_MAX \ ((ALE_RX_PAGE_SZ * ALE_RX_PAGES) / ETHER_MAX_LEN) #define ALE_PROC_DEFAULT (ALE_PROC_MAX / 4) struct ale_hw_stats { /* Rx stats. */ uint32_t rx_frames; uint32_t rx_bcast_frames; uint32_t rx_mcast_frames; uint32_t rx_pause_frames; uint32_t rx_control_frames; uint32_t rx_crcerrs; uint32_t rx_lenerrs; uint64_t rx_bytes; uint32_t rx_runts; uint32_t rx_fragments; uint32_t rx_pkts_64; uint32_t rx_pkts_65_127; uint32_t rx_pkts_128_255; uint32_t rx_pkts_256_511; uint32_t rx_pkts_512_1023; uint32_t rx_pkts_1024_1518; uint32_t rx_pkts_1519_max; uint32_t rx_pkts_truncated; uint32_t rx_fifo_oflows; uint32_t rx_rrs_errs; uint32_t rx_alignerrs; uint64_t rx_bcast_bytes; uint64_t rx_mcast_bytes; uint32_t rx_pkts_filtered; /* Tx stats. */ uint32_t tx_frames; uint32_t tx_bcast_frames; uint32_t tx_mcast_frames; uint32_t tx_pause_frames; uint32_t tx_excess_defer; uint32_t tx_control_frames; uint32_t tx_deferred; uint64_t tx_bytes; uint32_t tx_pkts_64; uint32_t tx_pkts_65_127; uint32_t tx_pkts_128_255; uint32_t tx_pkts_256_511; uint32_t tx_pkts_512_1023; uint32_t tx_pkts_1024_1518; uint32_t tx_pkts_1519_max; uint32_t tx_single_colls; uint32_t tx_multi_colls; uint32_t tx_late_colls; uint32_t tx_excess_colls; uint32_t tx_abort; uint32_t tx_underrun; uint32_t tx_desc_underrun; uint32_t tx_lenerrs; uint32_t tx_pkts_truncated; uint64_t tx_bcast_bytes; uint64_t tx_mcast_bytes; /* Misc. */ uint32_t reset_brk_seq; }; /* * Software state per device. */ struct ale_softc { struct arpcom arpcom; device_t ale_dev; int ale_mem_rid; struct resource *ale_mem_res; bus_space_tag_t ale_mem_bt; bus_space_handle_t ale_mem_bh; int ale_irq_rid; struct resource *ale_irq_res; void *ale_irq_handle; int ale_phyaddr; device_t ale_miibus; int ale_rev; int ale_chip_rev; uint8_t ale_eaddr[ETHER_ADDR_LEN]; uint32_t ale_dma_rd_burst; uint32_t ale_dma_wr_burst; int ale_flags; #define ALE_FLAG_PCIE 0x0001 #define ALE_FLAG_PCIX 0x0002 #define ALE_FLAG_MSI 0x0004 #define ALE_FLAG_MSIX 0x0008 #define ALE_FLAG_PMCAP 0x0010 #define ALE_FLAG_FASTETHER 0x0020 #define ALE_FLAG_JUMBO 0x0040 #define ALE_FLAG_RXCSUM_BUG 0x0080 #define ALE_FLAG_TXCSUM_BUG 0x0100 #define ALE_FLAG_TXCMB_BUG 0x0200 #define ALE_FLAG_DETACH 0x4000 #define ALE_FLAG_LINK 0x8000 struct callout ale_tick_ch; struct ale_hw_stats ale_stats; struct ale_chain_data ale_cdata; int ale_if_flags; int ale_int_rx_mod; int ale_int_tx_mod; int ale_max_frame_size; int ale_pagesize; }; /* Register access macros. */ #define CSR_WRITE_4(_sc, reg, val) \ bus_space_write_4((_sc)->ale_mem_bt, (_sc)->ale_mem_bh, (reg), (val)) #define CSR_WRITE_2(_sc, reg, val) \ bus_space_write_2((_sc)->ale_mem_bt, (_sc)->ale_mem_bh, (reg), (val)) #define CSR_WRITE_1(_sc, reg, val) \ bus_space_write_1((_sc)->ale_mem_bt, (_sc)->ale_mem_bh, (reg), (val)) #define CSR_READ_2(_sc, reg) \ bus_space_read_2((_sc)->ale_mem_bt, (_sc)->ale_mem_bh, (reg)) #define CSR_READ_4(_sc, reg) \ bus_space_read_4((_sc)->ale_mem_bt, (_sc)->ale_mem_bh, (reg)) #define ALE_TX_TIMEOUT 5 #define ALE_RESET_TIMEOUT 100 #define ALE_TIMEOUT 1000 #define ALE_PHY_TIMEOUT 1000 #endif /* _IF_ALEVAR_H */ |