amd8111e.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. /*
  2. * Advanced Micro Devices Inc. AMD8111E Linux Network Driver
  3. * Copyright (C) 2003 Advanced Micro Devices
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  17. Module Name:
  18. amd8111e.h
  19. Abstract:
  20. AMD8111 based 10/100 Ethernet Controller driver definitions.
  21. Environment:
  22. Kernel Mode
  23. Revision History:
  24. 3.0.0
  25. Initial Revision.
  26. 3.0.1
  27. */
  28. #ifndef _AMD811E_H
  29. #define _AMD811E_H
  30. /* Command style register access
  31. Registers CMD0, CMD2, CMD3,CMD7 and INTEN0 uses a write access technique called command style access. It allows the write to selected bits of this register without altering the bits that are not selected. Command style registers are divided into 4 bytes that can be written independently. Higher order bit of each byte is the value bit that specifies the value that will be written into the selected bits of register.
  32. eg., if the value 10011010b is written into the least significant byte of a command style register, bits 1,3 and 4 of the register will be set to 1, and the other bits will not be altered. If the value 00011010b is written into the same byte, bits 1,3 and 4 will be cleared to 0 and the other bits will not be altered.
  33. */
  34. /* Offset for Memory Mapped Registers. */
  35. /* 32 bit registers */
  36. #define ASF_STAT 0x00 /* ASF status register */
  37. #define CHIPID 0x04 /* Chip ID regsiter */
  38. #define MIB_DATA 0x10 /* MIB data register */
  39. #define MIB_ADDR 0x14 /* MIB address register */
  40. #define STAT0 0x30 /* Status0 register */
  41. #define INT0 0x38 /* Interrupt0 register */
  42. #define INTEN0 0x40 /* Interrupt0 enable register*/
  43. #define CMD0 0x48 /* Command0 register */
  44. #define CMD2 0x50 /* Command2 register */
  45. #define CMD3 0x54 /* Command3 resiter */
  46. #define CMD7 0x64 /* Command7 register */
  47. #define CTRL1 0x6C /* Control1 register */
  48. #define CTRL2 0x70 /* Control2 register */
  49. #define XMT_RING_LIMIT 0x7C /* Transmit ring limit register */
  50. #define AUTOPOLL0 0x88 /* Auto-poll0 register */
  51. #define AUTOPOLL1 0x8A /* Auto-poll1 register */
  52. #define AUTOPOLL2 0x8C /* Auto-poll2 register */
  53. #define AUTOPOLL3 0x8E /* Auto-poll3 register */
  54. #define AUTOPOLL4 0x90 /* Auto-poll4 register */
  55. #define AUTOPOLL5 0x92 /* Auto-poll5 register */
  56. #define AP_VALUE 0x98 /* Auto-poll value register */
  57. #define DLY_INT_A 0xA8 /* Group A delayed interrupt register */
  58. #define DLY_INT_B 0xAC /* Group B delayed interrupt register */
  59. #define FLOW_CONTROL 0xC8 /* Flow control register */
  60. #define PHY_ACCESS 0xD0 /* PHY access register */
  61. #define STVAL 0xD8 /* Software timer value register */
  62. #define XMT_RING_BASE_ADDR0 0x100 /* Transmit ring0 base addr register */
  63. #define XMT_RING_BASE_ADDR1 0x108 /* Transmit ring1 base addr register */
  64. #define XMT_RING_BASE_ADDR2 0x110 /* Transmit ring2 base addr register */
  65. #define XMT_RING_BASE_ADDR3 0x118 /* Transmit ring2 base addr register */
  66. #define RCV_RING_BASE_ADDR0 0x120 /* Transmit ring0 base addr register */
  67. #define PMAT0 0x190 /* OnNow pattern register0 */
  68. #define PMAT1 0x194 /* OnNow pattern register1 */
  69. /* 16bit registers */
  70. #define XMT_RING_LEN0 0x140 /* Transmit Ring0 length register */
  71. #define XMT_RING_LEN1 0x144 /* Transmit Ring1 length register */
  72. #define XMT_RING_LEN2 0x148 /* Transmit Ring2 length register */
  73. #define XMT_RING_LEN3 0x14C /* Transmit Ring3 length register */
  74. #define RCV_RING_LEN0 0x150 /* Receive Ring0 length register */
  75. #define SRAM_SIZE 0x178 /* SRAM size register */
  76. #define SRAM_BOUNDARY 0x17A /* SRAM boundary register */
  77. /* 48bit register */
  78. #define PADR 0x160 /* Physical address register */
  79. #define IFS1 0x18C /* Inter-frame spacing Part1 register */
  80. #define IFS 0x18D /* Inter-frame spacing register */
  81. #define IPG 0x18E /* Inter-frame gap register */
  82. /* 64bit register */
  83. #define LADRF 0x168 /* Logical address filter register */
  84. /* Register Bit Definitions */
  85. typedef enum {
  86. ASF_INIT_DONE = (1 << 1),
  87. ASF_INIT_PRESENT = (1 << 0),
  88. }STAT_ASF_BITS;
  89. typedef enum {
  90. MIB_CMD_ACTIVE = (1 << 15 ),
  91. MIB_RD_CMD = (1 << 13 ),
  92. MIB_CLEAR = (1 << 12 ),
  93. MIB_ADDRESS = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)|
  94. (1 << 4) | (1 << 5),
  95. }MIB_ADDR_BITS;
  96. typedef enum {
  97. PMAT_DET = (1 << 12),
  98. MP_DET = (1 << 11),
  99. LC_DET = (1 << 10),
  100. SPEED_MASK = (1 << 9)|(1 << 8)|(1 << 7),
  101. FULL_DPLX = (1 << 6),
  102. LINK_STATS = (1 << 5),
  103. AUTONEG_COMPLETE = (1 << 4),
  104. MIIPD = (1 << 3),
  105. RX_SUSPENDED = (1 << 2),
  106. TX_SUSPENDED = (1 << 1),
  107. RUNNING = (1 << 0),
  108. }STAT0_BITS;
  109. #define PHY_SPEED_10 0x2
  110. #define PHY_SPEED_100 0x3
  111. /* INT0 0x38, 32bit register */
  112. typedef enum {
  113. INTR = (1 << 31),
  114. PCSINT = (1 << 28),
  115. LCINT = (1 << 27),
  116. APINT5 = (1 << 26),
  117. APINT4 = (1 << 25),
  118. APINT3 = (1 << 24),
  119. TINT_SUM = (1 << 23),
  120. APINT2 = (1 << 22),
  121. APINT1 = (1 << 21),
  122. APINT0 = (1 << 20),
  123. MIIPDTINT = (1 << 19),
  124. MCCINT = (1 << 17),
  125. MREINT = (1 << 16),
  126. RINT_SUM = (1 << 15),
  127. SPNDINT = (1 << 14),
  128. MPINT = (1 << 13),
  129. SINT = (1 << 12),
  130. TINT3 = (1 << 11),
  131. TINT2 = (1 << 10),
  132. TINT1 = (1 << 9),
  133. TINT0 = (1 << 8),
  134. UINT = (1 << 7),
  135. STINT = (1 << 4),
  136. RINT0 = (1 << 0),
  137. }INT0_BITS;
  138. typedef enum {
  139. VAL3 = (1 << 31), /* VAL bit for byte 3 */
  140. VAL2 = (1 << 23), /* VAL bit for byte 2 */
  141. VAL1 = (1 << 15), /* VAL bit for byte 1 */
  142. VAL0 = (1 << 7), /* VAL bit for byte 0 */
  143. }VAL_BITS;
  144. typedef enum {
  145. /* VAL3 */
  146. LCINTEN = (1 << 27),
  147. APINT5EN = (1 << 26),
  148. APINT4EN = (1 << 25),
  149. APINT3EN = (1 << 24),
  150. /* VAL2 */
  151. APINT2EN = (1 << 22),
  152. APINT1EN = (1 << 21),
  153. APINT0EN = (1 << 20),
  154. MIIPDTINTEN = (1 << 19),
  155. MCCIINTEN = (1 << 18),
  156. MCCINTEN = (1 << 17),
  157. MREINTEN = (1 << 16),
  158. /* VAL1 */
  159. SPNDINTEN = (1 << 14),
  160. MPINTEN = (1 << 13),
  161. TINTEN3 = (1 << 11),
  162. SINTEN = (1 << 12),
  163. TINTEN2 = (1 << 10),
  164. TINTEN1 = (1 << 9),
  165. TINTEN0 = (1 << 8),
  166. /* VAL0 */
  167. STINTEN = (1 << 4),
  168. RINTEN0 = (1 << 0),
  169. INTEN0_CLEAR = 0x1F7F7F1F, /* Command style register */
  170. }INTEN0_BITS;
  171. typedef enum {
  172. /* VAL2 */
  173. RDMD0 = (1 << 16),
  174. /* VAL1 */
  175. TDMD3 = (1 << 11),
  176. TDMD2 = (1 << 10),
  177. TDMD1 = (1 << 9),
  178. TDMD0 = (1 << 8),
  179. /* VAL0 */
  180. UINTCMD = (1 << 6),
  181. RX_FAST_SPND = (1 << 5),
  182. TX_FAST_SPND = (1 << 4),
  183. RX_SPND = (1 << 3),
  184. TX_SPND = (1 << 2),
  185. INTREN = (1 << 1),
  186. RUN = (1 << 0),
  187. CMD0_CLEAR = 0x000F0F7F, /* Command style register */
  188. }CMD0_BITS;
  189. typedef enum {
  190. /* VAL3 */
  191. CONDUIT_MODE = (1 << 29),
  192. /* VAL2 */
  193. RPA = (1 << 19),
  194. DRCVPA = (1 << 18),
  195. DRCVBC = (1 << 17),
  196. PROM = (1 << 16),
  197. /* VAL1 */
  198. ASTRP_RCV = (1 << 13),
  199. RCV_DROP0 = (1 << 12),
  200. EMBA = (1 << 11),
  201. DXMT2PD = (1 << 10),
  202. LTINTEN = (1 << 9),
  203. DXMTFCS = (1 << 8),
  204. /* VAL0 */
  205. APAD_XMT = (1 << 6),
  206. DRTY = (1 << 5),
  207. INLOOP = (1 << 4),
  208. EXLOOP = (1 << 3),
  209. REX_RTRY = (1 << 2),
  210. REX_UFLO = (1 << 1),
  211. REX_LCOL = (1 << 0),
  212. CMD2_CLEAR = 0x3F7F3F7F, /* Command style register */
  213. }CMD2_BITS;
  214. typedef enum {
  215. /* VAL3 */
  216. ASF_INIT_DONE_ALIAS = (1 << 29),
  217. /* VAL2 */
  218. JUMBO = (1 << 21),
  219. VSIZE = (1 << 20),
  220. VLONLY = (1 << 19),
  221. VL_TAG_DEL = (1 << 18),
  222. /* VAL1 */
  223. EN_PMGR = (1 << 14),
  224. INTLEVEL = (1 << 13),
  225. FORCE_FULL_DUPLEX = (1 << 12),
  226. FORCE_LINK_STATUS = (1 << 11),
  227. APEP = (1 << 10),
  228. MPPLBA = (1 << 9),
  229. /* VAL0 */
  230. RESET_PHY_PULSE = (1 << 2),
  231. RESET_PHY = (1 << 1),
  232. PHY_RST_POL = (1 << 0),
  233. }CMD3_BITS;
  234. typedef enum {
  235. /* VAL0 */
  236. PMAT_SAVE_MATCH = (1 << 4),
  237. PMAT_MODE = (1 << 3),
  238. MPEN_SW = (1 << 1),
  239. LCMODE_SW = (1 << 0),
  240. CMD7_CLEAR = 0x0000001B /* Command style register */
  241. }CMD7_BITS;
  242. typedef enum {
  243. RESET_PHY_WIDTH = (0xF << 16) | (0xF<< 20), /* 0x00FF0000 */
  244. XMTSP_MASK = (1 << 9) | (1 << 8), /* 9:8 */
  245. XMTSP_128 = (1 << 9), /* 9 */
  246. XMTSP_64 = (1 << 8),
  247. CACHE_ALIGN = (1 << 4),
  248. BURST_LIMIT_MASK = (0xF << 0 ),
  249. CTRL1_DEFAULT = 0x00010111,
  250. }CTRL1_BITS;
  251. typedef enum {
  252. FMDC_MASK = (1 << 9)|(1 << 8), /* 9:8 */
  253. XPHYRST = (1 << 7),
  254. XPHYANE = (1 << 6),
  255. XPHYFD = (1 << 5),
  256. XPHYSP = (1 << 4) | (1 << 3), /* 4:3 */
  257. APDW_MASK = (1 << 2) | (1 << 1) | (1 << 0), /* 2:0 */
  258. }CTRL2_BITS;
  259. /* XMT_RING_LIMIT 0x7C, 32bit register */
  260. typedef enum {
  261. XMT_RING2_LIMIT = (0xFF << 16), /* 23:16 */
  262. XMT_RING1_LIMIT = (0xFF << 8), /* 15:8 */
  263. XMT_RING0_LIMIT = (0xFF << 0), /* 7:0 */
  264. }XMT_RING_LIMIT_BITS;
  265. typedef enum {
  266. AP_REG0_EN = (1 << 15),
  267. AP_REG0_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */
  268. AP_PHY0_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */
  269. }AUTOPOLL0_BITS;
  270. /* AUTOPOLL1 0x8A, 16bit register */
  271. typedef enum {
  272. AP_REG1_EN = (1 << 15),
  273. AP_REG1_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */
  274. AP_PRE_SUP1 = (1 << 6),
  275. AP_PHY1_DFLT = (1 << 5),
  276. AP_PHY1_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */
  277. }AUTOPOLL1_BITS;
  278. typedef enum {
  279. AP_REG2_EN = (1 << 15),
  280. AP_REG2_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */
  281. AP_PRE_SUP2 = (1 << 6),
  282. AP_PHY2_DFLT = (1 << 5),
  283. AP_PHY2_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */
  284. }AUTOPOLL2_BITS;
  285. typedef enum {
  286. AP_REG3_EN = (1 << 15),
  287. AP_REG3_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */
  288. AP_PRE_SUP3 = (1 << 6),
  289. AP_PHY3_DFLT = (1 << 5),
  290. AP_PHY3_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */
  291. }AUTOPOLL3_BITS;
  292. typedef enum {
  293. AP_REG4_EN = (1 << 15),
  294. AP_REG4_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */
  295. AP_PRE_SUP4 = (1 << 6),
  296. AP_PHY4_DFLT = (1 << 5),
  297. AP_PHY4_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */
  298. }AUTOPOLL4_BITS;
  299. typedef enum {
  300. AP_REG5_EN = (1 << 15),
  301. AP_REG5_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */
  302. AP_PRE_SUP5 = (1 << 6),
  303. AP_PHY5_DFLT = (1 << 5),
  304. AP_PHY5_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */
  305. }AUTOPOLL5_BITS;
  306. /* AP_VALUE 0x98, 32bit ragister */
  307. typedef enum {
  308. AP_VAL_ACTIVE = (1 << 31),
  309. AP_VAL_RD_CMD = ( 1 << 29),
  310. AP_ADDR = (1 << 18)|(1 << 17)|(1 << 16), /* 18:16 */
  311. AP_VAL = (0xF << 0) | (0xF << 4) |( 0xF << 8) |
  312. (0xF << 12), /* 15:0 */
  313. }AP_VALUE_BITS;
  314. typedef enum {
  315. DLY_INT_A_R3 = (1 << 31),
  316. DLY_INT_A_R2 = (1 << 30),
  317. DLY_INT_A_R1 = (1 << 29),
  318. DLY_INT_A_R0 = (1 << 28),
  319. DLY_INT_A_T3 = (1 << 27),
  320. DLY_INT_A_T2 = (1 << 26),
  321. DLY_INT_A_T1 = (1 << 25),
  322. DLY_INT_A_T0 = ( 1 << 24),
  323. EVENT_COUNT_A = (0xF << 16) | (0x1 << 20),/* 20:16 */
  324. MAX_DELAY_TIME_A = (0xF << 0) | (0xF << 4) | (1 << 8)|
  325. (1 << 9) | (1 << 10), /* 10:0 */
  326. }DLY_INT_A_BITS;
  327. typedef enum {
  328. DLY_INT_B_R3 = (1 << 31),
  329. DLY_INT_B_R2 = (1 << 30),
  330. DLY_INT_B_R1 = (1 << 29),
  331. DLY_INT_B_R0 = (1 << 28),
  332. DLY_INT_B_T3 = (1 << 27),
  333. DLY_INT_B_T2 = (1 << 26),
  334. DLY_INT_B_T1 = (1 << 25),
  335. DLY_INT_B_T0 = ( 1 << 24),
  336. EVENT_COUNT_B = (0xF << 16) | (0x1 << 20),/* 20:16 */
  337. MAX_DELAY_TIME_B = (0xF << 0) | (0xF << 4) | (1 << 8)|
  338. (1 << 9) | (1 << 10), /* 10:0 */
  339. }DLY_INT_B_BITS;
  340. /* FLOW_CONTROL 0xC8, 32bit register */
  341. typedef enum {
  342. PAUSE_LEN_CHG = (1 << 30),
  343. FTPE = (1 << 22),
  344. FRPE = (1 << 21),
  345. NAPA = (1 << 20),
  346. NPA = (1 << 19),
  347. FIXP = ( 1 << 18),
  348. FCCMD = ( 1 << 16),
  349. PAUSE_LEN = (0xF << 0) | (0xF << 4) |( 0xF << 8) | (0xF << 12), /* 15:0 */
  350. }FLOW_CONTROL_BITS;
  351. /* PHY_ ACCESS 0xD0, 32bit register */
  352. typedef enum {
  353. PHY_CMD_ACTIVE = (1 << 31),
  354. PHY_WR_CMD = (1 << 30),
  355. PHY_RD_CMD = (1 << 29),
  356. PHY_RD_ERR = (1 << 28),
  357. PHY_PRE_SUP = (1 << 27),
  358. PHY_ADDR = (1 << 21) | (1 << 22) | (1 << 23)|
  359. (1 << 24) |(1 << 25),/* 25:21 */
  360. PHY_REG_ADDR = (1 << 16) | (1 << 17) | (1 << 18)| (1 << 19) | (1 << 20),/* 20:16 */
  361. PHY_DATA = (0xF << 0)|(0xF << 4) |(0xF << 8)|
  362. (0xF << 12),/* 15:0 */
  363. }PHY_ACCESS_BITS;
  364. /* PMAT0 0x190, 32bit register */
  365. typedef enum {
  366. PMR_ACTIVE = (1 << 31),
  367. PMR_WR_CMD = (1 << 30),
  368. PMR_RD_CMD = (1 << 29),
  369. PMR_BANK = (1 <<28),
  370. PMR_ADDR = (0xF << 16)|(1 << 20)|(1 << 21)|
  371. (1 << 22),/* 22:16 */
  372. PMR_B4 = (0xF << 0) | (0xF << 4),/* 15:0 */
  373. }PMAT0_BITS;
  374. /* PMAT1 0x194, 32bit register */
  375. typedef enum {
  376. PMR_B3 = (0xF << 24) | (0xF <<28),/* 31:24 */
  377. PMR_B2 = (0xF << 16) |(0xF << 20),/* 23:16 */
  378. PMR_B1 = (0xF << 8) | (0xF <<12), /* 15:8 */
  379. PMR_B0 = (0xF << 0)|(0xF << 4),/* 7:0 */
  380. }PMAT1_BITS;
  381. /************************************************************************/
  382. /* */
  383. /* MIB counter definitions */
  384. /* */
  385. /************************************************************************/
  386. #define rcv_miss_pkts 0x00
  387. #define rcv_octets 0x01
  388. #define rcv_broadcast_pkts 0x02
  389. #define rcv_multicast_pkts 0x03
  390. #define rcv_undersize_pkts 0x04
  391. #define rcv_oversize_pkts 0x05
  392. #define rcv_fragments 0x06
  393. #define rcv_jabbers 0x07
  394. #define rcv_unicast_pkts 0x08
  395. #define rcv_alignment_errors 0x09
  396. #define rcv_fcs_errors 0x0A
  397. #define rcv_good_octets 0x0B
  398. #define rcv_mac_ctrl 0x0C
  399. #define rcv_flow_ctrl 0x0D
  400. #define rcv_pkts_64_octets 0x0E
  401. #define rcv_pkts_65to127_octets 0x0F
  402. #define rcv_pkts_128to255_octets 0x10
  403. #define rcv_pkts_256to511_octets 0x11
  404. #define rcv_pkts_512to1023_octets 0x12
  405. #define rcv_pkts_1024to1518_octets 0x13
  406. #define rcv_unsupported_opcode 0x14
  407. #define rcv_symbol_errors 0x15
  408. #define rcv_drop_pkts_ring1 0x16
  409. #define rcv_drop_pkts_ring2 0x17
  410. #define rcv_drop_pkts_ring3 0x18
  411. #define rcv_drop_pkts_ring4 0x19
  412. #define rcv_jumbo_pkts 0x1A
  413. #define xmt_underrun_pkts 0x20
  414. #define xmt_octets 0x21
  415. #define xmt_packets 0x22
  416. #define xmt_broadcast_pkts 0x23
  417. #define xmt_multicast_pkts 0x24
  418. #define xmt_collisions 0x25
  419. #define xmt_unicast_pkts 0x26
  420. #define xmt_one_collision 0x27
  421. #define xmt_multiple_collision 0x28
  422. #define xmt_deferred_transmit 0x29
  423. #define xmt_late_collision 0x2A
  424. #define xmt_excessive_defer 0x2B
  425. #define xmt_loss_carrier 0x2C
  426. #define xmt_excessive_collision 0x2D
  427. #define xmt_back_pressure 0x2E
  428. #define xmt_flow_ctrl 0x2F
  429. #define xmt_pkts_64_octets 0x30
  430. #define xmt_pkts_65to127_octets 0x31
  431. #define xmt_pkts_128to255_octets 0x32
  432. #define xmt_pkts_256to511_octets 0x33
  433. #define xmt_pkts_512to1023_octets 0x34
  434. #define xmt_pkts_1024to1518_octet 0x35
  435. #define xmt_oversize_pkts 0x36
  436. #define xmt_jumbo_pkts 0x37
  437. /* Driver definitions */
  438. #define PCI_VENDOR_ID_AMD 0x1022
  439. #define PCI_DEVICE_ID_AMD8111E_7462 0x7462
  440. #define MAX_UNITS 8 /* Maximum number of devices possible */
  441. #define NUM_TX_BUFFERS 32 /* Number of transmit buffers */
  442. #define NUM_RX_BUFFERS 32 /* Number of receive buffers */
  443. #define TX_BUFF_MOD_MASK 31 /* (NUM_TX_BUFFERS -1) */
  444. #define RX_BUFF_MOD_MASK 31 /* (NUM_RX_BUFFERS -1) */
  445. #define NUM_TX_RING_DR 32
  446. #define NUM_RX_RING_DR 32
  447. #define TX_RING_DR_MOD_MASK 31 /* (NUM_TX_RING_DR -1) */
  448. #define RX_RING_DR_MOD_MASK 31 /* (NUM_RX_RING_DR -1) */
  449. #define MAX_FILTER_SIZE 64 /* Maximum multicast address */
  450. #define AMD8111E_MIN_MTU 60
  451. #define AMD8111E_MAX_MTU 9000
  452. #define PKT_BUFF_SZ 1536
  453. #define MIN_PKT_LEN 60
  454. #define AMD8111E_TX_TIMEOUT (3 * HZ)/* 3 sec */
  455. #define SOFT_TIMER_FREQ 0xBEBC /* 0.5 sec */
  456. #define DELAY_TIMER_CONV 50 /* msec to 10 usec conversion.
  457. Only 500 usec resolution */
  458. #define OPTION_VLAN_ENABLE 0x0001
  459. #define OPTION_JUMBO_ENABLE 0x0002
  460. #define OPTION_MULTICAST_ENABLE 0x0004
  461. #define OPTION_WOL_ENABLE 0x0008
  462. #define OPTION_WAKE_MAGIC_ENABLE 0x0010
  463. #define OPTION_WAKE_PHY_ENABLE 0x0020
  464. #define OPTION_INTR_COAL_ENABLE 0x0040
  465. #define OPTION_DYN_IPG_ENABLE 0x0080
  466. #define PHY_REG_ADDR_MASK 0x1f
  467. /* ipg parameters */
  468. #define DEFAULT_IPG 0x60
  469. #define IFS1_DELTA 36
  470. #define IPG_CONVERGE_JIFFIES (HZ/2)
  471. #define IPG_STABLE_TIME 5
  472. #define MIN_IPG 96
  473. #define MAX_IPG 255
  474. #define IPG_STEP 16
  475. #define CSTATE 1
  476. #define SSTATE 2
  477. /* Assume contoller gets data 10 times the maximum processing time */
  478. #define REPEAT_CNT 10
  479. /* amd8111e descriptor flag definitions */
  480. typedef enum {
  481. OWN_BIT = (1 << 15),
  482. ADD_FCS_BIT = (1 << 13),
  483. LTINT_BIT = (1 << 12),
  484. STP_BIT = (1 << 9),
  485. ENP_BIT = (1 << 8),
  486. KILL_BIT = (1 << 6),
  487. TCC_VLAN_INSERT = (1 << 1),
  488. TCC_VLAN_REPLACE = (1 << 1) |( 1<< 0),
  489. }TX_FLAG_BITS;
  490. typedef enum {
  491. ERR_BIT = (1 << 14),
  492. FRAM_BIT = (1 << 13),
  493. OFLO_BIT = (1 << 12),
  494. CRC_BIT = (1 << 11),
  495. PAM_BIT = (1 << 6),
  496. LAFM_BIT = (1 << 5),
  497. BAM_BIT = (1 << 4),
  498. TT_VLAN_TAGGED = (1 << 3) |(1 << 2),/* 0x000 */
  499. TT_PRTY_TAGGED = (1 << 3),/* 0x0008 */
  500. }RX_FLAG_BITS;
  501. #define RESET_RX_FLAGS 0x0000
  502. #define TT_MASK 0x000c
  503. #define TCC_MASK 0x0003
  504. /* driver ioctl parameters */
  505. #define AMD8111E_REG_DUMP_LEN 13*sizeof(u32)
  506. /* amd8111e desriptor format */
  507. struct amd8111e_tx_dr{
  508. __le16 buff_count; /* Size of the buffer pointed by this descriptor */
  509. __le16 tx_flags;
  510. __le16 tag_ctrl_info;
  511. __le16 tag_ctrl_cmd;
  512. __le32 buff_phy_addr;
  513. __le32 reserved;
  514. };
  515. struct amd8111e_rx_dr{
  516. __le32 reserved;
  517. __le16 msg_count; /* Received message len */
  518. __le16 tag_ctrl_info;
  519. __le16 buff_count; /* Len of the buffer pointed by descriptor. */
  520. __le16 rx_flags;
  521. __le32 buff_phy_addr;
  522. };
  523. struct amd8111e_link_config{
  524. #define SPEED_INVALID 0xffff
  525. #define DUPLEX_INVALID 0xff
  526. #define AUTONEG_INVALID 0xff
  527. unsigned long orig_phy_option;
  528. u16 speed;
  529. u8 duplex;
  530. u8 autoneg;
  531. u8 reserved; /* 32bit alignment */
  532. };
  533. enum coal_type{
  534. NO_COALESCE,
  535. LOW_COALESCE,
  536. MEDIUM_COALESCE,
  537. HIGH_COALESCE,
  538. };
  539. enum coal_mode{
  540. RX_INTR_COAL,
  541. TX_INTR_COAL,
  542. DISABLE_COAL,
  543. ENABLE_COAL,
  544. };
  545. #define MAX_TIMEOUT 40
  546. #define MAX_EVENT_COUNT 31
  547. struct amd8111e_coalesce_conf{
  548. unsigned int rx_timeout;
  549. unsigned int rx_event_count;
  550. unsigned long rx_packets;
  551. unsigned long rx_prev_packets;
  552. unsigned long rx_bytes;
  553. unsigned long rx_prev_bytes;
  554. unsigned int rx_coal_type;
  555. unsigned int tx_timeout;
  556. unsigned int tx_event_count;
  557. unsigned long tx_packets;
  558. unsigned long tx_prev_packets;
  559. unsigned long tx_bytes;
  560. unsigned long tx_prev_bytes;
  561. unsigned int tx_coal_type;
  562. };
  563. struct ipg_info{
  564. unsigned int ipg_state;
  565. unsigned int ipg;
  566. unsigned int current_ipg;
  567. unsigned int col_cnt;
  568. unsigned int diff_col_cnt;
  569. unsigned int timer_tick;
  570. unsigned int prev_ipg;
  571. struct timer_list ipg_timer;
  572. };
  573. struct amd8111e_priv{
  574. struct amd8111e_tx_dr* tx_ring;
  575. struct amd8111e_rx_dr* rx_ring;
  576. dma_addr_t tx_ring_dma_addr; /* tx descriptor ring base address */
  577. dma_addr_t rx_ring_dma_addr; /* rx descriptor ring base address */
  578. const char *name;
  579. struct pci_dev *pci_dev; /* Ptr to the associated pci_dev */
  580. struct net_device* amd8111e_net_dev; /* ptr to associated net_device */
  581. /* Transmit and receive skbs */
  582. struct sk_buff *tx_skbuff[NUM_TX_BUFFERS];
  583. struct sk_buff *rx_skbuff[NUM_RX_BUFFERS];
  584. /* Transmit and receive dma mapped addr */
  585. dma_addr_t tx_dma_addr[NUM_TX_BUFFERS];
  586. dma_addr_t rx_dma_addr[NUM_RX_BUFFERS];
  587. /* Reg memory mapped address */
  588. void __iomem *mmio;
  589. struct napi_struct napi;
  590. spinlock_t lock; /* Guard lock */
  591. unsigned long rx_idx, tx_idx; /* The next free ring entry */
  592. unsigned long tx_complete_idx;
  593. unsigned long tx_ring_complete_idx;
  594. unsigned long tx_ring_idx;
  595. unsigned int rx_buff_len; /* Buffer length of rx buffers */
  596. int options; /* Options enabled/disabled for the device */
  597. unsigned long ext_phy_option;
  598. int ext_phy_addr;
  599. u32 ext_phy_id;
  600. struct amd8111e_link_config link_config;
  601. int pm_cap;
  602. struct net_device *next;
  603. int mii;
  604. struct mii_if_info mii_if;
  605. char opened;
  606. unsigned int drv_rx_errors;
  607. struct amd8111e_coalesce_conf coal_conf;
  608. struct ipg_info ipg_data;
  609. };
  610. /* kernel provided writeq does not write 64 bits into the amd8111e device register instead writes only higher 32bits data into lower 32bits of the register.
  611. BUG? */
  612. #define amd8111e_writeq(_UlData,_memMap) \
  613. writel(*(u32*)(&_UlData), _memMap); \
  614. writel(*(u32*)((u8*)(&_UlData)+4), _memMap+4)
  615. /* maps the external speed options to internal value */
  616. typedef enum {
  617. SPEED_AUTONEG,
  618. SPEED10_HALF,
  619. SPEED10_FULL,
  620. SPEED100_HALF,
  621. SPEED100_FULL,
  622. }EXT_PHY_OPTION;
  623. static int card_idx;
  624. static int speed_duplex[MAX_UNITS] = { 0, };
  625. static bool coalesce[MAX_UNITS] = { [ 0 ... MAX_UNITS-1] = true };
  626. static bool dynamic_ipg[MAX_UNITS] = { [ 0 ... MAX_UNITS-1] = false };
  627. static unsigned int chip_version;
  628. #endif /* _AMD8111E_H */