DPDK  18.05.1-rc1
rte_flow.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016 6WIND S.A.
3  * Copyright 2016 Mellanox Technologies, Ltd
4  */
5 
6 #ifndef RTE_FLOW_H_
7 #define RTE_FLOW_H_
8 
17 #include <stddef.h>
18 #include <stdint.h>
19 
20 #include <rte_arp.h>
21 #include <rte_ether.h>
22 #include <rte_eth_ctrl.h>
23 #include <rte_icmp.h>
24 #include <rte_ip.h>
25 #include <rte_sctp.h>
26 #include <rte_tcp.h>
27 #include <rte_udp.h>
28 #include <rte_byteorder.h>
29 #include <rte_esp.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
72 struct rte_flow_attr {
73  uint32_t group;
74  uint32_t priority;
75  uint32_t ingress:1;
76  uint32_t egress:1;
95  uint32_t transfer:1;
96  uint32_t reserved:29;
97 };
98 
125 
135 
145 
153 
163 
173 
183 
193 
200 
207 
214 
221 
228 
235 
242 
249 
256 
263 
270 
277 
284 
291 
303 
312 
321 
330 
337 
344 
351 
358 
365 
372 
379 
386 
393 
401 
409 
416 };
417 
430  uint32_t num;
431 };
432 
434 #ifndef __cplusplus
436  .num = 0x00000000,
437 };
438 #endif
439 
459  uint32_t id;
460 };
461 
463 #ifndef __cplusplus
465  .id = 0x00000000,
466 };
467 #endif
468 
490  uint32_t index;
491 };
492 
494 #ifndef __cplusplus
496  .index = 0x00000000,
497 };
498 #endif
499 
516  uint32_t id;
517 };
518 
520 #ifndef __cplusplus
522  .id = 0xffffffff,
523 };
524 #endif
525 
545  uint32_t relative:1;
546  uint32_t search:1;
547  uint32_t reserved:30;
548  int32_t offset;
549  uint16_t limit;
550  uint16_t length;
551  const uint8_t *pattern;
552 };
553 
555 #ifndef __cplusplus
557  .relative = 1,
558  .search = 1,
559  .reserved = 0x3fffffff,
560  .offset = 0xffffffff,
561  .limit = 0xffff,
562  .length = 0xffff,
563  .pattern = NULL,
564 };
565 #endif
566 
579  struct ether_addr dst;
580  struct ether_addr src;
582 };
583 
585 #ifndef __cplusplus
587  .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
588  .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
589  .type = RTE_BE16(0x0000),
590 };
591 #endif
592 
605 };
606 
608 #ifndef __cplusplus
610  .tci = RTE_BE16(0x0fff),
611  .inner_type = RTE_BE16(0x0000),
612 };
613 #endif
614 
623  struct ipv4_hdr hdr;
624 };
625 
627 #ifndef __cplusplus
629  .hdr = {
630  .src_addr = RTE_BE32(0xffffffff),
631  .dst_addr = RTE_BE32(0xffffffff),
632  },
633 };
634 #endif
635 
645  struct ipv6_hdr hdr;
646 };
647 
649 #ifndef __cplusplus
651  .hdr = {
652  .src_addr =
653  "\xff\xff\xff\xff\xff\xff\xff\xff"
654  "\xff\xff\xff\xff\xff\xff\xff\xff",
655  .dst_addr =
656  "\xff\xff\xff\xff\xff\xff\xff\xff"
657  "\xff\xff\xff\xff\xff\xff\xff\xff",
658  },
659 };
660 #endif
661 
668  struct icmp_hdr hdr;
669 };
670 
672 #ifndef __cplusplus
674  .hdr = {
675  .icmp_type = 0xff,
676  .icmp_code = 0xff,
677  },
678 };
679 #endif
680 
687  struct udp_hdr hdr;
688 };
689 
691 #ifndef __cplusplus
693  .hdr = {
694  .src_port = RTE_BE16(0xffff),
695  .dst_port = RTE_BE16(0xffff),
696  },
697 };
698 #endif
699 
706  struct tcp_hdr hdr;
707 };
708 
710 #ifndef __cplusplus
712  .hdr = {
713  .src_port = RTE_BE16(0xffff),
714  .dst_port = RTE_BE16(0xffff),
715  },
716 };
717 #endif
718 
725  struct sctp_hdr hdr;
726 };
727 
729 #ifndef __cplusplus
731  .hdr = {
732  .src_port = RTE_BE16(0xffff),
733  .dst_port = RTE_BE16(0xffff),
734  },
735 };
736 #endif
737 
744  uint8_t flags;
745  uint8_t rsvd0[3];
746  uint8_t vni[3];
747  uint8_t rsvd1;
748 };
749 
751 #ifndef __cplusplus
753  .vni = "\xff\xff\xff",
754 };
755 #endif
756 
773  uint8_t in_ecid_e;
774  uint8_t ecid_e;
776 };
777 
779 #ifndef __cplusplus
781  .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
782 };
783 #endif
784 
799  uint8_t tni[3];
800  uint8_t flow_id;
801 };
802 
804 #ifndef __cplusplus
806  .tni = "\xff\xff\xff",
807 };
808 #endif
809 
819  uint8_t label_tc_s[3];
820  uint8_t ttl;
821 };
822 
824 #ifndef __cplusplus
826  .label_tc_s = "\xff\xff\xf0",
827 };
828 #endif
829 
842 };
843 
845 #ifndef __cplusplus
847  .protocol = RTE_BE16(0xffff),
848 };
849 #endif
850 
869  uint32_t thresh;
870 };
871 
873 #ifndef __cplusplus
875  .thresh = 0xffffffff,
876 };
877 #endif
878 
891  uint8_t v_pt_rsv_flags;
892  uint8_t msg_type;
895 };
896 
898 #ifndef __cplusplus
900  .teid = RTE_BE32(0xffffffff),
901 };
902 #endif
903 
910  struct esp_hdr hdr;
911 };
912 
914 #ifndef __cplusplus
916  .hdr = {
917  .spi = 0xffffffff,
918  },
919 };
920 #endif
921 
934  uint8_t vni[3];
935  uint8_t rsvd1;
936 };
937 
939 #ifndef __cplusplus
941  .vni = "\xff\xff\xff",
942 };
943 #endif
944 
951  uint8_t flags;
952  uint8_t rsvd0[2];
953  uint8_t protocol;
954  uint8_t vni[3];
955  uint8_t rsvd1;
956 };
957 
959 #ifndef __cplusplus
961  .vni = "\xff\xff\xff",
962 };
963 #endif
964 
973  uint8_t hln;
974  uint8_t pln;
976  struct ether_addr sha;
978  struct ether_addr tha;
980 };
981 
983 #ifndef __cplusplus
984 static const struct rte_flow_item_arp_eth_ipv4
986  .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
987  .spa = RTE_BE32(0xffffffff),
988  .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
989  .tpa = RTE_BE32(0xffffffff),
990 };
991 #endif
992 
1004  uint8_t next_hdr;
1005 };
1006 
1008 #ifndef __cplusplus
1009 static const
1011  .next_hdr = 0xff,
1012 };
1013 #endif
1014 
1021  uint8_t type;
1022  uint8_t code;
1023  uint16_t checksum;
1024 };
1025 
1027 #ifndef __cplusplus
1029  .type = 0xff,
1030  .code = 0xff,
1031 };
1032 #endif
1033 
1040  uint8_t type;
1041  uint8_t code;
1044  uint8_t target_addr[16];
1045 };
1046 
1048 #ifndef __cplusplus
1049 static const
1051  .target_addr =
1052  "\xff\xff\xff\xff\xff\xff\xff\xff"
1053  "\xff\xff\xff\xff\xff\xff\xff\xff",
1054 };
1055 #endif
1056 
1063  uint8_t type;
1064  uint8_t code;
1071  uint8_t target_addr[16];
1072 };
1073 
1075 #ifndef __cplusplus
1076 static const
1078  .target_addr =
1079  "\xff\xff\xff\xff\xff\xff\xff\xff"
1080  "\xff\xff\xff\xff\xff\xff\xff\xff",
1081 };
1082 #endif
1083 
1096  uint8_t type;
1097  uint8_t length;
1098 };
1099 
1101 #ifndef __cplusplus
1102 static const struct rte_flow_item_icmp6_nd_opt
1104  .type = 0xff,
1105 };
1106 #endif
1107 
1120  uint8_t type;
1121  uint8_t length;
1122  struct ether_addr sla;
1123 };
1124 
1126 #ifndef __cplusplus
1127 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1129  .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1130 };
1131 #endif
1132 
1145  uint8_t type;
1146  uint8_t length;
1147  struct ether_addr tla;
1148 };
1149 
1151 #ifndef __cplusplus
1152 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1154  .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1155 };
1156 #endif
1157 
1177  uint32_t id;
1178 };
1179 
1215  const void *spec;
1216  const void *last;
1217  const void *mask;
1218 };
1219 
1253 
1261 
1269 
1278 
1286 
1294 
1301 
1310 
1320 
1329 
1337 
1345 
1353 
1360 
1368 
1376 
1384 
1392 
1400 
1408 
1417 
1426 
1434 
1442 
1450 
1458 
1466 
1474 
1482 
1491 
1499 
1508 };
1509 
1521  uint32_t id;
1522 };
1523 
1537  uint32_t group;
1538 };
1539 
1546  uint16_t index;
1547 };
1548 
1549 
1576  uint32_t shared:1;
1577  uint32_t reserved:31;
1578  uint32_t id;
1579 };
1580 
1587  uint32_t reset:1;
1588  uint32_t hits_set:1;
1589  uint32_t bytes_set:1;
1590  uint32_t reserved:29;
1591  uint64_t hits;
1592  uint64_t bytes;
1593 };
1594 
1638  uint32_t level;
1639  uint64_t types;
1640  uint32_t key_len;
1641  uint32_t queue_num;
1642  const uint8_t *key;
1643  const uint16_t *queue;
1644 };
1645 
1659  uint32_t original:1;
1660  uint32_t reserved:31;
1661  uint32_t id;
1662 };
1663 
1673  uint32_t original:1;
1674  uint32_t reserved:31;
1675  uint32_t index;
1676 };
1677 
1686  uint32_t original:1;
1687  uint32_t reserved:31;
1688  uint32_t id;
1689 };
1690 
1700  uint32_t mtr_id;
1701 };
1702 
1730 };
1731 
1739  uint8_t mpls_ttl;
1740 };
1741 
1749  uint8_t nw_ttl;
1750 };
1751 
1760 };
1761 
1770 };
1771 
1779  uint8_t vlan_pcp;
1780 };
1781 
1790 };
1791 
1800 };
1801 
1835 };
1836 
1869 };
1870 
1871 /*
1872  * Definition of a single action.
1873  *
1874  * A list of actions is terminated by a END action.
1875  *
1876  * For simple actions without a configuration structure, conf remains NULL.
1877  */
1878 struct rte_flow_action {
1879  enum rte_flow_action_type type;
1880  const void *conf;
1881 };
1882 
1889 struct rte_flow;
1890 
1915 };
1916 
1930  const void *cause;
1931  const char *message;
1932 };
1933 
1986 int
1987 rte_flow_validate(uint16_t port_id,
1988  const struct rte_flow_attr *attr,
1989  const struct rte_flow_item pattern[],
1990  const struct rte_flow_action actions[],
1991  struct rte_flow_error *error);
1992 
2013 struct rte_flow *
2014 rte_flow_create(uint16_t port_id,
2015  const struct rte_flow_attr *attr,
2016  const struct rte_flow_item pattern[],
2017  const struct rte_flow_action actions[],
2018  struct rte_flow_error *error);
2019 
2040 int
2041 rte_flow_destroy(uint16_t port_id,
2042  struct rte_flow *flow,
2043  struct rte_flow_error *error);
2044 
2061 int
2062 rte_flow_flush(uint16_t port_id,
2063  struct rte_flow_error *error);
2064 
2089 int
2090 rte_flow_query(uint16_t port_id,
2091  struct rte_flow *flow,
2092  const struct rte_flow_action *action,
2093  void *data,
2094  struct rte_flow_error *error);
2095 
2137 int
2138 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2139 
2157 int
2158 rte_flow_error_set(struct rte_flow_error *error,
2159  int code,
2160  enum rte_flow_error_type type,
2161  const void *cause,
2162  const char *message);
2163 
2171  size_t size;
2174  struct rte_flow_action *actions;
2175  uint8_t data[];
2176 };
2177 
2198 size_t
2199 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2200  const struct rte_flow_attr *attr,
2201  const struct rte_flow_item *items,
2202  const struct rte_flow_action *actions);
2203 
2204 #ifdef __cplusplus
2205 }
2206 #endif
2207 
2208 #endif /* RTE_FLOW_H_ */
uint32_t reserved
Definition: rte_flow.h:96
static const struct rte_flow_item_icmp6_nd_opt_sla_eth rte_flow_item_icmp6_nd_opt_sla_eth_mask
Definition: rte_flow.h:1128
rte_be16_t c_rsvd0_ver
Definition: rte_flow.h:840
rte_be16_t ver_opt_len_o_c_rsvd0
Definition: rte_flow.h:932
int rte_flow_validate(uint16_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error)
static const struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask
Definition: rte_flow.h:1077
static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask
Definition: rte_flow.h:650
rte_be16_t epcp_edei_in_ecid_b
Definition: rte_flow.h:770
rte_be16_t protocol
Definition: rte_flow.h:933
uint32_t num
Definition: rte_flow.h:430
uint32_t rte_be32_t
uint32_t src_addr
Definition: rte_ip.h:40
uint32_t original
Definition: rte_flow.h:1659
struct ether_addr src
Definition: rte_flow.h:580
int rte_flow_query(uint16_t port_id, struct rte_flow *flow, const struct rte_flow_action *action, void *data, struct rte_flow_error *error)
uint32_t group
Definition: rte_flow.h:73
struct rte_flow_item * definition
Definition: rte_flow.h:1834
static const struct rte_flow_item_gre rte_flow_item_gre_mask
Definition: rte_flow.h:846
struct rte_flow_attr attr
Definition: rte_flow.h:2172
rte_be16_t msg_len
Definition: rte_flow.h:893
static const struct rte_flow_item_gtp rte_flow_item_gtp_mask
Definition: rte_flow.h:899
static const struct rte_flow_item_icmp rte_flow_item_icmp_mask
Definition: rte_flow.h:673
struct tcp_hdr hdr
Definition: rte_flow.h:706
static const struct rte_flow_item_geneve rte_flow_item_geneve_mask
Definition: rte_flow.h:940
static const struct rte_flow_item_sctp rte_flow_item_sctp_mask
Definition: rte_flow.h:730
int rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error)
static const struct rte_flow_item_any rte_flow_item_any_mask
Definition: rte_flow.h:435
static const struct rte_flow_item_esp rte_flow_item_esp_mask
Definition: rte_flow.h:915
struct sctp_hdr hdr
Definition: rte_flow.h:725
uint8_t v_pt_rsv_flags
Definition: rte_flow.h:891
rte_be16_t protocol
Definition: rte_flow.h:798
uint32_t reserved
Definition: rte_flow.h:547
static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask
Definition: rte_flow.h:1028
struct rte_flow_action * actions
Definition: rte_flow.h:2174
uint8_t data[]
Definition: rte_flow.h:2175
static const struct rte_flow_item_icmp6_nd_opt rte_flow_item_icmp6_nd_opt_mask
Definition: rte_flow.h:1103
static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask
Definition: rte_flow.h:495
static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask
Definition: rte_flow.h:752
rte_eth_hash_function
Definition: rte_eth_ctrl.h:770
struct udp_hdr hdr
Definition: rte_flow.h:687
static const struct rte_flow_item_port_id rte_flow_item_port_id_mask
Definition: rte_flow.h:521
struct icmp_hdr hdr
Definition: rte_flow.h:668
static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask
Definition: rte_flow.h:805
rte_be32_t spi
Definition: rte_esp.h:24
const void * mask
Definition: rte_flow.h:1217
enum rte_eth_hash_function func
Definition: rte_flow.h:1612
rte_be16_t type
Definition: rte_flow.h:581
enum rte_flow_error_type type
Definition: rte_flow.h:1929
const void * cause
Definition: rte_flow.h:1930
struct ether_addr sha
Definition: rte_flow.h:976
struct ipv6_hdr hdr
Definition: rte_flow.h:645
uint16_t src_port
Definition: rte_sctp.h:27
static const struct rte_flow_item_udp rte_flow_item_udp_mask
Definition: rte_flow.h:692
rte_flow_error_type
Definition: rte_flow.h:1897
uint32_t id
Definition: rte_flow.h:459
const uint8_t * pattern
Definition: rte_flow.h:551
uint32_t search
Definition: rte_flow.h:546
uint8_t addr_bytes[ETHER_ADDR_LEN]
Definition: rte_ether.h:58
rte_be16_t rsvd_grp_ecid_b
Definition: rte_flow.h:772
uint8_t src_addr[16]
Definition: rte_ip.h:344
static const struct rte_flow_item_raw rte_flow_item_raw_mask
Definition: rte_flow.h:556
uint16_t limit
Definition: rte_flow.h:549
uint8_t vni[3]
Definition: rte_flow.h:934
int rte_flow_flush(uint16_t port_id, struct rte_flow_error *error)
static const struct rte_flow_item_mpls rte_flow_item_mpls_mask
Definition: rte_flow.h:825
static const struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask
Definition: rte_flow.h:1050
int rte_flow_error_set(struct rte_flow_error *error, int code, enum rte_flow_error_type type, const void *cause, const char *message)
const char * message
Definition: rte_flow.h:1931
uint16_t length
Definition: rte_flow.h:550
const void * last
Definition: rte_flow.h:1216
static const struct rte_flow_item_icmp6_nd_opt_tla_eth rte_flow_item_icmp6_nd_opt_tla_eth_mask
Definition: rte_flow.h:1153
rte_be32_t teid
Definition: rte_flow.h:894
int rte_flow_destroy(uint16_t port_id, struct rte_flow *flow, struct rte_flow_error *error)
uint32_t ingress
Definition: rte_flow.h:75
enum rte_flow_item_type type
Definition: rte_flow.h:1214
rte_be16_t tci
Definition: rte_flow.h:603
struct ipv4_hdr hdr
Definition: rte_flow.h:623
static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask
Definition: rte_flow.h:628
size_t size
Definition: rte_flow.h:2171
rte_be16_t c_k_s_rsvd0_ver
Definition: rte_flow.h:797
struct rte_flow_item * items
Definition: rte_flow.h:2173
rte_flow_action_type
Definition: rte_flow.h:1245
struct rte_flow * rte_flow_create(uint16_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], struct rte_flow_error *error)
const void * spec
Definition: rte_flow.h:1215
uint8_t label_tc_s[3]
Definition: rte_flow.h:819
const uint8_t * key
Definition: rte_flow.h:1642
static const struct rte_flow_item_arp_eth_ipv4 rte_flow_item_arp_eth_ipv4_mask
Definition: rte_flow.h:985
size_t rte_flow_copy(struct rte_flow_desc *fd, size_t len, const struct rte_flow_attr *attr, const struct rte_flow_item *items, const struct rte_flow_action *actions)
uint16_t src_port
Definition: rte_udp.h:27
static const struct rte_flow_item_eth rte_flow_item_eth_mask
Definition: rte_flow.h:586
struct esp_hdr hdr
Definition: rte_flow.h:910
uint16_t rte_be16_t
uint16_t src_port
Definition: rte_tcp.h:27
struct ether_addr dst
Definition: rte_flow.h:579
uint32_t reserved
Definition: rte_flow.h:1660
uint32_t priority
Definition: rte_flow.h:74
static const struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask
Definition: rte_flow.h:1010
static const struct rte_flow_item_vf rte_flow_item_vf_mask
Definition: rte_flow.h:464
rte_be16_t protocol
Definition: rte_flow.h:841
uint32_t queue_num
Definition: rte_flow.h:1641
uint8_t tni[3]
Definition: rte_flow.h:799
struct ether_addr tha
Definition: rte_flow.h:978
uint32_t transfer
Definition: rte_flow.h:95
struct rte_flow_item * definition
Definition: rte_flow.h:1868
static const struct rte_flow_item_vlan rte_flow_item_vlan_mask
Definition: rte_flow.h:609
uint8_t msg_type
Definition: rte_flow.h:892
uint32_t egress
Definition: rte_flow.h:76
static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask
Definition: rte_flow.h:780
static const struct rte_flow_item_tcp rte_flow_item_tcp_mask
Definition: rte_flow.h:711
static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask
Definition: rte_flow.h:874
rte_be16_t inner_type
Definition: rte_flow.h:604
uint8_t rsvd0[3]
Definition: rte_flow.h:745
const uint16_t * queue
Definition: rte_flow.h:1643
rte_flow_item_type
Definition: rte_flow.h:115
uint32_t relative
Definition: rte_flow.h:545
uint8_t vni[3]
Definition: rte_flow.h:746
int32_t offset
Definition: rte_flow.h:548
rte_be16_t inner_type
Definition: rte_flow.h:775
static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask
Definition: rte_flow.h:960