11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* $Id: sunhme.h,v 1.33 2001/08/03 06:23:04 davem Exp $ 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * sunhme.h: Definitions for Sparc HME/BigMac 10/100baseT ethernet driver. 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Also known as the "Happy Meal". 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com) 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _SUNHME_H 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _SUNHME_H 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/pci.h> 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Happy Meal global registers. */ 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_SWRESET 0x000UL /* Software Reset */ 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG 0x004UL /* Config Register */ 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT 0x108UL /* Status */ 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK 0x10cUL /* Interrupt Mask */ 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_REG_SIZE 0x110UL 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Global reset register. */ 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_RESET_ETX 0x01 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_RESET_ERX 0x02 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_RESET_ALL 0x03 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Global config register. */ 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_BURSTMSK 0x03 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_BURST16 0x00 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_BURST32 0x01 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_BURST64 0x02 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_64BIT 0x04 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_PARITY 0x08 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_CFG_RESV 0x10 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Global status register. */ 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_GOTFRAME 0x00000001 /* Received a frame */ 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RCNTEXP 0x00000002 /* Receive frame counter expired */ 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_ACNTEXP 0x00000004 /* Align-error counter expired */ 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_CCNTEXP 0x00000008 /* CRC-error counter expired */ 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_LCNTEXP 0x00000010 /* Length-error counter expired */ 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_STSTERR 0x00000080 /* Test error in XIF for SQE */ 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_SENTFRAME 0x00000100 /* Transmitted a frame */ 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_MAXPKTERR 0x00000400 /* Max-packet size error */ 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_FCNTEXP 0x00004000 /* First-collision counter expired */ 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_DTIMEXP 0x00008000 /* Defer-timer expired */ 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RXTOHOST 0x00010000 /* Moved from receive-FIFO to host memory */ 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_NORXD 0x00020000 /* No more receive descriptors */ 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RXERR 0x00040000 /* Error during receive dma */ 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RXLATERR 0x00080000 /* Late error during receive dma */ 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RXPERR 0x00100000 /* Parity error during receive dma */ 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_RXTERR 0x00200000 /* Tag error during receive dma */ 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_EOPERR 0x00400000 /* Transmit descriptor did not have EOP set */ 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_MIFIRQ 0x00800000 /* MIF is signaling an interrupt condition */ 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_HOSTTOTX 0x01000000 /* Moved from host memory to transmit-FIFO */ 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_TXALL 0x02000000 /* Transmitted all packets in the tx-fifo */ 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_TXEACK 0x04000000 /* Error during transmit dma */ 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_TXLERR 0x08000000 /* Late error during transmit dma */ 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_TXPERR 0x10000000 /* Parity error during transmit dma */ 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_TXTERR 0x20000000 /* Tag error during transmit dma */ 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_SLVERR 0x40000000 /* PIO access got an error */ 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_SLVPERR 0x80000000 /* PIO access got a parity error */ 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* All interesting error conditions. */ 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_STAT_ERRORS 0xfc7efefc 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Global interrupt mask register. */ 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_GOTFRAME 0x00000001 /* Received a frame */ 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RCNTEXP 0x00000002 /* Receive frame counter expired */ 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_ACNTEXP 0x00000004 /* Align-error counter expired */ 751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_CCNTEXP 0x00000008 /* CRC-error counter expired */ 761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_LCNTEXP 0x00000010 /* Length-error counter expired */ 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RFIFOVF 0x00000020 /* Receive FIFO overflow */ 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_CVCNTEXP 0x00000040 /* Code-violation counter expired */ 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_STSTERR 0x00000080 /* Test error in XIF for SQE */ 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_SENTFRAME 0x00000100 /* Transmitted a frame */ 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_TFIFO_UND 0x00000200 /* Transmit FIFO underrun */ 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_MAXPKTERR 0x00000400 /* Max-packet size error */ 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_NCNTEXP 0x00000800 /* Normal-collision counter expired */ 841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_ECNTEXP 0x00001000 /* Excess-collision counter expired */ 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_LCCNTEXP 0x00002000 /* Late-collision counter expired */ 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_FCNTEXP 0x00004000 /* First-collision counter expired */ 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_DTIMEXP 0x00008000 /* Defer-timer expired */ 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RXTOHOST 0x00010000 /* Moved from receive-FIFO to host memory */ 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_NORXD 0x00020000 /* No more receive descriptors */ 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RXERR 0x00040000 /* Error during receive dma */ 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RXLATERR 0x00080000 /* Late error during receive dma */ 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RXPERR 0x00100000 /* Parity error during receive dma */ 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_RXTERR 0x00200000 /* Tag error during receive dma */ 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_EOPERR 0x00400000 /* Transmit descriptor did not have EOP set */ 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_MIFIRQ 0x00800000 /* MIF is signaling an interrupt condition */ 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_HOSTTOTX 0x01000000 /* Moved from host memory to transmit-FIFO */ 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_TXALL 0x02000000 /* Transmitted all packets in the tx-fifo */ 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_TXEACK 0x04000000 /* Error during transmit dma */ 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_TXLERR 0x08000000 /* Late error during transmit dma */ 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_TXPERR 0x10000000 /* Parity error during transmit dma */ 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_TXTERR 0x20000000 /* Tag error during transmit dma */ 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_SLVERR 0x40000000 /* PIO access got an error */ 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define GREG_IMASK_SLVPERR 0x80000000 /* PIO access got a parity error */ 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Happy Meal external transmitter registers. */ 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_PENDING 0x00UL /* Transmit pending/wakeup register */ 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_CFG 0x04UL /* Transmit config register */ 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_RING 0x08UL /* Transmit ring pointer */ 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_BBASE 0x0cUL /* Transmit buffer base */ 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_BDISP 0x10UL /* Transmit buffer displacement */ 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_FIFOWPTR 0x14UL /* FIFO write ptr */ 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_FIFOSWPTR 0x18UL /* FIFO write ptr (shadow register) */ 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_FIFORPTR 0x1cUL /* FIFO read ptr */ 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_FIFOSRPTR 0x20UL /* FIFO read ptr (shadow register) */ 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_FIFOPCNT 0x24UL /* FIFO packet counter */ 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_SMACHINE 0x28UL /* Transmitter state machine */ 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_RSIZE 0x2cUL /* Ring descriptor size */ 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_BPTR 0x30UL /* Transmit data buffer ptr */ 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_REG_SIZE 0x34UL 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ETX transmit pending register. */ 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_TP_DMAWAKEUP 0x00000001 /* Restart transmit dma */ 1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ETX config register. */ 1251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_CFG_DMAENABLE 0x00000001 /* Enable transmit dma */ 1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_CFG_FIFOTHRESH 0x000003fe /* Transmit FIFO threshold */ 1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_CFG_IRQDAFTER 0x00000400 /* Interrupt after TX-FIFO drained */ 1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_CFG_IRQDBEFORE 0x00000000 /* Interrupt before TX-FIFO drained */ 1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ETX_RSIZE_SHIFT 4 1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Happy Meal external receiver registers. */ 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG 0x00UL /* Receiver config register */ 1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_RING 0x04UL /* Receiver ring ptr */ 1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_BPTR 0x08UL /* Receiver buffer ptr */ 1361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_FIFOWPTR 0x0cUL /* FIFO write ptr */ 1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_FIFOSWPTR 0x10UL /* FIFO write ptr (shadow register) */ 1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_FIFORPTR 0x14UL /* FIFO read ptr */ 1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_FIFOSRPTR 0x18UL /* FIFO read ptr (shadow register) */ 1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_SMACHINE 0x1cUL /* Receiver state machine */ 1411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_REG_SIZE 0x20UL 1421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* ERX config register. */ 1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_DMAENABLE 0x00000001 /* Enable receive DMA */ 1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_RESV1 0x00000006 /* Unused... */ 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_BYTEOFFSET 0x00000038 /* Receive first byte offset */ 1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_RESV2 0x000001c0 /* Unused... */ 1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_SIZE32 0x00000000 /* Receive ring size == 32 */ 1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_SIZE64 0x00000200 /* Receive ring size == 64 */ 1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_SIZE128 0x00000400 /* Receive ring size == 128 */ 1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_SIZE256 0x00000600 /* Receive ring size == 256 */ 1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_RESV3 0x0000f800 /* Unused... */ 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_CSUMSTART 0x007f0000 /* Offset of checksum start, 1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * in halfwords. */ 1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* I'd like a Big Mac, small fries, small coke, and SparcLinux please. */ 1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_XIFCFG 0x0000UL /* XIF config register */ 1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 0x4-->0x204, reserved */ 1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_TXSWRESET 0x208UL /* Transmitter software reset */ 1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_TXCFG 0x20cUL /* Transmitter config register */ 1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_IGAP1 0x210UL /* Inter-packet gap 1 */ 1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_IGAP2 0x214UL /* Inter-packet gap 2 */ 1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_ALIMIT 0x218UL /* Transmit attempt limit */ 1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_STIME 0x21cUL /* Transmit slot time */ 1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_PLEN 0x220UL /* Size of transmit preamble */ 1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_PPAT 0x224UL /* Pattern for transmit preamble */ 1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_TXSDELIM 0x228UL /* Transmit delimiter */ 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_JSIZE 0x22cUL /* Jam size */ 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_TXMAX 0x230UL /* Transmit max pkt size */ 1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_TXMIN 0x234UL /* Transmit min pkt size */ 1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_PATTEMPT 0x238UL /* Count of transmit peak attempts */ 1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_DTCTR 0x23cUL /* Transmit defer timer */ 1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_NCCTR 0x240UL /* Transmit normal-collision counter */ 1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_FCCTR 0x244UL /* Transmit first-collision counter */ 1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_EXCTR 0x248UL /* Transmit excess-collision counter */ 1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_LTCTR 0x24cUL /* Transmit late-collision counter */ 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RSEED 0x250UL /* Transmit random number seed */ 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_TXSMACHINE 0x254UL /* Transmit state machine */ 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 0x258-->0x304, reserved */ 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RXSWRESET 0x308UL /* Receiver software reset */ 1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RXCFG 0x30cUL /* Receiver config register */ 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RXMAX 0x310UL /* Receive max pkt size */ 1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RXMIN 0x314UL /* Receive min pkt size */ 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_MACADDR2 0x318UL /* Ether address register 2 */ 1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_MACADDR1 0x31cUL /* Ether address register 1 */ 1861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_MACADDR0 0x320UL /* Ether address register 0 */ 1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_FRCTR 0x324UL /* Receive frame receive counter */ 1881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_GLECTR 0x328UL /* Receive giant-length error counter */ 1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_UNALECTR 0x32cUL /* Receive unaligned error counter */ 1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RCRCECTR 0x330UL /* Receive CRC error counter */ 1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RXSMACHINE 0x334UL /* Receiver state machine */ 1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_RXCVALID 0x338UL /* Receiver code violation */ 1931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 0x33c, reserved */ 1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_HTABLE3 0x340UL /* Hash table 3 */ 1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_HTABLE2 0x344UL /* Hash table 2 */ 1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_HTABLE1 0x348UL /* Hash table 1 */ 1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_HTABLE0 0x34cUL /* Hash table 0 */ 1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_AFILTER2 0x350UL /* Address filter 2 */ 1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_AFILTER1 0x354UL /* Address filter 1 */ 2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_AFILTER0 0x358UL /* Address filter 0 */ 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_AFMASK 0x35cUL /* Address filter mask */ 2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BMAC_REG_SIZE 0x360UL 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* BigMac XIF config register. */ 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_ODENABLE 0x00000001 /* Output driver enable */ 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_XLBACK 0x00000002 /* Loopback-mode XIF enable */ 2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_MLBACK 0x00000004 /* Loopback-mode MII enable */ 2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_MIIDISAB 0x00000008 /* MII receive buffer disable */ 2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_SQENABLE 0x00000010 /* SQE test enable */ 2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_SQETWIN 0x000003e0 /* SQE time window */ 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_LANCE 0x00000010 /* Lance mode enable */ 2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_XCFG_LIPG0 0x000003e0 /* Lance mode IPG0 */ 2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* BigMac transmit config register. */ 2151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_ENABLE 0x00000001 /* Enable the transmitter */ 2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_SMODE 0x00000020 /* Enable slow transmit mode */ 2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_CIGN 0x00000040 /* Ignore transmit collisions */ 2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_FCSOFF 0x00000080 /* Do not emit FCS */ 2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_DBACKOFF 0x00000100 /* Disable backoff */ 2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_FULLDPLX 0x00000200 /* Enable full-duplex */ 2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_TXCFG_DGIVEUP 0x00000400 /* Don't give up on transmits */ 2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* BigMac receive config register. */ 2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_ENABLE 0x00000001 /* Enable the receiver */ 2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_PSTRIP 0x00000020 /* Pad byte strip enable */ 22625985edcedea6396277003854657b5f3cb31a628Lucas De Marchi#define BIGMAC_RXCFG_PMISC 0x00000040 /* Enable promiscuous mode */ 2271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_DERR 0x00000080 /* Disable error checking */ 2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_DCRCS 0x00000100 /* Disable CRC stripping */ 2291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_REJME 0x00000200 /* Reject packets addressed to me */ 2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_PGRP 0x00000400 /* Enable promisc group mode */ 2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_HENABLE 0x00000800 /* Enable the hash filter */ 2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define BIGMAC_RXCFG_AENABLE 0x00001000 /* Enable the address filter */ 2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* These are the "Management Interface" (ie. MIF) registers of the transceiver. */ 2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_BBCLOCK 0x00UL /* Bit bang clock register */ 2361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_BBDATA 0x04UL /* Bit bang data register */ 2371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_BBOENAB 0x08UL /* Bit bang output enable */ 2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_FRAME 0x0cUL /* Frame control/data register */ 2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_CFG 0x10UL /* MIF config register */ 2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_IMASK 0x14UL /* MIF interrupt mask */ 2411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_STATUS 0x18UL /* MIF status */ 2421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_SMACHINE 0x1cUL /* MIF state machine */ 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCVR_REG_SIZE 0x20UL 2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Frame commands. */ 2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FRAME_WRITE 0x50020000 2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define FRAME_READ 0x60020000 2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Transceiver config register */ 2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_PSELECT 0x00000001 /* Select PHY */ 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_PENABLE 0x00000002 /* Enable MIF polling */ 2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_BENABLE 0x00000004 /* Enable the "bit banger" oh baby */ 2531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_PREGADDR 0x000000f8 /* Address of poll register */ 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_MDIO0 0x00000100 /* MDIO zero, data/attached */ 2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_MDIO1 0x00000200 /* MDIO one, data/attached */ 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_CFG_PDADDR 0x00007c00 /* Device PHY address polling */ 2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Here are some PHY addresses. */ 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_PADDR_ETX 0 /* Internal transceiver */ 2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_PADDR_ITX 1 /* External transceiver */ 2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Transceiver status register */ 2631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_STAT_BASIC 0xffff0000 /* The "basic" part */ 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TCV_STAT_NORMAL 0x0000ffff /* The "non-basic" part */ 2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Inside the Happy Meal transceiver is the physical layer, they use an 2671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * implementations for National Semiconductor, part number DP83840VCE. 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * You can retrieve the data sheets and programming docs for this beast 2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * from http://www.national.com/ 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The DP83840 is capable of both 10 and 100Mbps ethernet, in both 2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * half and full duplex mode. It also supports auto negotiation. 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * But.... THIS THING IS A PAIN IN THE ASS TO PROGRAM! 2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Debugging eeprom burnt code is more fun than programming this chip! 2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Generic MII registers defined in linux/mii.h, these below 2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * are DP83840 specific. 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define DP83840_CSCONFIG 0x17 /* CS configuration */ 2821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* The Carrier Sense config register. */ 2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_RESV1 0x0001 /* Unused... */ 2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_LED4 0x0002 /* Pin for full-dplx LED4 */ 2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_LED1 0x0004 /* Pin for conn-status LED1 */ 2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_RESV2 0x0008 /* Unused... */ 2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_TCVDISAB 0x0010 /* Turns off the transceiver */ 2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_DFBYPASS 0x0020 /* Bypass disconnect function */ 2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_GLFORCE 0x0040 /* Good link force for 100mbps */ 2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_CLKTRISTATE 0x0080 /* Tristate 25m clock */ 2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_RESV3 0x0700 /* Unused... */ 2931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_ENCODE 0x0800 /* 1=MLT-3, 0=binary */ 2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_RENABLE 0x1000 /* Repeater mode enable */ 2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_TCDISABLE 0x2000 /* Disable timeout counter */ 2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_RESV4 0x4000 /* Unused... */ 2971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CSCONFIG_NDISABLE 0x8000 /* Disable NRZI */ 2981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Happy Meal descriptor rings and such. 3001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All descriptor rings must be aligned on a 2K boundary. 3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All receive buffers must be 64 byte aligned. 3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Always write the address first before setting the ownership 3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * bits to avoid races with the hardware scanning the ring. 3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 305f3ec33e587df02e25963755989cc473e3f07bf0dAl Virotypedef u32 __bitwise__ hme32; 306f3ec33e587df02e25963755989cc473e3f07bf0dAl Viro 3071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct happy_meal_rxd { 308f3ec33e587df02e25963755989cc473e3f07bf0dAl Viro hme32 rx_flags; 309f3ec33e587df02e25963755989cc473e3f07bf0dAl Viro hme32 rx_addr; 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RXFLAG_OWN 0x80000000 /* 1 = hardware, 0 = software */ 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RXFLAG_OVERFLOW 0x40000000 /* 1 = buffer overflow */ 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RXFLAG_SIZE 0x3fff0000 /* Size of the buffer */ 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RXFLAG_CSUM 0x0000ffff /* HW computed checksum */ 3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct happy_meal_txd { 318f3ec33e587df02e25963755989cc473e3f07bf0dAl Viro hme32 tx_flags; 319f3ec33e587df02e25963755989cc473e3f07bf0dAl Viro hme32 tx_addr; 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_OWN 0x80000000 /* 1 = hardware, 0 = software */ 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_SOP 0x40000000 /* 1 = start of packet */ 3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_EOP 0x20000000 /* 1 = end of packet */ 3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_CSENABLE 0x10000000 /* 1 = enable hw-checksums */ 3261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_CSLOCATION 0x0ff00000 /* Where to stick the csum */ 3271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_CSBUFBEGIN 0x000fc000 /* Where to begin checksum */ 3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TXFLAG_SIZE 0x00003fff /* Size of the packet */ 3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TX_RING_SIZE 32 /* Must be >16 and <255, multiple of 16 */ 3311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RX_RING_SIZE 32 /* see ERX_CFG_SIZE* for possible values */ 3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if (TX_RING_SIZE < 16 || TX_RING_SIZE > 256 || (TX_RING_SIZE % 16) != 0) 3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#error TX_RING_SIZE holds illegal value 3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TX_RING_MAXSIZE 256 3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RX_RING_MAXSIZE 256 3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* We use a 14 byte offset for checksum computation. */ 3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if (RX_RING_SIZE == 32) 3421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE32|((14/2)<<16)) 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if (RX_RING_SIZE == 64) 3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE64|((14/2)<<16)) 3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if (RX_RING_SIZE == 128) 3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE128|((14/2)<<16)) 3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if (RX_RING_SIZE == 256) 3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ERX_CFG_DEFAULT(off) (ERX_CFG_DMAENABLE|((off)<<3)|ERX_CFG_SIZE256|((14/2)<<16)) 3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 3531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#error RX_RING_SIZE holds illegal value 3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 3561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 3581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define NEXT_RX(num) (((num) + 1) & (RX_RING_SIZE - 1)) 3601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define NEXT_TX(num) (((num) + 1) & (TX_RING_SIZE - 1)) 3611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PREV_RX(num) (((num) - 1) & (RX_RING_SIZE - 1)) 3621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PREV_TX(num) (((num) - 1) & (TX_RING_SIZE - 1)) 3631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define TX_BUFFS_AVAIL(hp) \ 3651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (((hp)->tx_old <= (hp)->tx_new) ? \ 3661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (hp)->tx_old + (TX_RING_SIZE - 1) - (hp)->tx_new : \ 3671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (hp)->tx_old - (hp)->tx_new - 1) 3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RX_OFFSET 2 3701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RX_BUF_ALLOC_SIZE (1546 + RX_OFFSET + 64) 3711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define RX_COPY_THRESHOLD 256 3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct hmeal_init_block { 3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct happy_meal_rxd happy_meal_rxd[RX_RING_MAXSIZE]; 3761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct happy_meal_txd happy_meal_txd[TX_RING_MAXSIZE]; 3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define hblock_offset(mem, elem) \ 3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds((__u32)((unsigned long)(&(((struct hmeal_init_block *)0)->mem[elem])))) 3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Now software state stuff. */ 3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsenum happy_transceiver { 3841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds external = 0, 3851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds internal = 1, 3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds none = 2, 3871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Timer state engine. */ 3901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsenum happy_timer_state { 3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds arbwait = 0, /* Waiting for auto negotiation to complete. */ 3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds lupwait = 1, /* Auto-neg complete, awaiting link-up status. */ 3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ltrywait = 2, /* Forcing try of all modes, from fastest to slowest. */ 3941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds asleep = 3, /* Time inactive. */ 3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct quattro; 3981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Happy happy, joy joy! */ 4001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct happy_meal { 4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *gregs; /* Happy meal global registers */ 4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct hmeal_init_block *happy_block; /* RX and TX descriptors (CPU addr) */ 4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) 405f3ec33e587df02e25963755989cc473e3f07bf0dAl Viro u32 (*read_desc32)(hme32 *); 4061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void (*write_txd)(struct happy_meal_txd *, u32, u32); 4071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void (*write_rxd)(struct happy_meal_rxd *, u32, u32); 4081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4102dc11581376829303b98eadb2de253bee065a56aGrant Likely /* This is either an platform_device or a pci_dev. */ 4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void *happy_dev; 412db1a8611c8733711b40bbce11c87336e3e374634David S. Miller struct device *dma_dev; 4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spinlock_t happy_lock; 4151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sk_buff *rx_skbs[RX_RING_SIZE]; 4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct sk_buff *tx_skbs[TX_RING_SIZE]; 4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int rx_new, tx_new, rx_old, tx_old; 4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct net_device_stats net_stats; /* Statistical counters */ 4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) 4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds u32 (*read32)(void __iomem *); 4251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void (*write32)(void __iomem *, u32); 4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *etxregs; /* External transmitter regs */ 4291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *erxregs; /* External receiver regs */ 4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *bigmacregs; /* BIGMAC core regs */ 4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void __iomem *tcvregs; /* MIF transceiver regs */ 4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dma_addr_t hblock_dvma; /* DVMA visible address happy block */ 4341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int happy_flags; /* Driver state flags */ 4357deb1182175ee06cfcea40452d4f2fb1e33fcbb8Francois Romieu int irq; 4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds enum happy_transceiver tcvr_type; /* Kind of transceiver in use */ 4371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int happy_bursts; /* Get your mind out of the gutter */ 4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int paddr; /* PHY address for transceiver */ 4391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short hm_revision; /* Happy meal revision */ 4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_bmcr; /* SW copy of BMCR */ 4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_bmsr; /* SW copy of BMSR */ 4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_physid1; /* SW copy of PHYSID1 */ 4431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_physid2; /* SW copy of PHYSID2 */ 4441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_advertise; /* SW copy of ADVERTISE */ 4451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_lpa; /* SW copy of LPA */ 4461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_expansion; /* SW copy of EXPANSION */ 4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short sw_csconfig; /* SW copy of CSCONFIG */ 4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int auto_speed; /* Auto-nego link speed */ 4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int forced_speed; /* Force mode link speed */ 4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int poll_data; /* MIF poll data */ 4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int poll_flag; /* MIF poll flag */ 4521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int linkcheck; /* Have we checked the link yet? */ 4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int lnkup; /* Is the link up as far as we know? */ 4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int lnkdown; /* Trying to force the link down? */ 4551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int lnkcnt; /* Counter for link-up attempts. */ 4561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct timer_list happy_timer; /* To watch the link when coming up. */ 4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds enum happy_timer_state timer_state; /* State of the auto-neg timer. */ 4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int timer_ticks; /* Number of clicks at each state. */ 4591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct net_device *dev; /* Backpointer */ 4611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct quattro *qfe_parent; /* For Quattro cards */ 4621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int qfe_ent; /* Which instance on quattro */ 4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 4641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Here are the happy flags. */ 4661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_POLL 0x00000001 /* We are doing MIF polling */ 4671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_FENABLE 0x00000002 /* The MII frame is enabled */ 4681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_LANCE 0x00000004 /* We are using lance-mode */ 4691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_RXENABLE 0x00000008 /* Receiver is enabled */ 4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_AUTO 0x00000010 /* Using auto-negotiation, 0 = force */ 4711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_FULL 0x00000020 /* Full duplex enable */ 4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_MACFULL 0x00000040 /* Using full duplex in the MAC */ 4731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_POLLENABLE 0x00000080 /* Actually try MIF polling */ 4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_RXCV 0x00000100 /* XXX RXCV ENABLE */ 4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_INIT 0x00000200 /* Init called at least once */ 4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_LINKUP 0x00000400 /* 1 = Link is up */ 4771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_PCI 0x00000800 /* PCI based Happy Meal */ 4781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_QUATTRO 0x00001000 /* On QFE/Quattro card */ 4791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_20_21 (HFLAG_POLLENABLE | HFLAG_FENABLE) 4811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define HFLAG_NOT_A0 (HFLAG_POLLENABLE | HFLAG_FENABLE | HFLAG_LANCE | HFLAG_RXCV) 4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Support for QFE/Quattro cards. */ 4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct quattro { 4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct net_device *happy_meals[4]; 4861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* This is either a sbus_dev or a pci_dev. */ 4881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void *quattro_dev; 4891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct quattro *next; 4911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* PROM ranges, if any. */ 4931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SBUS 4941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct linux_prom_ranges ranges[8]; 4951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 4961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int nranges; 4971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 4981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* We use this to acquire receive skb's that we can DMA directly into. */ 5001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define ALIGNED_RX_SKB_ADDR(addr) \ 5011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr)) 5021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define happy_meal_alloc_skb(__length, __gfp_flags) \ 5031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds({ struct sk_buff *__skb; \ 5041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __skb = alloc_skb((__length) + 64, (__gfp_flags)); \ 5051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if(__skb) { \ 5061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int __offset = (int) ALIGNED_RX_SKB_ADDR(__skb->data); \ 5071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if(__offset) \ 5081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds skb_reserve(__skb, __offset); \ 5091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } \ 5101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __skb; \ 5111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}) 5121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* !(_SUNHME_H) */ 514