2 * Copyright (c) 2011 Jason King.
3 * Copyright (c) 2000 Berkeley Software Design, Inc.
4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
44 #define PCN_VENDORID 0x1022
45 #define PCN_DEVICEID_PCNET 0x2000
46 #define PCN_DEVICEID_HOME 0x2001
48 typedef struct pcn_type
{
51 char *pcn_name
; /* ddi_set_prop takes char * */
54 #define PCN_TXRECLAIM 8
55 #define PCN_HEADROOM 34
56 #define PCN_TXRESCHED 120
58 #define PCN_RXSTAT_BAM 0x0008 /* broadcast address match */
59 #define PCN_RXSTAT_LAFM 0x0010 /* logical address filter match */
60 #define PCN_RXSTAT_PAM 0x0020 /* physical address match */
61 #define PCN_RXSTAT_BPE 0x0080 /* bus parity error */
62 #define PCN_RXSTAT_ENP 0x0100 /* end of packet */
63 #define PCN_RXSTAT_STP 0x0200 /* start of packet */
64 #define PCN_RXSTAT_BUFF 0x0400 /* buffer error */
65 #define PCN_RXSTAT_CRC 0x0800 /* CRC error */
66 #define PCN_RXSTAT_OFLOW 0x1000 /* rx overrun */
67 #define PCN_RXSTAT_FRAM 0x2000 /* framing error */
68 #define PCN_RXSTAT_ERR 0x4000 /* error summary */
69 #define PCN_RXSTAT_OWN 0x8000
70 #define PCN_RXSTAT_STR \
85 #define PCN_RXLEN_MBO 0xF000
86 #define PCN_RXLEN_BUFSZ 0x0FFF
88 typedef struct pcn_rx_desc
{
97 typedef struct pcn_tx_desc
{
104 #define PCN_TXCTL_OWN 0x80000000
105 #define PCN_TXCTL_ERR 0x40000000 /* error summary */
106 #define PCN_TXCTL_ADD_FCS 0x20000000 /* add FCS to pkt */
107 #define PCN_TXCTL_MORE_LTINT 0x10000000
108 #define PCN_TXCTL_ONE 0x08000000
109 #define PCN_TXCTL_DEF 0x04000000
110 #define PCN_TXCTL_STP 0x02000000
111 #define PCN_TXCTL_ENP 0x01000000
112 #define PCN_TXCTL_BPE 0x00800000
113 #define PCN_TXCTL_MBO 0x0000F000
114 #define PCN_TXCTL_BUFSZ 0x00000FFF
115 #define PCN_TXCTL_STR \
127 typedef struct pcn_buf
{
129 ddi_dma_handle_t pb_dmah
;
130 ddi_acc_handle_t pb_acch
;
134 /* Constants, do not change */
135 #define PCN_BUFSZ (1664)
136 #define PCN_MCHASH (64)
138 /* Number of descriptor entries */
139 #define PCN_RXRING 64
140 #define PCN_TXRING 256
145 mii_handle_t pcn_mii
;
146 uint16_t pcn_cachesize
;
149 kmutex_t pcn_xmtlock
;
150 kmutex_t pcn_intrlock
;
151 kmutex_t pcn_reglock
;
152 ddi_iblock_cookie_t pcn_icookie
;
155 int8_t pcn_extphyaddr
;
158 * Register and DMA access
161 ddi_acc_handle_t pcn_regshandle
;
164 * Receive descriptors.
167 pcn_rx_desc_t
*pcn_rxdescp
;
168 ddi_dma_handle_t pcn_rxdesc_dmah
;
169 ddi_acc_handle_t pcn_rxdesc_acch
;
170 uint32_t pcn_rxdesc_paddr
;
171 pcn_buf_t
**pcn_rxbufs
;
174 * Transmit descriptors.
179 pcn_tx_desc_t
*pcn_txdescp
;
180 ddi_dma_handle_t pcn_txdesc_dmah
;
181 ddi_acc_handle_t pcn_txdesc_acch
;
182 uint32_t pcn_txdesc_paddr
;
183 pcn_buf_t
**pcn_txbufs
;
184 hrtime_t pcn_txstall_time
;
188 * Address management.
190 uchar_t pcn_addr
[ETHERADDRL
];
191 boolean_t pcn_promisc
;
192 uint16_t pcn_mccount
[PCN_MCHASH
];
193 uint16_t pcn_mctab
[PCN_MCHASH
/ 16];
198 uint64_t pcn_ipackets
;
199 uint64_t pcn_opackets
;
202 uint64_t pcn_brdcstxmt
;
203 uint64_t pcn_multixmt
;
204 uint64_t pcn_brdcstrcv
;
205 uint64_t pcn_multircv
;
206 uint64_t pcn_norcvbuf
;
210 uint64_t pcn_underflow
;
211 uint64_t pcn_overflow
;
212 uint64_t pcn_align_errors
;
213 uint64_t pcn_fcs_errors
;
214 uint64_t pcn_carrier_errors
;
215 uint64_t pcn_collisions
;
216 uint64_t pcn_ex_collisions
;
217 uint64_t pcn_tx_late_collisions
;
218 uint64_t pcn_defer_xmts
;
219 uint64_t pcn_first_collisions
;
220 uint64_t pcn_multi_collisions
;
221 uint64_t pcn_sqe_errors
;
222 uint64_t pcn_macxmt_errors
;
223 uint64_t pcn_macrcv_errors
;
224 uint64_t pcn_toolong_errors
;
230 #define PCN_RUNNING (1L << 0)
231 #define PCN_SUSPENDED (1L << 1)
232 #define PCN_INTR_ENABLED (1L << 2)
233 #define PCN_FLAGSTR \
238 #define IS_RUNNING(p) ((p)->pcn_flags & PCN_RUNNING)
239 #define IS_SUSPENDED(p) ((p)->pcn_flags & PCN_SUSPENDED)
241 #define SYNCTXDESC(pcnp, index, who) \
242 (void) ddi_dma_sync(pcnp->pcn_txdesc_dmah, \
243 (index * sizeof (pcn_tx_desc_t)), sizeof (pcn_tx_desc_t), who)
245 #define SYNCRXDESC(pcnp, index, who) \
246 (void) ddi_dma_sync(pcnp->pcn_rxdesc_dmah, \
247 (index * sizeof (pcn_rx_desc_t)), sizeof (pcn_rx_desc_t), who)
249 #define SYNCBUF(pb, len, who) \
250 (void) ddi_dma_sync(pb->pb_dmah, 0, len, who)
258 #endif /* _PCNIMPL_H */