

Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.
0115000 /*
0115001 * tc589d.h
0115002 *
0115003 * It is header of tc589d.c.
0115004 *
0115005 * Created: Oct 2004 by Wangzhi <quakewang@mail.whut.edu.cn>
0115006 * Referenced: i82365.h created by Philip Homburg
0115007 *
0115008 */
0115009
0115010 /* The following "#if ENABLE_TC589" is important, if we do not define *
0115011 * ENABLE_TC589, this file will not be compile into kernel */
0115012 #if ENABLE_TC589
0115013
0115014 /* The following define the receive buffer(RX) size *
0115015 * The data structure used here is a litte complex, but in essence *
0115016 * it is a queue. This ring queue have many(N_RX_BUF) blocks, *
0115017 * and a block have many(RX_BUF_BLOCK) bytes. So, the total RX buffer *
0115018 * size is TC589_RX_BUFSIZE=(N_RX_BUF*RX_BUF_BLOCK +1600). *
0115019 * PS1: the addition 1600 bytes is for less complex, because I do not *
0115020 * want to handle a ring queue, use this addition 1600 bytes we can *
0115021 * read the packets very easy(anywhere in the queue). If we change this *
0115022 * data structure a litte to ring queue, we can remove this addition *
0115023 * 1600 bytes. *
0115024 * PS2: why we use this stange data structure to hold packet? *
0115025 * Because my receive buffer usually overflow when I use other simple *
0115026 * data structure, especially in a busy network, there are many many *
0115027 * "small" packets all the time, use this strange data structure can *
0115028 * handle them, I wrote a PAPER on this strange(maybe very stupid or *
0115029 * simpe data struture). But, this data structure do very well indeed! */
0115030
0115031 /* Rx buffer size */
0115032 #define N_RX_BUF 200
0115033 #define RX_BUF_BLOCK 64
0115034 #define TC589_RX_BUFSIZE (N_RX_BUF*RX_BUF_BLOCK +1600)
0115035
0115036 /* Rx buffer start address in computer memory */
0115037 phys_bytes tc_rx_mem_start;
0115038 /* Rx buffer end address in computer memory */
0115039 phys_bytes tc_rx_mem_end;
0115040
0115041 /* Transmit buffer(TX) can hold NR_TX_BUF packets */
0115042
0115043 #define NR_TX_BUF 10
0115044 #define TX_BUF_BLOCK 1600
0115045
0115046 /* Tx buffer size */
0115047 #define TC589_TX_BUFSIZE (NR_TX_BUF * TX_BUF_BLOCK)
0115048
0115049 /* boot parameter about iobase and irq */
0115050 #define ENV_VAR "TC589D"
0115051
0115052 /* I/O vectors are handled IOVEC_NR entries at a time. used in writev. */
0115053 #define IOVEC_NR 16
0115054
0115055 /* how many network card can handle? */
0115056 #define TC_PORT_NR 1 /* Minix */
0115057
0115058 /* some constants and flags used in driver */
0115059 #define REM_DISABLED 0x0
0115060 #define REM_ENABLED 0x1
0115061
0115062 #define REF_PACK_SENT 0x001
0115063 #define REF_PACK_RECV 0x002
0115064 #define REF_SEND_AVAIL 0x004
0115065 #define REF_READING 0x010
0115066 #define REF_EMPTY 0x000
0115067 #define REF_PROMISC 0x040
0115068 #define REF_MULTI 0x080
0115069 #define REF_BROAD 0x100
0115070 #define REF_ENABLED 0x200
0115071 #define MY_RXCOMPLETE 0x1
0115072 #define MY_TVCOMPLETE 0x2
0115073
0115074 /* Offsets from base I/O address. */
0115075 #define EL3_DATA 0x00
0115076 #define EL3_TIMER 0x0a
0115077 #define EL3_CMD 0x0e
0115078 #define EL3_STATUS 0x0e
0115079 #define ID_PORT 0x100
0115080 #define EEPROM_READ 0x80
0115081
0115082 /* select 3C589D current windown, see specification of 3c589D */
0115083 #define EL3WINDOW(win_num) outw(0x300+EL3_CMD, SelectWindow + (win_num))
0115084
0115085 /* The top five bits written to EL3_CMD are a command, the lower
0115086 11 bits are the parameter, if applicable. see specification of 3c589D */
0115087 enum c509cmd {
0115088 TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11,
0115089 RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11, RxDiscard = 8<<11,
0115090 TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11,
0115091 FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11,
0115092 SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11,
0115093 SetTxThreshold = 18<<11, SetTxStart = 19<<11, StatsEnable = 21<<11,
0115094 StatsDisable = 22<<11, StopCoax = 23<<11
0115095 };
0115096
0115097 enum c509status {
0115098 IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004,
0115099 TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020,
0115100 IntReq = 0x0040, StatsFull = 0x0080, CmdBusy = 0x1000
0115101 };
0115102
0115103 /* The SetRxFilter command accepts the following classes: */
0115104 enum RxFilter {
0115105 RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8
0115106 };
0115107
0115108 /* Register window 1 offsets, the window used in normal operation. */
0115109 #define TX_FIFO 0x00
0115110 #define RX_FIFO 0x00
0115111 #define RX_STATUS 0x08
0115112 #define TX_STATUS 0x0B
0115113 #define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */
0115114
0115115 #define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */
0115116 #define WN4_MEDIA 0x0A /* Window 4: Various transcvr/media bits. */
0115117 #define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */
0115118 #define MEDIA_LED 0x0001 /* Enable link light on 3C589E cards. */
0115119
0115120 /* Time in jiffies before concluding Tx hung */
0115121 #define TX_TIMEOUT ((400*HZ)/1000)
0115122
0115123 #endif /* #if ENABLE_TC589 */
0115124
0115125 /*
0115126 * tc589d.h,v 1.0 2004/10/4 14:58 Wangzhi.
0115127 */