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

VxWorks

开发平台:

C/C++

  1. /* auEnd.h - END based MAC Ethernet header */
  2. /* Copyright 1998-2001 Wind River Systems, Inc. */
  3. /*
  4.  * This file has been developed or significantly modified by the
  5.  * MIPS Center of Excellence Dedicated Engineering Staff.
  6.  * This notice is as per the MIPS Center of Excellence Master Partner
  7.  * Agreement, do not remove this notice without checking first with
  8.  * WR/Platforms MIPS Center of Excellence engineering management.
  9.  */
  10. /*
  11. modification history
  12. --------------------
  13. 01h,03jun02,zmm  Fix AU_DEV_NAME_LEN, SPR 78215.
  14. 01g,14may02,zmm  Global au1000 name changes. SPR 77333.
  15. 01f,06may02,zmm  Fix SPR 76824.
  16. 01e,15nov01,zmm  Supported auto-negotiation and cache coherent mode.
  17.                  Add base addresses of the Ethernet registers. SPR 71884. 
  18. 01d,11oct01,tlc  Change register names according to new revision of Au1000
  19.                  Databook.  General cleanup.
  20. 01c,21sep01,agf  add ring size warning; 
  21.                  change MAC_ENABLE to use enableAdrs field
  22. 01b,19jun01,zmm  Put volatile in the MAC macros.
  23. 01a,17may01,mem  written.
  24. */
  25. #ifndef __INCauEndh
  26. #define __INCauEndh
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #ifndef _ASMLANGUAGE
  31. #include "end.h"
  32. #include "cacheLib.h"
  33. #include "netinet/if_ether.h"
  34. #include "miiLib.h"
  35. /* board level/bus specific and architecture specific macros */
  36. #if _BYTE_ORDER==_BIG_ENDIAN
  37. #   define PCI_SWAP(x) LONGSWAP((int)(x))
  38. #else
  39. #   define PCI_SWAP(x) (x)
  40. #endif
  41. /* 
  42.  * WARNING -- 
  43.  *   logic in the source code depends on the following being a power of 2 
  44.  */
  45. #define AU_N_TX_BUF 4 /* # of transmit buffers */
  46. #define AU_N_RX_BUF 4 /* # of receive buffers */
  47. /* Device IO or memory mapped access and data registers */
  48. #define AU_MAC_REG(reg)
  49. (*(volatile UINT32 *)((UINT32)(pDrvCtrl->devAdrs)+(reg)))
  50. #define AU_DMA_REG(reg)
  51. (*(volatile UINT32 *)((UINT32)(pDrvCtrl->dmaAdrs)+(reg)))
  52. #define AU_MAC_ENABLE
  53. (*(volatile UINT32 *)((UINT32)(pDrvCtrl->enableAdrs)))
  54. #define AU_MAC_CONTROL AU_MAC_REG(0x00)
  55. #define AU_MAC_ADDRESS_HIGH AU_MAC_REG(0x04)
  56. #define AU_MAC_ADDRESS_LOW AU_MAC_REG(0x08)
  57. #define AU_MULTICAST_HASH_ADDRESS_HIGH AU_MAC_REG(0x0c)
  58. #define AU_MULTICAST_HASH_ADDRESS_LOW AU_MAC_REG(0x10)
  59. #define AU_MII_CONTROL AU_MAC_REG(0x14)
  60. #define AU_MII_DATA AU_MAC_REG(0x18)
  61. #define AU_FLOW_CONTROL AU_MAC_REG(0x1c)
  62. #define AU_VLAN1_TAG AU_MAC_REG(0x20)
  63. #define AU_VLAN2_TAG AU_MAC_REG(0x24)
  64. /* AU Dedicated MAC DMA registers */
  65. #define AU_TX_STATUS(idx) AU_DMA_REG(0x00 + 0x10*(idx))
  66. #define AU_TX_ADDRESS(idx) AU_DMA_REG(0x04 + 0x10*(idx))
  67. #define AU_TX_LENGTH(idx) AU_DMA_REG(0x08 + 0x10*(idx))
  68. #define AU_RX_STATUS(idx) AU_DMA_REG(0x0100 + 0x10*(idx))
  69. #define AU_RX_ADDRESS(idx) AU_DMA_REG(0x0104 + 0x10*(idx))
  70. /* MAC Control bits */
  71. #define AU_MAC_CONTROL_RA (1 << 31) /* receive all */
  72. #define AU_MAC_CONTROL_EM_BIG (1 << 30) /* big endian */
  73. #define AU_MAC_CONTROL_DO         (1 << 23) /* disable receive own */
  74. #define AU_MAC_CONTROL_F         (1 << 20) /* full duplex */
  75. #define AU_MAC_CONTROL_PM (1 << 19) /* pass multicast */
  76. #define AU_MAC_CONTROL_PR (1 << 18) /* promiscuous mode */
  77. #define AU_MAC_CONTROL_IF (1 << 17) /* inverse filtering */
  78. #define AU_MAC_CONTROL_PB (1 << 16) /* pass bad frames */
  79. #define AU_MAC_CONTROL_HO (1 << 15) /* hash-only filter */
  80. #define AU_MAC_CONTROL_HP (1 << 13) /* hash/perfect */
  81. #define AU_MAC_CONTROL_LC (1 << 12) /* late collision */
  82. #define AU_MAC_CONTROL_DB (1 << 11) /* disable broadcast */
  83. #define AU_MAC_CONTROL_DR (1 << 10) /* disable retry */
  84. #define AU_MAC_CONTROL_AP (1 << 8) /* auto pad strip */
  85. #define AU_MAC_CONTROL_BL(n) (((n)&3) << 6) /* backoff limit */
  86. #define AU_MAC_CONTROL_DC (1 << 5) /* deferral clock */
  87. #define AU_MAC_CONTROL_TE (1 << 3) /* Tx enable */
  88. #define AU_MAC_CONTROL_RE (1 << 2) /* Rx enable */
  89. #define AU_MAC_CONTROL_LB_NORMAL (0) /* normal mode */
  90. /* MAC Enable bits */
  91. #define AU_MAC_ENABLE_JP (1 << 6) /* Jumbo Packet Enable */
  92. #define AU_MAC_ENABLE_E2 (1 << 5) /* Enable 2 */
  93. #define AU_MAC_ENABLE_E1 (1 << 4) /* Enable 1 */
  94. #define AU_MAC_ENABLE_C (1 << 3) /* Non-Cacheable */
  95. #define AU_MAC_ENABLE_TS (1 << 2) /* Toss */
  96. #define AU_MAC_ENABLE_E0 (1 << 1) /* Enable 0 */
  97. #define AU_MAC_ENABLE_CE (1 << 0) /* Clocks Enable */
  98. #define AU_MAC_ENABLE_RESET_ALL 0x00 /* Reset all */
  99. #define AU_MAC_ENABLE_CLOCKS_ONLY 0x41 /* only clocks */
  100. #define AU_MAC_ENABLE_NORMAL 0x37 /* Normal operation */
  101. /* CRC for logical address filter */
  102. #define AU_CRC_POLYNOMIAL 0xedb88320 /* CRC polynomial */
  103. #define AU_CRC_TO_LAF_IX(crc) ((crc) >> 26) /* get 6 MSBits */
  104. #define AU_LAF_LEN 8     /* logical addr filter legth */
  105. #define AU_LA_LEN 6 /* logical address length */
  106. #define MAC_ADDRS_SIZE  6
  107. /* MII Defines */
  108. #define AU_MAX_PHY 1
  109. /* MII Control bits */
  110. #define AU_MII_CONTROL_READ 0 /* Read */
  111. #define AU_MII_CONTROL_WRITE (1 << 1) /* Write */
  112. #define AU_MII_CONTROL_BUSY (1 << 0) /* Busy */
  113. #define MII_MGMT_WR_OFF 17
  114. #ifndef MII_WRITE
  115. #   define MII_WRITE               ((ULONG) 0x00002000)
  116. #endif
  117. #ifndef MII_READ
  118. #   define MII_READ                ((ULONG) 0x00044000)
  119. #endif
  120. #define MII_MGMT_WR ((ULONG) 0x00020000)
  121. #define MII_MGMT_CLOCK ((ULONG) 0x00010000)
  122. #define MII_READ_FRM ((ULONG) 0x60000000)
  123. #define MII_WRITE_FRM ((ULONG) 0x50020000)
  124. #define MII_PHY_CTRL_RES ((USHORT) 0x007F)
  125. #define MII_PHY_STAT_RES ((USHORT) 0x07C0)
  126. #define MII_PHY_NWAY_RES ((USHORT) 0x1C00)
  127. #define MII_PHY_NWAY_EXP_RES ((USHORT) 0xFFE0)
  128. #define MII_MGMT_DATA_IN ((ULONG) 0x00080000)
  129. #define MII_READ_DATA_MSK MII_MGMT_DATA_IN
  130. #define DEC_MAX_PHY              32      /* max number of PHY devices */
  131. #define DEC_MAX_LINK_TOUT        6       /* max link timeout (in secs) */
  132. #define MII_PREAMBLE            ((ULONG) 0xFFFFFFFF)
  133. #define MII_LINK_STATUS 0x4
  134. /* MII frame header format */
  135. #define MII_SOF                 0x4     /* start of frame */
  136. #define MII_RD                  0x2     /* op-code: Read */
  137. #define MII_WR                  0x1     /* op-code: Write  */
  138. /* MII PHY registers */
  139. #define MII_PHY_CR              0x00    /* Control Register */
  140. #define MII_PHY_SR              0x01    /* Status Register */
  141. #define MII_PHY_ID0             0x02    /* Identifier Register 0 */
  142. #define MII_PHY_ID1             0x03    /* Identifier Register 1 */
  143. #define MII_PHY_ANA             0x04    /* Auto Negot'n Advertisement */
  144. #define MII_PHY_ANLPA           0x05    /* Auto Negot'n Link Partner Ability */
  145. #define MII_PHY_ANE             0x06    /* Auto Negot'n Expansion */
  146. /* MII PHY Auto Negotiation Advertisement Register */
  147. #define MII_PHY_ANA_TAF 0x03e0  /* Technology Ability Field */
  148. #define MII_PHY_ANA_T4AM 0x0200  /* T4 Technology Ability Mask */
  149. #define MII_PHY_ANA_TXAM 0x0180  /* TX Technology Ability Mask */
  150. #define MII_PHY_ANA_FDAM 0x0140  /* Full Duplex Technology Ability Mask */
  151. #define MII_PHY_ANA_HDAM 0x02a0  /* Half Duplex Technology Ability Mask */
  152. #define MII_PHY_ANA_100M 0x0380  /* 100Mb Technology Ability Mask */
  153. #define MII_PHY_ANA_10M 0x0060  /* 10Mb Technology Ability Mask */
  154. #define MII_PHY_ANA_CSMA 0x0001  /* CSMA-CD Capable */
  155. /* MII PHY Auto Negotiation Remote End Register */
  156. #define MII_PHY_ANLPA_NP 0x8000  /* Next Page (Enable) */
  157. #define MII_PHY_ANLPA_ACK 0x4000  /* Remote Acknowledge */
  158. #define MII_PHY_ANLPA_RF 0x2000  /* Remote Fault */
  159. #define MII_PHY_ANLPA_TAF 0x03e0  /* Technology Ability Field */
  160. #define MII_PHY_ANLPA_T4AM 0x0200  /* T4 Technology Ability Mask */
  161. #define MII_PHY_ANLPA_TXAM 0x0180  /* TX Technology Ability Mask */
  162. #define MII_PHY_ANLPA_FDAM 0x0140  /* Full Duplex Technology Ability Mask */
  163. #define MII_PHY_ANLPA_HDAM 0x02a0  /* Half Duplex Technology Ability Mask */
  164. #define MII_PHY_ANLPA_100M 0x0380  /* 100Mb Technology Ability Mask */
  165. #define MII_PHY_ANLPA_10M 0x0060  /* 10Mb Technology Ability Mask */
  166. #define MII_PHY_ANLPA_CSMA 0x0001  /* CSMA-CD Capable */
  167. /* Special MII flag bit definitions, not the user flag bits */
  168. #define AU_USR_MII_BUS_MON     0x01000000      /* monitor the MII bus */
  169. #define AU_USR_MII_AN_TBL      0x04000000      /* use auto-negotiation table */
  170. #define AU_USR_MII_NO_AN       0x08000000      /* do not auto-negotiate */
  171. #define AU_USR_MII_FD          0x10000000      /* allow full duplex */
  172. #define AU_USR_MII_100MB       0x20000000      /* allow 100 MB */
  173. #define AU_USR_MII_HD          0x40000000      /* allow half duplex */
  174. #define AU_USR_MII_10MB        0x80000000      /* allow 10 MB */
  175. /* Definitions for the drvCtrl specific flags field */
  176. #define AU_PROMISCUOUS_FLAG     0x1     /* set the promiscuous mode */
  177. #define AU_MEM_ALLOC_FLAG       0x2     /* allocating memory flag */
  178. #define AU_PAD_USED_FLAG        0x4     /* padding used flag */
  179. #define AU_RCV_HANDLING_FLAG    0x8     /* handling recv packet */
  180. #define AU_START_OUTPUT_FLAG    0x10    /* trigger output flag */
  181. #define AU_POLLING              0x20    /* polling flag */
  182. #define AU_MODE_MEM_IO_MAP     0x100   /* device registers memory mapped */
  183. #define AU_MODE_DWIO     0x200   /* device in 32 bit mode */
  184. /* The definition of the driver control structure */
  185. typedef struct auDevice
  186.     {
  187.     END_OBJ endObj; /* The class we inherit from */
  188.     int  unit; /* unit number of the device */
  189.     UINT32      flags;                /* Our local flags */
  190.     UINT8 enetAddr[6]; /* ethernet address */
  191.     int         ivec;                   /* interrupt vector */
  192.     int         ilevel;                 /* interrupt level */
  193.     UINT32      devAdrs;                /* device structure address */
  194.     UINT32      dmaAdrs;                /* DMA device address */
  195.     UINT32      enableAdrs;             /* MAC enable register address */
  196.     char * pRxMem[AU_N_RX_BUF]; /* Base of receive buffers */
  197.     char * pTxMem[AU_N_TX_BUF]; /* Base of transmit buffers */
  198.     char *      pRxMemBase;             /* Base address of receive buffers */
  199.     char *      pTxMemBase;             /* Base address of transmit buffers */
  200.     int         offset; /* offset of data in the buffer */
  201.     int         rmdIndex;               /* current RMD index */
  202.     int         rringSize;              /* RMD ring size */
  203.     int         tmdIndex;               /* current TMD index */
  204.     int         tmdLastIndex;           /* last TMD index */
  205.     int         tringSize;              /* TMD ring size */
  206.     PHY_INFO   *pPhyInfo; /* info on a MII-compliant PHY */
  207.     UINT32 miiPhyFlags;      /* MII-compliant PHY flags */
  208.     UINT8 phyAddr;      /* MII-compliant PHY address */
  209.     MII_AN_ORDER_TBL * pMiiPhyTbl;      /* MII-compliant PHY's table */
  210.     CACHE_FUNCS cacheFuncs;             /* cache function pointers */
  211.     BOOL        txBlocked;              /* transmit flow control */
  212.     BOOL        txCleaning; /* transmit descriptor cleaning */
  213.     CL_POOL_ID  pClPoolId; /* cluster pool Id */
  214.     M_CL_CONFIG mClCfg; /* mBlk & cluster config structure */
  215.     CL_DESC clDesc; /* cluster descriptor table */
  216.     END_ERR     lastError;              /* Last error passed to muxError */
  217.     BOOL        errorHandling;          /* task level error handling */
  218.     u_short     errorStat;              /* error status */
  219.     } AU_DRV_CTRL;
  220. /* Configuration items */
  221. #define BUS_LATENCY_COUNT 0x1000 /* Max BUS timeo len in 0.1 uSeconds */
  222. #define AU_MIN_FBUF 100 /* Minsize of first buffer in chain */
  223. #define AU_BUFSIZ (ETHERMTU + SIZEOF_ETHERHEADER + 6)
  224. #define AU_DMA_BUFSIZ 2048 /* Req'd by Au1000 DMA engine */
  225. #define AU_SPEED 10000000
  226. #define AU_RMD_RLEN 5 /* ring size as a ^ 2 -- 32 RMD's */
  227. #define AU_TMD_TLEN 5 /* ring size as a ^ 2 -- 32 TMD's */
  228. #define AU_RMD_MIN 2 /* min descriptors 4 */
  229. #define AU_TMD_MIN 2 /* min descriptors 4 */
  230. #define AU_RMD_MAX 9 /* max descriptors 512 */
  231. #define AU_TMD_MAX 9 /* max descriptors 512 */
  232. #define AU_DEV_NAME "au" /* name of the device */
  233. #define AU_DEV_NAME_LEN 3 /* length of the name string */
  234. #define AU_APROM_SIZE 32 /* hardware address prom size */
  235. #define AU_PKT_LEN_GET(rmd) PCI_SWAP (rmd->rBufMskCnt) - 4;
  236. #if defined(__STDC__) || defined(__cplusplus)
  237. IMPORT END_OBJ * auEndLoad (char * initString);
  238. IMPORT STATUS   auInitParse (AU_DRV_CTRL * pDrvCtrl,
  239.   char * initString);
  240. #else
  241. IMPORT END_OBJ * auEndLoad ();
  242. IMPORT STATUS  auInitParse ();
  243. #endif  /* __STDC__ */
  244. #endif  /* _ASMLANGUAGE */
  245. #ifdef __cplusplus
  246. }
  247. #endif
  248. #endif /* __INCauEndh */