SSID: Respect ASCII character Label.
[tomato.git] / release / src / et / sys / etc.h
blob528b437fa5474704e2afe11df785c11a89ea7e3e
1 /*
2 * Common [OS-independent] header file for
3 * Broadcom BCM47XX 10/100Mbps Ethernet Device Driver
5 * Copyright 2006, Broadcom Corporation
6 * All Rights Reserved.
7 *
8 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
9 * the contents of this file may not be disclosed to third parties, copied
10 * or duplicated in any form, in whole or in part, without the prior
11 * written permission of Broadcom Corporation.
13 * $Id: etc.h,v 1.1.1.1 2007/03/20 12:22:00 roly Exp $
16 #ifndef _etc_h_
17 #define _etc_h_
19 #include <etioctl.h>
21 #define MAXMULTILIST 32
23 #ifndef ch_t
24 #define ch_t void
25 #endif
27 struct etc_info; /* forward declaration */
28 struct bcmstrbuf; /* forward declaration */
30 /* each chip type supports a set of chip-type-specific ops */
31 struct chops {
32 bool (*id)(uint vendor, uint device); /* return true if match */
33 void *(*attach)(struct etc_info *etc, void *dev, void *regs);
34 void (*detach)(ch_t *ch); /* free chip private state */
35 void (*reset)(ch_t *ch); /* chip reset */
36 void (*init)(ch_t *ch, bool full); /* chip init */
37 bool (*tx)(ch_t *ch, void *p); /* transmit frame */
38 void *(*rx)(ch_t *ch); /* receive frame */
39 void (*rxfill)(ch_t *ch); /* post dma rx buffers */
40 int (*getintrevents)(ch_t *ch, bool in_isr); /* return intr events */
41 bool (*errors)(ch_t *ch); /* handle chip errors */
42 void (*intrson)(ch_t *ch); /* enable chip interrupts */
43 void (*intrsoff)(ch_t *ch); /* disable chip interrupts */
44 void (*txreclaim)(ch_t *ch, bool all); /* reclaim transmit resources */
45 void (*rxreclaim)(ch_t *ch); /* reclaim receive resources */
46 void (*statsupd)(ch_t *ch); /* update sw stat counters */
47 void (*enablepme)(ch_t *ch); /* enable PME */
48 void (*disablepme)(ch_t *ch); /* disable PME */
49 void (*phyreset)(ch_t *ch, uint phyaddr); /* reset phy */
50 uint16 (*phyrd)(ch_t *ch, uint phyaddr, uint reg); /* read phy register */
51 void (*phywr)(ch_t *ch, uint phyaddr, uint reg, uint16 val); /* write phy register */
52 void (*dump)(ch_t *ch, struct bcmstrbuf *b); /* debugging output */
53 void (*longname)(ch_t *ch, char *buf, uint bufsize); /* return descriptive name */
54 void (*duplexupd)(ch_t *ch); /* keep mac duplex consistent */
58 * "Common" os-independent software state structure.
60 typedef struct etc_info {
61 void *et; /* pointer to os-specific private state */
62 uint unit; /* device instance number */
63 void *osh; /* pointer to os handler */
64 bool up; /* interface up and running */
65 bool promisc; /* promiscuous destination address */
66 bool qos; /* QoS priority determination on rx */
67 bool loopbk; /* loopback override mode */
69 int forcespeed; /* disable autonegotiation and force speed/duplex */
70 uint advertise; /* control speed/duplex advertised capability bits */
71 bool needautoneg; /* request restart autonegotiation */
72 int speed; /* current speed: 10, 100 */
73 int duplex; /* current duplex: 0=half, 1=full */
75 bool piomode; /* enable programmed io (!dma) */
76 void *pioactive; /* points to pio packet being transmitted */
77 volatile uint *txavail; /* dma: # tx descriptors available */
79 uint16 vendorid; /* pci function vendor id */
80 uint16 deviceid; /* pci function device id */
81 uint chip; /* chip number */
82 uint chiprev; /* chip revision */
84 bool nicmode; /* is this core using its own pci i/f */
86 struct chops *chops; /* pointer to chip-specific opsvec */
87 void *ch; /* pointer to chip-specific state */
88 void *robo; /* optional robo private data */
90 uint coreunit; /* sb chips: chip enet instance # */
91 uint phyaddr; /* sb chips: mdio 5-bit phy address */
92 uint mdcport; /* sb chips: which mii to use (enet core #) to access phy */
94 struct ether_addr cur_etheraddr; /* our local ethernet address */
95 struct ether_addr perm_etheraddr; /* original sprom local ethernet address */
97 struct ether_addr multicast[MAXMULTILIST];
98 uint nmulticast;
99 bool allmulti; /* enable all multicasts */
101 bool linkstate; /* link integrity state */
102 bool pm_modechange; /* true if mode change is to due pm */
104 uint32 now; /* elapsed seconds */
106 uint32 boardflags; /* board flags */
108 /* chip-maintained plus a few sw-maintained stat counters */
109 bcmenetmib_t mib; /* mib statistic counters */
110 uint32 txframe; /* transmitted frames */
111 uint32 txbyte; /* transmitted bytes */
112 uint32 rxframe; /* received frames */
113 uint32 rxbyte; /* received bytes */
114 uint32 txerror; /* total tx errors */
115 uint32 txnobuf; /* tx out-of-buffer errors */
116 uint32 rxerror; /* total rx errors */
117 uint32 rxnobuf; /* rx out-of-buffer errors */
118 uint32 reset; /* reset count */
119 uint32 dmade; /* pci descriptor errors */
120 uint32 dmada; /* pci data errors */
121 uint32 dmape; /* descriptor protocol error */
122 uint32 rxdmauflo; /* receive descriptor underflow */
123 uint32 rxoflo; /* receive fifo overflow */
124 uint32 txuflo; /* transmit fifo underflow */
125 uint32 rxbadlen; /* 802.3 len field != read length */
126 } etc_info_t;
128 /* interrupt event bitvec */
129 #define INTR_TX 0x1
130 #define INTR_RX 0x2
131 #define INTR_ERROR 0x4
132 #define INTR_TO 0x8
133 #define INTR_NEW 0x10
135 /* forcespeed values */
136 #define ET_AUTO -1
137 #define ET_10HALF 0
138 #define ET_10FULL 1
139 #define ET_100HALF 2
140 #define ET_100FULL 3
143 * Least-common denominator rxbuf start-of-data offset:
144 * Must be >= size of largest rxhdr
145 * Must be 2-mod-4 aligned so IP is 0-mod-4
147 #define HWRXOFF 30
149 /* exported prototypes */
150 extern struct chops *etc_chipmatch(uint vendor, uint device);
151 extern void *etc_attach(void *et, uint vendor, uint device, uint unit, void *dev, void *regsva);
152 extern void etc_detach(etc_info_t *etc);
153 extern void etc_reset(etc_info_t *etc);
154 extern void etc_init(etc_info_t *etc);
155 extern void etc_up(etc_info_t *etc);
156 extern uint etc_down(etc_info_t *etc, int reset);
157 extern int etc_ioctl(etc_info_t *etc, int cmd, void *arg);
158 extern void etc_promisc(etc_info_t *etc, uint on);
159 extern void etc_qos(etc_info_t *etc, uint on);
160 extern void etc_dump(etc_info_t *etc, struct bcmstrbuf *b);
161 extern void etc_watchdog(etc_info_t *etc);
162 extern uint etc_totlen(etc_info_t *etc, void *p);
164 #endif /* _etc_h_ */