ucc_geth.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. /*
  2. * Copyright (C) Freescale Semicondutor, Inc. 2006-2009. All rights reserved.
  3. *
  4. * Author: Shlomi Gridish <gridish@freescale.com>
  5. *
  6. * Description:
  7. * Internal header file for UCC Gigabit Ethernet unit routines.
  8. *
  9. * Changelog:
  10. * Jun 28, 2006 Li Yang <LeoLi@freescale.com>
  11. * - Rearrange code and style fixes
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. */
  18. #ifndef __UCC_GETH_H__
  19. #define __UCC_GETH_H__
  20. #include <linux/kernel.h>
  21. #include <linux/list.h>
  22. #include <linux/if_ether.h>
  23. #include <soc/fsl/qe/immap_qe.h>
  24. #include <soc/fsl/qe/qe.h>
  25. #include <soc/fsl/qe/ucc.h>
  26. #include <soc/fsl/qe/ucc_fast.h>
  27. #define DRV_DESC "QE UCC Gigabit Ethernet Controller"
  28. #define DRV_NAME "ucc_geth"
  29. #define DRV_VERSION "1.1"
  30. #define NUM_TX_QUEUES 8
  31. #define NUM_RX_QUEUES 8
  32. #define NUM_BDS_IN_PREFETCHED_BDS 4
  33. #define TX_IP_OFFSET_ENTRY_MAX 8
  34. #define NUM_OF_PADDRS 4
  35. #define ENET_INIT_PARAM_MAX_ENTRIES_RX 9
  36. #define ENET_INIT_PARAM_MAX_ENTRIES_TX 8
  37. struct ucc_geth {
  38. struct ucc_fast uccf;
  39. u8 res0[0x100 - sizeof(struct ucc_fast)];
  40. u32 maccfg1; /* mac configuration reg. 1 */
  41. u32 maccfg2; /* mac configuration reg. 2 */
  42. u32 ipgifg; /* interframe gap reg. */
  43. u32 hafdup; /* half-duplex reg. */
  44. u8 res1[0x10];
  45. u8 miimng[0x18]; /* MII management structure moved to _mii.h */
  46. u32 ifctl; /* interface control reg */
  47. u32 ifstat; /* interface statux reg */
  48. u32 macstnaddr1; /* mac station address part 1 reg */
  49. u32 macstnaddr2; /* mac station address part 2 reg */
  50. u8 res2[0x8];
  51. u32 uempr; /* UCC Ethernet Mac parameter reg */
  52. u32 utbipar; /* UCC tbi address reg */
  53. u16 uescr; /* UCC Ethernet statistics control reg */
  54. u8 res3[0x180 - 0x15A];
  55. u32 tx64; /* Total number of frames (including bad
  56. frames) transmitted that were exactly of the
  57. minimal length (64 for un tagged, 68 for
  58. tagged, or with length exactly equal to the
  59. parameter MINLength */
  60. u32 tx127; /* Total number of frames (including bad
  61. frames) transmitted that were between
  62. MINLength (Including FCS length==4) and 127
  63. octets */
  64. u32 tx255; /* Total number of frames (including bad
  65. frames) transmitted that were between 128
  66. (Including FCS length==4) and 255 octets */
  67. u32 rx64; /* Total number of frames received including
  68. bad frames that were exactly of the mninimal
  69. length (64 bytes) */
  70. u32 rx127; /* Total number of frames (including bad
  71. frames) received that were between MINLength
  72. (Including FCS length==4) and 127 octets */
  73. u32 rx255; /* Total number of frames (including bad
  74. frames) received that were between 128
  75. (Including FCS length==4) and 255 octets */
  76. u32 txok; /* Total number of octets residing in frames
  77. that where involved in successful
  78. transmission */
  79. u16 txcf; /* Total number of PAUSE control frames
  80. transmitted by this MAC */
  81. u8 res4[0x2];
  82. u32 tmca; /* Total number of frames that were transmitted
  83. successfully with the group address bit set
  84. that are not broadcast frames */
  85. u32 tbca; /* Total number of frames transmitted
  86. successfully that had destination address
  87. field equal to the broadcast address */
  88. u32 rxfok; /* Total number of frames received OK */
  89. u32 rxbok; /* Total number of octets received OK */
  90. u32 rbyt; /* Total number of octets received including
  91. octets in bad frames. Must be implemented in
  92. HW because it includes octets in frames that
  93. never even reach the UCC */
  94. u32 rmca; /* Total number of frames that were received
  95. successfully with the group address bit set
  96. that are not broadcast frames */
  97. u32 rbca; /* Total number of frames received successfully
  98. that had destination address equal to the
  99. broadcast address */
  100. u32 scar; /* Statistics carry register */
  101. u32 scam; /* Statistics caryy mask register */
  102. u8 res5[0x200 - 0x1c4];
  103. } __packed;
  104. /* UCC GETH TEMODR Register */
  105. #define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics
  106. */
  107. #define TEMODER_SCHEDULER_ENABLE 0x2000 /* enable scheduler */
  108. #define TEMODER_IP_CHECKSUM_GENERATE 0x0400 /* generate IPv4
  109. checksums */
  110. #define TEMODER_PERFORMANCE_OPTIMIZATION_MODE1 0x0200 /* enable performance
  111. optimization
  112. enhancement (mode1) */
  113. #define TEMODER_RMON_STATISTICS 0x0100 /* enable tx statistics
  114. */
  115. #define TEMODER_NUM_OF_QUEUES_SHIFT (15-15) /* Number of queues <<
  116. shift */
  117. /* UCC GETH TEMODR Register */
  118. #define REMODER_RX_RMON_STATISTICS_ENABLE 0x00001000 /* enable Rx
  119. statistics */
  120. #define REMODER_RX_EXTENDED_FEATURES 0x80000000 /* enable
  121. extended
  122. features */
  123. #define REMODER_VLAN_OPERATION_TAGGED_SHIFT (31-9 ) /* vlan operation
  124. tagged << shift */
  125. #define REMODER_VLAN_OPERATION_NON_TAGGED_SHIFT (31-10) /* vlan operation non
  126. tagged << shift */
  127. #define REMODER_RX_QOS_MODE_SHIFT (31-15) /* rx QoS mode << shift
  128. */
  129. #define REMODER_RMON_STATISTICS 0x00001000 /* enable rx
  130. statistics */
  131. #define REMODER_RX_EXTENDED_FILTERING 0x00000800 /* extended
  132. filtering
  133. vs.
  134. mpc82xx-like
  135. filtering */
  136. #define REMODER_NUM_OF_QUEUES_SHIFT (31-23) /* Number of queues <<
  137. shift */
  138. #define REMODER_DYNAMIC_MAX_FRAME_LENGTH 0x00000008 /* enable
  139. dynamic max
  140. frame length
  141. */
  142. #define REMODER_DYNAMIC_MIN_FRAME_LENGTH 0x00000004 /* enable
  143. dynamic min
  144. frame length
  145. */
  146. #define REMODER_IP_CHECKSUM_CHECK 0x00000002 /* check IPv4
  147. checksums */
  148. #define REMODER_IP_ADDRESS_ALIGNMENT 0x00000001 /* align ip
  149. address to
  150. 4-byte
  151. boundary */
  152. /* UCC GETH Event Register */
  153. #define UCCE_TXB (UCC_GETH_UCCE_TXB7 | UCC_GETH_UCCE_TXB6 | \
  154. UCC_GETH_UCCE_TXB5 | UCC_GETH_UCCE_TXB4 | \
  155. UCC_GETH_UCCE_TXB3 | UCC_GETH_UCCE_TXB2 | \
  156. UCC_GETH_UCCE_TXB1 | UCC_GETH_UCCE_TXB0)
  157. #define UCCE_RXB (UCC_GETH_UCCE_RXB7 | UCC_GETH_UCCE_RXB6 | \
  158. UCC_GETH_UCCE_RXB5 | UCC_GETH_UCCE_RXB4 | \
  159. UCC_GETH_UCCE_RXB3 | UCC_GETH_UCCE_RXB2 | \
  160. UCC_GETH_UCCE_RXB1 | UCC_GETH_UCCE_RXB0)
  161. #define UCCE_RXF (UCC_GETH_UCCE_RXF7 | UCC_GETH_UCCE_RXF6 | \
  162. UCC_GETH_UCCE_RXF5 | UCC_GETH_UCCE_RXF4 | \
  163. UCC_GETH_UCCE_RXF3 | UCC_GETH_UCCE_RXF2 | \
  164. UCC_GETH_UCCE_RXF1 | UCC_GETH_UCCE_RXF0)
  165. #define UCCE_OTHER (UCC_GETH_UCCE_SCAR | UCC_GETH_UCCE_GRA | \
  166. UCC_GETH_UCCE_CBPR | UCC_GETH_UCCE_BSY | \
  167. UCC_GETH_UCCE_RXC | UCC_GETH_UCCE_TXC | UCC_GETH_UCCE_TXE)
  168. #define UCCE_RX_EVENTS (UCCE_RXF | UCC_GETH_UCCE_BSY)
  169. #define UCCE_TX_EVENTS (UCCE_TXB | UCC_GETH_UCCE_TXE)
  170. /* TBI defines */
  171. #define ENET_TBI_MII_CR 0x00 /* Control */
  172. #define ENET_TBI_MII_SR 0x01 /* Status */
  173. #define ENET_TBI_MII_ANA 0x04 /* AN advertisement */
  174. #define ENET_TBI_MII_ANLPBPA 0x05 /* AN link partner base page ability */
  175. #define ENET_TBI_MII_ANEX 0x06 /* AN expansion */
  176. #define ENET_TBI_MII_ANNPT 0x07 /* AN next page transmit */
  177. #define ENET_TBI_MII_ANLPANP 0x08 /* AN link partner ability next page */
  178. #define ENET_TBI_MII_EXST 0x0F /* Extended status */
  179. #define ENET_TBI_MII_JD 0x10 /* Jitter diagnostics */
  180. #define ENET_TBI_MII_TBICON 0x11 /* TBI control */
  181. /* TBI MDIO register bit fields*/
  182. #define TBISR_LSTATUS 0x0004
  183. #define TBICON_CLK_SELECT 0x0020
  184. #define TBIANA_ASYMMETRIC_PAUSE 0x0100
  185. #define TBIANA_SYMMETRIC_PAUSE 0x0080
  186. #define TBIANA_HALF_DUPLEX 0x0040
  187. #define TBIANA_FULL_DUPLEX 0x0020
  188. #define TBICR_PHY_RESET 0x8000
  189. #define TBICR_ANEG_ENABLE 0x1000
  190. #define TBICR_RESTART_ANEG 0x0200
  191. #define TBICR_FULL_DUPLEX 0x0100
  192. #define TBICR_SPEED1_SET 0x0040
  193. #define TBIANA_SETTINGS ( \
  194. TBIANA_ASYMMETRIC_PAUSE \
  195. | TBIANA_SYMMETRIC_PAUSE \
  196. | TBIANA_FULL_DUPLEX \
  197. )
  198. #define TBICR_SETTINGS ( \
  199. TBICR_PHY_RESET \
  200. | TBICR_ANEG_ENABLE \
  201. | TBICR_FULL_DUPLEX \
  202. | TBICR_SPEED1_SET \
  203. )
  204. /* UCC GETH MACCFG1 (MAC Configuration 1 Register) */
  205. #define MACCFG1_FLOW_RX 0x00000020 /* Flow Control
  206. Rx */
  207. #define MACCFG1_FLOW_TX 0x00000010 /* Flow Control
  208. Tx */
  209. #define MACCFG1_ENABLE_SYNCHED_RX 0x00000008 /* Rx Enable
  210. synchronized
  211. to Rx stream
  212. */
  213. #define MACCFG1_ENABLE_RX 0x00000004 /* Enable Rx */
  214. #define MACCFG1_ENABLE_SYNCHED_TX 0x00000002 /* Tx Enable
  215. synchronized
  216. to Tx stream
  217. */
  218. #define MACCFG1_ENABLE_TX 0x00000001 /* Enable Tx */
  219. /* UCC GETH MACCFG2 (MAC Configuration 2 Register) */
  220. #define MACCFG2_PREL_SHIFT (31 - 19) /* Preamble
  221. Length <<
  222. shift */
  223. #define MACCFG2_PREL_MASK 0x0000f000 /* Preamble
  224. Length mask */
  225. #define MACCFG2_SRP 0x00000080 /* Soft Receive
  226. Preamble */
  227. #define MACCFG2_STP 0x00000040 /* Soft
  228. Transmit
  229. Preamble */
  230. #define MACCFG2_RESERVED_1 0x00000020 /* Reserved -
  231. must be set
  232. to 1 */
  233. #define MACCFG2_LC 0x00000010 /* Length Check
  234. */
  235. #define MACCFG2_MPE 0x00000008 /* Magic packet
  236. detect */
  237. #define MACCFG2_FDX 0x00000001 /* Full Duplex */
  238. #define MACCFG2_FDX_MASK 0x00000001 /* Full Duplex
  239. mask */
  240. #define MACCFG2_PAD_CRC 0x00000004
  241. #define MACCFG2_CRC_EN 0x00000002
  242. #define MACCFG2_PAD_AND_CRC_MODE_NONE 0x00000000 /* Neither
  243. Padding
  244. short frames
  245. nor CRC */
  246. #define MACCFG2_PAD_AND_CRC_MODE_CRC_ONLY 0x00000002 /* Append CRC
  247. only */
  248. #define MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC 0x00000004
  249. #define MACCFG2_INTERFACE_MODE_NIBBLE 0x00000100 /* nibble mode
  250. (MII/RMII/RGMII
  251. 10/100bps) */
  252. #define MACCFG2_INTERFACE_MODE_BYTE 0x00000200 /* byte mode
  253. (GMII/TBI/RTB/RGMII
  254. 1000bps ) */
  255. #define MACCFG2_INTERFACE_MODE_MASK 0x00000300 /* mask
  256. covering all
  257. relevant
  258. bits */
  259. /* UCC GETH IPGIFG (Inter-frame Gap / Inter-Frame Gap Register) */
  260. #define IPGIFG_NON_BACK_TO_BACK_IFG_PART1_SHIFT (31 - 7) /* Non
  261. back-to-back
  262. inter frame
  263. gap part 1.
  264. << shift */
  265. #define IPGIFG_NON_BACK_TO_BACK_IFG_PART2_SHIFT (31 - 15) /* Non
  266. back-to-back
  267. inter frame
  268. gap part 2.
  269. << shift */
  270. #define IPGIFG_MINIMUM_IFG_ENFORCEMENT_SHIFT (31 - 23) /* Mimimum IFG
  271. Enforcement
  272. << shift */
  273. #define IPGIFG_BACK_TO_BACK_IFG_SHIFT (31 - 31) /* back-to-back
  274. inter frame
  275. gap << shift
  276. */
  277. #define IPGIFG_NON_BACK_TO_BACK_IFG_PART1_MAX 127 /* Non back-to-back
  278. inter frame gap part
  279. 1. max val */
  280. #define IPGIFG_NON_BACK_TO_BACK_IFG_PART2_MAX 127 /* Non back-to-back
  281. inter frame gap part
  282. 2. max val */
  283. #define IPGIFG_MINIMUM_IFG_ENFORCEMENT_MAX 255 /* Mimimum IFG
  284. Enforcement max val */
  285. #define IPGIFG_BACK_TO_BACK_IFG_MAX 127 /* back-to-back inter
  286. frame gap max val */
  287. #define IPGIFG_NBTB_CS_IPG_MASK 0x7F000000
  288. #define IPGIFG_NBTB_IPG_MASK 0x007F0000
  289. #define IPGIFG_MIN_IFG_MASK 0x0000FF00
  290. #define IPGIFG_BTB_IPG_MASK 0x0000007F
  291. /* UCC GETH HAFDUP (Half Duplex Register) */
  292. #define HALFDUP_ALT_BEB_TRUNCATION_SHIFT (31 - 11) /* Alternate
  293. Binary
  294. Exponential
  295. Backoff
  296. Truncation
  297. << shift */
  298. #define HALFDUP_ALT_BEB_TRUNCATION_MAX 0xf /* Alternate Binary
  299. Exponential Backoff
  300. Truncation max val */
  301. #define HALFDUP_ALT_BEB 0x00080000 /* Alternate
  302. Binary
  303. Exponential
  304. Backoff */
  305. #define HALFDUP_BACK_PRESSURE_NO_BACKOFF 0x00040000 /* Back
  306. pressure no
  307. backoff */
  308. #define HALFDUP_NO_BACKOFF 0x00020000 /* No Backoff */
  309. #define HALFDUP_EXCESSIVE_DEFER 0x00010000 /* Excessive
  310. Defer */
  311. #define HALFDUP_MAX_RETRANSMISSION_SHIFT (31 - 19) /* Maximum
  312. Retransmission
  313. << shift */
  314. #define HALFDUP_MAX_RETRANSMISSION_MAX 0xf /* Maximum
  315. Retransmission max
  316. val */
  317. #define HALFDUP_COLLISION_WINDOW_SHIFT (31 - 31) /* Collision
  318. Window <<
  319. shift */
  320. #define HALFDUP_COLLISION_WINDOW_MAX 0x3f /* Collision Window max
  321. val */
  322. #define HALFDUP_ALT_BEB_TR_MASK 0x00F00000
  323. #define HALFDUP_RETRANS_MASK 0x0000F000
  324. #define HALFDUP_COL_WINDOW_MASK 0x0000003F
  325. /* UCC GETH UCCS (Ethernet Status Register) */
  326. #define UCCS_BPR 0x02 /* Back pressure (in
  327. half duplex mode) */
  328. #define UCCS_PAU 0x02 /* Pause state (in full
  329. duplex mode) */
  330. #define UCCS_MPD 0x01 /* Magic Packet
  331. Detected */
  332. /* UCC GETH IFSTAT (Interface Status Register) */
  333. #define IFSTAT_EXCESS_DEFER 0x00000200 /* Excessive
  334. transmission
  335. defer */
  336. /* UCC GETH MACSTNADDR1 (Station Address Part 1 Register) */
  337. #define MACSTNADDR1_OCTET_6_SHIFT (31 - 7) /* Station
  338. address 6th
  339. octet <<
  340. shift */
  341. #define MACSTNADDR1_OCTET_5_SHIFT (31 - 15) /* Station
  342. address 5th
  343. octet <<
  344. shift */
  345. #define MACSTNADDR1_OCTET_4_SHIFT (31 - 23) /* Station
  346. address 4th
  347. octet <<
  348. shift */
  349. #define MACSTNADDR1_OCTET_3_SHIFT (31 - 31) /* Station
  350. address 3rd
  351. octet <<
  352. shift */
  353. /* UCC GETH MACSTNADDR2 (Station Address Part 2 Register) */
  354. #define MACSTNADDR2_OCTET_2_SHIFT (31 - 7) /* Station
  355. address 2nd
  356. octet <<
  357. shift */
  358. #define MACSTNADDR2_OCTET_1_SHIFT (31 - 15) /* Station
  359. address 1st
  360. octet <<
  361. shift */
  362. /* UCC GETH UEMPR (Ethernet Mac Parameter Register) */
  363. #define UEMPR_PAUSE_TIME_VALUE_SHIFT (31 - 15) /* Pause time
  364. value <<
  365. shift */
  366. #define UEMPR_EXTENDED_PAUSE_TIME_VALUE_SHIFT (31 - 31) /* Extended
  367. pause time
  368. value <<
  369. shift */
  370. /* UCC GETH UTBIPAR (Ten Bit Interface Physical Address Register) */
  371. #define UTBIPAR_PHY_ADDRESS_SHIFT (31 - 31) /* Phy address
  372. << shift */
  373. #define UTBIPAR_PHY_ADDRESS_MASK 0x0000001f /* Phy address
  374. mask */
  375. /* UCC GETH UESCR (Ethernet Statistics Control Register) */
  376. #define UESCR_AUTOZ 0x8000 /* Automatically zero
  377. addressed
  378. statistical counter
  379. values */
  380. #define UESCR_CLRCNT 0x4000 /* Clear all statistics
  381. counters */
  382. #define UESCR_MAXCOV_SHIFT (15 - 7) /* Max
  383. Coalescing
  384. Value <<
  385. shift */
  386. #define UESCR_SCOV_SHIFT (15 - 15) /* Status
  387. Coalescing
  388. Value <<
  389. shift */
  390. /* UCC GETH UDSR (Data Synchronization Register) */
  391. #define UDSR_MAGIC 0x067E
  392. struct ucc_geth_thread_data_tx {
  393. u8 res0[104];
  394. } __packed;
  395. struct ucc_geth_thread_data_rx {
  396. u8 res0[40];
  397. } __packed;
  398. /* Send Queue Queue-Descriptor */
  399. struct ucc_geth_send_queue_qd {
  400. u32 bd_ring_base; /* pointer to BD ring base address */
  401. u8 res0[0x8];
  402. u32 last_bd_completed_address;/* initialize to last entry in BD ring */
  403. u8 res1[0x30];
  404. } __packed;
  405. struct ucc_geth_send_queue_mem_region {
  406. struct ucc_geth_send_queue_qd sqqd[NUM_TX_QUEUES];
  407. } __packed;
  408. struct ucc_geth_thread_tx_pram {
  409. u8 res0[64];
  410. } __packed;
  411. struct ucc_geth_thread_rx_pram {
  412. u8 res0[128];
  413. } __packed;
  414. #define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64
  415. #define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64
  416. #define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96
  417. struct ucc_geth_scheduler {
  418. u16 cpucount0; /* CPU packet counter */
  419. u16 cpucount1; /* CPU packet counter */
  420. u16 cecount0; /* QE packet counter */
  421. u16 cecount1; /* QE packet counter */
  422. u16 cpucount2; /* CPU packet counter */
  423. u16 cpucount3; /* CPU packet counter */
  424. u16 cecount2; /* QE packet counter */
  425. u16 cecount3; /* QE packet counter */
  426. u16 cpucount4; /* CPU packet counter */
  427. u16 cpucount5; /* CPU packet counter */
  428. u16 cecount4; /* QE packet counter */
  429. u16 cecount5; /* QE packet counter */
  430. u16 cpucount6; /* CPU packet counter */
  431. u16 cpucount7; /* CPU packet counter */
  432. u16 cecount6; /* QE packet counter */
  433. u16 cecount7; /* QE packet counter */
  434. u32 weightstatus[NUM_TX_QUEUES]; /* accumulated weight factor */
  435. u32 rtsrshadow; /* temporary variable handled by QE */
  436. u32 time; /* temporary variable handled by QE */
  437. u32 ttl; /* temporary variable handled by QE */
  438. u32 mblinterval; /* max burst length interval */
  439. u16 nortsrbytetime; /* normalized value of byte time in tsr units */
  440. u8 fracsiz; /* radix 2 log value of denom. of
  441. NorTSRByteTime */
  442. u8 res0[1];
  443. u8 strictpriorityq; /* Strict Priority Mask register */
  444. u8 txasap; /* Transmit ASAP register */
  445. u8 extrabw; /* Extra BandWidth register */
  446. u8 oldwfqmask; /* temporary variable handled by QE */
  447. u8 weightfactor[NUM_TX_QUEUES];
  448. /**< weight factor for queues */
  449. u32 minw; /* temporary variable handled by QE */
  450. u8 res1[0x70 - 0x64];
  451. } __packed;
  452. struct ucc_geth_tx_firmware_statistics_pram {
  453. u32 sicoltx; /* single collision */
  454. u32 mulcoltx; /* multiple collision */
  455. u32 latecoltxfr; /* late collision */
  456. u32 frabortduecol; /* frames aborted due to transmit collision */
  457. u32 frlostinmactxer; /* frames lost due to internal MAC error
  458. transmission that are not counted on any
  459. other counter */
  460. u32 carriersenseertx; /* carrier sense error */
  461. u32 frtxok; /* frames transmitted OK */
  462. u32 txfrexcessivedefer; /* frames with defferal time greater than
  463. specified threshold */
  464. u32 txpkts256; /* total packets (including bad) between 256
  465. and 511 octets */
  466. u32 txpkts512; /* total packets (including bad) between 512
  467. and 1023 octets */
  468. u32 txpkts1024; /* total packets (including bad) between 1024
  469. and 1518 octets */
  470. u32 txpktsjumbo; /* total packets (including bad) between 1024
  471. and MAXLength octets */
  472. } __packed;
  473. struct ucc_geth_rx_firmware_statistics_pram {
  474. u32 frrxfcser; /* frames with crc error */
  475. u32 fraligner; /* frames with alignment error */
  476. u32 inrangelenrxer; /* in range length error */
  477. u32 outrangelenrxer; /* out of range length error */
  478. u32 frtoolong; /* frame too long */
  479. u32 runt; /* runt */
  480. u32 verylongevent; /* very long event */
  481. u32 symbolerror; /* symbol error */
  482. u32 dropbsy; /* drop because of BD not ready */
  483. u8 res0[0x8];
  484. u32 mismatchdrop; /* drop because of MAC filtering (e.g. address
  485. or type mismatch) */
  486. u32 underpkts; /* total frames less than 64 octets */
  487. u32 pkts256; /* total frames (including bad) between 256 and
  488. 511 octets */
  489. u32 pkts512; /* total frames (including bad) between 512 and
  490. 1023 octets */
  491. u32 pkts1024; /* total frames (including bad) between 1024
  492. and 1518 octets */
  493. u32 pktsjumbo; /* total frames (including bad) between 1024
  494. and MAXLength octets */
  495. u32 frlossinmacer; /* frames lost because of internal MAC error
  496. that is not counted in any other counter */
  497. u32 pausefr; /* pause frames */
  498. u8 res1[0x4];
  499. u32 removevlan; /* total frames that had their VLAN tag removed
  500. */
  501. u32 replacevlan; /* total frames that had their VLAN tag
  502. replaced */
  503. u32 insertvlan; /* total frames that had their VLAN tag
  504. inserted */
  505. } __packed;
  506. struct ucc_geth_rx_interrupt_coalescing_entry {
  507. u32 interruptcoalescingmaxvalue; /* interrupt coalescing max
  508. value */
  509. u32 interruptcoalescingcounter; /* interrupt coalescing counter,
  510. initialize to
  511. interruptcoalescingmaxvalue */
  512. } __packed;
  513. struct ucc_geth_rx_interrupt_coalescing_table {
  514. struct ucc_geth_rx_interrupt_coalescing_entry coalescingentry[NUM_RX_QUEUES];
  515. /**< interrupt coalescing entry */
  516. } __packed;
  517. struct ucc_geth_rx_prefetched_bds {
  518. struct qe_bd bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */
  519. } __packed;
  520. struct ucc_geth_rx_bd_queues_entry {
  521. u32 bdbaseptr; /* BD base pointer */
  522. u32 bdptr; /* BD pointer */
  523. u32 externalbdbaseptr; /* external BD base pointer */
  524. u32 externalbdptr; /* external BD pointer */
  525. } __packed;
  526. struct ucc_geth_tx_global_pram {
  527. u16 temoder;
  528. u8 res0[0x38 - 0x02];
  529. u32 sqptr; /* a base pointer to send queue memory region */
  530. u32 schedulerbasepointer; /* a base pointer to scheduler memory
  531. region */
  532. u32 txrmonbaseptr; /* base pointer to Tx RMON statistics counter */
  533. u32 tstate; /* tx internal state. High byte contains
  534. function code */
  535. u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
  536. u32 vtagtable[0x8]; /* 8 4-byte VLAN tags */
  537. u32 tqptr; /* a base pointer to the Tx Queues Memory
  538. Region */
  539. u8 res2[0x80 - 0x74];
  540. } __packed;
  541. /* structure representing Extended Filtering Global Parameters in PRAM */
  542. struct ucc_geth_exf_global_pram {
  543. u32 l2pcdptr; /* individual address filter, high */
  544. u8 res0[0x10 - 0x04];
  545. } __packed;
  546. struct ucc_geth_rx_global_pram {
  547. u32 remoder; /* ethernet mode reg. */
  548. u32 rqptr; /* base pointer to the Rx Queues Memory Region*/
  549. u32 res0[0x1];
  550. u8 res1[0x20 - 0xC];
  551. u16 typeorlen; /* cutoff point less than which, type/len field
  552. is considered length */
  553. u8 res2[0x1];
  554. u8 rxgstpack; /* acknowledgement on GRACEFUL STOP RX command*/
  555. u32 rxrmonbaseptr; /* base pointer to Rx RMON statistics counter */
  556. u8 res3[0x30 - 0x28];
  557. u32 intcoalescingptr; /* Interrupt coalescing table pointer */
  558. u8 res4[0x36 - 0x34];
  559. u8 rstate; /* rx internal state. High byte contains
  560. function code */
  561. u8 res5[0x46 - 0x37];
  562. u16 mrblr; /* max receive buffer length reg. */
  563. u32 rbdqptr; /* base pointer to RxBD parameter table
  564. description */
  565. u16 mflr; /* max frame length reg. */
  566. u16 minflr; /* min frame length reg. */
  567. u16 maxd1; /* max dma1 length reg. */
  568. u16 maxd2; /* max dma2 length reg. */
  569. u32 ecamptr; /* external CAM address */
  570. u32 l2qt; /* VLAN priority mapping table. */
  571. u32 l3qt[0x8]; /* IP priority mapping table. */
  572. u16 vlantype; /* vlan type */
  573. u16 vlantci; /* default vlan tci */
  574. u8 addressfiltering[64]; /* address filtering data structure */
  575. u32 exfGlobalParam; /* base address for extended filtering global
  576. parameters */
  577. u8 res6[0x100 - 0xC4]; /* Initialize to zero */
  578. } __packed;
  579. #define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01
  580. /* structure representing InitEnet command */
  581. struct ucc_geth_init_pram {
  582. u8 resinit1;
  583. u8 resinit2;
  584. u8 resinit3;
  585. u8 resinit4;
  586. u16 resinit5;
  587. u8 res1[0x1];
  588. u8 largestexternallookupkeysize;
  589. u32 rgftgfrxglobal;
  590. u32 rxthread[ENET_INIT_PARAM_MAX_ENTRIES_RX]; /* rx threads */
  591. u8 res2[0x38 - 0x30];
  592. u32 txglobal; /* tx global */
  593. u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */
  594. u8 res3[0x1];
  595. } __packed;
  596. #define ENET_INIT_PARAM_RGF_SHIFT (32 - 4)
  597. #define ENET_INIT_PARAM_TGF_SHIFT (32 - 8)
  598. #define ENET_INIT_PARAM_RISC_MASK 0x0000003f
  599. #define ENET_INIT_PARAM_PTR_MASK 0x00ffffc0
  600. #define ENET_INIT_PARAM_SNUM_MASK 0xff000000
  601. #define ENET_INIT_PARAM_SNUM_SHIFT 24
  602. #define ENET_INIT_PARAM_MAGIC_RES_INIT1 0x06
  603. #define ENET_INIT_PARAM_MAGIC_RES_INIT2 0x30
  604. #define ENET_INIT_PARAM_MAGIC_RES_INIT3 0xff
  605. #define ENET_INIT_PARAM_MAGIC_RES_INIT4 0x00
  606. #define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400
  607. /* structure representing 82xx Address Filtering Enet Address in PRAM */
  608. struct ucc_geth_82xx_enet_address {
  609. u8 res1[0x2];
  610. u16 h; /* address (MSB) */
  611. u16 m; /* address */
  612. u16 l; /* address (LSB) */
  613. } __packed;
  614. /* structure representing 82xx Address Filtering PRAM */
  615. struct ucc_geth_82xx_address_filtering_pram {
  616. u32 iaddr_h; /* individual address filter, high */
  617. u32 iaddr_l; /* individual address filter, low */
  618. u32 gaddr_h; /* group address filter, high */
  619. u32 gaddr_l; /* group address filter, low */
  620. struct ucc_geth_82xx_enet_address __iomem taddr;
  621. struct ucc_geth_82xx_enet_address __iomem paddr[NUM_OF_PADDRS];
  622. u8 res0[0x40 - 0x38];
  623. } __packed;
  624. /* GETH Tx firmware statistics structure, used when calling
  625. UCC_GETH_GetStatistics. */
  626. struct ucc_geth_tx_firmware_statistics {
  627. u32 sicoltx; /* single collision */
  628. u32 mulcoltx; /* multiple collision */
  629. u32 latecoltxfr; /* late collision */
  630. u32 frabortduecol; /* frames aborted due to transmit collision */
  631. u32 frlostinmactxer; /* frames lost due to internal MAC error
  632. transmission that are not counted on any
  633. other counter */
  634. u32 carriersenseertx; /* carrier sense error */
  635. u32 frtxok; /* frames transmitted OK */
  636. u32 txfrexcessivedefer; /* frames with defferal time greater than
  637. specified threshold */
  638. u32 txpkts256; /* total packets (including bad) between 256
  639. and 511 octets */
  640. u32 txpkts512; /* total packets (including bad) between 512
  641. and 1023 octets */
  642. u32 txpkts1024; /* total packets (including bad) between 1024
  643. and 1518 octets */
  644. u32 txpktsjumbo; /* total packets (including bad) between 1024
  645. and MAXLength octets */
  646. } __packed;
  647. /* GETH Rx firmware statistics structure, used when calling
  648. UCC_GETH_GetStatistics. */
  649. struct ucc_geth_rx_firmware_statistics {
  650. u32 frrxfcser; /* frames with crc error */
  651. u32 fraligner; /* frames with alignment error */
  652. u32 inrangelenrxer; /* in range length error */
  653. u32 outrangelenrxer; /* out of range length error */
  654. u32 frtoolong; /* frame too long */
  655. u32 runt; /* runt */
  656. u32 verylongevent; /* very long event */
  657. u32 symbolerror; /* symbol error */
  658. u32 dropbsy; /* drop because of BD not ready */
  659. u8 res0[0x8];
  660. u32 mismatchdrop; /* drop because of MAC filtering (e.g. address
  661. or type mismatch) */
  662. u32 underpkts; /* total frames less than 64 octets */
  663. u32 pkts256; /* total frames (including bad) between 256 and
  664. 511 octets */
  665. u32 pkts512; /* total frames (including bad) between 512 and
  666. 1023 octets */
  667. u32 pkts1024; /* total frames (including bad) between 1024
  668. and 1518 octets */
  669. u32 pktsjumbo; /* total frames (including bad) between 1024
  670. and MAXLength octets */
  671. u32 frlossinmacer; /* frames lost because of internal MAC error
  672. that is not counted in any other counter */
  673. u32 pausefr; /* pause frames */
  674. u8 res1[0x4];
  675. u32 removevlan; /* total frames that had their VLAN tag removed
  676. */
  677. u32 replacevlan; /* total frames that had their VLAN tag
  678. replaced */
  679. u32 insertvlan; /* total frames that had their VLAN tag
  680. inserted */
  681. } __packed;
  682. /* GETH hardware statistics structure, used when calling
  683. UCC_GETH_GetStatistics. */
  684. struct ucc_geth_hardware_statistics {
  685. u32 tx64; /* Total number of frames (including bad
  686. frames) transmitted that were exactly of the
  687. minimal length (64 for un tagged, 68 for
  688. tagged, or with length exactly equal to the
  689. parameter MINLength */
  690. u32 tx127; /* Total number of frames (including bad
  691. frames) transmitted that were between
  692. MINLength (Including FCS length==4) and 127
  693. octets */
  694. u32 tx255; /* Total number of frames (including bad
  695. frames) transmitted that were between 128
  696. (Including FCS length==4) and 255 octets */
  697. u32 rx64; /* Total number of frames received including
  698. bad frames that were exactly of the mninimal
  699. length (64 bytes) */
  700. u32 rx127; /* Total number of frames (including bad
  701. frames) received that were between MINLength
  702. (Including FCS length==4) and 127 octets */
  703. u32 rx255; /* Total number of frames (including bad
  704. frames) received that were between 128
  705. (Including FCS length==4) and 255 octets */
  706. u32 txok; /* Total number of octets residing in frames
  707. that where involved in successful
  708. transmission */
  709. u16 txcf; /* Total number of PAUSE control frames
  710. transmitted by this MAC */
  711. u32 tmca; /* Total number of frames that were transmitted
  712. successfully with the group address bit set
  713. that are not broadcast frames */
  714. u32 tbca; /* Total number of frames transmitted
  715. successfully that had destination address
  716. field equal to the broadcast address */
  717. u32 rxfok; /* Total number of frames received OK */
  718. u32 rxbok; /* Total number of octets received OK */
  719. u32 rbyt; /* Total number of octets received including
  720. octets in bad frames. Must be implemented in
  721. HW because it includes octets in frames that
  722. never even reach the UCC */
  723. u32 rmca; /* Total number of frames that were received
  724. successfully with the group address bit set
  725. that are not broadcast frames */
  726. u32 rbca; /* Total number of frames received successfully
  727. that had destination address equal to the
  728. broadcast address */
  729. } __packed;
  730. /* UCC GETH Tx errors returned via TxConf callback */
  731. #define TX_ERRORS_DEF 0x0200
  732. #define TX_ERRORS_EXDEF 0x0100
  733. #define TX_ERRORS_LC 0x0080
  734. #define TX_ERRORS_RL 0x0040
  735. #define TX_ERRORS_RC_MASK 0x003C
  736. #define TX_ERRORS_RC_SHIFT 2
  737. #define TX_ERRORS_UN 0x0002
  738. #define TX_ERRORS_CSL 0x0001
  739. /* UCC GETH Rx errors returned via RxStore callback */
  740. #define RX_ERRORS_CMR 0x0200
  741. #define RX_ERRORS_M 0x0100
  742. #define RX_ERRORS_BC 0x0080
  743. #define RX_ERRORS_MC 0x0040
  744. /* Transmit BD. These are in addition to values defined in uccf. */
  745. #define T_VID 0x003c0000 /* insert VLAN id index mask. */
  746. #define T_DEF (((u32) TX_ERRORS_DEF ) << 16)
  747. #define T_EXDEF (((u32) TX_ERRORS_EXDEF ) << 16)
  748. #define T_LC (((u32) TX_ERRORS_LC ) << 16)
  749. #define T_RL (((u32) TX_ERRORS_RL ) << 16)
  750. #define T_RC_MASK (((u32) TX_ERRORS_RC_MASK ) << 16)
  751. #define T_UN (((u32) TX_ERRORS_UN ) << 16)
  752. #define T_CSL (((u32) TX_ERRORS_CSL ) << 16)
  753. #define T_ERRORS_REPORT (T_DEF | T_EXDEF | T_LC | T_RL | T_RC_MASK \
  754. | T_UN | T_CSL) /* transmit errors to report */
  755. /* Receive BD. These are in addition to values defined in uccf. */
  756. #define R_LG 0x00200000 /* Frame length violation. */
  757. #define R_NO 0x00100000 /* Non-octet aligned frame. */
  758. #define R_SH 0x00080000 /* Short frame. */
  759. #define R_CR 0x00040000 /* CRC error. */
  760. #define R_OV 0x00020000 /* Overrun. */
  761. #define R_IPCH 0x00010000 /* IP checksum check failed. */
  762. #define R_CMR (((u32) RX_ERRORS_CMR ) << 16)
  763. #define R_M (((u32) RX_ERRORS_M ) << 16)
  764. #define R_BC (((u32) RX_ERRORS_BC ) << 16)
  765. #define R_MC (((u32) RX_ERRORS_MC ) << 16)
  766. #define R_ERRORS_REPORT (R_CMR | R_M | R_BC | R_MC) /* receive errors to
  767. report */
  768. #define R_ERRORS_FATAL (R_LG | R_NO | R_SH | R_CR | \
  769. R_OV | R_IPCH) /* receive errors to discard */
  770. /* Alignments */
  771. #define UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT 256
  772. #define UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT 128
  773. #define UCC_GETH_THREAD_RX_PRAM_ALIGNMENT 128
  774. #define UCC_GETH_THREAD_TX_PRAM_ALIGNMENT 64
  775. #define UCC_GETH_THREAD_DATA_ALIGNMENT 256 /* spec gives values
  776. based on num of
  777. threads, but always
  778. using the maximum is
  779. easier */
  780. #define UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT 32
  781. #define UCC_GETH_SCHEDULER_ALIGNMENT 8 /* This is a guess */
  782. #define UCC_GETH_TX_STATISTICS_ALIGNMENT 4 /* This is a guess */
  783. #define UCC_GETH_RX_STATISTICS_ALIGNMENT 4 /* This is a guess */
  784. #define UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT 64
  785. #define UCC_GETH_RX_BD_QUEUES_ALIGNMENT 8 /* This is a guess */
  786. #define UCC_GETH_RX_PREFETCHED_BDS_ALIGNMENT 128 /* This is a guess */
  787. #define UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT 8 /* This
  788. is a
  789. guess
  790. */
  791. #define UCC_GETH_RX_BD_RING_ALIGNMENT 32
  792. #define UCC_GETH_TX_BD_RING_ALIGNMENT 32
  793. #define UCC_GETH_MRBLR_ALIGNMENT 128
  794. #define UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT 4
  795. #define UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT 32
  796. #define UCC_GETH_RX_DATA_BUF_ALIGNMENT 64
  797. #define UCC_GETH_TAD_EF 0x80
  798. #define UCC_GETH_TAD_V 0x40
  799. #define UCC_GETH_TAD_REJ 0x20
  800. #define UCC_GETH_TAD_VTAG_OP_RIGHT_SHIFT 2
  801. #define UCC_GETH_TAD_VTAG_OP_SHIFT 6
  802. #define UCC_GETH_TAD_V_NON_VTAG_OP 0x20
  803. #define UCC_GETH_TAD_RQOS_SHIFT 0
  804. #define UCC_GETH_TAD_V_PRIORITY_SHIFT 5
  805. #define UCC_GETH_TAD_CFI 0x10
  806. #define UCC_GETH_VLAN_PRIORITY_MAX 8
  807. #define UCC_GETH_IP_PRIORITY_MAX 64
  808. #define UCC_GETH_TX_VTAG_TABLE_ENTRY_MAX 8
  809. #define UCC_GETH_RX_BD_RING_SIZE_MIN 8
  810. #define UCC_GETH_TX_BD_RING_SIZE_MIN 2
  811. #define UCC_GETH_BD_RING_SIZE_MAX 0xffff
  812. #define UCC_GETH_SIZE_OF_BD QE_SIZEOF_BD
  813. /* Driver definitions */
  814. #define TX_BD_RING_LEN 0x10
  815. #define RX_BD_RING_LEN 0x20
  816. #define TX_RING_MOD_MASK(size) (size-1)
  817. #define RX_RING_MOD_MASK(size) (size-1)
  818. #define ENET_GROUP_ADDR 0x01 /* Group address mask
  819. for ethernet
  820. addresses */
  821. #define TX_TIMEOUT (1*HZ)
  822. #define SKB_ALLOC_TIMEOUT 100000
  823. #define PHY_INIT_TIMEOUT 100000
  824. #define PHY_CHANGE_TIME 2
  825. /* Fast Ethernet (10/100 Mbps) */
  826. #define UCC_GETH_URFS_INIT 512 /* Rx virtual FIFO size
  827. */
  828. #define UCC_GETH_URFET_INIT 256 /* 1/2 urfs */
  829. #define UCC_GETH_URFSET_INIT 384 /* 3/4 urfs */
  830. #define UCC_GETH_UTFS_INIT 512 /* Tx virtual FIFO size
  831. */
  832. #define UCC_GETH_UTFET_INIT 256 /* 1/2 utfs */
  833. #define UCC_GETH_UTFTT_INIT 256 /* 1/2 utfs
  834. due to errata */
  835. /* Gigabit Ethernet (1000 Mbps) */
  836. #define UCC_GETH_URFS_GIGA_INIT 4096/*2048*/ /* Rx virtual
  837. FIFO size */
  838. #define UCC_GETH_URFET_GIGA_INIT 2048/*1024*/ /* 1/2 urfs */
  839. #define UCC_GETH_URFSET_GIGA_INIT 3072/*1536*/ /* 3/4 urfs */
  840. #define UCC_GETH_UTFS_GIGA_INIT 4096/*2048*/ /* Tx virtual
  841. FIFO size */
  842. #define UCC_GETH_UTFET_GIGA_INIT 2048/*1024*/ /* 1/2 utfs */
  843. #define UCC_GETH_UTFTT_GIGA_INIT 4096/*0x40*/ /* Tx virtual
  844. FIFO size */
  845. #define UCC_GETH_REMODER_INIT 0 /* bits that must be
  846. set */
  847. #define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */
  848. /* Initial value for UPSMR */
  849. #define UCC_GETH_UPSMR_INIT UCC_GETH_UPSMR_RES1
  850. #define UCC_GETH_MACCFG1_INIT 0
  851. #define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1)
  852. /* Ethernet Address Type. */
  853. enum enet_addr_type {
  854. ENET_ADDR_TYPE_INDIVIDUAL,
  855. ENET_ADDR_TYPE_GROUP,
  856. ENET_ADDR_TYPE_BROADCAST
  857. };
  858. /* UCC GETH 82xx Ethernet Address Recognition Location */
  859. enum ucc_geth_enet_address_recognition_location {
  860. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station
  861. address */
  862. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional
  863. station
  864. address
  865. paddr1 */
  866. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR2, /* additional
  867. station
  868. address
  869. paddr2 */
  870. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR3, /* additional
  871. station
  872. address
  873. paddr3 */
  874. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_LAST, /* additional
  875. station
  876. address
  877. paddr4 */
  878. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */
  879. UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual
  880. hash */
  881. };
  882. /* UCC GETH vlan operation tagged */
  883. enum ucc_geth_vlan_operation_tagged {
  884. UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */
  885. UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG
  886. = 0x1, /* Tagged - replace vid portion of q tag */
  887. UCC_GETH_VLAN_OPERATION_TAGGED_IF_VID0_REPLACE_VID_WITH_DEFAULT_VALUE
  888. = 0x2, /* Tagged - if vid0 replace vid with default value */
  889. UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME
  890. = 0x3 /* Tagged - extract q tag from frame */
  891. };
  892. /* UCC GETH vlan operation non-tagged */
  893. enum ucc_geth_vlan_operation_non_tagged {
  894. UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */
  895. UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged -
  896. q tag insert
  897. */
  898. };
  899. /* UCC GETH Rx Quality of Service Mode */
  900. enum ucc_geth_qos_mode {
  901. UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */
  902. UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue
  903. determined
  904. by L2
  905. criteria */
  906. UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L3_CRITERIA = 0x2 /* queue
  907. determined
  908. by L3
  909. criteria */
  910. };
  911. /* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together
  912. for combined functionality */
  913. enum ucc_geth_statistics_gathering_mode {
  914. UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No
  915. statistics
  916. gathering */
  917. UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE = 0x00000001,/* Enable
  918. hardware
  919. statistics
  920. gathering
  921. */
  922. UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX = 0x00000004,/*Enable
  923. firmware
  924. tx
  925. statistics
  926. gathering
  927. */
  928. UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX = 0x00000008/* Enable
  929. firmware
  930. rx
  931. statistics
  932. gathering
  933. */
  934. };
  935. /* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */
  936. enum ucc_geth_maccfg2_pad_and_crc_mode {
  937. UCC_GETH_PAD_AND_CRC_MODE_NONE
  938. = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding
  939. short frames
  940. nor CRC */
  941. UCC_GETH_PAD_AND_CRC_MODE_CRC_ONLY
  942. = MACCFG2_PAD_AND_CRC_MODE_CRC_ONLY, /* Append
  943. CRC only */
  944. UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC =
  945. MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC
  946. };
  947. /* UCC GETH upsmr Flow Control Mode */
  948. enum ucc_geth_flow_control_mode {
  949. UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic
  950. flow control
  951. */
  952. UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY
  953. = 0x00004000 /* Send pause frame when RxFIFO reaches its
  954. emergency threshold */
  955. };
  956. /* UCC GETH number of threads */
  957. enum ucc_geth_num_of_threads {
  958. UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */
  959. UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */
  960. UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */
  961. UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */
  962. UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */
  963. };
  964. /* UCC GETH number of station addresses */
  965. enum ucc_geth_num_of_station_addresses {
  966. UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */
  967. UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */
  968. };
  969. /* UCC GETH 82xx Ethernet Address Container */
  970. struct enet_addr_container {
  971. u8 address[ETH_ALEN]; /* ethernet address */
  972. enum ucc_geth_enet_address_recognition_location location; /* location in
  973. 82xx address
  974. recognition
  975. hardware */
  976. struct list_head node;
  977. };
  978. #define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, struct enet_addr_container, node)
  979. /* UCC GETH Termination Action Descriptor (TAD) structure. */
  980. struct ucc_geth_tad_params {
  981. int rx_non_dynamic_extended_features_mode;
  982. int reject_frame;
  983. enum ucc_geth_vlan_operation_tagged vtag_op;
  984. enum ucc_geth_vlan_operation_non_tagged vnontag_op;
  985. enum ucc_geth_qos_mode rqos;
  986. u8 vpri;
  987. u16 vid;
  988. };
  989. /* GETH protocol initialization structure */
  990. struct ucc_geth_info {
  991. struct ucc_fast_info uf_info;
  992. u8 numQueuesTx;
  993. u8 numQueuesRx;
  994. int ipCheckSumCheck;
  995. int ipCheckSumGenerate;
  996. int rxExtendedFiltering;
  997. u32 extendedFilteringChainPointer;
  998. u16 typeorlen;
  999. int dynamicMaxFrameLength;
  1000. int dynamicMinFrameLength;
  1001. u8 nonBackToBackIfgPart1;
  1002. u8 nonBackToBackIfgPart2;
  1003. u8 miminumInterFrameGapEnforcement;
  1004. u8 backToBackInterFrameGap;
  1005. int ipAddressAlignment;
  1006. int lengthCheckRx;
  1007. u32 mblinterval;
  1008. u16 nortsrbytetime;
  1009. u8 fracsiz;
  1010. u8 strictpriorityq;
  1011. u8 txasap;
  1012. u8 extrabw;
  1013. int miiPreambleSupress;
  1014. u8 altBebTruncation;
  1015. int altBeb;
  1016. int backPressureNoBackoff;
  1017. int noBackoff;
  1018. int excessDefer;
  1019. u8 maxRetransmission;
  1020. u8 collisionWindow;
  1021. int pro;
  1022. int cap;
  1023. int rsh;
  1024. int rlpb;
  1025. int cam;
  1026. int bro;
  1027. int ecm;
  1028. int receiveFlowControl;
  1029. int transmitFlowControl;
  1030. u8 maxGroupAddrInHash;
  1031. u8 maxIndAddrInHash;
  1032. u8 prel;
  1033. u16 maxFrameLength;
  1034. u16 minFrameLength;
  1035. u16 maxD1Length;
  1036. u16 maxD2Length;
  1037. u16 vlantype;
  1038. u16 vlantci;
  1039. u32 ecamptr;
  1040. u32 eventRegMask;
  1041. u16 pausePeriod;
  1042. u16 extensionField;
  1043. struct device_node *phy_node;
  1044. struct device_node *tbi_node;
  1045. u8 weightfactor[NUM_TX_QUEUES];
  1046. u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES];
  1047. u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX];
  1048. u8 l3qt[UCC_GETH_IP_PRIORITY_MAX];
  1049. u32 vtagtable[UCC_GETH_TX_VTAG_TABLE_ENTRY_MAX];
  1050. u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
  1051. u16 bdRingLenTx[NUM_TX_QUEUES];
  1052. u16 bdRingLenRx[NUM_RX_QUEUES];
  1053. enum ucc_geth_num_of_station_addresses numStationAddresses;
  1054. enum qe_fltr_largest_external_tbl_lookup_key_size
  1055. largestexternallookupkeysize;
  1056. enum ucc_geth_statistics_gathering_mode statisticsMode;
  1057. enum ucc_geth_vlan_operation_tagged vlanOperationTagged;
  1058. enum ucc_geth_vlan_operation_non_tagged vlanOperationNonTagged;
  1059. enum ucc_geth_qos_mode rxQoSMode;
  1060. enum ucc_geth_flow_control_mode aufc;
  1061. enum ucc_geth_maccfg2_pad_and_crc_mode padAndCrc;
  1062. enum ucc_geth_num_of_threads numThreadsTx;
  1063. enum ucc_geth_num_of_threads numThreadsRx;
  1064. unsigned int riscTx;
  1065. unsigned int riscRx;
  1066. };
  1067. /* structure representing UCC GETH */
  1068. struct ucc_geth_private {
  1069. struct ucc_geth_info *ug_info;
  1070. struct ucc_fast_private *uccf;
  1071. struct device *dev;
  1072. struct net_device *ndev;
  1073. struct napi_struct napi;
  1074. struct work_struct timeout_work;
  1075. struct ucc_geth __iomem *ug_regs;
  1076. struct ucc_geth_init_pram *p_init_enet_param_shadow;
  1077. struct ucc_geth_exf_global_pram __iomem *p_exf_glbl_param;
  1078. u32 exf_glbl_param_offset;
  1079. struct ucc_geth_rx_global_pram __iomem *p_rx_glbl_pram;
  1080. u32 rx_glbl_pram_offset;
  1081. struct ucc_geth_tx_global_pram __iomem *p_tx_glbl_pram;
  1082. u32 tx_glbl_pram_offset;
  1083. struct ucc_geth_send_queue_mem_region __iomem *p_send_q_mem_reg;
  1084. u32 send_q_mem_reg_offset;
  1085. struct ucc_geth_thread_data_tx __iomem *p_thread_data_tx;
  1086. u32 thread_dat_tx_offset;
  1087. struct ucc_geth_thread_data_rx __iomem *p_thread_data_rx;
  1088. u32 thread_dat_rx_offset;
  1089. struct ucc_geth_scheduler __iomem *p_scheduler;
  1090. u32 scheduler_offset;
  1091. struct ucc_geth_tx_firmware_statistics_pram __iomem *p_tx_fw_statistics_pram;
  1092. u32 tx_fw_statistics_pram_offset;
  1093. struct ucc_geth_rx_firmware_statistics_pram __iomem *p_rx_fw_statistics_pram;
  1094. u32 rx_fw_statistics_pram_offset;
  1095. struct ucc_geth_rx_interrupt_coalescing_table __iomem *p_rx_irq_coalescing_tbl;
  1096. u32 rx_irq_coalescing_tbl_offset;
  1097. struct ucc_geth_rx_bd_queues_entry __iomem *p_rx_bd_qs_tbl;
  1098. u32 rx_bd_qs_tbl_offset;
  1099. u8 __iomem *p_tx_bd_ring[NUM_TX_QUEUES];
  1100. u32 tx_bd_ring_offset[NUM_TX_QUEUES];
  1101. u8 __iomem *p_rx_bd_ring[NUM_RX_QUEUES];
  1102. u32 rx_bd_ring_offset[NUM_RX_QUEUES];
  1103. u8 __iomem *confBd[NUM_TX_QUEUES];
  1104. u8 __iomem *txBd[NUM_TX_QUEUES];
  1105. u8 __iomem *rxBd[NUM_RX_QUEUES];
  1106. int badFrame[NUM_RX_QUEUES];
  1107. u16 cpucount[NUM_TX_QUEUES];
  1108. u16 __iomem *p_cpucount[NUM_TX_QUEUES];
  1109. int indAddrRegUsed[NUM_OF_PADDRS];
  1110. u8 paddr[NUM_OF_PADDRS][ETH_ALEN]; /* ethernet address */
  1111. u8 numGroupAddrInHash;
  1112. u8 numIndAddrInHash;
  1113. u8 numIndAddrInReg;
  1114. int rx_extended_features;
  1115. int rx_non_dynamic_extended_features;
  1116. struct list_head conf_skbs;
  1117. struct list_head group_hash_q;
  1118. struct list_head ind_hash_q;
  1119. u32 saved_uccm;
  1120. spinlock_t lock;
  1121. /* pointers to arrays of skbuffs for tx and rx */
  1122. struct sk_buff **tx_skbuff[NUM_TX_QUEUES];
  1123. struct sk_buff **rx_skbuff[NUM_RX_QUEUES];
  1124. /* indices pointing to the next free sbk in skb arrays */
  1125. u16 skb_curtx[NUM_TX_QUEUES];
  1126. u16 skb_currx[NUM_RX_QUEUES];
  1127. /* index of the first skb which hasn't been transmitted yet. */
  1128. u16 skb_dirtytx[NUM_TX_QUEUES];
  1129. struct ugeth_mii_info *mii_info;
  1130. struct phy_device *phydev;
  1131. phy_interface_t phy_interface;
  1132. int max_speed;
  1133. uint32_t msg_enable;
  1134. int oldspeed;
  1135. int oldduplex;
  1136. int oldlink;
  1137. int wol_en;
  1138. struct device_node *node;
  1139. };
  1140. void uec_set_ethtool_ops(struct net_device *netdev);
  1141. int init_flow_control_params(u32 automatic_flow_control_mode,
  1142. int rx_flow_control_enable, int tx_flow_control_enable,
  1143. u16 pause_period, u16 extension_field,
  1144. u32 __iomem *upsmr_register, u32 __iomem *uempr_register,
  1145. u32 __iomem *maccfg1_register);
  1146. #endif /* __UCC_GETH_H__ */