elt3c509End.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:18k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* elt3c509End.h - 3Com EtherLink III END network interface header*/ 
  2. /* Copyright 1998-2000 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01d,02aug00,jkf  moved statistic definitions to the driver, SPR#26952
  7. 01c,11jun00,ham  removed reference to etherLib.
  8. 01b,10mar99,sbs  added DEF_NUM_RX_FRAMES.
  9. 01a,28sep98,snk  written by mBedded Innovations Inc. 
  10. */
  11. #ifndef __INCelt3c509Endh
  12. #define __INCelt3c509Endh
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include "netinet/if_ether.h"
  17. #ifndef _ASMLANGUAGE
  18. /* debug defines */
  19. #undef DRV_DEBUG
  20. #ifdef DRV_DEBUG
  21. #define ELT_TIMING
  22. #endif /* DRV_DEBUG */
  23.     
  24. /* defines */
  25. #define EA_SIZE         6                /* one Ethernet address */
  26. #define EH_SIZE         14               /* ethernet header size */
  27. #define MAX_FRAME_SIZE  (EH_SIZE + ETHERMTU)    /* capacity of buffer */
  28. #define DEF_NUM_RX_FRAMES 64      /* default number of receive frames */
  29. #define ATTACHMENT_DEFAULT      0       /* use card as configured */
  30. #define ATTACHMENT_AUI          1       /* AUI  (thick, DIX, DB-15) */
  31. #define ATTACHMENT_BNC          2       /* BNC  (thin, 10BASE-2) */
  32. #define ATTACHMENT_RJ45         3       /* RJ-45 (twisted pair, TPE,10BASE-T)*/
  33. /* Configuration items */
  34. #define ELT3C509_BUFSIZ        (ETHERMTU + SIZEOF_ETHERHEADER + 6)
  35. #define ELT3C509_SPEED         10000000
  36. #define ELT_PRODUCTID_3C589    0x9058 /* product ID for PCMCIA 3C589 */
  37. /* naming items */
  38. #define ELT3C509_DEV_NAME  "elt"
  39. #define ELT3C509_DEV_NAME_LEN  4
  40. /* flags */
  41.     
  42. #define ELT3C_PROMISCUOUS_FLAG 0x1
  43. #define ELT3C_RCV_HANDLING_FLAG 0x2
  44. #define ELT3C_POLLING 0x4
  45. /* statistic block, see also driver source code */
  46. typedef struct 
  47.     {
  48. #ifdef ELT_TIMING
  49.     UINT elt3c509Stats[40];
  50. #else
  51.     UINT elt3c509Stats[30];
  52. #endif 
  53.     } ELT3C509_STAT;
  54.     /* ELT driver data structures */
  55. typedef struct elt3c509_device
  56.     {
  57.     END_OBJ      endObj; /* The class we inherit from. */
  58.     int unit; /* unit number */
  59.     char * pTxCluster; /* pointer to transmit cluster */
  60.     int nRxFrames; /* number of recv frames */
  61.     int                 rxFilter;    /* current recv address filter bits */
  62.     int                 port;        /* base I/O port of this board */
  63.     int                 ivec;        /* interrupt vector */
  64.     int                 intLevel;    /* interrupt level */
  65.     int                 attachment;  /* connector to use (AUI,BNC,TPE) */
  66.     int                 intMask; /* current board interrupt mask */
  67.     ELT3C509_STAT       elt3c509Stat; /* statistics */
  68.     long flags; /* Our local flags. */
  69.     UCHAR enetAddr [6]; /* ethernet address */
  70.     CACHE_FUNCS  cacheFuncs;     /* cache function pointers */
  71.     BOOL     txBlocked;  /* indicates netTask active/queued */
  72.     CL_POOL_ID   pClPoolId; /* cluster pool id */
  73.     M_CL_CONFIG endClConfig; /* cluster config structure */
  74.     CL_DESC endClDesc; /* cluster descriptor table */
  75. #ifdef ELT_TIMING
  76.     int                 interruptTime; /* timer value at ISR, -1 if invalid */
  77.     int                 maxRxLatency; /* max time to service receive buffer */
  78. #endif /* ELT_TIMING */
  79.     } ELT3C509_DEVICE;
  80. /* ELT register offsets, grouped by window number */
  81. /* all windows */
  82. #define ELT3C509_COMMAND     0x0e            /* command register */
  83. #define ELT3C509_STATUS      0x0e            /* status register */
  84. /* window number symbols for selection command */
  85. #define WIN_CONFIG      0x0000
  86. #define WIN_OPERATING   0x0001
  87. #define WIN_ADDRESS     0x0002
  88. #define WIN_FIFO        0x0003
  89. #define WIN_DIAGNOSTIC  0x0004
  90. #define WIN_RESULTS     0x0005
  91. #define WIN_STATISTICS  0x0006
  92. /* window 0, configuration and EEPROM */
  93. #define MANUF_ID        0x00            /* manufacturer ID */
  94. #define PRODUCT_ID      0x02            /* product ID/MCA adapter ID */
  95. #define CONFIG_CONTROL  0x04            /* configuration control */
  96. #define ADDRESS_CONFIG  0x06            /* address configuration */
  97. #define RESOURCE_CONFIG 0x08            /* resource configuration */
  98. #define EEPROM_CONTROL  0x0a            /* EEPROM control */
  99. #define EEPROM_DATA     0x0c            /* EEPROM data in/out */
  100. /* window 1, operating set */
  101. #define DATA_REGISTER   0x00            /* data (low word) in/out */
  102. #define DATA_HIGH       0x02            /* data (high word) in/out */
  103. #define RX_STATUS       0x08            /* received packet status */
  104. #define TIMER           0x0a            /* (byte) interrupt latency timer */
  105. #define TX_STATUS       0x0b            /* (byte) transmit status */
  106. #define TX_FREE_BYTES   0x0c            /* free bytes available in tx FIFO */
  107.                                         /* also appears in window 3 */
  108. /* window 2, station address setup/read */
  109. #define ADDRESS_0       0x00            /* (byte) station address 0 */
  110. #define ADDRESS_1       0x01            /* (byte) station address 1 */
  111. #define ADDRESS_2       0x02            /* (byte) station address 2 */
  112. #define ADDRESS_3       0x03            /* (byte) station address 3 */
  113. #define ADDRESS_4       0x04            /* (byte) station address 4 */
  114. #define ADDRESS_5       0x05            /* (byte) station address 5 */
  115. /* window 3, FIFO management */
  116. #define TX_RECLAIM      0x08            /* MCA tx reclaim threshold */
  117. #define RX_FREE_BYTES   0x0a            /* free bytes available in rx FIFO */
  118. #define TX_FREE_BYTES_3 0x0c            /* free bytes available in tx FIFO */
  119.                                         /* also appears in window 1 */
  120.                                         /* same offset so can use same macro */
  121. /* window 4, diagnostics */
  122. #define TX_DIAGNOSTIC   0x00            /* tx diagnostic */
  123. #define HOST_DIAGNOSTIC 0x02            /* host diagnostic */
  124. #define FIFO_DIAGNOSTIC 0x04            /* FIFO diagnostic */
  125. #define NET_DIAGNOSTIC  0x06            /* net diagnostic */
  126. #define ETHERNET_STATUS 0x08            /* ethernet controller status */
  127. #define MEDIA_STATUS    0x0a            /* media type and status */
  128. /* window 5, command results and internal state (read only) */
  129. #define TX_START_THRESH 0x00            /* tx start threshold + 4 */
  130. #define TX_AVAIL_THRESH 0x02            /* tx available threshold */
  131. #define RX_EARLY_THRESH 0x06            /* rx early threshold */
  132. #define RX_FILTER       0x08            /* rx filter lower 4 bits */
  133. #define INTERRUPT_MASK  0x0a            /* interrupt mask */
  134. #define READ_ZERO_MASK  0x0c            /* read zero mask */
  135. /* window 6, statistics registers (byte regs. MUST be read/written as bytes) */
  136. #define CARRIER_LOSTS    0x00   /* (byte) carrier loss during tx */
  137. #define SQE_FAILURES     0x01   /* (byte) heartbeat loss during tx */
  138. #define MULT_COLLISIONS  0x02   /* (byte) tx with multiple collis. */
  139. #define ONE_COLLISIONS   0x03   /* (byte) tx with one collision */
  140. #define LATE_COLLISIONS  0x04   /* (byte) tx with late collision */
  141. #define RECV_OVERRUNS    0x05   /* (byte) receive overruns */
  142. #define GOOD_TRANSMITS   0x06   /* (byte) frames transmitted OK */
  143. #define GOOD_RECEIVES    0x07   /* (byte) frames received OK */
  144. #define TX_DEFERRALS     0x08   /* (byte) transmit deferrals */
  145. #define BYTES_RECEIVED   0x0a   /* total bytes received OK */
  146. #define BYTES_TRANSMITTED       0x0c   /* total bytes transmitted OK */
  147. /* ISA ID sequence state machine commands */
  148. #define ID_PORT         0x0100          /* I/O port to access ID sequence */
  149.                                         /* could be 0x110..0x1f0 but this */
  150.                                         /* is a highly unlikely address to */
  151.                                         /* be used by anything else */
  152. #define ID_RESET        0x00            /* reset ID state machine */
  153. #define ID_EEPROM_READ  0x80            /* read EEPROM register addressed by */
  154.                                         /* last 6 bits of this command */
  155. #define ID_EEPROM_MASK  0x3f            /* these bits here */
  156. #define ID_SET_TAG      0xd0            /* set tag register to last 3 bits */
  157. #define ID_TAG_MASK     0x07            /* values 1..7 take tagged adapter */
  158.                                         /* out of the contention process */
  159. #define ID_ACTIVATE     0xff            /* activate adapter as pre-configured */
  160. #define ID_SEQUENCE_INITIAL     0xff    /* initial value in ID sequence */
  161. #define ID_SEQUENCE_LENGTH      255     /* iteration count */
  162. #define ID_CARRY_BIT     0x100   /* carry out of 8-bit ID value shift */
  163. #define ID_POLYNOMIAL    0xcf    /* XOR this with ID value */
  164. #define ID_REGISTER_SIZE        16      /* bits in an EEPROM register */
  165. /* important EEPROM addresses */
  166. #define EE_A_PRODUCT_ID  0x03    /* 3C5xx product id */
  167. #define EE_A_MANUFACTURER       0x07    /* 3Com mfg. id == 0x6d50 */
  168. #define EE_A_ADDRESS     0x08    /* address configuration */
  169. #define EE_A_RESOURCE    0x09    /* resource configuration */
  170. #define EE_A_OEM_NODE_0  0x0a    /* word 0 of OEM Ethernet address */
  171. #define EE_A_OEM_NODE_1  0x0b    /* word 1 of OEM Ethernet address */
  172. #define EE_A_OEM_NODE_2  0x0c    /* word 2 of OEM Ethernet address */
  173. #define MANUFACTURER_ID  0x6d50  /* 3Com id code in EEPROM */
  174. /* address configuration register fields and values */
  175. #define AC_IO_BASE_MASK  0x001f  /* I/O base address encoding */
  176.      /* 0-30 select n * 0x10 + 0x200 */
  177. #define AC_IO_BASE_ZERO  0x0200  /* first encoded address */
  178. #define AC_IO_BASE_FACTOR       0x10    /* convert code to address range */
  179. #define AC_IO_BASE_EISA  0x001f  /* EISA addressing indicator */
  180. #define AC_XCVR_MASK     0xc000  /* transciever selection field */
  181. #define AC_XCVR_TPE      0x0000  /* select twisted-pair (10BASE-T) */
  182. #define AC_XCVR_AUI      0x4000  /* select AUI (external transceiver) */
  183. #define AC_XCVR_BNC      0xc000  /* select BNC (10BASE-2); must also */
  184.                                         /* activate with START_COAX command */
  185.     
  186. /* configuration control register bits */
  187. #define CC_ENABLE        0x0001 /* set to enable IRQ driver */
  188. #define CC_RESET         0x0004 /* reset adapter to POR state */
  189. #define CC_POR_INTERNAL_ENDEC   0x0100 /* use internal encoder/decoder */
  190. #define CC_POR_10BASETAVAIL     0x0200
  191.          /* on-board TPE transceiver available */
  192. #define CC_POR_TEST_MASK        0x0c00 /* test mode bits */
  193. #define CC_POR_TEST_RECEIVE     0x0400 /* receive test mode */
  194. #define CC_POR_TEST_TRANSMIT    0x0800 /* transmit test mode */
  195. #define CC_POR_TEST_NORMAL      0x0c00 /* normal operation mode */
  196. #define CC_POR_10BASE2_AVAIL    0x1000
  197.        /* on-board coax transceiver available*/
  198. #define CC_POR_AUI_AVAIL        0x2000 /* on-board AUI connector evailable */
  199. /* FIFO diagnostic register bits */
  200. #define FD_TX_BC         0x0001  /* TX BIST is complete */
  201. #define FD_TX_BF         0x0002  /* TX BIST has failed */
  202. #define FD_TX_BFC        0x0004  /* sets TX BF to test for stuck-at */
  203. #define FD_TX_BIST       0x0008  /* enable BIST in TX FIFO RAM */
  204. #define FD_RX_BC         0x0010  /* TRX BIST is complete */
  205. #define FD_RX_BF         0x0020  /* RX BIST has failed */
  206. #define FD_RX_BFC        0x0040  /* sets RX BF to test for stuck-at */
  207. #define FD_RX_BIST       0x0080  /* enable BIST in RX FIFO RAM */
  208. #define FD_TX_OVERRUN    0x0400  /* host wrote too much data */
  209. #define FD_RX_OVERRUN    0x0800  /* RX overrun (not necessarily */
  210.                                         /* packet overrun yet) */
  211. #define FD_RX_STATUS_OVERRUN    0x1000  /* already 8 packets in RX FIFO */
  212. #define FD_RX_UNDERRUN   0x2000  /* host read past end of packet */
  213. #define FD_RX_RECEIVING  0x8000  /* packet being received now */
  214. /* media type and status bits */
  215. #define MT_S_SQE_ENABLE  0x0008  /* enable SQE error detection */
  216. #define MT_S_COLLISION   0x0010  /* (?) collision in progress */
  217. #define MT_S_CARRIER     0x0020  /* (?) carrier sensed currently */
  218. #define MT_S_JABBER_ENABLE      0x0040  /* enable jabber and polarity detect */
  219. #define MT_S_LINK_BEAT_ENABLE   0x0080  /* enable TPE link beat */
  220. #define MT_S_UNSQUELCH   0x0100  /* unsquelch status */
  221. #define MT_S_JABBER      0x0200  /* jabber status */
  222. #define MT_S_POLARITY    0x0400  /* polarity swap status */
  223. #define MT_S_LINK_BEAT   0x0800  /* link beat correct status */
  224. #define MT_S_SQE         0x1000  /* SQE present status */
  225. #define MT_S_INTERNAL_ENDEC     0x2000  /* internal encoder/decoder in use */
  226. #define MT_S_BNC         0x4000  /* BNC transceiver in use */
  227. #define MT_S_AUI_DISABLE        0x8000  /* AUI interface disabled */
  228. /* command opcodes (uppper 5 bits of command register) */
  229. #define GLOBAL_RESET    0x0000          /* global reset (powerup equiv.) */
  230. #define SELECT_WINDOW   0x0800          /* select register window */
  231. #define START_COAX      0x1000          /* start coaxial transciever */
  232. #define RX_DISABLE      0x1800          /* disable ethernet receiver */
  233. #define RX_ENABLE       0x2000          /* enable ethernet receiver */
  234. #define RX_RESET        0x2800          /* reset ethernet receiver */
  235. #define RX_DISCARD      0x4000          /* discard remainder of top FIFO pkt */
  236. #define TX_ENABLE       0x4800          /* enable ethernet transmitter */
  237. #define TX_DISABLE      0x5000          /* disable ethernet transmitter */
  238. #define TX_RESET        0x5800          /* reset ethernet transmitter */
  239. #define REQ_INTERRUPT   0x6000          /* set interrupt requested bit */
  240. #define ACK_INTERRUPT   0x6800          /* acknowledge interrupt conditions */
  241. #define MASK_INTERRUPT  0x7000          /* set interrupt mask bits */
  242. #define MASK_STATUS     0x7800          /* set status mask bits */
  243.                                         /* the "read zero mask" */
  244. #define SET_RX_FILTER   0x8000          /* set receive filter bits */
  245. #define SET_RX_THRESH   0x8800          /* set receive early threshold */
  246. #define SET_TX_AVAIL    0x9000          /* set transmit available threshold */
  247. #define SET_TX_START    0x9800          /* set transmit start threshold */
  248. #define STATS_ENABLE    0xa800          /* enable statistics collection */
  249. #define STATS_DISABLE   0xb000          /* disable statistics collection */
  250. #define STOP_COAX       0xb800          /* stop coaxial transciever */
  251. #define SET_TX_RECLAIM  0xc000          /* (MCA) set tx reclaim threshold */
  252. /* receive filter command argument bits */
  253. #define RX_F_STATION_IA  0x01  /* accept individual address */
  254. #define RX_F_MULTICAST   0x02  /* accept multicast (group) addresses */
  255. #define RX_F_BROADCAST   0x04  /* accept broadcast address */
  256. #define RX_F_PROMISCUOUS        0x08  /* accept all addresses */
  257. #define RX_F_NORMAL     (RX_F_STATION_IA | RX_F_BROADCAST)
  258. /* board status bits (also acknowledge and mask bits) */
  259. #define INTERRUPT_LATCH  0x0001 /* raise interrupt to host */
  260. #define ADAPTER_FAILURE  0x0002 /* error unrecoverable by adapter */
  261.                                        /* tx overrun, rx underrun, or */
  262.                                        /* hypothetical hardware errors */
  263. #define TX_COMPLETE      0x0004 /* tx finished with error or */
  264.                                        /* packet interrupt bit was set */
  265. #define TX_AVAILABLE     0x0008 /* tx available threshold exceeded */
  266. #define RX_COMPLETE      0x0010 /* a complete packet is available */
  267. #define RX_EARLY         0x0020 /* rx early threshold exceeded */
  268. #define INTERRUPT_REQ    0x0040 /* set by request interrupt command */
  269. #define UPDATE_STATS     0x0080 /* one or more statistics counters */
  270.                                        /* needs to be flushed */
  271. #define STATUS_MASK      0x00ff /* pick status bits out of register */
  272. #define COMMAND_IN_PROGRESS     0x1000 /* last command still being processed */
  273. #define WINDOW_MASK      0xe000 /* current register window selection */
  274. /* transmit status register bits */
  275. #define TX_S_RECLAIM    0x02            /* tx reclaim (MCA only) */
  276. #define TX_S_OVERFLOW   0x04            /* tx status overflow (lost info) */
  277. #define TX_S_MAX_COLL   0x08            /* maximum collisions reached */
  278. #define TX_S_UNDERRUN   0x10            /* underrun, tx reset required */
  279. #define TX_S_JABBER     0x20            /* jabber error, tx reset required */
  280. #define TX_S_INTERRUPT  0x40            /* interrupt on successful xmit */
  281. #define TX_S_COMPLETE   0x80            /* transmission complete */
  282.                                         /* This bit denotes a valid status */
  283.                                         /* when set; valid status is popped */
  284.                                         /* off the stack by a write cycle to */
  285.                                         /* the transmit status register */
  286. /* transmit free bytes constants */
  287. #define TX_IDLE_COUNT   0x7f8           /* 2,040; supposed to be 2,044 */
  288.                                         /* use a >= test to see if tx idle */
  289. /* receive status register bits */
  290. #define RX_S_CNT_MASK   0x07ff          /* received byte count field */
  291. #define RX_S_CODE_MASK  0x3800          /* error code field */
  292. #define RX_S_OVERRUN    0x0000          /* overrun error */
  293. #define RX_S_RUNT       0x1800          /* runt packet error */
  294. #define RX_S_ALIGN      0x2000          /* alignment (framing) error */
  295. #define RX_S_CRC        0x2800          /* CRC error */
  296. #define RX_S_OVERSIZE   0x0800          /* oversize packet error (>1514) */
  297. #define RX_S_DRIBBLE    0x1000          /* dribble bit(s); this code is */
  298.                                         /* valid when error bit is not set */
  299. #define RX_S_ERROR      0x4000          /* error in rx packet, code above */
  300. #define RX_S_INCOMPLETE 0x8000          /* packet is incomplete or FIFO empty */
  301.                                         /* opposite of transmit status! */
  302. /* transmit packet preamble bits and fields */
  303. #define TX_F_LEN_MASK    0x07ff  /* length field */
  304. #define TX_F_INTERRUPT   0x8000  /* interrupt on transmit complete */
  305. #define TX_F_DWORD_MASK  0xfffc  /* mask to round lengths to dword */
  306. #define TX_F_PREAMBLE_SIZE      4       /* size of packet length "preamble" */
  307. #endif  /* _ASMLANGUAGE */
  308. #ifdef __cplusplus
  309. }
  310. #endif
  311. #endif  /* __INCelt3c509Endh */