uec.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. /*
  2. * Copyright (C) 2006 Freescale Semiconductor, Inc.
  3. *
  4. * Dave Liu <daveliu@freescale.com>
  5. * based on source code of Shlomi Gridish
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __UEC_H__
  23. #define __UEC_H__
  24. #define MAX_TX_THREADS 8
  25. #define MAX_RX_THREADS 8
  26. #define MAX_TX_QUEUES 8
  27. #define MAX_RX_QUEUES 8
  28. #define MAX_PREFETCHED_BDS 4
  29. #define MAX_IPH_OFFSET_ENTRY 8
  30. #define MAX_ENET_INIT_PARAM_ENTRIES_RX 9
  31. #define MAX_ENET_INIT_PARAM_ENTRIES_TX 8
  32. /* UEC UPSMR (Protocol Specific Mode Register)
  33. */
  34. #define UPSMR_ECM 0x04000000 /* Enable CAM Miss */
  35. #define UPSMR_HSE 0x02000000 /* Hardware Statistics Enable */
  36. #define UPSMR_PRO 0x00400000 /* Promiscuous */
  37. #define UPSMR_CAP 0x00200000 /* CAM polarity */
  38. #define UPSMR_RSH 0x00100000 /* Receive Short Frames */
  39. #define UPSMR_RPM 0x00080000 /* Reduced Pin Mode interfaces */
  40. #define UPSMR_R10M 0x00040000 /* RGMII/RMII 10 Mode */
  41. #define UPSMR_RLPB 0x00020000 /* RMII Loopback Mode */
  42. #define UPSMR_TBIM 0x00010000 /* Ten-bit Interface Mode */
  43. #define UPSMR_RMM 0x00001000 /* RMII/RGMII Mode */
  44. #define UPSMR_CAM 0x00000400 /* CAM Address Matching */
  45. #define UPSMR_BRO 0x00000200 /* Broadcast Address */
  46. #define UPSMR_RES1 0x00002000 /* Reserved feild - must be 1 */
  47. #define UPSMR_INIT_VALUE (UPSMR_HSE | UPSMR_RES1)
  48. /* UEC MACCFG1 (MAC Configuration 1 Register)
  49. */
  50. #define MACCFG1_FLOW_RX 0x00000020 /* Flow Control Rx */
  51. #define MACCFG1_FLOW_TX 0x00000010 /* Flow Control Tx */
  52. #define MACCFG1_ENABLE_SYNCHED_RX 0x00000008 /* Enable Rx Sync */
  53. #define MACCFG1_ENABLE_RX 0x00000004 /* Enable Rx */
  54. #define MACCFG1_ENABLE_SYNCHED_TX 0x00000002 /* Enable Tx Sync */
  55. #define MACCFG1_ENABLE_TX 0x00000001 /* Enable Tx */
  56. #define MACCFG1_INIT_VALUE (0)
  57. /* UEC MACCFG2 (MAC Configuration 2 Register)
  58. */
  59. #define MACCFG2_PREL 0x00007000
  60. #define MACCFG2_PREL_SHIFT (31 - 19)
  61. #define MACCFG2_PREL_MASK 0x0000f000
  62. #define MACCFG2_SRP 0x00000080
  63. #define MACCFG2_STP 0x00000040
  64. #define MACCFG2_RESERVED_1 0x00000020 /* must be set */
  65. #define MACCFG2_LC 0x00000010 /* Length Check */
  66. #define MACCFG2_MPE 0x00000008
  67. #define MACCFG2_FDX 0x00000001 /* Full Duplex */
  68. #define MACCFG2_FDX_MASK 0x00000001
  69. #define MACCFG2_PAD_CRC 0x00000004
  70. #define MACCFG2_CRC_EN 0x00000002
  71. #define MACCFG2_PAD_AND_CRC_MODE_NONE 0x00000000
  72. #define MACCFG2_PAD_AND_CRC_MODE_CRC_ONLY 0x00000002
  73. #define MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC 0x00000004
  74. #define MACCFG2_INTERFACE_MODE_NIBBLE 0x00000100
  75. #define MACCFG2_INTERFACE_MODE_BYTE 0x00000200
  76. #define MACCFG2_INTERFACE_MODE_MASK 0x00000300
  77. #define MACCFG2_INIT_VALUE (MACCFG2_PREL | MACCFG2_RESERVED_1 | \
  78. MACCFG2_LC | MACCFG2_PAD_CRC | MACCFG2_FDX)
  79. /* UEC Event Register
  80. */
  81. #define UCCE_MPD 0x80000000
  82. #define UCCE_SCAR 0x40000000
  83. #define UCCE_GRA 0x20000000
  84. #define UCCE_CBPR 0x10000000
  85. #define UCCE_BSY 0x08000000
  86. #define UCCE_RXC 0x04000000
  87. #define UCCE_TXC 0x02000000
  88. #define UCCE_TXE 0x01000000
  89. #define UCCE_TXB7 0x00800000
  90. #define UCCE_TXB6 0x00400000
  91. #define UCCE_TXB5 0x00200000
  92. #define UCCE_TXB4 0x00100000
  93. #define UCCE_TXB3 0x00080000
  94. #define UCCE_TXB2 0x00040000
  95. #define UCCE_TXB1 0x00020000
  96. #define UCCE_TXB0 0x00010000
  97. #define UCCE_RXB7 0x00008000
  98. #define UCCE_RXB6 0x00004000
  99. #define UCCE_RXB5 0x00002000
  100. #define UCCE_RXB4 0x00001000
  101. #define UCCE_RXB3 0x00000800
  102. #define UCCE_RXB2 0x00000400
  103. #define UCCE_RXB1 0x00000200
  104. #define UCCE_RXB0 0x00000100
  105. #define UCCE_RXF7 0x00000080
  106. #define UCCE_RXF6 0x00000040
  107. #define UCCE_RXF5 0x00000020
  108. #define UCCE_RXF4 0x00000010
  109. #define UCCE_RXF3 0x00000008
  110. #define UCCE_RXF2 0x00000004
  111. #define UCCE_RXF1 0x00000002
  112. #define UCCE_RXF0 0x00000001
  113. #define UCCE_TXB (UCCE_TXB7 | UCCE_TXB6 | UCCE_TXB5 | UCCE_TXB4 | \
  114. UCCE_TXB3 | UCCE_TXB2 | UCCE_TXB1 | UCCE_TXB0)
  115. #define UCCE_RXB (UCCE_RXB7 | UCCE_RXB6 | UCCE_RXB5 | UCCE_RXB4 | \
  116. UCCE_RXB3 | UCCE_RXB2 | UCCE_RXB1 | UCCE_RXB0)
  117. #define UCCE_RXF (UCCE_RXF7 | UCCE_RXF6 | UCCE_RXF5 | UCCE_RXF4 | \
  118. UCCE_RXF3 | UCCE_RXF2 | UCCE_RXF1 | UCCE_RXF0)
  119. #define UCCE_OTHER (UCCE_SCAR | UCCE_GRA | UCCE_CBPR | UCCE_BSY | \
  120. UCCE_RXC | UCCE_TXC | UCCE_TXE)
  121. /* UEC TEMODR Register
  122. */
  123. #define TEMODER_SCHEDULER_ENABLE 0x2000
  124. #define TEMODER_IP_CHECKSUM_GENERATE 0x0400
  125. #define TEMODER_PERFORMANCE_OPTIMIZATION_MODE1 0x0200
  126. #define TEMODER_RMON_STATISTICS 0x0100
  127. #define TEMODER_NUM_OF_QUEUES_SHIFT (15-15)
  128. #define TEMODER_INIT_VALUE 0xc000
  129. /* UEC REMODR Register
  130. */
  131. #define REMODER_RX_RMON_STATISTICS_ENABLE 0x00001000
  132. #define REMODER_RX_EXTENDED_FEATURES 0x80000000
  133. #define REMODER_VLAN_OPERATION_TAGGED_SHIFT (31-9 )
  134. #define REMODER_VLAN_OPERATION_NON_TAGGED_SHIFT (31-10)
  135. #define REMODER_RX_QOS_MODE_SHIFT (31-15)
  136. #define REMODER_RMON_STATISTICS 0x00001000
  137. #define REMODER_RX_EXTENDED_FILTERING 0x00000800
  138. #define REMODER_NUM_OF_QUEUES_SHIFT (31-23)
  139. #define REMODER_DYNAMIC_MAX_FRAME_LENGTH 0x00000008
  140. #define REMODER_DYNAMIC_MIN_FRAME_LENGTH 0x00000004
  141. #define REMODER_IP_CHECKSUM_CHECK 0x00000002
  142. #define REMODER_IP_ADDRESS_ALIGNMENT 0x00000001
  143. #define REMODER_INIT_VALUE 0
  144. /* BMRx - Bus Mode Register */
  145. #define BMR_GLB 0x20
  146. #define BMR_BO_BE 0x10
  147. #define BMR_DTB_SECONDARY_BUS 0x02
  148. #define BMR_BDB_SECONDARY_BUS 0x01
  149. #define BMR_SHIFT 24
  150. #define BMR_INIT_VALUE (BMR_GLB | BMR_BO_BE)
  151. /* UEC UCCS (Ethernet Status Register)
  152. */
  153. #define UCCS_BPR 0x02
  154. #define UCCS_PAU 0x02
  155. #define UCCS_MPD 0x01
  156. /* UEC MIIMCFG (MII Management Configuration Register)
  157. */
  158. #define MIIMCFG_RESET_MANAGEMENT 0x80000000
  159. #define MIIMCFG_NO_PREAMBLE 0x00000010
  160. #define MIIMCFG_CLOCK_DIVIDE_SHIFT (31 - 31)
  161. #define MIIMCFG_CLOCK_DIVIDE_MASK 0x0000000f
  162. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_4 0x00000001
  163. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_6 0x00000002
  164. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_8 0x00000003
  165. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_10 0x00000004
  166. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_14 0x00000005
  167. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_20 0x00000006
  168. #define MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_28 0x00000007
  169. #define MIIMCFG_MNGMNT_CLC_DIV_INIT_VALUE \
  170. MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_10
  171. /* UEC MIIMCOM (MII Management Command Register)
  172. */
  173. #define MIIMCOM_SCAN_CYCLE 0x00000002 /* Scan cycle */
  174. #define MIIMCOM_READ_CYCLE 0x00000001 /* Read cycle */
  175. /* UEC MIIMADD (MII Management Address Register)
  176. */
  177. #define MIIMADD_PHY_ADDRESS_SHIFT (31 - 23)
  178. #define MIIMADD_PHY_REGISTER_SHIFT (31 - 31)
  179. /* UEC MIIMCON (MII Management Control Register)
  180. */
  181. #define MIIMCON_PHY_CONTROL_SHIFT (31 - 31)
  182. #define MIIMCON_PHY_STATUS_SHIFT (31 - 31)
  183. /* UEC MIIMIND (MII Management Indicator Register)
  184. */
  185. #define MIIMIND_NOT_VALID 0x00000004
  186. #define MIIMIND_SCAN 0x00000002
  187. #define MIIMIND_BUSY 0x00000001
  188. /* UEC UTBIPAR (Ten Bit Interface Physical Address Register)
  189. */
  190. #define UTBIPAR_PHY_ADDRESS_SHIFT (31 - 31)
  191. #define UTBIPAR_PHY_ADDRESS_MASK 0x0000001f
  192. /* UEC UESCR (Ethernet Statistics Control Register)
  193. */
  194. #define UESCR_AUTOZ 0x8000
  195. #define UESCR_CLRCNT 0x4000
  196. #define UESCR_MAXCOV_SHIFT (15 - 7)
  197. #define UESCR_SCOV_SHIFT (15 - 15)
  198. /****** Tx data struct collection ******/
  199. /* Tx thread data, each Tx thread has one this struct.
  200. */
  201. typedef struct uec_thread_data_tx {
  202. u8 res0[136];
  203. } __attribute__ ((packed)) uec_thread_data_tx_t;
  204. /* Tx thread parameter, each Tx thread has one this struct.
  205. */
  206. typedef struct uec_thread_tx_pram {
  207. u8 res0[64];
  208. } __attribute__ ((packed)) uec_thread_tx_pram_t;
  209. /* Send queue queue-descriptor, each Tx queue has one this QD
  210. */
  211. typedef struct uec_send_queue_qd {
  212. u32 bd_ring_base; /* pointer to BD ring base address */
  213. u8 res0[0x8];
  214. u32 last_bd_completed_address; /* last entry in BD ring */
  215. u8 res1[0x30];
  216. } __attribute__ ((packed)) uec_send_queue_qd_t;
  217. /* Send queue memory region */
  218. typedef struct uec_send_queue_mem_region {
  219. uec_send_queue_qd_t sqqd[MAX_TX_QUEUES];
  220. } __attribute__ ((packed)) uec_send_queue_mem_region_t;
  221. /* Scheduler struct
  222. */
  223. typedef struct uec_scheduler {
  224. u16 cpucount0; /* CPU packet counter */
  225. u16 cpucount1; /* CPU packet counter */
  226. u16 cecount0; /* QE packet counter */
  227. u16 cecount1; /* QE packet counter */
  228. u16 cpucount2; /* CPU packet counter */
  229. u16 cpucount3; /* CPU packet counter */
  230. u16 cecount2; /* QE packet counter */
  231. u16 cecount3; /* QE packet counter */
  232. u16 cpucount4; /* CPU packet counter */
  233. u16 cpucount5; /* CPU packet counter */
  234. u16 cecount4; /* QE packet counter */
  235. u16 cecount5; /* QE packet counter */
  236. u16 cpucount6; /* CPU packet counter */
  237. u16 cpucount7; /* CPU packet counter */
  238. u16 cecount6; /* QE packet counter */
  239. u16 cecount7; /* QE packet counter */
  240. u32 weightstatus[MAX_TX_QUEUES]; /* accumulated weight factor */
  241. u32 rtsrshadow; /* temporary variable handled by QE */
  242. u32 time; /* temporary variable handled by QE */
  243. u32 ttl; /* temporary variable handled by QE */
  244. u32 mblinterval; /* max burst length interval */
  245. u16 nortsrbytetime; /* normalized value of byte time in tsr units */
  246. u8 fracsiz;
  247. u8 res0[1];
  248. u8 strictpriorityq; /* Strict Priority Mask register */
  249. u8 txasap; /* Transmit ASAP register */
  250. u8 extrabw; /* Extra BandWidth register */
  251. u8 oldwfqmask; /* temporary variable handled by QE */
  252. u8 weightfactor[MAX_TX_QUEUES]; /**< weight factor for queues */
  253. u32 minw; /* temporary variable handled by QE */
  254. u8 res1[0x70-0x64];
  255. } __attribute__ ((packed)) uec_scheduler_t;
  256. /* Tx firmware counters
  257. */
  258. typedef struct uec_tx_firmware_statistics_pram {
  259. u32 sicoltx; /* single collision */
  260. u32 mulcoltx; /* multiple collision */
  261. u32 latecoltxfr; /* late collision */
  262. u32 frabortduecol; /* frames aborted due to tx collision */
  263. u32 frlostinmactxer; /* frames lost due to internal MAC error tx */
  264. u32 carriersenseertx; /* carrier sense error */
  265. u32 frtxok; /* frames transmitted OK */
  266. u32 txfrexcessivedefer;
  267. u32 txpkts256; /* total packets(including bad) 256~511 B */
  268. u32 txpkts512; /* total packets(including bad) 512~1023B */
  269. u32 txpkts1024; /* total packets(including bad) 1024~1518B */
  270. u32 txpktsjumbo; /* total packets(including bad) >1024 */
  271. } __attribute__ ((packed)) uec_tx_firmware_statistics_pram_t;
  272. /* Tx global parameter table
  273. */
  274. typedef struct uec_tx_global_pram {
  275. u16 temoder;
  276. u8 res0[0x38-0x02];
  277. u32 sqptr;
  278. u32 schedulerbasepointer;
  279. u32 txrmonbaseptr;
  280. u32 tstate;
  281. u8 iphoffset[MAX_IPH_OFFSET_ENTRY];
  282. u32 vtagtable[0x8];
  283. u32 tqptr;
  284. u8 res2[0x80-0x74];
  285. } __attribute__ ((packed)) uec_tx_global_pram_t;
  286. /****** Rx data struct collection ******/
  287. /* Rx thread data, each Rx thread has one this struct.
  288. */
  289. typedef struct uec_thread_data_rx {
  290. u8 res0[40];
  291. } __attribute__ ((packed)) uec_thread_data_rx_t;
  292. /* Rx thread parameter, each Rx thread has one this struct.
  293. */
  294. typedef struct uec_thread_rx_pram {
  295. u8 res0[128];
  296. } __attribute__ ((packed)) uec_thread_rx_pram_t;
  297. /* Rx firmware counters
  298. */
  299. typedef struct uec_rx_firmware_statistics_pram {
  300. u32 frrxfcser; /* frames with crc error */
  301. u32 fraligner; /* frames with alignment error */
  302. u32 inrangelenrxer; /* in range length error */
  303. u32 outrangelenrxer; /* out of range length error */
  304. u32 frtoolong; /* frame too long */
  305. u32 runt; /* runt */
  306. u32 verylongevent; /* very long event */
  307. u32 symbolerror; /* symbol error */
  308. u32 dropbsy; /* drop because of BD not ready */
  309. u8 res0[0x8];
  310. u32 mismatchdrop; /* drop because of MAC filtering */
  311. u32 underpkts; /* total frames less than 64 octets */
  312. u32 pkts256; /* total frames(including bad)256~511 B */
  313. u32 pkts512; /* total frames(including bad)512~1023 B */
  314. u32 pkts1024; /* total frames(including bad)1024~1518 B */
  315. u32 pktsjumbo; /* total frames(including bad) >1024 B */
  316. u32 frlossinmacer;
  317. u32 pausefr; /* pause frames */
  318. u8 res1[0x4];
  319. u32 removevlan;
  320. u32 replacevlan;
  321. u32 insertvlan;
  322. } __attribute__ ((packed)) uec_rx_firmware_statistics_pram_t;
  323. /* Rx interrupt coalescing entry, each Rx queue has one this entry.
  324. */
  325. typedef struct uec_rx_interrupt_coalescing_entry {
  326. u32 maxvalue;
  327. u32 counter;
  328. } __attribute__ ((packed)) uec_rx_interrupt_coalescing_entry_t;
  329. typedef struct uec_rx_interrupt_coalescing_table {
  330. uec_rx_interrupt_coalescing_entry_t entry[MAX_RX_QUEUES];
  331. } __attribute__ ((packed)) uec_rx_interrupt_coalescing_table_t;
  332. /* RxBD queue entry, each Rx queue has one this entry.
  333. */
  334. typedef struct uec_rx_bd_queues_entry {
  335. u32 bdbaseptr; /* BD base pointer */
  336. u32 bdptr; /* BD pointer */
  337. u32 externalbdbaseptr; /* external BD base pointer */
  338. u32 externalbdptr; /* external BD pointer */
  339. } __attribute__ ((packed)) uec_rx_bd_queues_entry_t;
  340. /* Rx global paramter table
  341. */
  342. typedef struct uec_rx_global_pram {
  343. u32 remoder; /* ethernet mode reg. */
  344. u32 rqptr; /* base pointer to the Rx Queues */
  345. u32 res0[0x1];
  346. u8 res1[0x20-0xC];
  347. u16 typeorlen;
  348. u8 res2[0x1];
  349. u8 rxgstpack; /* ack on GRACEFUL STOP RX command */
  350. u32 rxrmonbaseptr; /* Rx RMON statistics base */
  351. u8 res3[0x30-0x28];
  352. u32 intcoalescingptr; /* Interrupt coalescing table pointer */
  353. u8 res4[0x36-0x34];
  354. u8 rstate;
  355. u8 res5[0x46-0x37];
  356. u16 mrblr; /* max receive buffer length reg. */
  357. u32 rbdqptr; /* RxBD parameter table description */
  358. u16 mflr; /* max frame length reg. */
  359. u16 minflr; /* min frame length reg. */
  360. u16 maxd1; /* max dma1 length reg. */
  361. u16 maxd2; /* max dma2 length reg. */
  362. u32 ecamptr; /* external CAM address */
  363. u32 l2qt; /* VLAN priority mapping table. */
  364. u32 l3qt[0x8]; /* IP priority mapping table. */
  365. u16 vlantype; /* vlan type */
  366. u16 vlantci; /* default vlan tci */
  367. u8 addressfiltering[64];/* address filtering data structure */
  368. u32 exfGlobalParam; /* extended filtering global parameters */
  369. u8 res6[0x100-0xC4]; /* Initialize to zero */
  370. } __attribute__ ((packed)) uec_rx_global_pram_t;
  371. #define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01
  372. /****** UEC common ******/
  373. /* UCC statistics - hardware counters
  374. */
  375. typedef struct uec_hardware_statistics {
  376. u32 tx64;
  377. u32 tx127;
  378. u32 tx255;
  379. u32 rx64;
  380. u32 rx127;
  381. u32 rx255;
  382. u32 txok;
  383. u16 txcf;
  384. u32 tmca;
  385. u32 tbca;
  386. u32 rxfok;
  387. u32 rxbok;
  388. u32 rbyt;
  389. u32 rmca;
  390. u32 rbca;
  391. } __attribute__ ((packed)) uec_hardware_statistics_t;
  392. /* InitEnet command parameter
  393. */
  394. typedef struct uec_init_cmd_pram {
  395. u8 resinit0;
  396. u8 resinit1;
  397. u8 resinit2;
  398. u8 resinit3;
  399. u16 resinit4;
  400. u8 res1[0x1];
  401. u8 largestexternallookupkeysize;
  402. u32 rgftgfrxglobal;
  403. u32 rxthread[MAX_ENET_INIT_PARAM_ENTRIES_RX]; /* rx threads */
  404. u8 res2[0x38 - 0x30];
  405. u32 txglobal; /* tx global */
  406. u32 txthread[MAX_ENET_INIT_PARAM_ENTRIES_TX]; /* tx threads */
  407. u8 res3[0x1];
  408. } __attribute__ ((packed)) uec_init_cmd_pram_t;
  409. #define ENET_INIT_PARAM_RGF_SHIFT (32 - 4)
  410. #define ENET_INIT_PARAM_TGF_SHIFT (32 - 8)
  411. #define ENET_INIT_PARAM_RISC_MASK 0x0000003f
  412. #define ENET_INIT_PARAM_PTR_MASK 0x00ffffc0
  413. #define ENET_INIT_PARAM_SNUM_MASK 0xff000000
  414. #define ENET_INIT_PARAM_SNUM_SHIFT 24
  415. #define ENET_INIT_PARAM_MAGIC_RES_INIT0 0x06
  416. #define ENET_INIT_PARAM_MAGIC_RES_INIT1 0x30
  417. #define ENET_INIT_PARAM_MAGIC_RES_INIT2 0xff
  418. #define ENET_INIT_PARAM_MAGIC_RES_INIT3 0x00
  419. #define ENET_INIT_PARAM_MAGIC_RES_INIT4 0x0400
  420. /* structure representing 82xx Address Filtering Enet Address in PRAM
  421. */
  422. typedef struct uec_82xx_enet_address {
  423. u8 res1[0x2];
  424. u16 h; /* address (MSB) */
  425. u16 m; /* address */
  426. u16 l; /* address (LSB) */
  427. } __attribute__ ((packed)) uec_82xx_enet_address_t;
  428. /* structure representing 82xx Address Filtering PRAM
  429. */
  430. typedef struct uec_82xx_address_filtering_pram {
  431. u32 iaddr_h; /* individual address filter, high */
  432. u32 iaddr_l; /* individual address filter, low */
  433. u32 gaddr_h; /* group address filter, high */
  434. u32 gaddr_l; /* group address filter, low */
  435. uec_82xx_enet_address_t taddr;
  436. uec_82xx_enet_address_t paddr[4];
  437. u8 res0[0x40-0x38];
  438. } __attribute__ ((packed)) uec_82xx_address_filtering_pram_t;
  439. /* Buffer Descriptor
  440. */
  441. typedef struct buffer_descriptor {
  442. u16 status;
  443. u16 len;
  444. u32 data;
  445. } __attribute__ ((packed)) qe_bd_t, *p_bd_t;
  446. #define SIZEOFBD sizeof(qe_bd_t)
  447. /* Common BD flags
  448. */
  449. #define BD_WRAP 0x2000
  450. #define BD_INT 0x1000
  451. #define BD_LAST 0x0800
  452. #define BD_CLEAN 0x3000
  453. /* TxBD status flags
  454. */
  455. #define TxBD_READY 0x8000
  456. #define TxBD_PADCRC 0x4000
  457. #define TxBD_WRAP BD_WRAP
  458. #define TxBD_INT BD_INT
  459. #define TxBD_LAST BD_LAST
  460. #define TxBD_TXCRC 0x0400
  461. #define TxBD_DEF 0x0200
  462. #define TxBD_PP 0x0100
  463. #define TxBD_LC 0x0080
  464. #define TxBD_RL 0x0040
  465. #define TxBD_RC 0x003C
  466. #define TxBD_UNDERRUN 0x0002
  467. #define TxBD_TRUNC 0x0001
  468. #define TxBD_ERROR (TxBD_UNDERRUN | TxBD_TRUNC)
  469. /* RxBD status flags
  470. */
  471. #define RxBD_EMPTY 0x8000
  472. #define RxBD_OWNER 0x4000
  473. #define RxBD_WRAP BD_WRAP
  474. #define RxBD_INT BD_INT
  475. #define RxBD_LAST BD_LAST
  476. #define RxBD_FIRST 0x0400
  477. #define RxBD_CMR 0x0200
  478. #define RxBD_MISS 0x0100
  479. #define RxBD_BCAST 0x0080
  480. #define RxBD_MCAST 0x0040
  481. #define RxBD_LG 0x0020
  482. #define RxBD_NO 0x0010
  483. #define RxBD_SHORT 0x0008
  484. #define RxBD_CRCERR 0x0004
  485. #define RxBD_OVERRUN 0x0002
  486. #define RxBD_IPCH 0x0001
  487. #define RxBD_ERROR (RxBD_LG | RxBD_NO | RxBD_SHORT | \
  488. RxBD_CRCERR | RxBD_OVERRUN)
  489. /* BD access macros
  490. */
  491. #define BD_STATUS(_bd) (((p_bd_t)(_bd))->status)
  492. #define BD_STATUS_SET(_bd, _val) (((p_bd_t)(_bd))->status = _val)
  493. #define BD_LENGTH(_bd) (((p_bd_t)(_bd))->len)
  494. #define BD_LENGTH_SET(_bd, _val) (((p_bd_t)(_bd))->len = _val)
  495. #define BD_DATA_CLEAR(_bd) (((p_bd_t)(_bd))->data = 0)
  496. #define BD_IS_DATA(_bd) (((p_bd_t)(_bd))->data)
  497. #define BD_DATA(_bd) ((u8 *)(((p_bd_t)(_bd))->data))
  498. #define BD_DATA_SET(_bd, _data) (((p_bd_t)(_bd))->data = (u32)(_data))
  499. #define BD_ADVANCE(_bd,_status,_base) \
  500. (((_status) & BD_WRAP) ? (_bd) = ((p_bd_t)(_base)) : ++(_bd))
  501. /* Rx Prefetched BDs
  502. */
  503. typedef struct uec_rx_prefetched_bds {
  504. qe_bd_t bd[MAX_PREFETCHED_BDS]; /* prefetched bd */
  505. } __attribute__ ((packed)) uec_rx_prefetched_bds_t;
  506. /* Alignments
  507. */
  508. #define UEC_RX_GLOBAL_PRAM_ALIGNMENT 64
  509. #define UEC_TX_GLOBAL_PRAM_ALIGNMENT 64
  510. #define UEC_THREAD_RX_PRAM_ALIGNMENT 128
  511. #define UEC_THREAD_TX_PRAM_ALIGNMENT 64
  512. #define UEC_THREAD_DATA_ALIGNMENT 256
  513. #define UEC_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT 32
  514. #define UEC_SCHEDULER_ALIGNMENT 4
  515. #define UEC_TX_STATISTICS_ALIGNMENT 4
  516. #define UEC_RX_STATISTICS_ALIGNMENT 4
  517. #define UEC_RX_INTERRUPT_COALESCING_ALIGNMENT 4
  518. #define UEC_RX_BD_QUEUES_ALIGNMENT 8
  519. #define UEC_RX_PREFETCHED_BDS_ALIGNMENT 128
  520. #define UEC_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT 4
  521. #define UEC_RX_BD_RING_ALIGNMENT 32
  522. #define UEC_TX_BD_RING_ALIGNMENT 32
  523. #define UEC_MRBLR_ALIGNMENT 128
  524. #define UEC_RX_BD_RING_SIZE_ALIGNMENT 4
  525. #define UEC_TX_BD_RING_SIZE_MEMORY_ALIGNMENT 32
  526. #define UEC_RX_DATA_BUF_ALIGNMENT 64
  527. #define UEC_VLAN_PRIORITY_MAX 8
  528. #define UEC_IP_PRIORITY_MAX 64
  529. #define UEC_TX_VTAG_TABLE_ENTRY_MAX 8
  530. #define UEC_RX_BD_RING_SIZE_MIN 8
  531. #define UEC_TX_BD_RING_SIZE_MIN 2
  532. /* Ethernet speed
  533. */
  534. typedef enum enet_speed {
  535. ENET_SPEED_10BT, /* 10 Base T */
  536. ENET_SPEED_100BT, /* 100 Base T */
  537. ENET_SPEED_1000BT /* 1000 Base T */
  538. } enet_speed_e;
  539. /* Ethernet Address Type.
  540. */
  541. typedef enum enet_addr_type {
  542. ENET_ADDR_TYPE_INDIVIDUAL,
  543. ENET_ADDR_TYPE_GROUP,
  544. ENET_ADDR_TYPE_BROADCAST
  545. } enet_addr_type_e;
  546. /* TBI / MII Set Register
  547. */
  548. typedef enum enet_tbi_mii_reg {
  549. ENET_TBI_MII_CR = 0x00,
  550. ENET_TBI_MII_SR = 0x01,
  551. ENET_TBI_MII_ANA = 0x04,
  552. ENET_TBI_MII_ANLPBPA = 0x05,
  553. ENET_TBI_MII_ANEX = 0x06,
  554. ENET_TBI_MII_ANNPT = 0x07,
  555. ENET_TBI_MII_ANLPANP = 0x08,
  556. ENET_TBI_MII_EXST = 0x0F,
  557. ENET_TBI_MII_JD = 0x10,
  558. ENET_TBI_MII_TBICON = 0x11
  559. } enet_tbi_mii_reg_e;
  560. /* UEC number of threads
  561. */
  562. typedef enum uec_num_of_threads {
  563. UEC_NUM_OF_THREADS_1 = 0x1, /* 1 */
  564. UEC_NUM_OF_THREADS_2 = 0x2, /* 2 */
  565. UEC_NUM_OF_THREADS_4 = 0x0, /* 4 */
  566. UEC_NUM_OF_THREADS_6 = 0x3, /* 6 */
  567. UEC_NUM_OF_THREADS_8 = 0x4 /* 8 */
  568. } uec_num_of_threads_e;
  569. /* UEC ethernet interface type
  570. */
  571. typedef enum enet_interface {
  572. ENET_10_MII,
  573. ENET_10_RMII,
  574. ENET_10_RGMII,
  575. ENET_100_MII,
  576. ENET_100_RMII,
  577. ENET_100_RGMII,
  578. ENET_1000_GMII,
  579. ENET_1000_RGMII,
  580. ENET_1000_RGMII_ID,
  581. ENET_1000_RGMII_RXID,
  582. ENET_1000_TBI,
  583. ENET_1000_RTBI
  584. } enet_interface_e;
  585. /* UEC initialization info struct
  586. */
  587. typedef struct uec_info {
  588. ucc_fast_info_t uf_info;
  589. uec_num_of_threads_e num_threads_tx;
  590. uec_num_of_threads_e num_threads_rx;
  591. qe_risc_allocation_e risc_tx;
  592. qe_risc_allocation_e risc_rx;
  593. u16 rx_bd_ring_len;
  594. u16 tx_bd_ring_len;
  595. u8 phy_address;
  596. enet_interface_e enet_interface;
  597. } uec_info_t;
  598. /* UEC driver initialized info
  599. */
  600. #define MAX_RXBUF_LEN 1536
  601. #define MAX_FRAME_LEN 1518
  602. #define MIN_FRAME_LEN 64
  603. #define MAX_DMA1_LEN 1520
  604. #define MAX_DMA2_LEN 1520
  605. /* UEC driver private struct
  606. */
  607. typedef struct uec_private {
  608. uec_info_t *uec_info;
  609. ucc_fast_private_t *uccf;
  610. struct eth_device *dev;
  611. uec_t *uec_regs;
  612. uec_mii_t *uec_mii_regs;
  613. /* enet init command parameter */
  614. uec_init_cmd_pram_t *p_init_enet_param;
  615. u32 init_enet_param_offset;
  616. /* Rx and Tx paramter */
  617. uec_rx_global_pram_t *p_rx_glbl_pram;
  618. u32 rx_glbl_pram_offset;
  619. uec_tx_global_pram_t *p_tx_glbl_pram;
  620. u32 tx_glbl_pram_offset;
  621. uec_send_queue_mem_region_t *p_send_q_mem_reg;
  622. u32 send_q_mem_reg_offset;
  623. uec_thread_data_tx_t *p_thread_data_tx;
  624. u32 thread_dat_tx_offset;
  625. uec_thread_data_rx_t *p_thread_data_rx;
  626. u32 thread_dat_rx_offset;
  627. uec_rx_bd_queues_entry_t *p_rx_bd_qs_tbl;
  628. u32 rx_bd_qs_tbl_offset;
  629. /* BDs specific */
  630. u8 *p_tx_bd_ring;
  631. u32 tx_bd_ring_offset;
  632. u8 *p_rx_bd_ring;
  633. u32 rx_bd_ring_offset;
  634. u8 *p_rx_buf;
  635. u32 rx_buf_offset;
  636. volatile qe_bd_t *txBd;
  637. volatile qe_bd_t *rxBd;
  638. /* Status */
  639. int mac_tx_enabled;
  640. int mac_rx_enabled;
  641. int grace_stopped_tx;
  642. int grace_stopped_rx;
  643. int the_first_run;
  644. /* PHY specific */
  645. struct uec_mii_info *mii_info;
  646. int oldspeed;
  647. int oldduplex;
  648. int oldlink;
  649. } uec_private_t;
  650. #endif /* __UEC_H__ */