ucc_geth.h 47 KB

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