xgene_enet_cle.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /* Applied Micro X-Gene SoC Ethernet Classifier structures
  2. *
  3. * Copyright (c) 2016, Applied Micro Circuits Corporation
  4. * Authors: Khuong Dinh <kdinh@apm.com>
  5. * Tanmay Inamdar <tinamdar@apm.com>
  6. * Iyappan Subramanian <isubramanian@apm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __XGENE_ENET_CLE_H__
  22. #define __XGENE_ENET_CLE_H__
  23. #include <linux/io.h>
  24. #include <linux/random.h>
  25. /* Register offsets */
  26. #define INDADDR 0x04
  27. #define INDCMD 0x08
  28. #define INDCMD_STATUS 0x0c
  29. #define DATA_RAM0 0x10
  30. #define SNPTR0 0x0100
  31. #define SPPTR0 0x0104
  32. #define DFCLSRESDBPTR0 0x0108
  33. #define DFCLSRESDB00 0x010c
  34. #define RSS_CTRL0 0x0000013c
  35. #define CLE_CMD_TO 10 /* ms */
  36. #define CLE_PKTRAM_SIZE 256 /* bytes */
  37. #define CLE_PORT_OFFSET 0x200
  38. #define CLE_DRAM_REGS 17
  39. #define CLE_DN_TYPE_LEN 2
  40. #define CLE_DN_TYPE_POS 0
  41. #define CLE_DN_LASTN_LEN 1
  42. #define CLE_DN_LASTN_POS 2
  43. #define CLE_DN_HLS_LEN 1
  44. #define CLE_DN_HLS_POS 3
  45. #define CLE_DN_EXT_LEN 2
  46. #define CLE_DN_EXT_POS 4
  47. #define CLE_DN_BSTOR_LEN 2
  48. #define CLE_DN_BSTOR_POS 6
  49. #define CLE_DN_SBSTOR_LEN 2
  50. #define CLE_DN_SBSTOR_POS 8
  51. #define CLE_DN_RPTR_LEN 12
  52. #define CLE_DN_RPTR_POS 12
  53. #define CLE_BR_VALID_LEN 1
  54. #define CLE_BR_VALID_POS 0
  55. #define CLE_BR_NPPTR_LEN 9
  56. #define CLE_BR_NPPTR_POS 1
  57. #define CLE_BR_JB_LEN 1
  58. #define CLE_BR_JB_POS 10
  59. #define CLE_BR_JR_LEN 1
  60. #define CLE_BR_JR_POS 11
  61. #define CLE_BR_OP_LEN 3
  62. #define CLE_BR_OP_POS 12
  63. #define CLE_BR_NNODE_LEN 9
  64. #define CLE_BR_NNODE_POS 15
  65. #define CLE_BR_NBR_LEN 5
  66. #define CLE_BR_NBR_POS 24
  67. #define CLE_BR_DATA_LEN 16
  68. #define CLE_BR_DATA_POS 0
  69. #define CLE_BR_MASK_LEN 16
  70. #define CLE_BR_MASK_POS 16
  71. #define CLE_KN_PRIO_POS 0
  72. #define CLE_KN_PRIO_LEN 3
  73. #define CLE_KN_RPTR_POS 3
  74. #define CLE_KN_RPTR_LEN 10
  75. #define CLE_TYPE_POS 0
  76. #define CLE_TYPE_LEN 2
  77. #define CLE_DROP_POS 28
  78. #define CLE_DROP_LEN 1
  79. #define CLE_DSTQIDL_POS 25
  80. #define CLE_DSTQIDL_LEN 7
  81. #define CLE_DSTQIDH_POS 0
  82. #define CLE_DSTQIDH_LEN 5
  83. #define CLE_FPSEL_POS 21
  84. #define CLE_FPSEL_LEN 4
  85. #define CLE_NFPSEL_POS 17
  86. #define CLE_NFPSEL_LEN 4
  87. #define CLE_PRIORITY_POS 5
  88. #define CLE_PRIORITY_LEN 3
  89. #define JMP_ABS 0
  90. #define JMP_REL 1
  91. #define JMP_FW 0
  92. #define JMP_BW 1
  93. enum xgene_cle_ptree_nodes {
  94. PKT_TYPE_NODE,
  95. PKT_PROT_NODE,
  96. RSS_IPV4_TCP_NODE,
  97. RSS_IPV4_UDP_NODE,
  98. RSS_IPV4_OTHERS_NODE,
  99. LAST_NODE,
  100. MAX_NODES
  101. };
  102. enum xgene_cle_byte_store {
  103. NO_BYTE,
  104. FIRST_BYTE,
  105. SECOND_BYTE,
  106. BOTH_BYTES
  107. };
  108. /* Preclassification operation types */
  109. enum xgene_cle_node_type {
  110. INV,
  111. KN,
  112. EWDN,
  113. RES_NODE
  114. };
  115. /* Preclassification operation types */
  116. enum xgene_cle_op_type {
  117. EQT,
  118. NEQT,
  119. LTEQT,
  120. GTEQT,
  121. AND,
  122. NAND
  123. };
  124. enum xgene_cle_parser {
  125. PARSER0,
  126. PARSER1,
  127. PARSER2,
  128. PARSER_ALL
  129. };
  130. #define XGENE_CLE_DRAM(type) (((type) & 0xf) << 28)
  131. enum xgene_cle_dram_type {
  132. PKT_RAM,
  133. RSS_IDT,
  134. RSS_IPV4_HASH_SKEY,
  135. PTREE_RAM = 0xc,
  136. AVL_RAM,
  137. DB_RAM
  138. };
  139. enum xgene_cle_cmd_type {
  140. CLE_CMD_WR = 1,
  141. CLE_CMD_RD = 2,
  142. CLE_CMD_AVL_ADD = 8,
  143. CLE_CMD_AVL_DEL = 16,
  144. CLE_CMD_AVL_SRCH = 32
  145. };
  146. enum xgene_cle_ipv4_rss_hashtype {
  147. RSS_IPV4_8B,
  148. RSS_IPV4_12B,
  149. };
  150. enum xgene_cle_prot_type {
  151. XGENE_CLE_TCP,
  152. XGENE_CLE_UDP,
  153. XGENE_CLE_ESP,
  154. XGENE_CLE_OTHER
  155. };
  156. enum xgene_cle_prot_version {
  157. XGENE_CLE_IPV4,
  158. };
  159. enum xgene_cle_ptree_dbptrs {
  160. DB_RES_DROP,
  161. DB_RES_DEF,
  162. DB_RES_ACCEPT,
  163. DB_MAX_PTRS
  164. };
  165. /* RSS sideband signal info */
  166. #define SB_IPFRAG_POS 0
  167. #define SB_IPFRAG_LEN 1
  168. #define SB_IPPROT_POS 1
  169. #define SB_IPPROT_LEN 2
  170. #define SB_IPVER_POS 3
  171. #define SB_IPVER_LEN 1
  172. #define SB_HDRLEN_POS 4
  173. #define SB_HDRLEN_LEN 12
  174. /* RSS indirection table */
  175. #define XGENE_CLE_IDT_ENTRIES 128
  176. #define IDT_DSTQID_POS 0
  177. #define IDT_DSTQID_LEN 12
  178. #define IDT_FPSEL_POS 12
  179. #define IDT_FPSEL_LEN 5
  180. #define IDT_NFPSEL_POS 17
  181. #define IDT_NFPSEL_LEN 5
  182. #define IDT_FPSEL1_POS 12
  183. #define IDT_FPSEL1_LEN 4
  184. #define IDT_NFPSEL1_POS 16
  185. #define IDT_NFPSEL1_LEN 4
  186. struct xgene_cle_ptree_branch {
  187. bool valid;
  188. u16 next_packet_pointer;
  189. bool jump_bw;
  190. bool jump_rel;
  191. u8 operation;
  192. u16 next_node;
  193. u8 next_branch;
  194. u16 data;
  195. u16 mask;
  196. };
  197. struct xgene_cle_ptree_ewdn {
  198. u8 node_type;
  199. bool last_node;
  200. bool hdr_len_store;
  201. u8 hdr_extn;
  202. u8 byte_store;
  203. u8 search_byte_store;
  204. u16 result_pointer;
  205. u8 num_branches;
  206. struct xgene_cle_ptree_branch branch[6];
  207. };
  208. struct xgene_cle_ptree_key {
  209. u8 priority;
  210. u16 result_pointer;
  211. };
  212. struct xgene_cle_ptree_kn {
  213. u8 node_type;
  214. u8 num_keys;
  215. struct xgene_cle_ptree_key key[32];
  216. };
  217. struct xgene_cle_dbptr {
  218. u8 split_boundary;
  219. u8 mirror_nxtfpsel;
  220. u8 mirror_fpsel;
  221. u16 mirror_dstqid;
  222. u8 drop;
  223. u8 mirror;
  224. u8 hdr_data_split;
  225. u64 hopinfomsbs;
  226. u8 DR;
  227. u8 HR;
  228. u64 hopinfomlsbs;
  229. u16 h0enq_num;
  230. u8 h0fpsel;
  231. u8 nxtfpsel;
  232. u8 fpsel;
  233. u16 dstqid;
  234. u8 cle_priority;
  235. u8 cle_flowgroup;
  236. u8 cle_perflow;
  237. u8 cle_insert_timestamp;
  238. u8 stash;
  239. u8 in;
  240. u8 perprioen;
  241. u8 perflowgroupen;
  242. u8 perflowen;
  243. u8 selhash;
  244. u8 selhdrext;
  245. u8 mirror_nxtfpsel_msb;
  246. u8 mirror_fpsel_msb;
  247. u8 hfpsel_msb;
  248. u8 nxtfpsel_msb;
  249. u8 fpsel_msb;
  250. };
  251. struct xgene_cle_ptree {
  252. struct xgene_cle_ptree_kn *kn;
  253. struct xgene_cle_dbptr *dbptr;
  254. u32 num_kn;
  255. u32 num_dbptr;
  256. u32 start_node;
  257. u32 start_pkt;
  258. u32 start_dbptr;
  259. };
  260. struct xgene_enet_cle {
  261. void __iomem *base;
  262. struct xgene_cle_ptree ptree;
  263. enum xgene_cle_parser active_parser;
  264. u32 parsers;
  265. u32 max_nodes;
  266. u32 max_dbptrs;
  267. u32 jump_bytes;
  268. };
  269. extern const struct xgene_cle_ops xgene_cle3in_ops;
  270. #endif /* __XGENE_ENET_CLE_H__ */