pkt_cls.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef __LINUX_PKT_CLS_H
  3. #define __LINUX_PKT_CLS_H
  4. #include <linux/types.h>
  5. #include <linux/pkt_sched.h>
  6. #define TC_COOKIE_MAX_SIZE 16
  7. /* Action attributes */
  8. enum {
  9. TCA_ACT_UNSPEC,
  10. TCA_ACT_KIND,
  11. TCA_ACT_OPTIONS,
  12. TCA_ACT_INDEX,
  13. TCA_ACT_STATS,
  14. TCA_ACT_PAD,
  15. TCA_ACT_COOKIE,
  16. __TCA_ACT_MAX
  17. };
  18. #define TCA_ACT_MAX __TCA_ACT_MAX
  19. #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
  20. #define TCA_ACT_MAX_PRIO 32
  21. #define TCA_ACT_BIND 1
  22. #define TCA_ACT_NOBIND 0
  23. #define TCA_ACT_UNBIND 1
  24. #define TCA_ACT_NOUNBIND 0
  25. #define TCA_ACT_REPLACE 1
  26. #define TCA_ACT_NOREPLACE 0
  27. #define TC_ACT_UNSPEC (-1)
  28. #define TC_ACT_OK 0
  29. #define TC_ACT_RECLASSIFY 1
  30. #define TC_ACT_SHOT 2
  31. #define TC_ACT_PIPE 3
  32. #define TC_ACT_STOLEN 4
  33. #define TC_ACT_QUEUED 5
  34. #define TC_ACT_REPEAT 6
  35. #define TC_ACT_REDIRECT 7
  36. #define TC_ACT_TRAP 8 /* For hw path, this means "trap to cpu"
  37. * and don't further process the frame
  38. * in hardware. For sw path, this is
  39. * equivalent of TC_ACT_STOLEN - drop
  40. * the skb and act like everything
  41. * is alright.
  42. */
  43. #define TC_ACT_VALUE_MAX TC_ACT_TRAP
  44. /* There is a special kind of actions called "extended actions",
  45. * which need a value parameter. These have a local opcode located in
  46. * the highest nibble, starting from 1. The rest of the bits
  47. * are used to carry the value. These two parts together make
  48. * a combined opcode.
  49. */
  50. #define __TC_ACT_EXT_SHIFT 28
  51. #define __TC_ACT_EXT(local) ((local) << __TC_ACT_EXT_SHIFT)
  52. #define TC_ACT_EXT_VAL_MASK ((1 << __TC_ACT_EXT_SHIFT) - 1)
  53. #define TC_ACT_EXT_OPCODE(combined) ((combined) & (~TC_ACT_EXT_VAL_MASK))
  54. #define TC_ACT_EXT_CMP(combined, opcode) (TC_ACT_EXT_OPCODE(combined) == opcode)
  55. #define TC_ACT_JUMP __TC_ACT_EXT(1)
  56. #define TC_ACT_GOTO_CHAIN __TC_ACT_EXT(2)
  57. #define TC_ACT_EXT_OPCODE_MAX TC_ACT_GOTO_CHAIN
  58. /* Action type identifiers*/
  59. enum {
  60. TCA_ID_UNSPEC=0,
  61. TCA_ID_POLICE=1,
  62. /* other actions go here */
  63. __TCA_ID_MAX=255
  64. };
  65. #define TCA_ID_MAX __TCA_ID_MAX
  66. struct tc_police {
  67. __u32 index;
  68. int action;
  69. #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
  70. #define TC_POLICE_OK TC_ACT_OK
  71. #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
  72. #define TC_POLICE_SHOT TC_ACT_SHOT
  73. #define TC_POLICE_PIPE TC_ACT_PIPE
  74. __u32 limit;
  75. __u32 burst;
  76. __u32 mtu;
  77. struct tc_ratespec rate;
  78. struct tc_ratespec peakrate;
  79. int refcnt;
  80. int bindcnt;
  81. __u32 capab;
  82. };
  83. struct tcf_t {
  84. __u64 install;
  85. __u64 lastuse;
  86. __u64 expires;
  87. __u64 firstuse;
  88. };
  89. struct tc_cnt {
  90. int refcnt;
  91. int bindcnt;
  92. };
  93. #define tc_gen \
  94. __u32 index; \
  95. __u32 capab; \
  96. int action; \
  97. int refcnt; \
  98. int bindcnt
  99. enum {
  100. TCA_POLICE_UNSPEC,
  101. TCA_POLICE_TBF,
  102. TCA_POLICE_RATE,
  103. TCA_POLICE_PEAKRATE,
  104. TCA_POLICE_AVRATE,
  105. TCA_POLICE_RESULT,
  106. TCA_POLICE_TM,
  107. TCA_POLICE_PAD,
  108. __TCA_POLICE_MAX
  109. #define TCA_POLICE_RESULT TCA_POLICE_RESULT
  110. };
  111. #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
  112. /* tca flags definitions */
  113. #define TCA_CLS_FLAGS_SKIP_HW (1 << 0) /* don't offload filter to HW */
  114. #define TCA_CLS_FLAGS_SKIP_SW (1 << 1) /* don't use filter in SW */
  115. #define TCA_CLS_FLAGS_IN_HW (1 << 2) /* filter is offloaded to HW */
  116. #define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */
  117. #define TCA_CLS_FLAGS_VERBOSE (1 << 4) /* verbose logging */
  118. /* U32 filters */
  119. #define TC_U32_HTID(h) ((h)&0xFFF00000)
  120. #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
  121. #define TC_U32_HASH(h) (((h)>>12)&0xFF)
  122. #define TC_U32_NODE(h) ((h)&0xFFF)
  123. #define TC_U32_KEY(h) ((h)&0xFFFFF)
  124. #define TC_U32_UNSPEC 0
  125. #define TC_U32_ROOT (0xFFF00000)
  126. enum {
  127. TCA_U32_UNSPEC,
  128. TCA_U32_CLASSID,
  129. TCA_U32_HASH,
  130. TCA_U32_LINK,
  131. TCA_U32_DIVISOR,
  132. TCA_U32_SEL,
  133. TCA_U32_POLICE,
  134. TCA_U32_ACT,
  135. TCA_U32_INDEV,
  136. TCA_U32_PCNT,
  137. TCA_U32_MARK,
  138. TCA_U32_FLAGS,
  139. TCA_U32_PAD,
  140. __TCA_U32_MAX
  141. };
  142. #define TCA_U32_MAX (__TCA_U32_MAX - 1)
  143. struct tc_u32_key {
  144. __be32 mask;
  145. __be32 val;
  146. int off;
  147. int offmask;
  148. };
  149. struct tc_u32_sel {
  150. unsigned char flags;
  151. unsigned char offshift;
  152. unsigned char nkeys;
  153. __be16 offmask;
  154. __u16 off;
  155. short offoff;
  156. short hoff;
  157. __be32 hmask;
  158. struct tc_u32_key keys[0];
  159. };
  160. struct tc_u32_mark {
  161. __u32 val;
  162. __u32 mask;
  163. __u32 success;
  164. };
  165. struct tc_u32_pcnt {
  166. __u64 rcnt;
  167. __u64 rhit;
  168. __u64 kcnts[0];
  169. };
  170. /* Flags */
  171. #define TC_U32_TERMINAL 1
  172. #define TC_U32_OFFSET 2
  173. #define TC_U32_VAROFFSET 4
  174. #define TC_U32_EAT 8
  175. #define TC_U32_MAXDEPTH 8
  176. /* RSVP filter */
  177. enum {
  178. TCA_RSVP_UNSPEC,
  179. TCA_RSVP_CLASSID,
  180. TCA_RSVP_DST,
  181. TCA_RSVP_SRC,
  182. TCA_RSVP_PINFO,
  183. TCA_RSVP_POLICE,
  184. TCA_RSVP_ACT,
  185. __TCA_RSVP_MAX
  186. };
  187. #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
  188. struct tc_rsvp_gpi {
  189. __u32 key;
  190. __u32 mask;
  191. int offset;
  192. };
  193. struct tc_rsvp_pinfo {
  194. struct tc_rsvp_gpi dpi;
  195. struct tc_rsvp_gpi spi;
  196. __u8 protocol;
  197. __u8 tunnelid;
  198. __u8 tunnelhdr;
  199. __u8 pad;
  200. };
  201. /* ROUTE filter */
  202. enum {
  203. TCA_ROUTE4_UNSPEC,
  204. TCA_ROUTE4_CLASSID,
  205. TCA_ROUTE4_TO,
  206. TCA_ROUTE4_FROM,
  207. TCA_ROUTE4_IIF,
  208. TCA_ROUTE4_POLICE,
  209. TCA_ROUTE4_ACT,
  210. __TCA_ROUTE4_MAX
  211. };
  212. #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
  213. /* FW filter */
  214. enum {
  215. TCA_FW_UNSPEC,
  216. TCA_FW_CLASSID,
  217. TCA_FW_POLICE,
  218. TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
  219. TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
  220. TCA_FW_MASK,
  221. __TCA_FW_MAX
  222. };
  223. #define TCA_FW_MAX (__TCA_FW_MAX - 1)
  224. /* TC index filter */
  225. enum {
  226. TCA_TCINDEX_UNSPEC,
  227. TCA_TCINDEX_HASH,
  228. TCA_TCINDEX_MASK,
  229. TCA_TCINDEX_SHIFT,
  230. TCA_TCINDEX_FALL_THROUGH,
  231. TCA_TCINDEX_CLASSID,
  232. TCA_TCINDEX_POLICE,
  233. TCA_TCINDEX_ACT,
  234. __TCA_TCINDEX_MAX
  235. };
  236. #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
  237. /* Flow filter */
  238. enum {
  239. FLOW_KEY_SRC,
  240. FLOW_KEY_DST,
  241. FLOW_KEY_PROTO,
  242. FLOW_KEY_PROTO_SRC,
  243. FLOW_KEY_PROTO_DST,
  244. FLOW_KEY_IIF,
  245. FLOW_KEY_PRIORITY,
  246. FLOW_KEY_MARK,
  247. FLOW_KEY_NFCT,
  248. FLOW_KEY_NFCT_SRC,
  249. FLOW_KEY_NFCT_DST,
  250. FLOW_KEY_NFCT_PROTO_SRC,
  251. FLOW_KEY_NFCT_PROTO_DST,
  252. FLOW_KEY_RTCLASSID,
  253. FLOW_KEY_SKUID,
  254. FLOW_KEY_SKGID,
  255. FLOW_KEY_VLAN_TAG,
  256. FLOW_KEY_RXHASH,
  257. __FLOW_KEY_MAX,
  258. };
  259. #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
  260. enum {
  261. FLOW_MODE_MAP,
  262. FLOW_MODE_HASH,
  263. };
  264. enum {
  265. TCA_FLOW_UNSPEC,
  266. TCA_FLOW_KEYS,
  267. TCA_FLOW_MODE,
  268. TCA_FLOW_BASECLASS,
  269. TCA_FLOW_RSHIFT,
  270. TCA_FLOW_ADDEND,
  271. TCA_FLOW_MASK,
  272. TCA_FLOW_XOR,
  273. TCA_FLOW_DIVISOR,
  274. TCA_FLOW_ACT,
  275. TCA_FLOW_POLICE,
  276. TCA_FLOW_EMATCHES,
  277. TCA_FLOW_PERTURB,
  278. __TCA_FLOW_MAX
  279. };
  280. #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
  281. /* Basic filter */
  282. enum {
  283. TCA_BASIC_UNSPEC,
  284. TCA_BASIC_CLASSID,
  285. TCA_BASIC_EMATCHES,
  286. TCA_BASIC_ACT,
  287. TCA_BASIC_POLICE,
  288. __TCA_BASIC_MAX
  289. };
  290. #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
  291. /* Cgroup classifier */
  292. enum {
  293. TCA_CGROUP_UNSPEC,
  294. TCA_CGROUP_ACT,
  295. TCA_CGROUP_POLICE,
  296. TCA_CGROUP_EMATCHES,
  297. __TCA_CGROUP_MAX,
  298. };
  299. #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
  300. /* BPF classifier */
  301. #define TCA_BPF_FLAG_ACT_DIRECT (1 << 0)
  302. enum {
  303. TCA_BPF_UNSPEC,
  304. TCA_BPF_ACT,
  305. TCA_BPF_POLICE,
  306. TCA_BPF_CLASSID,
  307. TCA_BPF_OPS_LEN,
  308. TCA_BPF_OPS,
  309. TCA_BPF_FD,
  310. TCA_BPF_NAME,
  311. TCA_BPF_FLAGS,
  312. TCA_BPF_FLAGS_GEN,
  313. TCA_BPF_TAG,
  314. TCA_BPF_ID,
  315. __TCA_BPF_MAX,
  316. };
  317. #define TCA_BPF_MAX (__TCA_BPF_MAX - 1)
  318. /* Flower classifier */
  319. enum {
  320. TCA_FLOWER_UNSPEC,
  321. TCA_FLOWER_CLASSID,
  322. TCA_FLOWER_INDEV,
  323. TCA_FLOWER_ACT,
  324. TCA_FLOWER_KEY_ETH_DST, /* ETH_ALEN */
  325. TCA_FLOWER_KEY_ETH_DST_MASK, /* ETH_ALEN */
  326. TCA_FLOWER_KEY_ETH_SRC, /* ETH_ALEN */
  327. TCA_FLOWER_KEY_ETH_SRC_MASK, /* ETH_ALEN */
  328. TCA_FLOWER_KEY_ETH_TYPE, /* be16 */
  329. TCA_FLOWER_KEY_IP_PROTO, /* u8 */
  330. TCA_FLOWER_KEY_IPV4_SRC, /* be32 */
  331. TCA_FLOWER_KEY_IPV4_SRC_MASK, /* be32 */
  332. TCA_FLOWER_KEY_IPV4_DST, /* be32 */
  333. TCA_FLOWER_KEY_IPV4_DST_MASK, /* be32 */
  334. TCA_FLOWER_KEY_IPV6_SRC, /* struct in6_addr */
  335. TCA_FLOWER_KEY_IPV6_SRC_MASK, /* struct in6_addr */
  336. TCA_FLOWER_KEY_IPV6_DST, /* struct in6_addr */
  337. TCA_FLOWER_KEY_IPV6_DST_MASK, /* struct in6_addr */
  338. TCA_FLOWER_KEY_TCP_SRC, /* be16 */
  339. TCA_FLOWER_KEY_TCP_DST, /* be16 */
  340. TCA_FLOWER_KEY_UDP_SRC, /* be16 */
  341. TCA_FLOWER_KEY_UDP_DST, /* be16 */
  342. TCA_FLOWER_FLAGS,
  343. TCA_FLOWER_KEY_VLAN_ID, /* be16 */
  344. TCA_FLOWER_KEY_VLAN_PRIO, /* u8 */
  345. TCA_FLOWER_KEY_VLAN_ETH_TYPE, /* be16 */
  346. TCA_FLOWER_KEY_ENC_KEY_ID, /* be32 */
  347. TCA_FLOWER_KEY_ENC_IPV4_SRC, /* be32 */
  348. TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK,/* be32 */
  349. TCA_FLOWER_KEY_ENC_IPV4_DST, /* be32 */
  350. TCA_FLOWER_KEY_ENC_IPV4_DST_MASK,/* be32 */
  351. TCA_FLOWER_KEY_ENC_IPV6_SRC, /* struct in6_addr */
  352. TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK,/* struct in6_addr */
  353. TCA_FLOWER_KEY_ENC_IPV6_DST, /* struct in6_addr */
  354. TCA_FLOWER_KEY_ENC_IPV6_DST_MASK,/* struct in6_addr */
  355. TCA_FLOWER_KEY_TCP_SRC_MASK, /* be16 */
  356. TCA_FLOWER_KEY_TCP_DST_MASK, /* be16 */
  357. TCA_FLOWER_KEY_UDP_SRC_MASK, /* be16 */
  358. TCA_FLOWER_KEY_UDP_DST_MASK, /* be16 */
  359. TCA_FLOWER_KEY_SCTP_SRC_MASK, /* be16 */
  360. TCA_FLOWER_KEY_SCTP_DST_MASK, /* be16 */
  361. TCA_FLOWER_KEY_SCTP_SRC, /* be16 */
  362. TCA_FLOWER_KEY_SCTP_DST, /* be16 */
  363. TCA_FLOWER_KEY_ENC_UDP_SRC_PORT, /* be16 */
  364. TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK, /* be16 */
  365. TCA_FLOWER_KEY_ENC_UDP_DST_PORT, /* be16 */
  366. TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, /* be16 */
  367. TCA_FLOWER_KEY_FLAGS, /* be32 */
  368. TCA_FLOWER_KEY_FLAGS_MASK, /* be32 */
  369. TCA_FLOWER_KEY_ICMPV4_CODE, /* u8 */
  370. TCA_FLOWER_KEY_ICMPV4_CODE_MASK,/* u8 */
  371. TCA_FLOWER_KEY_ICMPV4_TYPE, /* u8 */
  372. TCA_FLOWER_KEY_ICMPV4_TYPE_MASK,/* u8 */
  373. TCA_FLOWER_KEY_ICMPV6_CODE, /* u8 */
  374. TCA_FLOWER_KEY_ICMPV6_CODE_MASK,/* u8 */
  375. TCA_FLOWER_KEY_ICMPV6_TYPE, /* u8 */
  376. TCA_FLOWER_KEY_ICMPV6_TYPE_MASK,/* u8 */
  377. TCA_FLOWER_KEY_ARP_SIP, /* be32 */
  378. TCA_FLOWER_KEY_ARP_SIP_MASK, /* be32 */
  379. TCA_FLOWER_KEY_ARP_TIP, /* be32 */
  380. TCA_FLOWER_KEY_ARP_TIP_MASK, /* be32 */
  381. TCA_FLOWER_KEY_ARP_OP, /* u8 */
  382. TCA_FLOWER_KEY_ARP_OP_MASK, /* u8 */
  383. TCA_FLOWER_KEY_ARP_SHA, /* ETH_ALEN */
  384. TCA_FLOWER_KEY_ARP_SHA_MASK, /* ETH_ALEN */
  385. TCA_FLOWER_KEY_ARP_THA, /* ETH_ALEN */
  386. TCA_FLOWER_KEY_ARP_THA_MASK, /* ETH_ALEN */
  387. TCA_FLOWER_KEY_MPLS_TTL, /* u8 - 8 bits */
  388. TCA_FLOWER_KEY_MPLS_BOS, /* u8 - 1 bit */
  389. TCA_FLOWER_KEY_MPLS_TC, /* u8 - 3 bits */
  390. TCA_FLOWER_KEY_MPLS_LABEL, /* be32 - 20 bits */
  391. TCA_FLOWER_KEY_TCP_FLAGS, /* be16 */
  392. TCA_FLOWER_KEY_TCP_FLAGS_MASK, /* be16 */
  393. TCA_FLOWER_KEY_IP_TOS, /* u8 */
  394. TCA_FLOWER_KEY_IP_TOS_MASK, /* u8 */
  395. TCA_FLOWER_KEY_IP_TTL, /* u8 */
  396. TCA_FLOWER_KEY_IP_TTL_MASK, /* u8 */
  397. TCA_FLOWER_KEY_CVLAN_ID, /* be16 */
  398. TCA_FLOWER_KEY_CVLAN_PRIO, /* u8 */
  399. TCA_FLOWER_KEY_CVLAN_ETH_TYPE, /* be16 */
  400. TCA_FLOWER_KEY_ENC_IP_TOS, /* u8 */
  401. TCA_FLOWER_KEY_ENC_IP_TOS_MASK, /* u8 */
  402. TCA_FLOWER_KEY_ENC_IP_TTL, /* u8 */
  403. TCA_FLOWER_KEY_ENC_IP_TTL_MASK, /* u8 */
  404. TCA_FLOWER_KEY_ENC_OPTS,
  405. TCA_FLOWER_KEY_ENC_OPTS_MASK,
  406. __TCA_FLOWER_MAX,
  407. };
  408. #define TCA_FLOWER_MAX (__TCA_FLOWER_MAX - 1)
  409. enum {
  410. TCA_FLOWER_KEY_ENC_OPTS_UNSPEC,
  411. TCA_FLOWER_KEY_ENC_OPTS_GENEVE, /* Nested
  412. * TCA_FLOWER_KEY_ENC_OPT_GENEVE_
  413. * attributes
  414. */
  415. __TCA_FLOWER_KEY_ENC_OPTS_MAX,
  416. };
  417. #define TCA_FLOWER_KEY_ENC_OPTS_MAX (__TCA_FLOWER_KEY_ENC_OPTS_MAX - 1)
  418. enum {
  419. TCA_FLOWER_KEY_ENC_OPT_GENEVE_UNSPEC,
  420. TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS, /* u16 */
  421. TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE, /* u8 */
  422. TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA, /* 4 to 128 bytes */
  423. __TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX,
  424. };
  425. #define TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX \
  426. (__TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX - 1)
  427. enum {
  428. TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
  429. TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
  430. };
  431. /* Match-all classifier */
  432. enum {
  433. TCA_MATCHALL_UNSPEC,
  434. TCA_MATCHALL_CLASSID,
  435. TCA_MATCHALL_ACT,
  436. TCA_MATCHALL_FLAGS,
  437. __TCA_MATCHALL_MAX,
  438. };
  439. #define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1)
  440. /* Extended Matches */
  441. struct tcf_ematch_tree_hdr {
  442. __u16 nmatches;
  443. __u16 progid;
  444. };
  445. enum {
  446. TCA_EMATCH_TREE_UNSPEC,
  447. TCA_EMATCH_TREE_HDR,
  448. TCA_EMATCH_TREE_LIST,
  449. __TCA_EMATCH_TREE_MAX
  450. };
  451. #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
  452. struct tcf_ematch_hdr {
  453. __u16 matchid;
  454. __u16 kind;
  455. __u16 flags;
  456. __u16 pad; /* currently unused */
  457. };
  458. /* 0 1
  459. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
  460. * +-----------------------+-+-+---+
  461. * | Unused |S|I| R |
  462. * +-----------------------+-+-+---+
  463. *
  464. * R(2) ::= relation to next ematch
  465. * where: 0 0 END (last ematch)
  466. * 0 1 AND
  467. * 1 0 OR
  468. * 1 1 Unused (invalid)
  469. * I(1) ::= invert result
  470. * S(1) ::= simple payload
  471. */
  472. #define TCF_EM_REL_END 0
  473. #define TCF_EM_REL_AND (1<<0)
  474. #define TCF_EM_REL_OR (1<<1)
  475. #define TCF_EM_INVERT (1<<2)
  476. #define TCF_EM_SIMPLE (1<<3)
  477. #define TCF_EM_REL_MASK 3
  478. #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
  479. enum {
  480. TCF_LAYER_LINK,
  481. TCF_LAYER_NETWORK,
  482. TCF_LAYER_TRANSPORT,
  483. __TCF_LAYER_MAX
  484. };
  485. #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
  486. /* Ematch type assignments
  487. * 1..32767 Reserved for ematches inside kernel tree
  488. * 32768..65535 Free to use, not reliable
  489. */
  490. #define TCF_EM_CONTAINER 0
  491. #define TCF_EM_CMP 1
  492. #define TCF_EM_NBYTE 2
  493. #define TCF_EM_U32 3
  494. #define TCF_EM_META 4
  495. #define TCF_EM_TEXT 5
  496. #define TCF_EM_VLAN 6
  497. #define TCF_EM_CANID 7
  498. #define TCF_EM_IPSET 8
  499. #define TCF_EM_IPT 9
  500. #define TCF_EM_MAX 9
  501. enum {
  502. TCF_EM_PROG_TC
  503. };
  504. enum {
  505. TCF_EM_OPND_EQ,
  506. TCF_EM_OPND_GT,
  507. TCF_EM_OPND_LT
  508. };
  509. #endif