fman.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. /*
  2. * Copyright 2008-2015 Freescale Semiconductor Inc.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. * * Neither the name of Freescale Semiconductor nor the
  12. * names of its contributors may be used to endorse or promote products
  13. * derived from this software without specific prior written permission.
  14. *
  15. *
  16. * ALTERNATIVELY, this software may be distributed under the terms of the
  17. * GNU General Public License ("GPL") as published by the Free Software
  18. * Foundation, either version 2 of that License or (at your option) any
  19. * later version.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
  22. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
  25. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. #ifndef __FM_H
  33. #define __FM_H
  34. #include <linux/io.h>
  35. /* FM Frame descriptor macros */
  36. /* Frame queue Context Override */
  37. #define FM_FD_CMD_FCO 0x80000000
  38. #define FM_FD_CMD_RPD 0x40000000 /* Read Prepended Data */
  39. #define FM_FD_CMD_DTC 0x10000000 /* Do L4 Checksum */
  40. /* TX-Port: Unsupported Format */
  41. #define FM_FD_ERR_UNSUPPORTED_FORMAT 0x04000000
  42. /* TX Port: Length Error */
  43. #define FM_FD_ERR_LENGTH 0x02000000
  44. #define FM_FD_ERR_DMA 0x01000000 /* DMA Data error */
  45. /* IPR frame (not error) */
  46. #define FM_FD_IPR 0x00000001
  47. /* IPR non-consistent-sp */
  48. #define FM_FD_ERR_IPR_NCSP (0x00100000 | FM_FD_IPR)
  49. /* IPR error */
  50. #define FM_FD_ERR_IPR (0x00200000 | FM_FD_IPR)
  51. /* IPR timeout */
  52. #define FM_FD_ERR_IPR_TO (0x00300000 | FM_FD_IPR)
  53. /* TX Port: Length Error */
  54. #define FM_FD_ERR_IPRE (FM_FD_ERR_IPR & ~FM_FD_IPR)
  55. /* Rx FIFO overflow, FCS error, code error, running disparity error
  56. * (SGMII and TBI modes), FIFO parity error. PHY Sequence error,
  57. * PHY error control character detected.
  58. */
  59. #define FM_FD_ERR_PHYSICAL 0x00080000
  60. /* Frame too long OR Frame size exceeds max_length_frame */
  61. #define FM_FD_ERR_SIZE 0x00040000
  62. /* classification discard */
  63. #define FM_FD_ERR_CLS_DISCARD 0x00020000
  64. /* Extract Out of Frame */
  65. #define FM_FD_ERR_EXTRACTION 0x00008000
  66. /* No Scheme Selected */
  67. #define FM_FD_ERR_NO_SCHEME 0x00004000
  68. /* Keysize Overflow */
  69. #define FM_FD_ERR_KEYSIZE_OVERFLOW 0x00002000
  70. /* Frame color is red */
  71. #define FM_FD_ERR_COLOR_RED 0x00000800
  72. /* Frame color is yellow */
  73. #define FM_FD_ERR_COLOR_YELLOW 0x00000400
  74. /* Parser Time out Exceed */
  75. #define FM_FD_ERR_PRS_TIMEOUT 0x00000080
  76. /* Invalid Soft Parser instruction */
  77. #define FM_FD_ERR_PRS_ILL_INSTRUCT 0x00000040
  78. /* Header error was identified during parsing */
  79. #define FM_FD_ERR_PRS_HDR_ERR 0x00000020
  80. /* Frame parsed beyind 256 first bytes */
  81. #define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008
  82. /* non Frame-Manager error */
  83. #define FM_FD_RX_STATUS_ERR_NON_FM 0x00400000
  84. /* FMan driver defines */
  85. #define FMAN_BMI_FIFO_UNITS 0x100
  86. #define OFFSET_UNITS 16
  87. /* BMan defines */
  88. #define BM_MAX_NUM_OF_POOLS 64 /* Buffers pools */
  89. #define FMAN_PORT_MAX_EXT_POOLS_NUM 8 /* External BM pools per Rx port */
  90. struct fman; /* FMan data */
  91. /* Enum for defining port types */
  92. enum fman_port_type {
  93. FMAN_PORT_TYPE_TX = 0, /* TX Port */
  94. FMAN_PORT_TYPE_RX, /* RX Port */
  95. };
  96. struct fman_rev_info {
  97. u8 major; /* Major revision */
  98. u8 minor; /* Minor revision */
  99. };
  100. enum fman_exceptions {
  101. FMAN_EX_DMA_BUS_ERROR = 0, /* DMA bus error. */
  102. FMAN_EX_DMA_READ_ECC, /* Read Buffer ECC error */
  103. FMAN_EX_DMA_SYSTEM_WRITE_ECC, /* Write Buffer ECC err on sys side */
  104. FMAN_EX_DMA_FM_WRITE_ECC, /* Write Buffer ECC error on FM side */
  105. FMAN_EX_DMA_SINGLE_PORT_ECC, /* Single Port ECC error on FM side */
  106. FMAN_EX_FPM_STALL_ON_TASKS, /* Stall of tasks on FPM */
  107. FMAN_EX_FPM_SINGLE_ECC, /* Single ECC on FPM. */
  108. FMAN_EX_FPM_DOUBLE_ECC, /* Double ECC error on FPM ram access */
  109. FMAN_EX_QMI_SINGLE_ECC, /* Single ECC on QMI. */
  110. FMAN_EX_QMI_DOUBLE_ECC, /* Double bit ECC occurred on QMI */
  111. FMAN_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/* DeQ from unknown port id */
  112. FMAN_EX_BMI_LIST_RAM_ECC, /* Linked List RAM ECC error */
  113. FMAN_EX_BMI_STORAGE_PROFILE_ECC,/* storage profile */
  114. FMAN_EX_BMI_STATISTICS_RAM_ECC,/* Statistics RAM ECC Err Enable */
  115. FMAN_EX_BMI_DISPATCH_RAM_ECC, /* Dispatch RAM ECC Error Enable */
  116. FMAN_EX_IRAM_ECC, /* Double bit ECC occurred on IRAM */
  117. FMAN_EX_MURAM_ECC /* Double bit ECC occurred on MURAM */
  118. };
  119. /* Parse results memory layout */
  120. struct fman_prs_result {
  121. u8 lpid; /* Logical port id */
  122. u8 shimr; /* Shim header result */
  123. u16 l2r; /* Layer 2 result */
  124. u16 l3r; /* Layer 3 result */
  125. u8 l4r; /* Layer 4 result */
  126. u8 cplan; /* Classification plan id */
  127. u16 nxthdr; /* Next Header */
  128. u16 cksum; /* Running-sum */
  129. /* Flags&fragment-offset field of the last IP-header */
  130. u16 flags_frag_off;
  131. /* Routing type field of a IPV6 routing extension header */
  132. u8 route_type;
  133. /* Routing Extension Header Present; last bit is IP valid */
  134. u8 rhp_ip_valid;
  135. u8 shim_off[2]; /* Shim offset */
  136. u8 ip_pid_off; /* IP PID (last IP-proto) offset */
  137. u8 eth_off; /* ETH offset */
  138. u8 llc_snap_off; /* LLC_SNAP offset */
  139. u8 vlan_off[2]; /* VLAN offset */
  140. u8 etype_off; /* ETYPE offset */
  141. u8 pppoe_off; /* PPP offset */
  142. u8 mpls_off[2]; /* MPLS offset */
  143. u8 ip_off[2]; /* IP offset */
  144. u8 gre_off; /* GRE offset */
  145. u8 l4_off; /* Layer 4 offset */
  146. u8 nxthdr_off; /* Parser end point */
  147. };
  148. /* A structure for defining buffer prefix area content. */
  149. struct fman_buffer_prefix_content {
  150. /* Number of bytes to be left at the beginning of the external
  151. * buffer; Note that the private-area will start from the base
  152. * of the buffer address.
  153. */
  154. u16 priv_data_size;
  155. /* true to pass the parse result to/from the FM;
  156. * User may use FM_PORT_GetBufferPrsResult() in
  157. * order to get the parser-result from a buffer.
  158. */
  159. bool pass_prs_result;
  160. /* true to pass the timeStamp to/from the FM User */
  161. bool pass_time_stamp;
  162. /* true to pass the KG hash result to/from the FM User may
  163. * use FM_PORT_GetBufferHashResult() in order to get the
  164. * parser-result from a buffer.
  165. */
  166. bool pass_hash_result;
  167. /* Add all other Internal-Context information: AD,
  168. * hash-result, key, etc.
  169. */
  170. u16 data_align;
  171. };
  172. /* A structure of information about each of the external
  173. * buffer pools used by a port or storage-profile.
  174. */
  175. struct fman_ext_pool_params {
  176. u8 id; /* External buffer pool id */
  177. u16 size; /* External buffer pool buffer size */
  178. };
  179. /* A structure for informing the driver about the external
  180. * buffer pools allocated in the BM and used by a port or a
  181. * storage-profile.
  182. */
  183. struct fman_ext_pools {
  184. u8 num_of_pools_used; /* Number of pools use by this port */
  185. struct fman_ext_pool_params ext_buf_pool[FMAN_PORT_MAX_EXT_POOLS_NUM];
  186. /* Parameters for each port */
  187. };
  188. /* A structure for defining BM pool depletion criteria */
  189. struct fman_buf_pool_depletion {
  190. /* select mode in which pause frames will be sent after a
  191. * number of pools (all together!) are depleted
  192. */
  193. bool pools_grp_mode_enable;
  194. /* the number of depleted pools that will invoke pause
  195. * frames transmission.
  196. */
  197. u8 num_of_pools;
  198. /* For each pool, true if it should be considered for
  199. * depletion (Note - this pool must be used by this port!).
  200. */
  201. bool pools_to_consider[BM_MAX_NUM_OF_POOLS];
  202. /* select mode in which pause frames will be sent
  203. * after a single-pool is depleted;
  204. */
  205. bool single_pool_mode_enable;
  206. /* For each pool, true if it should be considered
  207. * for depletion (Note - this pool must be used by this port!)
  208. */
  209. bool pools_to_consider_for_single_mode[BM_MAX_NUM_OF_POOLS];
  210. };
  211. /* Enum for inter-module interrupts registration */
  212. enum fman_event_modules {
  213. FMAN_MOD_MAC = 0, /* MAC event */
  214. FMAN_MOD_FMAN_CTRL, /* FMAN Controller */
  215. FMAN_MOD_DUMMY_LAST
  216. };
  217. /* Enum for interrupts types */
  218. enum fman_intr_type {
  219. FMAN_INTR_TYPE_ERR,
  220. FMAN_INTR_TYPE_NORMAL
  221. };
  222. /* Enum for inter-module interrupts registration */
  223. enum fman_inter_module_event {
  224. FMAN_EV_ERR_MAC0 = 0, /* MAC 0 error event */
  225. FMAN_EV_ERR_MAC1, /* MAC 1 error event */
  226. FMAN_EV_ERR_MAC2, /* MAC 2 error event */
  227. FMAN_EV_ERR_MAC3, /* MAC 3 error event */
  228. FMAN_EV_ERR_MAC4, /* MAC 4 error event */
  229. FMAN_EV_ERR_MAC5, /* MAC 5 error event */
  230. FMAN_EV_ERR_MAC6, /* MAC 6 error event */
  231. FMAN_EV_ERR_MAC7, /* MAC 7 error event */
  232. FMAN_EV_ERR_MAC8, /* MAC 8 error event */
  233. FMAN_EV_ERR_MAC9, /* MAC 9 error event */
  234. FMAN_EV_MAC0, /* MAC 0 event (Magic packet detection) */
  235. FMAN_EV_MAC1, /* MAC 1 event (Magic packet detection) */
  236. FMAN_EV_MAC2, /* MAC 2 (Magic packet detection) */
  237. FMAN_EV_MAC3, /* MAC 3 (Magic packet detection) */
  238. FMAN_EV_MAC4, /* MAC 4 (Magic packet detection) */
  239. FMAN_EV_MAC5, /* MAC 5 (Magic packet detection) */
  240. FMAN_EV_MAC6, /* MAC 6 (Magic packet detection) */
  241. FMAN_EV_MAC7, /* MAC 7 (Magic packet detection) */
  242. FMAN_EV_MAC8, /* MAC 8 event (Magic packet detection) */
  243. FMAN_EV_MAC9, /* MAC 9 event (Magic packet detection) */
  244. FMAN_EV_FMAN_CTRL_0, /* Fman controller event 0 */
  245. FMAN_EV_FMAN_CTRL_1, /* Fman controller event 1 */
  246. FMAN_EV_FMAN_CTRL_2, /* Fman controller event 2 */
  247. FMAN_EV_FMAN_CTRL_3, /* Fman controller event 3 */
  248. FMAN_EV_CNT
  249. };
  250. struct fman_intr_src {
  251. void (*isr_cb)(void *src_arg);
  252. void *src_handle;
  253. };
  254. /* Structure for port-FM communication during fman_port_init. */
  255. struct fman_port_init_params {
  256. u8 port_id; /* port Id */
  257. enum fman_port_type port_type; /* Port type */
  258. u16 port_speed; /* Port speed */
  259. u16 liodn_offset; /* Port's requested resource */
  260. u8 num_of_tasks; /* Port's requested resource */
  261. u8 num_of_extra_tasks; /* Port's requested resource */
  262. u8 num_of_open_dmas; /* Port's requested resource */
  263. u8 num_of_extra_open_dmas; /* Port's requested resource */
  264. u32 size_of_fifo; /* Port's requested resource */
  265. u32 extra_size_of_fifo; /* Port's requested resource */
  266. u8 deq_pipeline_depth; /* Port's requested resource */
  267. u16 max_frame_length; /* Port's max frame length. */
  268. u16 liodn_base;
  269. /* LIODN base for this port, to be used together with LIODN offset. */
  270. };
  271. void fman_get_revision(struct fman *fman, struct fman_rev_info *rev_info);
  272. void fman_register_intr(struct fman *fman, enum fman_event_modules mod,
  273. u8 mod_id, enum fman_intr_type intr_type,
  274. void (*f_isr)(void *h_src_arg), void *h_src_arg);
  275. void fman_unregister_intr(struct fman *fman, enum fman_event_modules mod,
  276. u8 mod_id, enum fman_intr_type intr_type);
  277. int fman_set_port_params(struct fman *fman,
  278. struct fman_port_init_params *port_params);
  279. int fman_reset_mac(struct fman *fman, u8 mac_id);
  280. u16 fman_get_clock_freq(struct fman *fman);
  281. u32 fman_get_bmi_max_fifo_size(struct fman *fman);
  282. int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl);
  283. u32 fman_get_qman_channel_id(struct fman *fman, u32 port_id);
  284. struct resource *fman_get_mem_region(struct fman *fman);
  285. u16 fman_get_max_frm(void);
  286. int fman_get_rx_extra_headroom(void);
  287. struct fman *fman_bind(struct device *dev);
  288. #endif /* __FM_H */