Commit 96e0ee07 authored by Jeff Garzik's avatar Jeff Garzik

Merge pobox.com:/garz/repo/netdev-2.6/tlan

into pobox.com:/garz/repo/net-drivers-2.6
parents 7bedd791 1d947228
......@@ -223,13 +223,11 @@ static const char tlan_banner[] = "ThunderLAN driver v1.15\n";
static int tlan_have_pci;
static int tlan_have_eisa;
const char *media[] = {
static const char *media[] = {
"10BaseT-HD ", "10BaseT-FD ","100baseTx-HD ",
"100baseTx-FD", "100baseT4", NULL
};
int media_map[] = { 0x0020, 0x0040, 0x0080, 0x0100, 0x0200,};
static struct board {
const char *deviceLabel;
u32 flags;
......@@ -382,7 +380,7 @@ static TLanIntVectorFunc *TLanIntVector[TLAN_INT_NUMBER_OF_INTS] = {
static inline void
TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
unsigned long flags = 0;
if (!in_irq())
......@@ -438,7 +436,7 @@ TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type )
static void __devexit tlan_remove_one( struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata( pdev );
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
unregister_netdev( dev );
......@@ -557,7 +555,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &pdev->dev);
priv = dev->priv;
priv = netdev_priv(dev);
priv->pciDev = pdev;
......@@ -693,7 +691,7 @@ static void TLan_Eisa_Cleanup(void)
while( tlan_have_eisa ) {
dev = TLan_Eisa_Devices;
priv = dev->priv;
priv = netdev_priv(dev);
if (priv->dmaStorage) {
pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, priv->dmaStorageDMA );
}
......@@ -854,7 +852,7 @@ static int TLan_Init( struct net_device *dev )
int i;
TLanPrivateInfo *priv;
priv = dev->priv;
priv = netdev_priv(dev);
if ( bbuf ) {
dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
......@@ -937,7 +935,7 @@ static int TLan_Init( struct net_device *dev )
static int TLan_Open( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
int err;
priv->tlanRev = TLan_DioRead8( dev->base_addr, TLAN_DEF_REVISION );
......@@ -983,7 +981,7 @@ static int TLan_Open( struct net_device *dev )
static int TLan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
struct mii_ioctl_data *data = if_mii(rq);
u32 phy = priv->phy[priv->phyNum];
......@@ -1062,7 +1060,7 @@ static void TLan_tx_timeout(struct net_device *dev)
static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
TLanList *tail_list;
dma_addr_t tail_list_phys;
u8 *tail_buffer;
......@@ -1170,7 +1168,7 @@ static irqreturn_t TLan_HandleInterrupt(int irq, void *dev_id, struct pt_regs *r
TLanPrivateInfo *priv;
dev = dev_id;
priv = dev->priv;
priv = netdev_priv(dev);
spin_lock(&priv->lock);
......@@ -1211,7 +1209,7 @@ static irqreturn_t TLan_HandleInterrupt(int irq, void *dev_id, struct pt_regs *r
static int TLan_Close(struct net_device *dev)
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
netif_stop_queue(dev);
priv->neg_be_verbose = 0;
......@@ -1251,7 +1249,7 @@ static int TLan_Close(struct net_device *dev)
static struct net_device_stats *TLan_GetStats( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
int i;
/* Should only read stats if open ? */
......@@ -1270,7 +1268,7 @@ static struct net_device_stats *TLan_GetStats( struct net_device *dev )
TLan_PrintList( priv->txList + i, "TX", i );
}
return ( &( (TLanPrivateInfo *) dev->priv )->stats );
return ( &( (TLanPrivateInfo *) netdev_priv(dev) )->stats );
} /* TLan_GetStats */
......@@ -1405,7 +1403,7 @@ u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
int eoc = 0;
TLanList *head_list;
dma_addr_t head_list_phys;
......@@ -1527,7 +1525,7 @@ u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u32 ack = 0;
int eoc = 0;
u8 *head_buffer;
......@@ -1694,7 +1692,7 @@ u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
TLanList *head_list;
dma_addr_t head_list_phys;
u32 ack = 1;
......@@ -1742,7 +1740,7 @@ u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u32 ack;
u32 error;
u8 net_sts;
......@@ -1817,7 +1815,7 @@ u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
dma_addr_t head_list_phys;
u32 ack = 1;
......@@ -1878,7 +1876,7 @@ u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
void TLan_Timer( unsigned long data )
{
struct net_device *dev = (struct net_device *) data;
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u32 elapsed;
unsigned long flags = 0;
......@@ -1958,7 +1956,7 @@ void TLan_Timer( unsigned long data )
void TLan_ResetLists( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
int i;
TLanList *list;
dma_addr_t list_phys;
......@@ -2018,7 +2016,7 @@ void TLan_ResetLists( struct net_device *dev )
void TLan_FreeLists( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
int i;
TLanList *list;
struct sk_buff *skb;
......@@ -2138,7 +2136,7 @@ void TLan_PrintList( TLanList *list, char *type, int num)
void TLan_ReadAndClearStats( struct net_device *dev, int record )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u32 tx_good, tx_under;
u32 rx_good, rx_over;
u32 def_tx, crc, code;
......@@ -2214,7 +2212,7 @@ void TLan_ReadAndClearStats( struct net_device *dev, int record )
void
TLan_ResetAdapter( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
int i;
u32 addr;
u32 data;
......@@ -2300,7 +2298,7 @@ TLan_ResetAdapter( struct net_device *dev )
void
TLan_FinishReset( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u8 data;
u32 phy;
u8 sio;
......@@ -2464,7 +2462,7 @@ void TLan_SetMac( struct net_device *dev, int areg, char *mac )
void TLan_PhyPrint( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 i, data0, data1, data2, data3, phy;
phy = priv->phy[priv->phyNum];
......@@ -2513,7 +2511,7 @@ void TLan_PhyPrint( struct net_device *dev )
void TLan_PhyDetect( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 control;
u16 hi;
u16 lo;
......@@ -2560,7 +2558,7 @@ void TLan_PhyDetect( struct net_device *dev )
void TLan_PhyPowerDown( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 value;
TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering down PHY(s).\n", dev->name );
......@@ -2585,7 +2583,7 @@ void TLan_PhyPowerDown( struct net_device *dev )
void TLan_PhyPowerUp( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 value;
TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering up PHY.\n", dev->name );
......@@ -2606,7 +2604,7 @@ void TLan_PhyPowerUp( struct net_device *dev )
void TLan_PhyReset( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 phy;
u16 value;
......@@ -2634,7 +2632,7 @@ void TLan_PhyReset( struct net_device *dev )
void TLan_PhyStartLink( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 ability;
u16 control;
u16 data;
......@@ -2721,7 +2719,7 @@ void TLan_PhyStartLink( struct net_device *dev )
void TLan_PhyFinishAutoNeg( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 an_adv;
u16 an_lpa;
u16 data;
......@@ -2805,7 +2803,7 @@ void TLan_PhyFinishAutoNeg( struct net_device *dev )
void TLan_PhyMonitor( struct net_device *dev )
{
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
u16 phy;
u16 phy_status;
......@@ -2882,7 +2880,7 @@ int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
u32 i;
int err;
int minten;
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
unsigned long flags = 0;
err = FALSE;
......@@ -3051,7 +3049,7 @@ void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
u16 sio;
int minten;
unsigned long flags = 0;
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
......@@ -3278,7 +3276,7 @@ void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data )
{
int err;
TLanPrivateInfo *priv = dev->priv;
TLanPrivateInfo *priv = netdev_priv(dev);
unsigned long flags = 0;
int ret=0;
......
......@@ -443,7 +443,7 @@ typedef struct tlan_private_tag {
/* Routines to access internal registers. */
inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
static inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
{
outw(internal_addr, base_addr + TLAN_DIO_ADR);
return (inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)));
......@@ -453,7 +453,7 @@ inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
static inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
{
outw(internal_addr, base_addr + TLAN_DIO_ADR);
return (inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)));
......@@ -463,7 +463,7 @@ inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
static inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
{
outw(internal_addr, base_addr + TLAN_DIO_ADR);
return (inl(base_addr + TLAN_DIO_DATA));
......@@ -473,7 +473,7 @@ inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
static inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
{
outw(internal_addr, base_addr + TLAN_DIO_ADR);
outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
......@@ -483,7 +483,7 @@ inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
static inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
{
outw(internal_addr, base_addr + TLAN_DIO_ADR);
outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
......@@ -493,46 +493,38 @@ inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
static inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
{
outw(internal_addr, base_addr + TLAN_DIO_ADR);
outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
}
#if 0
inline void TLan_ClearBit(u8 bit, u16 port)
{
outb_p(inb_p(port) & ~bit, port);
}
inline int TLan_GetBit(u8 bit, u16 port)
{
return ((int) (inb_p(port) & bit));
}
inline void TLan_SetBit(u8 bit, u16 port)
{
outb_p(inb_p(port) | bit, port);
}
#endif
#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port)
#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit))
#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port)
#ifdef I_LIKE_A_FAST_HASH_FUNCTION
/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */
/* the code below is about seven times as fast as the original code */
inline u32 TLan_HashFunc( u8 *a )
/*
* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those
* the code below is about seven times as fast as the original code
*
* The original code was:
*
* u32 xor( u32 a, u32 b ) { return ( ( a && ! b ) || ( ! a && b ) ); }
*
* #define XOR8( a, b, c, d, e, f, g, h ) \
* xor( a, xor( b, xor( c, xor( d, xor( e, xor( f, xor( g, h ) ) ) ) ) ) )
* #define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
*
* hash = XOR8( DA(a,0), DA(a, 6), DA(a,12), DA(a,18), DA(a,24), DA(a,30), DA(a,36), DA(a,42) );
* hash |= XOR8( DA(a,1), DA(a, 7), DA(a,13), DA(a,19), DA(a,25), DA(a,31), DA(a,37), DA(a,43) ) << 1;
* hash |= XOR8( DA(a,2), DA(a, 8), DA(a,14), DA(a,20), DA(a,26), DA(a,32), DA(a,38), DA(a,44) ) << 2;
* hash |= XOR8( DA(a,3), DA(a, 9), DA(a,15), DA(a,21), DA(a,27), DA(a,33), DA(a,39), DA(a,45) ) << 3;
* hash |= XOR8( DA(a,4), DA(a,10), DA(a,16), DA(a,22), DA(a,28), DA(a,34), DA(a,40), DA(a,46) ) << 4;
* hash |= XOR8( DA(a,5), DA(a,11), DA(a,17), DA(a,23), DA(a,29), DA(a,35), DA(a,41), DA(a,47) ) << 5;
*
*/
static inline u32 TLan_HashFunc( const u8 *a )
{
u8 hash;
......@@ -545,30 +537,4 @@ inline u32 TLan_HashFunc( u8 *a )
return (hash & 077);
}
#else /* original code */
inline u32 xor( u32 a, u32 b )
{
return ( ( a && ! b ) || ( ! a && b ) );
}
#define XOR8( a, b, c, d, e, f, g, h ) xor( a, xor( b, xor( c, xor( d, xor( e, xor( f, xor( g, h ) ) ) ) ) ) )
#define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
inline u32 TLan_HashFunc( u8 *a )
{
u32 hash;
hash = XOR8( DA(a,0), DA(a, 6), DA(a,12), DA(a,18), DA(a,24), DA(a,30), DA(a,36), DA(a,42) );
hash |= XOR8( DA(a,1), DA(a, 7), DA(a,13), DA(a,19), DA(a,25), DA(a,31), DA(a,37), DA(a,43) ) << 1;
hash |= XOR8( DA(a,2), DA(a, 8), DA(a,14), DA(a,20), DA(a,26), DA(a,32), DA(a,38), DA(a,44) ) << 2;
hash |= XOR8( DA(a,3), DA(a, 9), DA(a,15), DA(a,21), DA(a,27), DA(a,33), DA(a,39), DA(a,45) ) << 3;
hash |= XOR8( DA(a,4), DA(a,10), DA(a,16), DA(a,22), DA(a,28), DA(a,34), DA(a,40), DA(a,46) ) << 4;
hash |= XOR8( DA(a,5), DA(a,11), DA(a,17), DA(a,23), DA(a,29), DA(a,35), DA(a,41), DA(a,47) ) << 5;
return hash;
}
#endif /* I_LIKE_A_FAST_HASH_FUNCTION */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment