xgene_enet_cle.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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_PRIORITY_POS 5
  86. #define CLE_PRIORITY_LEN 3
  87. #define JMP_ABS 0
  88. #define JMP_REL 1
  89. #define JMP_FW 0
  90. #define JMP_BW 1
  91. enum xgene_cle_ptree_nodes {
  92. PKT_TYPE_NODE,
  93. PKT_PROT_NODE,
  94. RSS_IPV4_TCP_NODE,
  95. RSS_IPV4_UDP_NODE,
  96. LAST_NODE,
  97. MAX_NODES
  98. };
  99. enum xgene_cle_byte_store {
  100. NO_BYTE,
  101. FIRST_BYTE,
  102. SECOND_BYTE,
  103. BOTH_BYTES
  104. };
  105. /* Preclassification operation types */
  106. enum xgene_cle_node_type {
  107. INV,
  108. KN,
  109. EWDN,
  110. RES_NODE
  111. };
  112. /* Preclassification operation types */
  113. enum xgene_cle_op_type {
  114. EQT,
  115. NEQT,
  116. LTEQT,
  117. GTEQT,
  118. AND,
  119. NAND
  120. };
  121. enum xgene_cle_parser {
  122. PARSER0,
  123. PARSER1,
  124. PARSER2,
  125. PARSER_ALL
  126. };
  127. #define XGENE_CLE_DRAM(type) (((type) & 0xf) << 28)
  128. enum xgene_cle_dram_type {
  129. PKT_RAM,
  130. RSS_IDT,
  131. RSS_IPV4_HASH_SKEY,
  132. PTREE_RAM = 0xc,
  133. AVL_RAM,
  134. DB_RAM
  135. };
  136. enum xgene_cle_cmd_type {
  137. CLE_CMD_WR = 1,
  138. CLE_CMD_RD = 2,
  139. CLE_CMD_AVL_ADD = 8,
  140. CLE_CMD_AVL_DEL = 16,
  141. CLE_CMD_AVL_SRCH = 32
  142. };
  143. enum xgene_cle_ipv4_rss_hashtype {
  144. RSS_IPV4_8B,
  145. RSS_IPV4_12B,
  146. };
  147. enum xgene_cle_prot_type {
  148. XGENE_CLE_TCP,
  149. XGENE_CLE_UDP,
  150. XGENE_CLE_ESP,
  151. XGENE_CLE_OTHER
  152. };
  153. enum xgene_cle_prot_version {
  154. XGENE_CLE_IPV4,
  155. };
  156. enum xgene_cle_ptree_dbptrs {
  157. DB_RES_DROP,
  158. DB_RES_DEF,
  159. DB_RES_ACCEPT,
  160. DB_MAX_PTRS
  161. };
  162. /* RSS sideband signal info */
  163. #define SB_IPFRAG_POS 0
  164. #define SB_IPFRAG_LEN 1
  165. #define SB_IPPROT_POS 1
  166. #define SB_IPPROT_LEN 2
  167. #define SB_IPVER_POS 3
  168. #define SB_IPVER_LEN 1
  169. #define SB_HDRLEN_POS 4
  170. #define SB_HDRLEN_LEN 12
  171. /* RSS indirection table */
  172. #define XGENE_CLE_IDT_ENTRIES 128
  173. #define IDT_DSTQID_POS 0
  174. #define IDT_DSTQID_LEN 12
  175. #define IDT_FPSEL_POS 12
  176. #define IDT_FPSEL_LEN 4
  177. #define IDT_NFPSEL_POS 16
  178. #define IDT_NFPSEL_LEN 4
  179. struct xgene_cle_ptree_branch {
  180. bool valid;
  181. u16 next_packet_pointer;
  182. bool jump_bw;
  183. bool jump_rel;
  184. u8 operation;
  185. u16 next_node;
  186. u8 next_branch;
  187. u16 data;
  188. u16 mask;
  189. };
  190. struct xgene_cle_ptree_ewdn {
  191. u8 node_type;
  192. bool last_node;
  193. bool hdr_len_store;
  194. u8 hdr_extn;
  195. u8 byte_store;
  196. u8 search_byte_store;
  197. u16 result_pointer;
  198. u8 num_branches;
  199. struct xgene_cle_ptree_branch branch[6];
  200. };
  201. struct xgene_cle_ptree_key {
  202. u8 priority;
  203. u16 result_pointer;
  204. };
  205. struct xgene_cle_ptree_kn {
  206. u8 node_type;
  207. u8 num_keys;
  208. struct xgene_cle_ptree_key key[32];
  209. };
  210. struct xgene_cle_dbptr {
  211. u8 split_boundary;
  212. u8 mirror_nxtfpsel;
  213. u8 mirror_fpsel;
  214. u16 mirror_dstqid;
  215. u8 drop;
  216. u8 mirror;
  217. u8 hdr_data_split;
  218. u64 hopinfomsbs;
  219. u8 DR;
  220. u8 HR;
  221. u64 hopinfomlsbs;
  222. u16 h0enq_num;
  223. u8 h0fpsel;
  224. u8 nxtfpsel;
  225. u8 fpsel;
  226. u16 dstqid;
  227. u8 cle_priority;
  228. u8 cle_flowgroup;
  229. u8 cle_perflow;
  230. u8 cle_insert_timestamp;
  231. u8 stash;
  232. u8 in;
  233. u8 perprioen;
  234. u8 perflowgroupen;
  235. u8 perflowen;
  236. u8 selhash;
  237. u8 selhdrext;
  238. u8 mirror_nxtfpsel_msb;
  239. u8 mirror_fpsel_msb;
  240. u8 hfpsel_msb;
  241. u8 nxtfpsel_msb;
  242. u8 fpsel_msb;
  243. };
  244. struct xgene_cle_ptree {
  245. struct xgene_cle_ptree_ewdn *dn;
  246. struct xgene_cle_ptree_kn *kn;
  247. struct xgene_cle_dbptr *dbptr;
  248. u32 num_dn;
  249. u32 num_kn;
  250. u32 num_dbptr;
  251. u32 start_node;
  252. u32 start_pkt;
  253. u32 start_dbptr;
  254. };
  255. struct xgene_enet_cle {
  256. void __iomem *base;
  257. struct xgene_cle_ptree ptree;
  258. enum xgene_cle_parser active_parser;
  259. u32 parsers;
  260. u32 max_nodes;
  261. u32 max_dbptrs;
  262. u32 jump_bytes;
  263. };
  264. extern struct xgene_cle_ops xgene_cle3in_ops;
  265. #endif /* __XGENE_ENET_CLE_H__ */