1 /* $NetBSD: if_stgereg.h,v 1.3 2003/02/10 21:10:07 christos Exp $ */
2 /* $FreeBSD: src/sys/dev/stge/if_stgereg.h,v 1.1 2006/07/25 00:37:09 yongari Exp $ */
5 * Copyright (c) 2001 The NetBSD Foundation, Inc.
8 * This code is derived from software contributed to The NetBSD Foundation
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
41 * Transmit descriptor list size.
43 #define STGE_TX_RING_CNT 256
44 #define STGE_TX_LOWAT (STGE_TX_RING_CNT/32)
45 #define STGE_TX_HIWAT (STGE_TX_RING_CNT - STGE_TX_LOWAT)
48 * Receive descriptor list size.
50 #define STGE_RX_RING_CNT 256
52 #define STGE_MAXTXSEGS STGE_NTXFRAGS
53 #define STGE_MAXSGSIZE PAGE_SIZE
55 #define STGE_JUMBO_FRAMELEN 9022
56 #define STGE_JUMBO_MTU \
57 (STGE_JUMBO_FRAMELEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
60 struct mbuf *tx_m; /* head of our mbuf chain */
61 bus_dmamap_t tx_dmamap; /* our DMA map */
62 STAILQ_ENTRY(stge_txdesc) tx_q;
65 STAILQ_HEAD(stge_txdq, stge_txdesc);
69 bus_dmamap_t rx_dmamap;
72 #define STGE_ADDR_LO(x) ((u_int64_t) (x) & 0xffffffff)
73 #define STGE_ADDR_HI(x) ((u_int64_t) (x) >> 32)
75 #define STGE_RING_ALIGN 8
77 struct stge_chain_data{
78 bus_dma_tag_t stge_parent_tag;
79 bus_dma_tag_t stge_tx_tag;
80 struct stge_txdesc stge_txdesc[STGE_TX_RING_CNT];
81 struct stge_txdq stge_txfreeq;
82 struct stge_txdq stge_txbusyq;
83 bus_dma_tag_t stge_rx_tag;
84 struct stge_rxdesc stge_rxdesc[STGE_RX_RING_CNT];
85 bus_dma_tag_t stge_tx_ring_tag;
86 bus_dmamap_t stge_tx_ring_map;
87 bus_dma_tag_t stge_rx_ring_tag;
88 bus_dmamap_t stge_rx_ring_map;
89 bus_dmamap_t stge_rx_sparemap;
96 struct mbuf *stge_rxhead;
97 struct mbuf *stge_rxtail;
100 struct stge_ring_data {
101 struct stge_tfd *stge_tx_ring;
102 bus_addr_t stge_tx_ring_paddr;
103 struct stge_rfd *stge_rx_ring;
104 bus_addr_t stge_rx_ring_paddr;
107 #define STGE_TX_RING_ADDR(sc, i) \
108 ((sc)->sc_rdata.stge_tx_ring_paddr + sizeof(struct stge_tfd) * (i))
109 #define STGE_RX_RING_ADDR(sc, i) \
110 ((sc)->sc_rdata.stge_rx_ring_paddr + sizeof(struct stge_rfd) * (i))
112 #define STGE_TX_RING_SZ \
113 (sizeof(struct stge_tfd) * STGE_TX_RING_CNT)
114 #define STGE_RX_RING_SZ \
115 (sizeof(struct stge_rfd) * STGE_RX_RING_CNT)
118 * Software state per device.
121 struct arpcom arpcom;
125 bus_space_handle_t sc_bhandle; /* bus space handle */
126 bus_space_tag_t sc_btag; /* bus space tag */
129 struct resource *sc_res;
132 struct resource *sc_irq;
133 void *sc_ih; /* interrupt cookie */
135 int sc_rev; /* silicon revision */
137 struct callout sc_tick_ch; /* tick callout */
139 struct ifpoll_compat sc_npoll;
140 struct stge_chain_data sc_cdata;
141 struct stge_ring_data sc_rdata;
144 int sc_txthresh; /* Tx threshold */
145 uint32_t sc_usefiber:1; /* if we're fiber */
146 uint32_t sc_stge1023:1; /* are we a 1023 */
147 uint32_t sc_DMACtrl; /* prototype DMACtrl reg. */
148 uint32_t sc_MACCtrl; /* prototype MacCtrl reg. */
149 uint16_t sc_IntEnable; /* prototype IntEnable reg. */
150 uint16_t sc_led; /* LED conf. from EEPROM */
151 uint8_t sc_PhyCtrl; /* prototype PhyCtrl reg. */
156 int sc_rxint_dmawait;
160 #define STGE_MAXERR 5
162 #define STGE_RXCHAIN_RESET(_sc) \
164 (_sc)->sc_cdata.stge_rxhead = NULL; \
165 (_sc)->sc_cdata.stge_rxtail = NULL; \
166 (_sc)->sc_cdata.stge_rxlen = 0; \
167 } while (/*CONSTCOND*/0)
169 #define STGE_TIMEOUT 1000
171 struct stge_mii_frame {
176 uint8_t mii_turnaround;