gianfar.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  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. #define TCTRL_TXSCHED_PRIO 0x00000002
  257. #define TCTRL_TXSCHED_WRRS 0x00000004
  258. #define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN)
  259. #define IEVENT_INIT_CLEAR 0xffffffff
  260. #define IEVENT_BABR 0x80000000
  261. #define IEVENT_RXC 0x40000000
  262. #define IEVENT_BSY 0x20000000
  263. #define IEVENT_EBERR 0x10000000
  264. #define IEVENT_MSRO 0x04000000
  265. #define IEVENT_GTSC 0x02000000
  266. #define IEVENT_BABT 0x01000000
  267. #define IEVENT_TXC 0x00800000
  268. #define IEVENT_TXE 0x00400000
  269. #define IEVENT_TXB 0x00200000
  270. #define IEVENT_TXF 0x00100000
  271. #define IEVENT_LC 0x00040000
  272. #define IEVENT_CRL 0x00020000
  273. #define IEVENT_XFUN 0x00010000
  274. #define IEVENT_RXB0 0x00008000
  275. #define IEVENT_MAG 0x00000800
  276. #define IEVENT_GRSC 0x00000100
  277. #define IEVENT_RXF0 0x00000080
  278. #define IEVENT_FIR 0x00000008
  279. #define IEVENT_FIQ 0x00000004
  280. #define IEVENT_DPE 0x00000002
  281. #define IEVENT_PERR 0x00000001
  282. #define IEVENT_RX_MASK (IEVENT_RXB0 | IEVENT_RXF0 | IEVENT_BSY)
  283. #define IEVENT_TX_MASK (IEVENT_TXB | IEVENT_TXF)
  284. #define IEVENT_RTX_MASK (IEVENT_RX_MASK | IEVENT_TX_MASK)
  285. #define IEVENT_ERR_MASK \
  286. (IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \
  287. IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \
  288. | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR \
  289. | IEVENT_MAG | IEVENT_BABR)
  290. #define IMASK_INIT_CLEAR 0x00000000
  291. #define IMASK_BABR 0x80000000
  292. #define IMASK_RXC 0x40000000
  293. #define IMASK_BSY 0x20000000
  294. #define IMASK_EBERR 0x10000000
  295. #define IMASK_MSRO 0x04000000
  296. #define IMASK_GTSC 0x02000000
  297. #define IMASK_BABT 0x01000000
  298. #define IMASK_TXC 0x00800000
  299. #define IMASK_TXEEN 0x00400000
  300. #define IMASK_TXBEN 0x00200000
  301. #define IMASK_TXFEN 0x00100000
  302. #define IMASK_LC 0x00040000
  303. #define IMASK_CRL 0x00020000
  304. #define IMASK_XFUN 0x00010000
  305. #define IMASK_RXB0 0x00008000
  306. #define IMASK_MAG 0x00000800
  307. #define IMASK_GRSC 0x00000100
  308. #define IMASK_RXFEN0 0x00000080
  309. #define IMASK_FIR 0x00000008
  310. #define IMASK_FIQ 0x00000004
  311. #define IMASK_DPE 0x00000002
  312. #define IMASK_PERR 0x00000001
  313. #define IMASK_DEFAULT (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \
  314. IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \
  315. IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \
  316. | IMASK_PERR)
  317. #define IMASK_RTX_DISABLED ((~(IMASK_RXFEN0 | IMASK_TXFEN | IMASK_BSY)) \
  318. & IMASK_DEFAULT)
  319. /* Fifo management */
  320. #define FIFO_TX_THR_MASK 0x01ff
  321. #define FIFO_TX_STARVE_MASK 0x01ff
  322. #define FIFO_TX_STARVE_OFF_MASK 0x01ff
  323. /* Attribute fields */
  324. /* This enables rx snooping for buffers and descriptors */
  325. #define ATTR_BDSTASH 0x00000800
  326. #define ATTR_BUFSTASH 0x00004000
  327. #define ATTR_SNOOPING 0x000000c0
  328. #define ATTR_INIT_SETTINGS ATTR_SNOOPING
  329. #define ATTRELI_INIT_SETTINGS 0x0
  330. #define ATTRELI_EL_MASK 0x3fff0000
  331. #define ATTRELI_EL(x) (x << 16)
  332. #define ATTRELI_EI_MASK 0x00003fff
  333. #define ATTRELI_EI(x) (x)
  334. #define BD_LFLAG(flags) ((flags) << 16)
  335. #define BD_LENGTH_MASK 0x0000ffff
  336. #define FPR_FILER_MASK 0xFFFFFFFF
  337. #define MAX_FILER_IDX 0xFF
  338. /* This default RIR value directly corresponds
  339. * to the 3-bit hash value generated */
  340. #define DEFAULT_RIR0 0x05397700
  341. /* RQFCR register bits */
  342. #define RQFCR_GPI 0x80000000
  343. #define RQFCR_HASHTBL_Q 0x00000000
  344. #define RQFCR_HASHTBL_0 0x00020000
  345. #define RQFCR_HASHTBL_1 0x00040000
  346. #define RQFCR_HASHTBL_2 0x00060000
  347. #define RQFCR_HASHTBL_3 0x00080000
  348. #define RQFCR_HASH 0x00010000
  349. #define RQFCR_QUEUE 0x0000FC00
  350. #define RQFCR_CLE 0x00000200
  351. #define RQFCR_RJE 0x00000100
  352. #define RQFCR_AND 0x00000080
  353. #define RQFCR_CMP_EXACT 0x00000000
  354. #define RQFCR_CMP_MATCH 0x00000020
  355. #define RQFCR_CMP_NOEXACT 0x00000040
  356. #define RQFCR_CMP_NOMATCH 0x00000060
  357. /* RQFCR PID values */
  358. #define RQFCR_PID_MASK 0x00000000
  359. #define RQFCR_PID_PARSE 0x00000001
  360. #define RQFCR_PID_ARB 0x00000002
  361. #define RQFCR_PID_DAH 0x00000003
  362. #define RQFCR_PID_DAL 0x00000004
  363. #define RQFCR_PID_SAH 0x00000005
  364. #define RQFCR_PID_SAL 0x00000006
  365. #define RQFCR_PID_ETY 0x00000007
  366. #define RQFCR_PID_VID 0x00000008
  367. #define RQFCR_PID_PRI 0x00000009
  368. #define RQFCR_PID_TOS 0x0000000A
  369. #define RQFCR_PID_L4P 0x0000000B
  370. #define RQFCR_PID_DIA 0x0000000C
  371. #define RQFCR_PID_SIA 0x0000000D
  372. #define RQFCR_PID_DPT 0x0000000E
  373. #define RQFCR_PID_SPT 0x0000000F
  374. /* RQFPR when PID is 0x0001 */
  375. #define RQFPR_HDR_GE_512 0x00200000
  376. #define RQFPR_LERR 0x00100000
  377. #define RQFPR_RAR 0x00080000
  378. #define RQFPR_RARQ 0x00040000
  379. #define RQFPR_AR 0x00020000
  380. #define RQFPR_ARQ 0x00010000
  381. #define RQFPR_EBC 0x00008000
  382. #define RQFPR_VLN 0x00004000
  383. #define RQFPR_CFI 0x00002000
  384. #define RQFPR_JUM 0x00001000
  385. #define RQFPR_IPF 0x00000800
  386. #define RQFPR_FIF 0x00000400
  387. #define RQFPR_IPV4 0x00000200
  388. #define RQFPR_IPV6 0x00000100
  389. #define RQFPR_ICC 0x00000080
  390. #define RQFPR_ICV 0x00000040
  391. #define RQFPR_TCP 0x00000020
  392. #define RQFPR_UDP 0x00000010
  393. #define RQFPR_TUC 0x00000008
  394. #define RQFPR_TUV 0x00000004
  395. #define RQFPR_PER 0x00000002
  396. #define RQFPR_EER 0x00000001
  397. /* TxBD status field bits */
  398. #define TXBD_READY 0x8000
  399. #define TXBD_PADCRC 0x4000
  400. #define TXBD_WRAP 0x2000
  401. #define TXBD_INTERRUPT 0x1000
  402. #define TXBD_LAST 0x0800
  403. #define TXBD_CRC 0x0400
  404. #define TXBD_DEF 0x0200
  405. #define TXBD_HUGEFRAME 0x0080
  406. #define TXBD_LATECOLLISION 0x0080
  407. #define TXBD_RETRYLIMIT 0x0040
  408. #define TXBD_RETRYCOUNTMASK 0x003c
  409. #define TXBD_UNDERRUN 0x0002
  410. #define TXBD_TOE 0x0002
  411. /* Tx FCB param bits */
  412. #define TXFCB_VLN 0x80
  413. #define TXFCB_IP 0x40
  414. #define TXFCB_IP6 0x20
  415. #define TXFCB_TUP 0x10
  416. #define TXFCB_UDP 0x08
  417. #define TXFCB_CIP 0x04
  418. #define TXFCB_CTU 0x02
  419. #define TXFCB_NPH 0x01
  420. #define TXFCB_DEFAULT (TXFCB_IP|TXFCB_TUP|TXFCB_CTU|TXFCB_NPH)
  421. /* RxBD status field bits */
  422. #define RXBD_EMPTY 0x8000
  423. #define RXBD_RO1 0x4000
  424. #define RXBD_WRAP 0x2000
  425. #define RXBD_INTERRUPT 0x1000
  426. #define RXBD_LAST 0x0800
  427. #define RXBD_FIRST 0x0400
  428. #define RXBD_MISS 0x0100
  429. #define RXBD_BROADCAST 0x0080
  430. #define RXBD_MULTICAST 0x0040
  431. #define RXBD_LARGE 0x0020
  432. #define RXBD_NONOCTET 0x0010
  433. #define RXBD_SHORT 0x0008
  434. #define RXBD_CRCERR 0x0004
  435. #define RXBD_OVERRUN 0x0002
  436. #define RXBD_TRUNCATED 0x0001
  437. #define RXBD_STATS 0x01ff
  438. #define RXBD_ERR (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET \
  439. | RXBD_CRCERR | RXBD_OVERRUN \
  440. | RXBD_TRUNCATED)
  441. /* Rx FCB status field bits */
  442. #define RXFCB_VLN 0x8000
  443. #define RXFCB_IP 0x4000
  444. #define RXFCB_IP6 0x2000
  445. #define RXFCB_TUP 0x1000
  446. #define RXFCB_CIP 0x0800
  447. #define RXFCB_CTU 0x0400
  448. #define RXFCB_EIP 0x0200
  449. #define RXFCB_ETU 0x0100
  450. #define RXFCB_CSUM_MASK 0x0f00
  451. #define RXFCB_PERR_MASK 0x000c
  452. #define RXFCB_PERR_BADL3 0x0008
  453. #define GFAR_INT_NAME_MAX (IFNAMSIZ + 6) /* '_g#_xx' */
  454. struct txbd8
  455. {
  456. union {
  457. struct {
  458. u16 status; /* Status Fields */
  459. u16 length; /* Buffer length */
  460. };
  461. u32 lstatus;
  462. };
  463. u32 bufPtr; /* Buffer Pointer */
  464. };
  465. struct txfcb {
  466. u8 flags;
  467. u8 ptp; /* Flag to enable tx timestamping */
  468. u8 l4os; /* Level 4 Header Offset */
  469. u8 l3os; /* Level 3 Header Offset */
  470. u16 phcs; /* Pseudo-header Checksum */
  471. u16 vlctl; /* VLAN control word */
  472. };
  473. struct rxbd8
  474. {
  475. union {
  476. struct {
  477. u16 status; /* Status Fields */
  478. u16 length; /* Buffer Length */
  479. };
  480. u32 lstatus;
  481. };
  482. u32 bufPtr; /* Buffer Pointer */
  483. };
  484. struct rxfcb {
  485. u16 flags;
  486. u8 rq; /* Receive Queue index */
  487. u8 pro; /* Layer 4 Protocol */
  488. u16 reserved;
  489. u16 vlctl; /* VLAN control word */
  490. };
  491. struct gianfar_skb_cb {
  492. int alignamount;
  493. };
  494. #define GFAR_CB(skb) ((struct gianfar_skb_cb *)((skb)->cb))
  495. struct rmon_mib
  496. {
  497. u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */
  498. u32 tr127; /* 0x.684 - Transmit and Receive 65-127 byte Frame Counter */
  499. u32 tr255; /* 0x.688 - Transmit and Receive 128-255 byte Frame Counter */
  500. u32 tr511; /* 0x.68c - Transmit and Receive 256-511 byte Frame Counter */
  501. u32 tr1k; /* 0x.690 - Transmit and Receive 512-1023 byte Frame Counter */
  502. u32 trmax; /* 0x.694 - Transmit and Receive 1024-1518 byte Frame Counter */
  503. u32 trmgv; /* 0x.698 - Transmit and Receive 1519-1522 byte Good VLAN Frame */
  504. u32 rbyt; /* 0x.69c - Receive Byte Counter */
  505. u32 rpkt; /* 0x.6a0 - Receive Packet Counter */
  506. u32 rfcs; /* 0x.6a4 - Receive FCS Error Counter */
  507. u32 rmca; /* 0x.6a8 - Receive Multicast Packet Counter */
  508. u32 rbca; /* 0x.6ac - Receive Broadcast Packet Counter */
  509. u32 rxcf; /* 0x.6b0 - Receive Control Frame Packet Counter */
  510. u32 rxpf; /* 0x.6b4 - Receive Pause Frame Packet Counter */
  511. u32 rxuo; /* 0x.6b8 - Receive Unknown OP Code Counter */
  512. u32 raln; /* 0x.6bc - Receive Alignment Error Counter */
  513. u32 rflr; /* 0x.6c0 - Receive Frame Length Error Counter */
  514. u32 rcde; /* 0x.6c4 - Receive Code Error Counter */
  515. u32 rcse; /* 0x.6c8 - Receive Carrier Sense Error Counter */
  516. u32 rund; /* 0x.6cc - Receive Undersize Packet Counter */
  517. u32 rovr; /* 0x.6d0 - Receive Oversize Packet Counter */
  518. u32 rfrg; /* 0x.6d4 - Receive Fragments Counter */
  519. u32 rjbr; /* 0x.6d8 - Receive Jabber Counter */
  520. u32 rdrp; /* 0x.6dc - Receive Drop Counter */
  521. u32 tbyt; /* 0x.6e0 - Transmit Byte Counter Counter */
  522. u32 tpkt; /* 0x.6e4 - Transmit Packet Counter */
  523. u32 tmca; /* 0x.6e8 - Transmit Multicast Packet Counter */
  524. u32 tbca; /* 0x.6ec - Transmit Broadcast Packet Counter */
  525. u32 txpf; /* 0x.6f0 - Transmit Pause Control Frame Counter */
  526. u32 tdfr; /* 0x.6f4 - Transmit Deferral Packet Counter */
  527. u32 tedf; /* 0x.6f8 - Transmit Excessive Deferral Packet Counter */
  528. u32 tscl; /* 0x.6fc - Transmit Single Collision Packet Counter */
  529. u32 tmcl; /* 0x.700 - Transmit Multiple Collision Packet Counter */
  530. u32 tlcl; /* 0x.704 - Transmit Late Collision Packet Counter */
  531. u32 txcl; /* 0x.708 - Transmit Excessive Collision Packet Counter */
  532. u32 tncl; /* 0x.70c - Transmit Total Collision Counter */
  533. u8 res1[4];
  534. u32 tdrp; /* 0x.714 - Transmit Drop Frame Counter */
  535. u32 tjbr; /* 0x.718 - Transmit Jabber Frame Counter */
  536. u32 tfcs; /* 0x.71c - Transmit FCS Error Counter */
  537. u32 txcf; /* 0x.720 - Transmit Control Frame Counter */
  538. u32 tovr; /* 0x.724 - Transmit Oversize Frame Counter */
  539. u32 tund; /* 0x.728 - Transmit Undersize Frame Counter */
  540. u32 tfrg; /* 0x.72c - Transmit Fragments Frame Counter */
  541. u32 car1; /* 0x.730 - Carry Register One */
  542. u32 car2; /* 0x.734 - Carry Register Two */
  543. u32 cam1; /* 0x.738 - Carry Mask Register One */
  544. u32 cam2; /* 0x.73c - Carry Mask Register Two */
  545. };
  546. struct gfar_extra_stats {
  547. u64 kernel_dropped;
  548. u64 rx_large;
  549. u64 rx_short;
  550. u64 rx_nonoctet;
  551. u64 rx_crcerr;
  552. u64 rx_overrun;
  553. u64 rx_bsy;
  554. u64 rx_babr;
  555. u64 rx_trunc;
  556. u64 eberr;
  557. u64 tx_babt;
  558. u64 tx_underrun;
  559. u64 rx_skbmissing;
  560. u64 tx_timeout;
  561. };
  562. #define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32))
  563. #define GFAR_EXTRA_STATS_LEN (sizeof(struct gfar_extra_stats)/sizeof(u64))
  564. /* Number of stats in the stats structure (ignore car and cam regs)*/
  565. #define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN)
  566. #define GFAR_INFOSTR_LEN 32
  567. struct gfar_stats {
  568. u64 extra[GFAR_EXTRA_STATS_LEN];
  569. u64 rmon[GFAR_RMON_LEN];
  570. };
  571. struct gfar {
  572. u32 tsec_id; /* 0x.000 - Controller ID register */
  573. u32 tsec_id2; /* 0x.004 - Controller ID2 register */
  574. u8 res1[8];
  575. u32 ievent; /* 0x.010 - Interrupt Event Register */
  576. u32 imask; /* 0x.014 - Interrupt Mask Register */
  577. u32 edis; /* 0x.018 - Error Disabled Register */
  578. u32 emapg; /* 0x.01c - Group Error mapping register */
  579. u32 ecntrl; /* 0x.020 - Ethernet Control Register */
  580. u32 minflr; /* 0x.024 - Minimum Frame Length Register */
  581. u32 ptv; /* 0x.028 - Pause Time Value Register */
  582. u32 dmactrl; /* 0x.02c - DMA Control Register */
  583. u32 tbipa; /* 0x.030 - TBI PHY Address Register */
  584. u8 res2[28];
  585. u32 fifo_rx_pause; /* 0x.050 - FIFO receive pause start threshold
  586. register */
  587. u32 fifo_rx_pause_shutoff; /* x.054 - FIFO receive starve shutoff
  588. register */
  589. u32 fifo_rx_alarm; /* 0x.058 - FIFO receive alarm start threshold
  590. register */
  591. u32 fifo_rx_alarm_shutoff; /*0x.05c - FIFO receive alarm starve
  592. shutoff register */
  593. u8 res3[44];
  594. u32 fifo_tx_thr; /* 0x.08c - FIFO transmit threshold register */
  595. u8 res4[8];
  596. u32 fifo_tx_starve; /* 0x.098 - FIFO transmit starve register */
  597. u32 fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */
  598. u8 res5[96];
  599. u32 tctrl; /* 0x.100 - Transmit Control Register */
  600. u32 tstat; /* 0x.104 - Transmit Status Register */
  601. u32 dfvlan; /* 0x.108 - Default VLAN Control word */
  602. u32 tbdlen; /* 0x.10c - Transmit Buffer Descriptor Data Length Register */
  603. u32 txic; /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */
  604. u32 tqueue; /* 0x.114 - Transmit queue control register */
  605. u8 res7[40];
  606. u32 tr03wt; /* 0x.140 - TxBD Rings 0-3 round-robin weightings */
  607. u32 tr47wt; /* 0x.144 - TxBD Rings 4-7 round-robin weightings */
  608. u8 res8[52];
  609. u32 tbdbph; /* 0x.17c - Tx data buffer pointer high */
  610. u8 res9a[4];
  611. u32 tbptr0; /* 0x.184 - TxBD Pointer for ring 0 */
  612. u8 res9b[4];
  613. u32 tbptr1; /* 0x.18c - TxBD Pointer for ring 1 */
  614. u8 res9c[4];
  615. u32 tbptr2; /* 0x.194 - TxBD Pointer for ring 2 */
  616. u8 res9d[4];
  617. u32 tbptr3; /* 0x.19c - TxBD Pointer for ring 3 */
  618. u8 res9e[4];
  619. u32 tbptr4; /* 0x.1a4 - TxBD Pointer for ring 4 */
  620. u8 res9f[4];
  621. u32 tbptr5; /* 0x.1ac - TxBD Pointer for ring 5 */
  622. u8 res9g[4];
  623. u32 tbptr6; /* 0x.1b4 - TxBD Pointer for ring 6 */
  624. u8 res9h[4];
  625. u32 tbptr7; /* 0x.1bc - TxBD Pointer for ring 7 */
  626. u8 res9[64];
  627. u32 tbaseh; /* 0x.200 - TxBD base address high */
  628. u32 tbase0; /* 0x.204 - TxBD Base Address of ring 0 */
  629. u8 res10a[4];
  630. u32 tbase1; /* 0x.20c - TxBD Base Address of ring 1 */
  631. u8 res10b[4];
  632. u32 tbase2; /* 0x.214 - TxBD Base Address of ring 2 */
  633. u8 res10c[4];
  634. u32 tbase3; /* 0x.21c - TxBD Base Address of ring 3 */
  635. u8 res10d[4];
  636. u32 tbase4; /* 0x.224 - TxBD Base Address of ring 4 */
  637. u8 res10e[4];
  638. u32 tbase5; /* 0x.22c - TxBD Base Address of ring 5 */
  639. u8 res10f[4];
  640. u32 tbase6; /* 0x.234 - TxBD Base Address of ring 6 */
  641. u8 res10g[4];
  642. u32 tbase7; /* 0x.23c - TxBD Base Address of ring 7 */
  643. u8 res10[192];
  644. u32 rctrl; /* 0x.300 - Receive Control Register */
  645. u32 rstat; /* 0x.304 - Receive Status Register */
  646. u8 res12[8];
  647. u32 rxic; /* 0x.310 - Receive Interrupt Coalescing Configuration Register */
  648. u32 rqueue; /* 0x.314 - Receive queue control register */
  649. u32 rir0; /* 0x.318 - Ring mapping register 0 */
  650. u32 rir1; /* 0x.31c - Ring mapping register 1 */
  651. u32 rir2; /* 0x.320 - Ring mapping register 2 */
  652. u32 rir3; /* 0x.324 - Ring mapping register 3 */
  653. u8 res13[8];
  654. u32 rbifx; /* 0x.330 - Receive bit field extract control register */
  655. u32 rqfar; /* 0x.334 - Receive queue filing table address register */
  656. u32 rqfcr; /* 0x.338 - Receive queue filing table control register */
  657. u32 rqfpr; /* 0x.33c - Receive queue filing table property register */
  658. u32 mrblr; /* 0x.340 - Maximum Receive Buffer Length Register */
  659. u8 res14[56];
  660. u32 rbdbph; /* 0x.37c - Rx data buffer pointer high */
  661. u8 res15a[4];
  662. u32 rbptr0; /* 0x.384 - RxBD pointer for ring 0 */
  663. u8 res15b[4];
  664. u32 rbptr1; /* 0x.38c - RxBD pointer for ring 1 */
  665. u8 res15c[4];
  666. u32 rbptr2; /* 0x.394 - RxBD pointer for ring 2 */
  667. u8 res15d[4];
  668. u32 rbptr3; /* 0x.39c - RxBD pointer for ring 3 */
  669. u8 res15e[4];
  670. u32 rbptr4; /* 0x.3a4 - RxBD pointer for ring 4 */
  671. u8 res15f[4];
  672. u32 rbptr5; /* 0x.3ac - RxBD pointer for ring 5 */
  673. u8 res15g[4];
  674. u32 rbptr6; /* 0x.3b4 - RxBD pointer for ring 6 */
  675. u8 res15h[4];
  676. u32 rbptr7; /* 0x.3bc - RxBD pointer for ring 7 */
  677. u8 res16[64];
  678. u32 rbaseh; /* 0x.400 - RxBD base address high */
  679. u32 rbase0; /* 0x.404 - RxBD base address of ring 0 */
  680. u8 res17a[4];
  681. u32 rbase1; /* 0x.40c - RxBD base address of ring 1 */
  682. u8 res17b[4];
  683. u32 rbase2; /* 0x.414 - RxBD base address of ring 2 */
  684. u8 res17c[4];
  685. u32 rbase3; /* 0x.41c - RxBD base address of ring 3 */
  686. u8 res17d[4];
  687. u32 rbase4; /* 0x.424 - RxBD base address of ring 4 */
  688. u8 res17e[4];
  689. u32 rbase5; /* 0x.42c - RxBD base address of ring 5 */
  690. u8 res17f[4];
  691. u32 rbase6; /* 0x.434 - RxBD base address of ring 6 */
  692. u8 res17g[4];
  693. u32 rbase7; /* 0x.43c - RxBD base address of ring 7 */
  694. u8 res17[192];
  695. u32 maccfg1; /* 0x.500 - MAC Configuration 1 Register */
  696. u32 maccfg2; /* 0x.504 - MAC Configuration 2 Register */
  697. u32 ipgifg; /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */
  698. u32 hafdup; /* 0x.50c - Half Duplex Register */
  699. u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */
  700. u8 res18[12];
  701. u8 gfar_mii_regs[24]; /* See gianfar_phy.h */
  702. u32 ifctrl; /* 0x.538 - Interface control register */
  703. u32 ifstat; /* 0x.53c - Interface Status Register */
  704. u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */
  705. u32 macstnaddr2; /* 0x.544 - Station Address Part 2 Register */
  706. u32 mac01addr1; /* 0x.548 - MAC exact match address 1, part 1 */
  707. u32 mac01addr2; /* 0x.54c - MAC exact match address 1, part 2 */
  708. u32 mac02addr1; /* 0x.550 - MAC exact match address 2, part 1 */
  709. u32 mac02addr2; /* 0x.554 - MAC exact match address 2, part 2 */
  710. u32 mac03addr1; /* 0x.558 - MAC exact match address 3, part 1 */
  711. u32 mac03addr2; /* 0x.55c - MAC exact match address 3, part 2 */
  712. u32 mac04addr1; /* 0x.560 - MAC exact match address 4, part 1 */
  713. u32 mac04addr2; /* 0x.564 - MAC exact match address 4, part 2 */
  714. u32 mac05addr1; /* 0x.568 - MAC exact match address 5, part 1 */
  715. u32 mac05addr2; /* 0x.56c - MAC exact match address 5, part 2 */
  716. u32 mac06addr1; /* 0x.570 - MAC exact match address 6, part 1 */
  717. u32 mac06addr2; /* 0x.574 - MAC exact match address 6, part 2 */
  718. u32 mac07addr1; /* 0x.578 - MAC exact match address 7, part 1 */
  719. u32 mac07addr2; /* 0x.57c - MAC exact match address 7, part 2 */
  720. u32 mac08addr1; /* 0x.580 - MAC exact match address 8, part 1 */
  721. u32 mac08addr2; /* 0x.584 - MAC exact match address 8, part 2 */
  722. u32 mac09addr1; /* 0x.588 - MAC exact match address 9, part 1 */
  723. u32 mac09addr2; /* 0x.58c - MAC exact match address 9, part 2 */
  724. u32 mac10addr1; /* 0x.590 - MAC exact match address 10, part 1*/
  725. u32 mac10addr2; /* 0x.594 - MAC exact match address 10, part 2*/
  726. u32 mac11addr1; /* 0x.598 - MAC exact match address 11, part 1*/
  727. u32 mac11addr2; /* 0x.59c - MAC exact match address 11, part 2*/
  728. u32 mac12addr1; /* 0x.5a0 - MAC exact match address 12, part 1*/
  729. u32 mac12addr2; /* 0x.5a4 - MAC exact match address 12, part 2*/
  730. u32 mac13addr1; /* 0x.5a8 - MAC exact match address 13, part 1*/
  731. u32 mac13addr2; /* 0x.5ac - MAC exact match address 13, part 2*/
  732. u32 mac14addr1; /* 0x.5b0 - MAC exact match address 14, part 1*/
  733. u32 mac14addr2; /* 0x.5b4 - MAC exact match address 14, part 2*/
  734. u32 mac15addr1; /* 0x.5b8 - MAC exact match address 15, part 1*/
  735. u32 mac15addr2; /* 0x.5bc - MAC exact match address 15, part 2*/
  736. u8 res20[192];
  737. struct rmon_mib rmon; /* 0x.680-0x.73c */
  738. u32 rrej; /* 0x.740 - Receive filer rejected packet counter */
  739. u8 res21[188];
  740. u32 igaddr0; /* 0x.800 - Indivdual/Group address register 0*/
  741. u32 igaddr1; /* 0x.804 - Indivdual/Group address register 1*/
  742. u32 igaddr2; /* 0x.808 - Indivdual/Group address register 2*/
  743. u32 igaddr3; /* 0x.80c - Indivdual/Group address register 3*/
  744. u32 igaddr4; /* 0x.810 - Indivdual/Group address register 4*/
  745. u32 igaddr5; /* 0x.814 - Indivdual/Group address register 5*/
  746. u32 igaddr6; /* 0x.818 - Indivdual/Group address register 6*/
  747. u32 igaddr7; /* 0x.81c - Indivdual/Group address register 7*/
  748. u8 res22[96];
  749. u32 gaddr0; /* 0x.880 - Group address register 0 */
  750. u32 gaddr1; /* 0x.884 - Group address register 1 */
  751. u32 gaddr2; /* 0x.888 - Group address register 2 */
  752. u32 gaddr3; /* 0x.88c - Group address register 3 */
  753. u32 gaddr4; /* 0x.890 - Group address register 4 */
  754. u32 gaddr5; /* 0x.894 - Group address register 5 */
  755. u32 gaddr6; /* 0x.898 - Group address register 6 */
  756. u32 gaddr7; /* 0x.89c - Group address register 7 */
  757. u8 res23a[352];
  758. u32 fifocfg; /* 0x.a00 - FIFO interface config register */
  759. u8 res23b[252];
  760. u8 res23c[248];
  761. u32 attr; /* 0x.bf8 - Attributes Register */
  762. u32 attreli; /* 0x.bfc - Attributes Extract Length and Extract Index Register */
  763. u8 res24[688];
  764. u32 isrg0; /* 0x.eb0 - Interrupt steering group 0 register */
  765. u32 isrg1; /* 0x.eb4 - Interrupt steering group 1 register */
  766. u32 isrg2; /* 0x.eb8 - Interrupt steering group 2 register */
  767. u32 isrg3; /* 0x.ebc - Interrupt steering group 3 register */
  768. u8 res25[16];
  769. u32 rxic0; /* 0x.ed0 - Ring 0 Rx interrupt coalescing */
  770. u32 rxic1; /* 0x.ed4 - Ring 1 Rx interrupt coalescing */
  771. u32 rxic2; /* 0x.ed8 - Ring 2 Rx interrupt coalescing */
  772. u32 rxic3; /* 0x.edc - Ring 3 Rx interrupt coalescing */
  773. u32 rxic4; /* 0x.ee0 - Ring 4 Rx interrupt coalescing */
  774. u32 rxic5; /* 0x.ee4 - Ring 5 Rx interrupt coalescing */
  775. u32 rxic6; /* 0x.ee8 - Ring 6 Rx interrupt coalescing */
  776. u32 rxic7; /* 0x.eec - Ring 7 Rx interrupt coalescing */
  777. u8 res26[32];
  778. u32 txic0; /* 0x.f10 - Ring 0 Tx interrupt coalescing */
  779. u32 txic1; /* 0x.f14 - Ring 1 Tx interrupt coalescing */
  780. u32 txic2; /* 0x.f18 - Ring 2 Tx interrupt coalescing */
  781. u32 txic3; /* 0x.f1c - Ring 3 Tx interrupt coalescing */
  782. u32 txic4; /* 0x.f20 - Ring 4 Tx interrupt coalescing */
  783. u32 txic5; /* 0x.f24 - Ring 5 Tx interrupt coalescing */
  784. u32 txic6; /* 0x.f28 - Ring 6 Tx interrupt coalescing */
  785. u32 txic7; /* 0x.f2c - Ring 7 Tx interrupt coalescing */
  786. u8 res27[208];
  787. };
  788. /* Flags related to gianfar device features */
  789. #define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001
  790. #define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002
  791. #define FSL_GIANFAR_DEV_HAS_RMON 0x00000004
  792. #define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008
  793. #define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010
  794. #define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
  795. #define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
  796. #define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
  797. #define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100
  798. #define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200
  799. #define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400
  800. #define FSL_GIANFAR_DEV_HAS_TIMER 0x00000800
  801. #if (MAXGROUPS == 2)
  802. #define DEFAULT_MAPPING 0xAA
  803. #else
  804. #define DEFAULT_MAPPING 0xFF
  805. #endif
  806. #define ISRG_SHIFT_TX 0x10
  807. #define ISRG_SHIFT_RX 0x18
  808. /* The same driver can operate in two modes */
  809. /* SQ_SG_MODE: Single Queue Single Group Mode
  810. * (Backward compatible mode)
  811. * MQ_MG_MODE: Multi Queue Multi Group mode
  812. */
  813. enum {
  814. SQ_SG_MODE = 0,
  815. MQ_MG_MODE
  816. };
  817. /*
  818. * Per TX queue stats
  819. */
  820. struct tx_q_stats {
  821. unsigned long tx_packets;
  822. unsigned long tx_bytes;
  823. };
  824. /**
  825. * struct gfar_priv_tx_q - per tx queue structure
  826. * @txlock: per queue tx spin lock
  827. * @tx_skbuff:skb pointers
  828. * @skb_curtx: to be used skb pointer
  829. * @skb_dirtytx:the last used skb pointer
  830. * @stats: bytes/packets stats
  831. * @qindex: index of this queue
  832. * @dev: back pointer to the dev structure
  833. * @grp: back pointer to the group to which this queue belongs
  834. * @tx_bd_base: First tx buffer descriptor
  835. * @cur_tx: Next free ring entry
  836. * @dirty_tx: First buffer in line to be transmitted
  837. * @tx_ring_size: Tx ring size
  838. * @num_txbdfree: number of free TxBds
  839. * @txcoalescing: enable/disable tx coalescing
  840. * @txic: transmit interrupt coalescing value
  841. * @txcount: coalescing value if based on tx frame count
  842. * @txtime: coalescing value if based on time
  843. */
  844. struct gfar_priv_tx_q {
  845. spinlock_t txlock __attribute__ ((aligned (SMP_CACHE_BYTES)));
  846. struct sk_buff ** tx_skbuff;
  847. /* Buffer descriptor pointers */
  848. dma_addr_t tx_bd_dma_base;
  849. struct txbd8 *tx_bd_base;
  850. struct txbd8 *cur_tx;
  851. struct txbd8 *dirty_tx;
  852. struct tx_q_stats stats;
  853. struct net_device *dev;
  854. struct gfar_priv_grp *grp;
  855. u16 skb_curtx;
  856. u16 skb_dirtytx;
  857. u16 qindex;
  858. unsigned int tx_ring_size;
  859. unsigned int num_txbdfree;
  860. /* Configuration info for the coalescing features */
  861. unsigned char txcoalescing;
  862. unsigned long txic;
  863. unsigned short txcount;
  864. unsigned short txtime;
  865. };
  866. /*
  867. * Per RX queue stats
  868. */
  869. struct rx_q_stats {
  870. unsigned long rx_packets;
  871. unsigned long rx_bytes;
  872. unsigned long rx_dropped;
  873. };
  874. /**
  875. * struct gfar_priv_rx_q - per rx queue structure
  876. * @rxlock: per queue rx spin lock
  877. * @rx_skbuff: skb pointers
  878. * @skb_currx: currently use skb pointer
  879. * @rx_bd_base: First rx buffer descriptor
  880. * @cur_rx: Next free rx ring entry
  881. * @qindex: index of this queue
  882. * @dev: back pointer to the dev structure
  883. * @rx_ring_size: Rx ring size
  884. * @rxcoalescing: enable/disable rx-coalescing
  885. * @rxic: receive interrupt coalescing vlaue
  886. */
  887. struct gfar_priv_rx_q {
  888. spinlock_t rxlock __attribute__ ((aligned (SMP_CACHE_BYTES)));
  889. struct sk_buff ** rx_skbuff;
  890. dma_addr_t rx_bd_dma_base;
  891. struct rxbd8 *rx_bd_base;
  892. struct rxbd8 *cur_rx;
  893. struct net_device *dev;
  894. struct gfar_priv_grp *grp;
  895. struct rx_q_stats stats;
  896. u16 skb_currx;
  897. u16 qindex;
  898. unsigned int rx_ring_size;
  899. /* RX Coalescing values */
  900. unsigned char rxcoalescing;
  901. unsigned long rxic;
  902. };
  903. /**
  904. * struct gfar_priv_grp - per group structure
  905. * @napi: the napi poll function
  906. * @priv: back pointer to the priv structure
  907. * @regs: the ioremapped register space for this group
  908. * @grp_id: group id for this group
  909. * @interruptTransmit: The TX interrupt number for this group
  910. * @interruptReceive: The RX interrupt number for this group
  911. * @interruptError: The ERROR interrupt number for this group
  912. * @int_name_tx: tx interrupt name for this group
  913. * @int_name_rx: rx interrupt name for this group
  914. * @int_name_er: er interrupt name for this group
  915. */
  916. struct gfar_priv_grp {
  917. spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES)));
  918. struct napi_struct napi;
  919. struct gfar_private *priv;
  920. struct gfar __iomem *regs;
  921. unsigned int grp_id;
  922. unsigned long rx_bit_map;
  923. unsigned long tx_bit_map;
  924. unsigned long num_tx_queues;
  925. unsigned long num_rx_queues;
  926. unsigned int rstat;
  927. unsigned int tstat;
  928. unsigned int imask;
  929. unsigned int ievent;
  930. unsigned int interruptTransmit;
  931. unsigned int interruptReceive;
  932. unsigned int interruptError;
  933. char int_name_tx[GFAR_INT_NAME_MAX];
  934. char int_name_rx[GFAR_INT_NAME_MAX];
  935. char int_name_er[GFAR_INT_NAME_MAX];
  936. };
  937. enum gfar_errata {
  938. GFAR_ERRATA_74 = 0x01,
  939. GFAR_ERRATA_76 = 0x02,
  940. GFAR_ERRATA_A002 = 0x04,
  941. GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */
  942. };
  943. /* Struct stolen almost completely (and shamelessly) from the FCC enet source
  944. * (Ok, that's not so true anymore, but there is a family resemblance)
  945. * The GFAR buffer descriptors track the ring buffers. The rx_bd_base
  946. * and tx_bd_base always point to the currently available buffer.
  947. * The dirty_tx tracks the current buffer that is being sent by the
  948. * controller. The cur_tx and dirty_tx are equal under both completely
  949. * empty and completely full conditions. The empty/ready indicator in
  950. * the buffer descriptor determines the actual condition.
  951. */
  952. struct gfar_private {
  953. /* Indicates how many tx, rx queues are enabled */
  954. unsigned int num_tx_queues;
  955. unsigned int num_rx_queues;
  956. unsigned int num_grps;
  957. unsigned int mode;
  958. /* The total tx and rx ring size for the enabled queues */
  959. unsigned int total_tx_ring_size;
  960. unsigned int total_rx_ring_size;
  961. struct device_node *node;
  962. struct net_device *ndev;
  963. struct platform_device *ofdev;
  964. enum gfar_errata errata;
  965. struct gfar_priv_grp gfargrp[MAXGROUPS];
  966. struct gfar_priv_tx_q *tx_queue[MAX_TX_QS];
  967. struct gfar_priv_rx_q *rx_queue[MAX_RX_QS];
  968. /* RX per device parameters */
  969. unsigned int rx_buffer_size;
  970. unsigned int rx_stash_size;
  971. unsigned int rx_stash_index;
  972. u32 cur_filer_idx;
  973. struct sk_buff_head rx_recycle;
  974. /* RX queue filer rule set*/
  975. struct ethtool_rx_list rx_list;
  976. struct mutex rx_queue_access;
  977. /* Hash registers and their width */
  978. u32 __iomem *hash_regs[16];
  979. int hash_width;
  980. /* global parameters */
  981. unsigned int fifo_threshold;
  982. unsigned int fifo_starve;
  983. unsigned int fifo_starve_off;
  984. /* Bitfield update lock */
  985. spinlock_t bflock;
  986. phy_interface_t interface;
  987. struct device_node *phy_node;
  988. struct device_node *tbi_node;
  989. u32 device_flags;
  990. unsigned char
  991. extended_hash:1,
  992. bd_stash_en:1,
  993. rx_filer_enable:1,
  994. wol_en:1; /* Wake-on-LAN enabled */
  995. unsigned short padding;
  996. /* PHY stuff */
  997. struct phy_device *phydev;
  998. struct mii_bus *mii_bus;
  999. int oldspeed;
  1000. int oldduplex;
  1001. int oldlink;
  1002. uint32_t msg_enable;
  1003. struct work_struct reset_task;
  1004. /* Network Statistics */
  1005. struct gfar_extra_stats extra_stats;
  1006. /* HW time stamping enabled flag */
  1007. int hwts_rx_en;
  1008. int hwts_tx_en;
  1009. /*Filer table*/
  1010. unsigned int ftp_rqfpr[MAX_FILER_IDX + 1];
  1011. unsigned int ftp_rqfcr[MAX_FILER_IDX + 1];
  1012. };
  1013. static inline int gfar_has_errata(struct gfar_private *priv,
  1014. enum gfar_errata err)
  1015. {
  1016. return priv->errata & err;
  1017. }
  1018. static inline u32 gfar_read(volatile unsigned __iomem *addr)
  1019. {
  1020. u32 val;
  1021. val = in_be32(addr);
  1022. return val;
  1023. }
  1024. static inline void gfar_write(volatile unsigned __iomem *addr, u32 val)
  1025. {
  1026. out_be32(addr, val);
  1027. }
  1028. static inline void gfar_write_filer(struct gfar_private *priv,
  1029. unsigned int far, unsigned int fcr, unsigned int fpr)
  1030. {
  1031. struct gfar __iomem *regs = priv->gfargrp[0].regs;
  1032. gfar_write(&regs->rqfar, far);
  1033. gfar_write(&regs->rqfcr, fcr);
  1034. gfar_write(&regs->rqfpr, fpr);
  1035. }
  1036. static inline void gfar_read_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. *fcr = gfar_read(&regs->rqfcr);
  1042. *fpr = gfar_read(&regs->rqfpr);
  1043. }
  1044. extern void lock_rx_qs(struct gfar_private *priv);
  1045. extern void lock_tx_qs(struct gfar_private *priv);
  1046. extern void unlock_rx_qs(struct gfar_private *priv);
  1047. extern void unlock_tx_qs(struct gfar_private *priv);
  1048. extern irqreturn_t gfar_receive(int irq, void *dev_id);
  1049. extern int startup_gfar(struct net_device *dev);
  1050. extern void stop_gfar(struct net_device *dev);
  1051. extern void gfar_halt(struct net_device *dev);
  1052. extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
  1053. int enable, u32 regnum, u32 read);
  1054. extern void gfar_configure_coalescing(struct gfar_private *priv,
  1055. unsigned long tx_mask, unsigned long rx_mask);
  1056. void gfar_init_sysfs(struct net_device *dev);
  1057. int gfar_set_features(struct net_device *dev, netdev_features_t features);
  1058. extern void gfar_check_rx_parser_mode(struct gfar_private *priv);
  1059. extern void gfar_vlan_mode(struct net_device *dev, netdev_features_t features);
  1060. extern const struct ethtool_ops gfar_ethtool_ops;
  1061. #define MAX_FILER_CACHE_IDX (2*(MAX_FILER_IDX))
  1062. #define RQFCR_PID_PRI_MASK 0xFFFFFFF8
  1063. #define RQFCR_PID_L4P_MASK 0xFFFFFF00
  1064. #define RQFCR_PID_VID_MASK 0xFFFFF000
  1065. #define RQFCR_PID_PORT_MASK 0xFFFF0000
  1066. #define RQFCR_PID_MAC_MASK 0xFF000000
  1067. struct gfar_mask_entry {
  1068. unsigned int mask; /* The mask value which is valid form start to end */
  1069. unsigned int start;
  1070. unsigned int end;
  1071. unsigned int block; /* Same block values indicate depended entries */
  1072. };
  1073. /* Represents a receive filer table entry */
  1074. struct gfar_filer_entry {
  1075. u32 ctrl;
  1076. u32 prop;
  1077. };
  1078. /* The 20 additional entries are a shadow for one extra element */
  1079. struct filer_table {
  1080. u32 index;
  1081. struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20];
  1082. };
  1083. /* The gianfar_ptp module will set this variable */
  1084. extern int gfar_phc_index;
  1085. #endif /* __GIANFAR_H */