ia64/linux-2.6.18-xen.hg

annotate drivers/net/via-velocity.h @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
ian@0 3 * All rights reserved.
ian@0 4 *
ian@0 5 * This software may be redistributed and/or modified under
ian@0 6 * the terms of the GNU General Public License as published by the Free
ian@0 7 * Software Foundation; either version 2 of the License, or
ian@0 8 * any later version.
ian@0 9 *
ian@0 10 * This program is distributed in the hope that it will be useful, but
ian@0 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
ian@0 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ian@0 13 * for more details.
ian@0 14 *
ian@0 15 * File: via-velocity.h
ian@0 16 *
ian@0 17 * Purpose: Header file to define driver's private structures.
ian@0 18 *
ian@0 19 * Author: Chuang Liang-Shing, AJ Jiang
ian@0 20 *
ian@0 21 * Date: Jan 24, 2003
ian@0 22 */
ian@0 23
ian@0 24
ian@0 25 #ifndef VELOCITY_H
ian@0 26 #define VELOCITY_H
ian@0 27
ian@0 28 #define VELOCITY_TX_CSUM_SUPPORT
ian@0 29
ian@0 30 #define VELOCITY_NAME "via-velocity"
ian@0 31 #define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
ian@0 32 #define VELOCITY_VERSION "1.13"
ian@0 33
ian@0 34 #define VELOCITY_IO_SIZE 256
ian@0 35
ian@0 36 #define PKT_BUF_SZ 1540
ian@0 37
ian@0 38 #define MAX_UNITS 8
ian@0 39 #define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1}
ian@0 40
ian@0 41 #define REV_ID_VT6110 (0)
ian@0 42
ian@0 43 #define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0)
ian@0 44 #define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0)
ian@0 45 #define DWORD_REG_BITS_ON(x,p) do { writel(readl((p))|(x),(p));} while (0)
ian@0 46
ian@0 47 #define BYTE_REG_BITS_IS_ON(x,p) (readb((p)) & (x))
ian@0 48 #define WORD_REG_BITS_IS_ON(x,p) (readw((p)) & (x))
ian@0 49 #define DWORD_REG_BITS_IS_ON(x,p) (readl((p)) & (x))
ian@0 50
ian@0 51 #define BYTE_REG_BITS_OFF(x,p) do { writeb(readb((p)) & (~(x)),(p));} while (0)
ian@0 52 #define WORD_REG_BITS_OFF(x,p) do { writew(readw((p)) & (~(x)),(p));} while (0)
ian@0 53 #define DWORD_REG_BITS_OFF(x,p) do { writel(readl((p)) & (~(x)),(p));} while (0)
ian@0 54
ian@0 55 #define BYTE_REG_BITS_SET(x,m,p) do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0)
ian@0 56 #define WORD_REG_BITS_SET(x,m,p) do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0)
ian@0 57 #define DWORD_REG_BITS_SET(x,m,p) do { writel( (readl((p)) & (~(m)))|(x),(p));} while (0)
ian@0 58
ian@0 59 #define VAR_USED(p) do {(p)=(p);} while (0)
ian@0 60
ian@0 61 /*
ian@0 62 * Purpose: Structures for MAX RX/TX descriptors.
ian@0 63 */
ian@0 64
ian@0 65
ian@0 66 #define B_OWNED_BY_CHIP 1
ian@0 67 #define B_OWNED_BY_HOST 0
ian@0 68
ian@0 69 /*
ian@0 70 * Bits in the RSR0 register
ian@0 71 */
ian@0 72
ian@0 73 #define RSR_DETAG 0x0080
ian@0 74 #define RSR_SNTAG 0x0040
ian@0 75 #define RSR_RXER 0x0020
ian@0 76 #define RSR_RL 0x0010
ian@0 77 #define RSR_CE 0x0008
ian@0 78 #define RSR_FAE 0x0004
ian@0 79 #define RSR_CRC 0x0002
ian@0 80 #define RSR_VIDM 0x0001
ian@0 81
ian@0 82 /*
ian@0 83 * Bits in the RSR1 register
ian@0 84 */
ian@0 85
ian@0 86 #define RSR_RXOK 0x8000 // rx OK
ian@0 87 #define RSR_PFT 0x4000 // Perfect filtering address match
ian@0 88 #define RSR_MAR 0x2000 // MAC accept multicast address packet
ian@0 89 #define RSR_BAR 0x1000 // MAC accept broadcast address packet
ian@0 90 #define RSR_PHY 0x0800 // MAC accept physical address packet
ian@0 91 #define RSR_VTAG 0x0400 // 802.1p/1q tagging packet indicator
ian@0 92 #define RSR_STP 0x0200 // start of packet
ian@0 93 #define RSR_EDP 0x0100 // end of packet
ian@0 94
ian@0 95 /*
ian@0 96 * Bits in the RSR1 register
ian@0 97 */
ian@0 98
ian@0 99 #define RSR1_RXOK 0x80 // rx OK
ian@0 100 #define RSR1_PFT 0x40 // Perfect filtering address match
ian@0 101 #define RSR1_MAR 0x20 // MAC accept multicast address packet
ian@0 102 #define RSR1_BAR 0x10 // MAC accept broadcast address packet
ian@0 103 #define RSR1_PHY 0x08 // MAC accept physical address packet
ian@0 104 #define RSR1_VTAG 0x04 // 802.1p/1q tagging packet indicator
ian@0 105 #define RSR1_STP 0x02 // start of packet
ian@0 106 #define RSR1_EDP 0x01 // end of packet
ian@0 107
ian@0 108 /*
ian@0 109 * Bits in the CSM register
ian@0 110 */
ian@0 111
ian@0 112 #define CSM_IPOK 0x40 //IP Checkusm validatiaon ok
ian@0 113 #define CSM_TUPOK 0x20 //TCP/UDP Checkusm validatiaon ok
ian@0 114 #define CSM_FRAG 0x10 //Fragment IP datagram
ian@0 115 #define CSM_IPKT 0x04 //Received an IP packet
ian@0 116 #define CSM_TCPKT 0x02 //Received a TCP packet
ian@0 117 #define CSM_UDPKT 0x01 //Received a UDP packet
ian@0 118
ian@0 119 /*
ian@0 120 * Bits in the TSR0 register
ian@0 121 */
ian@0 122
ian@0 123 #define TSR0_ABT 0x0080 // Tx abort because of excessive collision
ian@0 124 #define TSR0_OWT 0x0040 // Jumbo frame Tx abort
ian@0 125 #define TSR0_OWC 0x0020 // Out of window collision
ian@0 126 #define TSR0_COLS 0x0010 // experience collision in this transmit event
ian@0 127 #define TSR0_NCR3 0x0008 // collision retry counter[3]
ian@0 128 #define TSR0_NCR2 0x0004 // collision retry counter[2]
ian@0 129 #define TSR0_NCR1 0x0002 // collision retry counter[1]
ian@0 130 #define TSR0_NCR0 0x0001 // collision retry counter[0]
ian@0 131 #define TSR0_TERR 0x8000 //
ian@0 132 #define TSR0_FDX 0x4000 // current transaction is serviced by full duplex mode
ian@0 133 #define TSR0_GMII 0x2000 // current transaction is serviced by GMII mode
ian@0 134 #define TSR0_LNKFL 0x1000 // packet serviced during link down
ian@0 135 #define TSR0_SHDN 0x0400 // shutdown case
ian@0 136 #define TSR0_CRS 0x0200 // carrier sense lost
ian@0 137 #define TSR0_CDH 0x0100 // AQE test fail (CD heartbeat)
ian@0 138
ian@0 139 /*
ian@0 140 * Bits in the TSR1 register
ian@0 141 */
ian@0 142
ian@0 143 #define TSR1_TERR 0x80 //
ian@0 144 #define TSR1_FDX 0x40 // current transaction is serviced by full duplex mode
ian@0 145 #define TSR1_GMII 0x20 // current transaction is serviced by GMII mode
ian@0 146 #define TSR1_LNKFL 0x10 // packet serviced during link down
ian@0 147 #define TSR1_SHDN 0x04 // shutdown case
ian@0 148 #define TSR1_CRS 0x02 // carrier sense lost
ian@0 149 #define TSR1_CDH 0x01 // AQE test fail (CD heartbeat)
ian@0 150
ian@0 151 //
ian@0 152 // Bits in the TCR0 register
ian@0 153 //
ian@0 154 #define TCR0_TIC 0x80 // assert interrupt immediately while descriptor has been send complete
ian@0 155 #define TCR0_PIC 0x40 // priority interrupt request, INA# is issued over adaptive interrupt scheme
ian@0 156 #define TCR0_VETAG 0x20 // enable VLAN tag
ian@0 157 #define TCR0_IPCK 0x10 // request IP checksum calculation.
ian@0 158 #define TCR0_UDPCK 0x08 // request UDP checksum calculation.
ian@0 159 #define TCR0_TCPCK 0x04 // request TCP checksum calculation.
ian@0 160 #define TCR0_JMBO 0x02 // indicate a jumbo packet in GMAC side
ian@0 161 #define TCR0_CRC 0x01 // disable CRC generation
ian@0 162
ian@0 163 #define TCPLS_NORMAL 3
ian@0 164 #define TCPLS_START 2
ian@0 165 #define TCPLS_END 1
ian@0 166 #define TCPLS_MED 0
ian@0 167
ian@0 168
ian@0 169 // max transmit or receive buffer size
ian@0 170 #define CB_RX_BUF_SIZE 2048UL // max buffer size
ian@0 171 // NOTE: must be multiple of 4
ian@0 172
ian@0 173 #define CB_MAX_RD_NUM 512 // MAX # of RD
ian@0 174 #define CB_MAX_TD_NUM 256 // MAX # of TD
ian@0 175
ian@0 176 #define CB_INIT_RD_NUM_3119 128 // init # of RD, for setup VT3119
ian@0 177 #define CB_INIT_TD_NUM_3119 64 // init # of TD, for setup VT3119
ian@0 178
ian@0 179 #define CB_INIT_RD_NUM 128 // init # of RD, for setup default
ian@0 180 #define CB_INIT_TD_NUM 64 // init # of TD, for setup default
ian@0 181
ian@0 182 // for 3119
ian@0 183 #define CB_TD_RING_NUM 4 // # of TD rings.
ian@0 184 #define CB_MAX_SEG_PER_PKT 7 // max data seg per packet (Tx)
ian@0 185
ian@0 186
ian@0 187 /*
ian@0 188 * If collisions excess 15 times , tx will abort, and
ian@0 189 * if tx fifo underflow, tx will fail
ian@0 190 * we should try to resend it
ian@0 191 */
ian@0 192
ian@0 193 #define CB_MAX_TX_ABORT_RETRY 3
ian@0 194
ian@0 195 /*
ian@0 196 * Receive descriptor
ian@0 197 */
ian@0 198
ian@0 199 struct rdesc0 {
ian@0 200 u16 RSR; /* Receive status */
ian@0 201 u16 len:14; /* Received packet length */
ian@0 202 u16 reserved:1;
ian@0 203 u16 owner:1; /* Who owns this buffer ? */
ian@0 204 };
ian@0 205
ian@0 206 struct rdesc1 {
ian@0 207 u16 PQTAG;
ian@0 208 u8 CSM;
ian@0 209 u8 IPKT;
ian@0 210 };
ian@0 211
ian@0 212 struct rx_desc {
ian@0 213 struct rdesc0 rdesc0;
ian@0 214 struct rdesc1 rdesc1;
ian@0 215 u32 pa_low; /* Low 32 bit PCI address */
ian@0 216 u16 pa_high; /* Next 16 bit PCI address (48 total) */
ian@0 217 u16 len:15; /* Frame size */
ian@0 218 u16 inten:1; /* Enable interrupt */
ian@0 219 } __attribute__ ((__packed__));
ian@0 220
ian@0 221 /*
ian@0 222 * Transmit descriptor
ian@0 223 */
ian@0 224
ian@0 225 struct tdesc0 {
ian@0 226 u16 TSR; /* Transmit status register */
ian@0 227 u16 pktsize:14; /* Size of frame */
ian@0 228 u16 reserved:1;
ian@0 229 u16 owner:1; /* Who owns the buffer */
ian@0 230 };
ian@0 231
ian@0 232 struct pqinf { /* Priority queue info */
ian@0 233 u16 VID:12;
ian@0 234 u16 CFI:1;
ian@0 235 u16 priority:3;
ian@0 236 } __attribute__ ((__packed__));
ian@0 237
ian@0 238 struct tdesc1 {
ian@0 239 struct pqinf pqinf;
ian@0 240 u8 TCR;
ian@0 241 u8 TCPLS:2;
ian@0 242 u8 reserved:2;
ian@0 243 u8 CMDZ:4;
ian@0 244 } __attribute__ ((__packed__));
ian@0 245
ian@0 246 struct td_buf {
ian@0 247 u32 pa_low;
ian@0 248 u16 pa_high;
ian@0 249 u16 bufsize:14;
ian@0 250 u16 reserved:1;
ian@0 251 u16 queue:1;
ian@0 252 } __attribute__ ((__packed__));
ian@0 253
ian@0 254 struct tx_desc {
ian@0 255 struct tdesc0 tdesc0;
ian@0 256 struct tdesc1 tdesc1;
ian@0 257 struct td_buf td_buf[7];
ian@0 258 };
ian@0 259
ian@0 260 struct velocity_rd_info {
ian@0 261 struct sk_buff *skb;
ian@0 262 dma_addr_t skb_dma;
ian@0 263 };
ian@0 264
ian@0 265 /**
ian@0 266 * alloc_rd_info - allocate an rd info block
ian@0 267 *
ian@0 268 * Alocate and initialize a receive info structure used for keeping
ian@0 269 * track of kernel side information related to each receive
ian@0 270 * descriptor we are using
ian@0 271 */
ian@0 272
ian@0 273 static inline struct velocity_rd_info *alloc_rd_info(void)
ian@0 274 {
ian@0 275 struct velocity_rd_info *ptr;
ian@0 276 if ((ptr = kmalloc(sizeof(struct velocity_rd_info), GFP_ATOMIC)) == NULL)
ian@0 277 return NULL;
ian@0 278 else {
ian@0 279 memset(ptr, 0, sizeof(struct velocity_rd_info));
ian@0 280 return ptr;
ian@0 281 }
ian@0 282 }
ian@0 283
ian@0 284 /*
ian@0 285 * Used to track transmit side buffers.
ian@0 286 */
ian@0 287
ian@0 288 struct velocity_td_info {
ian@0 289 struct sk_buff *skb;
ian@0 290 u8 *buf;
ian@0 291 int nskb_dma;
ian@0 292 dma_addr_t skb_dma[7];
ian@0 293 dma_addr_t buf_dma;
ian@0 294 };
ian@0 295
ian@0 296 enum velocity_owner {
ian@0 297 OWNED_BY_HOST = 0,
ian@0 298 OWNED_BY_NIC = 1
ian@0 299 };
ian@0 300
ian@0 301
ian@0 302 /*
ian@0 303 * MAC registers and macros.
ian@0 304 */
ian@0 305
ian@0 306
ian@0 307 #define MCAM_SIZE 64
ian@0 308 #define VCAM_SIZE 64
ian@0 309 #define TX_QUEUE_NO 4
ian@0 310
ian@0 311 #define MAX_HW_MIB_COUNTER 32
ian@0 312 #define VELOCITY_MIN_MTU (64)
ian@0 313 #define VELOCITY_MAX_MTU (9000)
ian@0 314
ian@0 315 /*
ian@0 316 * Registers in the MAC
ian@0 317 */
ian@0 318
ian@0 319 #define MAC_REG_PAR 0x00 // physical address
ian@0 320 #define MAC_REG_RCR 0x06
ian@0 321 #define MAC_REG_TCR 0x07
ian@0 322 #define MAC_REG_CR0_SET 0x08
ian@0 323 #define MAC_REG_CR1_SET 0x09
ian@0 324 #define MAC_REG_CR2_SET 0x0A
ian@0 325 #define MAC_REG_CR3_SET 0x0B
ian@0 326 #define MAC_REG_CR0_CLR 0x0C
ian@0 327 #define MAC_REG_CR1_CLR 0x0D
ian@0 328 #define MAC_REG_CR2_CLR 0x0E
ian@0 329 #define MAC_REG_CR3_CLR 0x0F
ian@0 330 #define MAC_REG_MAR 0x10
ian@0 331 #define MAC_REG_CAM 0x10
ian@0 332 #define MAC_REG_DEC_BASE_HI 0x18
ian@0 333 #define MAC_REG_DBF_BASE_HI 0x1C
ian@0 334 #define MAC_REG_ISR_CTL 0x20
ian@0 335 #define MAC_REG_ISR_HOTMR 0x20
ian@0 336 #define MAC_REG_ISR_TSUPTHR 0x20
ian@0 337 #define MAC_REG_ISR_RSUPTHR 0x20
ian@0 338 #define MAC_REG_ISR_CTL1 0x21
ian@0 339 #define MAC_REG_TXE_SR 0x22
ian@0 340 #define MAC_REG_RXE_SR 0x23
ian@0 341 #define MAC_REG_ISR 0x24
ian@0 342 #define MAC_REG_ISR0 0x24
ian@0 343 #define MAC_REG_ISR1 0x25
ian@0 344 #define MAC_REG_ISR2 0x26
ian@0 345 #define MAC_REG_ISR3 0x27
ian@0 346 #define MAC_REG_IMR 0x28
ian@0 347 #define MAC_REG_IMR0 0x28
ian@0 348 #define MAC_REG_IMR1 0x29
ian@0 349 #define MAC_REG_IMR2 0x2A
ian@0 350 #define MAC_REG_IMR3 0x2B
ian@0 351 #define MAC_REG_TDCSR_SET 0x30
ian@0 352 #define MAC_REG_RDCSR_SET 0x32
ian@0 353 #define MAC_REG_TDCSR_CLR 0x34
ian@0 354 #define MAC_REG_RDCSR_CLR 0x36
ian@0 355 #define MAC_REG_RDBASE_LO 0x38
ian@0 356 #define MAC_REG_RDINDX 0x3C
ian@0 357 #define MAC_REG_TDBASE_LO 0x40
ian@0 358 #define MAC_REG_RDCSIZE 0x50
ian@0 359 #define MAC_REG_TDCSIZE 0x52
ian@0 360 #define MAC_REG_TDINDX 0x54
ian@0 361 #define MAC_REG_TDIDX0 0x54
ian@0 362 #define MAC_REG_TDIDX1 0x56
ian@0 363 #define MAC_REG_TDIDX2 0x58
ian@0 364 #define MAC_REG_TDIDX3 0x5A
ian@0 365 #define MAC_REG_PAUSE_TIMER 0x5C
ian@0 366 #define MAC_REG_RBRDU 0x5E
ian@0 367 #define MAC_REG_FIFO_TEST0 0x60
ian@0 368 #define MAC_REG_FIFO_TEST1 0x64
ian@0 369 #define MAC_REG_CAMADDR 0x68
ian@0 370 #define MAC_REG_CAMCR 0x69
ian@0 371 #define MAC_REG_GFTEST 0x6A
ian@0 372 #define MAC_REG_FTSTCMD 0x6B
ian@0 373 #define MAC_REG_MIICFG 0x6C
ian@0 374 #define MAC_REG_MIISR 0x6D
ian@0 375 #define MAC_REG_PHYSR0 0x6E
ian@0 376 #define MAC_REG_PHYSR1 0x6F
ian@0 377 #define MAC_REG_MIICR 0x70
ian@0 378 #define MAC_REG_MIIADR 0x71
ian@0 379 #define MAC_REG_MIIDATA 0x72
ian@0 380 #define MAC_REG_SOFT_TIMER0 0x74
ian@0 381 #define MAC_REG_SOFT_TIMER1 0x76
ian@0 382 #define MAC_REG_CFGA 0x78
ian@0 383 #define MAC_REG_CFGB 0x79
ian@0 384 #define MAC_REG_CFGC 0x7A
ian@0 385 #define MAC_REG_CFGD 0x7B
ian@0 386 #define MAC_REG_DCFG0 0x7C
ian@0 387 #define MAC_REG_DCFG1 0x7D
ian@0 388 #define MAC_REG_MCFG0 0x7E
ian@0 389 #define MAC_REG_MCFG1 0x7F
ian@0 390
ian@0 391 #define MAC_REG_TBIST 0x80
ian@0 392 #define MAC_REG_RBIST 0x81
ian@0 393 #define MAC_REG_PMCC 0x82
ian@0 394 #define MAC_REG_STICKHW 0x83
ian@0 395 #define MAC_REG_MIBCR 0x84
ian@0 396 #define MAC_REG_EERSV 0x85
ian@0 397 #define MAC_REG_REVID 0x86
ian@0 398 #define MAC_REG_MIBREAD 0x88
ian@0 399 #define MAC_REG_BPMA 0x8C
ian@0 400 #define MAC_REG_EEWR_DATA 0x8C
ian@0 401 #define MAC_REG_BPMD_WR 0x8F
ian@0 402 #define MAC_REG_BPCMD 0x90
ian@0 403 #define MAC_REG_BPMD_RD 0x91
ian@0 404 #define MAC_REG_EECHKSUM 0x92
ian@0 405 #define MAC_REG_EECSR 0x93
ian@0 406 #define MAC_REG_EERD_DATA 0x94
ian@0 407 #define MAC_REG_EADDR 0x96
ian@0 408 #define MAC_REG_EMBCMD 0x97
ian@0 409 #define MAC_REG_JMPSR0 0x98
ian@0 410 #define MAC_REG_JMPSR1 0x99
ian@0 411 #define MAC_REG_JMPSR2 0x9A
ian@0 412 #define MAC_REG_JMPSR3 0x9B
ian@0 413 #define MAC_REG_CHIPGSR 0x9C
ian@0 414 #define MAC_REG_TESTCFG 0x9D
ian@0 415 #define MAC_REG_DEBUG 0x9E
ian@0 416 #define MAC_REG_CHIPGCR 0x9F
ian@0 417 #define MAC_REG_WOLCR0_SET 0xA0
ian@0 418 #define MAC_REG_WOLCR1_SET 0xA1
ian@0 419 #define MAC_REG_PWCFG_SET 0xA2
ian@0 420 #define MAC_REG_WOLCFG_SET 0xA3
ian@0 421 #define MAC_REG_WOLCR0_CLR 0xA4
ian@0 422 #define MAC_REG_WOLCR1_CLR 0xA5
ian@0 423 #define MAC_REG_PWCFG_CLR 0xA6
ian@0 424 #define MAC_REG_WOLCFG_CLR 0xA7
ian@0 425 #define MAC_REG_WOLSR0_SET 0xA8
ian@0 426 #define MAC_REG_WOLSR1_SET 0xA9
ian@0 427 #define MAC_REG_WOLSR0_CLR 0xAC
ian@0 428 #define MAC_REG_WOLSR1_CLR 0xAD
ian@0 429 #define MAC_REG_PATRN_CRC0 0xB0
ian@0 430 #define MAC_REG_PATRN_CRC1 0xB2
ian@0 431 #define MAC_REG_PATRN_CRC2 0xB4
ian@0 432 #define MAC_REG_PATRN_CRC3 0xB6
ian@0 433 #define MAC_REG_PATRN_CRC4 0xB8
ian@0 434 #define MAC_REG_PATRN_CRC5 0xBA
ian@0 435 #define MAC_REG_PATRN_CRC6 0xBC
ian@0 436 #define MAC_REG_PATRN_CRC7 0xBE
ian@0 437 #define MAC_REG_BYTEMSK0_0 0xC0
ian@0 438 #define MAC_REG_BYTEMSK0_1 0xC4
ian@0 439 #define MAC_REG_BYTEMSK0_2 0xC8
ian@0 440 #define MAC_REG_BYTEMSK0_3 0xCC
ian@0 441 #define MAC_REG_BYTEMSK1_0 0xD0
ian@0 442 #define MAC_REG_BYTEMSK1_1 0xD4
ian@0 443 #define MAC_REG_BYTEMSK1_2 0xD8
ian@0 444 #define MAC_REG_BYTEMSK1_3 0xDC
ian@0 445 #define MAC_REG_BYTEMSK2_0 0xE0
ian@0 446 #define MAC_REG_BYTEMSK2_1 0xE4
ian@0 447 #define MAC_REG_BYTEMSK2_2 0xE8
ian@0 448 #define MAC_REG_BYTEMSK2_3 0xEC
ian@0 449 #define MAC_REG_BYTEMSK3_0 0xF0
ian@0 450 #define MAC_REG_BYTEMSK3_1 0xF4
ian@0 451 #define MAC_REG_BYTEMSK3_2 0xF8
ian@0 452 #define MAC_REG_BYTEMSK3_3 0xFC
ian@0 453
ian@0 454 /*
ian@0 455 * Bits in the RCR register
ian@0 456 */
ian@0 457
ian@0 458 #define RCR_AS 0x80
ian@0 459 #define RCR_AP 0x40
ian@0 460 #define RCR_AL 0x20
ian@0 461 #define RCR_PROM 0x10
ian@0 462 #define RCR_AB 0x08
ian@0 463 #define RCR_AM 0x04
ian@0 464 #define RCR_AR 0x02
ian@0 465 #define RCR_SEP 0x01
ian@0 466
ian@0 467 /*
ian@0 468 * Bits in the TCR register
ian@0 469 */
ian@0 470
ian@0 471 #define TCR_TB2BDIS 0x80
ian@0 472 #define TCR_COLTMC1 0x08
ian@0 473 #define TCR_COLTMC0 0x04
ian@0 474 #define TCR_LB1 0x02 /* loopback[1] */
ian@0 475 #define TCR_LB0 0x01 /* loopback[0] */
ian@0 476
ian@0 477 /*
ian@0 478 * Bits in the CR0 register
ian@0 479 */
ian@0 480
ian@0 481 #define CR0_TXON 0x00000008UL
ian@0 482 #define CR0_RXON 0x00000004UL
ian@0 483 #define CR0_STOP 0x00000002UL /* stop MAC, default = 1 */
ian@0 484 #define CR0_STRT 0x00000001UL /* start MAC */
ian@0 485 #define CR0_SFRST 0x00008000UL /* software reset */
ian@0 486 #define CR0_TM1EN 0x00004000UL
ian@0 487 #define CR0_TM0EN 0x00002000UL
ian@0 488 #define CR0_DPOLL 0x00000800UL /* disable rx/tx auto polling */
ian@0 489 #define CR0_DISAU 0x00000100UL
ian@0 490 #define CR0_XONEN 0x00800000UL
ian@0 491 #define CR0_FDXTFCEN 0x00400000UL /* full-duplex TX flow control enable */
ian@0 492 #define CR0_FDXRFCEN 0x00200000UL /* full-duplex RX flow control enable */
ian@0 493 #define CR0_HDXFCEN 0x00100000UL /* half-duplex flow control enable */
ian@0 494 #define CR0_XHITH1 0x00080000UL /* TX XON high threshold 1 */
ian@0 495 #define CR0_XHITH0 0x00040000UL /* TX XON high threshold 0 */
ian@0 496 #define CR0_XLTH1 0x00020000UL /* TX pause frame low threshold 1 */
ian@0 497 #define CR0_XLTH0 0x00010000UL /* TX pause frame low threshold 0 */
ian@0 498 #define CR0_GSPRST 0x80000000UL
ian@0 499 #define CR0_FORSRST 0x40000000UL
ian@0 500 #define CR0_FPHYRST 0x20000000UL
ian@0 501 #define CR0_DIAG 0x10000000UL
ian@0 502 #define CR0_INTPCTL 0x04000000UL
ian@0 503 #define CR0_GINTMSK1 0x02000000UL
ian@0 504 #define CR0_GINTMSK0 0x01000000UL
ian@0 505
ian@0 506 /*
ian@0 507 * Bits in the CR1 register
ian@0 508 */
ian@0 509
ian@0 510 #define CR1_SFRST 0x80 /* software reset */
ian@0 511 #define CR1_TM1EN 0x40
ian@0 512 #define CR1_TM0EN 0x20
ian@0 513 #define CR1_DPOLL 0x08 /* disable rx/tx auto polling */
ian@0 514 #define CR1_DISAU 0x01
ian@0 515
ian@0 516 /*
ian@0 517 * Bits in the CR2 register
ian@0 518 */
ian@0 519
ian@0 520 #define CR2_XONEN 0x80
ian@0 521 #define CR2_FDXTFCEN 0x40 /* full-duplex TX flow control enable */
ian@0 522 #define CR2_FDXRFCEN 0x20 /* full-duplex RX flow control enable */
ian@0 523 #define CR2_HDXFCEN 0x10 /* half-duplex flow control enable */
ian@0 524 #define CR2_XHITH1 0x08 /* TX XON high threshold 1 */
ian@0 525 #define CR2_XHITH0 0x04 /* TX XON high threshold 0 */
ian@0 526 #define CR2_XLTH1 0x02 /* TX pause frame low threshold 1 */
ian@0 527 #define CR2_XLTH0 0x01 /* TX pause frame low threshold 0 */
ian@0 528
ian@0 529 /*
ian@0 530 * Bits in the CR3 register
ian@0 531 */
ian@0 532
ian@0 533 #define CR3_GSPRST 0x80
ian@0 534 #define CR3_FORSRST 0x40
ian@0 535 #define CR3_FPHYRST 0x20
ian@0 536 #define CR3_DIAG 0x10
ian@0 537 #define CR3_INTPCTL 0x04
ian@0 538 #define CR3_GINTMSK1 0x02
ian@0 539 #define CR3_GINTMSK0 0x01
ian@0 540
ian@0 541 #define ISRCTL_UDPINT 0x8000
ian@0 542 #define ISRCTL_TSUPDIS 0x4000
ian@0 543 #define ISRCTL_RSUPDIS 0x2000
ian@0 544 #define ISRCTL_PMSK1 0x1000
ian@0 545 #define ISRCTL_PMSK0 0x0800
ian@0 546 #define ISRCTL_INTPD 0x0400
ian@0 547 #define ISRCTL_HCRLD 0x0200
ian@0 548 #define ISRCTL_SCRLD 0x0100
ian@0 549
ian@0 550 /*
ian@0 551 * Bits in the ISR_CTL1 register
ian@0 552 */
ian@0 553
ian@0 554 #define ISRCTL1_UDPINT 0x80
ian@0 555 #define ISRCTL1_TSUPDIS 0x40
ian@0 556 #define ISRCTL1_RSUPDIS 0x20
ian@0 557 #define ISRCTL1_PMSK1 0x10
ian@0 558 #define ISRCTL1_PMSK0 0x08
ian@0 559 #define ISRCTL1_INTPD 0x04
ian@0 560 #define ISRCTL1_HCRLD 0x02
ian@0 561 #define ISRCTL1_SCRLD 0x01
ian@0 562
ian@0 563 /*
ian@0 564 * Bits in the TXE_SR register
ian@0 565 */
ian@0 566
ian@0 567 #define TXESR_TFDBS 0x08
ian@0 568 #define TXESR_TDWBS 0x04
ian@0 569 #define TXESR_TDRBS 0x02
ian@0 570 #define TXESR_TDSTR 0x01
ian@0 571
ian@0 572 /*
ian@0 573 * Bits in the RXE_SR register
ian@0 574 */
ian@0 575
ian@0 576 #define RXESR_RFDBS 0x08
ian@0 577 #define RXESR_RDWBS 0x04
ian@0 578 #define RXESR_RDRBS 0x02
ian@0 579 #define RXESR_RDSTR 0x01
ian@0 580
ian@0 581 /*
ian@0 582 * Bits in the ISR register
ian@0 583 */
ian@0 584
ian@0 585 #define ISR_ISR3 0x80000000UL
ian@0 586 #define ISR_ISR2 0x40000000UL
ian@0 587 #define ISR_ISR1 0x20000000UL
ian@0 588 #define ISR_ISR0 0x10000000UL
ian@0 589 #define ISR_TXSTLI 0x02000000UL
ian@0 590 #define ISR_RXSTLI 0x01000000UL
ian@0 591 #define ISR_HFLD 0x00800000UL
ian@0 592 #define ISR_UDPI 0x00400000UL
ian@0 593 #define ISR_MIBFI 0x00200000UL
ian@0 594 #define ISR_SHDNI 0x00100000UL
ian@0 595 #define ISR_PHYI 0x00080000UL
ian@0 596 #define ISR_PWEI 0x00040000UL
ian@0 597 #define ISR_TMR1I 0x00020000UL
ian@0 598 #define ISR_TMR0I 0x00010000UL
ian@0 599 #define ISR_SRCI 0x00008000UL
ian@0 600 #define ISR_LSTPEI 0x00004000UL
ian@0 601 #define ISR_LSTEI 0x00002000UL
ian@0 602 #define ISR_OVFI 0x00001000UL
ian@0 603 #define ISR_FLONI 0x00000800UL
ian@0 604 #define ISR_RACEI 0x00000400UL
ian@0 605 #define ISR_TXWB1I 0x00000200UL
ian@0 606 #define ISR_TXWB0I 0x00000100UL
ian@0 607 #define ISR_PTX3I 0x00000080UL
ian@0 608 #define ISR_PTX2I 0x00000040UL
ian@0 609 #define ISR_PTX1I 0x00000020UL
ian@0 610 #define ISR_PTX0I 0x00000010UL
ian@0 611 #define ISR_PTXI 0x00000008UL
ian@0 612 #define ISR_PRXI 0x00000004UL
ian@0 613 #define ISR_PPTXI 0x00000002UL
ian@0 614 #define ISR_PPRXI 0x00000001UL
ian@0 615
ian@0 616 /*
ian@0 617 * Bits in the IMR register
ian@0 618 */
ian@0 619
ian@0 620 #define IMR_TXSTLM 0x02000000UL
ian@0 621 #define IMR_UDPIM 0x00400000UL
ian@0 622 #define IMR_MIBFIM 0x00200000UL
ian@0 623 #define IMR_SHDNIM 0x00100000UL
ian@0 624 #define IMR_PHYIM 0x00080000UL
ian@0 625 #define IMR_PWEIM 0x00040000UL
ian@0 626 #define IMR_TMR1IM 0x00020000UL
ian@0 627 #define IMR_TMR0IM 0x00010000UL
ian@0 628
ian@0 629 #define IMR_SRCIM 0x00008000UL
ian@0 630 #define IMR_LSTPEIM 0x00004000UL
ian@0 631 #define IMR_LSTEIM 0x00002000UL
ian@0 632 #define IMR_OVFIM 0x00001000UL
ian@0 633 #define IMR_FLONIM 0x00000800UL
ian@0 634 #define IMR_RACEIM 0x00000400UL
ian@0 635 #define IMR_TXWB1IM 0x00000200UL
ian@0 636 #define IMR_TXWB0IM 0x00000100UL
ian@0 637
ian@0 638 #define IMR_PTX3IM 0x00000080UL
ian@0 639 #define IMR_PTX2IM 0x00000040UL
ian@0 640 #define IMR_PTX1IM 0x00000020UL
ian@0 641 #define IMR_PTX0IM 0x00000010UL
ian@0 642 #define IMR_PTXIM 0x00000008UL
ian@0 643 #define IMR_PRXIM 0x00000004UL
ian@0 644 #define IMR_PPTXIM 0x00000002UL
ian@0 645 #define IMR_PPRXIM 0x00000001UL
ian@0 646
ian@0 647 /* 0x0013FB0FUL = initial value of IMR */
ian@0 648
ian@0 649 #define INT_MASK_DEF (IMR_PPTXIM|IMR_PPRXIM|IMR_PTXIM|IMR_PRXIM|\
ian@0 650 IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|\
ian@0 651 IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\
ian@0 652 IMR_SHDNIM|IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM)
ian@0 653
ian@0 654 /*
ian@0 655 * Bits in the TDCSR0/1, RDCSR0 register
ian@0 656 */
ian@0 657
ian@0 658 #define TRDCSR_DEAD 0x0008
ian@0 659 #define TRDCSR_WAK 0x0004
ian@0 660 #define TRDCSR_ACT 0x0002
ian@0 661 #define TRDCSR_RUN 0x0001
ian@0 662
ian@0 663 /*
ian@0 664 * Bits in the CAMADDR register
ian@0 665 */
ian@0 666
ian@0 667 #define CAMADDR_CAMEN 0x80
ian@0 668 #define CAMADDR_VCAMSL 0x40
ian@0 669
ian@0 670 /*
ian@0 671 * Bits in the CAMCR register
ian@0 672 */
ian@0 673
ian@0 674 #define CAMCR_PS1 0x80
ian@0 675 #define CAMCR_PS0 0x40
ian@0 676 #define CAMCR_AITRPKT 0x20
ian@0 677 #define CAMCR_AITR16 0x10
ian@0 678 #define CAMCR_CAMRD 0x08
ian@0 679 #define CAMCR_CAMWR 0x04
ian@0 680 #define CAMCR_PS_CAM_MASK 0x40
ian@0 681 #define CAMCR_PS_CAM_DATA 0x80
ian@0 682 #define CAMCR_PS_MAR 0x00
ian@0 683
ian@0 684 /*
ian@0 685 * Bits in the MIICFG register
ian@0 686 */
ian@0 687
ian@0 688 #define MIICFG_MPO1 0x80
ian@0 689 #define MIICFG_MPO0 0x40
ian@0 690 #define MIICFG_MFDC 0x20
ian@0 691
ian@0 692 /*
ian@0 693 * Bits in the MIISR register
ian@0 694 */
ian@0 695
ian@0 696 #define MIISR_MIDLE 0x80
ian@0 697
ian@0 698 /*
ian@0 699 * Bits in the PHYSR0 register
ian@0 700 */
ian@0 701
ian@0 702 #define PHYSR0_PHYRST 0x80
ian@0 703 #define PHYSR0_LINKGD 0x40
ian@0 704 #define PHYSR0_FDPX 0x10
ian@0 705 #define PHYSR0_SPDG 0x08
ian@0 706 #define PHYSR0_SPD10 0x04
ian@0 707 #define PHYSR0_RXFLC 0x02
ian@0 708 #define PHYSR0_TXFLC 0x01
ian@0 709
ian@0 710 /*
ian@0 711 * Bits in the PHYSR1 register
ian@0 712 */
ian@0 713
ian@0 714 #define PHYSR1_PHYTBI 0x01
ian@0 715
ian@0 716 /*
ian@0 717 * Bits in the MIICR register
ian@0 718 */
ian@0 719
ian@0 720 #define MIICR_MAUTO 0x80
ian@0 721 #define MIICR_RCMD 0x40
ian@0 722 #define MIICR_WCMD 0x20
ian@0 723 #define MIICR_MDPM 0x10
ian@0 724 #define MIICR_MOUT 0x08
ian@0 725 #define MIICR_MDO 0x04
ian@0 726 #define MIICR_MDI 0x02
ian@0 727 #define MIICR_MDC 0x01
ian@0 728
ian@0 729 /*
ian@0 730 * Bits in the MIIADR register
ian@0 731 */
ian@0 732
ian@0 733 #define MIIADR_SWMPL 0x80
ian@0 734
ian@0 735 /*
ian@0 736 * Bits in the CFGA register
ian@0 737 */
ian@0 738
ian@0 739 #define CFGA_PMHCTG 0x08
ian@0 740 #define CFGA_GPIO1PD 0x04
ian@0 741 #define CFGA_ABSHDN 0x02
ian@0 742 #define CFGA_PACPI 0x01
ian@0 743
ian@0 744 /*
ian@0 745 * Bits in the CFGB register
ian@0 746 */
ian@0 747
ian@0 748 #define CFGB_GTCKOPT 0x80
ian@0 749 #define CFGB_MIIOPT 0x40
ian@0 750 #define CFGB_CRSEOPT 0x20
ian@0 751 #define CFGB_OFSET 0x10
ian@0 752 #define CFGB_CRANDOM 0x08
ian@0 753 #define CFGB_CAP 0x04
ian@0 754 #define CFGB_MBA 0x02
ian@0 755 #define CFGB_BAKOPT 0x01
ian@0 756
ian@0 757 /*
ian@0 758 * Bits in the CFGC register
ian@0 759 */
ian@0 760
ian@0 761 #define CFGC_EELOAD 0x80
ian@0 762 #define CFGC_BROPT 0x40
ian@0 763 #define CFGC_DLYEN 0x20
ian@0 764 #define CFGC_DTSEL 0x10
ian@0 765 #define CFGC_BTSEL 0x08
ian@0 766 #define CFGC_BPS2 0x04 /* bootrom select[2] */
ian@0 767 #define CFGC_BPS1 0x02 /* bootrom select[1] */
ian@0 768 #define CFGC_BPS0 0x01 /* bootrom select[0] */
ian@0 769
ian@0 770 /*
ian@0 771 * Bits in the CFGD register
ian@0 772 */
ian@0 773
ian@0 774 #define CFGD_IODIS 0x80
ian@0 775 #define CFGD_MSLVDACEN 0x40
ian@0 776 #define CFGD_CFGDACEN 0x20
ian@0 777 #define CFGD_PCI64EN 0x10
ian@0 778 #define CFGD_HTMRL4 0x08
ian@0 779
ian@0 780 /*
ian@0 781 * Bits in the DCFG1 register
ian@0 782 */
ian@0 783
ian@0 784 #define DCFG_XMWI 0x8000
ian@0 785 #define DCFG_XMRM 0x4000
ian@0 786 #define DCFG_XMRL 0x2000
ian@0 787 #define DCFG_PERDIS 0x1000
ian@0 788 #define DCFG_MRWAIT 0x0400
ian@0 789 #define DCFG_MWWAIT 0x0200
ian@0 790 #define DCFG_LATMEN 0x0100
ian@0 791
ian@0 792 /*
ian@0 793 * Bits in the MCFG0 register
ian@0 794 */
ian@0 795
ian@0 796 #define MCFG_RXARB 0x0080
ian@0 797 #define MCFG_RFT1 0x0020
ian@0 798 #define MCFG_RFT0 0x0010
ian@0 799 #define MCFG_LOWTHOPT 0x0008
ian@0 800 #define MCFG_PQEN 0x0004
ian@0 801 #define MCFG_RTGOPT 0x0002
ian@0 802 #define MCFG_VIDFR 0x0001
ian@0 803
ian@0 804 /*
ian@0 805 * Bits in the MCFG1 register
ian@0 806 */
ian@0 807
ian@0 808 #define MCFG_TXARB 0x8000
ian@0 809 #define MCFG_TXQBK1 0x0800
ian@0 810 #define MCFG_TXQBK0 0x0400
ian@0 811 #define MCFG_TXQNOBK 0x0200
ian@0 812 #define MCFG_SNAPOPT 0x0100
ian@0 813
ian@0 814 /*
ian@0 815 * Bits in the PMCC register
ian@0 816 */
ian@0 817
ian@0 818 #define PMCC_DSI 0x80
ian@0 819 #define PMCC_D2_DIS 0x40
ian@0 820 #define PMCC_D1_DIS 0x20
ian@0 821 #define PMCC_D3C_EN 0x10
ian@0 822 #define PMCC_D3H_EN 0x08
ian@0 823 #define PMCC_D2_EN 0x04
ian@0 824 #define PMCC_D1_EN 0x02
ian@0 825 #define PMCC_D0_EN 0x01
ian@0 826
ian@0 827 /*
ian@0 828 * Bits in STICKHW
ian@0 829 */
ian@0 830
ian@0 831 #define STICKHW_SWPTAG 0x10
ian@0 832 #define STICKHW_WOLSR 0x08
ian@0 833 #define STICKHW_WOLEN 0x04
ian@0 834 #define STICKHW_DS1 0x02 /* R/W by software/cfg cycle */
ian@0 835 #define STICKHW_DS0 0x01 /* suspend well DS write port */
ian@0 836
ian@0 837 /*
ian@0 838 * Bits in the MIBCR register
ian@0 839 */
ian@0 840
ian@0 841 #define MIBCR_MIBISTOK 0x80
ian@0 842 #define MIBCR_MIBISTGO 0x40
ian@0 843 #define MIBCR_MIBINC 0x20
ian@0 844 #define MIBCR_MIBHI 0x10
ian@0 845 #define MIBCR_MIBFRZ 0x08
ian@0 846 #define MIBCR_MIBFLSH 0x04
ian@0 847 #define MIBCR_MPTRINI 0x02
ian@0 848 #define MIBCR_MIBCLR 0x01
ian@0 849
ian@0 850 /*
ian@0 851 * Bits in the EERSV register
ian@0 852 */
ian@0 853
ian@0 854 #define EERSV_BOOT_RPL ((u8) 0x01) /* Boot method selection for VT6110 */
ian@0 855
ian@0 856 #define EERSV_BOOT_MASK ((u8) 0x06)
ian@0 857 #define EERSV_BOOT_INT19 ((u8) 0x00)
ian@0 858 #define EERSV_BOOT_INT18 ((u8) 0x02)
ian@0 859 #define EERSV_BOOT_LOCAL ((u8) 0x04)
ian@0 860 #define EERSV_BOOT_BEV ((u8) 0x06)
ian@0 861
ian@0 862
ian@0 863 /*
ian@0 864 * Bits in BPCMD
ian@0 865 */
ian@0 866
ian@0 867 #define BPCMD_BPDNE 0x80
ian@0 868 #define BPCMD_EBPWR 0x02
ian@0 869 #define BPCMD_EBPRD 0x01
ian@0 870
ian@0 871 /*
ian@0 872 * Bits in the EECSR register
ian@0 873 */
ian@0 874
ian@0 875 #define EECSR_EMBP 0x40 /* eeprom embeded programming */
ian@0 876 #define EECSR_RELOAD 0x20 /* eeprom content reload */
ian@0 877 #define EECSR_DPM 0x10 /* eeprom direct programming */
ian@0 878 #define EECSR_ECS 0x08 /* eeprom CS pin */
ian@0 879 #define EECSR_ECK 0x04 /* eeprom CK pin */
ian@0 880 #define EECSR_EDI 0x02 /* eeprom DI pin */
ian@0 881 #define EECSR_EDO 0x01 /* eeprom DO pin */
ian@0 882
ian@0 883 /*
ian@0 884 * Bits in the EMBCMD register
ian@0 885 */
ian@0 886
ian@0 887 #define EMBCMD_EDONE 0x80
ian@0 888 #define EMBCMD_EWDIS 0x08
ian@0 889 #define EMBCMD_EWEN 0x04
ian@0 890 #define EMBCMD_EWR 0x02
ian@0 891 #define EMBCMD_ERD 0x01
ian@0 892
ian@0 893 /*
ian@0 894 * Bits in TESTCFG register
ian@0 895 */
ian@0 896
ian@0 897 #define TESTCFG_HBDIS 0x80
ian@0 898
ian@0 899 /*
ian@0 900 * Bits in CHIPGCR register
ian@0 901 */
ian@0 902
ian@0 903 #define CHIPGCR_FCGMII 0x80
ian@0 904 #define CHIPGCR_FCFDX 0x40
ian@0 905 #define CHIPGCR_FCRESV 0x20
ian@0 906 #define CHIPGCR_FCMODE 0x10
ian@0 907 #define CHIPGCR_LPSOPT 0x08
ian@0 908 #define CHIPGCR_TM1US 0x04
ian@0 909 #define CHIPGCR_TM0US 0x02
ian@0 910 #define CHIPGCR_PHYINTEN 0x01
ian@0 911
ian@0 912 /*
ian@0 913 * Bits in WOLCR0
ian@0 914 */
ian@0 915
ian@0 916 #define WOLCR_MSWOLEN7 0x0080 /* enable pattern match filtering */
ian@0 917 #define WOLCR_MSWOLEN6 0x0040
ian@0 918 #define WOLCR_MSWOLEN5 0x0020
ian@0 919 #define WOLCR_MSWOLEN4 0x0010
ian@0 920 #define WOLCR_MSWOLEN3 0x0008
ian@0 921 #define WOLCR_MSWOLEN2 0x0004
ian@0 922 #define WOLCR_MSWOLEN1 0x0002
ian@0 923 #define WOLCR_MSWOLEN0 0x0001
ian@0 924 #define WOLCR_ARP_EN 0x0001
ian@0 925
ian@0 926 /*
ian@0 927 * Bits in WOLCR1
ian@0 928 */
ian@0 929
ian@0 930 #define WOLCR_LINKOFF_EN 0x0800 /* link off detected enable */
ian@0 931 #define WOLCR_LINKON_EN 0x0400 /* link on detected enable */
ian@0 932 #define WOLCR_MAGIC_EN 0x0200 /* magic packet filter enable */
ian@0 933 #define WOLCR_UNICAST_EN 0x0100 /* unicast filter enable */
ian@0 934
ian@0 935
ian@0 936 /*
ian@0 937 * Bits in PWCFG
ian@0 938 */
ian@0 939
ian@0 940 #define PWCFG_PHYPWOPT 0x80 /* internal MII I/F timing */
ian@0 941 #define PWCFG_PCISTICK 0x40 /* PCI sticky R/W enable */
ian@0 942 #define PWCFG_WOLTYPE 0x20 /* pulse(1) or button (0) */
ian@0 943 #define PWCFG_LEGCY_WOL 0x10
ian@0 944 #define PWCFG_PMCSR_PME_SR 0x08
ian@0 945 #define PWCFG_PMCSR_PME_EN 0x04 /* control by PCISTICK */
ian@0 946 #define PWCFG_LEGACY_WOLSR 0x02 /* Legacy WOL_SR shadow */
ian@0 947 #define PWCFG_LEGACY_WOLEN 0x01 /* Legacy WOL_EN shadow */
ian@0 948
ian@0 949 /*
ian@0 950 * Bits in WOLCFG
ian@0 951 */
ian@0 952
ian@0 953 #define WOLCFG_PMEOVR 0x80 /* for legacy use, force PMEEN always */
ian@0 954 #define WOLCFG_SAM 0x20 /* accept multicast case reset, default=0 */
ian@0 955 #define WOLCFG_SAB 0x10 /* accept broadcast case reset, default=0 */
ian@0 956 #define WOLCFG_SMIIACC 0x08 /* ?? */
ian@0 957 #define WOLCFG_SGENWH 0x02
ian@0 958 #define WOLCFG_PHYINTEN 0x01 /* 0:PHYINT trigger enable, 1:use internal MII
ian@0 959 to report status change */
ian@0 960 /*
ian@0 961 * Bits in WOLSR1
ian@0 962 */
ian@0 963
ian@0 964 #define WOLSR_LINKOFF_INT 0x0800
ian@0 965 #define WOLSR_LINKON_INT 0x0400
ian@0 966 #define WOLSR_MAGIC_INT 0x0200
ian@0 967 #define WOLSR_UNICAST_INT 0x0100
ian@0 968
ian@0 969 /*
ian@0 970 * Ethernet address filter type
ian@0 971 */
ian@0 972
ian@0 973 #define PKT_TYPE_NONE 0x0000 /* Turn off receiver */
ian@0 974 #define PKT_TYPE_DIRECTED 0x0001 /* obselete, directed address is always accepted */
ian@0 975 #define PKT_TYPE_MULTICAST 0x0002
ian@0 976 #define PKT_TYPE_ALL_MULTICAST 0x0004
ian@0 977 #define PKT_TYPE_BROADCAST 0x0008
ian@0 978 #define PKT_TYPE_PROMISCUOUS 0x0020
ian@0 979 #define PKT_TYPE_LONG 0x2000 /* NOTE.... the definition of LONG is >2048 bytes in our chip */
ian@0 980 #define PKT_TYPE_RUNT 0x4000
ian@0 981 #define PKT_TYPE_ERROR 0x8000 /* Accept error packets, e.g. CRC error */
ian@0 982
ian@0 983 /*
ian@0 984 * Loopback mode
ian@0 985 */
ian@0 986
ian@0 987 #define MAC_LB_NONE 0x00
ian@0 988 #define MAC_LB_INTERNAL 0x01
ian@0 989 #define MAC_LB_EXTERNAL 0x02
ian@0 990
ian@0 991 /*
ian@0 992 * Enabled mask value of irq
ian@0 993 */
ian@0 994
ian@0 995 #if defined(_SIM)
ian@0 996 #define IMR_MASK_VALUE 0x0033FF0FUL /* initial value of IMR
ian@0 997 set IMR0 to 0x0F according to spec */
ian@0 998
ian@0 999 #else
ian@0 1000 #define IMR_MASK_VALUE 0x0013FB0FUL /* initial value of IMR
ian@0 1001 ignore MIBFI,RACEI to
ian@0 1002 reduce intr. frequency
ian@0 1003 NOTE.... do not enable NoBuf int mask at driver driver
ian@0 1004 when (1) NoBuf -> RxThreshold = SF
ian@0 1005 (2) OK -> RxThreshold = original value
ian@0 1006 */
ian@0 1007 #endif
ian@0 1008
ian@0 1009 /*
ian@0 1010 * Revision id
ian@0 1011 */
ian@0 1012
ian@0 1013 #define REV_ID_VT3119_A0 0x00
ian@0 1014 #define REV_ID_VT3119_A1 0x01
ian@0 1015 #define REV_ID_VT3216_A0 0x10
ian@0 1016
ian@0 1017 /*
ian@0 1018 * Max time out delay time
ian@0 1019 */
ian@0 1020
ian@0 1021 #define W_MAX_TIMEOUT 0x0FFFU
ian@0 1022
ian@0 1023
ian@0 1024 /*
ian@0 1025 * MAC registers as a structure. Cannot be directly accessed this
ian@0 1026 * way but generates offsets for readl/writel() calls
ian@0 1027 */
ian@0 1028
ian@0 1029 struct mac_regs {
ian@0 1030 volatile u8 PAR[6]; /* 0x00 */
ian@0 1031 volatile u8 RCR;
ian@0 1032 volatile u8 TCR;
ian@0 1033
ian@0 1034 volatile u32 CR0Set; /* 0x08 */
ian@0 1035 volatile u32 CR0Clr; /* 0x0C */
ian@0 1036
ian@0 1037 volatile u8 MARCAM[8]; /* 0x10 */
ian@0 1038
ian@0 1039 volatile u32 DecBaseHi; /* 0x18 */
ian@0 1040 volatile u16 DbfBaseHi; /* 0x1C */
ian@0 1041 volatile u16 reserved_1E;
ian@0 1042
ian@0 1043 volatile u16 ISRCTL; /* 0x20 */
ian@0 1044 volatile u8 TXESR;
ian@0 1045 volatile u8 RXESR;
ian@0 1046
ian@0 1047 volatile u32 ISR; /* 0x24 */
ian@0 1048 volatile u32 IMR;
ian@0 1049
ian@0 1050 volatile u32 TDStatusPort; /* 0x2C */
ian@0 1051
ian@0 1052 volatile u16 TDCSRSet; /* 0x30 */
ian@0 1053 volatile u8 RDCSRSet;
ian@0 1054 volatile u8 reserved_33;
ian@0 1055 volatile u16 TDCSRClr;
ian@0 1056 volatile u8 RDCSRClr;
ian@0 1057 volatile u8 reserved_37;
ian@0 1058
ian@0 1059 volatile u32 RDBaseLo; /* 0x38 */
ian@0 1060 volatile u16 RDIdx; /* 0x3C */
ian@0 1061 volatile u16 reserved_3E;
ian@0 1062
ian@0 1063 volatile u32 TDBaseLo[4]; /* 0x40 */
ian@0 1064
ian@0 1065 volatile u16 RDCSize; /* 0x50 */
ian@0 1066 volatile u16 TDCSize; /* 0x52 */
ian@0 1067 volatile u16 TDIdx[4]; /* 0x54 */
ian@0 1068 volatile u16 tx_pause_timer; /* 0x5C */
ian@0 1069 volatile u16 RBRDU; /* 0x5E */
ian@0 1070
ian@0 1071 volatile u32 FIFOTest0; /* 0x60 */
ian@0 1072 volatile u32 FIFOTest1; /* 0x64 */
ian@0 1073
ian@0 1074 volatile u8 CAMADDR; /* 0x68 */
ian@0 1075 volatile u8 CAMCR; /* 0x69 */
ian@0 1076 volatile u8 GFTEST; /* 0x6A */
ian@0 1077 volatile u8 FTSTCMD; /* 0x6B */
ian@0 1078
ian@0 1079 volatile u8 MIICFG; /* 0x6C */
ian@0 1080 volatile u8 MIISR;
ian@0 1081 volatile u8 PHYSR0;
ian@0 1082 volatile u8 PHYSR1;
ian@0 1083 volatile u8 MIICR;
ian@0 1084 volatile u8 MIIADR;
ian@0 1085 volatile u16 MIIDATA;
ian@0 1086
ian@0 1087 volatile u16 SoftTimer0; /* 0x74 */
ian@0 1088 volatile u16 SoftTimer1;
ian@0 1089
ian@0 1090 volatile u8 CFGA; /* 0x78 */
ian@0 1091 volatile u8 CFGB;
ian@0 1092 volatile u8 CFGC;
ian@0 1093 volatile u8 CFGD;
ian@0 1094
ian@0 1095 volatile u16 DCFG; /* 0x7C */
ian@0 1096 volatile u16 MCFG;
ian@0 1097
ian@0 1098 volatile u8 TBIST; /* 0x80 */
ian@0 1099 volatile u8 RBIST;
ian@0 1100 volatile u8 PMCPORT;
ian@0 1101 volatile u8 STICKHW;
ian@0 1102
ian@0 1103 volatile u8 MIBCR; /* 0x84 */
ian@0 1104 volatile u8 reserved_85;
ian@0 1105 volatile u8 rev_id;
ian@0 1106 volatile u8 PORSTS;
ian@0 1107
ian@0 1108 volatile u32 MIBData; /* 0x88 */
ian@0 1109
ian@0 1110 volatile u16 EEWrData;
ian@0 1111
ian@0 1112 volatile u8 reserved_8E;
ian@0 1113 volatile u8 BPMDWr;
ian@0 1114 volatile u8 BPCMD;
ian@0 1115 volatile u8 BPMDRd;
ian@0 1116
ian@0 1117 volatile u8 EECHKSUM; /* 0x92 */
ian@0 1118 volatile u8 EECSR;
ian@0 1119
ian@0 1120 volatile u16 EERdData; /* 0x94 */
ian@0 1121 volatile u8 EADDR;
ian@0 1122 volatile u8 EMBCMD;
ian@0 1123
ian@0 1124
ian@0 1125 volatile u8 JMPSR0; /* 0x98 */
ian@0 1126 volatile u8 JMPSR1;
ian@0 1127 volatile u8 JMPSR2;
ian@0 1128 volatile u8 JMPSR3;
ian@0 1129 volatile u8 CHIPGSR; /* 0x9C */
ian@0 1130 volatile u8 TESTCFG;
ian@0 1131 volatile u8 DEBUG;
ian@0 1132 volatile u8 CHIPGCR;
ian@0 1133
ian@0 1134 volatile u16 WOLCRSet; /* 0xA0 */
ian@0 1135 volatile u8 PWCFGSet;
ian@0 1136 volatile u8 WOLCFGSet;
ian@0 1137
ian@0 1138 volatile u16 WOLCRClr; /* 0xA4 */
ian@0 1139 volatile u8 PWCFGCLR;
ian@0 1140 volatile u8 WOLCFGClr;
ian@0 1141
ian@0 1142 volatile u16 WOLSRSet; /* 0xA8 */
ian@0 1143 volatile u16 reserved_AA;
ian@0 1144
ian@0 1145 volatile u16 WOLSRClr; /* 0xAC */
ian@0 1146 volatile u16 reserved_AE;
ian@0 1147
ian@0 1148 volatile u16 PatternCRC[8]; /* 0xB0 */
ian@0 1149 volatile u32 ByteMask[4][4]; /* 0xC0 */
ian@0 1150 } __attribute__ ((__packed__));
ian@0 1151
ian@0 1152
ian@0 1153 enum hw_mib {
ian@0 1154 HW_MIB_ifRxAllPkts = 0,
ian@0 1155 HW_MIB_ifRxOkPkts,
ian@0 1156 HW_MIB_ifTxOkPkts,
ian@0 1157 HW_MIB_ifRxErrorPkts,
ian@0 1158 HW_MIB_ifRxRuntOkPkt,
ian@0 1159 HW_MIB_ifRxRuntErrPkt,
ian@0 1160 HW_MIB_ifRx64Pkts,
ian@0 1161 HW_MIB_ifTx64Pkts,
ian@0 1162 HW_MIB_ifRx65To127Pkts,
ian@0 1163 HW_MIB_ifTx65To127Pkts,
ian@0 1164 HW_MIB_ifRx128To255Pkts,
ian@0 1165 HW_MIB_ifTx128To255Pkts,
ian@0 1166 HW_MIB_ifRx256To511Pkts,
ian@0 1167 HW_MIB_ifTx256To511Pkts,
ian@0 1168 HW_MIB_ifRx512To1023Pkts,
ian@0 1169 HW_MIB_ifTx512To1023Pkts,
ian@0 1170 HW_MIB_ifRx1024To1518Pkts,
ian@0 1171 HW_MIB_ifTx1024To1518Pkts,
ian@0 1172 HW_MIB_ifTxEtherCollisions,
ian@0 1173 HW_MIB_ifRxPktCRCE,
ian@0 1174 HW_MIB_ifRxJumboPkts,
ian@0 1175 HW_MIB_ifTxJumboPkts,
ian@0 1176 HW_MIB_ifRxMacControlFrames,
ian@0 1177 HW_MIB_ifTxMacControlFrames,
ian@0 1178 HW_MIB_ifRxPktFAE,
ian@0 1179 HW_MIB_ifRxLongOkPkt,
ian@0 1180 HW_MIB_ifRxLongPktErrPkt,
ian@0 1181 HW_MIB_ifTXSQEErrors,
ian@0 1182 HW_MIB_ifRxNobuf,
ian@0 1183 HW_MIB_ifRxSymbolErrors,
ian@0 1184 HW_MIB_ifInRangeLengthErrors,
ian@0 1185 HW_MIB_ifLateCollisions,
ian@0 1186 HW_MIB_SIZE
ian@0 1187 };
ian@0 1188
ian@0 1189 enum chip_type {
ian@0 1190 CHIP_TYPE_VT6110 = 1,
ian@0 1191 };
ian@0 1192
ian@0 1193 struct velocity_info_tbl {
ian@0 1194 enum chip_type chip_id;
ian@0 1195 char *name;
ian@0 1196 int txqueue;
ian@0 1197 u32 flags;
ian@0 1198 };
ian@0 1199
ian@0 1200 #define mac_hw_mibs_init(regs) {\
ian@0 1201 BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\
ian@0 1202 BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\
ian@0 1203 do {}\
ian@0 1204 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\
ian@0 1205 BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\
ian@0 1206 }
ian@0 1207
ian@0 1208 #define mac_read_isr(regs) readl(&((regs)->ISR))
ian@0 1209 #define mac_write_isr(regs, x) writel((x),&((regs)->ISR))
ian@0 1210 #define mac_clear_isr(regs) writel(0xffffffffL,&((regs)->ISR))
ian@0 1211
ian@0 1212 #define mac_write_int_mask(mask, regs) writel((mask),&((regs)->IMR));
ian@0 1213 #define mac_disable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Clr))
ian@0 1214 #define mac_enable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Set))
ian@0 1215
ian@0 1216 #define mac_hw_mibs_read(regs, MIBs) {\
ian@0 1217 int i;\
ian@0 1218 BYTE_REG_BITS_ON(MIBCR_MPTRINI,&((regs)->MIBCR));\
ian@0 1219 for (i=0;i<HW_MIB_SIZE;i++) {\
ian@0 1220 (MIBs)[i]=readl(&((regs)->MIBData));\
ian@0 1221 }\
ian@0 1222 }
ian@0 1223
ian@0 1224 #define mac_set_dma_length(regs, n) {\
ian@0 1225 BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\
ian@0 1226 }
ian@0 1227
ian@0 1228 #define mac_set_rx_thresh(regs, n) {\
ian@0 1229 BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\
ian@0 1230 }
ian@0 1231
ian@0 1232 #define mac_rx_queue_run(regs) {\
ian@0 1233 writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\
ian@0 1234 }
ian@0 1235
ian@0 1236 #define mac_rx_queue_wake(regs) {\
ian@0 1237 writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\
ian@0 1238 }
ian@0 1239
ian@0 1240 #define mac_tx_queue_run(regs, n) {\
ian@0 1241 writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\
ian@0 1242 }
ian@0 1243
ian@0 1244 #define mac_tx_queue_wake(regs, n) {\
ian@0 1245 writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\
ian@0 1246 }
ian@0 1247
ian@0 1248 #define mac_eeprom_reload(regs) {\
ian@0 1249 int i=0;\
ian@0 1250 BYTE_REG_BITS_ON(EECSR_RELOAD,&((regs)->EECSR));\
ian@0 1251 do {\
ian@0 1252 udelay(10);\
ian@0 1253 if (i++>0x1000) {\
ian@0 1254 break;\
ian@0 1255 }\
ian@0 1256 }while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&((regs)->EECSR)));\
ian@0 1257 }
ian@0 1258
ian@0 1259 enum velocity_cam_type {
ian@0 1260 VELOCITY_VLAN_ID_CAM = 0,
ian@0 1261 VELOCITY_MULTICAST_CAM
ian@0 1262 };
ian@0 1263
ian@0 1264 /**
ian@0 1265 * mac_get_cam_mask - Read a CAM mask
ian@0 1266 * @regs: register block for this velocity
ian@0 1267 * @mask: buffer to store mask
ian@0 1268 * @cam_type: CAM to fetch
ian@0 1269 *
ian@0 1270 * Fetch the mask bits of the selected CAM and store them into the
ian@0 1271 * provided mask buffer.
ian@0 1272 */
ian@0 1273
ian@0 1274 static inline void mac_get_cam_mask(struct mac_regs __iomem * regs, u8 * mask, enum velocity_cam_type cam_type)
ian@0 1275 {
ian@0 1276 int i;
ian@0 1277 /* Select CAM mask */
ian@0 1278 BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1279
ian@0 1280 if (cam_type == VELOCITY_VLAN_ID_CAM)
ian@0 1281 writeb(CAMADDR_VCAMSL, &regs->CAMADDR);
ian@0 1282 else
ian@0 1283 writeb(0, &regs->CAMADDR);
ian@0 1284
ian@0 1285 /* read mask */
ian@0 1286 for (i = 0; i < 8; i++)
ian@0 1287 *mask++ = readb(&(regs->MARCAM[i]));
ian@0 1288
ian@0 1289 /* disable CAMEN */
ian@0 1290 writeb(0, &regs->CAMADDR);
ian@0 1291
ian@0 1292 /* Select mar */
ian@0 1293 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1294
ian@0 1295 }
ian@0 1296
ian@0 1297 /**
ian@0 1298 * mac_set_cam_mask - Set a CAM mask
ian@0 1299 * @regs: register block for this velocity
ian@0 1300 * @mask: CAM mask to load
ian@0 1301 * @cam_type: CAM to store
ian@0 1302 *
ian@0 1303 * Store a new mask into a CAM
ian@0 1304 */
ian@0 1305
ian@0 1306 static inline void mac_set_cam_mask(struct mac_regs __iomem * regs, u8 * mask, enum velocity_cam_type cam_type)
ian@0 1307 {
ian@0 1308 int i;
ian@0 1309 /* Select CAM mask */
ian@0 1310 BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1311
ian@0 1312 if (cam_type == VELOCITY_VLAN_ID_CAM)
ian@0 1313 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, &regs->CAMADDR);
ian@0 1314 else
ian@0 1315 writeb(CAMADDR_CAMEN, &regs->CAMADDR);
ian@0 1316
ian@0 1317 for (i = 0; i < 8; i++) {
ian@0 1318 writeb(*mask++, &(regs->MARCAM[i]));
ian@0 1319 }
ian@0 1320 /* disable CAMEN */
ian@0 1321 writeb(0, &regs->CAMADDR);
ian@0 1322
ian@0 1323 /* Select mar */
ian@0 1324 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1325 }
ian@0 1326
ian@0 1327 /**
ian@0 1328 * mac_set_cam - set CAM data
ian@0 1329 * @regs: register block of this velocity
ian@0 1330 * @idx: Cam index
ian@0 1331 * @addr: 2 or 6 bytes of CAM data
ian@0 1332 * @cam_type: CAM to load
ian@0 1333 *
ian@0 1334 * Load an address or vlan tag into a CAM
ian@0 1335 */
ian@0 1336
ian@0 1337 static inline void mac_set_cam(struct mac_regs __iomem * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
ian@0 1338 {
ian@0 1339 int i;
ian@0 1340
ian@0 1341 /* Select CAM mask */
ian@0 1342 BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1343
ian@0 1344 idx &= (64 - 1);
ian@0 1345
ian@0 1346 if (cam_type == VELOCITY_VLAN_ID_CAM)
ian@0 1347 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx, &regs->CAMADDR);
ian@0 1348 else
ian@0 1349 writeb(CAMADDR_CAMEN | idx, &regs->CAMADDR);
ian@0 1350
ian@0 1351 if (cam_type == VELOCITY_VLAN_ID_CAM)
ian@0 1352 writew(*((u16 *) addr), &regs->MARCAM[0]);
ian@0 1353 else {
ian@0 1354 for (i = 0; i < 6; i++) {
ian@0 1355 writeb(*addr++, &(regs->MARCAM[i]));
ian@0 1356 }
ian@0 1357 }
ian@0 1358 BYTE_REG_BITS_ON(CAMCR_CAMWR, &regs->CAMCR);
ian@0 1359
ian@0 1360 udelay(10);
ian@0 1361
ian@0 1362 writeb(0, &regs->CAMADDR);
ian@0 1363
ian@0 1364 /* Select mar */
ian@0 1365 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1366 }
ian@0 1367
ian@0 1368 /**
ian@0 1369 * mac_get_cam - fetch CAM data
ian@0 1370 * @regs: register block of this velocity
ian@0 1371 * @idx: Cam index
ian@0 1372 * @addr: buffer to hold up to 6 bytes of CAM data
ian@0 1373 * @cam_type: CAM to load
ian@0 1374 *
ian@0 1375 * Load an address or vlan tag from a CAM into the buffer provided by
ian@0 1376 * the caller. VLAN tags are 2 bytes the address cam entries are 6.
ian@0 1377 */
ian@0 1378
ian@0 1379 static inline void mac_get_cam(struct mac_regs __iomem * regs, int idx, u8 *addr, enum velocity_cam_type cam_type)
ian@0 1380 {
ian@0 1381 int i;
ian@0 1382
ian@0 1383 /* Select CAM mask */
ian@0 1384 BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1385
ian@0 1386 idx &= (64 - 1);
ian@0 1387
ian@0 1388 if (cam_type == VELOCITY_VLAN_ID_CAM)
ian@0 1389 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx, &regs->CAMADDR);
ian@0 1390 else
ian@0 1391 writeb(CAMADDR_CAMEN | idx, &regs->CAMADDR);
ian@0 1392
ian@0 1393 BYTE_REG_BITS_ON(CAMCR_CAMRD, &regs->CAMCR);
ian@0 1394
ian@0 1395 udelay(10);
ian@0 1396
ian@0 1397 if (cam_type == VELOCITY_VLAN_ID_CAM)
ian@0 1398 *((u16 *) addr) = readw(&(regs->MARCAM[0]));
ian@0 1399 else
ian@0 1400 for (i = 0; i < 6; i++, addr++)
ian@0 1401 *((u8 *) addr) = readb(&(regs->MARCAM[i]));
ian@0 1402
ian@0 1403 writeb(0, &regs->CAMADDR);
ian@0 1404
ian@0 1405 /* Select mar */
ian@0 1406 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
ian@0 1407 }
ian@0 1408
ian@0 1409 /**
ian@0 1410 * mac_wol_reset - reset WOL after exiting low power
ian@0 1411 * @regs: register block of this velocity
ian@0 1412 *
ian@0 1413 * Called after we drop out of wake on lan mode in order to
ian@0 1414 * reset the Wake on lan features. This function doesn't restore
ian@0 1415 * the rest of the logic from the result of sleep/wakeup
ian@0 1416 */
ian@0 1417
ian@0 1418 static inline void mac_wol_reset(struct mac_regs __iomem * regs)
ian@0 1419 {
ian@0 1420
ian@0 1421 /* Turn off SWPTAG right after leaving power mode */
ian@0 1422 BYTE_REG_BITS_OFF(STICKHW_SWPTAG, &regs->STICKHW);
ian@0 1423 /* clear sticky bits */
ian@0 1424 BYTE_REG_BITS_OFF((STICKHW_DS1 | STICKHW_DS0), &regs->STICKHW);
ian@0 1425
ian@0 1426 BYTE_REG_BITS_OFF(CHIPGCR_FCGMII, &regs->CHIPGCR);
ian@0 1427 BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR);
ian@0 1428 /* disable force PME-enable */
ian@0 1429 writeb(WOLCFG_PMEOVR, &regs->WOLCFGClr);
ian@0 1430 /* disable power-event config bit */
ian@0 1431 writew(0xFFFF, &regs->WOLCRClr);
ian@0 1432 /* clear power status */
ian@0 1433 writew(0xFFFF, &regs->WOLSRClr);
ian@0 1434 }
ian@0 1435
ian@0 1436
ian@0 1437 /*
ian@0 1438 * Header for WOL definitions. Used to compute hashes
ian@0 1439 */
ian@0 1440
ian@0 1441 typedef u8 MCAM_ADDR[ETH_ALEN];
ian@0 1442
ian@0 1443 struct arp_packet {
ian@0 1444 u8 dest_mac[ETH_ALEN];
ian@0 1445 u8 src_mac[ETH_ALEN];
ian@0 1446 u16 type;
ian@0 1447 u16 ar_hrd;
ian@0 1448 u16 ar_pro;
ian@0 1449 u8 ar_hln;
ian@0 1450 u8 ar_pln;
ian@0 1451 u16 ar_op;
ian@0 1452 u8 ar_sha[ETH_ALEN];
ian@0 1453 u8 ar_sip[4];
ian@0 1454 u8 ar_tha[ETH_ALEN];
ian@0 1455 u8 ar_tip[4];
ian@0 1456 } __attribute__ ((__packed__));
ian@0 1457
ian@0 1458 struct _magic_packet {
ian@0 1459 u8 dest_mac[6];
ian@0 1460 u8 src_mac[6];
ian@0 1461 u16 type;
ian@0 1462 u8 MAC[16][6];
ian@0 1463 u8 password[6];
ian@0 1464 } __attribute__ ((__packed__));
ian@0 1465
ian@0 1466 /*
ian@0 1467 * Store for chip context when saving and restoring status. Not
ian@0 1468 * all fields are saved/restored currently.
ian@0 1469 */
ian@0 1470
ian@0 1471 struct velocity_context {
ian@0 1472 u8 mac_reg[256];
ian@0 1473 MCAM_ADDR cam_addr[MCAM_SIZE];
ian@0 1474 u16 vcam[VCAM_SIZE];
ian@0 1475 u32 cammask[2];
ian@0 1476 u32 patcrc[2];
ian@0 1477 u32 pattern[8];
ian@0 1478 };
ian@0 1479
ian@0 1480
ian@0 1481 /*
ian@0 1482 * MII registers.
ian@0 1483 */
ian@0 1484
ian@0 1485
ian@0 1486 /*
ian@0 1487 * Registers in the MII (offset unit is WORD)
ian@0 1488 */
ian@0 1489
ian@0 1490 #define MII_REG_BMCR 0x00 // physical address
ian@0 1491 #define MII_REG_BMSR 0x01 //
ian@0 1492 #define MII_REG_PHYID1 0x02 // OUI
ian@0 1493 #define MII_REG_PHYID2 0x03 // OUI + Module ID + REV ID
ian@0 1494 #define MII_REG_ANAR 0x04 //
ian@0 1495 #define MII_REG_ANLPAR 0x05 //
ian@0 1496 #define MII_REG_G1000CR 0x09 //
ian@0 1497 #define MII_REG_G1000SR 0x0A //
ian@0 1498 #define MII_REG_MODCFG 0x10 //
ian@0 1499 #define MII_REG_TCSR 0x16 //
ian@0 1500 #define MII_REG_PLED 0x1B //
ian@0 1501 // NS, MYSON only
ian@0 1502 #define MII_REG_PCR 0x17 //
ian@0 1503 // ESI only
ian@0 1504 #define MII_REG_PCSR 0x17 //
ian@0 1505 #define MII_REG_AUXCR 0x1C //
ian@0 1506
ian@0 1507 // Marvell 88E1000/88E1000S
ian@0 1508 #define MII_REG_PSCR 0x10 // PHY specific control register
ian@0 1509
ian@0 1510 //
ian@0 1511 // Bits in the BMCR register
ian@0 1512 //
ian@0 1513 #define BMCR_RESET 0x8000 //
ian@0 1514 #define BMCR_LBK 0x4000 //
ian@0 1515 #define BMCR_SPEED100 0x2000 //
ian@0 1516 #define BMCR_AUTO 0x1000 //
ian@0 1517 #define BMCR_PD 0x0800 //
ian@0 1518 #define BMCR_ISO 0x0400 //
ian@0 1519 #define BMCR_REAUTO 0x0200 //
ian@0 1520 #define BMCR_FDX 0x0100 //
ian@0 1521 #define BMCR_SPEED1G 0x0040 //
ian@0 1522 //
ian@0 1523 // Bits in the BMSR register
ian@0 1524 //
ian@0 1525 #define BMSR_AUTOCM 0x0020 //
ian@0 1526 #define BMSR_LNK 0x0004 //
ian@0 1527
ian@0 1528 //
ian@0 1529 // Bits in the ANAR register
ian@0 1530 //
ian@0 1531 #define ANAR_ASMDIR 0x0800 // Asymmetric PAUSE support
ian@0 1532 #define ANAR_PAUSE 0x0400 // Symmetric PAUSE Support
ian@0 1533 #define ANAR_T4 0x0200 //
ian@0 1534 #define ANAR_TXFD 0x0100 //
ian@0 1535 #define ANAR_TX 0x0080 //
ian@0 1536 #define ANAR_10FD 0x0040 //
ian@0 1537 #define ANAR_10 0x0020 //
ian@0 1538 //
ian@0 1539 // Bits in the ANLPAR register
ian@0 1540 //
ian@0 1541 #define ANLPAR_ASMDIR 0x0800 // Asymmetric PAUSE support
ian@0 1542 #define ANLPAR_PAUSE 0x0400 // Symmetric PAUSE Support
ian@0 1543 #define ANLPAR_T4 0x0200 //
ian@0 1544 #define ANLPAR_TXFD 0x0100 //
ian@0 1545 #define ANLPAR_TX 0x0080 //
ian@0 1546 #define ANLPAR_10FD 0x0040 //
ian@0 1547 #define ANLPAR_10 0x0020 //
ian@0 1548
ian@0 1549 //
ian@0 1550 // Bits in the G1000CR register
ian@0 1551 //
ian@0 1552 #define G1000CR_1000FD 0x0200 // PHY is 1000-T Full-duplex capable
ian@0 1553 #define G1000CR_1000 0x0100 // PHY is 1000-T Half-duplex capable
ian@0 1554
ian@0 1555 //
ian@0 1556 // Bits in the G1000SR register
ian@0 1557 //
ian@0 1558 #define G1000SR_1000FD 0x0800 // LP PHY is 1000-T Full-duplex capable
ian@0 1559 #define G1000SR_1000 0x0400 // LP PHY is 1000-T Half-duplex capable
ian@0 1560
ian@0 1561 #define TCSR_ECHODIS 0x2000 //
ian@0 1562 #define AUXCR_MDPPS 0x0004 //
ian@0 1563
ian@0 1564 // Bits in the PLED register
ian@0 1565 #define PLED_LALBE 0x0004 //
ian@0 1566
ian@0 1567 // Marvell 88E1000/88E1000S Bits in the PHY specific control register (10h)
ian@0 1568 #define PSCR_ACRSTX 0x0800 // Assert CRS on Transmit
ian@0 1569
ian@0 1570 #define PHYID_CICADA_CS8201 0x000FC410UL
ian@0 1571 #define PHYID_VT3216_32BIT 0x000FC610UL
ian@0 1572 #define PHYID_VT3216_64BIT 0x000FC600UL
ian@0 1573 #define PHYID_MARVELL_1000 0x01410C50UL
ian@0 1574 #define PHYID_MARVELL_1000S 0x01410C40UL
ian@0 1575
ian@0 1576 #define PHYID_REV_ID_MASK 0x0000000FUL
ian@0 1577
ian@0 1578 #define PHYID_GET_PHY_REV_ID(i) ((i) & PHYID_REV_ID_MASK)
ian@0 1579 #define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK)
ian@0 1580
ian@0 1581 #define MII_REG_BITS_ON(x,i,p) do {\
ian@0 1582 u16 w;\
ian@0 1583 velocity_mii_read((p),(i),&(w));\
ian@0 1584 (w)|=(x);\
ian@0 1585 velocity_mii_write((p),(i),(w));\
ian@0 1586 } while (0)
ian@0 1587
ian@0 1588 #define MII_REG_BITS_OFF(x,i,p) do {\
ian@0 1589 u16 w;\
ian@0 1590 velocity_mii_read((p),(i),&(w));\
ian@0 1591 (w)&=(~(x));\
ian@0 1592 velocity_mii_write((p),(i),(w));\
ian@0 1593 } while (0)
ian@0 1594
ian@0 1595 #define MII_REG_BITS_IS_ON(x,i,p) ({\
ian@0 1596 u16 w;\
ian@0 1597 velocity_mii_read((p),(i),&(w));\
ian@0 1598 ((int) ((w) & (x)));})
ian@0 1599
ian@0 1600 #define MII_GET_PHY_ID(p) ({\
ian@0 1601 u32 id;\
ian@0 1602 velocity_mii_read((p),MII_REG_PHYID2,(u16 *) &id);\
ian@0 1603 velocity_mii_read((p),MII_REG_PHYID1,((u16 *) &id)+1);\
ian@0 1604 (id);})
ian@0 1605
ian@0 1606 /*
ian@0 1607 * Inline debug routine
ian@0 1608 */
ian@0 1609
ian@0 1610
ian@0 1611 enum velocity_msg_level {
ian@0 1612 MSG_LEVEL_ERR = 0, //Errors that will cause abnormal operation.
ian@0 1613 MSG_LEVEL_NOTICE = 1, //Some errors need users to be notified.
ian@0 1614 MSG_LEVEL_INFO = 2, //Normal message.
ian@0 1615 MSG_LEVEL_VERBOSE = 3, //Will report all trival errors.
ian@0 1616 MSG_LEVEL_DEBUG = 4 //Only for debug purpose.
ian@0 1617 };
ian@0 1618
ian@0 1619 #ifdef VELOCITY_DEBUG
ian@0 1620 #define ASSERT(x) { \
ian@0 1621 if (!(x)) { \
ian@0 1622 printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\
ian@0 1623 __FUNCTION__, __LINE__);\
ian@0 1624 BUG(); \
ian@0 1625 }\
ian@0 1626 }
ian@0 1627 #define VELOCITY_DBG(p,args...) printk(p, ##args)
ian@0 1628 #else
ian@0 1629 #define ASSERT(x)
ian@0 1630 #define VELOCITY_DBG(x)
ian@0 1631 #endif
ian@0 1632
ian@0 1633 #define VELOCITY_PRT(l, p, args...) do {if (l<=msglevel) printk( p ,##args);} while (0)
ian@0 1634
ian@0 1635 #define VELOCITY_PRT_CAMMASK(p,t) {\
ian@0 1636 int i;\
ian@0 1637 if ((t)==VELOCITY_MULTICAST_CAM) {\
ian@0 1638 for (i=0;i<(MCAM_SIZE/8);i++)\
ian@0 1639 printk("%02X",(p)->mCAMmask[i]);\
ian@0 1640 }\
ian@0 1641 else {\
ian@0 1642 for (i=0;i<(VCAM_SIZE/8);i++)\
ian@0 1643 printk("%02X",(p)->vCAMmask[i]);\
ian@0 1644 }\
ian@0 1645 printk("\n");\
ian@0 1646 }
ian@0 1647
ian@0 1648
ian@0 1649
ian@0 1650 #define VELOCITY_WOL_MAGIC 0x00000000UL
ian@0 1651 #define VELOCITY_WOL_PHY 0x00000001UL
ian@0 1652 #define VELOCITY_WOL_ARP 0x00000002UL
ian@0 1653 #define VELOCITY_WOL_UCAST 0x00000004UL
ian@0 1654 #define VELOCITY_WOL_BCAST 0x00000010UL
ian@0 1655 #define VELOCITY_WOL_MCAST 0x00000020UL
ian@0 1656 #define VELOCITY_WOL_MAGIC_SEC 0x00000040UL
ian@0 1657
ian@0 1658 /*
ian@0 1659 * Flags for options
ian@0 1660 */
ian@0 1661
ian@0 1662 #define VELOCITY_FLAGS_TAGGING 0x00000001UL
ian@0 1663 #define VELOCITY_FLAGS_TX_CSUM 0x00000002UL
ian@0 1664 #define VELOCITY_FLAGS_RX_CSUM 0x00000004UL
ian@0 1665 #define VELOCITY_FLAGS_IP_ALIGN 0x00000008UL
ian@0 1666 #define VELOCITY_FLAGS_VAL_PKT_LEN 0x00000010UL
ian@0 1667
ian@0 1668 #define VELOCITY_FLAGS_FLOW_CTRL 0x01000000UL
ian@0 1669
ian@0 1670 /*
ian@0 1671 * Flags for driver status
ian@0 1672 */
ian@0 1673
ian@0 1674 #define VELOCITY_FLAGS_OPENED 0x00010000UL
ian@0 1675 #define VELOCITY_FLAGS_VMNS_CONNECTED 0x00020000UL
ian@0 1676 #define VELOCITY_FLAGS_VMNS_COMMITTED 0x00040000UL
ian@0 1677 #define VELOCITY_FLAGS_WOL_ENABLED 0x00080000UL
ian@0 1678
ian@0 1679 /*
ian@0 1680 * Flags for MII status
ian@0 1681 */
ian@0 1682
ian@0 1683 #define VELOCITY_LINK_FAIL 0x00000001UL
ian@0 1684 #define VELOCITY_SPEED_10 0x00000002UL
ian@0 1685 #define VELOCITY_SPEED_100 0x00000004UL
ian@0 1686 #define VELOCITY_SPEED_1000 0x00000008UL
ian@0 1687 #define VELOCITY_DUPLEX_FULL 0x00000010UL
ian@0 1688 #define VELOCITY_AUTONEG_ENABLE 0x00000020UL
ian@0 1689 #define VELOCITY_FORCED_BY_EEPROM 0x00000040UL
ian@0 1690
ian@0 1691 /*
ian@0 1692 * For velocity_set_media_duplex
ian@0 1693 */
ian@0 1694
ian@0 1695 #define VELOCITY_LINK_CHANGE 0x00000001UL
ian@0 1696
ian@0 1697 enum speed_opt {
ian@0 1698 SPD_DPX_AUTO = 0,
ian@0 1699 SPD_DPX_100_HALF = 1,
ian@0 1700 SPD_DPX_100_FULL = 2,
ian@0 1701 SPD_DPX_10_HALF = 3,
ian@0 1702 SPD_DPX_10_FULL = 4
ian@0 1703 };
ian@0 1704
ian@0 1705 enum velocity_init_type {
ian@0 1706 VELOCITY_INIT_COLD = 0,
ian@0 1707 VELOCITY_INIT_RESET,
ian@0 1708 VELOCITY_INIT_WOL
ian@0 1709 };
ian@0 1710
ian@0 1711 enum velocity_flow_cntl_type {
ian@0 1712 FLOW_CNTL_DEFAULT = 1,
ian@0 1713 FLOW_CNTL_TX,
ian@0 1714 FLOW_CNTL_RX,
ian@0 1715 FLOW_CNTL_TX_RX,
ian@0 1716 FLOW_CNTL_DISABLE,
ian@0 1717 };
ian@0 1718
ian@0 1719 struct velocity_opt {
ian@0 1720 int numrx; /* Number of RX descriptors */
ian@0 1721 int numtx; /* Number of TX descriptors */
ian@0 1722 enum speed_opt spd_dpx; /* Media link mode */
ian@0 1723 int vid; /* vlan id */
ian@0 1724 int DMA_length; /* DMA length */
ian@0 1725 int rx_thresh; /* RX_THRESH */
ian@0 1726 int flow_cntl;
ian@0 1727 int wol_opts; /* Wake on lan options */
ian@0 1728 int td_int_count;
ian@0 1729 int int_works;
ian@0 1730 int rx_bandwidth_hi;
ian@0 1731 int rx_bandwidth_lo;
ian@0 1732 int rx_bandwidth_en;
ian@0 1733 u32 flags;
ian@0 1734 };
ian@0 1735
ian@0 1736 struct velocity_info {
ian@0 1737 struct list_head list;
ian@0 1738
ian@0 1739 struct pci_dev *pdev;
ian@0 1740 struct net_device *dev;
ian@0 1741 struct net_device_stats stats;
ian@0 1742
ian@0 1743 dma_addr_t rd_pool_dma;
ian@0 1744 dma_addr_t td_pool_dma[TX_QUEUE_NO];
ian@0 1745
ian@0 1746 dma_addr_t tx_bufs_dma;
ian@0 1747 u8 *tx_bufs;
ian@0 1748
ian@0 1749 u8 ip_addr[4];
ian@0 1750 enum chip_type chip_id;
ian@0 1751
ian@0 1752 struct mac_regs __iomem * mac_regs;
ian@0 1753 unsigned long memaddr;
ian@0 1754 unsigned long ioaddr;
ian@0 1755
ian@0 1756 u8 rev_id;
ian@0 1757
ian@0 1758 #define AVAIL_TD(p,q) ((p)->options.numtx-((p)->td_used[(q)]))
ian@0 1759
ian@0 1760 int num_txq;
ian@0 1761
ian@0 1762 volatile int td_used[TX_QUEUE_NO];
ian@0 1763 int td_curr[TX_QUEUE_NO];
ian@0 1764 int td_tail[TX_QUEUE_NO];
ian@0 1765 struct tx_desc *td_rings[TX_QUEUE_NO];
ian@0 1766 struct velocity_td_info *td_infos[TX_QUEUE_NO];
ian@0 1767
ian@0 1768 int rd_curr;
ian@0 1769 int rd_dirty;
ian@0 1770 u32 rd_filled;
ian@0 1771 struct rx_desc *rd_ring;
ian@0 1772 struct velocity_rd_info *rd_info; /* It's an array */
ian@0 1773
ian@0 1774 #define GET_RD_BY_IDX(vptr, idx) (vptr->rd_ring[idx])
ian@0 1775 u32 mib_counter[MAX_HW_MIB_COUNTER];
ian@0 1776 struct velocity_opt options;
ian@0 1777
ian@0 1778 u32 int_mask;
ian@0 1779
ian@0 1780 u32 flags;
ian@0 1781
ian@0 1782 int rx_buf_sz;
ian@0 1783 u32 mii_status;
ian@0 1784 u32 phy_id;
ian@0 1785 int multicast_limit;
ian@0 1786
ian@0 1787 u8 vCAMmask[(VCAM_SIZE / 8)];
ian@0 1788 u8 mCAMmask[(MCAM_SIZE / 8)];
ian@0 1789
ian@0 1790 spinlock_t lock;
ian@0 1791
ian@0 1792 int wol_opts;
ian@0 1793 u8 wol_passwd[6];
ian@0 1794
ian@0 1795 struct velocity_context context;
ian@0 1796
ian@0 1797 u32 ticks;
ian@0 1798 u32 rx_bytes;
ian@0 1799
ian@0 1800 };
ian@0 1801
ian@0 1802 /**
ian@0 1803 * velocity_get_ip - find an IP address for the device
ian@0 1804 * @vptr: Velocity to query
ian@0 1805 *
ian@0 1806 * Dig out an IP address for this interface so that we can
ian@0 1807 * configure wakeup with WOL for ARP. If there are multiple IP
ian@0 1808 * addresses on this chain then we use the first - multi-IP WOL is not
ian@0 1809 * supported.
ian@0 1810 *
ian@0 1811 * CHECK ME: locking
ian@0 1812 */
ian@0 1813
ian@0 1814 static inline int velocity_get_ip(struct velocity_info *vptr)
ian@0 1815 {
ian@0 1816 struct in_device *in_dev = (struct in_device *) vptr->dev->ip_ptr;
ian@0 1817 struct in_ifaddr *ifa;
ian@0 1818
ian@0 1819 if (in_dev != NULL) {
ian@0 1820 ifa = (struct in_ifaddr *) in_dev->ifa_list;
ian@0 1821 if (ifa != NULL) {
ian@0 1822 memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
ian@0 1823 return 0;
ian@0 1824 }
ian@0 1825 }
ian@0 1826 return -ENOENT;
ian@0 1827 }
ian@0 1828
ian@0 1829 /**
ian@0 1830 * velocity_update_hw_mibs - fetch MIB counters from chip
ian@0 1831 * @vptr: velocity to update
ian@0 1832 *
ian@0 1833 * The velocity hardware keeps certain counters in the hardware
ian@0 1834 * side. We need to read these when the user asks for statistics
ian@0 1835 * or when they overflow (causing an interrupt). The read of the
ian@0 1836 * statistic clears it, so we keep running master counters in user
ian@0 1837 * space.
ian@0 1838 */
ian@0 1839
ian@0 1840 static inline void velocity_update_hw_mibs(struct velocity_info *vptr)
ian@0 1841 {
ian@0 1842 u32 tmp;
ian@0 1843 int i;
ian@0 1844 BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR));
ian@0 1845
ian@0 1846 while (BYTE_REG_BITS_IS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)));
ian@0 1847
ian@0 1848 BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR));
ian@0 1849 for (i = 0; i < HW_MIB_SIZE; i++) {
ian@0 1850 tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL;
ian@0 1851 vptr->mib_counter[i] += tmp;
ian@0 1852 }
ian@0 1853 }
ian@0 1854
ian@0 1855 /**
ian@0 1856 * init_flow_control_register - set up flow control
ian@0 1857 * @vptr: velocity to configure
ian@0 1858 *
ian@0 1859 * Configure the flow control registers for this velocity device.
ian@0 1860 */
ian@0 1861
ian@0 1862 static inline void init_flow_control_register(struct velocity_info *vptr)
ian@0 1863 {
ian@0 1864 struct mac_regs __iomem * regs = vptr->mac_regs;
ian@0 1865
ian@0 1866 /* Set {XHITH1, XHITH0, XLTH1, XLTH0} in FlowCR1 to {1, 0, 1, 1}
ian@0 1867 depend on RD=64, and Turn on XNOEN in FlowCR1 */
ian@0 1868 writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0), &regs->CR0Set);
ian@0 1869 writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0), &regs->CR0Clr);
ian@0 1870
ian@0 1871 /* Set TxPauseTimer to 0xFFFF */
ian@0 1872 writew(0xFFFF, &regs->tx_pause_timer);
ian@0 1873
ian@0 1874 /* Initialize RBRDU to Rx buffer count. */
ian@0 1875 writew(vptr->options.numrx, &regs->RBRDU);
ian@0 1876 }
ian@0 1877
ian@0 1878
ian@0 1879 #endif