a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**************************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* tlan.c -- Etherboot device driver for the Texas Instruments ThunderLAN
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* This program is free software; you can redistribute it and/or modify
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* it under the terms of the GNU General Public License as published by
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* the Free Software Foundation; either version 2 of the License, or
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* (at your option) any later version.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* This program is distributed in the hope that it will be useful,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* but WITHOUT ANY WARRANTY; without even the implied warranty of
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* GNU General Public License for more details.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* You should have received a copy of the GNU General Public License
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* along with this program; if not, write to the Free Software
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* Portions of this code (almost all) based on:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* tlan.c: Linux ThunderLan Driver:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* by James Banks
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* (C) 1997-1998 Caldera, Inc.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* (C) 1998 James Banks
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* (C) 1999-2001 Torben Mathiasen
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* (C) 2002 Samuel Chessman
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* REVISION HISTORY:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* ================
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* v1.0 07-08-2003 timlegge Initial not quite working version
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* Indent Style: indent -kr -i8
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync***************************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * the General Public License version 2 (GPLv2) at this time for any software where
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * a choice of GPL license versions is made available with the language indicating
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * that GPLv2 or any later version may be used, or where a choice of which version
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * of the GPL is applied is otherwise unspecified.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncFILE_LICENCE ( GPL2_OR_LATER );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync* TLan Definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FALSE 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TRUE 1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_MIN_FRAME_SIZE 64
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_MAX_FRAME_SIZE 1600
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NUM_RX_LISTS 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NUM_TX_LISTS 2
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_IGNORE 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_RECORD 1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DBG(lvl, format, args...) if (debug&lvl) printf("TLAN: " format, ##args );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync*/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEBUG_GNRL 0x0001
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEBUG_TX 0x0002
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEBUG_RX 0x0004
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEBUG_LIST 0x0008
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEBUG_PROBE 0x0010
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define MAX_TLAN_BOARDS 8 /* Max number of boards installed at a time */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Device Identification Definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PCI_DEVICE_ID_NETELLIGENT_10_T2 0xB012
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100 0xB030
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef PCI_DEVICE_ID_OLICOM_OC2183
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef PCI_DEVICE_ID_OLICOM_OC2325
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef PCI_DEVICE_ID_OLICOM_OC2326
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsynctypedef struct tlan_adapter_entry {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync u16 vendorId;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync u16 deviceId;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync char *deviceLabel;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync u32 flags;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync u16 addrOfs;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} TLanAdapterEntry;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ADAPTER_NONE 0x00000000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ADAPTER_BIT_RATE_PHY 0x00000002
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ADAPTER_USE_INTERN_10 0x00000004
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ADAPTER_ACTIVITY_LED 0x00000008
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_SPEED_DEFAULT 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_SPEED_10 10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_SPEED_100 100
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DUPLEX_DEFAULT 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DUPLEX_HALF 1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DUPLEX_FULL 2
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * EISA Definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_ID 0xc80 /* EISA ID Registers */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_ID0 0xc80 /* EISA ID Register 0 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_ID1 0xc81 /* EISA ID Register 1 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_ID2 0xc82 /* EISA ID Register 2 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_ID3 0xc83 /* EISA ID Register 3 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_CR 0xc84 /* EISA Control Register */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_REG0 0xc88 /* EISA Configuration Register 0 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_REG1 0xc89 /* EISA Configuration Register 1 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_REG2 0xc8a /* EISA Configuration Register 2 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_REG3 0xc8f /* EISA Configuration Register 3 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EISA_APROM 0xc90 /* Ethernet Address PROM */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Rx/Tx List Definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_BUFFERS_PER_LIST 10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_LAST_BUFFER 0x80000000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_UNUSED 0x8000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_FRM_CMP 0x4000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_READY 0x3000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_EOC 0x0800
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_RX_ERROR 0x0400
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_PASS_CRC 0x0200
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CSTAT_DP_PR 0x0100
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * PHY definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_PHY_MAX_ADDR 0x1F
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_PHY_NONE 0x20
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * TLan Driver Timer Definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_LINK_BEAT 1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_ACTIVITY 2
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_PHY_PDOWN 3
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_PHY_PUP 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_PHY_RESET 5
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_PHY_START_LINK 6
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_PHY_FINISH_AN 7
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_FINISH_RESET 8
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TIMER_ACT_DELAY (HZ/10)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * TLan Driver Eeprom Definitions
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_EEPROM_ACK 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_EEPROM_STOP 1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync /*****************************************************************
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Host Register Offsets and Contents
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync ****************************************************************/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HOST_CMD 0x00
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_GO 0x80000000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_STOP 0x40000000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_ACK 0x20000000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_CS_MASK 0x1FE00000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_EOC 0x00100000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_RT 0x00080000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_NES 0x00040000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_AD_RST 0x00008000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_LD_TMR 0x00004000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_LD_THR 0x00002000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_REQ_INT 0x00001000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_INT_OFF 0x00000800
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_INT_ON 0x00000400
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HC_AC_MASK 0x000000FF
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CH_PARM 0x04
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DIO_ADR 0x08
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DA_ADR_INC 0x8000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DA_RAM_ADR 0x4000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HOST_INT 0x0A
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HI_IV_MASK 0x1FE0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HI_IT_MASK 0x001C
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DIO_DATA 0x0C
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* ThunderLAN Internal Register DIO Offsets */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD 0x00
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_NRESET 0x80
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_NWRAP 0x40
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_CSF 0x20
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_CAF 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_NOBRX 0x08
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_DUPLEX 0x04
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_TRFRAM 0x02
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CMD_TXPACE 0x01
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO 0x01
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_MINTEN 0x80
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_ECLOK 0x40
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_ETXEN 0x20
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_EDATA 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_NMRST 0x08
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_MCLK 0x04
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_MTXEN 0x02
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_SIO_MDATA 0x01
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_STS 0x02
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_STS_MIRQ 0x80
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_STS_HBEAT 0x40
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_STS_TXSTOP 0x20
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_STS_RXSTOP 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_STS_RSRVD 0x0F
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_MASK 0x03
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_MASK_MASK7 0x80
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_MASK_MASK6 0x40
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_MASK_MASK5 0x20
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_MASK_MASK4 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_MASK_RSRVD 0x0F
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CONFIG 0x04
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_RCLK 0x8000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_TCLK 0x4000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_BIT 0x2000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_RXCRC 0x1000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_PEF 0x0800
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_1FRAG 0x0400
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_1CHAN 0x0200
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_MTEST 0x0100
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_PHY_EN 0x0080
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_NET_CFG_MSMASK 0x007F
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_MAN_TEST 0x06
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEF_VENDOR_ID 0x08
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEF_DEVICE_ID 0x0A
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEF_REVISION 0x0C
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEF_SUBCLASS 0x0D
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEF_MIN_LAT 0x0E
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEF_MAX_LAT 0x0F
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_AREG_0 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_AREG_1 0x16
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_AREG_2 0x1C
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_AREG_3 0x22
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HASH_1 0x28
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_HASH_2 0x2C
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_GOOD_TX_FRMS 0x30
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TX_UNDERUNS 0x33
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_GOOD_RX_FRMS 0x34
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_RX_OVERRUNS 0x37
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_DEFERRED_TX 0x38
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CRC_ERRORS 0x3A
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CODE_ERRORS 0x3B
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_MULTICOL_FRMS 0x3C
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_SINGLECOL_FRMS 0x3E
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_EXCESSCOL_FRMS 0x40
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_LATE_COLS 0x41
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_CARRIER_LOSS 0x42
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ACOMMIT 0x43
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_LED_REG 0x44
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_LED_ACT 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_LED_LINK 0x01
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_BSIZE_REG 0x45
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_MAX_RX 0x46
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_DIS 0x48
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ID_TX_EOC 0x04
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ID_RX_EOF 0x02
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_ID_RX_EOC 0x01
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* ThunderLAN Interrupt Codes */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_NUMBER_OF_INTS 8
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_NONE 0x0000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_TX_EOF 0x0001
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_STAT_OVERFLOW 0x0002
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_RX_EOF 0x0003
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_DUMMY 0x0004
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_TX_EOC 0x0005
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_STATUS_CHECK 0x0006
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_INT_RX_EOC 0x0007
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* ThunderLAN MII Registers */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* ThunderLAN Specific MII/PHY Registers */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TLPHY_ID 0x10
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TLPHY_CTL 0x11
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_IGLINK 0x8000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_SWAPOL 0x4000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_AUISEL 0x2000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_SQEEN 0x1000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_MTEST 0x0800
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_RESERVED 0x07F8
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_NFEW 0x0004
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_INTEN 0x0002
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TC_TINT 0x0001
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TLPHY_STS 0x12
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TS_MINT 0x8000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TS_PHOK 0x4000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TS_POLOK 0x2000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TS_TPENERGY 0x1000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TS_RESERVED 0x0FFF
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_TLPHY_PAR 0x19
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_PHY_CIM_STAT 0x0020
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_PHY_SPEED_100 0x0040
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_PHY_DUPLEX_FULL 0x0080
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLAN_PHY_AN_EN_STAT 0x0400
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* National Sem. & Level1 PHY id's */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define NAT_SEM_ID1 0x2000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define NAT_SEM_ID2 0x5C01
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define LEVEL1_ID1 0x7810
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define LEVEL1_ID2 0x0000
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Routines to access internal registers. */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(internal_addr, base_addr + TLAN_DIO_ADR);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return (inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} /* TLan_DioRead8 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(internal_addr, base_addr + TLAN_DIO_ADR);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return (inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} /* TLan_DioRead16 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(internal_addr, base_addr + TLAN_DIO_ADR);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return (inl(base_addr + TLAN_DIO_DATA));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} /* TLan_DioRead32 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(internal_addr, base_addr + TLAN_DIO_ADR);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(internal_addr, base_addr + TLAN_DIO_ADR);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outw(internal_addr, base_addr + TLAN_DIO_ADR);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#if 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline void TLan_ClearBit(u8 bit, u16 port)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outb_p(inb_p(port) & ~bit, port);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline int TLan_GetBit(u8 bit, u16 port)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return ((int) (inb_p(port) & bit));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline void TLan_SetBit(u8 bit, u16 port)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync outb_p(inb_p(port) | bit, port);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifdef I_LIKE_A_FAST_HASH_FUNCTION
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* the code below is about seven times as fast as the original code */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline u32 TLan_HashFunc(u8 * a)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync u8 hash;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash = (a[0] ^ a[3]); /* & 077 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash ^= ((a[0] ^ a[3]) >> 6); /* & 003 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash ^= ((a[1] ^ a[4]) << 2); /* & 074 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash ^= ((a[1] ^ a[4]) >> 4); /* & 017 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash ^= ((a[2] ^ a[5]) << 4); /* & 060 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash ^= ((a[2] ^ a[5]) >> 2); /* & 077 */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return (hash & 077);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else /* original code */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline u32 xor(u32 a, u32 b)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return ((a && !b) || (!a && b));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#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 ) ) ) ) ) ) )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline u32 TLan_HashFunc(u8 * a)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync u32 hash;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash =
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync XOR8(DA(a, 0), DA(a, 6), DA(a, 12), DA(a, 18), DA(a, 24),
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DA(a, 30), DA(a, 36), DA(a, 42));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash |=
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync XOR8(DA(a, 1), DA(a, 7), DA(a, 13), DA(a, 19), DA(a, 25),
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DA(a, 31), DA(a, 37), DA(a, 43)) << 1;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash |=
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync XOR8(DA(a, 2), DA(a, 8), DA(a, 14), DA(a, 20), DA(a, 26),
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DA(a, 32), DA(a, 38), DA(a, 44)) << 2;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash |=
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync XOR8(DA(a, 3), DA(a, 9), DA(a, 15), DA(a, 21), DA(a, 27),
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DA(a, 33), DA(a, 39), DA(a, 45)) << 3;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash |=
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync XOR8(DA(a, 4), DA(a, 10), DA(a, 16), DA(a, 22), DA(a, 28),
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DA(a, 34), DA(a, 40), DA(a, 46)) << 4;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync hash |=
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync XOR8(DA(a, 5), DA(a, 11), DA(a, 17), DA(a, 23), DA(a, 29),
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DA(a, 35), DA(a, 41), DA(a, 47)) << 5;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return hash;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* I_LIKE_A_FAST_HASH_FUNCTION */