daaf00b8b1a9884cdb88df5a133462ecaa6c0118
[dpdk.git] / drivers / net / tap / tap_flow.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright 2017 6WIND S.A.
5  *   Copyright 2017 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 _TAP_FLOW_H_
35 #define _TAP_FLOW_H_
36
37 #include <rte_flow.h>
38 #include <rte_flow_driver.h>
39 #include <rte_eth_tap.h>
40 #include <tap_autoconf.h>
41
42 /**
43  * In TC, priority 0 means we require the kernel to allocate one for us.
44  * In rte_flow, however, we want the priority 0 to be the most important one.
45  * Use an offset to have the most important priority being 1 in TC.
46  */
47 #define PRIORITY_OFFSET 1
48 #define PRIORITY_MASK (0xfff)
49 #define MAX_PRIORITY (PRIORITY_MASK - PRIORITY_OFFSET)
50 #define GROUP_MASK (0xf)
51 #define GROUP_SHIFT 12
52 #define MAX_GROUP GROUP_MASK
53 #define RSS_PRIORITY_OFFSET RTE_PMD_TAP_MAX_QUEUES
54
55 /**
56  * These index are actually in reversed order: their priority is processed
57  * by subtracting their value to the lowest priority (PRIORITY_MASK).
58  * Thus the first one will have the lowest priority in the end
59  * (but biggest value).
60  */
61 enum implicit_rule_index {
62         TAP_REMOTE_TX,
63         TAP_ISOLATE,
64         TAP_REMOTE_BROADCASTV6,
65         TAP_REMOTE_BROADCAST,
66         TAP_REMOTE_ALLMULTI,
67         TAP_REMOTE_PROMISC,
68         TAP_REMOTE_LOCAL_MAC,
69         TAP_REMOTE_MAX_IDX,
70 };
71
72 enum bpf_fd_idx {
73         SEC_L3_L4,
74         SEC_MAX,
75 };
76
77 int tap_dev_filter_ctrl(struct rte_eth_dev *dev,
78                         enum rte_filter_type filter_type,
79                         enum rte_filter_op filter_op,
80                         void *arg);
81 int tap_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error);
82
83 int tap_flow_implicit_create(struct pmd_internals *pmd,
84                              enum implicit_rule_index idx);
85 int tap_flow_implicit_destroy(struct pmd_internals *pmd,
86                               enum implicit_rule_index idx);
87 int tap_flow_implicit_flush(struct pmd_internals *pmd,
88                             struct rte_flow_error *error);
89
90 int tap_flow_bpf_cls_q(__u32 queue_idx);
91 int tap_flow_bpf_calc_l3_l4_hash(__u32 key_idx, int map_fd);
92 int tap_flow_bpf_rss_map_create(unsigned int key_size, unsigned int value_size,
93                         unsigned int max_entries);
94 int tap_flow_bpf_update_rss_elem(int fd, void *key, void *value);
95
96 #endif /* _TAP_FLOW_H_ */