1 /*
2 * Copyright (c) 2005 by David E. O'Brien <obrien@FreeBSD.org>.
3 * Copyright (c) 2003 by Quinton Dolan <q@onthenet.com.au>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $Id: if_nvreg.h,v 1.6 2004/08/12 14:00:05 q Exp $
28 * $FreeBSD: releng/6.1/sys/dev/nve/if_nvereg.h 153359 2005-12-12 19:40:04Z jhb $
29 */
30
31 #ifndef _IF_NVEREG_H_
32 #define _IF_NVEREG_H_
33
34 #ifndef NVIDIA_VENDORID
35 #define NVIDIA_VENDORID 0x10DE
36 #endif
37
38 #define NFORCE_MCPNET1_DEVICEID 0x01C3
39 #define NFORCE_MCPNET2_DEVICEID 0x0066
40 #define NFORCE_MCPNET3_DEVICEID 0x00D6
41 #define NFORCE_MCPNET4_DEVICEID 0x0086
42 #define NFORCE_MCPNET5_DEVICEID 0x008C
43 #define NFORCE_MCPNET6_DEVICEID 0x00E6
44 #define NFORCE_MCPNET7_DEVICEID 0x00DF
45 #define NFORCE_MCPNET8_DEVICEID 0x0056
46 #define NFORCE_MCPNET9_DEVICEID 0x0057
47 #define NFORCE_MCPNET10_DEVICEID 0x0037
48 #define NFORCE_MCPNET11_DEVICEID 0x0038
49
50 #define NV_RID 0x10
51
52 #define TX_RING_SIZE 64
53 #define RX_RING_SIZE 64
54 #define NV_MAX_FRAGS 63
55
56 #define FCS_LEN 4
57
58 #define NVE_DEBUG 0x0000
59 #define NVE_DEBUG_INIT 0x0001
60 #define NVE_DEBUG_RUNNING 0x0002
61 #define NVE_DEBUG_DEINIT 0x0004
62 #define NVE_DEBUG_IOCTL 0x0008
63 #define NVE_DEBUG_INTERRUPT 0x0010
64 #define NVE_DEBUG_API 0x0020
65 #define NVE_DEBUG_LOCK 0x0040
66 #define NVE_DEBUG_BROKEN 0x0080
67 #define NVE_DEBUG_MII 0x0100
68 #define NVE_DEBUG_ALL 0xFFFF
69
70 #if NVE_DEBUG
71 #define DEBUGOUT(level, fmt, args...) if (NVE_DEBUG & level) \
72 printf(fmt, ## args)
73 #else
74 #define DEBUGOUT(level, fmt, args...)
75 #endif
76
77 typedef unsigned long ulong;
78
79 struct nve_map_buffer {
80 struct mbuf *mbuf; /* mbuf receiving packet */
81 bus_dmamap_t map; /* DMA map */
82 };
83
84 struct nve_dma_info {
85 bus_dma_tag_t tag;
86 struct nve_map_buffer buf;
87 u_int16_t buflength;
88 caddr_t vaddr; /* Virtual memory address */
89 bus_addr_t paddr; /* DMA physical address */
90 };
91
92 struct nve_rx_desc {
93 struct nve_rx_desc *next;
94 struct nve_map_buffer buf;
95 u_int16_t buflength;
96 caddr_t vaddr;
97 bus_addr_t paddr;
98 };
99
100 struct nve_tx_desc {
101 /* Don't add anything above this structure */
102 TX_INFO_ADAP TxInfoAdap;
103 struct nve_tx_desc *next;
104 struct nve_map_buffer buf;
105 u_int16_t buflength;
106 u_int32_t numfrags;
107 bus_dma_segment_t frags[NV_MAX_FRAGS + 1];
108 };
109
110 struct nve_softc {
111 struct ifnet *ifp; /* interface info */
112 struct resource *res;
113 struct resource *irq;
114
115 ADAPTER_API *hwapi;
116 OS_API osapi;
117
118 device_t miibus;
119 device_t dev;
120 struct callout stat_callout;
121
122 void *sc_ih;
123 bus_space_tag_t sc_st;
124 bus_space_handle_t sc_sh;
125 bus_dma_tag_t mtag;
126 bus_dma_tag_t rtag;
127 bus_dmamap_t rmap;
128 bus_dma_tag_t ttag;
129 bus_dmamap_t tmap;
130
131 struct nve_rx_desc *rx_desc;
132 struct nve_tx_desc *tx_desc;
133 bus_addr_t rx_addr;
134 bus_addr_t tx_addr;
135 u_int16_t rx_ring_full;
136 u_int16_t tx_ring_full;
137 u_int32_t cur_rx;
138 u_int32_t cur_tx;
139 u_int32_t pending_rxs;
140 u_int32_t pending_txs;
141
142 struct mtx mtx;
143
144 /* Stuff for dealing with the NVIDIA OS API */
145 struct callout ostimer;
146 PTIMER_FUNC ostimer_func;
147 void *ostimer_params;
148 int linkup;
149 ulong tx_errors;
150 NV_UINT32 hwmode;
151 NV_UINT32 max_frame_size;
152 NV_UINT32 phyaddr;
153 NV_UINT32 media;
154 CMNDATA_OS_ADAPTER adapterdata;
155 unsigned char original_mac_addr[6];
156 };
157
158 struct nve_type {
159 u_int16_t vid_id;
160 u_int16_t dev_id;
161 char *name;
162 };
163
164 #define NVE_LOCK(_sc) mtx_lock(&(_sc)->mtx)
165 #define NVE_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
166 #define NVE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED)
167
168 #define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */
169 #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */
170 #define ETHER_ALIGN 2
171
172 extern int ADAPTER_ReadPhy (PVOID pContext, ULONG ulPhyAddr, ULONG ulReg, ULONG *pulVal);
173 extern int ADAPTER_WritePhy (PVOID pContext, ULONG ulPhyAddr, ULONG ulReg, ULONG ulVal);
174 extern int ADAPTER_Init (PVOID pContext, USHORT usForcedSpeed, UCHAR ucForceDpx, UCHAR ucForceMode, UINT *puiLinkState);
175
176 #endif /* _IF_NVEREG_H_ */
Cache object: c097ec3de183ae15c5116ef37ba879ff
|