tc956xmac.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /*
  2. * TC956X ethernet driver.
  3. *
  4. * tc956xmac.h
  5. *
  6. * Copyright (C) 2007-2009 STMicroelectronics Ltd
  7. * Copyright (C) 2023 Toshiba Electronic Devices & Storage Corporation
  8. *
  9. * This file has been derived from the STMicro Linux driver,
  10. * and developed or modified for TC956X.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2, or (at your option)
  15. * any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25. */
  26. /*! History:
  27. * 20 Jan 2021 : Initial Version
  28. * VERSION : 00-01
  29. *
  30. * 15 Mar 2021 : Base lined
  31. * VERSION : 01-00
  32. *
  33. * 05 Jul 2021 : 1. Used Systick handler instead of Driver kernel timer to process transmitted Tx descriptors.
  34. * 2. XFI interface support and module parameters for selection of Port0 and Port1 interface
  35. * VERSION : 01-00-01
  36. * 15 Jul 2021 : 1. USXGMII/XFI/SGMII/RGMII interface supported without module parameter
  37. * VERSION : 01-00-02
  38. * 20 Jul 2021 : 1. Version update
  39. * 2. Default Port1 interface selected as SGMII
  40. * VERSION : 01-00-03
  41. * 22 Jul 2021 : 1. Version update
  42. * 2. USXGMII/XFI/SGMII/RGMII interface supported with module parameters
  43. * VERSION : 01-00-04
  44. * 22 Jul 2021 : 1. Dynamic CM3 TAMAP configuration
  45. * VERSION : 01-00-05
  46. * 23 Jul 2021 : 1. Add support for contiguous allocation of memory
  47. * VERSION : 01-00-06
  48. * 29 Jul 2021 : 1. Add support to set MAC Address register
  49. * VERSION : 01-00-07
  50. * 05 Aug 2021 : 1. Store and use Port0 pci_dev for all DMA allocation/mapping for IPA path
  51. * : 2. Register Port0 as only PCIe device, incase its PHY is not found
  52. * VERSION : 01-00-08
  53. * 16 Aug 2021 : 1. PHY interrupt mode supported through .config_intr and .ack_interrupt API
  54. * VERSION : 01-00-09
  55. * 24 Aug 2021 : 1. Disable TC956X_PCIE_GEN3_SETTING and TC956X_LOAD_FW_HEADER macros and provide support via Makefile
  56. * : 2. Platform API supported
  57. * VERSION : 01-00-10
  58. * 02 Sep 2021 : 1. Configuration of Link state L0 and L1 transaction delay for PCIe switch ports & Endpoint.
  59. * VERSION : 01-00-11
  60. * 09 Sep 2021 : Reverted changes related to usage of Port-0 pci_dev for all DMA allocation/mapping for IPA path
  61. * VERSION : 01-00-12
  62. * 14 Sep 2021 : 1. Version update
  63. * VERSION : 01-00-13
  64. * 23 Sep 2021 : 1. Version update
  65. * VERSION : 01-00-14
  66. * 29 Sep 2021 : 1. Version update
  67. * VERSION : 01-00-15
  68. * 14 Oct 2021 : 1. Version update
  69. * VERSION : 01-00-16
  70. * 19 Oct 2021 : 1. Adding M3 SRAM Debug counters to ethtool statistics
  71. * : 2. Adding MTL RX Overflow/packet miss count, TX underflow counts,Rx Watchdog value to ethtool statistics.
  72. * : 3. Version update
  73. * VERSION : 01-00-17
  74. * 21 Oct 2021 : 1. Added support for GPIO configuration API
  75. * : 2. Version update
  76. * VERSION : 01-00-18
  77. * 26 Oct 2021 : 1. Updated Driver Module Version.
  78. : 2. Added variable for port-wise suspend status.
  79. : 3. Added macro to control EEE MAC Control.
  80. * VERSION : 01-00-19
  81. * 04 Nov 2021 : 1. Version update
  82. * VERSION : 01-00-20
  83. * 08 Nov 2021 : 1. Version update
  84. * VERSION : 01-00-21
  85. * 24 Nov 2021 : 1. Version update
  86. 2. Private member used instead of global for wol interrupt indication
  87. * VERSION : 01-00-22
  88. * 24 Nov 2021 : 1. Version update
  89. * VERSION : 01-00-23
  90. * 24 Nov 2021 : 1. EEE macro enabled by default.
  91. 2. Module param support for EEE configuration
  92. 3. Version update
  93. * VERSION : 01-00-24
  94. * 30 Nov 2021 : 1. Version update
  95. * VERSION : 01-00-25
  96. * 30 Nov 2021 : 1. Version update
  97. * VERSION : 01-00-26
  98. * 01 Dec 2021 : 1. Version update
  99. * VERSION : 01-00-27
  100. * 01 Dec 2021 : 1. Version update
  101. * VERSION : 01-00-28
  102. * 03 Dec 2021 : 1. Version update
  103. * VERSION : 01-00-29
  104. * 08 Dec 2021 : 1. Version update
  105. * VERSION : 01-00-30
  106. * 10 Dec 2021 : 1. Version update
  107. * VERSION : 01-00-31
  108. * 27 Dec 2021 : 1. Support for eMAC Reset and unused clock disable during Suspend and restoring it back during resume.
  109. 2. Version update.
  110. * VERSION : 01-00-32
  111. * 06 Jan 2022 : 1. Version update
  112. * VERSION : 01-00-33
  113. * 07 Jan 2022 : 1. Version update
  114. * VERSION : 01-00-34
  115. * 11 Jan 2022 : 1. Version update
  116. * VERSION : 01-00-35
  117. * 18 Jan 2022 : 1. IRQ device name change
  118. * 2. Version update
  119. * VERSION : 01-00-36
  120. * 20 Jan 2022 : 1. Version update
  121. * VERSION : 01-00-37
  122. * 24 Jan 2022 : 1. Version update
  123. * VERSION : 01-00-38
  124. * 31 Jan 2022 : 1. Debug dump API and structures added to dump registers during crash.
  125. * 2. Version update.
  126. * VERSION : 01-00-39
  127. * 02 Feb 2022 : 1. Version update
  128. * VERSION : 01-00-40
  129. * 04 Feb 2022 : 1. Version update
  130. * VERSION : 01-00-41
  131. * 14 Feb 2022 : 1. Reset assert and clock disable support during Link Down.
  132. * 2. Version update.
  133. * VERSION : 01-00-42
  134. * 22 Feb 2022 : 1. Supported GPIO configuration save and restoration
  135. * 2. Version update.
  136. * VERSION : 01-00-43
  137. * 25 Feb 2022 : 1. Version update.
  138. * VERSION : 01-00-44
  139. * 09 Mar 2022 : 1. Version update
  140. * VERSION : 01-00-45
  141. * 22 Mar 2022 : 1. Version update
  142. * VERSION : 01-00-46
  143. * 05 Apr 2022 : 1. Version update
  144. * VERSION : 01-00-47
  145. * 06 Apr 2022 : 1. Version update
  146. * VERSION : 01-00-48
  147. * 14 Apr 2022 : 1. Version update
  148. * VERSION : 01-00-49
  149. * 25 Apr 2022 : 1. Version update
  150. * VERSION : 01-00-50
  151. * 29 Apr 2022 : 1. Added variable for tracking port release status and Lock for syncing linkdown, port rlease and release of offloaded DMA channels
  152. * 2. Version update.
  153. * VERSION : 01-00-51
  154. * 15 Jun 2022 : 1. Added debugfs support for module specific register dump
  155. * 2. Version update.
  156. * VERSION : 01-00-52
  157. * 08 Aug 2022 : 1. Version update
  158. * VERSION : 01-00-53
  159. * 31 Aug 2022 : 1. Added Fix for configuring Rx Parser when EEE is enabled and RGMII Interface is used
  160. * 2. Version update.
  161. * VERSION : 01-00-54
  162. * 02 Sep 2022 : 1. 2500Base-X support for line speeds 2.5Gbps, 1Gbps, 100Mbps.
  163. * 2. Version update
  164. * VERSION : 01-00-55
  165. * 21 Oct 2022 : 1. Version update
  166. * VERSION : 01-00-56
  167. * 09 Nov 2022 : 1. Version update
  168. * VERSION : 01-00-57
  169. * 22 Dec 2022 : 1. Support for SW reset during link down.
  170. * 2. Version update
  171. * VERSION : 01-00-58
  172. * 09 May 2023 : 1. Version update
  173. * VERSION : 01-00-59
  174. * 10 Nov 2023 : 1. DSP Cascade related modifications
  175. * 2. Kernel 6.1 Porting changes
  176. * 3. Version update
  177. * VERSION : 01-02-59
  178. *
  179. * 26 Dec 2023 : 1. Kernel 6.6 Porting changes
  180. * 2. Added the support for TC commands taprio and flower
  181. * 3. Version update
  182. * VERSION : 01-03-59
  183. */
  184. #ifndef __TC956XMAC_H__
  185. #define __TC956XMAC_H__
  186. #include <linux/clk.h>
  187. #include <linux/if_vlan.h>
  188. #include "tc956xmac_inc.h"
  189. #ifndef TC956X_SRIOV_VF
  190. #include <linux/phylink.h>
  191. #endif
  192. #include <linux/pci.h>
  193. #include "common.h"
  194. #include <linux/ptp_clock_kernel.h>
  195. #include <linux/net_tstamp.h>
  196. #include <linux/reset.h>
  197. #include <linux/version.h>
  198. #if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0))
  199. #include <net/page_pool.h>
  200. #else
  201. #include <net/page_pool/helpers.h>
  202. #endif
  203. #ifdef TC956X_SRIOV_PF
  204. #include "tc956x_pf_rsc_mng.h"
  205. #endif
  206. #ifndef TC956X_SRIOV_VF
  207. //#define TC956X_LOAD_FW_HEADER
  208. #endif
  209. #define PF_DRIVER 4
  210. /* Uncomment EEE_MAC_CONTROLLED_MODE macro for MAC controlled EEE Mode & comment for PHY controlled EEE mode */
  211. #define EEE_MAC_CONTROLLED_MODE
  212. /* Uncomment TC956X_5_G_2_5_G_EEE_SUPPORT macro for enabling EEE support for 5G and 2.5G */
  213. #define TC956X_5_G_2_5_G_EEE_SUPPORT
  214. // #define CONFIG_TC956XMAC_SELFTESTS /*Enable this macro to test Feature selftest*/
  215. #ifdef TC956X
  216. #define VENDOR_ID 0x1179
  217. #ifndef TC956X_SRIOV_VF
  218. #define DEVICE_ID 0x0220 /* PF - 0x0220, VF - 0x0221 */
  219. #elif (defined TC956X_SRIOV_VF)
  220. #define DEVICE_ID 0x0221 /* PF - 0x0220, VF - 0x0221 */
  221. #endif
  222. #endif
  223. #define SUB_SYS_VENDOR_ID 0x1179
  224. #define SUB_SYS_DEVICE_ID 0x0001
  225. #define PCI_ETHC_CLASS_CODE 0x020000
  226. #define PCI_ETHC_CLASS_MASK 0xFFFFFF
  227. #define MOD_PARAM_ACCESS 0444
  228. #define TC956X_PCI_DMA_WIDTH 64
  229. #define TC956X_TX_QUEUES 8
  230. #define TC956X_RX_QUEUES 8
  231. #ifndef FIRMWARE_NAME
  232. #define FIRMWARE_NAME "TC956X_Firmware_PCIeBridge.bin"
  233. #endif
  234. #define TC956X_TOTAL_VFS 3
  235. #ifdef TC956X
  236. #ifndef TC956X_SRIOV_VF
  237. #define TC956X_RESOURCE_NAME "tc956x_pci-eth"
  238. #define IRQ_DEV_NAME(x) (((x) == RM_PF0_ID) ? ("eth0") : ("eth1"))
  239. #define WOL_IRQ_DEV_NAME(x) (((x) == RM_PF0_ID) ? ("eth0_wol") : ("eth1_wol"))
  240. #define DRV_MODULE_VERSION "V_01-03-59"
  241. #define TC956X_FW_MAX_SIZE (64*1024)
  242. #elif (defined TC956X_SRIOV_VF)
  243. #define TC956X_RESOURCE_NAME "tc956x_vf_pci-eth"
  244. #define DRV_MODULE_VERSION "V_01-01-59"
  245. #endif
  246. #define ATR_AXI4_SLV_BASE 0x0800
  247. #define ATR_AXI4_SLAVE_OFFSET 0x0100
  248. #define ATR_AXI4_TABLE_OFFSET 0x20
  249. #define TC956X_AXI4_SLV(ch, tid) (ATR_AXI4_SLV_BASE +\
  250. (ch * ATR_AXI4_SLAVE_OFFSET) +\
  251. (tid * ATR_AXI4_TABLE_OFFSET))
  252. #define SRC_ADDR_LO_OFFSET 0x00
  253. #define SRC_ADDR_HI_OFFSET 0x04
  254. #define TRSL_ADDR_LO_OFFSET 0x08
  255. #define TRSL_ADDR_HI_OFFSET 0x0C
  256. #define TRSL_PARAM_OFFSET 0x10
  257. #define TRSL_MASK_OFFSET1 0x18
  258. #define TRSL_MASK_OFFSET2 0x1C
  259. #define TC956X_AXI4_SLV_SRC_ADDR_LO(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  260. SRC_ADDR_LO_OFFSET)
  261. #define TC956X_AXI4_SLV_SRC_ADDR_HI(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  262. SRC_ADDR_HI_OFFSET)
  263. #define TC956X_AXI4_SLV_TRSL_ADDR_LO(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  264. TRSL_ADDR_LO_OFFSET)
  265. #define TC956X_AXI4_SLV_TRSL_ADDR_HI(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  266. TRSL_ADDR_HI_OFFSET)
  267. #define TC956X_AXI4_SLV_TRSL_PARAM(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  268. TRSL_PARAM_OFFSET)
  269. #define TC956X_AXI4_SLV_TRSL_MASK1(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  270. TRSL_MASK_OFFSET1)
  271. #define TC956X_AXI4_SLV_TRSL_MASK2(ch, tid) (TC956X_AXI4_SLV(ch, tid) +\
  272. TRSL_MASK_OFFSET2)
  273. #define TC956X_ATR_IMPL 1U
  274. #define TC956X_ATR_SIZE(size) ((size - 1U) << 1U)
  275. #define TC956X_ATR_SIZE_MASK GENMASK(6, 1)
  276. #define TC956x_ATR_SIZE_SHIFT 1
  277. #define TC956X_SRC_LO_MASK GENMASK(31, 12)
  278. #define TC956X_SRC_LO_SHIFT 12
  279. #define TC956X_AXI4_SLV00_ATR_SIZE 36U
  280. #define TC956X_AXI4_SLV00_SRC_ADDR_LO_VAL (0x00000000U)
  281. #define TC956X_AXI4_SLV00_SRC_ADDR_HI_VAL (0x00000010U)
  282. #define TC956X_AXI4_SLV00_TRSL_ADDR_LO_VAL (0x00000000U)
  283. #define TC956X_AXI4_SLV00_TRSL_ADDR_HI_VAL (0x00000000U)
  284. #define TC956X_AXI4_SLV00_TRSL_PARAM_VAL (0x00000000U)
  285. #define TC956X_AXI4_SLV00_SRC_ADDR_LO_VAL_DEFAULT (0x0000007FU)
  286. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  287. #define TC956X_AXI4_SLV01_ATR_SIZE 28U /* 28 bit DMA Mask */
  288. #define TC956X_AXI4_SLV01_SRC_ADDR_LO_VAL (0x60000000U)
  289. #define TC956X_AXI4_SLV01_SRC_ADDR_HI_VAL (0x00000000U)
  290. #define TC956X_AXI4_SLV01_TRSL_ADDR_LO_VAL (0x00000000U)
  291. #define TC956X_AXI4_SLV01_TRSL_ADDR_HI_VAL (0x00000000U)
  292. #define TC956X_AXI4_SLV01_TRSL_PARAM_VAL (0x00000000U)
  293. #endif
  294. #define TC956X_M3_SRAM_FW_VER_OFFSET 0x4F900 /* DMEM addrs 0x2000F900 */
  295. /* M3 Debug Counters in SRAM*/
  296. #define TC956X_M3_SRAM_DEBUG_CNTS_OFFSET 0x4F800 /* DMEM addrs 0x2000F800 */
  297. #define DB_CNT_LEN 4 /* Size of each debug counter in bytes */
  298. #define DB_CNT0 0 /* reserved0 */
  299. #define DB_CNT1 1 /* reserved1 */
  300. #define DB_CNT2 2 /* reserved2 */
  301. #define DB_CNT3 3 /* reserved3 */
  302. #define DB_CNT4 4 /* reserved4 */
  303. #define DB_CNT5 5 /* reserved5 */
  304. #define DB_CNT6 6 /* reserved6 */
  305. #define DB_CNT7 7 /* reserved7 */
  306. #define DB_CNT8 8 /* reserved8 */
  307. #define DB_CNT9 9 /* reserved9 */
  308. #define DB_CNT10 10 /* reserved10 */
  309. #define DB_CNT11 11 /* m3 watchdog expiry count*/
  310. #define DB_CNT12 12 /* m3 watchdog monitor value */
  311. #define DB_CNT13 13 /* reserved13 */
  312. #define DB_CNT14 14 /* reserved14 */
  313. #define DB_CNT15 15 /* m3 systick counter lower 32bits */
  314. #define DB_CNT16 16 /* m3 systick counter upper 32bits */
  315. #define DB_CNT17 17 /* m3 transmission timeout indication for port0 */
  316. #define DB_CNT18 18 /* m3 transmission timeout indication for port1 */
  317. #define DB_CNT19 19 /* reserved19 */
  318. #define SIXTEEN 16
  319. #define TWENTY 20
  320. #define TWENTY_FOUR 24
  321. #define SIXTY_FOUR 64
  322. #define ONE_TWENTY_EIGHT 128
  323. #define TWO_FIFTY_SIX 256
  324. #define FIVE_HUNDRED_TWELVE 512
  325. #define THOUSAND_TWENTY_FOUR 1024
  326. #define SPD_DIV_10G 10000000
  327. #define SPD_DIV_5G 5000000
  328. #define SPD_DIV_2_5G 2500000
  329. #define SPD_DIV_1G 1000000
  330. #define SPD_DIV_100M 100000
  331. #define NRSTCTRL0_RST_ASRT 0x1
  332. #define NRSTCTRL0_RST_DE_ASRT 0x3
  333. #define TC956X_OFFSET_TAMAP 0x00000010
  334. #define TC956X_MASK_TAMAP 0xFFFFF000
  335. #define TC956X_SHIFT_TAMAP 32
  336. #define TC956X_OFFSET_OW 28
  337. #define TC956X_OFFSET_OW_MAX 53
  338. #define TC956X_HEX_ZERO 0x00000000
  339. #define TC956X_BAR0 0
  340. #define TC956X_BAR2 2
  341. #define TC956X_BAR4 4
  342. #define NMODESTS 0x0004
  343. #define NMODESTS_MODE 0x200
  344. #define NMODESTS_MODE2 0x400
  345. #define NMODESTS_MODE2_SHIFT 10
  346. #define TC956X_PCIE_SETTING_A 0 /* x4x1x1 mode */
  347. #define TC956X_PCIE_SETTING_B 1 /* x2x2x1 mode */
  348. #define TC9563_CFG_NEMACTXCDLY 0x1050U
  349. #define TC9563_CFG_NEMACIOCTL 0x107CU
  350. #define NEMACTXCDLY_DEFAULT 0x00000000U
  351. #define NEMACIOCTL_DEFAULT 0xF300F300
  352. /* Systick count SRAM address DMEM addrs 0x2000F83C, Check this value for any change */
  353. #define SYSTCIK_SRAM_OFFSET 0x4F83C
  354. /* Tx Timer count SRAM address DMEM addrs 0x2000F844, Check this value for any change */
  355. #define TX_TIMER_SRAM_OFFSET_0 0x4F844
  356. /* Tx Timer count SRAM address DMEM addrs 0x2000F848, Check this value for any change */
  357. #define TX_TIMER_SRAM_OFFSET_1 0x4F848
  358. #define TX_TIMER_SRAM_OFFSET(t) (((t) == RM_PF0_ID) ? (TX_TIMER_SRAM_OFFSET_0) : (TX_TIMER_SRAM_OFFSET_1))
  359. #define TC956X_M3_SRAM_EEPROM_MAC_ADDR 0x47000 /* DMEM addrs 0x20007000U */
  360. #define TC956X_M3_SRAM_EEPROM_OFFSET_ADDR 0x47050 /* DMEM addrs 0x20007050U */
  361. #define TC956X_M3_SRAM_EEPROM_MAC_COUNT 0x47051 /* DMEM addrs 0x20007051U */
  362. #define TC956X_M3_INIT_DONE 0x47054 /* DMEM addrs 0x20007054U */
  363. #define TC956X_M3_FW_EXIT 0x47058 /* DMEM addrs 0x20007058U */
  364. #define TC956X_M3_DBG_VER_START 0x4F900
  365. #define ENABLE_USXGMII_INTERFACE 0
  366. #define ENABLE_XFI_INTERFACE 1 /* XFI/SFI, this is same as USXGMII, except XPCS autoneg disabled */
  367. #define ENABLE_RGMII_INTERFACE 2
  368. #define ENABLE_SGMII_INTERFACE 3
  369. #define ENABLE_2500BASE_X_INTERFACE 4
  370. #define MTL_FPE_AFSZ_64 0
  371. #define MTL_FPE_AFSZ_128 1
  372. #define MTL_FPE_AFSZ_192 2
  373. #define MTL_FPE_AFSZ_256 3
  374. #ifdef TC956X_SRIOV_PF
  375. #define TC956X_DISABLE_CHNL 0
  376. #define TC956X_ENABLE_CHNL 1
  377. #define TC956X_DISABLE_QUEUE 0
  378. #define TC956X_ENABLE_QUEUE 1
  379. #endif
  380. #define MMC_XGMAC_TX_FPE_FRAG 0x208
  381. #define MMC_XGMAC_RX_PKT_ASSEMBLY_OK 0x230
  382. #define MMC_XGMAC_RX_FPE_FRAG 0x234
  383. #endif
  384. #define MAX_CM3_TAMAP_ENTRIES 3
  385. #define CM3_TAMAP_ATR_SIZE 28 /* ATR Size = 2 ^ (28 + 1) = 512MB */
  386. #define CM3_TAMAP_SIZE (1 << (CM3_TAMAP_ATR_SIZE + 1))
  387. #define CM3_TAMAP_MASK (CM3_TAMAP_SIZE - 1)
  388. #define CM3_TAMAP_SRC_ADDR_START 0x60000000
  389. #define TC956XMAC_ALIGN(x) ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16)
  390. #define TC956X_MAX_LINK_DELAY 800
  391. #define XDP_PACKET_HEADROOM 256
  392. #define TC956X_MAX_RX_BUF_SIZE(num) (((num) * PAGE_SIZE) - XDP_PACKET_HEADROOM)
  393. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  394. struct tc956xmac_cm3_tamap {
  395. u32 trsl_addr_hi;
  396. u32 trsl_addr_low;
  397. u32 src_addr_hi;
  398. u32 src_addr_low; /* Only [31:12] bits will be considered */
  399. u32 atr_size;
  400. bool valid;
  401. };
  402. #endif
  403. struct tc956xmac_resources {
  404. void __iomem *addr;
  405. #ifdef TC956X_SRIOV_PF
  406. #ifdef CONFIG_PCI_IOV
  407. u32 sriov_enabled;
  408. #endif
  409. #endif
  410. void __iomem *tc956x_BRIDGE_CFG_pci_base_addr;
  411. void __iomem *tc956x_SRAM_pci_base_addr;
  412. void __iomem *tc956x_SFR_pci_base_addr;
  413. const char *mac;
  414. int wol_irq;
  415. int lpi_irq;
  416. int irq;
  417. #ifdef TC956X
  418. unsigned int port_num;
  419. unsigned int port_interface; /* Kernel module parameter variable for interface */
  420. unsigned int eee_enabled; /* Parameter to store kernel module parameter to enable/disable EEE */
  421. unsigned int tx_lpi_timer; /* Parameter to store kernel module parameter for LPI Auto Entry Timer */
  422. #endif
  423. };
  424. struct tc956xmac_tx_info {
  425. dma_addr_t buf;
  426. bool map_as_page;
  427. unsigned int len;
  428. bool last_segment;
  429. bool is_jumbo;
  430. };
  431. #define TC956XMAC_TBS_AVAIL BIT(0)
  432. #define TC956XMAC_TBS_EN BIT(1)
  433. /* Frequently used values are kept adjacent for cache effect */
  434. struct tc956xmac_tx_queue {
  435. u32 tx_count_frames;
  436. int tbs;
  437. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0))
  438. struct hrtimer txtimer;
  439. #else
  440. struct timer_list txtimer;
  441. #endif
  442. u32 queue_index;
  443. struct tc956xmac_priv *priv_data;
  444. struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
  445. struct dma_edesc *dma_entx;
  446. struct dma_desc *dma_tx;
  447. struct sk_buff **tx_skbuff;
  448. struct tc956xmac_tx_info *tx_skbuff_dma;
  449. unsigned int cur_tx;
  450. unsigned int dirty_tx;
  451. dma_addr_t dma_tx_phy;
  452. u32 tx_tail_addr;
  453. u32 mss;
  454. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  455. struct sk_buff **tx_offload_skbuff;
  456. dma_addr_t *tx_offload_skbuff_dma;
  457. dma_addr_t buff_tx_phy;
  458. void *buffer_tx_va_addr;
  459. #endif
  460. };
  461. struct tc956xmac_rx_buffer {
  462. struct page *page;
  463. struct page *sec_page;
  464. dma_addr_t addr;
  465. dma_addr_t sec_addr;
  466. };
  467. struct tc956xmac_rx_queue {
  468. u32 rx_count_frames;
  469. u32 queue_index;
  470. struct page_pool *page_pool;
  471. struct tc956xmac_rx_buffer *buf_pool;
  472. struct tc956xmac_priv *priv_data;
  473. struct dma_extended_desc *dma_erx;
  474. struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
  475. unsigned int cur_rx;
  476. unsigned int dirty_rx;
  477. u32 rx_zeroc_thresh;
  478. dma_addr_t dma_rx_phy;
  479. u32 rx_tail_addr;
  480. unsigned int state_saved;
  481. struct {
  482. struct sk_buff *skb;
  483. unsigned int len;
  484. unsigned int error;
  485. } state;
  486. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  487. struct sk_buff **rx_offload_skbuff;
  488. dma_addr_t *rx_offload_skbuff_dma;
  489. dma_addr_t buff_rx_phy;
  490. void *buffer_rx_va_addr;
  491. #endif
  492. };
  493. struct tc956xmac_channel {
  494. struct napi_struct rx_napi ____cacheline_aligned_in_smp;
  495. struct napi_struct tx_napi ____cacheline_aligned_in_smp;
  496. struct tc956xmac_priv *priv_data;
  497. spinlock_t lock;
  498. u32 index;
  499. };
  500. struct tc956xmac_tc_entry {
  501. bool in_use;
  502. bool in_hw;
  503. bool is_last;
  504. bool is_frag;
  505. void *frag_ptr;
  506. unsigned int table_pos;
  507. u32 handle;
  508. u32 prio;
  509. struct {
  510. u32 match_data;
  511. u32 match_en;
  512. u8 af:1;
  513. u8 rf:1;
  514. u8 im:1;
  515. u8 nc:1;
  516. u8 res1:4;
  517. u8 frame_offset:6;
  518. u8 res2:2;
  519. u8 ok_index;
  520. u8 res3;
  521. u16 dma_ch_no;
  522. u16 res4;
  523. } __packed val;
  524. };
  525. #ifdef TC956X
  526. #define TC956XMAC_PPS_MAX 3 /* Two are for output signal generation and one is internal use for eMAC */
  527. #else
  528. #define TC956XMAC_PPS_MAX 4
  529. #endif
  530. struct tc956xmac_pps_cfg {
  531. bool available;
  532. struct timespec64 start;
  533. struct timespec64 period;
  534. };
  535. struct tc956xmac_rss {
  536. int enable;
  537. u8 key[TC956XMAC_RSS_HASH_KEY_SIZE];
  538. u32 table[TC956XMAC_RSS_MAX_TABLE_SIZE];
  539. };
  540. #define TC956XMAC_FLOW_ACTION_DROP BIT(0)
  541. struct tc956xmac_flow_entry {
  542. unsigned long cookie;
  543. unsigned long action;
  544. u8 ip_proto;
  545. int in_use;
  546. int idx;
  547. int is_l4;
  548. };
  549. struct tc956xmac_rfs_entry {
  550. unsigned long cookie;
  551. u16 etype;
  552. int in_use;
  553. int type;
  554. int tc;
  555. };
  556. struct tc956x_cbs_params {
  557. u32 send_slope;
  558. u32 idle_slope;
  559. u32 high_credit;
  560. u32 low_credit;
  561. u32 percentage;
  562. };
  563. struct tc956x_gpio_config {
  564. u8 config; /* 1: configured, 0: not configured*/
  565. u8 out_val; /* 0 or 1 */
  566. };
  567. struct drv_cap {
  568. u8 csum_en;
  569. u8 crc_en;
  570. u8 tso_en;
  571. u8 jumbo_en;
  572. };
  573. #if defined(TC956X_SRIOV_PF) && defined(TC956X_SRIOV_LOCK)
  574. struct sync_locks {
  575. spinlock_t mac_filter;
  576. spinlock_t vlan_filter;
  577. spinlock_t est;
  578. spinlock_t fpe;
  579. spinlock_t frp;
  580. spinlock_t cbs;
  581. };
  582. #endif
  583. #ifdef TC956X_SRIOV_PF
  584. struct work_queue_param {
  585. struct ethtool_pauseparam pause;
  586. struct ifreq rq;
  587. u16 val_out[MAX_NO_OF_VFS];
  588. u32 queue_no;
  589. u8 fn_id;
  590. u8 vf_no;
  591. };
  592. #endif
  593. /* Rx Frame Steering */
  594. enum tc956x_rfs_type {
  595. TC956X_RFS_T_VLAN,
  596. TC956X_RFS_T_LLDP,
  597. TC956X_RFS_T_1588,
  598. TC956X_RFS_T_MAX,
  599. };
  600. struct tc956xmac_priv {
  601. /* Frequently used values are kept adjacent for cache effect */
  602. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0))
  603. u32 tx_coal_frames[MTL_MAX_TX_QUEUES];
  604. u32 tx_coal_timer[MTL_MAX_TX_QUEUES];
  605. u32 rx_coal_frames[MTL_MAX_TX_QUEUES];
  606. #else
  607. u32 tx_coal_frames;
  608. u32 tx_coal_timer;
  609. u32 rx_coal_frames;
  610. #endif
  611. int tx_coalesce;
  612. int hwts_tx_en;
  613. bool tx_path_in_lpi_mode;
  614. bool tso;
  615. int sph;
  616. u32 sarc_type;
  617. unsigned int dma_buf_sz;
  618. unsigned int rx_copybreak;
  619. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0))
  620. u32 rx_riwt[MTL_MAX_RX_QUEUES];
  621. #else
  622. u32 rx_riwt;
  623. #endif
  624. int hwts_rx_en;
  625. void __iomem *ioaddr;
  626. #ifdef TC956X_SRIOV_PF
  627. #ifdef CONFIG_PCI_IOV
  628. s32 sriov_enabled;
  629. #endif
  630. #endif
  631. void __iomem *tc956x_BRIDGE_CFG_pci_base_addr;
  632. void __iomem *tc956x_SRAM_pci_base_addr;
  633. void __iomem *tc956x_SFR_pci_base_addr;
  634. #if defined(TC956X_SRIOV_PF) | defined(TC956X_SRIOV_VF)
  635. void __iomem *tc956x_SRAM_mailbox_base_addr;
  636. #endif
  637. #ifdef TC956X_SRIOV_PF
  638. unsigned char clear_to_send[MAX_NO_OF_VFS];
  639. #endif
  640. struct net_device *dev;
  641. struct device *device;
  642. struct mac_device_info *hw;
  643. int (*hwif_quirks)(struct tc956xmac_priv *priv);
  644. struct mutex lock;
  645. /* RX Queue */
  646. struct tc956xmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
  647. /* TX Queue */
  648. struct tc956xmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
  649. /* Generic channel for NAPI */
  650. struct tc956xmac_channel channel[TC956XMAC_CH_MAX];
  651. unsigned int l2_filtering_mode; /* 0 - if perfect and 1 - if hash filtering */
  652. unsigned int vlan_hash_filtering;
  653. struct tc956x_mac_addr *mac_table;
  654. struct tc956x_vlan_id *vlan_table;
  655. u32 sa_vlan_ins_via_reg;
  656. unsigned char ins_mac_addr[ETH_ALEN];
  657. /* RX Parser */
  658. bool rxp_enabled;
  659. /* Phy Link State */
  660. u32 link;
  661. int speed;
  662. u32 duplex;
  663. bool oldlink;
  664. int oldduplex;
  665. unsigned int flow_ctrl;
  666. unsigned int pause;
  667. struct mii_bus *mii;
  668. int mii_irq[PHY_MAX_ADDR];
  669. #ifndef TC956X_SRIOV_VF
  670. struct phylink_config phylink_config;
  671. struct phylink *phylink;
  672. #endif
  673. struct tc956xmac_extra_stats xstats ____cacheline_aligned_in_smp;
  674. struct tc956xmac_safety_stats sstats;
  675. struct plat_tc956xmacenet_data *plat;
  676. struct dma_features dma_cap;
  677. struct tc956xmac_counters mmc;
  678. #ifdef TC956X_SRIOV_VF
  679. struct tc956x_sw_counters sw_stats;
  680. #endif
  681. int hw_cap_support;
  682. int synopsys_id;
  683. u32 msg_enable;
  684. int wolopts;
  685. int wol_irq;
  686. int clk_csr;
  687. int lpi_irq;
  688. unsigned int eee_enabled;
  689. int eee_active;
  690. unsigned int tx_lpi_timer;
  691. unsigned int mode;
  692. unsigned int chain_mode;
  693. int extend_desc;
  694. struct hwtstamp_config tstamp_config;
  695. struct ptp_clock *ptp_clock;
  696. struct ptp_clock_info ptp_clock_ops;
  697. unsigned int default_addend;
  698. u32 sub_second_inc;
  699. u32 systime_flags;
  700. u32 adv_ts;
  701. int use_riwt;
  702. int irq_wake;
  703. spinlock_t ptp_lock;
  704. void __iomem *mmcaddr;
  705. void __iomem *ptpaddr;
  706. #ifdef TC956X
  707. void __iomem *xpcsaddr;
  708. void __iomem *pmaaddr;
  709. #endif
  710. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  711. #ifdef CONFIG_DEBUG_FS
  712. struct dentry *dbgfs_dir;
  713. #endif
  714. unsigned long state;
  715. struct workqueue_struct *wq;
  716. struct work_struct service_task;
  717. #ifdef TC956X_SRIOV_PF
  718. struct workqueue_struct *mbx_wq;
  719. struct work_struct service_mbx_task;
  720. struct work_queue_param mbx_wq_param;
  721. #endif
  722. spinlock_t wq_lock;
  723. #ifdef TC956X_SRIOV_VF
  724. struct workqueue_struct *mbx_wq;
  725. struct work_struct mbx_service_task;
  726. unsigned char flag;
  727. #endif
  728. /* CBS configurations */
  729. struct tc956x_cbs_params cbs_speed100_cfg[8];
  730. struct tc956x_cbs_params cbs_speed1000_cfg[8];
  731. struct tc956x_cbs_params cbs_speed2500_cfg[8];
  732. struct tc956x_cbs_params cbs_speed5000_cfg[8];
  733. struct tc956x_cbs_params cbs_speed10000_cfg[8];
  734. /* TC Handling */
  735. unsigned int tc_entries_max;
  736. unsigned int tc_off_max;
  737. struct tc956xmac_tc_entry *tc_entries;
  738. unsigned int flow_entries_max;
  739. struct tc956xmac_flow_entry *flow_entries;
  740. unsigned int rfs_entries_max[TC956X_RFS_T_MAX];
  741. unsigned int rfs_entries_cnt[TC956X_RFS_T_MAX];
  742. unsigned int rfs_entries_total;
  743. struct tc956xmac_rfs_entry *rfs_entries;
  744. /* Pulse Per Second output */
  745. struct tc956xmac_pps_cfg pps[TC956XMAC_PPS_MAX];
  746. /* Receive Side Scaling */
  747. struct tc956xmac_rss rss;
  748. #ifdef TC956X_SRIOV_PF
  749. u8 dma_vf_map[TC956XMAC_CH_MAX];
  750. u8 pf_queue_dma_map[MTL_MAX_TX_QUEUES];
  751. /* Features enabled in PF */
  752. struct drv_cap pf_drv_cap;
  753. #endif
  754. /* Function ID information */
  755. struct fn_id fn_id_info;
  756. #ifdef TC956X_SRIOV_VF
  757. /* Features enabled in PF */
  758. struct drv_cap pf_drv_cap;
  759. #endif
  760. /* Tx Checksum Insertion */
  761. u32 csum_insertion;
  762. #if defined(TC956X_SRIOV_PF) | defined(TC956X_SRIOV_VF)
  763. u32 rx_csum_state;
  764. #endif
  765. /* CRC Tx Rx Configuraion */
  766. u32 tx_crc_pad_state;
  767. u32 rx_crc_pad_state;
  768. #ifdef TC956X_SRIOV_PF
  769. u8 rsc_dma_ch_alloc[MAX_FUNCTIONS_PER_PF];
  770. #endif
  771. /* eMAC port number */
  772. #ifdef TC956X
  773. u32 port_num;
  774. u32 mac_loopback_mode;
  775. u32 phy_loopback_mode;
  776. bool is_sgmii_2p5g; /* For 2.5G SGMI, XPCS doesn't support AN. This flag is to identify 2.5G Speed for SGMII interface. */
  777. u32 port_interface; /* Kernel module parameter variable for interface */
  778. bool tc956x_port_pm_suspend; /* Port Suspend Status; True : port suspended, False : port resume */
  779. bool tc956xmac_pm_wol_interrupt; /* Port-wise flag for clearing interrupt after resume. */
  780. #endif
  781. /* set to 1 when ptp offload is enabled, else 0. */
  782. u32 ptp_offload;
  783. /*
  784. *ptp offloading mode - ORDINARY_SLAVE, ORDINARY_MASTER,
  785. * TRANSPARENT_SLAVE, TRANSPARENT_MASTER, PTOP_TRANSPERENT.
  786. */
  787. u32 ptp_offloading_mode;
  788. /* set to 1 when onestep timestamp is enabled, else 0. */
  789. u32 ost_en;
  790. /* Private data store for platform layer */
  791. void *plat_priv;
  792. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  793. void *client_priv;
  794. struct tc956xmac_cm3_tamap cm3_tamap[MAX_CM3_TAMAP_ENTRIES];
  795. #endif
  796. /* Work struct for handling phy interrupt */
  797. struct work_struct emac_phy_work;
  798. u32 pm_saved_emac_rst; /* Save and restore EMAC Resets during suspend-resume sequence */
  799. u32 pm_saved_emac_clk; /* Save and restore EMAC Clocks during suspend-resume sequence */
  800. #ifdef TC956X_SRIOV_PF
  801. #ifdef TC956X_MAGIC_PACKET_WOL_CONF
  802. bool wol_config_enabled; /* Flag to indicate SerDes configuration for SGMII, 1Gbps for WOL */
  803. #endif /* #ifdef TC956X_MAGIC_PACKET_WOL_CONF */
  804. u32 pm_saved_linkdown_rst; /* Save and restore Resets during link-down sequence */
  805. u32 pm_saved_linkdown_clk; /* Save and restore Clocks during link-down sequence */
  806. bool port_link_down; /* Flag to save per port link down state */
  807. bool port_release; /* Flag to notify appropriate sequence of link down & up */
  808. struct mutex port_ld_release_lock; /* Mutex lock to handle (set and clear) flag to notify
  809. appropriate sequence of link down & up */
  810. #endif
  811. struct tc956x_gpio_config saved_gpio_config[GPIO_12 + 1]; /* Only GPIO0- GPIO06, GPI010-GPIO12 are used */
  812. #ifdef CONFIG_DEBUG_FS
  813. struct dentry *debugfs_dir; /* debugfs structure pointer for port specific */
  814. #endif
  815. #ifdef TC956X_ENABLE_MAC2MAC_BRIDGE
  816. void *pbridge_buffaddr;
  817. dma_addr_t pbridge_handle;
  818. size_t pbridge_buffsize;
  819. #endif
  820. #if defined(TC956X_SRIOV_PF) && defined(TC956X_SRIOV_LOCK)
  821. struct sync_locks spn_lock;
  822. #endif
  823. unsigned long link_state;
  824. bool link_down_rst; /* For light-weight release and open during link-down */
  825. };
  826. struct tc956x_version {
  827. unsigned char rel_dbg; /* 'R' for release, 'D' for debug */
  828. unsigned char major;
  829. unsigned char minor;
  830. unsigned char sub_minor;
  831. unsigned char patch_rel_major;
  832. unsigned char patch_rel_minor;
  833. };
  834. enum tc956xmac_state {
  835. TC956XMAC_DOWN,
  836. TC956XMAC_RESET_REQUESTED,
  837. TC956XMAC_RESETING,
  838. TC956XMAC_SERVICE_SCHED,
  839. };
  840. struct tc956x_regs_config {
  841. u32 ncid;
  842. u32 nclkctrl0;
  843. u32 nrstctrl0;
  844. u32 nclkctrl1;
  845. u32 nrstctrl1;
  846. u32 nemac0ctl;
  847. u32 nemac1ctl;
  848. u32 nemacsts;
  849. u32 gpioi0;
  850. u32 gpioi1;
  851. u32 gpioe0;
  852. u32 gpioe1;
  853. };
  854. struct tc956x_regs_pcie {
  855. u32 rsc_mng_id;
  856. };
  857. struct tc956x_regs_msi {
  858. u32 msi_out_en;
  859. u32 msi_mask_set;
  860. u32 msi_mask_clr;
  861. u32 int_sts;
  862. u32 int_raw_sts;
  863. u32 msi_sts;
  864. u32 cnt_int0;
  865. u32 cnt_int1;
  866. u32 cnt_int2;
  867. u32 cnt_int3;
  868. u32 cnt_int4;
  869. u32 cnt_int11;
  870. u32 cnt_int12;
  871. u32 cnt_int20;
  872. u32 cnt_int24;
  873. };
  874. struct tc956x_regs_intc {
  875. u32 intmcumask0;
  876. u32 intmcumask1;
  877. u32 intmcumask2;
  878. };
  879. struct tc956x_regs_dma_ch {
  880. u32 control;
  881. u32 list_haddr;
  882. u32 list_laddr;
  883. u32 ring_len;
  884. u32 curr_haddr;
  885. u32 curr_laddr;
  886. u32 tail_ptr;
  887. u32 buf_haddr;
  888. u32 buf_laddr;
  889. };
  890. struct tx956x_tx_desc_buf_addrs {
  891. dma_addr_t desc_phy_addr;
  892. struct dma_desc *desc_va_addr;
  893. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  894. dma_addr_t buff_phy_addr;
  895. void *buff_va_addr;
  896. #endif
  897. struct sk_buff **tx_skbuff;
  898. struct tc956xmac_tx_info *tx_skbuff_dma;
  899. };
  900. struct tx956x_rx_desc_buf_addrs {
  901. dma_addr_t desc_phy_addr;
  902. struct dma_desc *desc_va_addr;
  903. #ifdef TC956X_DMA_OFFLOAD_ENABLE
  904. dma_addr_t buff_phy_addr;
  905. void *buff_va_addr;
  906. #endif
  907. struct tc956xmac_rx_buffer *buf_pool;
  908. };
  909. struct tc956x_regs_dma {
  910. u32 debug_sts0;
  911. u32 ch_control[TC956XMAC_CH_MAX];
  912. u32 interrupt_enable[TC956XMAC_CH_MAX];
  913. u32 ch_status[TC956XMAC_CH_MAX];
  914. u32 debug_status[TC956XMAC_CH_MAX];
  915. u32 rxch_watchdog_timer[TC956XMAC_CH_MAX];
  916. struct tc956x_regs_dma_ch tx_ch[TC956XMAC_CH_MAX];
  917. struct tc956x_regs_dma_ch rx_ch[TC956XMAC_CH_MAX];
  918. /* RX Channels */
  919. struct tx956x_rx_desc_buf_addrs rx_queue[MTL_MAX_RX_QUEUES];
  920. /* TX Channels */
  921. struct tx956x_tx_desc_buf_addrs tx_queue[MTL_MAX_TX_QUEUES];
  922. };
  923. struct tc956x_regs_mac {
  924. u32 mac_tx_config;
  925. u32 mac_rx_config;
  926. u32 mac_pkt_filter;
  927. u32 mac_tx_rx_status;
  928. u32 mac_debug;
  929. };
  930. struct tc956x_regs_mtl_tx {
  931. u32 op_mode;
  932. u32 underflow;
  933. u32 debug;
  934. };
  935. struct tc956x_regs_mtl_rx {
  936. u32 op_mode;
  937. u32 miss_pkt_overflow;
  938. u32 debug;
  939. u32 flow_control;
  940. };
  941. struct tc956x_regs_mtl {
  942. u32 op_mode;
  943. u32 mtl_rxq_dma_map0;
  944. u32 mtl_rxq_dma_map1;
  945. struct tc956x_regs_mtl_tx tx_info[MTL_MAX_TX_QUEUES];
  946. struct tc956x_regs_mtl_rx rx_info[MTL_MAX_RX_QUEUES];
  947. };
  948. struct tc956x_regs_m3 {
  949. u32 sram_tx_pcie_addr[TC956XMAC_CH_MAX];
  950. u32 sram_rx_pcie_addr[TC956XMAC_CH_MAX];
  951. u32 m3_fw_init_done;
  952. u32 m3_fw_exit;
  953. u32 m3_debug_cnt0;
  954. u32 m3_debug_cnt1;
  955. u32 m3_debug_cnt2;
  956. u32 m3_debug_cnt3;
  957. u32 m3_debug_cnt4;
  958. u32 m3_debug_cnt5;
  959. u32 m3_debug_cnt6;
  960. u32 m3_debug_cnt7;
  961. u32 m3_debug_cnt8;
  962. u32 m3_debug_cnt9;
  963. u32 m3_debug_cnt10;
  964. u32 m3_watchdog_exp_cnt;
  965. u32 m3_watchdog_monitor_cnt;
  966. u32 m3_debug_cnt13;
  967. u32 m3_debug_cnt14;
  968. u32 m3_systick_cnt_upper_value;
  969. u32 m3_systick_cnt_lower_value;
  970. u32 m3_tx_timeout_port0;
  971. u32 m3_tx_timeout_port1;
  972. u32 m3_debug_cnt19;
  973. };
  974. struct tc956x_tamap {
  975. u32 trsl_addr_hi;
  976. u32 trsl_addr_low;
  977. u32 src_addr_hi;
  978. u32 src_addr_low; /* Only [31:12] bits will be considered */
  979. u32 atr_size;
  980. u32 atr_impl;
  981. };
  982. struct tx956x_driver_info {
  983. u8 driver[32];
  984. u8 version[32];
  985. u8 fw_version[32];
  986. };
  987. struct tc956x_statistics {
  988. u64 rx_buf_unav_irq[TC956XMAC_CH_MAX];
  989. u64 tx_pkt_n[TC956XMAC_CH_MAX];
  990. u64 tx_pkt_errors_n[TC956XMAC_CH_MAX];
  991. u64 rx_pkt_n[TC956XMAC_CH_MAX];
  992. u64 mmc_tx_broadcastframe_g;
  993. u64 mmc_tx_multicastframe_g;
  994. u64 mmc_tx_64_octets_gb;
  995. u64 mmc_tx_framecount_gb;
  996. u64 mmc_tx_65_to_127_octets_gb;
  997. u64 mmc_tx_128_to_255_octets_gb;
  998. u64 mmc_tx_256_to_511_octets_gb;
  999. u64 mmc_tx_512_to_1023_octets_gb;
  1000. u64 mmc_tx_1024_to_max_octets_gb;
  1001. u64 mmc_tx_unicast_gb;
  1002. u64 mmc_tx_underflow_error;
  1003. u64 mmc_tx_framecount_g;
  1004. u64 mmc_tx_pause_frame;
  1005. u64 mmc_tx_vlan_frame_g;
  1006. u64 mmc_tx_lpi_us_cntr;
  1007. u64 mmc_tx_lpi_tran_cntr;
  1008. /* MMC RX counter registers */
  1009. u64 mmc_rx_framecount_gb;
  1010. u64 mmc_rx_broadcastframe_g;
  1011. u64 mmc_rx_multicastframe_g;
  1012. u64 mmc_rx_crc_error;
  1013. u64 mmc_rx_jabber_error;
  1014. u64 mmc_rx_undersize_g;
  1015. u64 mmc_rx_oversize_g;
  1016. u64 mmc_rx_64_octets_gb;
  1017. u64 mmc_rx_65_to_127_octets_gb;
  1018. u64 mmc_rx_128_to_255_octets_gb;
  1019. u64 mmc_rx_256_to_511_octets_gb;
  1020. u64 mmc_rx_512_to_1023_octets_gb;
  1021. u64 mmc_rx_1024_to_max_octets_gb;
  1022. u64 mmc_rx_unicast_g;
  1023. u64 mmc_rx_length_error;
  1024. u64 mmc_rx_pause_frames;
  1025. u64 mmc_rx_fifo_overflow;
  1026. u64 mmc_rx_lpi_us_cntr;
  1027. u64 mmc_rx_lpi_tran_cntr;
  1028. };
  1029. struct tc956x_regs {
  1030. /*PCIe register*/
  1031. struct tc956x_regs_pcie pcie_reg;
  1032. /*Configuration register*/
  1033. struct tc956x_regs_config config_reg;
  1034. /*MSI register*/
  1035. struct tc956x_regs_msi msi_reg;
  1036. /*INTC register*/
  1037. struct tc956x_regs_intc intc_reg;
  1038. /*DMA Descriptor stats*/
  1039. struct tc956x_regs_dma dma_reg;
  1040. /*MAC debug stats*/
  1041. struct tc956x_regs_mac mac_reg;
  1042. /*MTL debug stats*/
  1043. struct tc956x_regs_mtl mtl_reg;
  1044. /*M3 stats*/
  1045. struct tc956x_regs_m3 m3_reg;
  1046. /*FRP Table*/
  1047. struct tc956xmac_rx_parser_cfg *rxp_cfg;
  1048. /* TAMAP */
  1049. struct tc956x_tamap tamap[MAX_CM3_TAMAP_ENTRIES + 1]; /*0th for PCIe-eMAC 1,2,3 for IPA*/
  1050. /*Driver & FW Information */
  1051. struct tx956x_driver_info info;
  1052. /* Statistics counters*/
  1053. struct tc956x_statistics stats;
  1054. };
  1055. int tc956x_dump_regs(struct net_device *net_device, struct tc956x_regs *regs);
  1056. int tc956x_print_debug_regs(struct net_device *net_device, struct tc956x_regs *regs);
  1057. int tc956xmac_mdio_unregister(struct net_device *ndev);
  1058. int tc956xmac_mdio_register(struct net_device *ndev);
  1059. int tc956xmac_mdio_reset(struct mii_bus *mii);
  1060. void tc956xmac_set_ethtool_ops(struct net_device *netdev);
  1061. void tc956xmac_ptp_register(struct tc956xmac_priv *priv);
  1062. void tc956xmac_ptp_unregister(struct tc956xmac_priv *priv);
  1063. #ifdef TC956X_SRIOV_PF
  1064. int tc956xmac_resume(struct device *dev);
  1065. int tc956xmac_suspend(struct device *dev);
  1066. int tc956xmac_dvr_remove(struct device *dev);
  1067. int tc956xmac_dvr_probe(struct device *device,
  1068. struct plat_tc956xmacenet_data *plat_dat,
  1069. struct tc956xmac_resources *res);
  1070. #elif defined TC956X_SRIOV_VF
  1071. int tc956xmac_vf_resume(struct device *dev);
  1072. int tc956xmac_vf_suspend(struct device *dev);
  1073. int tc956xmac_vf_dvr_remove(struct device *dev);
  1074. int tc956xmac_vf_dvr_probe(struct device *device,
  1075. struct plat_tc956xmacenet_data *plat_dat,
  1076. struct tc956xmac_resources *res);
  1077. #endif
  1078. void tc956xmac_disable_eee_mode(struct tc956xmac_priv *priv);
  1079. bool tc956xmac_eee_init(struct tc956xmac_priv *priv);
  1080. #ifdef CONFIG_TC956XMAC_SELFTESTS
  1081. void tc956xmac_selftest_run(struct net_device *dev,
  1082. struct ethtool_test *etest, u64 *buf);
  1083. void tc956xmac_selftest_get_strings(struct tc956xmac_priv *priv, u8 *data);
  1084. int tc956xmac_selftest_get_count(struct tc956xmac_priv *priv);
  1085. #else
  1086. static inline void tc956xmac_selftest_run(struct net_device *dev,
  1087. struct ethtool_test *etest, u64 *buf)
  1088. {
  1089. /* Not enabled */
  1090. }
  1091. static inline void tc956xmac_selftest_get_strings(struct tc956xmac_priv *priv,
  1092. u8 *data)
  1093. {
  1094. /* Not enabled */
  1095. }
  1096. static inline int tc956xmac_selftest_get_count(struct tc956xmac_priv *priv)
  1097. {
  1098. return -EOPNOTSUPP;
  1099. }
  1100. #endif /* CONFIG_TC956XMAC_SELFTESTS */
  1101. /* Function Prototypes */
  1102. #ifndef TC956X_SRIOV_VF
  1103. s32 tc956x_load_firmware(struct device *dev, struct tc956xmac_resources *res);
  1104. #endif
  1105. extern int tc956xmac_pm_usage_counter;
  1106. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  1107. int tc956x_pf_get_fn_idx_from_int_sts(struct tc956xmac_priv *priv,
  1108. struct fn_id *fn_id_info);
  1109. void tc956x_pf_parse_mbx(struct tc956xmac_priv *priv,
  1110. enum mbx_msg_fns msg_src);
  1111. #endif
  1112. #ifdef CONFIG_TC956X_PLATFORM_SUPPORT
  1113. int tc956x_platform_probe(struct tc956xmac_priv *priv, struct tc956xmac_resources *res);
  1114. int tc956x_platform_remove(struct tc956xmac_priv *priv);
  1115. int tc956x_platform_suspend(struct tc956xmac_priv *priv);
  1116. int tc956x_platform_resume(struct tc956xmac_priv *priv);
  1117. #else
  1118. static inline int tc956x_platform_probe(struct tc956xmac_priv *priv, struct tc956xmac_resources *res) { return 0; }
  1119. static inline int tc956x_platform_remove(struct tc956xmac_priv *priv) { return 0; }
  1120. static inline int tc956x_platform_suspend(struct tc956xmac_priv *priv) { return 0; }
  1121. static inline int tc956x_platform_resume(struct tc956xmac_priv *priv) { return 0; }
  1122. #endif
  1123. int tc956x_GPIO_OutputConfigPin(struct tc956xmac_priv *priv, u32 gpio_pin, u8 out_value);
  1124. int tc956x_gpio_restore_configuration(struct tc956xmac_priv *priv);
  1125. #ifdef TC956X_SRIOV_VF
  1126. int tc956x_vf_get_fn_idx_from_int_sts(struct tc956xmac_priv *priv,
  1127. struct fn_id *fn_id_info);
  1128. void tc956x_vf_parse_mbx(struct tc956xmac_priv *priv,
  1129. enum mbx_msg_fns msg_src);
  1130. int tc956x_vf_rsc_mng_get_fn_id(struct tc956xmac_priv *priv, void __iomem *reg_pci_bridge_config_addr,
  1131. struct fn_id *fn_id_info);
  1132. #endif
  1133. int tc956x_set_pci_speed(struct pci_dev *pdev, u32 speed);
  1134. void tc956xmac_link_change_set_power(struct tc956xmac_priv *priv, enum TC956X_PORT_LINK_CHANGE_STATE state);
  1135. #endif /* __TC956XMAC_H__ */