9e332b0314a22dd179d4ec331e0721893d98bef3
[deb_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
41 /**
42  * In TC, priority 0 means we require the kernel to allocate one for us.
43  * In rte_flow, however, we want the priority 0 to be the most important one.
44  * Use an offset to have the most important priority being 1 in TC.
45  */
46 #define PRIORITY_OFFSET 1
47 #define PRIORITY_MASK (0xfff)
48 #define MAX_PRIORITY (PRIORITY_MASK - PRIORITY_OFFSET)
49 #define GROUP_MASK (0xf)
50 #define GROUP_SHIFT 12
51 #define MAX_GROUP GROUP_MASK
52
53 /**
54  * These index are actually in reversed order: their priority is processed
55  * by subtracting their value to the lowest priority (PRIORITY_MASK).
56  * Thus the first one will have the lowest priority in the end
57  * (but biggest value).
58  */
59 enum implicit_rule_index {
60         TAP_REMOTE_TX,
61         TAP_ISOLATE,
62         TAP_REMOTE_BROADCASTV6,
63         TAP_REMOTE_BROADCAST,
64         TAP_REMOTE_ALLMULTI,
65         TAP_REMOTE_PROMISC,
66         TAP_REMOTE_LOCAL_MAC,
67         TAP_REMOTE_MAX_IDX,
68 };
69
70 int tap_dev_filter_ctrl(struct rte_eth_dev *dev,
71                         enum rte_filter_type filter_type,
72                         enum rte_filter_op filter_op,
73                         void *arg);
74 int tap_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error);
75
76 int tap_flow_implicit_create(struct pmd_internals *pmd,
77                              enum implicit_rule_index idx);
78 int tap_flow_implicit_destroy(struct pmd_internals *pmd,
79                               enum implicit_rule_index idx);
80 int tap_flow_implicit_flush(struct pmd_internals *pmd,
81                             struct rte_flow_error *error);
82
83 #endif /* _TAP_FLOW_H_ */