2 * Copyright (c) 1999,2000,2001 Jonathan Lemon
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sys/dev/gx/if_gxvar.h,v 1.1.2.1 2001/11/15 03:09:23 jlemon Exp $
30 * $DragonFly: src/sys/dev/netif/gx/Attic/if_gxvar.h,v 1.4 2005/02/21 18:40:36 joerg Exp $
33 #if defined(__DragonFly__) || __FreeBSD_version < 500000
36 #define mtx_init(a, b, c)
37 #define mtx_destroy(a)
38 struct mtx { int filler; };
40 #define GX_LOCK(gx) mtx_lock(&(gx)->gx_mtx)
41 #define GX_UNLOCK(gx) mtx_unlock(&(gx)->gx_mtx)
46 #define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
49 #ifndef PCIM_CMD_MWIEN
50 #define PCIM_CMD_MWIEN 0x0010
55 /* CSR_WRITE_8 assumes the register is in low/high order */
56 #define CSR_WRITE_8(gx, reg, val) do { \
57 bus_space_write_4(gx->gx_btag, gx->gx_bhandle, reg, val & 0xffffffff); \
58 bus_space_write_4(gx->gx_btag, gx->gx_bhandle, reg + 4, val >> 32); \
60 #define CSR_WRITE_4(gx, reg, val) \
61 bus_space_write_4(gx->gx_btag, gx->gx_bhandle, reg, val)
62 #define CSR_WRITE_2(gx, reg, val) \
63 bus_space_write_2(gx->gx_btag, gx->gx_bhandle, reg, val)
64 #define CSR_WRITE_1(gx, reg, val) \
65 bus_space_write_1(gx->gx_btag, gx->gx_bhandle, reg, val)
67 #define CSR_READ_4(gx, reg) \
68 bus_space_read_4(gx->gx_btag, gx->gx_bhandle, reg)
69 #define CSR_READ_2(gx, reg) \
70 bus_space_read_2(gx->gx_btag, gx->gx_bhandle, reg)
71 #define CSR_READ_1(gx, reg) \
72 bus_space_read_1(gx->gx_btag, gx->gx_bhandle, reg)
74 #define GX_SETBIT(gx, reg, x) \
75 CSR_WRITE_4(gx, reg, (CSR_READ_4(gx, reg) | (x)))
76 #define GX_CLRBIT(gx, reg, x) \
77 CSR_WRITE_4(gx, reg, (CSR_READ_4(gx, reg) & ~(x)))
80 * In theory, these can go up to 64K each, but due to chip bugs,
81 * they are limited to 256 max. Descriptor counts should be a
84 #define GX_TX_RING_CNT 256
85 #define GX_RX_RING_CNT 256
87 #define GX_INC(x, y) (x) = (x + 1) % y
88 #define GX_PREV(x, y) (x == 0 ? y - 1 : x - 1)
90 #define GX_MAX_MTU (16 * 1024)
93 struct gx_rx_desc gx_rx_ring[GX_RX_RING_CNT];
94 struct gx_tx_desc gx_tx_ring[GX_TX_RING_CNT];
97 struct gx_chain_data {
98 struct mbuf *gx_rx_chain[GX_RX_RING_CNT];
99 struct mbuf *gx_tx_chain[GX_TX_RING_CNT];
119 struct arpcom arpcom; /* interface info */
120 struct ifmedia gx_media; /* media info */
121 bus_space_handle_t gx_bhandle; /* bus space handle */
122 bus_space_tag_t gx_btag; /* bus space tag */
123 void *gx_intrhand; /* irq handler handle */
124 struct resource *gx_irq; /* IRQ resource handle */
125 struct resource *gx_res; /* I/O or shared mem handle */
128 u_int8_t gx_unit; /* controller number */
129 u_int8_t gx_tbimode; /* transceiver flag */
130 int gx_vflags; /* version-specific flags */
131 u_int32_t gx_ipg; /* version-specific IPG */
132 struct gx_ring_data *gx_rdata;
133 struct gx_chain_data gx_cdata;
135 struct mbuf *gx_pkthdr;
136 struct mbuf **gx_pktnextp;
137 int gx_rx_tail_idx; /* receive ring tail index */
138 int gx_tx_tail_idx; /* transmit ring tail index */
139 int gx_tx_head_idx; /* transmit ring tail index */
141 int gx_txcontext; /* current TX context */
142 struct gx_regs gx_reg;
146 int gx_tx_intr_delay;
147 int gx_rx_intr_delay;
150 int gx_tx_interrupts;
151 int gx_rx_interrupts;
156 * flags to compensate for differing chip variants
158 #define GXF_FORCE_TBI 0x0001 /* force TBI mode on */
159 #define GXF_DMA 0x0002 /* has DMA control registers */
160 #define GXF_ENABLE_MWI 0x0004 /* supports MWI burst mode */
161 #define GXF_OLD_REGS 0x0008 /* use old register mapping */
162 #define GXF_CSUM 0x0010 /* hardware checksum offload */
165 * TX Context definitions.
167 #define GX_TXCONTEXT_NONE 0
168 #define GX_TXCONTEXT_TCPIP 1
169 #define GX_TXCONTEXT_UDPIP 2