DPDK  17.05.2
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 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
93 struct rte_flow_attr {
94  uint32_t group;
95  uint32_t priority;
96  uint32_t ingress:1;
97  uint32_t egress:1;
98  uint32_t reserved:30;
99 };
100 
129 
139 
149 
157 
172 
187 
202 
209 
216 
223 
230 
237 
244 
251 
258 
265 
272 
279 
286 
293 
300 };
301 
314  uint32_t num;
315 };
316 
318 #ifndef __cplusplus
320  .num = 0x00000000,
321 };
322 #endif
323 
343  uint32_t id;
344 };
345 
347 #ifndef __cplusplus
349  .id = 0x00000000,
350 };
351 #endif
352 
374  uint32_t index;
375 };
376 
378 #ifndef __cplusplus
380  .index = 0x00000000,
381 };
382 #endif
383 
403  uint32_t relative:1;
404  uint32_t search:1;
405  uint32_t reserved:30;
406  int32_t offset;
407  uint16_t limit;
408  uint16_t length;
409  uint8_t pattern[];
410 };
411 
413 #ifndef __cplusplus
415  .relative = 1,
416  .search = 1,
417  .reserved = 0x3fffffff,
418  .offset = 0xffffffff,
419  .limit = 0xffff,
420  .length = 0xffff,
421 };
422 #endif
423 
430  struct ether_addr dst;
431  struct ether_addr src;
432  uint16_t type;
433 };
434 
436 #ifndef __cplusplus
438  .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
439  .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
440  .type = 0x0000,
441 };
442 #endif
443 
453  uint16_t tpid;
454  uint16_t tci;
455 };
456 
458 #ifndef __cplusplus
460  .tpid = 0x0000,
461  .tci = 0xffff,
462 };
463 #endif
464 
473  struct ipv4_hdr hdr;
474 };
475 
477 #ifndef __cplusplus
479  .hdr = {
480  .src_addr = 0xffffffff,
481  .dst_addr = 0xffffffff,
482  },
483 };
484 #endif
485 
494  struct ipv6_hdr hdr;
495 };
496 
498 #ifndef __cplusplus
500  .hdr = {
501  .src_addr =
502  "\xff\xff\xff\xff\xff\xff\xff\xff"
503  "\xff\xff\xff\xff\xff\xff\xff\xff",
504  .dst_addr =
505  "\xff\xff\xff\xff\xff\xff\xff\xff"
506  "\xff\xff\xff\xff\xff\xff\xff\xff",
507  },
508 };
509 #endif
510 
517  struct icmp_hdr hdr;
518 };
519 
521 #ifndef __cplusplus
523  .hdr = {
524  .icmp_type = 0xff,
525  .icmp_code = 0xff,
526  },
527 };
528 #endif
529 
536  struct udp_hdr hdr;
537 };
538 
540 #ifndef __cplusplus
542  .hdr = {
543  .src_port = 0xffff,
544  .dst_port = 0xffff,
545  },
546 };
547 #endif
548 
555  struct tcp_hdr hdr;
556 };
557 
559 #ifndef __cplusplus
561  .hdr = {
562  .src_port = 0xffff,
563  .dst_port = 0xffff,
564  },
565 };
566 #endif
567 
574  struct sctp_hdr hdr;
575 };
576 
578 #ifndef __cplusplus
580  .hdr = {
581  .src_port = 0xffff,
582  .dst_port = 0xffff,
583  },
584 };
585 #endif
586 
593  uint8_t flags;
594  uint8_t rsvd0[3];
595  uint8_t vni[3];
596  uint8_t rsvd1;
597 };
598 
600 #ifndef __cplusplus
602  .vni = "\xff\xff\xff",
603 };
604 #endif
605 
612  uint16_t tpid;
619  uint16_t rsvd_grp_ecid_b;
620  uint8_t in_ecid_e;
621  uint8_t ecid_e;
622 };
623 
625 #ifndef __cplusplus
627 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
628  .rsvd_grp_ecid_b = 0x3fff,
629 #elif RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
630  .rsvd_grp_ecid_b = 0xff3f,
631 #else
632 #error Unsupported endianness.
633 #endif
634 };
635 #endif
636 
649  uint16_t c_k_s_rsvd0_ver;
650  uint16_t protocol;
651  uint8_t tni[3];
652  uint8_t flow_id;
653 };
654 
656 #ifndef __cplusplus
658  .tni = "\xff\xff\xff",
659 };
660 #endif
661 
671  uint8_t label_tc_s[3];
672  uint8_t ttl;
673 };
674 
676 #ifndef __cplusplus
678  .label_tc_s = "\xff\xff\xf0",
679 };
680 #endif
681 
692  uint16_t c_rsvd0_ver;
693  uint16_t protocol;
694 };
695 
697 #ifndef __cplusplus
699  .protocol = 0xffff,
700 };
701 #endif
702 
737  enum rte_flow_item_type type;
738  const void *spec;
739  const void *last;
740  const void *mask;
741 };
742 
781 
791 
801 
811 
821 
828 
837 
849 
859 
868 
876 
884 };
885 
897  uint32_t id;
898 };
899 
908  uint16_t index;
909 };
910 
917  uint32_t reset:1;
918  uint32_t hits_set:1;
919  uint32_t bytes_set:1;
920  uint32_t reserved:29;
921  uint64_t hits;
922  uint64_t bytes;
923 };
924 
936  uint16_t index;
937 };
938 
952  const struct rte_eth_rss_conf *rss_conf;
953  uint16_t num;
954  uint16_t queue[];
955 };
956 
971  uint32_t original:1;
972  uint32_t reserved:31;
973  uint32_t id;
974 };
975 
985  const void *conf;
986 };
987 
994 struct rte_flow;
995 
1015 };
1016 
1030  const void *cause;
1031  const char *message;
1032 };
1033 
1084 int
1085 rte_flow_validate(uint8_t port_id,
1086  const struct rte_flow_attr *attr,
1087  const struct rte_flow_item pattern[],
1088  const struct rte_flow_action actions[],
1089  struct rte_flow_error *error);
1090 
1111 struct rte_flow *
1112 rte_flow_create(uint8_t port_id,
1113  const struct rte_flow_attr *attr,
1114  const struct rte_flow_item pattern[],
1115  const struct rte_flow_action actions[],
1116  struct rte_flow_error *error);
1117 
1138 int
1139 rte_flow_destroy(uint8_t port_id,
1140  struct rte_flow *flow,
1141  struct rte_flow_error *error);
1142 
1159 int
1160 rte_flow_flush(uint8_t port_id,
1161  struct rte_flow_error *error);
1162 
1187 int
1188 rte_flow_query(uint8_t port_id,
1189  struct rte_flow *flow,
1190  enum rte_flow_action_type action,
1191  void *data,
1192  struct rte_flow_error *error);
1193 
1194 #ifdef __cplusplus
1195 }
1196 #endif
1197 
1198 #endif /* RTE_FLOW_H_ */
uint32_t bytes_set
Definition: rte_flow.h:919
uint32_t reserved
Definition: rte_flow.h:98
int rte_flow_query(uint8_t port_id, struct rte_flow *flow, enum rte_flow_action_type action, void *data, struct rte_flow_error *error)
static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask
Definition: rte_flow.h:499
uint32_t num
Definition: rte_flow.h:314
uint32_t src_addr
Definition: rte_ip.h:102
uint32_t original
Definition: rte_flow.h:971
uint32_t group
Definition: rte_flow.h:94
static const struct rte_flow_item_gre rte_flow_item_gre_mask
Definition: rte_flow.h:698
static const struct rte_flow_item_icmp rte_flow_item_icmp_mask
Definition: rte_flow.h:522
struct tcp_hdr hdr
Definition: rte_flow.h:555
static const struct rte_flow_item_sctp rte_flow_item_sctp_mask
Definition: rte_flow.h:579
uint16_t protocol
Definition: rte_flow.h:693
static const struct rte_flow_item_any rte_flow_item_any_mask
Definition: rte_flow.h:319
struct sctp_hdr hdr
Definition: rte_flow.h:574
uint32_t reserved
Definition: rte_flow.h:405
int rte_flow_destroy(uint8_t port_id, struct rte_flow *flow, struct rte_flow_error *error)
uint16_t epcp_edei_in_ecid_b
Definition: rte_flow.h:617
static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask
Definition: rte_flow.h:601
struct udp_hdr hdr
Definition: rte_flow.h:536
struct icmp_hdr hdr
Definition: rte_flow.h:517
static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask
Definition: rte_flow.h:657
const void * mask
Definition: rte_flow.h:740
const void * cause
Definition: rte_flow.h:1030
struct ipv6_hdr hdr
Definition: rte_flow.h:494
uint16_t c_k_s_rsvd0_ver
Definition: rte_flow.h:649
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:541
rte_flow_error_type
Definition: rte_flow.h:1002
uint32_t id
Definition: rte_flow.h:343
uint32_t search
Definition: rte_flow.h:404
uint8_t addr_bytes[ETHER_ADDR_LEN]
Definition: rte_ether.h:87
uint32_t index
Definition: rte_flow.h:374
uint8_t src_addr[16]
Definition: rte_ip.h:406
static const struct rte_flow_item_raw rte_flow_item_raw_mask
Definition: rte_flow.h:414
uint16_t limit
Definition: rte_flow.h:407
static const struct rte_flow_item_mpls rte_flow_item_mpls_mask
Definition: rte_flow.h:677
uint16_t rsvd_grp_ecid_b
Definition: rte_flow.h:619
const void * conf
Definition: rte_flow.h:985
const char * message
Definition: rte_flow.h:1031
uint16_t length
Definition: rte_flow.h:408
const void * last
Definition: rte_flow.h:739
uint32_t ingress
Definition: rte_flow.h:96
struct ipv4_hdr hdr
Definition: rte_flow.h:473
int rte_flow_validate(uint8_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_ipv4 rte_flow_item_ipv4_mask
Definition: rte_flow.h:478
rte_flow_action_type
Definition: rte_flow.h:771
int rte_flow_flush(uint8_t port_id, struct rte_flow_error *error)
const struct rte_eth_rss_conf * rss_conf
Definition: rte_flow.h:952
const void * spec
Definition: rte_flow.h:738
uint8_t label_tc_s[3]
Definition: rte_flow.h:671
uint16_t protocol
Definition: rte_flow.h:650
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:437
uint16_t c_rsvd0_ver
Definition: rte_flow.h:692
uint16_t src_port
Definition: rte_tcp.h:89
struct ether_addr dst
Definition: rte_flow.h:430
uint32_t reserved
Definition: rte_flow.h:972
uint32_t priority
Definition: rte_flow.h:95
static const struct rte_flow_item_port rte_flow_item_port_mask
Definition: rte_flow.h:379
static const struct rte_flow_item_vf rte_flow_item_vf_mask
Definition: rte_flow.h:348
uint16_t type
Definition: rte_flow.h:432
uint8_t tni[3]
Definition: rte_flow.h:651
static const struct rte_flow_item_vlan rte_flow_item_vlan_mask
Definition: rte_flow.h:459
uint32_t egress
Definition: rte_flow.h:97
static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask
Definition: rte_flow.h:626
static const struct rte_flow_item_tcp rte_flow_item_tcp_mask
Definition: rte_flow.h:560
rte_flow_item_type
Definition: rte_flow.h:119
uint32_t relative
Definition: rte_flow.h:403
uint8_t vni[3]
Definition: rte_flow.h:595
int32_t offset
Definition: rte_flow.h:406
struct rte_flow * rte_flow_create(uint8_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)