ipg.h 25 KB

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