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

VxWorks

开发平台:

C/C++

  1. /* if_elt.h - 3Com EtherLink III network interface header*/ 
  2. /* Copyright 2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01h,19apr02,rcs  added obsolescence warning SPR# 76010 
  7. 01g,06mar96,hdn  added ELT_CTRL.
  8. 01f,13oct95,hdn  changed reset to elt-reset.
  9. 01e,07feb94,bcs  added net job queue statistics
  10. 01d,23jan94,bcs  added timing statistics
  11. 01c,16jan94,bcs  added rxearly to statistics
  12. 01b,08jan94,bcs  added statistics structure
  13. 01a,09dec93,bcs  written. 
  14. */
  15. #ifndef __INCif_elth
  16. #define __INCif_elth
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #warning "if_elt driver is obsolete, please use elt3c509End driver"
  21. #ifndef _ASMLANGUAGE
  22. #define EA_SIZE         6               /* one Ethernet address */
  23. #define EH_SIZE         14              /* avoid structure padding issues */
  24. #define MAX_FRAME_SIZE  (EH_SIZE + ETHERMTU)    /* capacity of buffer */
  25. /* Typedefs for external structures that are not typedef'd in their .h files */
  26. typedef struct mbuf MBUF;
  27. typedef struct arpcom IDR; /* Interface Data Record wrapper */
  28. typedef struct ifnet IFNET; /* real Interface Data Record */
  29. typedef struct sockaddr SOCK;
  30. /* ELT driver data structures */
  31. typedef struct elt_frame                /* frame buffer, list element */
  32.     {
  33.     struct elt_frame *  lNext;          /* linked list pointer */
  34.     u_char              refCnt;         /* reference count when loaned out */
  35.     UINT16              count;          /* bytes left to transmit or */
  36.                                         /* received so far; initially */
  37.                                         /* length rounded up to dword */
  38.                                         /* plus size of "preamble" */
  39.     char *              nextByte;       /* next byte to transmit or */
  40.                                         /* next byte to receive into */
  41.                                         /* Following fields map to FIFO */
  42.                                         /* transmit packet structure; */
  43.                                         /* used same way for receive */
  44.     UINT16              length;         /* length of contained frame */
  45.                                         /* received frame includes error */
  46.     UINT16              unassigned;     /* pad "preamble" to dword size */
  47.     char                header [EH_SIZE];
  48.     char                data [ETHERMTU];
  49.     char                padToDword [MAX_FRAME_SIZE % sizeof (long)];
  50.     } ELT_FRAME;
  51. /* statistics block */
  52. typedef struct 
  53.     {
  54. #define collisions      stat[0]
  55. #define crcs            stat[1]
  56. #define aligns          stat[2]
  57. #define rxnobuffers     stat[3]
  58. #define rxoverruns      stat[4]
  59. #define disabled        stat[5]
  60. #define deferring       stat[6]
  61. #define txunderruns     stat[7]
  62. #define aborts          stat[8]
  63. #define outofwindow     stat[9]
  64. #define heartbeats      stat[10]
  65. #define badPacket       stat[11]
  66. #define shortPacket     stat[12]
  67. #define txnoerror       stat[13]
  68. #define rxnoerror       stat[14]
  69. #define txerror         stat[15]
  70. #define rxerror         stat[16]
  71. #define overwrite       stat[17]
  72. #define wrapped         stat[18]
  73. #define interrupts      stat[19]
  74. #define elt_reset       stat[20]
  75. #define strayint        stat[21]
  76. #define multcollisions  stat[22]
  77. #define latecollisions  stat[23]
  78. #define nocarriers      stat[24]
  79. #define jabbers         stat[25]
  80. #define txoverruns      stat[26]
  81. #define rxunderruns     stat[27]
  82. #define rxearly         stat[28]
  83. #ifdef ELT_TIMING
  84. #define timerUpdates    stat[29]
  85. #define timerOverflow   stat[30]
  86. #define timerInvalid    stat[31]
  87. #define maxRxLatency    stat[32]
  88. #define minRxLatency    stat[33]
  89. #define maxIntLatency   stat[34]
  90. #define taskQRxOuts     stat[35]
  91. #define maxRxTaskQ      stat[36]
  92. #define taskQTxOuts     stat[37]
  93. #define maxTxTaskQ      stat[38]
  94.     UINT stat[40];
  95. #else
  96.     UINT stat[30];
  97. #endif /* ELT_TIMING */
  98.     } ELT_STAT;
  99. /* The definition of the driver control structure */
  100. typedef struct elt_ctrl
  101.     {
  102.     IDR                 idr;        /* interface data record */
  103.     BOOL                attached;   /* indicates attach() called */
  104.     volatile BOOL       rxHandling; /* flag, indicates netTask active/queued */
  105.     volatile BOOL       txHandling; /* flag, indicates netTask active/queued */
  106.     int                 nRxFrames;  /* how many receive frames to create */
  107.     ELT_FRAME *         pFrameArea; /* whole clump of rcv and transmit frames */
  108.     ELT_FRAME *         pTxFrame;   /* transmit frame buffer (only one) */
  109.     volatile ELT_FRAME *pRxHead;    /* head of received frame list */
  110.     ELT_FRAME *         pRxTail;    /* tail of received frame list */
  111.     volatile ELT_FRAME *pRxCurrent; /* frame currently being received */
  112.     int                 nLoanFrames;/* count of loanable frame buffers */
  113.     int                 rxFilter;   /* current receive address filter bits */
  114.     int                 port;       /* base I/O port of this board */
  115.     int                 ivec;       /* interrupt vector */
  116.     int                 intLevel;   /* interrupt level */
  117.     int                 attachment; /* board connector to use (AUI,BNC,TPE) */
  118.     int                 intMask;    /* current board interrupt mask */
  119.     ELT_STAT            eltStat;    /* statistics */
  120. #ifdef ELT_TIMING
  121.     int                 interruptTime; /* timer value at ISR, -1 if invalid */
  122.     int                 maxRxLatency; /* max time to service receive buffer */
  123. #endif /* ELT_TIMING */
  124.     } ELT_CTRL;
  125. /* ELT register offsets, grouped by window number */
  126. /* all windows */
  127. #define ELT_COMMAND     0x0e            /* command register */
  128. #define ELT_STATUS      0x0e            /* status register */
  129. /* window number symbols for selection command */
  130. #define WIN_CONFIG      0x0000
  131. #define WIN_OPERATING   0x0001
  132. #define WIN_ADDRESS     0x0002
  133. #define WIN_FIFO        0x0003
  134. #define WIN_DIAGNOSTIC  0x0004
  135. #define WIN_RESULTS     0x0005
  136. #define WIN_STATISTICS  0x0006
  137. /* window 0, configuration and EEPROM */
  138. #define MANUF_ID        0x00            /* manufacturer ID */
  139. #define PRODUCT_ID      0x02            /* product ID/MCA adapter ID */
  140. #define CONFIG_CONTROL  0x04            /* configuration control */
  141. #define ADDRESS_CONFIG  0x06            /* address configuration */
  142. #define RESOURCE_CONFIG 0x08            /* resource configuration */
  143. #define EEPROM_CONTROL  0x0a            /* EEPROM control */
  144. #define EEPROM_DATA     0x0c            /* EEPROM data in/out */
  145. /* window 1, operating set */
  146. #define DATA_REGISTER   0x00            /* data (low word) in/out */
  147. #define DATA_HIGH       0x02            /* data (high word) in/out */
  148. #define RX_STATUS       0x08            /* received packet status */
  149. #define TIMER           0x0a            /* (byte) interrupt latency timer */
  150. #define TX_STATUS       0x0b            /* (byte) transmit status */
  151. #define TX_FREE_BYTES   0x0c            /* free bytes available in tx FIFO */
  152.                                         /* also appears in window 3 */
  153. /* window 2, station address setup/read */
  154. #define ADDRESS_0       0x00            /* (byte) station address 0 */
  155. #define ADDRESS_1       0x01            /* (byte) station address 1 */
  156. #define ADDRESS_2       0x02            /* (byte) station address 2 */
  157. #define ADDRESS_3       0x03            /* (byte) station address 3 */
  158. #define ADDRESS_4       0x04            /* (byte) station address 4 */
  159. #define ADDRESS_5       0x05            /* (byte) station address 5 */
  160. /* window 3, FIFO management */
  161. #define TX_RECLAIM      0x08            /* MCA tx reclaim threshold */
  162. #define RX_FREE_BYTES   0x0a            /* free bytes available in rx FIFO */
  163. #define TX_FREE_BYTES_3 0x0c            /* free bytes available in tx FIFO */
  164.                                         /* also appears in window 1 */
  165.                                         /* same offset so can use same macro */
  166. /* window 4, diagnostics */
  167. #define TX_DIAGNOSTIC   0x00            /* tx diagnostic */
  168. #define HOST_DIAGNOSTIC 0x02            /* host diagnostic */
  169. #define FIFO_DIAGNOSTIC 0x04            /* FIFO diagnostic */
  170. #define NET_DIAGNOSTIC  0x06            /* net diagnostic */
  171. #define ETHERNET_STATUS 0x08            /* ethernet controller status */
  172. #define MEDIA_STATUS    0x0a            /* media type and status */
  173. /* window 5, command results and internal state (read only) */
  174. #define TX_START_THRESH 0x00            /* tx start threshold + 4 */
  175. #define TX_AVAIL_THRESH 0x02            /* tx available threshold */
  176. #define RX_EARLY_THRESH 0x06            /* rx early threshold */
  177. #define RX_FILTER       0x08            /* rx filter lower 4 bits */
  178. #define INTERRUPT_MASK  0x0a            /* interrupt mask */
  179. #define READ_ZERO_MASK  0x0c            /* read zero mask */
  180. /* window 6, statistics registers (byte regs. MUST be read/written as bytes) */
  181. #define CARRIER_LOSTS   0x00            /* (byte) carrier loss during tx */
  182. #define SQE_FAILURES    0x01            /* (byte) heartbeat loss during tx */
  183. #define MULT_COLLISIONS 0x02            /* (byte) tx with multiple collis. */
  184. #define ONE_COLLISIONS  0x03            /* (byte) tx with one collision */
  185. #define LATE_COLLISIONS 0x04            /* (byte) tx with late collision */
  186. #define RECV_OVERRUNS   0x05            /* (byte) receive overruns */
  187. #define GOOD_TRANSMITS  0x06            /* (byte) frames transmitted OK */
  188. #define GOOD_RECEIVES   0x07            /* (byte) frames received OK */
  189. #define TX_DEFERRALS    0x08            /* (byte) transmit deferrals */
  190. #define BYTES_RECEIVED  0x0a            /* total bytes received OK */
  191. #define BYTES_TRANSMITTED       0x0c    /* total bytes transmitted OK */
  192. /* ISA ID sequence state machine commands */
  193. #define ID_PORT         0x0100          /* I/O port to access ID sequence */
  194.                                         /* could be 0x110..0x1f0 but this */
  195.                                         /* is a highly unlikely address to */
  196.                                         /* be used by anything else */
  197. #define ID_RESET        0x00            /* reset ID state machine */
  198. #define ID_EEPROM_READ  0x80            /* read EEPROM register addressed by */
  199.                                         /* last 6 bits of this command */
  200. #define ID_EEPROM_MASK  0x3f            /* these bits here */
  201. #define ID_SET_TAG      0xd0            /* set tag register to last 3 bits */
  202. #define ID_TAG_MASK     0x07            /* values 1..7 take tagged adapter */
  203.                                         /* out of the contention process */
  204. #define ID_ACTIVATE     0xff            /* activate adapter as pre-configured */
  205. #define ID_SEQUENCE_INITIAL     0xff    /* initial value in ID sequence */
  206. #define ID_SEQUENCE_LENGTH      255     /* iteration count */
  207. #define ID_CARRY_BIT    0x100           /* carry out of 8-bit ID value shift */
  208. #define ID_POLYNOMIAL   0xcf            /* XOR this with ID value */
  209. #define ID_REGISTER_SIZE        16      /* bits in an EEPROM register */
  210. /* important EEPROM addresses */
  211. #define EE_A_PRODUCT_ID 0x03            /* 3C5xx product id */
  212. #define EE_A_MANUFACTURER       0x07    /* 3Com mfg. id == 0x6d50 */
  213. #define EE_A_ADDRESS    0x08            /* address configuration */
  214. #define EE_A_RESOURCE   0x09            /* resource configuration */
  215. #define EE_A_OEM_NODE_0 0x0a            /* word 0 of OEM Ethernet address */
  216. #define EE_A_OEM_NODE_1 0x0b            /* word 1 of OEM Ethernet address */
  217. #define EE_A_OEM_NODE_2 0x0c            /* word 2 of OEM Ethernet address */
  218. #define MANUFACTURER_ID 0x6d50          /* 3Com id code in EEPROM */
  219. /* address configuration register fields and values */
  220. #define AC_IO_BASE_MASK 0x001f          /* I/O base address encoding */
  221.                                         /* 0-30 select n * 0x10 + 0x200 */
  222. #define AC_IO_BASE_ZERO 0x0200          /* first encoded address */
  223. #define AC_IO_BASE_FACTOR       0x10    /* convert code to address range */
  224. #define AC_IO_BASE_EISA 0x001f          /* EISA addressing indicator */
  225. #define AC_XCVR_MASK    0xc000          /* transciever selection field */
  226. #define AC_XCVR_TPE     0x0000          /* select twisted-pair (10BASE-T) */
  227. #define AC_XCVR_AUI     0x4000          /* select AUI (external transceiver) */
  228. #define AC_XCVR_BNC     0xc000          /* select BNC (10BASE-2); must also */
  229.                                         /* activate with START_COAX command */
  230. /* configuration control register bits */
  231. #define CC_ENABLE       0x0001          /* set to enable IRQ driver */
  232. #define CC_RESET        0x0004          /* reset adapter to POR state */
  233. #define CC_POR_INTERNAL_ENDEC   0x0100  /* use internal encoder/decoder */
  234. #define CC_POR_10BASETAVAIL     0x0200  /* on-board TPE transceiver available */
  235. #define CC_POR_TEST_MASK        0x0c00  /* test mode bits */
  236. #define CC_POR_TEST_RECEIVE     0x0400  /* receive test mode */
  237. #define CC_POR_TEST_TRANSMIT    0x0800  /* transmit test mode */
  238. #define CC_POR_TEST_NORMAL      0x0c00  /* normal operation mode */
  239. #define CC_POR_10BASE2_AVAIL    0x1000  /* on-board coax transceiver available*/
  240. #define CC_POR_AUI_AVAIL        0x2000  /* on-board AUI connector evailable */
  241. /* FIFO diagnostic register bits */
  242. #define FD_TX_BC        0x0001          /* TX BIST is complete */
  243. #define FD_TX_BF        0x0002          /* TX BIST has failed */
  244. #define FD_TX_BFC       0x0004          /* sets TX BF to test for stuck-at */
  245. #define FD_TX_BIST      0x0008          /* enable BIST in TX FIFO RAM */
  246. #define FD_RX_BC        0x0010          /* TRX BIST is complete */
  247. #define FD_RX_BF        0x0020          /* RX BIST has failed */
  248. #define FD_RX_BFC       0x0040          /* sets RX BF to test for stuck-at */
  249. #define FD_RX_BIST      0x0080          /* enable BIST in RX FIFO RAM */
  250. #define FD_TX_OVERRUN   0x0400          /* host wrote too much data */
  251. #define FD_RX_OVERRUN   0x0800          /* RX overrun (not necessarily */
  252.                                         /* packet overrun yet) */
  253. #define FD_RX_STATUS_OVERRUN    0x1000  /* already 8 packets in RX FIFO */
  254. #define FD_RX_UNDERRUN  0x2000          /* host read past end of packet */
  255. #define FD_RX_RECEIVING 0x8000          /* packet being received now */
  256. /* media type and status bits */
  257. #define MT_S_SQE_ENABLE 0x0008          /* enable SQE error detection */
  258. #define MT_S_COLLISION  0x0010          /* (?) collision in progress */
  259. #define MT_S_CARRIER    0x0020          /* (?) carrier sensed currently */
  260. #define MT_S_JABBER_ENABLE      0x0040  /* enable jabber and polarity detect */
  261. #define MT_S_LINK_BEAT_ENABLE   0x0080  /* enable TPE link beat */
  262. #define MT_S_UNSQUELCH  0x0100          /* unsquelch status */
  263. #define MT_S_JABBER     0x0200          /* jabber status */
  264. #define MT_S_POLARITY   0x0400          /* polarity swap status */
  265. #define MT_S_LINK_BEAT  0x0800          /* link beat correct status */
  266. #define MT_S_SQE        0x1000          /* SQE present status */
  267. #define MT_S_INTERNAL_ENDEC     0x2000  /* internal encoder/decoder in use */
  268. #define MT_S_BNC        0x4000          /* BNC transceiver in use */
  269. #define MT_S_AUI_DISABLE        0x8000  /* AUI interface disabled */
  270. /* command opcodes (uppper 5 bits of command register) */
  271. #define GLOBAL_RESET    0x0000          /* global reset (powerup equiv.) */
  272. #define SELECT_WINDOW   0x0800          /* select register window */
  273. #define START_COAX      0x1000          /* start coaxial transciever */
  274. #define RX_DISABLE      0x1800          /* disable ethernet receiver */
  275. #define RX_ENABLE       0x2000          /* enable ethernet receiver */
  276. #define RX_RESET        0x2800          /* reset ethernet receiver */
  277. #define RX_DISCARD      0x4000          /* discard remainder of top FIFO pkt */
  278. #define TX_ENABLE       0x4800          /* enable ethernet transmitter */
  279. #define TX_DISABLE      0x5000          /* disable ethernet transmitter */
  280. #define TX_RESET        0x5800          /* reset ethernet transmitter */
  281. #define REQ_INTERRUPT   0x6000          /* set interrupt requested bit */
  282. #define ACK_INTERRUPT   0x6800          /* acknowledge interrupt conditions */
  283. #define MASK_INTERRUPT  0x7000          /* set interrupt mask bits */
  284. #define MASK_STATUS     0x7800          /* set status mask bits */
  285.                                         /* the "read zero mask" */
  286. #define SET_RX_FILTER   0x8000          /* set receive filter bits */
  287. #define SET_RX_THRESH   0x8800          /* set receive early threshold */
  288. #define SET_TX_AVAIL    0x9000          /* set transmit available threshold */
  289. #define SET_TX_START    0x9800          /* set transmit start threshold */
  290. #define STATS_ENABLE    0xa800          /* enable statistics collection */
  291. #define STATS_DISABLE   0xb000          /* disable statistics collection */
  292. #define STOP_COAX       0xb800          /* stop coaxial transciever */
  293. #define SET_TX_RECLAIM  0xc000          /* (MCA) set tx reclaim threshold */
  294. /* receive filter command argument bits */
  295. #define RX_F_STATION_IA 0x01            /* accept individual address */
  296. #define RX_F_MULTICAST  0x02            /* accept multicast (group) addresses */
  297. #define RX_F_BROADCAST  0x04            /* accept broadcast address */
  298. #define RX_F_PROMISCUOUS        0x08    /* accept all addresses */
  299. #define RX_F_NORMAL     (RX_F_STATION_IA | RX_F_BROADCAST)
  300. /* board status bits (also acknowledge and mask bits) */
  301. #define INTERRUPT_LATCH 0x0001          /* raise interrupt to host */
  302. #define ADAPTER_FAILURE 0x0002          /* error unrecoverable by adapter */
  303.                                         /* tx overrun, rx underrun, or */
  304.                                         /* hypothetical hardware errors */
  305. #define TX_COMPLETE     0x0004          /* tx finished with error or */
  306.                                         /* packet interrupt bit was set */
  307. #define TX_AVAILABLE    0x0008          /* tx available threshold exceeded */
  308. #define RX_COMPLETE     0x0010          /* a complete packet is available */
  309. #define RX_EARLY        0x0020          /* rx early threshold exceeded */
  310. #define INTERRUPT_REQ   0x0040          /* set by request interrupt command */
  311. #define UPDATE_STATS    0x0080          /* one or more statistics counters */
  312.                                         /* needs to be flushed */
  313. #define STATUS_MASK     0x00ff          /* pick status bits out of register */
  314. #define COMMAND_IN_PROGRESS     0x1000  /* last command still being processed */
  315. #define WINDOW_MASK     0xe000          /* current register window selection */
  316. /* transmit status register bits */
  317. #define TX_S_RECLAIM    0x02            /* tx reclaim (MCA only) */
  318. #define TX_S_OVERFLOW   0x04            /* tx status overflow (lost info) */
  319. #define TX_S_MAX_COLL   0x08            /* maximum collisions reached */
  320. #define TX_S_UNDERRUN   0x10            /* underrun, tx reset required */
  321. #define TX_S_JABBER     0x20            /* jabber error, tx reset required */
  322. #define TX_S_INTERRUPT  0x40            /* interrupt on successful xmit */
  323. #define TX_S_COMPLETE   0x80            /* transmission complete */
  324.                                         /* This bit denotes a valid status */
  325.                                         /* when set; valid status is popped */
  326.                                         /* off the stack by a write cycle to */
  327.                                         /* the transmit status register */
  328. /* transmit free bytes constants */
  329. #define TX_IDLE_COUNT   0x7f8           /* 2,040; supposed to be 2,044 */
  330.                                         /* use a >= test to see if tx idle */
  331. /* receive status register bits */
  332. #define RX_S_CNT_MASK   0x07ff          /* received byte count field */
  333. #define RX_S_CODE_MASK  0x3800          /* error code field */
  334. #define RX_S_OVERRUN    0x0000          /* overrun error */
  335. #define RX_S_RUNT       0x1800          /* runt packet error */
  336. #define RX_S_ALIGN      0x2000          /* alignment (framing) error */
  337. #define RX_S_CRC        0x2800          /* CRC error */
  338. #define RX_S_OVERSIZE   0x0800          /* oversize packet error (>1514) */
  339. #define RX_S_DRIBBLE    0x1000          /* dribble bit(s); this code is */
  340.                                         /* valid when error bit is not set */
  341. #define RX_S_ERROR      0x4000          /* error in rx packet, code above */
  342. #define RX_S_INCOMPLETE 0x8000          /* packet is incomplete or FIFO empty */
  343.                                         /* opposite of transmit status! */
  344. /* transmit packet preamble bits and fields */
  345. #define TX_F_LEN_MASK   0x07ff          /* length field */
  346. #define TX_F_INTERRUPT  0x8000          /* interrupt on transmit complete */
  347. #define TX_F_DWORD_MASK 0xfffc          /* mask to round lengths to dword */
  348. #define TX_F_PREAMBLE_SIZE      4       /* size of packet length "preamble" */
  349. /* function declarations */
  350. #if defined(__STDC__) || defined(__cplusplus)
  351. extern STATUS eltattach (int unit, int port, int ivec, int intLevel,
  352.     int nRxFrames, int attachment, char *ifName);
  353. #else
  354. extern STATUS eltattach ();
  355. #endif  /* __STDC__ */
  356. #endif  /* _ASMLANGUAGE */
  357. #ifdef __cplusplus
  358. }
  359. #endif
  360. #endif  /* __INCif_elth */