blob: d1fce450ea04ff15d54aa6e3939004ddc0372cc5 [file] [log] [blame]
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07001/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
gd7805985025c02007-07-12 10:37:47 -07005 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07007 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
Garrett D'Amore02193462009-05-11 21:07:23 -070022 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
gd7805985025c02007-07-12 10:37:47 -070023 * Use is subject to license terms.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070024 */
25
26#ifndef _SYS_HME_H
27#define _SYS_HME_H
28
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070029#ifdef __cplusplus
30extern "C" {
31#endif
32
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070033#ifdef _KERNEL
34
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070035/* default IPG settings */
36#define IPG1 8
37#define IPG2 4
38
39/*
40 * Declarations and definitions specific to the
41 * FEPS 10/100 Mbps Ethernet (hme) device.
42 */
43
44/*
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070045 * Per-Stream instance state information.
46 *
47 * Each instance is dynamically allocated at open() and free'd
48 * at close(). Each per-Stream instance points to at most one
49 * per-device structure using the sb_hmep field. All instances
50 * are threaded together into one list of active instances
51 * ordered on minor device number.
52 */
53
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070054#define HME_2P0_REVID 0xa0 /* hme - feps. */
55#define HME_2P1_REVID 0x20
56#define HME_2P1_REVID_OBP 0x21
57#define HME_1C0_REVID 0xc0 /* cheerio 1.0, hme 2.0 equiv. */
58#define HME_2C0_REVID 0xc1 /* cheerio 2.0, hme 2.2 equiv. */
59#define HME_REV_VERS_MASK 0x0f /* Mask to retain bits for cheerio ver */
60
Garrett D'Amore02193462009-05-11 21:07:23 -070061typedef struct {
62 ddi_dma_handle_t dmah;
63 ddi_acc_handle_t acch;
64 caddr_t kaddr;
65 uint32_t paddr;
66} hmebuf_t;
67
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070068/*
69 * HME Device Channel instance state information.
70 *
71 * Each instance is dynamically allocated on first attach.
72 */
73struct hme {
gd7805985025c02007-07-12 10:37:47 -070074 mac_handle_t hme_mh; /* GLDv3 handle */
Garrett D'Amore06673d92009-10-15 22:31:12 -070075 mii_handle_t hme_mii;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070076 dev_info_t *dip; /* associated dev_info */
77 int instance; /* instance */
78 ulong_t pagesize; /* btop(9F) */
79
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070080 int hme_mifpoll_enable;
81 int hme_frame_enable;
82 int hme_lance_mode_enable;
83 int hme_rxcv_enable;
84
Garrett D'Amore06673d92009-10-15 22:31:12 -070085 uint32_t hme_lance_mode;
86 uint32_t hme_ipg0;
87 uint32_t hme_ipg1;
88 uint32_t hme_ipg2;
89
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070090 uint_t hme_burstsizes; /* binary encoded val */
91 uint32_t hme_config; /* Config reg store */
92
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070093 int hme_phy_failure; /* phy failure type */
94
95 int hme_64bit_xfer; /* 64-bit Sbus xfers */
96 int hme_phyad;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070097
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070098 int hme_nlasttries;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070099 int hme_cheerio_mode;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700100
101 struct ether_addr hme_factaddr; /* factory mac address */
102 struct ether_addr hme_ouraddr; /* individual address */
103 uint32_t hme_addrflags; /* address flags */
104 uint32_t hme_flags; /* misc. flags */
gd7805985025c02007-07-12 10:37:47 -0700105 boolean_t hme_wantw; /* xmit: out of resources */
gd78059228fdff2007-08-23 20:40:28 -0700106 boolean_t hme_started; /* mac layer started */
gd7805985025c02007-07-12 10:37:47 -0700107
Garrett D'Amore02193462009-05-11 21:07:23 -0700108 uint8_t hme_devno;
109
gd7805985025c02007-07-12 10:37:47 -0700110 uint16_t hme_ladrf[4]; /* 64 bit multicast filter */
111 uint32_t hme_ladrf_refcnt[64];
112 boolean_t hme_promisc;
113 uint32_t hme_multi; /* refcount on mcast addrs */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700114
Garrett D'Amore02193462009-05-11 21:07:23 -0700115 struct hme_global *hme_globregp; /* HME global regs */
116 struct hme_etx *hme_etxregp; /* HME ETX regs */
117 struct hme_erx *hme_erxregp; /* HME ERX regs */
118 struct hme_bmac *hme_bmacregp; /* BigMAC registers */
119 struct hme_mif *hme_mifregp; /* HME transceiver */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700120 unsigned char *hme_romp; /* fcode rom pointer */
121
122 kmutex_t hme_xmitlock; /* protect xmit-side fields */
123 kmutex_t hme_intrlock; /* protect intr-side fields */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700124 ddi_iblock_cookie_t hme_cookie; /* interrupt cookie */
125
126 struct hme_rmd *hme_rmdp; /* receive descriptor ring start */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700127 struct hme_tmd *hme_tmdp; /* transmit descriptor ring start */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700128
Garrett D'Amore02193462009-05-11 21:07:23 -0700129 ddi_dma_handle_t hme_rmd_dmah;
130 ddi_acc_handle_t hme_rmd_acch;
131 caddr_t hme_rmd_kaddr;
132 uint32_t hme_rmd_paddr;
133
134 ddi_dma_handle_t hme_tmd_dmah;
135 ddi_acc_handle_t hme_tmd_acch;
136 caddr_t hme_tmd_kaddr;
137 uint32_t hme_tmd_paddr;
138
139 uint64_t hme_rxindex;
140 uint64_t hme_txindex;
141 uint64_t hme_txreclaim;
142
143 hmebuf_t *hme_tbuf; /* hmebuf associated with TMD */
144 hmebuf_t *hme_rbuf; /* hmebuf associated with RMD */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700145
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700146 ddi_device_acc_attr_t hme_dev_attr;
147 ddi_acc_handle_t hme_globregh; /* HME global regs */
148 ddi_acc_handle_t hme_etxregh; /* HME ETX regs */
149 ddi_acc_handle_t hme_erxregh; /* HME ERX regs */
150 ddi_acc_handle_t hme_bmacregh; /* BigMAC registers */
151 ddi_acc_handle_t hme_mifregh; /* HME transceiver */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700152 ddi_acc_handle_t hme_romh; /* rom handle */
153
154 ddi_acc_handle_t pci_config_handle; /* HME PCI config */
155
156 /*
157 * DDI dma handle, kernel virtual base,
158 * and io virtual base of IOPB area.
159 */
160 ddi_dma_handle_t hme_iopbhandle;
161 ulong_t hme_iopbkbase;
Garrett D'Amore02193462009-05-11 21:07:23 -0700162 uint32_t hme_iopbiobase;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700163
164 kstat_t *hme_ksp; /* kstat pointer */
165 kstat_t *hme_intrstats; /* kstat interrupt counter */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700166
gd7805985025c02007-07-12 10:37:47 -0700167 uint64_t hme_ipackets;
168 uint64_t hme_rbytes;
169 uint64_t hme_ierrors;
170 uint64_t hme_opackets;
171 uint64_t hme_obytes;
172 uint64_t hme_oerrors;
173 uint64_t hme_multircv; /* # multicast packets received */
174 uint64_t hme_multixmt; /* # multicast packets for xmit */
175 uint64_t hme_brdcstrcv; /* # broadcast packets received */
176 uint64_t hme_brdcstxmt; /* # broadcast packets for xmit */
177 uint64_t hme_oflo;
178 uint64_t hme_uflo;
179 uint64_t hme_norcvbuf; /* # rcv packets discarded */
180 uint64_t hme_noxmtbuf; /* # xmit packets discarded */
181 uint64_t hme_duplex;
182 uint64_t hme_align_errors;
183 uint64_t hme_coll;
184 uint64_t hme_fcs_errors;
185 uint64_t hme_defer_xmts;
186 uint64_t hme_sqe_errors;
187 uint64_t hme_excol;
188 uint64_t hme_fstcol;
189 uint64_t hme_tlcol;
190 uint64_t hme_toolong_errors;
191 uint64_t hme_runt;
gd780594dd87b62008-03-20 20:18:47 -0700192 uint64_t hme_carrier_errors;
gd7805985025c02007-07-12 10:37:47 -0700193 uint64_t hme_jab;
194
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700195 uint32_t hme_cvc;
196 uint32_t hme_lenerr;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700197 uint32_t hme_buff;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700198 uint32_t hme_missed;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700199 uint32_t hme_nocanput;
200 uint32_t hme_allocbfail;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700201 uint32_t hme_babl;
202 uint32_t hme_tmder;
203 uint32_t hme_txlaterr;
204 uint32_t hme_rxlaterr;
205 uint32_t hme_slvparerr;
206 uint32_t hme_txparerr;
207 uint32_t hme_rxparerr;
208 uint32_t hme_slverrack;
209 uint32_t hme_txerrack;
210 uint32_t hme_rxerrack;
211 uint32_t hme_txtagerr;
212 uint32_t hme_rxtagerr;
213 uint32_t hme_eoperr;
214 uint32_t hme_notmds;
215 uint32_t hme_notbufs;
216 uint32_t hme_norbufs;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700217
218 /*
219 * check if transmitter is hung
220 */
221 uint32_t hme_starts;
222 uint32_t hme_txhung;
223 time_t hme_msg_time;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700224
225 /*
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700226 * Debuging kstats
227 */
228 uint32_t inits;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700229 uint32_t phyfail;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700230 uint32_t asic_rev;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700231};
232
233/* flags */
234#define HMERUNNING 0x01 /* chip is initialized */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700235#define HMESUSPENDED 0x08 /* suspended interface */
236#define HMEINITIALIZED 0x10 /* interface initialized */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700237
238/* Mac address flags */
239
240#define HME_FACTADDR_PRESENT 0x01 /* factory MAC id present */
241#define HME_FACTADDR_USE 0x02 /* use factory MAC id */
242
243struct hmekstat {
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700244 struct kstat_named hk_cvc; /* code violation errors */
245 struct kstat_named hk_lenerr; /* rx len errors */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700246 struct kstat_named hk_buff; /* buff errors */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700247 struct kstat_named hk_missed; /* missed/dropped packets */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700248 struct kstat_named hk_nocanput; /* nocanput errors */
249 struct kstat_named hk_allocbfail; /* allocb failures */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700250 struct kstat_named hk_babl; /* runt errors */
251 struct kstat_named hk_tmder; /* tmd errors */
252 struct kstat_named hk_txlaterr; /* tx late errors */
253 struct kstat_named hk_rxlaterr; /* rx late errors */
254 struct kstat_named hk_slvparerr; /* slave parity errors */
255 struct kstat_named hk_txparerr; /* tx parity errors */
256 struct kstat_named hk_rxparerr; /* rx parity errors */
257 struct kstat_named hk_slverrack; /* slave error acks */
258 struct kstat_named hk_txerrack; /* tx error acks */
259 struct kstat_named hk_rxerrack; /* rx error acks */
260 struct kstat_named hk_txtagerr; /* tx tag error */
261 struct kstat_named hk_rxtagerr; /* rx tag error */
262 struct kstat_named hk_eoperr; /* eop error */
263 struct kstat_named hk_notmds; /* tmd errors */
264 struct kstat_named hk_notbufs; /* tx buf errors */
265 struct kstat_named hk_norbufs; /* rx buf errors */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700266
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700267 struct kstat_named hk_inits; /* global inits */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700268 struct kstat_named hk_phyfail; /* phy failures */
269
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700270 struct kstat_named hk_asic_rev; /* asic_rev */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700271};
272
273#define HMEDRAINTIME (400000) /* # microseconds xmit drain */
274
275#define ROUNDUP(a, n) (((a) + ((n) - 1)) & ~((n) - 1))
276#define ROUNDUP2(a, n) (uchar_t *)((((uintptr_t)(a)) + ((n) - 1)) & ~((n) - 1))
277
278/*
279 * Xmit/receive buffer structure.
280 * This structure is organized to meet the following requirements:
281 * - bb_buf starts on an HMEBURSTSIZE boundary.
282 * - hmebuf is an even multiple of HMEBURSTSIZE
gd7805985025c02007-07-12 10:37:47 -0700283 * - bb_buf[] is large enough to contain max VLAN frame (1522) plus
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700284 * (3 x HMEBURSTSIZE) rounded up to the next HMEBURSTSIZE
285 * XXX What about another 128 bytes (HMEC requirement).
286 * Fast aligned copy requires both the source and destination
287 * addresses have the same offset from some N-byte boundary.
288 */
289#define HMEBURSTSIZE (64)
290#define HMEBURSTMASK (HMEBURSTSIZE - 1)
291#define HMEBUFSIZE (1728)
292
293/*
294 * Define offset from start of bb_buf[] to point receive descriptor.
295 * Requirements:
296 * - must be 14 bytes back of a 4-byte boundary so the start of
297 * the network packet is 4-byte aligned.
298 * - leave some headroom for others
299 */
300#define HMEHEADROOM (34)
301
302/* Offset for the first byte in the receive buffer */
303#define HME_FSTBYTE_OFFSET 2
304
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700305#endif /* _KERNEL */
306
307#ifdef __cplusplus
308}
309#endif
310
311#endif /* _SYS_HME_H */