ucc_geth.h 45 KB

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