ucc_geth.h 47 KB

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