hwif.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
  3. // stmmac HW Interface Callbacks
  4. #ifndef __STMMAC_HWIF_H__
  5. #define __STMMAC_HWIF_H__
  6. #include <linux/netdevice.h>
  7. #include <linux/stmmac.h>
  8. #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \
  9. ({ \
  10. int __result = -EINVAL; \
  11. if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) { \
  12. (__priv)->hw->__module->__cname((__arg0), ##__args); \
  13. __result = 0; \
  14. } \
  15. __result; \
  16. })
  17. #define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \
  18. ({ \
  19. int __result = -EINVAL; \
  20. if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \
  21. __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \
  22. __result; \
  23. })
  24. struct stmmac_extra_stats;
  25. struct stmmac_safety_stats;
  26. struct dma_desc;
  27. struct dma_extended_desc;
  28. struct dma_edesc;
  29. /* Descriptors helpers */
  30. struct stmmac_desc_ops {
  31. /* DMA RX descriptor ring initialization */
  32. void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode,
  33. int end, int bfsize);
  34. /* DMA TX descriptor ring initialization */
  35. void (*init_tx_desc)(struct dma_desc *p, int mode, int end);
  36. /* Invoked by the xmit function to prepare the tx descriptor */
  37. void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len,
  38. bool csum_flag, int mode, bool tx_own, bool ls,
  39. unsigned int tot_pkt_len);
  40. void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1,
  41. int len2, bool tx_own, bool ls, unsigned int tcphdrlen,
  42. unsigned int tcppayloadlen);
  43. /* Set/get the owner of the descriptor */
  44. void (*set_tx_owner)(struct dma_desc *p);
  45. int (*get_tx_owner)(struct dma_desc *p);
  46. /* Clean the tx descriptor as soon as the tx irq is received */
  47. void (*release_tx_desc)(struct dma_desc *p, int mode);
  48. /* Clear interrupt on tx frame completion. When this bit is
  49. * set an interrupt happens as soon as the frame is transmitted */
  50. void (*set_tx_ic)(struct dma_desc *p);
  51. /* Last tx segment reports the transmit status */
  52. int (*get_tx_ls)(struct dma_desc *p);
  53. /* Return the transmit status looking at the TDES1 */
  54. int (*tx_status)(void *data, struct stmmac_extra_stats *x,
  55. struct dma_desc *p, void __iomem *ioaddr);
  56. /* Get the buffer size from the descriptor */
  57. int (*get_tx_len)(struct dma_desc *p);
  58. /* Handle extra events on specific interrupts hw dependent */
  59. void (*set_rx_owner)(struct dma_desc *p, int disable_rx_ic);
  60. /* Get the receive frame size */
  61. int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type);
  62. /* Return the reception status looking at the RDES1 */
  63. int (*rx_status)(void *data, struct stmmac_extra_stats *x,
  64. struct dma_desc *p);
  65. void (*rx_extended_status)(void *data, struct stmmac_extra_stats *x,
  66. struct dma_extended_desc *p);
  67. /* Set tx timestamp enable bit */
  68. void (*enable_tx_timestamp) (struct dma_desc *p);
  69. /* get tx timestamp status */
  70. int (*get_tx_timestamp_status) (struct dma_desc *p);
  71. /* get timestamp value */
  72. void (*get_timestamp)(void *desc, u32 ats, u64 *ts);
  73. /* get rx timestamp status */
  74. int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
  75. /* Display ring */
  76. void (*display_ring)(void *head, unsigned int size, bool rx,
  77. dma_addr_t dma_rx_phy, unsigned int desc_size);
  78. /* set MSS via context descriptor */
  79. void (*set_mss)(struct dma_desc *p, unsigned int mss);
  80. /* set descriptor skbuff address */
  81. void (*set_addr)(struct dma_desc *p, dma_addr_t addr);
  82. /* clear descriptor */
  83. void (*clear)(struct dma_desc *p);
  84. /* RSS */
  85. int (*get_rx_hash)(struct dma_desc *p, u32 *hash,
  86. enum pkt_hash_types *type);
  87. void (*get_rx_header_len)(struct dma_desc *p, unsigned int *len);
  88. void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid);
  89. void (*set_sarc)(struct dma_desc *p, u32 sarc_type);
  90. void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag,
  91. u32 inner_type);
  92. void (*set_vlan)(struct dma_desc *p, u32 type);
  93. void (*set_tbs)(struct dma_edesc *p, u32 sec, u32 nsec);
  94. };
  95. #define stmmac_init_rx_desc(__priv, __args...) \
  96. stmmac_do_void_callback(__priv, desc, init_rx_desc, __args)
  97. #define stmmac_init_tx_desc(__priv, __args...) \
  98. stmmac_do_void_callback(__priv, desc, init_tx_desc, __args)
  99. #define stmmac_prepare_tx_desc(__priv, __args...) \
  100. stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args)
  101. #define stmmac_prepare_tso_tx_desc(__priv, __args...) \
  102. stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args)
  103. #define stmmac_set_tx_owner(__priv, __args...) \
  104. stmmac_do_void_callback(__priv, desc, set_tx_owner, __args)
  105. #define stmmac_get_tx_owner(__priv, __args...) \
  106. stmmac_do_callback(__priv, desc, get_tx_owner, __args)
  107. #define stmmac_release_tx_desc(__priv, __args...) \
  108. stmmac_do_void_callback(__priv, desc, release_tx_desc, __args)
  109. #define stmmac_set_tx_ic(__priv, __args...) \
  110. stmmac_do_void_callback(__priv, desc, set_tx_ic, __args)
  111. #define stmmac_get_tx_ls(__priv, __args...) \
  112. stmmac_do_callback(__priv, desc, get_tx_ls, __args)
  113. #define stmmac_tx_status(__priv, __args...) \
  114. stmmac_do_callback(__priv, desc, tx_status, __args)
  115. #define stmmac_get_tx_len(__priv, __args...) \
  116. stmmac_do_callback(__priv, desc, get_tx_len, __args)
  117. #define stmmac_set_rx_owner(__priv, __args...) \
  118. stmmac_do_void_callback(__priv, desc, set_rx_owner, __args)
  119. #define stmmac_get_rx_frame_len(__priv, __args...) \
  120. stmmac_do_callback(__priv, desc, get_rx_frame_len, __args)
  121. #define stmmac_rx_status(__priv, __args...) \
  122. stmmac_do_callback(__priv, desc, rx_status, __args)
  123. #define stmmac_rx_extended_status(__priv, __args...) \
  124. stmmac_do_void_callback(__priv, desc, rx_extended_status, __args)
  125. #define stmmac_enable_tx_timestamp(__priv, __args...) \
  126. stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args)
  127. #define stmmac_get_tx_timestamp_status(__priv, __args...) \
  128. stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args)
  129. #define stmmac_get_timestamp(__priv, __args...) \
  130. stmmac_do_void_callback(__priv, desc, get_timestamp, __args)
  131. #define stmmac_get_rx_timestamp_status(__priv, __args...) \
  132. stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args)
  133. #define stmmac_display_ring(__priv, __args...) \
  134. stmmac_do_void_callback(__priv, desc, display_ring, __args)
  135. #define stmmac_set_mss(__priv, __args...) \
  136. stmmac_do_void_callback(__priv, desc, set_mss, __args)
  137. #define stmmac_set_desc_addr(__priv, __args...) \
  138. stmmac_do_void_callback(__priv, desc, set_addr, __args)
  139. #define stmmac_clear_desc(__priv, __args...) \
  140. stmmac_do_void_callback(__priv, desc, clear, __args)
  141. #define stmmac_get_rx_hash(__priv, __args...) \
  142. stmmac_do_callback(__priv, desc, get_rx_hash, __args)
  143. #define stmmac_get_rx_header_len(__priv, __args...) \
  144. stmmac_do_void_callback(__priv, desc, get_rx_header_len, __args)
  145. #define stmmac_set_desc_sec_addr(__priv, __args...) \
  146. stmmac_do_void_callback(__priv, desc, set_sec_addr, __args)
  147. #define stmmac_set_desc_sarc(__priv, __args...) \
  148. stmmac_do_void_callback(__priv, desc, set_sarc, __args)
  149. #define stmmac_set_desc_vlan_tag(__priv, __args...) \
  150. stmmac_do_void_callback(__priv, desc, set_vlan_tag, __args)
  151. #define stmmac_set_desc_vlan(__priv, __args...) \
  152. stmmac_do_void_callback(__priv, desc, set_vlan, __args)
  153. #define stmmac_set_desc_tbs(__priv, __args...) \
  154. stmmac_do_void_callback(__priv, desc, set_tbs, __args)
  155. struct stmmac_dma_cfg;
  156. struct dma_features;
  157. /* Specific DMA helpers */
  158. struct stmmac_dma_ops {
  159. /* DMA core initialization */
  160. int (*reset)(void __iomem *ioaddr);
  161. void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
  162. int atds);
  163. void (*init_chan)(void __iomem *ioaddr,
  164. struct stmmac_dma_cfg *dma_cfg, u32 chan);
  165. void (*init_rx_chan)(void __iomem *ioaddr,
  166. struct stmmac_dma_cfg *dma_cfg,
  167. dma_addr_t phy, u32 chan);
  168. void (*init_tx_chan)(void __iomem *ioaddr,
  169. struct stmmac_dma_cfg *dma_cfg,
  170. dma_addr_t phy, u32 chan);
  171. /* Configure the AXI Bus Mode Register */
  172. void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi);
  173. /* Dump DMA registers */
  174. void (*dump_regs)(void __iomem *ioaddr, u32 *reg_space);
  175. void (*dma_rx_mode)(void __iomem *ioaddr, int mode, u32 channel,
  176. int fifosz, u8 qmode);
  177. void (*dma_tx_mode)(void __iomem *ioaddr, int mode, u32 channel,
  178. int fifosz, u8 qmode);
  179. /* To track extra statistic (if supported) */
  180. void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
  181. void __iomem *ioaddr);
  182. void (*enable_dma_transmission) (void __iomem *ioaddr);
  183. void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan,
  184. bool rx, bool tx);
  185. void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan,
  186. bool rx, bool tx);
  187. void (*start_tx)(void __iomem *ioaddr, u32 chan);
  188. void (*stop_tx)(void __iomem *ioaddr, u32 chan);
  189. void (*start_rx)(void __iomem *ioaddr, u32 chan);
  190. void (*stop_rx)(void __iomem *ioaddr, u32 chan);
  191. int (*dma_interrupt) (void __iomem *ioaddr,
  192. struct stmmac_extra_stats *x, u32 chan, u32 dir);
  193. /* If supported then get the optional core features */
  194. int (*get_hw_feature)(void __iomem *ioaddr,
  195. struct dma_features *dma_cap);
  196. /* Program the HW RX Watchdog */
  197. void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 queue);
  198. void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
  199. void (*set_rx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
  200. void (*set_rx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
  201. void (*set_tx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
  202. void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan);
  203. void (*qmode)(void __iomem *ioaddr, u32 channel, u8 qmode);
  204. void (*set_bfsize)(void __iomem *ioaddr, int bfsize, u32 chan);
  205. void (*enable_sph)(void __iomem *ioaddr, bool en, u32 chan);
  206. int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);
  207. };
  208. #define stmmac_reset(__priv, __args...) \
  209. stmmac_do_callback(__priv, dma, reset, __args)
  210. #define stmmac_dma_init(__priv, __args...) \
  211. stmmac_do_void_callback(__priv, dma, init, __args)
  212. #define stmmac_init_chan(__priv, __args...) \
  213. stmmac_do_void_callback(__priv, dma, init_chan, __args)
  214. #define stmmac_init_rx_chan(__priv, __args...) \
  215. stmmac_do_void_callback(__priv, dma, init_rx_chan, __args)
  216. #define stmmac_init_tx_chan(__priv, __args...) \
  217. stmmac_do_void_callback(__priv, dma, init_tx_chan, __args)
  218. #define stmmac_axi(__priv, __args...) \
  219. stmmac_do_void_callback(__priv, dma, axi, __args)
  220. #define stmmac_dump_dma_regs(__priv, __args...) \
  221. stmmac_do_void_callback(__priv, dma, dump_regs, __args)
  222. #define stmmac_dma_rx_mode(__priv, __args...) \
  223. stmmac_do_void_callback(__priv, dma, dma_rx_mode, __args)
  224. #define stmmac_dma_tx_mode(__priv, __args...) \
  225. stmmac_do_void_callback(__priv, dma, dma_tx_mode, __args)
  226. #define stmmac_dma_diagnostic_fr(__priv, __args...) \
  227. stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
  228. #define stmmac_enable_dma_transmission(__priv, __args...) \
  229. stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
  230. #define stmmac_enable_dma_irq(__priv, __args...) \
  231. stmmac_do_void_callback(__priv, dma, enable_dma_irq, __args)
  232. #define stmmac_disable_dma_irq(__priv, __args...) \
  233. stmmac_do_void_callback(__priv, dma, disable_dma_irq, __args)
  234. #define stmmac_start_tx(__priv, __args...) \
  235. stmmac_do_void_callback(__priv, dma, start_tx, __args)
  236. #define stmmac_stop_tx(__priv, __args...) \
  237. stmmac_do_void_callback(__priv, dma, stop_tx, __args)
  238. #define stmmac_start_rx(__priv, __args...) \
  239. stmmac_do_void_callback(__priv, dma, start_rx, __args)
  240. #define stmmac_stop_rx(__priv, __args...) \
  241. stmmac_do_void_callback(__priv, dma, stop_rx, __args)
  242. #define stmmac_dma_interrupt_status(__priv, __args...) \
  243. stmmac_do_callback(__priv, dma, dma_interrupt, __args)
  244. #define stmmac_get_hw_feature(__priv, __args...) \
  245. stmmac_do_callback(__priv, dma, get_hw_feature, __args)
  246. #define stmmac_rx_watchdog(__priv, __args...) \
  247. stmmac_do_void_callback(__priv, dma, rx_watchdog, __args)
  248. #define stmmac_set_tx_ring_len(__priv, __args...) \
  249. stmmac_do_void_callback(__priv, dma, set_tx_ring_len, __args)
  250. #define stmmac_set_rx_ring_len(__priv, __args...) \
  251. stmmac_do_void_callback(__priv, dma, set_rx_ring_len, __args)
  252. #define stmmac_set_rx_tail_ptr(__priv, __args...) \
  253. stmmac_do_void_callback(__priv, dma, set_rx_tail_ptr, __args)
  254. #define stmmac_set_tx_tail_ptr(__priv, __args...) \
  255. stmmac_do_void_callback(__priv, dma, set_tx_tail_ptr, __args)
  256. #define stmmac_enable_tso(__priv, __args...) \
  257. stmmac_do_void_callback(__priv, dma, enable_tso, __args)
  258. #define stmmac_dma_qmode(__priv, __args...) \
  259. stmmac_do_void_callback(__priv, dma, qmode, __args)
  260. #define stmmac_set_dma_bfsize(__priv, __args...) \
  261. stmmac_do_void_callback(__priv, dma, set_bfsize, __args)
  262. #define stmmac_enable_sph(__priv, __args...) \
  263. stmmac_do_void_callback(__priv, dma, enable_sph, __args)
  264. #define stmmac_enable_tbs(__priv, __args...) \
  265. stmmac_do_callback(__priv, dma, enable_tbs, __args)
  266. struct mac_device_info;
  267. struct net_device;
  268. struct rgmii_adv;
  269. struct stmmac_tc_entry;
  270. struct stmmac_pps_cfg;
  271. struct stmmac_rss;
  272. struct stmmac_est;
  273. /* Helpers to program the MAC core */
  274. struct stmmac_ops {
  275. /* MAC core initialization */
  276. void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
  277. /* Enable the MAC RX/TX */
  278. void (*set_mac)(void __iomem *ioaddr, bool enable);
  279. /* Enable and verify that the IPC module is supported */
  280. int (*rx_ipc)(struct mac_device_info *hw);
  281. /* Enable RX Queues */
  282. void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
  283. /* RX Queues Priority */
  284. void (*rx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
  285. /* TX Queues Priority */
  286. void (*tx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
  287. /* RX Queues Routing */
  288. void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet,
  289. u32 queue);
  290. /* Program RX Algorithms */
  291. void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
  292. /* Program TX Algorithms */
  293. void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
  294. /* Set MTL TX queues weight */
  295. void (*set_mtl_tx_queue_weight)(struct mac_device_info *hw,
  296. u32 weight, u32 queue);
  297. /* RX MTL queue to RX dma mapping */
  298. void (*map_mtl_to_dma)(struct mac_device_info *hw, u32 queue, u32 chan);
  299. /* Configure AV Algorithm */
  300. void (*config_cbs)(struct mac_device_info *hw, u32 send_slope,
  301. u32 idle_slope, u32 high_credit, u32 low_credit,
  302. u32 queue);
  303. /* Dump MAC registers */
  304. void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
  305. /* Handle extra events on specific interrupts hw dependent */
  306. int (*host_irq_status)(struct mac_device_info *hw,
  307. struct stmmac_extra_stats *x);
  308. /* Handle MTL interrupts */
  309. int (*host_mtl_irq_status)(struct mac_device_info *hw, u32 chan);
  310. /* Multicast filter setting */
  311. void (*set_filter)(struct mac_device_info *hw, struct net_device *dev);
  312. /* Flow control setting */
  313. void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex,
  314. unsigned int fc, unsigned int pause_time, u32 tx_cnt);
  315. /* Set power management mode (e.g. magic frame) */
  316. void (*pmt)(struct mac_device_info *hw, unsigned long mode);
  317. /* Set/Get Unicast MAC addresses */
  318. void (*set_umac_addr)(struct mac_device_info *hw,
  319. const unsigned char *addr,
  320. unsigned int reg_n);
  321. void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr,
  322. unsigned int reg_n);
  323. void (*set_eee_mode)(struct mac_device_info *hw,
  324. bool en_tx_lpi_clockgating);
  325. void (*reset_eee_mode)(struct mac_device_info *hw);
  326. void (*set_eee_lpi_entry_timer)(struct mac_device_info *hw, int et);
  327. void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw);
  328. void (*set_eee_pls)(struct mac_device_info *hw, int link);
  329. void (*debug)(void __iomem *ioaddr, struct stmmac_extra_stats *x,
  330. u32 rx_queues, u32 tx_queues);
  331. /* PCS calls */
  332. void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral,
  333. bool loopback);
  334. void (*pcs_rane)(void __iomem *ioaddr, bool restart);
  335. void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv);
  336. /* Safety Features */
  337. int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp,
  338. struct stmmac_safety_feature_cfg *safety_cfg);
  339. int (*safety_feat_irq_status)(struct net_device *ndev,
  340. void __iomem *ioaddr, unsigned int asp,
  341. struct stmmac_safety_stats *stats);
  342. int (*safety_feat_dump)(struct stmmac_safety_stats *stats,
  343. int index, unsigned long *count, const char **desc);
  344. /* Flexible RX Parser */
  345. int (*rxp_config)(void __iomem *ioaddr, struct stmmac_tc_entry *entries,
  346. unsigned int count);
  347. /* Flexible PPS */
  348. int (*flex_pps_config)(void __iomem *ioaddr, int index,
  349. struct stmmac_pps_cfg *cfg, bool enable,
  350. u32 sub_second_inc, u32 systime_flags);
  351. /* Loopback for selftests */
  352. void (*set_mac_loopback)(void __iomem *ioaddr, bool enable);
  353. /* RSS */
  354. int (*rss_configure)(struct mac_device_info *hw,
  355. struct stmmac_rss *cfg, u32 num_rxq);
  356. /* VLAN */
  357. void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
  358. __le16 perfect_match, bool is_double);
  359. void (*enable_vlan)(struct mac_device_info *hw, u32 type);
  360. int (*add_hw_vlan_rx_fltr)(struct net_device *dev,
  361. struct mac_device_info *hw,
  362. __be16 proto, u16 vid);
  363. int (*del_hw_vlan_rx_fltr)(struct net_device *dev,
  364. struct mac_device_info *hw,
  365. __be16 proto, u16 vid);
  366. void (*restore_hw_vlan_rx_fltr)(struct net_device *dev,
  367. struct mac_device_info *hw);
  368. /* TX Timestamp */
  369. int (*get_mac_tx_timestamp)(struct mac_device_info *hw, u64 *ts);
  370. /* Source Address Insertion / Replacement */
  371. void (*sarc_configure)(void __iomem *ioaddr, int val);
  372. /* Filtering */
  373. int (*config_l3_filter)(struct mac_device_info *hw, u32 filter_no,
  374. bool en, bool ipv6, bool sa, bool inv,
  375. u32 match);
  376. int (*config_l4_filter)(struct mac_device_info *hw, u32 filter_no,
  377. bool en, bool udp, bool sa, bool inv,
  378. u32 match);
  379. void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr);
  380. int (*est_configure)(void __iomem *ioaddr, struct stmmac_est *cfg,
  381. unsigned int ptp_rate);
  382. void (*est_irq_status)(void __iomem *ioaddr, struct net_device *dev,
  383. struct stmmac_extra_stats *x, u32 txqcnt);
  384. void (*fpe_configure)(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg,
  385. u32 num_txq, u32 num_rxq,
  386. bool enable);
  387. void (*fpe_send_mpacket)(void __iomem *ioaddr,
  388. struct stmmac_fpe_cfg *cfg,
  389. enum stmmac_mpacket_type type);
  390. int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev);
  391. };
  392. #define stmmac_core_init(__priv, __args...) \
  393. stmmac_do_void_callback(__priv, mac, core_init, __args)
  394. #define stmmac_mac_set(__priv, __args...) \
  395. stmmac_do_void_callback(__priv, mac, set_mac, __args)
  396. #define stmmac_rx_ipc(__priv, __args...) \
  397. stmmac_do_callback(__priv, mac, rx_ipc, __args)
  398. #define stmmac_rx_queue_enable(__priv, __args...) \
  399. stmmac_do_void_callback(__priv, mac, rx_queue_enable, __args)
  400. #define stmmac_rx_queue_prio(__priv, __args...) \
  401. stmmac_do_void_callback(__priv, mac, rx_queue_prio, __args)
  402. #define stmmac_tx_queue_prio(__priv, __args...) \
  403. stmmac_do_void_callback(__priv, mac, tx_queue_prio, __args)
  404. #define stmmac_rx_queue_routing(__priv, __args...) \
  405. stmmac_do_void_callback(__priv, mac, rx_queue_routing, __args)
  406. #define stmmac_prog_mtl_rx_algorithms(__priv, __args...) \
  407. stmmac_do_void_callback(__priv, mac, prog_mtl_rx_algorithms, __args)
  408. #define stmmac_prog_mtl_tx_algorithms(__priv, __args...) \
  409. stmmac_do_void_callback(__priv, mac, prog_mtl_tx_algorithms, __args)
  410. #define stmmac_set_mtl_tx_queue_weight(__priv, __args...) \
  411. stmmac_do_void_callback(__priv, mac, set_mtl_tx_queue_weight, __args)
  412. #define stmmac_map_mtl_to_dma(__priv, __args...) \
  413. stmmac_do_void_callback(__priv, mac, map_mtl_to_dma, __args)
  414. #define stmmac_config_cbs(__priv, __args...) \
  415. stmmac_do_void_callback(__priv, mac, config_cbs, __args)
  416. #define stmmac_dump_mac_regs(__priv, __args...) \
  417. stmmac_do_void_callback(__priv, mac, dump_regs, __args)
  418. #define stmmac_host_irq_status(__priv, __args...) \
  419. stmmac_do_callback(__priv, mac, host_irq_status, __args)
  420. #define stmmac_host_mtl_irq_status(__priv, __args...) \
  421. stmmac_do_callback(__priv, mac, host_mtl_irq_status, __args)
  422. #define stmmac_set_filter(__priv, __args...) \
  423. stmmac_do_void_callback(__priv, mac, set_filter, __args)
  424. #define stmmac_flow_ctrl(__priv, __args...) \
  425. stmmac_do_void_callback(__priv, mac, flow_ctrl, __args)
  426. #define stmmac_pmt(__priv, __args...) \
  427. stmmac_do_void_callback(__priv, mac, pmt, __args)
  428. #define stmmac_set_umac_addr(__priv, __args...) \
  429. stmmac_do_void_callback(__priv, mac, set_umac_addr, __args)
  430. #define stmmac_get_umac_addr(__priv, __args...) \
  431. stmmac_do_void_callback(__priv, mac, get_umac_addr, __args)
  432. #define stmmac_set_eee_mode(__priv, __args...) \
  433. stmmac_do_void_callback(__priv, mac, set_eee_mode, __args)
  434. #define stmmac_reset_eee_mode(__priv, __args...) \
  435. stmmac_do_void_callback(__priv, mac, reset_eee_mode, __args)
  436. #define stmmac_set_eee_lpi_timer(__priv, __args...) \
  437. stmmac_do_void_callback(__priv, mac, set_eee_lpi_entry_timer, __args)
  438. #define stmmac_set_eee_timer(__priv, __args...) \
  439. stmmac_do_void_callback(__priv, mac, set_eee_timer, __args)
  440. #define stmmac_set_eee_pls(__priv, __args...) \
  441. stmmac_do_void_callback(__priv, mac, set_eee_pls, __args)
  442. #define stmmac_mac_debug(__priv, __args...) \
  443. stmmac_do_void_callback(__priv, mac, debug, __args)
  444. #define stmmac_pcs_ctrl_ane(__priv, __args...) \
  445. stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args)
  446. #define stmmac_pcs_rane(__priv, __args...) \
  447. stmmac_do_void_callback(__priv, mac, pcs_rane, __args)
  448. #define stmmac_pcs_get_adv_lp(__priv, __args...) \
  449. stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args)
  450. #define stmmac_safety_feat_config(__priv, __args...) \
  451. stmmac_do_callback(__priv, mac, safety_feat_config, __args)
  452. #define stmmac_safety_feat_irq_status(__priv, __args...) \
  453. stmmac_do_callback(__priv, mac, safety_feat_irq_status, __args)
  454. #define stmmac_safety_feat_dump(__priv, __args...) \
  455. stmmac_do_callback(__priv, mac, safety_feat_dump, __args)
  456. #define stmmac_rxp_config(__priv, __args...) \
  457. stmmac_do_callback(__priv, mac, rxp_config, __args)
  458. #define stmmac_flex_pps_config(__priv, __args...) \
  459. stmmac_do_callback(__priv, mac, flex_pps_config, __args)
  460. #define stmmac_set_mac_loopback(__priv, __args...) \
  461. stmmac_do_void_callback(__priv, mac, set_mac_loopback, __args)
  462. #define stmmac_rss_configure(__priv, __args...) \
  463. stmmac_do_callback(__priv, mac, rss_configure, __args)
  464. #define stmmac_update_vlan_hash(__priv, __args...) \
  465. stmmac_do_void_callback(__priv, mac, update_vlan_hash, __args)
  466. #define stmmac_enable_vlan(__priv, __args...) \
  467. stmmac_do_void_callback(__priv, mac, enable_vlan, __args)
  468. #define stmmac_add_hw_vlan_rx_fltr(__priv, __args...) \
  469. stmmac_do_callback(__priv, mac, add_hw_vlan_rx_fltr, __args)
  470. #define stmmac_del_hw_vlan_rx_fltr(__priv, __args...) \
  471. stmmac_do_callback(__priv, mac, del_hw_vlan_rx_fltr, __args)
  472. #define stmmac_restore_hw_vlan_rx_fltr(__priv, __args...) \
  473. stmmac_do_void_callback(__priv, mac, restore_hw_vlan_rx_fltr, __args)
  474. #define stmmac_get_mac_tx_timestamp(__priv, __args...) \
  475. stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args)
  476. #define stmmac_sarc_configure(__priv, __args...) \
  477. stmmac_do_void_callback(__priv, mac, sarc_configure, __args)
  478. #define stmmac_config_l3_filter(__priv, __args...) \
  479. stmmac_do_callback(__priv, mac, config_l3_filter, __args)
  480. #define stmmac_config_l4_filter(__priv, __args...) \
  481. stmmac_do_callback(__priv, mac, config_l4_filter, __args)
  482. #define stmmac_set_arp_offload(__priv, __args...) \
  483. stmmac_do_void_callback(__priv, mac, set_arp_offload, __args)
  484. #define stmmac_est_configure(__priv, __args...) \
  485. stmmac_do_callback(__priv, mac, est_configure, __args)
  486. #define stmmac_est_irq_status(__priv, __args...) \
  487. stmmac_do_void_callback(__priv, mac, est_irq_status, __args)
  488. #define stmmac_fpe_configure(__priv, __args...) \
  489. stmmac_do_void_callback(__priv, mac, fpe_configure, __args)
  490. #define stmmac_fpe_send_mpacket(__priv, __args...) \
  491. stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args)
  492. #define stmmac_fpe_irq_status(__priv, __args...) \
  493. stmmac_do_callback(__priv, mac, fpe_irq_status, __args)
  494. struct stmmac_priv;
  495. /* PTP and HW Timer helpers */
  496. struct stmmac_hwtimestamp {
  497. void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data);
  498. void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock,
  499. int gmac4, u32 *ssinc);
  500. int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec);
  501. int (*config_addend) (void __iomem *ioaddr, u32 addend);
  502. int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec,
  503. int add_sub, int gmac4);
  504. void (*get_systime) (void __iomem *ioaddr, u64 *systime);
  505. void (*get_ptptime)(void __iomem *ioaddr, u64 *ptp_time);
  506. void (*timestamp_interrupt)(struct stmmac_priv *priv);
  507. };
  508. #define stmmac_config_hw_tstamping(__priv, __args...) \
  509. stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args)
  510. #define stmmac_config_sub_second_increment(__priv, __args...) \
  511. stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args)
  512. #define stmmac_init_systime(__priv, __args...) \
  513. stmmac_do_callback(__priv, ptp, init_systime, __args)
  514. #define stmmac_config_addend(__priv, __args...) \
  515. stmmac_do_callback(__priv, ptp, config_addend, __args)
  516. #define stmmac_adjust_systime(__priv, __args...) \
  517. stmmac_do_callback(__priv, ptp, adjust_systime, __args)
  518. #define stmmac_get_systime(__priv, __args...) \
  519. stmmac_do_void_callback(__priv, ptp, get_systime, __args)
  520. #define stmmac_get_ptptime(__priv, __args...) \
  521. stmmac_do_void_callback(__priv, ptp, get_ptptime, __args)
  522. #define stmmac_timestamp_interrupt(__priv, __args...) \
  523. stmmac_do_void_callback(__priv, ptp, timestamp_interrupt, __args)
  524. /* Helpers to manage the descriptors for chain and ring modes */
  525. struct stmmac_mode_ops {
  526. void (*init) (void *des, dma_addr_t phy_addr, unsigned int size,
  527. unsigned int extend_desc);
  528. unsigned int (*is_jumbo_frm) (int len, int ehn_desc);
  529. int (*jumbo_frm)(void *priv, struct sk_buff *skb, int csum);
  530. int (*set_16kib_bfsize)(int mtu);
  531. void (*init_desc3)(struct dma_desc *p);
  532. void (*refill_desc3) (void *priv, struct dma_desc *p);
  533. void (*clean_desc3) (void *priv, struct dma_desc *p);
  534. };
  535. #define stmmac_mode_init(__priv, __args...) \
  536. stmmac_do_void_callback(__priv, mode, init, __args)
  537. #define stmmac_is_jumbo_frm(__priv, __args...) \
  538. stmmac_do_callback(__priv, mode, is_jumbo_frm, __args)
  539. #define stmmac_jumbo_frm(__priv, __args...) \
  540. stmmac_do_callback(__priv, mode, jumbo_frm, __args)
  541. #define stmmac_set_16kib_bfsize(__priv, __args...) \
  542. stmmac_do_callback(__priv, mode, set_16kib_bfsize, __args)
  543. #define stmmac_init_desc3(__priv, __args...) \
  544. stmmac_do_void_callback(__priv, mode, init_desc3, __args)
  545. #define stmmac_refill_desc3(__priv, __args...) \
  546. stmmac_do_void_callback(__priv, mode, refill_desc3, __args)
  547. #define stmmac_clean_desc3(__priv, __args...) \
  548. stmmac_do_void_callback(__priv, mode, clean_desc3, __args)
  549. struct tc_cls_u32_offload;
  550. struct tc_cbs_qopt_offload;
  551. struct flow_cls_offload;
  552. struct tc_taprio_qopt_offload;
  553. struct tc_etf_qopt_offload;
  554. struct stmmac_tc_ops {
  555. int (*init)(struct stmmac_priv *priv);
  556. int (*setup_cls_u32)(struct stmmac_priv *priv,
  557. struct tc_cls_u32_offload *cls);
  558. int (*setup_cbs)(struct stmmac_priv *priv,
  559. struct tc_cbs_qopt_offload *qopt);
  560. int (*setup_cls)(struct stmmac_priv *priv,
  561. struct flow_cls_offload *cls);
  562. int (*setup_taprio)(struct stmmac_priv *priv,
  563. struct tc_taprio_qopt_offload *qopt);
  564. int (*setup_etf)(struct stmmac_priv *priv,
  565. struct tc_etf_qopt_offload *qopt);
  566. };
  567. #define stmmac_tc_init(__priv, __args...) \
  568. stmmac_do_callback(__priv, tc, init, __args)
  569. #define stmmac_tc_setup_cls_u32(__priv, __args...) \
  570. stmmac_do_callback(__priv, tc, setup_cls_u32, __args)
  571. #define stmmac_tc_setup_cbs(__priv, __args...) \
  572. stmmac_do_callback(__priv, tc, setup_cbs, __args)
  573. #define stmmac_tc_setup_cls(__priv, __args...) \
  574. stmmac_do_callback(__priv, tc, setup_cls, __args)
  575. #define stmmac_tc_setup_taprio(__priv, __args...) \
  576. stmmac_do_callback(__priv, tc, setup_taprio, __args)
  577. #define stmmac_tc_setup_etf(__priv, __args...) \
  578. stmmac_do_callback(__priv, tc, setup_etf, __args)
  579. struct stmmac_counters;
  580. struct stmmac_mmc_ops {
  581. void (*ctrl)(void __iomem *ioaddr, unsigned int mode);
  582. void (*intr_all_mask)(void __iomem *ioaddr);
  583. void (*read)(void __iomem *ioaddr, struct stmmac_counters *mmc);
  584. };
  585. #define stmmac_mmc_ctrl(__priv, __args...) \
  586. stmmac_do_void_callback(__priv, mmc, ctrl, __args)
  587. #define stmmac_mmc_intr_all_mask(__priv, __args...) \
  588. stmmac_do_void_callback(__priv, mmc, intr_all_mask, __args)
  589. #define stmmac_mmc_read(__priv, __args...) \
  590. stmmac_do_void_callback(__priv, mmc, read, __args)
  591. struct stmmac_regs_off {
  592. u32 ptp_off;
  593. u32 mmc_off;
  594. };
  595. extern const struct stmmac_ops dwmac100_ops;
  596. extern const struct stmmac_dma_ops dwmac100_dma_ops;
  597. extern const struct stmmac_ops dwmac1000_ops;
  598. extern const struct stmmac_dma_ops dwmac1000_dma_ops;
  599. extern const struct stmmac_ops dwmac4_ops;
  600. extern const struct stmmac_dma_ops dwmac4_dma_ops;
  601. extern const struct stmmac_ops dwmac410_ops;
  602. extern const struct stmmac_dma_ops dwmac410_dma_ops;
  603. extern const struct stmmac_ops dwmac510_ops;
  604. extern const struct stmmac_tc_ops dwmac510_tc_ops;
  605. extern const struct stmmac_ops dwxgmac210_ops;
  606. extern const struct stmmac_ops dwxlgmac2_ops;
  607. extern const struct stmmac_dma_ops dwxgmac210_dma_ops;
  608. extern const struct stmmac_desc_ops dwxgmac210_desc_ops;
  609. extern const struct stmmac_mmc_ops dwmac_mmc_ops;
  610. extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
  611. #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */
  612. #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */
  613. int stmmac_hwif_init(struct stmmac_priv *priv);
  614. #endif /* __STMMAC_HWIF_H__ */