DPDK  17.11.10
rte_flow.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright 2016 6WIND S.A.
5  * Copyright 2016 Mellanox.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of 6WIND S.A. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef RTE_FLOW_H_
35 #define RTE_FLOW_H_
36 
45 #include <rte_arp.h>
46 #include <rte_ether.h>
47 #include <rte_icmp.h>
48 #include <rte_ip.h>
49 #include <rte_sctp.h>
50 #include <rte_tcp.h>
51 #include <rte_udp.h>
52 #include <rte_byteorder.h>
53 #include <rte_esp.h>
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
94 struct rte_flow_attr {
95  uint32_t group;
96  uint32_t priority;
97  uint32_t ingress:1;
98  uint32_t egress:1;
99  uint32_t reserved:30;
100 };
101 
130 
140 
150 
158 
173 
188 
203 
210 
217 
224 
231 
238 
245 
252 
259 
266 
273 
280 
287 
294 
301 
313 
322 
331 
340 
347 };
348 
361  uint32_t num;
362 };
363 
365 #ifndef __cplusplus
367  .num = 0x00000000,
368 };
369 #endif
370 
390  uint32_t id;
391 };
392 
394 #ifndef __cplusplus
396  .id = 0x00000000,
397 };
398 #endif
399 
421  uint32_t index;
422 };
423 
425 #ifndef __cplusplus
427  .index = 0x00000000,
428 };
429 #endif
430 
450  uint32_t relative:1;
451  uint32_t search:1;
452  uint32_t reserved:30;
453  int32_t offset;
454  uint16_t limit;
455  uint16_t length;
456  uint8_t pattern[];
457 };
458 
460 #ifndef __cplusplus
462  .relative = 1,
463  .search = 1,
464  .reserved = 0x3fffffff,
465  .offset = 0xffffffff,
466  .limit = 0xffff,
467  .length = 0xffff,
468 };
469 #endif
470 
477  struct ether_addr dst;
478  struct ether_addr src;
480 };
481 
483 #ifndef __cplusplus
485  .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
486  .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
487  .type = RTE_BE16(0x0000),
488 };
489 #endif
490 
502 };
503 
505 #ifndef __cplusplus
507  .tpid = RTE_BE16(0x0000),
508  .tci = RTE_BE16(0xffff),
509 };
510 #endif
511 
520  struct ipv4_hdr hdr;
521 };
522 
524 #ifndef __cplusplus
526  .hdr = {
527  .src_addr = RTE_BE32(0xffffffff),
528  .dst_addr = RTE_BE32(0xffffffff),
529  },
530 };
531 #endif
532 
541  struct ipv6_hdr hdr;
542 };
543 
545 #ifndef __cplusplus
547  .hdr = {
548  .src_addr =
549  "\xff\xff\xff\xff\xff\xff\xff\xff"
550  "\xff\xff\xff\xff\xff\xff\xff\xff",
551  .dst_addr =
552  "\xff\xff\xff\xff\xff\xff\xff\xff"
553  "\xff\xff\xff\xff\xff\xff\xff\xff",
554  },
555 };
556 #endif
557 
564  struct icmp_hdr hdr;
565 };
566 
568 #ifndef __cplusplus
570  .hdr = {
571  .icmp_type = 0xff,
572  .icmp_code = 0xff,
573  },
574 };
575 #endif
576 
583  struct udp_hdr hdr;
584 };
585 
587 #ifndef __cplusplus
589  .hdr = {
590  .src_port = RTE_BE16(0xffff),
591  .dst_port = RTE_BE16(0xffff),
592  },
593 };
594 #endif
595 
602  struct tcp_hdr hdr;
603 };
604 
606 #ifndef __cplusplus
608  .hdr = {
609  .src_port = RTE_BE16(0xffff),
610  .dst_port = RTE_BE16(0xffff),
611  },
612 };
613 #endif
614 
621  struct sctp_hdr hdr;
622 };
623 
625 #ifndef __cplusplus
627  .hdr = {
628  .src_port = RTE_BE16(0xffff),
629  .dst_port = RTE_BE16(0xffff),
630  },
631 };
632 #endif
633 
640  uint8_t flags;
641  uint8_t rsvd0[3];
642  uint8_t vni[3];
643  uint8_t rsvd1;
644 };
645 
647 #ifndef __cplusplus
649  .vni = "\xff\xff\xff",
650 };
651 #endif
652 
667  uint8_t in_ecid_e;
668  uint8_t ecid_e;
669 };
670 
672 #ifndef __cplusplus
674  .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
675 };
676 #endif
677 
692  uint8_t tni[3];
693  uint8_t flow_id;
694 };
695 
697 #ifndef __cplusplus
699  .tni = "\xff\xff\xff",
700 };
701 #endif
702 
712  uint8_t label_tc_s[3];
713  uint8_t ttl;
714 };
715 
717 #ifndef __cplusplus
719  .label_tc_s = "\xff\xff\xf0",
720 };
721 #endif
722 
735 };
736 
738 #ifndef __cplusplus
740  .protocol = RTE_BE16(0xffff),
741 };
742 #endif
743 
762  uint32_t thresh;
763 };
764 
766 #ifndef __cplusplus
768  .thresh = 0xffffffff,
769 };
770 #endif
771 
784  uint8_t v_pt_rsv_flags;
785  uint8_t msg_type;
788 };
789 
791 #ifndef __cplusplus
793  .teid = RTE_BE32(0xffffffff),
794 };
795 #endif
796 
803  struct esp_hdr hdr;
804 };
805 
807 #ifndef __cplusplus
809  .hdr = {
810  .spi = RTE_BE32(0xffffffff),
811  },
812 };
813 #endif
814 
850  const void *spec;
851  const void *last;
852  const void *mask;
853 };
854 
893 
903 
913 
923 
933 
940 
949 
961 
971 
980 
988 
996 
1004 
1012 };
1013 
1025  uint32_t id;
1026 };
1027 
1036  uint16_t index;
1037 };
1038 
1045  uint32_t reset:1;
1046  uint32_t hits_set:1;
1047  uint32_t bytes_set:1;
1048  uint32_t reserved:29;
1049  uint64_t hits;
1050  uint64_t bytes;
1051 };
1052 
1064  uint16_t index;
1065 };
1066 
1080  const struct rte_eth_rss_conf *rss_conf;
1081  uint16_t num;
1082  uint16_t queue[];
1083 };
1084 
1099  uint32_t original:1;
1100  uint32_t reserved:31;
1101  uint32_t id;
1102 };
1103 
1115  uint32_t mtr_id;
1116 };
1117 
1147 };
1148 
1158  const void *conf;
1159 };
1160 
1167 struct rte_flow;
1168 
1188 };
1189 
1203  const void *cause;
1204  const char *message;
1205 };
1206 
1257 int
1258 rte_flow_validate(uint16_t port_id,
1259  const struct rte_flow_attr *attr,
1260  const struct rte_flow_item pattern[],
1261  const struct rte_flow_action actions[],
1262  struct rte_flow_error *error);
1263 
1284 struct rte_flow *
1285 rte_flow_create(uint16_t port_id,
1286  const struct rte_flow_attr *attr,
1287  const struct rte_flow_item pattern[],
1288  const struct rte_flow_action actions[],
1289  struct rte_flow_error *error);
1290 
1311 int
1312 rte_flow_destroy(uint16_t port_id,
1313  struct rte_flow *flow,
1314  struct rte_flow_error *error);
1315 
1332 int
1333 rte_flow_flush(uint16_t port_id,
1334  struct rte_flow_error *error);
1335 
1360 int
1361 rte_flow_query(uint16_t port_id,
1362  struct rte_flow *flow,
1363  enum rte_flow_action_type action,
1364  void *data,
1365  struct rte_flow_error *error);
1366 
1408 int
1409 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
1410 
1428 int
1429 rte_flow_error_set(struct rte_flow_error *error,
1430  int code,
1431  enum rte_flow_error_type type,
1432  const void *cause,
1433  const char *message);
1434 
1442  size_t size;
1446  uint8_t data[];
1447 };
1448 
1469 size_t
1470 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
1471  const struct rte_flow_attr *attr,
1472  const struct rte_flow_item *items,
1473  const struct rte_flow_action *actions);
1474 
1475 #ifdef __cplusplus
1476 }
1477 #endif
1478 
1479 #endif /* RTE_FLOW_H_ */
uint32_t reserved
Definition: rte_flow.h:99
rte_be16_t c_rsvd0_ver
Definition: rte_flow.h:733
uint8_t pattern[]
Definition: rte_flow.h:456
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_ipv6 rte_flow_item_ipv6_mask
Definition: rte_flow.h:546
rte_be16_t epcp_edei_in_ecid_b
Definition: rte_flow.h:664
uint32_t num
Definition: rte_flow.h:361
uint32_t rte_be32_t
uint32_t src_addr
Definition: rte_ip.h:102
uint32_t original
Definition: rte_flow.h:1099
struct ether_addr src
Definition: rte_flow.h:478
uint32_t group
Definition: rte_flow.h:95
static const struct rte_flow_item_gre rte_flow_item_gre_mask
Definition: rte_flow.h:739
struct rte_flow_attr attr
Definition: rte_flow.h:1443
rte_be16_t msg_len
Definition: rte_flow.h:786
static const struct rte_flow_item_gtp rte_flow_item_gtp_mask
Definition: rte_flow.h:792
static const struct rte_flow_item_icmp rte_flow_item_icmp_mask
Definition: rte_flow.h:569
struct tcp_hdr hdr
Definition: rte_flow.h:602
static const struct rte_flow_item_sctp rte_flow_item_sctp_mask
Definition: rte_flow.h:626
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:366
static const struct rte_flow_item_esp rte_flow_item_esp_mask
Definition: rte_flow.h:808
struct sctp_hdr hdr
Definition: rte_flow.h:621
uint8_t v_pt_rsv_flags
Definition: rte_flow.h:784
rte_be16_t protocol
Definition: rte_flow.h:691
uint32_t reserved
Definition: rte_flow.h:452
struct rte_flow_action * actions
Definition: rte_flow.h:1445
uint8_t data[]
Definition: rte_flow.h:1446
static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask
Definition: rte_flow.h:648
struct udp_hdr hdr
Definition: rte_flow.h:583
struct icmp_hdr hdr
Definition: rte_flow.h:564
static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask
Definition: rte_flow.h:698
rte_be32_t spi
Definition: rte_esp.h:52
const void * mask
Definition: rte_flow.h:852
rte_be16_t type
Definition: rte_flow.h:479
enum rte_flow_error_type type
Definition: rte_flow.h:1202
const void * cause
Definition: rte_flow.h:1203
struct ipv6_hdr hdr
Definition: rte_flow.h:541
uint16_t src_port
Definition: rte_sctp.h:89
static const struct rte_flow_item_udp rte_flow_item_udp_mask
Definition: rte_flow.h:588
rte_flow_error_type
Definition: rte_flow.h:1175
int rte_flow_query(uint16_t port_id, struct rte_flow *flow, enum rte_flow_action_type action, void *data, struct rte_flow_error *error)
rte_be16_t tpid
Definition: rte_flow.h:659
uint32_t id
Definition: rte_flow.h:390
uint32_t search
Definition: rte_flow.h:451
uint8_t addr_bytes[ETHER_ADDR_LEN]
Definition: rte_ether.h:87
rte_be16_t rsvd_grp_ecid_b
Definition: rte_flow.h:666
uint32_t index
Definition: rte_flow.h:421
uint8_t src_addr[16]
Definition: rte_ip.h:410
static const struct rte_flow_item_raw rte_flow_item_raw_mask
Definition: rte_flow.h:461
uint16_t limit
Definition: rte_flow.h:454
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:718
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 void * conf
Definition: rte_flow.h:1158
const char * message
Definition: rte_flow.h:1204
uint16_t length
Definition: rte_flow.h:455
const void * last
Definition: rte_flow.h:851
rte_be32_t teid
Definition: rte_flow.h:787
int rte_flow_destroy(uint16_t port_id, struct rte_flow *flow, struct rte_flow_error *error)
uint32_t ingress
Definition: rte_flow.h:97
enum rte_flow_item_type type
Definition: rte_flow.h:849
rte_be16_t tci
Definition: rte_flow.h:501
struct ipv4_hdr hdr
Definition: rte_flow.h:520
static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask
Definition: rte_flow.h:525
size_t size
Definition: rte_flow.h:1442
rte_be16_t c_k_s_rsvd0_ver
Definition: rte_flow.h:690
struct rte_flow_item * items
Definition: rte_flow.h:1444
rte_flow_action_type
Definition: rte_flow.h:883
rte_be16_t tpid
Definition: rte_flow.h:500
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 struct rte_eth_rss_conf * rss_conf
Definition: rte_flow.h:1080
const void * spec
Definition: rte_flow.h:850
uint8_t label_tc_s[3]
Definition: rte_flow.h:712
uint16_t queue[]
Definition: rte_flow.h:1082
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:89
static const struct rte_flow_item_eth rte_flow_item_eth_mask
Definition: rte_flow.h:484
struct esp_hdr hdr
Definition: rte_flow.h:803
uint16_t rte_be16_t
uint16_t src_port
Definition: rte_tcp.h:89
struct ether_addr dst
Definition: rte_flow.h:477
uint32_t reserved
Definition: rte_flow.h:1100
uint32_t priority
Definition: rte_flow.h:96
static const struct rte_flow_item_port rte_flow_item_port_mask
Definition: rte_flow.h:426
static const struct rte_flow_item_vf rte_flow_item_vf_mask
Definition: rte_flow.h:395
rte_be16_t protocol
Definition: rte_flow.h:734
uint8_t tni[3]
Definition: rte_flow.h:692
static const struct rte_flow_item_vlan rte_flow_item_vlan_mask
Definition: rte_flow.h:506
uint8_t msg_type
Definition: rte_flow.h:785
uint32_t egress
Definition: rte_flow.h:98
static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask
Definition: rte_flow.h:673
static const struct rte_flow_item_tcp rte_flow_item_tcp_mask
Definition: rte_flow.h:607
static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask
Definition: rte_flow.h:767
enum rte_flow_action_type type
Definition: rte_flow.h:1157
uint8_t rsvd0[3]
Definition: rte_flow.h:641
rte_flow_item_type
Definition: rte_flow.h:120
uint32_t relative
Definition: rte_flow.h:450
uint8_t vni[3]
Definition: rte_flow.h:642
int32_t offset
Definition: rte_flow.h:453