gianfar.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. /*
  2. * drivers/net/ethernet/freescale/gianfar.h
  3. *
  4. * Gianfar Ethernet Driver
  5. * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
  6. * Based on 8260_io/fcc_enet.c
  7. *
  8. * Author: Andy Fleming
  9. * Maintainer: Kumar Gala
  10. * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com>
  11. *
  12. * Copyright 2002-2009, 2011 Freescale Semiconductor, Inc.
  13. *
  14. * This program is free software; you can redistribute it and/or modify it
  15. * under the terms of the GNU General Public License as published by the
  16. * Free Software Foundation; either version 2 of the License, or (at your
  17. * option) any later version.
  18. *
  19. * Still left to do:
  20. * -Add support for module parameters
  21. * -Add patch for ethtool phys id
  22. */
  23. #ifndef __GIANFAR_H
  24. #define __GIANFAR_H
  25. #include <linux/kernel.h>
  26. #include <linux/sched.h>
  27. #include <linux/string.h>
  28. #include <linux/errno.h>
  29. #include <linux/slab.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/init.h>
  32. #include <linux/delay.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/etherdevice.h>
  35. #include <linux/skbuff.h>
  36. #include <linux/spinlock.h>
  37. #include <linux/mm.h>
  38. #include <linux/mii.h>
  39. #include <linux/phy.h>
  40. #include <asm/io.h>
  41. #include <asm/irq.h>
  42. #include <asm/uaccess.h>
  43. #include <linux/module.h>
  44. #include <linux/crc32.h>
  45. #include <linux/workqueue.h>
  46. #include <linux/ethtool.h>
  47. struct ethtool_flow_spec_container {
  48. struct ethtool_rx_flow_spec fs;
  49. struct list_head list;
  50. };
  51. struct ethtool_rx_list {
  52. struct list_head list;
  53. unsigned int count;
  54. };
  55. /* The maximum number of packets to be handled in one call of gfar_poll */
  56. #define GFAR_DEV_WEIGHT 64
  57. /* Length for FCB */
  58. #define GMAC_FCB_LEN 8
  59. /* Length for TxPAL */
  60. #define GMAC_TXPAL_LEN 16
  61. /* Default padding amount */
  62. #define DEFAULT_PADDING 2
  63. /* Number of bytes to align the rx bufs to */
  64. #define RXBUF_ALIGNMENT 64
  65. /* The number of bytes which composes a unit for the purpose of
  66. * allocating data buffers. ie-for any given MTU, the data buffer
  67. * will be the next highest multiple of 512 bytes. */
  68. #define INCREMENTAL_BUFFER_SIZE 512
  69. #define PHY_INIT_TIMEOUT 100000
  70. #define DRV_NAME "gfar-enet"
  71. extern const char gfar_driver_version[];
  72. /* MAXIMUM NUMBER OF QUEUES SUPPORTED */
  73. #define MAX_TX_QS 0x8
  74. #define MAX_RX_QS 0x8
  75. /* MAXIMUM NUMBER OF GROUPS SUPPORTED */
  76. #define MAXGROUPS 0x2
  77. /* These need to be powers of 2 for this driver */
  78. #define DEFAULT_TX_RING_SIZE 256
  79. #define DEFAULT_RX_RING_SIZE 256
  80. #define GFAR_RX_MAX_RING_SIZE 256
  81. #define GFAR_TX_MAX_RING_SIZE 256
  82. #define GFAR_MAX_FIFO_THRESHOLD 511
  83. #define GFAR_MAX_FIFO_STARVE 511
  84. #define GFAR_MAX_FIFO_STARVE_OFF 511
  85. #define DEFAULT_RX_BUFFER_SIZE 1536
  86. #define TX_RING_MOD_MASK(size) (size-1)
  87. #define RX_RING_MOD_MASK(size) (size-1)
  88. #define JUMBO_BUFFER_SIZE 9728
  89. #define JUMBO_FRAME_SIZE 9600
  90. #define DEFAULT_FIFO_TX_THR 0x100
  91. #define DEFAULT_FIFO_TX_STARVE 0x40
  92. #define DEFAULT_FIFO_TX_STARVE_OFF 0x80
  93. #define DEFAULT_BD_STASH 1
  94. #define DEFAULT_STASH_LENGTH 96
  95. #define DEFAULT_STASH_INDEX 0
  96. /* The number of Exact Match registers */
  97. #define GFAR_EM_NUM 15
  98. /* Latency of interface clock in nanoseconds */
  99. /* Interface clock latency , in this case, means the
  100. * time described by a value of 1 in the interrupt
  101. * coalescing registers' time fields. Since those fields
  102. * refer to the time it takes for 64 clocks to pass, the
  103. * latencies are as such:
  104. * GBIT = 125MHz => 8ns/clock => 8*64 ns / tick
  105. * 100 = 25 MHz => 40ns/clock => 40*64 ns / tick
  106. * 10 = 2.5 MHz => 400ns/clock => 400*64 ns / tick
  107. */
  108. #define GFAR_GBIT_TIME 512
  109. #define GFAR_100_TIME 2560
  110. #define GFAR_10_TIME 25600
  111. #define DEFAULT_TX_COALESCE 1
  112. #define DEFAULT_TXCOUNT 16
  113. #define DEFAULT_TXTIME 21
  114. #define DEFAULT_RXTIME 21
  115. #define DEFAULT_RX_COALESCE 0
  116. #define DEFAULT_RXCOUNT 0
  117. #define GFAR_SUPPORTED (SUPPORTED_10baseT_Half \
  118. | SUPPORTED_10baseT_Full \
  119. | SUPPORTED_100baseT_Half \
  120. | SUPPORTED_100baseT_Full \
  121. | SUPPORTED_Autoneg \
  122. | SUPPORTED_MII)
  123. /* TBI register addresses */
  124. #define MII_TBICON 0x11
  125. /* TBICON register bit fields */
  126. #define TBICON_CLK_SELECT 0x0020
  127. /* MAC register bits */
  128. #define MACCFG1_SOFT_RESET 0x80000000
  129. #define MACCFG1_RESET_RX_MC 0x00080000
  130. #define MACCFG1_RESET_TX_MC 0x00040000
  131. #define MACCFG1_RESET_RX_FUN 0x00020000
  132. #define MACCFG1_RESET_TX_FUN 0x00010000
  133. #define MACCFG1_LOOPBACK 0x00000100
  134. #define MACCFG1_RX_FLOW 0x00000020
  135. #define MACCFG1_TX_FLOW 0x00000010
  136. #define MACCFG1_SYNCD_RX_EN 0x00000008
  137. #define MACCFG1_RX_EN 0x00000004
  138. #define MACCFG1_SYNCD_TX_EN 0x00000002
  139. #define MACCFG1_TX_EN 0x00000001
  140. #define MACCFG2_INIT_SETTINGS 0x00007205
  141. #define MACCFG2_FULL_DUPLEX 0x00000001
  142. #define MACCFG2_IF 0x00000300
  143. #define MACCFG2_MII 0x00000100
  144. #define MACCFG2_GMII 0x00000200
  145. #define MACCFG2_HUGEFRAME 0x00000020
  146. #define MACCFG2_LENGTHCHECK 0x00000010
  147. #define MACCFG2_MPEN 0x00000008
  148. #define ECNTRL_FIFM 0x00008000
  149. #define ECNTRL_INIT_SETTINGS 0x00001000
  150. #define ECNTRL_TBI_MODE 0x00000020
  151. #define ECNTRL_REDUCED_MODE 0x00000010
  152. #define ECNTRL_R100 0x00000008
  153. #define ECNTRL_REDUCED_MII_MODE 0x00000004
  154. #define ECNTRL_SGMII_MODE 0x00000002
  155. #define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE
  156. #define MINFLR_INIT_SETTINGS 0x00000040
  157. /* Tqueue control */
  158. #define TQUEUE_EN0 0x00008000
  159. #define TQUEUE_EN1 0x00004000
  160. #define TQUEUE_EN2 0x00002000
  161. #define TQUEUE_EN3 0x00001000
  162. #define TQUEUE_EN4 0x00000800
  163. #define TQUEUE_EN5 0x00000400
  164. #define TQUEUE_EN6 0x00000200
  165. #define TQUEUE_EN7 0x00000100
  166. #define TQUEUE_EN_ALL 0x0000FF00
  167. #define TR03WT_WT0_MASK 0xFF000000
  168. #define TR03WT_WT1_MASK 0x00FF0000
  169. #define TR03WT_WT2_MASK 0x0000FF00
  170. #define TR03WT_WT3_MASK 0x000000FF
  171. #define TR47WT_WT4_MASK 0xFF000000
  172. #define TR47WT_WT5_MASK 0x00FF0000
  173. #define TR47WT_WT6_MASK 0x0000FF00
  174. #define TR47WT_WT7_MASK 0x000000FF
  175. /* Rqueue control */
  176. #define RQUEUE_EX0 0x00800000
  177. #define RQUEUE_EX1 0x00400000
  178. #define RQUEUE_EX2 0x00200000
  179. #define RQUEUE_EX3 0x00100000
  180. #define RQUEUE_EX4 0x00080000
  181. #define RQUEUE_EX5 0x00040000
  182. #define RQUEUE_EX6 0x00020000
  183. #define RQUEUE_EX7 0x00010000
  184. #define RQUEUE_EX_ALL 0x00FF0000
  185. #define RQUEUE_EN0 0x00000080
  186. #define RQUEUE_EN1 0x00000040
  187. #define RQUEUE_EN2 0x00000020
  188. #define RQUEUE_EN3 0x00000010
  189. #define RQUEUE_EN4 0x00000008
  190. #define RQUEUE_EN5 0x00000004
  191. #define RQUEUE_EN6 0x00000002
  192. #define RQUEUE_EN7 0x00000001
  193. #define RQUEUE_EN_ALL 0x000000FF
  194. /* Init to do tx snooping for buffers and descriptors */
  195. #define DMACTRL_INIT_SETTINGS 0x000000c3
  196. #define DMACTRL_GRS 0x00000010
  197. #define DMACTRL_GTS 0x00000008
  198. #define TSTAT_CLEAR_THALT_ALL 0xFF000000
  199. #define TSTAT_CLEAR_THALT 0x80000000
  200. #define TSTAT_CLEAR_THALT0 0x80000000
  201. #define TSTAT_CLEAR_THALT1 0x40000000
  202. #define TSTAT_CLEAR_THALT2 0x20000000
  203. #define TSTAT_CLEAR_THALT3 0x10000000
  204. #define TSTAT_CLEAR_THALT4 0x08000000
  205. #define TSTAT_CLEAR_THALT5 0x04000000
  206. #define TSTAT_CLEAR_THALT6 0x02000000
  207. #define TSTAT_CLEAR_THALT7 0x01000000
  208. /* Interrupt coalescing macros */
  209. #define IC_ICEN 0x80000000
  210. #define IC_ICFT_MASK 0x1fe00000
  211. #define IC_ICFT_SHIFT 21
  212. #define mk_ic_icft(x) \
  213. (((unsigned int)x << IC_ICFT_SHIFT)&IC_ICFT_MASK)
  214. #define IC_ICTT_MASK 0x0000ffff
  215. #define mk_ic_ictt(x) (x&IC_ICTT_MASK)
  216. #define mk_ic_value(count, time) (IC_ICEN | \
  217. mk_ic_icft(count) | \
  218. mk_ic_ictt(time))
  219. #define get_icft_value(ic) (((unsigned long)ic & IC_ICFT_MASK) >> \
  220. IC_ICFT_SHIFT)
  221. #define get_ictt_value(ic) ((unsigned long)ic & IC_ICTT_MASK)
  222. #define DEFAULT_TXIC mk_ic_value(DEFAULT_TXCOUNT, DEFAULT_TXTIME)
  223. #define DEFAULT_RXIC mk_ic_value(DEFAULT_RXCOUNT, DEFAULT_RXTIME)
  224. #define skip_bd(bdp, stride, base, ring_size) ({ \
  225. typeof(bdp) new_bd = (bdp) + (stride); \
  226. (new_bd >= (base) + (ring_size)) ? (new_bd - (ring_size)) : new_bd; })
  227. #define next_bd(bdp, base, ring_size) skip_bd(bdp, 1, base, ring_size)
  228. #define RCTRL_TS_ENABLE 0x01000000
  229. #define RCTRL_PAL_MASK 0x001f0000
  230. #define RCTRL_VLEX 0x00002000
  231. #define RCTRL_FILREN 0x00001000
  232. #define RCTRL_GHTX 0x00000400
  233. #define RCTRL_IPCSEN 0x00000200
  234. #define RCTRL_TUCSEN 0x00000100
  235. #define RCTRL_PRSDEP_MASK 0x000000c0
  236. #define RCTRL_PRSDEP_INIT 0x000000c0
  237. #define RCTRL_PRSFM 0x00000020
  238. #define RCTRL_PROM 0x00000008
  239. #define RCTRL_EMEN 0x00000002
  240. #define RCTRL_REQ_PARSER (RCTRL_VLEX | RCTRL_IPCSEN | \
  241. RCTRL_TUCSEN | RCTRL_FILREN)
  242. #define RCTRL_CHECKSUMMING (RCTRL_IPCSEN | RCTRL_TUCSEN | \
  243. RCTRL_PRSDEP_INIT)
  244. #define RCTRL_EXTHASH (RCTRL_GHTX)
  245. #define RCTRL_VLAN (RCTRL_PRSDEP_INIT)
  246. #define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK)
  247. #define RSTAT_CLEAR_RHALT 0x00800000
  248. #define TCTRL_IPCSEN 0x00004000
  249. #define TCTRL_TUCSEN 0x00002000
  250. #define TCTRL_VLINS 0x00001000
  251. #define TCTRL_THDF 0x00000800
  252. #define TCTRL_RFCPAUSE 0x00000010
  253. #define TCTRL_TFCPAUSE 0x00000008
  254. #define TCTRL_TXSCHED_MASK 0x00000006
  255. #define TCTRL_TXSCHED_INIT 0x00000000
  256. /* priority scheduling */
  257. #define TCTRL_TXSCHED_PRIO 0x00000002
  258. /* weighted round-robin scheduling (WRRS) */
  259. #define TCTRL_TXSCHED_WRRS 0x00000004
  260. /* default WRRS weight and policy setting,
  261. * tailored to the tr03wt and tr47wt registers:
  262. * equal weight for all Tx Qs, measured in 64byte units
  263. */
  264. #define DEFAULT_WRRS_WEIGHT 0x18181818
  265. #define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN)
  266. #define IEVENT_INIT_CLEAR 0xffffffff
  267. #define IEVENT_BABR 0x80000000
  268. #define IEVENT_RXC 0x40000000
  269. #define IEVENT_BSY 0x20000000
  270. #define IEVENT_EBERR 0x10000000
  271. #define IEVENT_MSRO 0x04000000
  272. #define IEVENT_GTSC 0x02000000
  273. #define IEVENT_BABT 0x01000000
  274. #define IEVENT_TXC 0x00800000
  275. #define IEVENT_TXE 0x00400000
  276. #define IEVENT_TXB 0x00200000
  277. #define IEVENT_TXF 0x00100000
  278. #define IEVENT_LC 0x00040000
  279. #define IEVENT_CRL 0x00020000
  280. #define IEVENT_XFUN 0x00010000
  281. #define IEVENT_RXB0 0x00008000
  282. #define IEVENT_MAG 0x00000800
  283. #define IEVENT_GRSC 0x00000100
  284. #define IEVENT_RXF0 0x00000080
  285. #define IEVENT_FIR 0x00000008
  286. #define IEVENT_FIQ 0x00000004
  287. #define IEVENT_DPE 0x00000002
  288. #define IEVENT_PERR 0x00000001
  289. #define IEVENT_RX_MASK (IEVENT_RXB0 | IEVENT_RXF0 | IEVENT_BSY)
  290. #define IEVENT_TX_MASK (IEVENT_TXB | IEVENT_TXF)
  291. #define IEVENT_RTX_MASK (IEVENT_RX_MASK | IEVENT_TX_MASK)
  292. #define IEVENT_ERR_MASK \
  293. (IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \
  294. IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \
  295. | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR \
  296. | IEVENT_MAG | IEVENT_BABR)
  297. #define IMASK_INIT_CLEAR 0x00000000
  298. #define IMASK_BABR 0x80000000
  299. #define IMASK_RXC 0x40000000
  300. #define IMASK_BSY 0x20000000
  301. #define IMASK_EBERR 0x10000000
  302. #define IMASK_MSRO 0x04000000
  303. #define IMASK_GTSC 0x02000000
  304. #define IMASK_BABT 0x01000000
  305. #define IMASK_TXC 0x00800000
  306. #define IMASK_TXEEN 0x00400000
  307. #define IMASK_TXBEN 0x00200000
  308. #define IMASK_TXFEN 0x00100000
  309. #define IMASK_LC 0x00040000
  310. #define IMASK_CRL 0x00020000
  311. #define IMASK_XFUN 0x00010000
  312. #define IMASK_RXB0 0x00008000
  313. #define IMASK_MAG 0x00000800
  314. #define IMASK_GRSC 0x00000100
  315. #define IMASK_RXFEN0 0x00000080
  316. #define IMASK_FIR 0x00000008
  317. #define IMASK_FIQ 0x00000004
  318. #define IMASK_DPE 0x00000002
  319. #define IMASK_PERR 0x00000001
  320. #define IMASK_DEFAULT (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \
  321. IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \
  322. IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \
  323. | IMASK_PERR)
  324. #define IMASK_RTX_DISABLED ((~(IMASK_RXFEN0 | IMASK_TXFEN | IMASK_BSY)) \
  325. & IMASK_DEFAULT)
  326. /* Fifo management */
  327. #define FIFO_TX_THR_MASK 0x01ff
  328. #define FIFO_TX_STARVE_MASK 0x01ff
  329. #define FIFO_TX_STARVE_OFF_MASK 0x01ff
  330. /* Attribute fields */
  331. /* This enables rx snooping for buffers and descriptors */
  332. #define ATTR_BDSTASH 0x00000800
  333. #define ATTR_BUFSTASH 0x00004000
  334. #define ATTR_SNOOPING 0x000000c0
  335. #define ATTR_INIT_SETTINGS ATTR_SNOOPING
  336. #define ATTRELI_INIT_SETTINGS 0x0
  337. #define ATTRELI_EL_MASK 0x3fff0000
  338. #define ATTRELI_EL(x) (x << 16)
  339. #define ATTRELI_EI_MASK 0x00003fff
  340. #define ATTRELI_EI(x) (x)
  341. #define BD_LFLAG(flags) ((flags) << 16)
  342. #define BD_LENGTH_MASK 0x0000ffff
  343. #define FPR_FILER_MASK 0xFFFFFFFF
  344. #define MAX_FILER_IDX 0xFF
  345. /* This default RIR value directly corresponds
  346. * to the 3-bit hash value generated */
  347. #define DEFAULT_RIR0 0x05397700
  348. /* RQFCR register bits */
  349. #define RQFCR_GPI 0x80000000
  350. #define RQFCR_HASHTBL_Q 0x00000000
  351. #define RQFCR_HASHTBL_0 0x00020000
  352. #define RQFCR_HASHTBL_1 0x00040000
  353. #define RQFCR_HASHTBL_2 0x00060000
  354. #define RQFCR_HASHTBL_3 0x00080000
  355. #define RQFCR_HASH 0x00010000
  356. #define RQFCR_QUEUE 0x0000FC00
  357. #define RQFCR_CLE 0x00000200
  358. #define RQFCR_RJE 0x00000100
  359. #define RQFCR_AND 0x00000080
  360. #define RQFCR_CMP_EXACT 0x00000000
  361. #define RQFCR_CMP_MATCH 0x00000020
  362. #define RQFCR_CMP_NOEXACT 0x00000040
  363. #define RQFCR_CMP_NOMATCH 0x00000060
  364. /* RQFCR PID values */
  365. #define RQFCR_PID_MASK 0x00000000
  366. #define RQFCR_PID_PARSE 0x00000001
  367. #define RQFCR_PID_ARB 0x00000002
  368. #define RQFCR_PID_DAH 0x00000003
  369. #define RQFCR_PID_DAL 0x00000004
  370. #define RQFCR_PID_SAH 0x00000005
  371. #define RQFCR_PID_SAL 0x00000006
  372. #define RQFCR_PID_ETY 0x00000007
  373. #define RQFCR_PID_VID 0x00000008
  374. #define RQFCR_PID_PRI 0x00000009
  375. #define RQFCR_PID_TOS 0x0000000A
  376. #define RQFCR_PID_L4P 0x0000000B
  377. #define RQFCR_PID_DIA 0x0000000C
  378. #define RQFCR_PID_SIA 0x0000000D
  379. #define RQFCR_PID_DPT 0x0000000E
  380. #define RQFCR_PID_SPT 0x0000000F
  381. /* RQFPR when PID is 0x0001 */
  382. #define RQFPR_HDR_GE_512 0x00200000
  383. #define RQFPR_LERR 0x00100000
  384. #define RQFPR_RAR 0x00080000
  385. #define RQFPR_RARQ 0x00040000
  386. #define RQFPR_AR 0x00020000
  387. #define RQFPR_ARQ 0x00010000
  388. #define RQFPR_EBC 0x00008000
  389. #define RQFPR_VLN 0x00004000
  390. #define RQFPR_CFI 0x00002000
  391. #define RQFPR_JUM 0x00001000
  392. #define RQFPR_IPF 0x00000800
  393. #define RQFPR_FIF 0x00000400
  394. #define RQFPR_IPV4 0x00000200
  395. #define RQFPR_IPV6 0x00000100
  396. #define RQFPR_ICC 0x00000080
  397. #define RQFPR_ICV 0x00000040
  398. #define RQFPR_TCP 0x00000020
  399. #define RQFPR_UDP 0x00000010
  400. #define RQFPR_TUC 0x00000008
  401. #define RQFPR_TUV 0x00000004
  402. #define RQFPR_PER 0x00000002
  403. #define RQFPR_EER 0x00000001
  404. /* TxBD status field bits */
  405. #define TXBD_READY 0x8000
  406. #define TXBD_PADCRC 0x4000
  407. #define TXBD_WRAP 0x2000
  408. #define TXBD_INTERRUPT 0x1000
  409. #define TXBD_LAST 0x0800
  410. #define TXBD_CRC 0x0400
  411. #define TXBD_DEF 0x0200
  412. #define TXBD_HUGEFRAME 0x0080
  413. #define TXBD_LATECOLLISION 0x0080
  414. #define TXBD_RETRYLIMIT 0x0040
  415. #define TXBD_RETRYCOUNTMASK 0x003c
  416. #define TXBD_UNDERRUN 0x0002
  417. #define TXBD_TOE 0x0002
  418. /* Tx FCB param bits */
  419. #define TXFCB_VLN 0x80
  420. #define TXFCB_IP 0x40
  421. #define TXFCB_IP6 0x20
  422. #define TXFCB_TUP 0x10
  423. #define TXFCB_UDP 0x08
  424. #define TXFCB_CIP 0x04
  425. #define TXFCB_CTU 0x02
  426. #define TXFCB_NPH 0x01
  427. #define TXFCB_DEFAULT (TXFCB_IP|TXFCB_TUP|TXFCB_CTU|TXFCB_NPH)
  428. /* RxBD status field bits */
  429. #define RXBD_EMPTY 0x8000
  430. #define RXBD_RO1 0x4000
  431. #define RXBD_WRAP 0x2000
  432. #define RXBD_INTERRUPT 0x1000
  433. #define RXBD_LAST 0x0800
  434. #define RXBD_FIRST 0x0400
  435. #define RXBD_MISS 0x0100
  436. #define RXBD_BROADCAST 0x0080
  437. #define RXBD_MULTICAST 0x0040
  438. #define RXBD_LARGE 0x0020
  439. #define RXBD_NONOCTET 0x0010
  440. #define RXBD_SHORT 0x0008
  441. #define RXBD_CRCERR 0x0004
  442. #define RXBD_OVERRUN 0x0002
  443. #define RXBD_TRUNCATED 0x0001
  444. #define RXBD_STATS 0x01ff
  445. #define RXBD_ERR (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET \
  446. | RXBD_CRCERR | RXBD_OVERRUN \
  447. | RXBD_TRUNCATED)
  448. /* Rx FCB status field bits */
  449. #define RXFCB_VLN 0x8000
  450. #define RXFCB_IP 0x4000
  451. #define RXFCB_IP6 0x2000
  452. #define RXFCB_TUP 0x1000
  453. #define RXFCB_CIP 0x0800
  454. #define RXFCB_CTU 0x0400
  455. #define RXFCB_EIP 0x0200
  456. #define RXFCB_ETU 0x0100
  457. #define RXFCB_CSUM_MASK 0x0f00
  458. #define RXFCB_PERR_MASK 0x000c
  459. #define RXFCB_PERR_BADL3 0x0008
  460. #define GFAR_INT_NAME_MAX (IFNAMSIZ + 6) /* '_g#_xx' */
  461. struct txbd8
  462. {
  463. union {
  464. struct {
  465. u16 status; /* Status Fields */
  466. u16 length; /* Buffer length */
  467. };
  468. u32 lstatus;
  469. };
  470. u32 bufPtr; /* Buffer Pointer */
  471. };
  472. struct txfcb {
  473. u8 flags;
  474. u8 ptp; /* Flag to enable tx timestamping */
  475. u8 l4os; /* Level 4 Header Offset */
  476. u8 l3os; /* Level 3 Header Offset */
  477. u16 phcs; /* Pseudo-header Checksum */
  478. u16 vlctl; /* VLAN control word */
  479. };
  480. struct rxbd8
  481. {
  482. union {
  483. struct {
  484. u16 status; /* Status Fields */
  485. u16 length; /* Buffer Length */
  486. };
  487. u32 lstatus;
  488. };
  489. u32 bufPtr; /* Buffer Pointer */
  490. };
  491. struct rxfcb {
  492. u16 flags;
  493. u8 rq; /* Receive Queue index */
  494. u8 pro; /* Layer 4 Protocol */
  495. u16 reserved;
  496. u16 vlctl; /* VLAN control word */
  497. };
  498. struct gianfar_skb_cb {
  499. int alignamount;
  500. };
  501. #define GFAR_CB(skb) ((struct gianfar_skb_cb *)((skb)->cb))
  502. struct rmon_mib
  503. {
  504. u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */
  505. u32 tr127; /* 0x.684 - Transmit and Receive 65-127 byte Frame Counter */
  506. u32 tr255; /* 0x.688 - Transmit and Receive 128-255 byte Frame Counter */
  507. u32 tr511; /* 0x.68c - Transmit and Receive 256-511 byte Frame Counter */
  508. u32 tr1k; /* 0x.690 - Transmit and Receive 512-1023 byte Frame Counter */
  509. u32 trmax; /* 0x.694 - Transmit and Receive 1024-1518 byte Frame Counter */
  510. u32 trmgv; /* 0x.698 - Transmit and Receive 1519-1522 byte Good VLAN Frame */
  511. u32 rbyt; /* 0x.69c - Receive Byte Counter */
  512. u32 rpkt; /* 0x.6a0 - Receive Packet Counter */
  513. u32 rfcs; /* 0x.6a4 - Receive FCS Error Counter */
  514. u32 rmca; /* 0x.6a8 - Receive Multicast Packet Counter */
  515. u32 rbca; /* 0x.6ac - Receive Broadcast Packet Counter */
  516. u32 rxcf; /* 0x.6b0 - Receive Control Frame Packet Counter */
  517. u32 rxpf; /* 0x.6b4 - Receive Pause Frame Packet Counter */
  518. u32 rxuo; /* 0x.6b8 - Receive Unknown OP Code Counter */
  519. u32 raln; /* 0x.6bc - Receive Alignment Error Counter */
  520. u32 rflr; /* 0x.6c0 - Receive Frame Length Error Counter */
  521. u32 rcde; /* 0x.6c4 - Receive Code Error Counter */
  522. u32 rcse; /* 0x.6c8 - Receive Carrier Sense Error Counter */
  523. u32 rund; /* 0x.6cc - Receive Undersize Packet Counter */
  524. u32 rovr; /* 0x.6d0 - Receive Oversize Packet Counter */
  525. u32 rfrg; /* 0x.6d4 - Receive Fragments Counter */
  526. u32 rjbr; /* 0x.6d8 - Receive Jabber Counter */
  527. u32 rdrp; /* 0x.6dc - Receive Drop Counter */
  528. u32 tbyt; /* 0x.6e0 - Transmit Byte Counter Counter */
  529. u32 tpkt; /* 0x.6e4 - Transmit Packet Counter */
  530. u32 tmca; /* 0x.6e8 - Transmit Multicast Packet Counter */
  531. u32 tbca; /* 0x.6ec - Transmit Broadcast Packet Counter */
  532. u32 txpf; /* 0x.6f0 - Transmit Pause Control Frame Counter */
  533. u32 tdfr; /* 0x.6f4 - Transmit Deferral Packet Counter */
  534. u32 tedf; /* 0x.6f8 - Transmit Excessive Deferral Packet Counter */
  535. u32 tscl; /* 0x.6fc - Transmit Single Collision Packet Counter */
  536. u32 tmcl; /* 0x.700 - Transmit Multiple Collision Packet Counter */
  537. u32 tlcl; /* 0x.704 - Transmit Late Collision Packet Counter */
  538. u32 txcl; /* 0x.708 - Transmit Excessive Collision Packet Counter */
  539. u32 tncl; /* 0x.70c - Transmit Total Collision Counter */
  540. u8 res1[4];
  541. u32 tdrp; /* 0x.714 - Transmit Drop Frame Counter */
  542. u32 tjbr; /* 0x.718 - Transmit Jabber Frame Counter */
  543. u32 tfcs; /* 0x.71c - Transmit FCS Error Counter */
  544. u32 txcf; /* 0x.720 - Transmit Control Frame Counter */
  545. u32 tovr; /* 0x.724 - Transmit Oversize Frame Counter */
  546. u32 tund; /* 0x.728 - Transmit Undersize Frame Counter */
  547. u32 tfrg; /* 0x.72c - Transmit Fragments Frame Counter */
  548. u32 car1; /* 0x.730 - Carry Register One */
  549. u32 car2; /* 0x.734 - Carry Register Two */
  550. u32 cam1; /* 0x.738 - Carry Mask Register One */
  551. u32 cam2; /* 0x.73c - Carry Mask Register Two */
  552. };
  553. struct gfar_extra_stats {
  554. u64 kernel_dropped;
  555. u64 rx_large;
  556. u64 rx_short;
  557. u64 rx_nonoctet;
  558. u64 rx_crcerr;
  559. u64 rx_overrun;
  560. u64 rx_bsy;
  561. u64 rx_babr;
  562. u64 rx_trunc;
  563. u64 eberr;
  564. u64 tx_babt;
  565. u64 tx_underrun;
  566. u64 rx_skbmissing;
  567. u64 tx_timeout;
  568. };
  569. #define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32))
  570. #define GFAR_EXTRA_STATS_LEN (sizeof(struct gfar_extra_stats)/sizeof(u64))
  571. /* Number of stats in the stats structure (ignore car and cam regs)*/
  572. #define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN)
  573. #define GFAR_INFOSTR_LEN 32
  574. struct gfar_stats {
  575. u64 extra[GFAR_EXTRA_STATS_LEN];
  576. u64 rmon[GFAR_RMON_LEN];
  577. };
  578. struct gfar {
  579. u32 tsec_id; /* 0x.000 - Controller ID register */
  580. u32 tsec_id2; /* 0x.004 - Controller ID2 register */
  581. u8 res1[8];
  582. u32 ievent; /* 0x.010 - Interrupt Event Register */
  583. u32 imask; /* 0x.014 - Interrupt Mask Register */
  584. u32 edis; /* 0x.018 - Error Disabled Register */
  585. u32 emapg; /* 0x.01c - Group Error mapping register */
  586. u32 ecntrl; /* 0x.020 - Ethernet Control Register */
  587. u32 minflr; /* 0x.024 - Minimum Frame Length Register */
  588. u32 ptv; /* 0x.028 - Pause Time Value Register */
  589. u32 dmactrl; /* 0x.02c - DMA Control Register */
  590. u32 tbipa; /* 0x.030 - TBI PHY Address Register */
  591. u8 res2[28];
  592. u32 fifo_rx_pause; /* 0x.050 - FIFO receive pause start threshold
  593. register */
  594. u32 fifo_rx_pause_shutoff; /* x.054 - FIFO receive starve shutoff
  595. register */
  596. u32 fifo_rx_alarm; /* 0x.058 - FIFO receive alarm start threshold
  597. register */
  598. u32 fifo_rx_alarm_shutoff; /*0x.05c - FIFO receive alarm starve
  599. shutoff register */
  600. u8 res3[44];
  601. u32 fifo_tx_thr; /* 0x.08c - FIFO transmit threshold register */
  602. u8 res4[8];
  603. u32 fifo_tx_starve; /* 0x.098 - FIFO transmit starve register */
  604. u32 fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */
  605. u8 res5[96];
  606. u32 tctrl; /* 0x.100 - Transmit Control Register */
  607. u32 tstat; /* 0x.104 - Transmit Status Register */
  608. u32 dfvlan; /* 0x.108 - Default VLAN Control word */
  609. u32 tbdlen; /* 0x.10c - Transmit Buffer Descriptor Data Length Register */
  610. u32 txic; /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */
  611. u32 tqueue; /* 0x.114 - Transmit queue control register */
  612. u8 res7[40];
  613. u32 tr03wt; /* 0x.140 - TxBD Rings 0-3 round-robin weightings */
  614. u32 tr47wt; /* 0x.144 - TxBD Rings 4-7 round-robin weightings */
  615. u8 res8[52];
  616. u32 tbdbph; /* 0x.17c - Tx data buffer pointer high */
  617. u8 res9a[4];
  618. u32 tbptr0; /* 0x.184 - TxBD Pointer for ring 0 */
  619. u8 res9b[4];
  620. u32 tbptr1; /* 0x.18c - TxBD Pointer for ring 1 */
  621. u8 res9c[4];
  622. u32 tbptr2; /* 0x.194 - TxBD Pointer for ring 2 */
  623. u8 res9d[4];
  624. u32 tbptr3; /* 0x.19c - TxBD Pointer for ring 3 */
  625. u8 res9e[4];
  626. u32 tbptr4; /* 0x.1a4 - TxBD Pointer for ring 4 */
  627. u8 res9f[4];
  628. u32 tbptr5; /* 0x.1ac - TxBD Pointer for ring 5 */
  629. u8 res9g[4];
  630. u32 tbptr6; /* 0x.1b4 - TxBD Pointer for ring 6 */
  631. u8 res9h[4];
  632. u32 tbptr7; /* 0x.1bc - TxBD Pointer for ring 7 */
  633. u8 res9[64];
  634. u32 tbaseh; /* 0x.200 - TxBD base address high */
  635. u32 tbase0; /* 0x.204 - TxBD Base Address of ring 0 */
  636. u8 res10a[4];
  637. u32 tbase1; /* 0x.20c - TxBD Base Address of ring 1 */
  638. u8 res10b[4];
  639. u32 tbase2; /* 0x.214 - TxBD Base Address of ring 2 */
  640. u8 res10c[4];
  641. u32 tbase3; /* 0x.21c - TxBD Base Address of ring 3 */
  642. u8 res10d[4];
  643. u32 tbase4; /* 0x.224 - TxBD Base Address of ring 4 */
  644. u8 res10e[4];
  645. u32 tbase5; /* 0x.22c - TxBD Base Address of ring 5 */
  646. u8 res10f[4];
  647. u32 tbase6; /* 0x.234 - TxBD Base Address of ring 6 */
  648. u8 res10g[4];
  649. u32 tbase7; /* 0x.23c - TxBD Base Address of ring 7 */
  650. u8 res10[192];
  651. u32 rctrl; /* 0x.300 - Receive Control Register */
  652. u32 rstat; /* 0x.304 - Receive Status Register */
  653. u8 res12[8];
  654. u32 rxic; /* 0x.310 - Receive Interrupt Coalescing Configuration Register */
  655. u32 rqueue; /* 0x.314 - Receive queue control register */
  656. u32 rir0; /* 0x.318 - Ring mapping register 0 */
  657. u32 rir1; /* 0x.31c - Ring mapping register 1 */
  658. u32 rir2; /* 0x.320 - Ring mapping register 2 */
  659. u32 rir3; /* 0x.324 - Ring mapping register 3 */
  660. u8 res13[8];
  661. u32 rbifx; /* 0x.330 - Receive bit field extract control register */
  662. u32 rqfar; /* 0x.334 - Receive queue filing table address register */
  663. u32 rqfcr; /* 0x.338 - Receive queue filing table control register */
  664. u32 rqfpr; /* 0x.33c - Receive queue filing table property register */
  665. u32 mrblr; /* 0x.340 - Maximum Receive Buffer Length Register */
  666. u8 res14[56];
  667. u32 rbdbph; /* 0x.37c - Rx data buffer pointer high */
  668. u8 res15a[4];
  669. u32 rbptr0; /* 0x.384 - RxBD pointer for ring 0 */
  670. u8 res15b[4];
  671. u32 rbptr1; /* 0x.38c - RxBD pointer for ring 1 */
  672. u8 res15c[4];
  673. u32 rbptr2; /* 0x.394 - RxBD pointer for ring 2 */
  674. u8 res15d[4];
  675. u32 rbptr3; /* 0x.39c - RxBD pointer for ring 3 */
  676. u8 res15e[4];
  677. u32 rbptr4; /* 0x.3a4 - RxBD pointer for ring 4 */
  678. u8 res15f[4];
  679. u32 rbptr5; /* 0x.3ac - RxBD pointer for ring 5 */
  680. u8 res15g[4];
  681. u32 rbptr6; /* 0x.3b4 - RxBD pointer for ring 6 */
  682. u8 res15h[4];
  683. u32 rbptr7; /* 0x.3bc - RxBD pointer for ring 7 */
  684. u8 res16[64];
  685. u32 rbaseh; /* 0x.400 - RxBD base address high */
  686. u32 rbase0; /* 0x.404 - RxBD base address of ring 0 */
  687. u8 res17a[4];
  688. u32 rbase1; /* 0x.40c - RxBD base address of ring 1 */
  689. u8 res17b[4];
  690. u32 rbase2; /* 0x.414 - RxBD base address of ring 2 */
  691. u8 res17c[4];
  692. u32 rbase3; /* 0x.41c - RxBD base address of ring 3 */
  693. u8 res17d[4];
  694. u32 rbase4; /* 0x.424 - RxBD base address of ring 4 */
  695. u8 res17e[4];
  696. u32 rbase5; /* 0x.42c - RxBD base address of ring 5 */
  697. u8 res17f[4];
  698. u32 rbase6; /* 0x.434 - RxBD base address of ring 6 */
  699. u8 res17g[4];
  700. u32 rbase7; /* 0x.43c - RxBD base address of ring 7 */
  701. u8 res17[192];
  702. u32 maccfg1; /* 0x.500 - MAC Configuration 1 Register */
  703. u32 maccfg2; /* 0x.504 - MAC Configuration 2 Register */
  704. u32 ipgifg; /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */
  705. u32 hafdup; /* 0x.50c - Half Duplex Register */
  706. u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */
  707. u8 res18[12];
  708. u8 gfar_mii_regs[24]; /* See gianfar_phy.h */
  709. u32 ifctrl; /* 0x.538 - Interface control register */
  710. u32 ifstat; /* 0x.53c - Interface Status Register */
  711. u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */
  712. u32 macstnaddr2; /* 0x.544 - Station Address Part 2 Register */
  713. u32 mac01addr1; /* 0x.548 - MAC exact match address 1, part 1 */
  714. u32 mac01addr2; /* 0x.54c - MAC exact match address 1, part 2 */
  715. u32 mac02addr1; /* 0x.550 - MAC exact match address 2, part 1 */
  716. u32 mac02addr2; /* 0x.554 - MAC exact match address 2, part 2 */
  717. u32 mac03addr1; /* 0x.558 - MAC exact match address 3, part 1 */
  718. u32 mac03addr2; /* 0x.55c - MAC exact match address 3, part 2 */
  719. u32 mac04addr1; /* 0x.560 - MAC exact match address 4, part 1 */
  720. u32 mac04addr2; /* 0x.564 - MAC exact match address 4, part 2 */
  721. u32 mac05addr1; /* 0x.568 - MAC exact match address 5, part 1 */
  722. u32 mac05addr2; /* 0x.56c - MAC exact match address 5, part 2 */
  723. u32 mac06addr1; /* 0x.570 - MAC exact match address 6, part 1 */
  724. u32 mac06addr2; /* 0x.574 - MAC exact match address 6, part 2 */
  725. u32 mac07addr1; /* 0x.578 - MAC exact match address 7, part 1 */
  726. u32 mac07addr2; /* 0x.57c - MAC exact match address 7, part 2 */
  727. u32 mac08addr1; /* 0x.580 - MAC exact match address 8, part 1 */
  728. u32 mac08addr2; /* 0x.584 - MAC exact match address 8, part 2 */
  729. u32 mac09addr1; /* 0x.588 - MAC exact match address 9, part 1 */
  730. u32 mac09addr2; /* 0x.58c - MAC exact match address 9, part 2 */
  731. u32 mac10addr1; /* 0x.590 - MAC exact match address 10, part 1*/
  732. u32 mac10addr2; /* 0x.594 - MAC exact match address 10, part 2*/
  733. u32 mac11addr1; /* 0x.598 - MAC exact match address 11, part 1*/
  734. u32 mac11addr2; /* 0x.59c - MAC exact match address 11, part 2*/
  735. u32 mac12addr1; /* 0x.5a0 - MAC exact match address 12, part 1*/
  736. u32 mac12addr2; /* 0x.5a4 - MAC exact match address 12, part 2*/
  737. u32 mac13addr1; /* 0x.5a8 - MAC exact match address 13, part 1*/
  738. u32 mac13addr2; /* 0x.5ac - MAC exact match address 13, part 2*/
  739. u32 mac14addr1; /* 0x.5b0 - MAC exact match address 14, part 1*/
  740. u32 mac14addr2; /* 0x.5b4 - MAC exact match address 14, part 2*/
  741. u32 mac15addr1; /* 0x.5b8 - MAC exact match address 15, part 1*/
  742. u32 mac15addr2; /* 0x.5bc - MAC exact match address 15, part 2*/
  743. u8 res20[192];
  744. struct rmon_mib rmon; /* 0x.680-0x.73c */
  745. u32 rrej; /* 0x.740 - Receive filer rejected packet counter */
  746. u8 res21[188];
  747. u32 igaddr0; /* 0x.800 - Indivdual/Group address register 0*/
  748. u32 igaddr1; /* 0x.804 - Indivdual/Group address register 1*/
  749. u32 igaddr2; /* 0x.808 - Indivdual/Group address register 2*/
  750. u32 igaddr3; /* 0x.80c - Indivdual/Group address register 3*/
  751. u32 igaddr4; /* 0x.810 - Indivdual/Group address register 4*/
  752. u32 igaddr5; /* 0x.814 - Indivdual/Group address register 5*/
  753. u32 igaddr6; /* 0x.818 - Indivdual/Group address register 6*/
  754. u32 igaddr7; /* 0x.81c - Indivdual/Group address register 7*/
  755. u8 res22[96];
  756. u32 gaddr0; /* 0x.880 - Group address register 0 */
  757. u32 gaddr1; /* 0x.884 - Group address register 1 */
  758. u32 gaddr2; /* 0x.888 - Group address register 2 */
  759. u32 gaddr3; /* 0x.88c - Group address register 3 */
  760. u32 gaddr4; /* 0x.890 - Group address register 4 */
  761. u32 gaddr5; /* 0x.894 - Group address register 5 */
  762. u32 gaddr6; /* 0x.898 - Group address register 6 */
  763. u32 gaddr7; /* 0x.89c - Group address register 7 */
  764. u8 res23a[352];
  765. u32 fifocfg; /* 0x.a00 - FIFO interface config register */
  766. u8 res23b[252];
  767. u8 res23c[248];
  768. u32 attr; /* 0x.bf8 - Attributes Register */
  769. u32 attreli; /* 0x.bfc - Attributes Extract Length and Extract Index Register */
  770. u8 res24[688];
  771. u32 isrg0; /* 0x.eb0 - Interrupt steering group 0 register */
  772. u32 isrg1; /* 0x.eb4 - Interrupt steering group 1 register */
  773. u32 isrg2; /* 0x.eb8 - Interrupt steering group 2 register */
  774. u32 isrg3; /* 0x.ebc - Interrupt steering group 3 register */
  775. u8 res25[16];
  776. u32 rxic0; /* 0x.ed0 - Ring 0 Rx interrupt coalescing */
  777. u32 rxic1; /* 0x.ed4 - Ring 1 Rx interrupt coalescing */
  778. u32 rxic2; /* 0x.ed8 - Ring 2 Rx interrupt coalescing */
  779. u32 rxic3; /* 0x.edc - Ring 3 Rx interrupt coalescing */
  780. u32 rxic4; /* 0x.ee0 - Ring 4 Rx interrupt coalescing */
  781. u32 rxic5; /* 0x.ee4 - Ring 5 Rx interrupt coalescing */
  782. u32 rxic6; /* 0x.ee8 - Ring 6 Rx interrupt coalescing */
  783. u32 rxic7; /* 0x.eec - Ring 7 Rx interrupt coalescing */
  784. u8 res26[32];
  785. u32 txic0; /* 0x.f10 - Ring 0 Tx interrupt coalescing */
  786. u32 txic1; /* 0x.f14 - Ring 1 Tx interrupt coalescing */
  787. u32 txic2; /* 0x.f18 - Ring 2 Tx interrupt coalescing */
  788. u32 txic3; /* 0x.f1c - Ring 3 Tx interrupt coalescing */
  789. u32 txic4; /* 0x.f20 - Ring 4 Tx interrupt coalescing */
  790. u32 txic5; /* 0x.f24 - Ring 5 Tx interrupt coalescing */
  791. u32 txic6; /* 0x.f28 - Ring 6 Tx interrupt coalescing */
  792. u32 txic7; /* 0x.f2c - Ring 7 Tx interrupt coalescing */
  793. u8 res27[208];
  794. };
  795. /* Flags related to gianfar device features */
  796. #define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001
  797. #define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002
  798. #define FSL_GIANFAR_DEV_HAS_RMON 0x00000004
  799. #define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008
  800. #define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010
  801. #define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
  802. #define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
  803. #define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
  804. #define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100
  805. #define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200
  806. #define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400
  807. #define FSL_GIANFAR_DEV_HAS_TIMER 0x00000800
  808. #if (MAXGROUPS == 2)
  809. #define DEFAULT_MAPPING 0xAA
  810. #else
  811. #define DEFAULT_MAPPING 0xFF
  812. #endif
  813. #define ISRG_SHIFT_TX 0x10
  814. #define ISRG_SHIFT_RX 0x18
  815. /* The same driver can operate in two modes */
  816. /* SQ_SG_MODE: Single Queue Single Group Mode
  817. * (Backward compatible mode)
  818. * MQ_MG_MODE: Multi Queue Multi Group mode
  819. */
  820. enum {
  821. SQ_SG_MODE = 0,
  822. MQ_MG_MODE
  823. };
  824. /*
  825. * Per TX queue stats
  826. */
  827. struct tx_q_stats {
  828. unsigned long tx_packets;
  829. unsigned long tx_bytes;
  830. };
  831. /**
  832. * struct gfar_priv_tx_q - per tx queue structure
  833. * @txlock: per queue tx spin lock
  834. * @tx_skbuff:skb pointers
  835. * @skb_curtx: to be used skb pointer
  836. * @skb_dirtytx:the last used skb pointer
  837. * @stats: bytes/packets stats
  838. * @qindex: index of this queue
  839. * @dev: back pointer to the dev structure
  840. * @grp: back pointer to the group to which this queue belongs
  841. * @tx_bd_base: First tx buffer descriptor
  842. * @cur_tx: Next free ring entry
  843. * @dirty_tx: First buffer in line to be transmitted
  844. * @tx_ring_size: Tx ring size
  845. * @num_txbdfree: number of free TxBds
  846. * @txcoalescing: enable/disable tx coalescing
  847. * @txic: transmit interrupt coalescing value
  848. * @txcount: coalescing value if based on tx frame count
  849. * @txtime: coalescing value if based on time
  850. */
  851. struct gfar_priv_tx_q {
  852. spinlock_t txlock __attribute__ ((aligned (SMP_CACHE_BYTES)));
  853. struct sk_buff ** tx_skbuff;
  854. /* Buffer descriptor pointers */
  855. dma_addr_t tx_bd_dma_base;
  856. struct txbd8 *tx_bd_base;
  857. struct txbd8 *cur_tx;
  858. struct txbd8 *dirty_tx;
  859. struct tx_q_stats stats;
  860. struct net_device *dev;
  861. struct gfar_priv_grp *grp;
  862. u16 skb_curtx;
  863. u16 skb_dirtytx;
  864. u16 qindex;
  865. unsigned int tx_ring_size;
  866. unsigned int num_txbdfree;
  867. /* Configuration info for the coalescing features */
  868. unsigned char txcoalescing;
  869. unsigned long txic;
  870. unsigned short txcount;
  871. unsigned short txtime;
  872. };
  873. /*
  874. * Per RX queue stats
  875. */
  876. struct rx_q_stats {
  877. unsigned long rx_packets;
  878. unsigned long rx_bytes;
  879. unsigned long rx_dropped;
  880. };
  881. /**
  882. * struct gfar_priv_rx_q - per rx queue structure
  883. * @rxlock: per queue rx spin lock
  884. * @rx_skbuff: skb pointers
  885. * @skb_currx: currently use skb pointer
  886. * @rx_bd_base: First rx buffer descriptor
  887. * @cur_rx: Next free rx ring entry
  888. * @qindex: index of this queue
  889. * @dev: back pointer to the dev structure
  890. * @rx_ring_size: Rx ring size
  891. * @rxcoalescing: enable/disable rx-coalescing
  892. * @rxic: receive interrupt coalescing vlaue
  893. */
  894. struct gfar_priv_rx_q {
  895. spinlock_t rxlock __attribute__ ((aligned (SMP_CACHE_BYTES)));
  896. struct sk_buff ** rx_skbuff;
  897. dma_addr_t rx_bd_dma_base;
  898. struct rxbd8 *rx_bd_base;
  899. struct rxbd8 *cur_rx;
  900. struct net_device *dev;
  901. struct gfar_priv_grp *grp;
  902. struct rx_q_stats stats;
  903. u16 skb_currx;
  904. u16 qindex;
  905. unsigned int rx_ring_size;
  906. /* RX Coalescing values */
  907. unsigned char rxcoalescing;
  908. unsigned long rxic;
  909. };
  910. /**
  911. * struct gfar_priv_grp - per group structure
  912. * @napi: the napi poll function
  913. * @priv: back pointer to the priv structure
  914. * @regs: the ioremapped register space for this group
  915. * @grp_id: group id for this group
  916. * @interruptTransmit: The TX interrupt number for this group
  917. * @interruptReceive: The RX interrupt number for this group
  918. * @interruptError: The ERROR interrupt number for this group
  919. * @int_name_tx: tx interrupt name for this group
  920. * @int_name_rx: rx interrupt name for this group
  921. * @int_name_er: er interrupt name for this group
  922. */
  923. struct gfar_priv_grp {
  924. spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES)));
  925. struct napi_struct napi;
  926. struct gfar_private *priv;
  927. struct gfar __iomem *regs;
  928. unsigned int grp_id;
  929. unsigned long rx_bit_map;
  930. unsigned long tx_bit_map;
  931. unsigned long num_tx_queues;
  932. unsigned long num_rx_queues;
  933. unsigned int rstat;
  934. unsigned int tstat;
  935. unsigned int imask;
  936. unsigned int ievent;
  937. unsigned int interruptTransmit;
  938. unsigned int interruptReceive;
  939. unsigned int interruptError;
  940. char int_name_tx[GFAR_INT_NAME_MAX];
  941. char int_name_rx[GFAR_INT_NAME_MAX];
  942. char int_name_er[GFAR_INT_NAME_MAX];
  943. };
  944. enum gfar_errata {
  945. GFAR_ERRATA_74 = 0x01,
  946. GFAR_ERRATA_76 = 0x02,
  947. GFAR_ERRATA_A002 = 0x04,
  948. GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */
  949. };
  950. /* Struct stolen almost completely (and shamelessly) from the FCC enet source
  951. * (Ok, that's not so true anymore, but there is a family resemblance)
  952. * The GFAR buffer descriptors track the ring buffers. The rx_bd_base
  953. * and tx_bd_base always point to the currently available buffer.
  954. * The dirty_tx tracks the current buffer that is being sent by the
  955. * controller. The cur_tx and dirty_tx are equal under both completely
  956. * empty and completely full conditions. The empty/ready indicator in
  957. * the buffer descriptor determines the actual condition.
  958. */
  959. struct gfar_private {
  960. /* Indicates how many tx, rx queues are enabled */
  961. unsigned int num_tx_queues;
  962. unsigned int num_rx_queues;
  963. unsigned int num_grps;
  964. unsigned int mode;
  965. /* The total tx and rx ring size for the enabled queues */
  966. unsigned int total_tx_ring_size;
  967. unsigned int total_rx_ring_size;
  968. struct device_node *node;
  969. struct net_device *ndev;
  970. struct platform_device *ofdev;
  971. enum gfar_errata errata;
  972. struct gfar_priv_grp gfargrp[MAXGROUPS];
  973. struct gfar_priv_tx_q *tx_queue[MAX_TX_QS];
  974. struct gfar_priv_rx_q *rx_queue[MAX_RX_QS];
  975. /* RX per device parameters */
  976. unsigned int rx_buffer_size;
  977. unsigned int rx_stash_size;
  978. unsigned int rx_stash_index;
  979. u32 cur_filer_idx;
  980. struct sk_buff_head rx_recycle;
  981. /* RX queue filer rule set*/
  982. struct ethtool_rx_list rx_list;
  983. struct mutex rx_queue_access;
  984. /* Hash registers and their width */
  985. u32 __iomem *hash_regs[16];
  986. int hash_width;
  987. /* global parameters */
  988. unsigned int fifo_threshold;
  989. unsigned int fifo_starve;
  990. unsigned int fifo_starve_off;
  991. /* Bitfield update lock */
  992. spinlock_t bflock;
  993. phy_interface_t interface;
  994. struct device_node *phy_node;
  995. struct device_node *tbi_node;
  996. u32 device_flags;
  997. unsigned char
  998. extended_hash:1,
  999. bd_stash_en:1,
  1000. rx_filer_enable:1,
  1001. wol_en:1, /* Wake-on-LAN enabled */
  1002. prio_sched_en:1; /* Enable priorty based Tx scheduling in Hw */
  1003. unsigned short padding;
  1004. /* PHY stuff */
  1005. struct phy_device *phydev;
  1006. struct mii_bus *mii_bus;
  1007. int oldspeed;
  1008. int oldduplex;
  1009. int oldlink;
  1010. uint32_t msg_enable;
  1011. struct work_struct reset_task;
  1012. /* Network Statistics */
  1013. struct gfar_extra_stats extra_stats;
  1014. /* HW time stamping enabled flag */
  1015. int hwts_rx_en;
  1016. int hwts_tx_en;
  1017. /*Filer table*/
  1018. unsigned int ftp_rqfpr[MAX_FILER_IDX + 1];
  1019. unsigned int ftp_rqfcr[MAX_FILER_IDX + 1];
  1020. };
  1021. static inline int gfar_has_errata(struct gfar_private *priv,
  1022. enum gfar_errata err)
  1023. {
  1024. return priv->errata & err;
  1025. }
  1026. static inline u32 gfar_read(volatile unsigned __iomem *addr)
  1027. {
  1028. u32 val;
  1029. val = in_be32(addr);
  1030. return val;
  1031. }
  1032. static inline void gfar_write(volatile unsigned __iomem *addr, u32 val)
  1033. {
  1034. out_be32(addr, val);
  1035. }
  1036. static inline void gfar_write_filer(struct gfar_private *priv,
  1037. unsigned int far, unsigned int fcr, unsigned int fpr)
  1038. {
  1039. struct gfar __iomem *regs = priv->gfargrp[0].regs;
  1040. gfar_write(&regs->rqfar, far);
  1041. gfar_write(&regs->rqfcr, fcr);
  1042. gfar_write(&regs->rqfpr, fpr);
  1043. }
  1044. static inline void gfar_read_filer(struct gfar_private *priv,
  1045. unsigned int far, unsigned int *fcr, unsigned int *fpr)
  1046. {
  1047. struct gfar __iomem *regs = priv->gfargrp[0].regs;
  1048. gfar_write(&regs->rqfar, far);
  1049. *fcr = gfar_read(&regs->rqfcr);
  1050. *fpr = gfar_read(&regs->rqfpr);
  1051. }
  1052. extern void lock_rx_qs(struct gfar_private *priv);
  1053. extern void lock_tx_qs(struct gfar_private *priv);
  1054. extern void unlock_rx_qs(struct gfar_private *priv);
  1055. extern void unlock_tx_qs(struct gfar_private *priv);
  1056. extern irqreturn_t gfar_receive(int irq, void *dev_id);
  1057. extern int startup_gfar(struct net_device *dev);
  1058. extern void stop_gfar(struct net_device *dev);
  1059. extern void gfar_halt(struct net_device *dev);
  1060. extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
  1061. int enable, u32 regnum, u32 read);
  1062. extern void gfar_configure_coalescing(struct gfar_private *priv,
  1063. unsigned long tx_mask, unsigned long rx_mask);
  1064. void gfar_init_sysfs(struct net_device *dev);
  1065. int gfar_set_features(struct net_device *dev, netdev_features_t features);
  1066. extern void gfar_check_rx_parser_mode(struct gfar_private *priv);
  1067. extern void gfar_vlan_mode(struct net_device *dev, netdev_features_t features);
  1068. extern const struct ethtool_ops gfar_ethtool_ops;
  1069. #define MAX_FILER_CACHE_IDX (2*(MAX_FILER_IDX))
  1070. #define RQFCR_PID_PRI_MASK 0xFFFFFFF8
  1071. #define RQFCR_PID_L4P_MASK 0xFFFFFF00
  1072. #define RQFCR_PID_VID_MASK 0xFFFFF000
  1073. #define RQFCR_PID_PORT_MASK 0xFFFF0000
  1074. #define RQFCR_PID_MAC_MASK 0xFF000000
  1075. struct gfar_mask_entry {
  1076. unsigned int mask; /* The mask value which is valid form start to end */
  1077. unsigned int start;
  1078. unsigned int end;
  1079. unsigned int block; /* Same block values indicate depended entries */
  1080. };
  1081. /* Represents a receive filer table entry */
  1082. struct gfar_filer_entry {
  1083. u32 ctrl;
  1084. u32 prop;
  1085. };
  1086. /* The 20 additional entries are a shadow for one extra element */
  1087. struct filer_table {
  1088. u32 index;
  1089. struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20];
  1090. };
  1091. #endif /* __GIANFAR_H */