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

VxWorks

开发平台:

C/C++

  1. /* motFecEnd.h - Motorola FEC Ethernet network interface header */
  2. /* Copyright 1990-2002 Wind River Systems, Inc. */
  3. /* Copyright 1999-2000 Motorola, Inc., All Rights Reserved */
  4. /*
  5. modification history
  6. --------------------
  7. 01g,01apr02,pmr  SPR 72070: passing unit number to sysFecEnetAddrGet.
  8. 01f,07dec01,rcs  added  define REV_D_3 SPR# 71420  
  9. 01e,26oct01,crg  added support for proper setting of MII management interface
  10.                  speed (SPR 33812)
  11. 01d,21nov00,rhk  added define for revision D4 processor and for pin mux bit.
  12. 01c,11jun00,ham  removed reference to etherLib.
  13. 01b,09feb99,cn  changes required by performance improvement (SPR# 24883).
  14. 01a,09nov98,cn  written.
  15. */
  16. #ifndef __INCmotFecEndh
  17. #define __INCmotFecEndh
  18. /* includes */
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* defines */
  23. /* revision D.3 and greater processors require special FEC initialization */
  24. #define REV_D_4 0x0502
  25. #define REV_D_3 0x0501
  26. /*
  27.  * redefine the macro below in the bsp if you need to access the device
  28.  * registers/descriptors in a more suitable way.
  29.  */
  30. #ifndef MOT_FEC_LONG_WR
  31. #define MOT_FEC_LONG_WR(addr, value)                                        
  32.     (* (addr) = ((UINT32) (value)))
  33. #endif /* MOT_FEC_LONG_WR */
  34. #ifndef MOT_FEC_WORD_WR
  35. #define MOT_FEC_WORD_WR(addr, value)                                        
  36.     (* (addr) = ((UINT16) (value)))
  37. #endif /* MOT_FEC_WORD_WR */
  38. #ifndef MOT_FEC_BYTE_WR
  39. #define MOT_FEC_BYTE_WR(addr, value)                                        
  40.     (* (addr) = ((UINT8) (value)))
  41. #endif /* MOT_FEC_BYTE_WR */
  42. #ifndef MOT_FEC_LONG_RD
  43. #define MOT_FEC_LONG_RD(addr, value)                                        
  44.     ((value) = (* (UINT32 *) (addr)))
  45. #endif /* MOT_FEC_LONG_RD */
  46. #ifndef MOT_FEC_WORD_RD
  47. #define MOT_FEC_WORD_RD(addr, value)                                        
  48.     ((value) = (* (UINT16 *) (addr)))
  49. #endif /* MOT_FEC_WORD_RD */
  50. #ifndef MOT_FEC_BYTE_RD
  51. #define MOT_FEC_BYTE_RD(addr, value)                                        
  52.     ((value) = (* (UINT8 *) (addr)))
  53. #endif /* MOT_FEC_BYTE_RD */
  54. /*
  55.  * Default macro definitions for BSP interface.
  56.  * These macros can be redefined in a wrapper file, to generate
  57.  * a new module with an optimized interface.
  58.  */
  59. #ifndef SYS_FEC_INT_CONNECT
  60. #define SYS_FEC_INT_CONNECT(pDrvCtrl, pFunc, arg, ret)                      
  61. {                                                                           
  62. IMPORT STATUS intConnect (VOIDFUNCPTR *, VOIDFUNCPTR, int);     
  63. ret = OK;                                                                   
  64.                                                                             
  65. if (MOT_FEC_VECTOR (pDrvCtrl) && (!(pDrvCtrl->intrConnect)))       
  66.     {                                                                       
  67.     pDrvCtrl->intrConnect = TRUE;                                        
  68.     ret = (intConnect) ((VOIDFUNCPTR*)                                   
  69.                                 INUM_TO_IVEC (MOT_FEC_VECTOR (pDrvCtrl)),   
  70.                                 (pFunc), (int) (arg));                      
  71.     }                                                                       
  72. }
  73. #endif /* SYS_FEC_INT_CONNECT */
  74. #ifndef SYS_FEC_INT_DISCONNECT
  75. #define SYS_FEC_INT_DISCONNECT(pDrvCtrl, pFunc, arg, ret)                   
  76. {                                                                           
  77. ret = OK;                                                                   
  78.                                                                             
  79. if (MOT_FEC_VECTOR (pDrvCtrl) && (motFecIntDisc != NULL))                  
  80.     {                                                                       
  81.     pDrvCtrl->intrConnect = FALSE;                                          
  82.     ret = (*motFecIntDisc) ((VOIDFUNCPTR*)                               
  83.                               INUM_TO_IVEC (MOT_FEC_VECTOR (pDrvCtrl)),     
  84.                               (pFunc));                                     
  85.     }                                                                       
  86. }
  87. #endif /* SYS_FEC_INT_DISCONNECT */
  88. #ifndef SYS_FEC_INT_ENABLE
  89. #define SYS_FEC_INT_ENABLE(pDrvCtrl, ret)     
  90. {                                                                           
  91. IMPORT int intEnable (int);     
  92. ret = OK;                                                                   
  93.                                                                             
  94. if (MOT_FEC_VECTOR (pDrvCtrl))           
  95.     ret = intEnable ((int) (MOT_FEC_VECTOR (pDrvCtrl)));     
  96. }
  97. #endif /* SYS_FEC_INT_ENABLE */
  98. #ifndef SYS_FEC_INT_DISABLE
  99. #define SYS_FEC_INT_DISABLE(pDrvCtrl, ret)     
  100. {                                                                           
  101. IMPORT int intDisable (int);     
  102. ret = OK;                                                                   
  103.                                                                             
  104. if (MOT_FEC_VECTOR (pDrvCtrl))           
  105.     ret = intDisable ((int) (MOT_FEC_VECTOR (pDrvCtrl)));     
  106. }
  107. #endif /* SYS_FEC_INT_DISABLE */
  108. #define SYS_FEC_ENET_ADDR_GET(address)                                  
  109. if (sysFecEnetAddrGet != NULL)                                          
  110.     if (sysFecEnetAddrGet (pDrvCtrl->unit, (address)) == ERROR)         
  111.         {                                                               
  112.         errnoSet (S_iosLib_INVALID_ETHERNET_ADDRESS);                   
  113.         return (NULL);                                                  
  114.         }
  115. #define SYS_FEC_ENET_ENABLE                                             
  116. if (sysFecEnetEnable != NULL)                                           
  117.     if (sysFecEnetEnable (pDrvCtrl->motCpmAddr) == ERROR)               
  118.         return (ERROR);
  119. #define SYS_FEC_ENET_DISABLE                                            
  120. if (sysFecEnetDisable != NULL)                                          
  121.     if (sysFecEnetDisable (pDrvCtrl->motCpmAddr) == ERROR)              
  122.         return (ERROR);
  123. #define MOT_FEC_DEV_NAME        "motfec"
  124. #define MOT_FEC_DEV_NAME_LEN    7
  125. #define MOT_FEC_TBD_DEF_NUM     64 /* default number of TBDs */
  126. #define MOT_FEC_RBD_DEF_NUM     48 /* default number of RBDs */
  127. #define MOT_FEC_TX_CL_NUM     6 /* number of tx clusters */
  128. #define MOT_FEC_BD_LOAN_NUM     32 /* loaned BDs */
  129. #define MOT_FEC_TBD_MAX         128      /* max number of TBDs */
  130. #define MOT_FEC_RBD_MAX         128      /* max number of TBDs */
  131. #define MOT_FEC_WAIT_MAX 0xf0000000 /* max delay after sending */
  132. #define MOT_FEC_ADDR_LEN        6               /* ethernet address length */
  133. /* Control/Status Registers (CSR) definitions */
  134. #define MOT_FEC_CSR_OFF         0x0e00  /* CSRs offset in the 860T RAM */
  135. #define MOT_FEC_ADDR_L_OFF      0x0e00  /* lower 32-bits of MAC address */
  136. #define MOT_FEC_ADDR_H_OFF      0x0e04  /* upper 16-bits of MAC address */
  137. #define MOT_FEC_HASH_H_OFF      0x0e08  /* upper 32-bits of hash table */
  138. #define MOT_FEC_HASH_L_OFF      0x0e0c  /* lower 32-bits of hash table */
  139. #define MOT_FEC_RX_START_OFF    0x0e10  /* rx ring start address */
  140. #define MOT_FEC_TX_START_OFF    0x0e14  /* tx ring start address */
  141. #define MOT_FEC_RX_BUF_OFF      0x0e18  /* max rx buf length */
  142. #define MOT_FEC_CTRL_OFF        0x0e40  /* FEC control register */
  143. #define MOT_FEC_EVENT_OFF       0x0e44  /* interrupt event register */
  144. #define MOT_FEC_MASK_OFF        0x0e48  /* interrupt mask register */
  145. #define MOT_FEC_VEC_OFF         0x0e4c  /* interrupt level/vector register */
  146. #define MOT_FEC_RX_ACT_OFF      0x0e50  /* rx ring has been updated */
  147. #define MOT_FEC_TX_ACT_OFF      0x0e54  /* tx ring has been updated */
  148. #define MOT_FEC_MII_DATA_OFF    0x0e80  /* MII data register */
  149. #define MOT_FEC_MII_SPEED_OFF   0x0e84  /* MII speed register */
  150. #define MOT_FEC_RX_BOUND_OFF    0x0ecc  /* rx fifo limit in the 860T ram */
  151. #define MOT_FEC_RX_FIFO_OFF     0x0ed0  /* rx fifo base in the 860T ram */
  152. #define MOT_FEC_TX_FIFO_OFF     0x0eec  /* tx fifo base in the 860T ram */
  153. #define MOT_FEC_SDMA_OFF        0x0f34  /* function code to SDMA */
  154. #define MOT_FEC_RX_CTRL_OFF     0x0f44  /* rx control register */
  155. #define MOT_FEC_RX_FR_OFF       0x0f48  /* max rx frame length */
  156. #define MOT_FEC_TX_CTRL_OFF     0x0f84  /* tx control register */
  157. /* Control/Status Registers (CSR) bit definitions */
  158. #define MOT_FEC_RX_START_MSK    0xfffffffc      /* quad-word alignment */
  159.                                                 /* required for rx BDs */
  160. #define MOT_FEC_TX_START_MSK    0xfffffffc      /* quad-word alignment */
  161.                                                 /* required for tx BDs */
  162. /* Ethernet CSR bit definitions */
  163. #define MOT_FEC_ETH_PINMUX 0x00000004 /* select FEC for port D pins */
  164. #define MOT_FEC_ETH_EN          0x00000002      /* enable Ethernet operation */
  165. #define MOT_FEC_ETH_DIS         0x00000000      /* disable Ethernet operation */
  166. #define MOT_FEC_ETH_RES         0x00000001      /* reset the FEC */
  167. #define MOT_FEC_CTRL_MASK       0x00000007      /* FEC control register mask */
  168. /*
  169.  * interrupt bits definitions: these are common to both the
  170.  * mask and the event register.
  171.  */
  172. #define MOT_FEC_EVENT_HB        0x80000000      /* heartbeat error */
  173. #define MOT_FEC_EVENT_BABR      0x40000000      /* babbling rx error */
  174. #define MOT_FEC_EVENT_BABT      0x20000000      /* babbling tx error */
  175. #define MOT_FEC_EVENT_GRA       0x10000000      /* graceful stop complete */
  176. #define MOT_FEC_EVENT_TXF       0x08000000      /* tx frame */
  177. #define MOT_FEC_EVENT_TXB       0x04000000      /* tx buffer */
  178. #define MOT_FEC_EVENT_RXF       0x02000000      /* rx frame */
  179. #define MOT_FEC_EVENT_RXB       0x01000000      /* rx buffer */
  180. #define MOT_FEC_EVENT_MII       0x00800000      /* MII transfer */
  181. #define MOT_FEC_EVENT_BERR      0x00400000      /* U-bus access error */
  182. #define MOT_FEC_EVENT_MSK       0xffc00000      /* clear all interrupts */
  183. #define MOT_FEC_MASK_ALL        MOT_FEC_EVENT_MSK    /* mask all interrupts */
  184. /* bit masks for the interrupt level/vector CSR */
  185. #define MOT_FEC_LVL_MSK         0xe0000000      /* intr level */
  186. #define MOT_FEC_TYPE_MSK        0x0000000c      /* highest pending intr */
  187. #define MOT_FEC_VEC_MSK         0xe000000c      /* this register mask */
  188. #define MOT_FEC_RES_MSK         0x1ffffff3      /* reserved bits */
  189. #define MOT_FEC_LVL_SHIFT       0x1d            /* intr level bits location */
  190. /* transmit and receive active registers definitions */
  191. #define MOT_FEC_TX_ACT          0x01000000      /* tx active bit */
  192. #define MOT_FEC_RX_ACT          0x01000000      /* rx active bit */
  193. /* MII management frame CSRs */
  194. #define MOT_FEC_MII_ST          0x40000000      /* start of frame delimiter */
  195. #define MOT_FEC_MII_OP_RD       0x20000000      /* perform a read operation */
  196. #define MOT_FEC_MII_OP_WR       0x10000000      /* perform a write operation */
  197. #define MOT_FEC_MII_ADDR_MSK    0x0f800000      /* PHY address field mask */
  198. #define MOT_FEC_MII_REG_MSK     0x007c0000      /* PHY register field mask */
  199. #define MOT_FEC_MII_TA          0x00020000      /* turnaround */
  200. #define MOT_FEC_MII_DATA_MSK    0x0000ffff      /* PHY data field */
  201. #define MOT_FEC_MII_RA_SHIFT    0x12            /* mii reg address bits */
  202. #define MOT_FEC_MII_PA_SHIFT    0x17            /* mii PHY address bits */
  203. #define MOT_FEC_MII_PRE_DIS     0x00000080      /* desable preamble */
  204. #define MOT_FEC_MII_SPEED_25    0x00000005      /* recommended for 25Mhz CPU */
  205. #define MOT_FEC_MII_SPEED_33    0x00000007      /* recommended for 33Mhz CPU */
  206. #define MOT_FEC_MII_SPEED_40    0x00000008      /* recommended for 40Mhz CPU */
  207. #define MOT_FEC_MII_SPEED_50    0x0000000a      /* recommended for 50Mhz CPU */
  208. #define MOT_FEC_MII_SPEED_SHIFT 1 /* MII_SPEED bits location */
  209. #define MOT_FEC_MII_CLOCK_MAX 2500000 /* max freq of MII clock (Hz) */
  210. #define MOT_FEC_MII_MAN_DIS     0x00000000      /* disable the MII management */
  211.                                                 /* interface */
  212. #define MOT_FEC_MII_SPEED_MSK   0xffffff81      /* speed field mask */
  213. /* FIFO transmit and receive CSRs definitions */
  214. #define MOT_FEC_FIFO_MSK        0x000003ff      /* FIFO rx/tx/bound mask */
  215. /* SDMA function code CSR */
  216. #define MOT_FEC_SDMA_DATA_BE    0x60000000      /* big-endian byte-ordering */
  217.                                                 /* for SDMA data transfer */
  218. #define MOT_FEC_SDMA_DATA_PPC   0x20000000      /* PPC byte-ordering */
  219.                                                 /* for SDMA data transfer */
  220. #define MOT_FEC_SDMA_DATA_RES   0x00000000      /* reserved value */
  221. #define MOT_FEC_SDMA_BD_BE      0x18000000      /* big-endian byte-ordering */
  222.                                                 /* for SDMA BDs transfer */
  223. #define MOT_FEC_SDMA_BD_PPC     0x08000000      /* PPC byte-ordering */
  224.                                                 /* for SDMA BDs transfer */
  225. #define MOT_FEC_SDMA_BD_RES     0x00000000      /* reserved value */
  226. #define MOT_FEC_SDMA_FUNC_0     0x00000000      /* no function code */
  227. /* receive control/hash registers bit definitions */
  228. #define MOT_FEC_RX_CTRL_PROM    0x00000008      /* promiscous mode */
  229. #define MOT_FEC_RX_CTRL_MII     0x00000004      /* select MII interface */
  230. #define MOT_FEC_RX_CTRL_DRT     0x00000002      /* disable rx on transmit */
  231. #define MOT_FEC_RX_CTRL_LOOP    0x00000001      /* loopback mode */
  232. #define MOT_FEC_RX_FR_MSK       0x000007ff      /* rx frame length mask */
  233. /* transmit control register bit definitions */
  234. #define MOT_FEC_TX_CTRL_FD      0x00000004      /* enable full duplex mode */
  235. #define MOT_FEC_TX_CTRL_HBC     0x00000002      /* HB check is performed */
  236. #define MOT_FEC_TX_CTRL_GRA     0x00000001      /* issue a graceful tx stop */
  237. /* rx/tx buffer descriptors definitions */
  238. #define MOT_FEC_RBD_SZ          8       /* RBD size in byte */
  239. #define MOT_FEC_TBD_SZ          8       /* TBD size in byte */
  240. #define MOT_FEC_TBD_MIN         6       /* min number of TBDs */
  241. #define MOT_FEC_RBD_MIN         4       /* min number of RBDs */
  242. #define MOT_FEC_TBD_POLL_NUM    1       /* one TBD for poll operation */
  243. #define CL_OVERHEAD             4       /* prepended cluster overhead */
  244. #define CL_ALIGNMENT            4       /* cluster required alignment */
  245. #define MBLK_ALIGNMENT          4       /* mBlks required alignment */
  246. #define MOT_FEC_BD_ALIGN        0x10    /* required alignment for RBDs */
  247. #define MOT_FEC_MAX_PCK_SZ      (ETHERMTU + SIZEOF_ETHERHEADER          
  248.                                  + ETHER_CRC_LEN)
  249. #define MOT_FEC_BD_STAT_OFF     0       /* offset of the status word */
  250. #define MOT_FEC_BD_LEN_OFF      2       /* offset of the data length word */
  251. #define MOT_FEC_BD_ADDR_OFF     4       /* offset of the data pointer word */
  252. /* TBD bits definitions */
  253. #define MOT_FEC_TBD_RDY         0x8000          /* ready for transmission */
  254. #define MOT_FEC_TBD_TO1         0x4000          /* transmit ownership bit 1 */
  255. #define MOT_FEC_TBD_WRAP        0x2000          /* look at CSR5 for next bd */
  256. #define MOT_FEC_TBD_TO2         0x1000          /* transmit ownership bit 2 */
  257. #define MOT_FEC_TBD_LAST        0x0800          /* last bd in this frame */
  258. #define MOT_FEC_TBD_CRC         0x0400          /* transmit the CRC sequence */
  259. #define MOT_FEC_TBD_DEF         0x0200          /* deferred transmission */
  260. #define MOT_FEC_TBD_HB          0x0100          /* heartbeat error */
  261. #define MOT_FEC_TBD_LC          0x0080          /* late collision */
  262. #define MOT_FEC_TBD_RL          0x0040          /* retransmission limit */
  263. #define MOT_FEC_TBD_UN          0x0002          /* underrun error */
  264. #define MOT_FEC_TBD_CSL         0x0001          /* carrier sense lost */
  265. #define MOT_FEC_TBD_RC_MASK     0x003c          /* retransmission count mask */
  266. /* RBD bits definitions */
  267. #define MOT_FEC_RBD_EMPTY       0x8000          /* ready for reception */
  268. #define MOT_FEC_RBD_RO1         0x4000          /* receive ownership bit 1 */
  269. #define MOT_FEC_RBD_WRAP        0x2000          /* look at CSR4 for next bd */
  270. #define MOT_FEC_RBD_RO2         0x1000          /* receive ownership bit 2 */
  271. #define MOT_FEC_RBD_LAST        0x0800          /* last bd in this frame */
  272. #define MOT_FEC_RBD_RES1        0x0400          /* reserved bit 1 */
  273. #define MOT_FEC_RBD_RES2        0x0200          /* reserved bit 2 */
  274. #define MOT_FEC_RBD_MISS        0x0100          /* address recognition miss */
  275. #define MOT_FEC_RBD_BC          0x0080          /* broadcast frame */
  276. #define MOT_FEC_RBD_MC          0x0040          /* multicast frame */
  277. #define MOT_FEC_RBD_LG          0x0020          /* frame length violation */
  278. #define MOT_FEC_RBD_NO          0x0010          /* nonoctet aligned frame */
  279. #define MOT_FEC_RBD_SH          0x0008          /* short frame error */
  280.                                                 /* not supported by the 860T */
  281. #define MOT_FEC_RBD_CRC         0x0004          /* CRC error */
  282. #define MOT_FEC_RBD_OV          0x0002          /* overrun error */
  283. #define MOT_FEC_RBD_TR          0x0001          /* truncated frame (>2KB) */
  284. #define MOT_FEC_RBD_ERR         (MOT_FEC_RBD_LG  |                      
  285.                                  MOT_FEC_RBD_NO  |                      
  286.                                  MOT_FEC_RBD_CRC |                      
  287.                                  MOT_FEC_RBD_OV  |                      
  288.                                  MOT_FEC_RBD_TR)
  289. #define MOT_FEC_CRC_POLY 0x04c11db7 /* CRC polynomium: */
  290. /* x^32 + x^26 + x^23 + */
  291. /* x^22 + x^16 + x^12 + */
  292. /* x^11 + x^10 + x^8  + */
  293. /* x^7  + x^5  + x^4  + */
  294. /* x^2  + x^1  + x^0  + */
  295. #define MOT_FEC_HASH_MASK 0x7c000000 /* bits 27-31 */
  296. #define MOT_FEC_HASH_SHIFT 0x1a /* to get the index */
  297. /* defines related to the PHY device */
  298. #define MOT_FEC_PHY_PRE_INIT 0x0001 /* PHY info initialized */
  299. #define MOT_FEC_PHY_AUTO 0x0010 /* enable auto-negotiation */
  300. #define MOT_FEC_PHY_TBL 0x0020 /* use negotiation table */
  301. #define MOT_FEC_PHY_100 0x0040 /* PHY may use 100Mbit speed */
  302. #define MOT_FEC_PHY_10 0x0080 /* PHY may use 10Mbit speed */
  303. #define MOT_FEC_PHY_FD 0x0100 /* PHY may use full duplex */
  304. #define MOT_FEC_PHY_HD 0x0200 /* PHY may use half duplex */
  305. #define MOT_FEC_PHY_MAX_WAIT 0x100 /* max delay before */
  306. #define MOT_FEC_PHY_NULL 0xff /* PHY is not present */
  307. #define MOT_FEC_PHY_DEF 0x0 /* PHY's logical address */
  308. /* allowed PHY's speeds */
  309. #define MOT_FEC_100MBS 100000000       /* bits per sec */
  310. #define MOT_FEC_10MBS 10000000        /* bits per sec */
  311. /*
  312.  * user flags: full duplex mode, loopback mode, serial interface etc.
  313.  * the user may configure some of this options according to his needs
  314.  * by setting the related bits in the <userFlags> field of the load string.
  315.  */
  316. #define MOT_FEC_USR_PHY_NO_AN 0x00000001 /* do not auto-negotiate */
  317. #define MOT_FEC_USR_PHY_TBL 0x00000002 /* use negotiation table */
  318. #define MOT_FEC_USR_PHY_NO_FD 0x00000004 /* do not use full duplex */
  319. #define MOT_FEC_USR_PHY_NO_100 0x00000008 /* do not use 100Mbit speed */
  320. #define MOT_FEC_USR_PHY_NO_HD 0x00000010 /* do not use half duplex */
  321. #define MOT_FEC_USR_PHY_NO_10 0x00000020 /* do not use 10Mbit speed */
  322. #define MOT_FEC_USR_PHY_ISO 0x00000100 /* isolate a PHY */
  323. #define MOT_FEC_USR_SER 0x00000200 /* 7-wire serial interface */
  324. #define MOT_FEC_USR_LOOP 0x00000400 /* loopback mode */
  325. /* only use it for testing */
  326. #define MOT_FEC_USR_HBC 0x00000080 /* perform heartbeat control */
  327. #define MOT_FEC_TBD_OK 0x1 /* the TBD is a good one */
  328. #define MOT_FEC_TBD_BUSY 0x2 /* the TBD has not been used */
  329. #define MOT_FEC_TBD_ERROR 0x4 /* the TBD is errored */
  330. #define PKT_TYPE_MULTI 0x1 /* packet with a multicast address */
  331. #define PKT_TYPE_UNI 0x2 /* packet with a unicast address */
  332. #define PKT_TYPE_NONE 0x4 /* address type is not meaningful */
  333. #define BUF_TYPE_CL 0x1 /* this's a cluster pointer */
  334. #define BUF_TYPE_MBLK 0x2 /* this's a mblk pointer */
  335. /* frame descriptors definitions */
  336. typedef char * MOT_FEC_BD_ID;
  337. typedef MOT_FEC_BD_ID    MOT_FEC_TBD_ID;
  338. typedef MOT_FEC_BD_ID    MOT_FEC_RBD_ID;
  339. /* MII definitions */
  340. #define ETHER_CRC_LEN 0x4 /* CRC length in bytes */
  341. #define MII_MAX_PHY_NUM 0x20 /* max number of attached PHYs */
  342. #define MII_CTRL_REG 0x0 /* Control Register */
  343. #define MII_STAT_REG 0x1 /* Status Register */
  344. #define MII_PHY_ID1_REG 0x2 /* PHY identifier 1 Register */
  345. #define MII_PHY_ID2_REG 0x3 /* PHY identifier 2 Register */
  346. #define MII_AN_ADS_REG 0x4 /* Auto-Negotiation    */
  347. /* Advertisement Register */
  348. #define MII_AN_PRTN_REG 0x5 /* Auto-Negotiation      */
  349. /* partner ability Register */
  350. #define MII_AN_EXP_REG 0x6 /* Auto-Negotiation   */
  351. /* Expansion Register */
  352. #define MII_AN_NEXT_REG 0x7 /* Auto-Negotiation         */
  353. /* next-page transmit Register */
  354. /* MII control register bit  */
  355. #define MII_CR_COLL_TEST 0x0080 /* collision test */
  356. #define MII_CR_FDX 0x0100 /* FDX =1, half duplex =0 */
  357. #define MII_CR_RESTART 0x0200 /* restart auto negotiation */
  358. #define MII_CR_ISOLATE 0x0400 /* isolate PHY from MII */
  359. #define MII_CR_POWER_DOWN 0x0800 /* power down */
  360. #define MII_CR_AUTO_EN 0x1000 /* auto-negotiation enable */
  361. #define MII_CR_100 0x2000 /* 0 = 10mb, 1 = 100mb */
  362. #define MII_CR_LOOPBACK 0x4000 /* 0 = normal, 1 = loopback */
  363. #define MII_CR_RESET 0x8000 /* 0 = normal, 1 = PHY reset */
  364. #define MII_CR_NORM_EN 0x0000 /* just enable the PHY */
  365. /* MII Status register bit definitions */
  366. #define MII_SR_LINK_STATUS 0x0004        /* link Status -- 1 = link */
  367. #define MII_SR_AUTO_SEL 0x0008        /* auto speed select capable */
  368. #define MII_SR_REMOTE_FAULT     0x0010       /* Remote fault detect */
  369. #define MII_SR_AUTO_NEG         0x0020       /* auto negotiation complete */
  370. #define MII_SR_10T_HALF_DPX     0x0800      /* 10BaseT HD capable */
  371. #define MII_SR_10T_FULL_DPX     0x1000     /* 10BaseT FD capable */
  372. #define MII_SR_TX_HALF_DPX      0x2000     /* TX HD capable */
  373. #define MII_SR_TX_FULL_DPX      0x4000      /* TX FD capable */
  374. #define MII_SR_T4               0x8000     /* T4 capable */
  375. /* MII Link Code word  bit definitions */
  376. #define MII_BP_FAULT 0x2000        /* remote fault */
  377. #define MII_BP_ACK 0x4000        /* acknowledge */
  378. #define MII_BP_NP 0x8000        /* nexp page is supported */
  379. /* MII Next Page bit definitions */
  380. #define MII_NP_TOGGLE 0x0800        /* toggle bit */
  381. #define MII_NP_ACK2 0x1000        /* acknowledge two */
  382. #define MII_NP_MSG 0x2000        /* message page */
  383. #define MII_NP_ACK1 0x4000        /* acknowledge one */
  384. #define MII_NP_NP 0x8000        /* nexp page will follow */
  385. /* MII Expansion Register bit definitions */
  386. #define MII_EXP_FAULT 0x0010        /* parallel detection fault */
  387. #define MII_EXP_PRTN_NP 0x0008        /* link partner next-page able */
  388. #define MII_EXP_LOC_NP 0x0004        /* local PHY next-page able */
  389. #define MII_EXP_PR 0x0002        /* full page received */
  390. #define MII_EXP_PRT_AN 0x0001        /* link partner auto negotiation able */
  391. /* technology ability field bit definitions */
  392. #define MII_TECH_10BASE_T 0x0020 /* 10Base-T */
  393. #define MII_TECH_10BASE_FD 0x0040 /* 10Base-T Full Duplex */
  394. #define MII_TECH_100BASE_TX 0x0080 /* 100Base-TX */
  395. #define MII_TECH_100BASE_TX_FD 0x0100 /* 100Base-TX Full Duplex */
  396. #define MII_TECH_100BASE_T4 0x0200 /* 100Base-T4 */
  397. #define MII_TECH_MASK 0x1fe0 /* technology abilities mask */
  398. #define MII_AN_FAIL 0x10 /* auto-negotiation fail */
  399. #define MII_STAT_FAIL 0x20 /* errors in the status register */
  400. #define MOT_FEC_PHY_NO_ABLE 0x40 /* the PHY lacks some abilities */
  401. /*
  402.  * this table may be customized by the user in configNet.h
  403.  */
  404. IMPORT INT16 motFecPhyAnOrderTbl [];
  405. /*
  406.  * the table below is used to translate user settings
  407.  * into MII-standard values for technology abilities.
  408.  */
  409. LOCAL UINT16 miiAnLookupTbl [] = {
  410.   MII_TECH_10BASE_T,
  411.   MII_TECH_10BASE_FD,
  412.   MII_TECH_100BASE_TX,
  413.   MII_TECH_100BASE_TX_FD,
  414.   MII_TECH_100BASE_T4
  415.          };
  416. LOCAL UINT16 miiCrLookupTbl [] = {
  417.   MII_CR_NORM_EN,
  418.   MII_CR_FDX,
  419.   MII_CR_100,
  420.   (MII_CR_100 | MII_CR_FDX),
  421.   (MII_CR_100 | MII_CR_FDX)
  422.          };
  423. typedef struct mii_regs
  424.     {
  425.     UINT16 phyStatus; /* PHY's status register */
  426.     UINT16 phyCtrl; /* PHY's control register */
  427.     UINT16 phyId1; /* PHY's identifier field 1 */
  428.     UINT16 phyId2; /* PHY's identifier field 2 */
  429.     UINT16 phyAds; /* PHY's advertisement register */
  430.     UINT16 phyPrtn; /* PHY's partner register */
  431.     UINT16 phyExp; /* PHY's expansion register */
  432.     UINT16 phyNext; /* PHY's next paget transmit register */
  433.     } MII_REGS;
  434. typedef struct phy_info
  435.     {
  436.     MII_REGS miiRegs; /* PHY registers */
  437.     UINT8 phyAddr; /* address of the PHY to be used */
  438.     UINT8 isoPhyAddr; /* address of a PHY to isolate */
  439.     UINT32 phyFlags; /* some flags */
  440.     UINT32              phySpeed;      /* 10/100 Mbit/sec */
  441.     UINT32              phyMode;      /* half/full duplex mode */
  442.     UINT32              phyDefMode;     /* default operating mode */
  443.     } PHY_INFO;
  444. typedef struct mot_fec_tbd_list
  445.     {
  446.     UINT16 fragNum;
  447.     UINT16 pktType;
  448.     UCHAR * pBuf;
  449.     UINT16 bufType;
  450.     struct mot_fec_tbd_list * pNext;
  451.     MOT_FEC_TBD_ID pTbd;
  452.     } MOT_FEC_TBD_LIST;
  453. typedef MOT_FEC_TBD_LIST * MOT_FEC_TBD_LIST_ID;
  454. /* The definition of the driver control structure */
  455. typedef struct drv_ctrl
  456.     {
  457.     END_OBJ             endObj;         /* base class */
  458.     int                 unit;           /* unit number */
  459.     UINT32              motCpmAddr;     /* internal RAM base address */
  460.     int                 ivec;           /* interrupt vector number */
  461.     int                 ilevel;         /* interrupt level */
  462.     UINT32              fifoTxBase;     /* address of Tx FIFO in internal RAM */
  463.     UINT32              fifoRxBase;     /* address of Rx FIFO in internal RAM */
  464.     char *              pBufBase;       /* FEC memory pool base */
  465.     ULONG               bufSize;        /* FEC memory pool size */
  466.     UINT16              rbdNum;         /* number of RBDs */
  467.     MOT_FEC_RBD_ID rbdBase;        /* RBD ring */
  468.     UINT16              rbdIndex;       /* RBD index */
  469.     UINT16              tbdNum;         /* number of TBDs */
  470.     MOT_FEC_TBD_ID      tbdBase;        /* TBD ring */
  471.     UINT16              tbdIndex;       /* TBD index */
  472.     UINT16              usedTbdIndex;   /* used TBD index */
  473.     UINT16              cleanTbdNum;    /* number of clean TBDs */
  474.     BOOL                txStall;        /* tx handler stalled - no Tbd */
  475.     MOT_FEC_TBD_LIST *  pTbdList [MOT_FEC_TBD_MAX];
  476. /* list of TBDs */
  477.     ULONG               userFlags;      /* some user flags */
  478.     INT8                flags;          /* driver state */
  479.     BOOL                loaded;         /* interface has been loaded */
  480.     BOOL                intrConnect;    /* interrupt has been connected */
  481.     UINT32 intMask; /* interrupt mask register */
  482.     UCHAR * pTxPollBuf; /* cluster pointer for poll mode */
  483.     UCHAR *             rxBuf[MOT_FEC_RBD_MAX];
  484.                                         /* array of pointers to clusters */
  485.     SEM_ID miiSem; /* synch semaphore for mii frames */
  486.     SEM_ID graSem; /* synch semaphore for graceful */
  487. /* transmit command */
  488.     char *              pClBlkArea;     /* cluster block pointer */
  489.     UINT32              clBlkSize;      /* clusters block memory size */
  490.     char *              pMBlkArea;      /* mBlock area pointer */
  491.     UINT32              mBlkSize;      /* mBlocks area memory size */
  492.     CACHE_FUNCS         bdCacheFuncs;   /* cache descriptor */
  493.     CACHE_FUNCS         bufCacheFuncs;  /* cache descriptor */
  494.     CL_POOL_ID          pClPoolId;      /* cluster pool identifier */
  495.     PHY_INFO *phyInfo; /* info on a MII-compliant PHY */
  496.     UINT32 clockSpeed; /* clock speed (Hz) for MII_SPEED */
  497.     } DRV_CTRL;
  498. /*
  499.  * this cache functions descriptors is used to flush/invalidate
  500.  * the FEC's data buffers. They are set to the system's cache
  501.  * flush and invalidate routine. This will allow proper operation
  502.  * of the driver if data cache are turned on.
  503.  */
  504. IMPORT STATUS   cacheArchInvalidate (CACHE_TYPE, void *, size_t);
  505. IMPORT STATUS   cacheArchFlush (CACHE_TYPE, void *, size_t);
  506. LOCAL   CACHE_FUNCS     motFecBufCacheFuncs;
  507. LOCAL FUNCPTR motFecBufInvRtn = cacheArchInvalidate;
  508. LOCAL FUNCPTR motFecBufFlushRtn = cacheArchFlush;
  509. FUNCPTR motFecIntDisc = NULL;   /* assign a proper disc routine */
  510. IMPORT STATUS sysFecEnetAddrGet (UINT32 motCmpAddr, UCHAR * address);
  511. IMPORT STATUS sysFecEnetEnable (UINT32 motCmpAddr);
  512. IMPORT STATUS sysFecEnetDisable (UINT32 motCmpAddr);
  513. IMPORT FUNCPTR  _func_motFecPhyInit;
  514. IMPORT FUNCPTR  _func_motFecHbFail;
  515. #ifdef __cplusplus
  516. }
  517. #endif
  518. #endif /* __INCmotFecEndh */