ucc_geth.h 46 KB

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