ucc_geth.h 44 KB

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