ucc_geth.h 46 KB

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