ipg.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. /*
  2. *
  3. * ipg.h
  4. *
  5. * Include file for Gigabit Ethernet device driver for Network
  6. * Interface Cards (NICs) utilizing the Tamarack Microelectronics
  7. * Inc. IPG Gigabit or Triple Speed Ethernet Media Access
  8. * Controller.
  9. *
  10. * Craig Rich
  11. * Sundance Technology, Inc.
  12. * 1485 Saratoga Avenue
  13. * Suite 200
  14. * San Jose, CA 95129
  15. * 408 873 4117
  16. * www.sundanceti.com
  17. * craig_rich@sundanceti.com
  18. */
  19. #ifndef __LINUX_IPG_H
  20. #define __LINUX_IPG_H
  21. #include <linux/version.h>
  22. #include <linux/module.h>
  23. #include <linux/kernel.h>
  24. #include <linux/pci.h>
  25. #include <linux/ioport.h>
  26. #include <linux/errno.h>
  27. #include <asm/io.h>
  28. #include <linux/delay.h>
  29. #include <linux/types.h>
  30. #include <linux/netdevice.h>
  31. #include <linux/etherdevice.h>
  32. #include <linux/init.h>
  33. #include <linux/skbuff.h>
  34. #include <linux/version.h>
  35. #include <asm/bitops.h>
  36. /*#include <asm/spinlock.h>*/
  37. #define DrvVer "2.09d"
  38. #define IPG_DEV_KFREE_SKB(skb) dev_kfree_skb_irq(skb)
  39. /*
  40. * Constants
  41. */
  42. /* GMII based PHY IDs */
  43. #define NS 0x2000
  44. #define MARVELL 0x0141
  45. #define ICPLUS_PHY 0x243
  46. /* NIC Physical Layer Device MII register fields. */
  47. #define MII_PHY_SELECTOR_IEEE8023 0x0001
  48. #define MII_PHY_TECHABILITYFIELD 0x1FE0
  49. /* GMII_PHY_1000 need to set to prefer master */
  50. #define GMII_PHY_1000BASETCONTROL_PreferMaster 0x0400
  51. /* NIC Physical Layer Device GMII constants. */
  52. #define GMII_PREAMBLE 0xFFFFFFFF
  53. #define GMII_ST 0x1
  54. #define GMII_READ 0x2
  55. #define GMII_WRITE 0x1
  56. #define GMII_TA_READ_MASK 0x1
  57. #define GMII_TA_WRITE 0x2
  58. /* I/O register offsets. */
  59. enum ipg_regs {
  60. DMA_CTRL = 0x00,
  61. RX_DMA_STATUS = 0x08, // Unused + reserved
  62. TFD_LIST_PTR_0 = 0x10,
  63. TFD_LIST_PTR_1 = 0x14,
  64. TX_DMA_BURST_THRESH = 0x18,
  65. TX_DMA_URGENT_THRESH = 0x19,
  66. TX_DMA_POLL_PERIOD = 0x1a,
  67. RFD_LIST_PTR_0 = 0x1c,
  68. RFD_LIST_PTR_1 = 0x20,
  69. RX_DMA_BURST_THRESH = 0x24,
  70. RX_DMA_URGENT_THRESH = 0x25,
  71. RX_DMA_POLL_PERIOD = 0x26,
  72. DEBUG_CTRL = 0x2c,
  73. ASIC_CTRL = 0x30,
  74. FIFO_CTRL = 0x38, // Unused
  75. FLOW_OFF_THRESH = 0x3c,
  76. FLOW_ON_THRESH = 0x3e,
  77. EEPROM_DATA = 0x48,
  78. EEPROM_CTRL = 0x4a,
  79. EXPROM_ADDR = 0x4c, // Unused
  80. EXPROM_DATA = 0x50, // Unused
  81. WAKE_EVENT = 0x51, // Unused
  82. COUNTDOWN = 0x54, // Unused
  83. INT_STATUS_ACK = 0x5a,
  84. INT_ENABLE = 0x5c,
  85. INT_STATUS = 0x5e, // Unused
  86. TX_STATUS = 0x60,
  87. MAC_CTRL = 0x6c,
  88. VLAN_TAG = 0x70, // Unused
  89. PHY_SET = 0x75, // JES20040127EEPROM
  90. PHY_CTRL = 0x76,
  91. STATION_ADDRESS_0 = 0x78,
  92. STATION_ADDRESS_1 = 0x7a,
  93. STATION_ADDRESS_2 = 0x7c,
  94. MAX_FRAME_SIZE = 0x86,
  95. RECEIVE_MODE = 0x88,
  96. HASHTABLE_0 = 0x8c,
  97. HASHTABLE_1 = 0x90,
  98. RMON_STATISTICS_MASK = 0x98,
  99. STATISTICS_MASK = 0x9c,
  100. RX_JUMBO_FRAMES = 0xbc, // Unused
  101. TCP_CHECKSUM_ERRORS = 0xc0, // Unused
  102. IP_CHECKSUM_ERRORS = 0xc2, // Unused
  103. UDP_CHECKSUM_ERRORS = 0xc4, // Unused
  104. TX_JUMBO_FRAMES = 0xf4 // Unused
  105. };
  106. /* Ethernet MIB statistic register offsets. */
  107. #define IPG_OCTETRCVOK 0xA8
  108. #define IPG_MCSTOCTETRCVDOK 0xAC
  109. #define IPG_BCSTOCTETRCVOK 0xB0
  110. #define IPG_FRAMESRCVDOK 0xB4
  111. #define IPG_MCSTFRAMESRCVDOK 0xB8
  112. #define IPG_BCSTFRAMESRCVDOK 0xBE
  113. #define IPG_MACCONTROLFRAMESRCVD 0xC6
  114. #define IPG_FRAMETOOLONGERRRORS 0xC8
  115. #define IPG_INRANGELENGTHERRORS 0xCA
  116. #define IPG_FRAMECHECKSEQERRORS 0xCC
  117. #define IPG_FRAMESLOSTRXERRORS 0xCE
  118. #define IPG_OCTETXMTOK 0xD0
  119. #define IPG_MCSTOCTETXMTOK 0xD4
  120. #define IPG_BCSTOCTETXMTOK 0xD8
  121. #define IPG_FRAMESXMTDOK 0xDC
  122. #define IPG_MCSTFRAMESXMTDOK 0xE0
  123. #define IPG_FRAMESWDEFERREDXMT 0xE4
  124. #define IPG_LATECOLLISIONS 0xE8
  125. #define IPG_MULTICOLFRAMES 0xEC
  126. #define IPG_SINGLECOLFRAMES 0xF0
  127. #define IPG_BCSTFRAMESXMTDOK 0xF6
  128. #define IPG_CARRIERSENSEERRORS 0xF8
  129. #define IPG_MACCONTROLFRAMESXMTDOK 0xFA
  130. #define IPG_FRAMESABORTXSCOLLS 0xFC
  131. #define IPG_FRAMESWEXDEFERRAL 0xFE
  132. /* RMON statistic register offsets. */
  133. #define IPG_ETHERSTATSCOLLISIONS 0x100
  134. #define IPG_ETHERSTATSOCTETSTRANSMIT 0x104
  135. #define IPG_ETHERSTATSPKTSTRANSMIT 0x108
  136. #define IPG_ETHERSTATSPKTS64OCTESTSTRANSMIT 0x10C
  137. #define IPG_ETHERSTATSPKTS65TO127OCTESTSTRANSMIT 0x110
  138. #define IPG_ETHERSTATSPKTS128TO255OCTESTSTRANSMIT 0x114
  139. #define IPG_ETHERSTATSPKTS256TO511OCTESTSTRANSMIT 0x118
  140. #define IPG_ETHERSTATSPKTS512TO1023OCTESTSTRANSMIT 0x11C
  141. #define IPG_ETHERSTATSPKTS1024TO1518OCTESTSTRANSMIT 0x120
  142. #define IPG_ETHERSTATSCRCALIGNERRORS 0x124
  143. #define IPG_ETHERSTATSUNDERSIZEPKTS 0x128
  144. #define IPG_ETHERSTATSFRAGMENTS 0x12C
  145. #define IPG_ETHERSTATSJABBERS 0x130
  146. #define IPG_ETHERSTATSOCTETS 0x134
  147. #define IPG_ETHERSTATSPKTS 0x138
  148. #define IPG_ETHERSTATSPKTS64OCTESTS 0x13C
  149. #define IPG_ETHERSTATSPKTS65TO127OCTESTS 0x140
  150. #define IPG_ETHERSTATSPKTS128TO255OCTESTS 0x144
  151. #define IPG_ETHERSTATSPKTS256TO511OCTESTS 0x148
  152. #define IPG_ETHERSTATSPKTS512TO1023OCTESTS 0x14C
  153. #define IPG_ETHERSTATSPKTS1024TO1518OCTESTS 0x150
  154. /* RMON statistic register equivalents. */
  155. #define IPG_ETHERSTATSMULTICASTPKTSTRANSMIT 0xE0
  156. #define IPG_ETHERSTATSBROADCASTPKTSTRANSMIT 0xF6
  157. #define IPG_ETHERSTATSMULTICASTPKTS 0xB8
  158. #define IPG_ETHERSTATSBROADCASTPKTS 0xBE
  159. #define IPG_ETHERSTATSOVERSIZEPKTS 0xC8
  160. #define IPG_ETHERSTATSDROPEVENTS 0xCE
  161. /* Serial EEPROM offsets */
  162. #define IPG_EEPROM_CONFIGPARAM 0x00
  163. #define IPG_EEPROM_ASICCTRL 0x01
  164. #define IPG_EEPROM_SUBSYSTEMVENDORID 0x02
  165. #define IPG_EEPROM_SUBSYSTEMID 0x03
  166. #define IPG_EEPROM_STATIONADDRESS0 0x10
  167. #define IPG_EEPROM_STATIONADDRESS1 0x11
  168. #define IPG_EEPROM_STATIONADDRESS2 0x12
  169. /* Register & data structure bit masks */
  170. /* PCI register masks. */
  171. /* IOBaseAddress */
  172. #define IPG_PIB_RSVD_MASK 0xFFFFFE01
  173. #define IPG_PIB_IOBASEADDRESS 0xFFFFFF00
  174. #define IPG_PIB_IOBASEADDRIND 0x00000001
  175. /* MemBaseAddress */
  176. #define IPG_PMB_RSVD_MASK 0xFFFFFE07
  177. #define IPG_PMB_MEMBASEADDRIND 0x00000001
  178. #define IPG_PMB_MEMMAPTYPE 0x00000006
  179. #define IPG_PMB_MEMMAPTYPE0 0x00000002
  180. #define IPG_PMB_MEMMAPTYPE1 0x00000004
  181. #define IPG_PMB_MEMBASEADDRESS 0xFFFFFE00
  182. /* ConfigStatus */
  183. #define IPG_CS_RSVD_MASK 0xFFB0
  184. #define IPG_CS_CAPABILITIES 0x0010
  185. #define IPG_CS_66MHZCAPABLE 0x0020
  186. #define IPG_CS_FASTBACK2BACK 0x0080
  187. #define IPG_CS_DATAPARITYREPORTED 0x0100
  188. #define IPG_CS_DEVSELTIMING 0x0600
  189. #define IPG_CS_SIGNALEDTARGETABORT 0x0800
  190. #define IPG_CS_RECEIVEDTARGETABORT 0x1000
  191. #define IPG_CS_RECEIVEDMASTERABORT 0x2000
  192. #define IPG_CS_SIGNALEDSYSTEMERROR 0x4000
  193. #define IPG_CS_DETECTEDPARITYERROR 0x8000
  194. /* TFD data structure masks. */
  195. /* TFDList, TFC */
  196. #define IPG_TFC_RSVD_MASK 0x0000FFFF9FFFFFFF
  197. #define IPG_TFC_FRAMEID 0x000000000000FFFF
  198. #define IPG_TFC_WORDALIGN 0x0000000000030000
  199. #define IPG_TFC_WORDALIGNTODWORD 0x0000000000000000
  200. #define IPG_TFC_WORDALIGNTOWORD 0x0000000000020000
  201. #define IPG_TFC_WORDALIGNDISABLED 0x0000000000030000
  202. #define IPG_TFC_TCPCHECKSUMENABLE 0x0000000000040000
  203. #define IPG_TFC_UDPCHECKSUMENABLE 0x0000000000080000
  204. #define IPG_TFC_IPCHECKSUMENABLE 0x0000000000100000
  205. #define IPG_TFC_FCSAPPENDDISABLE 0x0000000000200000
  206. #define IPG_TFC_TXINDICATE 0x0000000000400000
  207. #define IPG_TFC_TXDMAINDICATE 0x0000000000800000
  208. #define IPG_TFC_FRAGCOUNT 0x000000000F000000
  209. #define IPG_TFC_VLANTAGINSERT 0x0000000010000000
  210. #define IPG_TFC_TFDDONE 0x0000000080000000
  211. #define IPG_TFC_VID 0x00000FFF00000000
  212. #define IPG_TFC_CFI 0x0000100000000000
  213. #define IPG_TFC_USERPRIORITY 0x0000E00000000000
  214. /* TFDList, FragInfo */
  215. #define IPG_TFI_RSVD_MASK 0xFFFF00FFFFFFFFFF
  216. #define IPG_TFI_FRAGADDR 0x000000FFFFFFFFFF
  217. #define IPG_TFI_FRAGLEN 0xFFFF000000000000LL
  218. /* RFD data structure masks. */
  219. /* RFDList, RFS */
  220. #define IPG_RFS_RSVD_MASK 0x0000FFFFFFFFFFFF
  221. #define IPG_RFS_RXFRAMELEN 0x000000000000FFFF
  222. #define IPG_RFS_RXFIFOOVERRUN 0x0000000000010000
  223. #define IPG_RFS_RXRUNTFRAME 0x0000000000020000
  224. #define IPG_RFS_RXALIGNMENTERROR 0x0000000000040000
  225. #define IPG_RFS_RXFCSERROR 0x0000000000080000
  226. #define IPG_RFS_RXOVERSIZEDFRAME 0x0000000000100000
  227. #define IPG_RFS_RXLENGTHERROR 0x0000000000200000
  228. #define IPG_RFS_VLANDETECTED 0x0000000000400000
  229. #define IPG_RFS_TCPDETECTED 0x0000000000800000
  230. #define IPG_RFS_TCPERROR 0x0000000001000000
  231. #define IPG_RFS_UDPDETECTED 0x0000000002000000
  232. #define IPG_RFS_UDPERROR 0x0000000004000000
  233. #define IPG_RFS_IPDETECTED 0x0000000008000000
  234. #define IPG_RFS_IPERROR 0x0000000010000000
  235. #define IPG_RFS_FRAMESTART 0x0000000020000000
  236. #define IPG_RFS_FRAMEEND 0x0000000040000000
  237. #define IPG_RFS_RFDDONE 0x0000000080000000
  238. #define IPG_RFS_TCI 0x0000FFFF00000000
  239. /* RFDList, FragInfo */
  240. #define IPG_RFI_RSVD_MASK 0xFFFF00FFFFFFFFFF
  241. #define IPG_RFI_FRAGADDR 0x000000FFFFFFFFFF
  242. #define IPG_RFI_FRAGLEN 0xFFFF000000000000LL
  243. /* I/O Register masks. */
  244. /* RMON Statistics Mask */
  245. #define IPG_RZ_ALL 0x0FFFFFFF
  246. /* Statistics Mask */
  247. #define IPG_SM_ALL 0x0FFFFFFF
  248. #define IPG_SM_OCTETRCVOK_FRAMESRCVDOK 0x00000001
  249. #define IPG_SM_MCSTOCTETRCVDOK_MCSTFRAMESRCVDOK 0x00000002
  250. #define IPG_SM_BCSTOCTETRCVDOK_BCSTFRAMESRCVDOK 0x00000004
  251. #define IPG_SM_RXJUMBOFRAMES 0x00000008
  252. #define IPG_SM_TCPCHECKSUMERRORS 0x00000010
  253. #define IPG_SM_IPCHECKSUMERRORS 0x00000020
  254. #define IPG_SM_UDPCHECKSUMERRORS 0x00000040
  255. #define IPG_SM_MACCONTROLFRAMESRCVD 0x00000080
  256. #define IPG_SM_FRAMESTOOLONGERRORS 0x00000100
  257. #define IPG_SM_INRANGELENGTHERRORS 0x00000200
  258. #define IPG_SM_FRAMECHECKSEQERRORS 0x00000400
  259. #define IPG_SM_FRAMESLOSTRXERRORS 0x00000800
  260. #define IPG_SM_OCTETXMTOK_FRAMESXMTOK 0x00001000
  261. #define IPG_SM_MCSTOCTETXMTOK_MCSTFRAMESXMTDOK 0x00002000
  262. #define IPG_SM_BCSTOCTETXMTOK_BCSTFRAMESXMTDOK 0x00004000
  263. #define IPG_SM_FRAMESWDEFERREDXMT 0x00008000
  264. #define IPG_SM_LATECOLLISIONS 0x00010000
  265. #define IPG_SM_MULTICOLFRAMES 0x00020000
  266. #define IPG_SM_SINGLECOLFRAMES 0x00040000
  267. #define IPG_SM_TXJUMBOFRAMES 0x00080000
  268. #define IPG_SM_CARRIERSENSEERRORS 0x00100000
  269. #define IPG_SM_MACCONTROLFRAMESXMTD 0x00200000
  270. #define IPG_SM_FRAMESABORTXSCOLLS 0x00400000
  271. #define IPG_SM_FRAMESWEXDEFERAL 0x00800000
  272. /* Countdown */
  273. #define IPG_CD_RSVD_MASK 0x0700FFFF
  274. #define IPG_CD_COUNT 0x0000FFFF
  275. #define IPG_CD_COUNTDOWNSPEED 0x01000000
  276. #define IPG_CD_COUNTDOWNMODE 0x02000000
  277. #define IPG_CD_COUNTINTENABLED 0x04000000
  278. /* TxDMABurstThresh */
  279. #define IPG_TB_RSVD_MASK 0xFF
  280. /* TxDMAUrgentThresh */
  281. #define IPG_TU_RSVD_MASK 0xFF
  282. /* TxDMAPollPeriod */
  283. #define IPG_TP_RSVD_MASK 0xFF
  284. /* RxDMAUrgentThresh */
  285. #define IPG_RU_RSVD_MASK 0xFF
  286. /* RxDMAPollPeriod */
  287. #define IPG_RP_RSVD_MASK 0xFF
  288. /* ReceiveMode */
  289. #define IPG_RM_RSVD_MASK 0x3F
  290. #define IPG_RM_RECEIVEUNICAST 0x01
  291. #define IPG_RM_RECEIVEMULTICAST 0x02
  292. #define IPG_RM_RECEIVEBROADCAST 0x04
  293. #define IPG_RM_RECEIVEALLFRAMES 0x08
  294. #define IPG_RM_RECEIVEMULTICASTHASH 0x10
  295. #define IPG_RM_RECEIVEIPMULTICAST 0x20
  296. /* PhySet JES20040127EEPROM*/
  297. #define IPG_PS_MEM_LENB9B 0x01
  298. #define IPG_PS_MEM_LEN9 0x02
  299. #define IPG_PS_NON_COMPDET 0x04
  300. /* PhyCtrl */
  301. #define IPG_PC_RSVD_MASK 0xFF
  302. #define IPG_PC_MGMTCLK_LO 0x00
  303. #define IPG_PC_MGMTCLK_HI 0x01
  304. #define IPG_PC_MGMTCLK 0x01
  305. #define IPG_PC_MGMTDATA 0x02
  306. #define IPG_PC_MGMTDIR 0x04
  307. #define IPG_PC_DUPLEX_POLARITY 0x08
  308. #define IPG_PC_DUPLEX_STATUS 0x10
  309. #define IPG_PC_LINK_POLARITY 0x20
  310. #define IPG_PC_LINK_SPEED 0xC0
  311. #define IPG_PC_LINK_SPEED_10MBPS 0x40
  312. #define IPG_PC_LINK_SPEED_100MBPS 0x80
  313. #define IPG_PC_LINK_SPEED_1000MBPS 0xC0
  314. /* DMACtrl */
  315. #define IPG_DC_RSVD_MASK 0xC07D9818
  316. #define IPG_DC_RX_DMA_COMPLETE 0x00000008
  317. #define IPG_DC_RX_DMA_POLL_NOW 0x00000010
  318. #define IPG_DC_TX_DMA_COMPLETE 0x00000800
  319. #define IPG_DC_TX_DMA_POLL_NOW 0x00001000
  320. #define IPG_DC_TX_DMA_IN_PROG 0x00008000
  321. #define IPG_DC_RX_EARLY_DISABLE 0x00010000
  322. #define IPG_DC_MWI_DISABLE 0x00040000
  323. #define IPG_DC_TX_WRITE_BACK_DISABLE 0x00080000
  324. #define IPG_DC_TX_BURST_LIMIT 0x00700000
  325. #define IPG_DC_TARGET_ABORT 0x40000000
  326. #define IPG_DC_MASTER_ABORT 0x80000000
  327. /* ASICCtrl */
  328. #define IPG_AC_RSVD_MASK 0x07FFEFF2
  329. #define IPG_AC_EXP_ROM_SIZE 0x00000002
  330. #define IPG_AC_PHY_SPEED10 0x00000010
  331. #define IPG_AC_PHY_SPEED100 0x00000020
  332. #define IPG_AC_PHY_SPEED1000 0x00000040
  333. #define IPG_AC_PHY_MEDIA 0x00000080
  334. #define IPG_AC_FORCED_CFG 0x00000700
  335. #define IPG_AC_D3RESETDISABLE 0x00000800
  336. #define IPG_AC_SPEED_UP_MODE 0x00002000
  337. #define IPG_AC_LED_MODE 0x00004000
  338. #define IPG_AC_RST_OUT_POLARITY 0x00008000
  339. #define IPG_AC_GLOBAL_RESET 0x00010000
  340. #define IPG_AC_RX_RESET 0x00020000
  341. #define IPG_AC_TX_RESET 0x00040000
  342. #define IPG_AC_DMA 0x00080000
  343. #define IPG_AC_FIFO 0x00100000
  344. #define IPG_AC_NETWORK 0x00200000
  345. #define IPG_AC_HOST 0x00400000
  346. #define IPG_AC_AUTO_INIT 0x00800000
  347. #define IPG_AC_RST_OUT 0x01000000
  348. #define IPG_AC_INT_REQUEST 0x02000000
  349. #define IPG_AC_RESET_BUSY 0x04000000
  350. #define IPG_AC_LED_SPEED 0x08000000 //JES20040127EEPROM
  351. #define IPG_AC_LED_MODE_BIT_1 0x20000000 //JES20040127EEPROM
  352. /* EepromCtrl */
  353. #define IPG_EC_RSVD_MASK 0x83FF
  354. #define IPG_EC_EEPROM_ADDR 0x00FF
  355. #define IPG_EC_EEPROM_OPCODE 0x0300
  356. #define IPG_EC_EEPROM_SUBCOMMAD 0x0000
  357. #define IPG_EC_EEPROM_WRITEOPCODE 0x0100
  358. #define IPG_EC_EEPROM_READOPCODE 0x0200
  359. #define IPG_EC_EEPROM_ERASEOPCODE 0x0300
  360. #define IPG_EC_EEPROM_BUSY 0x8000
  361. /* FIFOCtrl */
  362. #define IPG_FC_RSVD_MASK 0xC001
  363. #define IPG_FC_RAM_TEST_MODE 0x0001
  364. #define IPG_FC_TRANSMITTING 0x4000
  365. #define IPG_FC_RECEIVING 0x8000
  366. /* TxStatus */
  367. #define IPG_TS_RSVD_MASK 0xFFFF00DD
  368. #define IPG_TS_TX_ERROR 0x00000001
  369. #define IPG_TS_LATE_COLLISION 0x00000004
  370. #define IPG_TS_TX_MAX_COLL 0x00000008
  371. #define IPG_TS_TX_UNDERRUN 0x00000010
  372. #define IPG_TS_TX_IND_REQD 0x00000040
  373. #define IPG_TS_TX_COMPLETE 0x00000080
  374. #define IPG_TS_TX_FRAMEID 0xFFFF0000
  375. /* WakeEvent */
  376. #define IPG_WE_WAKE_PKT_ENABLE 0x01
  377. #define IPG_WE_MAGIC_PKT_ENABLE 0x02
  378. #define IPG_WE_LINK_EVT_ENABLE 0x04
  379. #define IPG_WE_WAKE_POLARITY 0x08
  380. #define IPG_WE_WAKE_PKT_EVT 0x10
  381. #define IPG_WE_MAGIC_PKT_EVT 0x20
  382. #define IPG_WE_LINK_EVT 0x40
  383. #define IPG_WE_WOL_ENABLE 0x80
  384. /* IntEnable */
  385. #define IPG_IE_RSVD_MASK 0x1FFE
  386. #define IPG_IE_HOST_ERROR 0x0002
  387. #define IPG_IE_TX_COMPLETE 0x0004
  388. #define IPG_IE_MAC_CTRL_FRAME 0x0008
  389. #define IPG_IE_RX_COMPLETE 0x0010
  390. #define IPG_IE_RX_EARLY 0x0020
  391. #define IPG_IE_INT_REQUESTED 0x0040
  392. #define IPG_IE_UPDATE_STATS 0x0080
  393. #define IPG_IE_LINK_EVENT 0x0100
  394. #define IPG_IE_TX_DMA_COMPLETE 0x0200
  395. #define IPG_IE_RX_DMA_COMPLETE 0x0400
  396. #define IPG_IE_RFD_LIST_END 0x0800
  397. #define IPG_IE_RX_DMA_PRIORITY 0x1000
  398. /* IntStatus */
  399. #define IPG_IS_RSVD_MASK 0x1FFF
  400. #define IPG_IS_INTERRUPT_STATUS 0x0001
  401. #define IPG_IS_HOST_ERROR 0x0002
  402. #define IPG_IS_TX_COMPLETE 0x0004
  403. #define IPG_IS_MAC_CTRL_FRAME 0x0008
  404. #define IPG_IS_RX_COMPLETE 0x0010
  405. #define IPG_IS_RX_EARLY 0x0020
  406. #define IPG_IS_INT_REQUESTED 0x0040
  407. #define IPG_IS_UPDATE_STATS 0x0080
  408. #define IPG_IS_LINK_EVENT 0x0100
  409. #define IPG_IS_TX_DMA_COMPLETE 0x0200
  410. #define IPG_IS_RX_DMA_COMPLETE 0x0400
  411. #define IPG_IS_RFD_LIST_END 0x0800
  412. #define IPG_IS_RX_DMA_PRIORITY 0x1000
  413. /* MACCtrl */
  414. #define IPG_MC_RSVD_MASK 0x7FE33FA3
  415. #define IPG_MC_IFS_SELECT 0x00000003
  416. #define IPG_MC_IFS_4352BIT 0x00000003
  417. #define IPG_MC_IFS_1792BIT 0x00000002
  418. #define IPG_MC_IFS_1024BIT 0x00000001
  419. #define IPG_MC_IFS_96BIT 0x00000000
  420. #define IPG_MC_DUPLEX_SELECT 0x00000020
  421. #define IPG_MC_DUPLEX_SELECT_FD 0x00000020
  422. #define IPG_MC_DUPLEX_SELECT_HD 0x00000000
  423. #define IPG_MC_TX_FLOW_CONTROL_ENABLE 0x00000080
  424. #define IPG_MC_RX_FLOW_CONTROL_ENABLE 0x00000100
  425. #define IPG_MC_RCV_FCS 0x00000200
  426. #define IPG_MC_FIFO_LOOPBACK 0x00000400
  427. #define IPG_MC_MAC_LOOPBACK 0x00000800
  428. #define IPG_MC_AUTO_VLAN_TAGGING 0x00001000
  429. #define IPG_MC_AUTO_VLAN_UNTAGGING 0x00002000
  430. #define IPG_MC_COLLISION_DETECT 0x00010000
  431. #define IPG_MC_CARRIER_SENSE 0x00020000
  432. #define IPG_MC_STATISTICS_ENABLE 0x00200000
  433. #define IPG_MC_STATISTICS_DISABLE 0x00400000
  434. #define IPG_MC_STATISTICS_ENABLED 0x00800000
  435. #define IPG_MC_TX_ENABLE 0x01000000
  436. #define IPG_MC_TX_DISABLE 0x02000000
  437. #define IPG_MC_TX_ENABLED 0x04000000
  438. #define IPG_MC_RX_ENABLE 0x08000000
  439. #define IPG_MC_RX_DISABLE 0x10000000
  440. #define IPG_MC_RX_ENABLED 0x20000000
  441. #define IPG_MC_PAUSED 0x40000000
  442. /*
  443. * Tune
  444. */
  445. /* Miscellaneous Constants. */
  446. #define TRUE 1
  447. #define FALSE 0
  448. /* Assign IPG_APPEND_FCS_ON_TX > 0 for auto FCS append on TX. */
  449. #define IPG_APPEND_FCS_ON_TX TRUE
  450. /* Assign IPG_APPEND_FCS_ON_TX > 0 for auto FCS strip on RX. */
  451. #define IPG_STRIP_FCS_ON_RX TRUE
  452. /* Assign IPG_DROP_ON_RX_ETH_ERRORS > 0 to drop RX frames with
  453. * Ethernet errors.
  454. */
  455. #define IPG_DROP_ON_RX_ETH_ERRORS TRUE
  456. /* Assign IPG_INSERT_MANUAL_VLAN_TAG > 0 to insert VLAN tags manually
  457. * (via TFC).
  458. */
  459. #define IPG_INSERT_MANUAL_VLAN_TAG FALSE
  460. /* Assign IPG_ADD_IPCHECKSUM_ON_TX > 0 for auto IP checksum on TX. */
  461. #define IPG_ADD_IPCHECKSUM_ON_TX FALSE
  462. /* Assign IPG_ADD_TCPCHECKSUM_ON_TX > 0 for auto TCP checksum on TX.
  463. * DO NOT USE FOR SILICON REVISIONS B3 AND EARLIER.
  464. */
  465. #define IPG_ADD_TCPCHECKSUM_ON_TX FALSE
  466. /* Assign IPG_ADD_UDPCHECKSUM_ON_TX > 0 for auto UDP checksum on TX.
  467. * DO NOT USE FOR SILICON REVISIONS B3 AND EARLIER.
  468. */
  469. #define IPG_ADD_UDPCHECKSUM_ON_TX FALSE
  470. /* If inserting VLAN tags manually, assign the IPG_MANUAL_VLAN_xx
  471. * constants as desired.
  472. */
  473. #define IPG_MANUAL_VLAN_VID 0xABC
  474. #define IPG_MANUAL_VLAN_CFI 0x1
  475. #define IPG_MANUAL_VLAN_USERPRIORITY 0x5
  476. #define IPG_IO_REG_RANGE 0xFF
  477. #define IPG_MEM_REG_RANGE 0x154
  478. #define IPG_DRIVER_NAME "Sundance Technology IPG Triple-Speed Ethernet"
  479. #define IPG_NIC_PHY_ADDRESS 0x01
  480. #define IPG_DMALIST_ALIGN_PAD 0x07
  481. #define IPG_MULTICAST_HASHTABLE_SIZE 0x40
  482. /* Number of miliseconds to wait after issuing a software reset.
  483. * 0x05 <= IPG_AC_RESETWAIT to account for proper 10Mbps operation.
  484. */
  485. #define IPG_AC_RESETWAIT 0x05
  486. /* Number of IPG_AC_RESETWAIT timeperiods before declaring timeout. */
  487. #define IPG_AC_RESET_TIMEOUT 0x0A
  488. /* Minimum number of nanoseconds used to toggle MDC clock during
  489. * MII/GMII register access.
  490. */
  491. #define IPG_PC_PHYCTRLWAIT_NS 200
  492. #define IPG_TFDLIST_LENGTH 0x100
  493. /* Number of frames between TxDMAComplete interrupt.
  494. * 0 < IPG_FRAMESBETWEENTXDMACOMPLETES <= IPG_TFDLIST_LENGTH
  495. */
  496. #define IPG_FRAMESBETWEENTXDMACOMPLETES 0x1
  497. #ifdef JUMBO_FRAME
  498. # ifdef JUMBO_FRAME_SIZE_2K
  499. # define JUMBO_FRAME_SIZE 2048
  500. # define __IPG_RXFRAG_SIZE 2048
  501. # else
  502. # ifdef JUMBO_FRAME_SIZE_3K
  503. # define JUMBO_FRAME_SIZE 3072
  504. # define __IPG_RXFRAG_SIZE 3072
  505. # else
  506. # ifdef JUMBO_FRAME_SIZE_4K
  507. # define JUMBO_FRAME_SIZE 4096
  508. # define __IPG_RXFRAG_SIZE 4088
  509. # else
  510. # ifdef JUMBO_FRAME_SIZE_5K
  511. # define JUMBO_FRAME_SIZE 5120
  512. # define __IPG_RXFRAG_SIZE 4088
  513. # else
  514. # ifdef JUMBO_FRAME_SIZE_6K
  515. # define JUMBO_FRAME_SIZE 6144
  516. # define __IPG_RXFRAG_SIZE 4088
  517. # else
  518. # ifdef JUMBO_FRAME_SIZE_7K
  519. # define JUMBO_FRAME_SIZE 7168
  520. # define __IPG_RXFRAG_SIZE 4088
  521. # else
  522. # ifdef JUMBO_FRAME_SIZE_8K
  523. # define JUMBO_FRAME_SIZE 8192
  524. # define __IPG_RXFRAG_SIZE 4088
  525. # else
  526. # ifdef JUMBO_FRAME_SIZE_9K
  527. # define JUMBO_FRAME_SIZE 9216
  528. # define __IPG_RXFRAG_SIZE 4088
  529. # else
  530. # ifdef JUMBO_FRAME_SIZE_10K
  531. # define JUMBO_FRAME_SIZE 10240
  532. # define __IPG_RXFRAG_SIZE 4088
  533. # else
  534. # define JUMBO_FRAME_SIZE 4096
  535. # endif
  536. # endif
  537. # endif
  538. # endif
  539. # endif
  540. # endif
  541. # endif
  542. # endif
  543. # endif
  544. #endif
  545. /* Size of allocated received buffers. Nominally 0x0600.
  546. * Define larger if expecting jumbo frames.
  547. */
  548. #ifdef JUMBO_FRAME
  549. //IPG_TXFRAG_SIZE must <= 0x2b00, or TX will crash
  550. #define IPG_TXFRAG_SIZE JUMBO_FRAME_SIZE
  551. #endif
  552. /* Size of allocated received buffers. Nominally 0x0600.
  553. * Define larger if expecting jumbo frames.
  554. */
  555. #ifdef JUMBO_FRAME
  556. //4088=4096-8
  557. #define IPG_RXFRAG_SIZE __IPG_RXFRAG_SIZE
  558. #define IPG_RXSUPPORT_SIZE IPG_MAX_RXFRAME_SIZE
  559. #else
  560. #define IPG_RXFRAG_SIZE 0x0600
  561. #define IPG_RXSUPPORT_SIZE IPG_RXFRAG_SIZE
  562. #endif
  563. /* IPG_MAX_RXFRAME_SIZE <= IPG_RXFRAG_SIZE */
  564. #ifdef JUMBO_FRAME
  565. #define IPG_MAX_RXFRAME_SIZE JUMBO_FRAME_SIZE
  566. #else
  567. #define IPG_MAX_RXFRAME_SIZE 0x0600
  568. #endif
  569. #define IPG_RFDLIST_LENGTH 0x100
  570. /* Maximum number of RFDs to process per interrupt.
  571. * 1 < IPG_MAXRFDPROCESS_COUNT < IPG_RFDLIST_LENGTH
  572. */
  573. #define IPG_MAXRFDPROCESS_COUNT 0x80
  574. /* Minimum margin between last freed RFD, and current RFD.
  575. * 1 < IPG_MINUSEDRFDSTOFREE < IPG_RFDLIST_LENGTH
  576. */
  577. #define IPG_MINUSEDRFDSTOFREE 0x80
  578. /* specify the jumbo frame maximum size
  579. * per unit is 0x600 (the RxBuffer size that one RFD can carry)
  580. */
  581. #define MAX_JUMBOSIZE 0x8 // max is 12K
  582. /* Key register values loaded at driver start up. */
  583. /* TXDMAPollPeriod is specified in 320ns increments.
  584. *
  585. * Value Time
  586. * ---------------------
  587. * 0x00-0x01 320ns
  588. * 0x03 ~1us
  589. * 0x1F ~10us
  590. * 0xFF ~82us
  591. */
  592. #define IPG_TXDMAPOLLPERIOD_VALUE 0x26
  593. /* TxDMAUrgentThresh specifies the minimum amount of
  594. * data in the transmit FIFO before asserting an
  595. * urgent transmit DMA request.
  596. *
  597. * Value Min TxFIFO occupied space before urgent TX request
  598. * ---------------------------------------------------------------
  599. * 0x00-0x04 128 bytes (1024 bits)
  600. * 0x27 1248 bytes (~10000 bits)
  601. * 0x30 1536 bytes (12288 bits)
  602. * 0xFF 8192 bytes (65535 bits)
  603. */
  604. #define IPG_TXDMAURGENTTHRESH_VALUE 0x04
  605. /* TxDMABurstThresh specifies the minimum amount of
  606. * free space in the transmit FIFO before asserting an
  607. * transmit DMA request.
  608. *
  609. * Value Min TxFIFO free space before TX request
  610. * ----------------------------------------------------
  611. * 0x00-0x08 256 bytes
  612. * 0x30 1536 bytes
  613. * 0xFF 8192 bytes
  614. */
  615. #define IPG_TXDMABURSTTHRESH_VALUE 0x30
  616. /* RXDMAPollPeriod is specified in 320ns increments.
  617. *
  618. * Value Time
  619. * ---------------------
  620. * 0x00-0x01 320ns
  621. * 0x03 ~1us
  622. * 0x1F ~10us
  623. * 0xFF ~82us
  624. */
  625. #define IPG_RXDMAPOLLPERIOD_VALUE 0x01
  626. /* RxDMAUrgentThresh specifies the minimum amount of
  627. * free space within the receive FIFO before asserting
  628. * a urgent receive DMA request.
  629. *
  630. * Value Min RxFIFO free space before urgent RX request
  631. * ---------------------------------------------------------------
  632. * 0x00-0x04 128 bytes (1024 bits)
  633. * 0x27 1248 bytes (~10000 bits)
  634. * 0x30 1536 bytes (12288 bits)
  635. * 0xFF 8192 bytes (65535 bits)
  636. */
  637. #define IPG_RXDMAURGENTTHRESH_VALUE 0x30
  638. /* RxDMABurstThresh specifies the minimum amount of
  639. * occupied space within the receive FIFO before asserting
  640. * a receive DMA request.
  641. *
  642. * Value Min TxFIFO free space before TX request
  643. * ----------------------------------------------------
  644. * 0x00-0x08 256 bytes
  645. * 0x30 1536 bytes
  646. * 0xFF 8192 bytes
  647. */
  648. #define IPG_RXDMABURSTTHRESH_VALUE 0x30
  649. /* FlowOnThresh specifies the maximum amount of occupied
  650. * space in the receive FIFO before a PAUSE frame with
  651. * maximum pause time transmitted.
  652. *
  653. * Value Max RxFIFO occupied space before PAUSE
  654. * ---------------------------------------------------
  655. * 0x0000 0 bytes
  656. * 0x0740 29,696 bytes
  657. * 0x07FF 32,752 bytes
  658. */
  659. #define IPG_FLOWONTHRESH_VALUE 0x0740
  660. /* FlowOffThresh specifies the minimum amount of occupied
  661. * space in the receive FIFO before a PAUSE frame with
  662. * zero pause time is transmitted.
  663. *
  664. * Value Max RxFIFO occupied space before PAUSE
  665. * ---------------------------------------------------
  666. * 0x0000 0 bytes
  667. * 0x00BF 3056 bytes
  668. * 0x07FF 32,752 bytes
  669. */
  670. #define IPG_FLOWOFFTHRESH_VALUE 0x00BF
  671. /*
  672. * Miscellaneous macros.
  673. */
  674. /* Marco for printing debug statements.
  675. # define IPG_DDEBUG_MSG(args...) printk(KERN_DEBUG "IPG: " ## args) */
  676. #ifdef IPG_DEBUG
  677. # define IPG_DEBUG_MSG(args...)
  678. # define IPG_DDEBUG_MSG(args...) printk(KERN_DEBUG "IPG: " args)
  679. # define IPG_DUMPRFDLIST(args) ipg_dump_rfdlist(args)
  680. # define IPG_DUMPTFDLIST(args) ipg_dump_tfdlist(args)
  681. #else
  682. # define IPG_DEBUG_MSG(args...)
  683. # define IPG_DDEBUG_MSG(args...)
  684. # define IPG_DUMPRFDLIST(args)
  685. # define IPG_DUMPTFDLIST(args)
  686. #endif
  687. /*
  688. * End miscellaneous macros.
  689. */
  690. /* Transmit Frame Descriptor. The IPG supports 15 fragments,
  691. * however Linux requires only a single fragment. Note, each
  692. * TFD field is 64 bits wide.
  693. */
  694. struct ipg_tx {
  695. __le64 next_desc;
  696. __le64 tfc;
  697. __le64 frag_info;
  698. };
  699. /* Receive Frame Descriptor. Note, each RFD field is 64 bits wide.
  700. */
  701. struct ipg_rx {
  702. __le64 next_desc;
  703. __le64 rfs;
  704. __le64 frag_info;
  705. };
  706. struct SJumbo {
  707. int FoundStart;
  708. int CurrentSize;
  709. struct sk_buff *skb;
  710. };
  711. /* Structure of IPG NIC specific data. */
  712. struct ipg_nic_private {
  713. void __iomem *ioaddr;
  714. struct ipg_tx *txd;
  715. struct ipg_rx *rxd;
  716. dma_addr_t txd_map;
  717. dma_addr_t rxd_map;
  718. struct sk_buff *TxBuff[IPG_TFDLIST_LENGTH];
  719. struct sk_buff *RxBuff[IPG_RFDLIST_LENGTH];
  720. unsigned int tx_current;
  721. unsigned int tx_dirty;
  722. unsigned int rx_current;
  723. unsigned int rx_dirty;
  724. // Add by Grace 2005/05/19
  725. #ifdef JUMBO_FRAME
  726. struct SJumbo Jumbo;
  727. #endif
  728. unsigned int rx_buf_sz;
  729. struct pci_dev *pdev;
  730. struct net_device *dev;
  731. struct net_device_stats stats;
  732. spinlock_t lock;
  733. int tenmbpsmode;
  734. /*Jesse20040128EEPROM_VALUE */
  735. u16 LED_Mode;
  736. u16 station_addr[3]; /* Station Address in EEPROM Reg 0x10..0x12 */
  737. struct mutex mii_mutex;
  738. struct mii_if_info mii_if;
  739. int ResetCurrentTFD;
  740. #ifdef IPG_DEBUG
  741. int RFDlistendCount;
  742. int RFDListCheckedCount;
  743. int EmptyRFDListCount;
  744. #endif
  745. struct delayed_work task;
  746. };
  747. //variable record -- index by leading revision/length
  748. //Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN
  749. unsigned short DefaultPhyParam[] = {
  750. // 11/12/03 IP1000A v1-3 rev=0x40
  751. /*--------------------------------------------------------------------------
  752. (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2,
  753. 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6,
  754. 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700,
  755. --------------------------------------------------------------------------*/
  756. // 12/17/03 IP1000A v1-4 rev=0x40
  757. (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31,
  758. 0x0000,
  759. 30, 0x005e, 9, 0x0700,
  760. // 01/09/04 IP1000A v1-5 rev=0x41
  761. (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31,
  762. 0x0000,
  763. 30, 0x005e, 9, 0x0700,
  764. 0x0000
  765. };
  766. #endif /* __LINUX_IPG_H */