/src/openvswitch/lib/netdev-dpdk.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2014, 2015, 2016 Nicira, Inc. |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at: |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | |
17 | | #ifndef NETDEV_DPDK_H |
18 | | #define NETDEV_DPDK_H |
19 | | |
20 | | #include <config.h> |
21 | | |
22 | | #include "openvswitch/compiler.h" |
23 | | #include "smap.h" |
24 | | |
25 | | struct dp_packet; |
26 | | struct netdev; |
27 | | |
28 | | #ifdef DPDK_NETDEV |
29 | | |
30 | | #include <rte_flow.h> |
31 | | |
32 | | void netdev_dpdk_register(const struct smap *); |
33 | | void free_dpdk_buf(struct dp_packet *); |
34 | | |
35 | | uint32_t netdev_dpdk_extbuf_size(uint32_t); |
36 | | void *netdev_dpdk_extbuf_allocate(uint32_t); |
37 | | void netdev_dpdk_extbuf_replace(struct dp_packet *, void *, uint32_t); |
38 | | |
39 | | bool netdev_dpdk_flow_api_supported(struct netdev *, bool check_only); |
40 | | |
41 | | int |
42 | | netdev_dpdk_rte_flow_destroy(struct netdev *netdev, |
43 | | struct rte_flow *rte_flow, |
44 | | struct rte_flow_error *error); |
45 | | struct rte_flow * |
46 | | netdev_dpdk_rte_flow_create(struct netdev *netdev, |
47 | | const struct rte_flow_attr *attr, |
48 | | const struct rte_flow_item *items, |
49 | | const struct rte_flow_action *actions, |
50 | | struct rte_flow_error *error); |
51 | | int |
52 | | netdev_dpdk_rte_flow_query_count(struct netdev *netdev, |
53 | | struct rte_flow *rte_flow, |
54 | | struct rte_flow_query_count *query, |
55 | | struct rte_flow_error *error); |
56 | | int |
57 | | netdev_dpdk_get_port_id(struct netdev *netdev); |
58 | | |
59 | | static inline void |
60 | | set_error(struct rte_flow_error *error, enum rte_flow_error_type type) |
61 | | { |
62 | | if (!error) { |
63 | | return; |
64 | | } |
65 | | error->type = type; |
66 | | error->cause = NULL; |
67 | | error->message = NULL; |
68 | | } |
69 | | |
70 | | #ifdef ALLOW_EXPERIMENTAL_API |
71 | | |
72 | | int netdev_dpdk_rte_flow_tunnel_decap_set(struct netdev *, |
73 | | struct rte_flow_tunnel *, |
74 | | struct rte_flow_action **, |
75 | | uint32_t *num_of_actions, |
76 | | struct rte_flow_error *); |
77 | | int netdev_dpdk_rte_flow_tunnel_match(struct netdev *, |
78 | | struct rte_flow_tunnel *, |
79 | | struct rte_flow_item **, |
80 | | uint32_t *num_of_items, |
81 | | struct rte_flow_error *); |
82 | | int netdev_dpdk_rte_flow_get_restore_info(struct netdev *, |
83 | | struct dp_packet *, |
84 | | struct rte_flow_restore_info *, |
85 | | struct rte_flow_error *); |
86 | | int netdev_dpdk_rte_flow_tunnel_action_decap_release(struct netdev *, |
87 | | struct rte_flow_action *, |
88 | | uint32_t num_of_actions, |
89 | | struct rte_flow_error *); |
90 | | int netdev_dpdk_rte_flow_tunnel_item_release(struct netdev *, |
91 | | struct rte_flow_item *, |
92 | | uint32_t num_of_items, |
93 | | struct rte_flow_error *); |
94 | | |
95 | | #else |
96 | | |
97 | | static inline int |
98 | | netdev_dpdk_rte_flow_tunnel_decap_set( |
99 | | struct netdev *netdev OVS_UNUSED, |
100 | | struct rte_flow_tunnel *tunnel OVS_UNUSED, |
101 | | struct rte_flow_action **actions OVS_UNUSED, |
102 | | uint32_t *num_of_actions OVS_UNUSED, |
103 | | struct rte_flow_error *error) |
104 | | { |
105 | | set_error(error, RTE_FLOW_ERROR_TYPE_ACTION); |
106 | | return -1; |
107 | | } |
108 | | |
109 | | static inline int |
110 | | netdev_dpdk_rte_flow_tunnel_match(struct netdev *netdev OVS_UNUSED, |
111 | | struct rte_flow_tunnel *tunnel OVS_UNUSED, |
112 | | struct rte_flow_item **items OVS_UNUSED, |
113 | | uint32_t *num_of_items OVS_UNUSED, |
114 | | struct rte_flow_error *error) |
115 | | { |
116 | | set_error(error, RTE_FLOW_ERROR_TYPE_ITEM); |
117 | | return -1; |
118 | | } |
119 | | |
120 | | static inline int |
121 | | netdev_dpdk_rte_flow_get_restore_info( |
122 | | struct netdev *netdev OVS_UNUSED, |
123 | | struct dp_packet *p OVS_UNUSED, |
124 | | struct rte_flow_restore_info *info OVS_UNUSED, |
125 | | struct rte_flow_error *error) |
126 | | { |
127 | | set_error(error, RTE_FLOW_ERROR_TYPE_ATTR); |
128 | | return -1; |
129 | | } |
130 | | |
131 | | static inline int |
132 | | netdev_dpdk_rte_flow_tunnel_action_decap_release( |
133 | | struct netdev *netdev OVS_UNUSED, |
134 | | struct rte_flow_action *actions OVS_UNUSED, |
135 | | uint32_t num_of_actions OVS_UNUSED, |
136 | | struct rte_flow_error *error) |
137 | | { |
138 | | set_error(error, RTE_FLOW_ERROR_TYPE_NONE); |
139 | | return 0; |
140 | | } |
141 | | |
142 | | static inline int |
143 | | netdev_dpdk_rte_flow_tunnel_item_release( |
144 | | struct netdev *netdev OVS_UNUSED, |
145 | | struct rte_flow_item *items OVS_UNUSED, |
146 | | uint32_t num_of_items OVS_UNUSED, |
147 | | struct rte_flow_error *error) |
148 | | { |
149 | | set_error(error, RTE_FLOW_ERROR_TYPE_NONE); |
150 | | return 0; |
151 | | } |
152 | | |
153 | | #endif /* ALLOW_EXPERIMENTAL_API */ |
154 | | |
155 | | #else |
156 | | |
157 | | static inline void |
158 | | free_dpdk_buf(struct dp_packet *buf OVS_UNUSED) |
159 | 0 | { |
160 | | /* Nothing */ |
161 | 0 | } Unexecuted instantiation: packets.c:free_dpdk_buf Unexecuted instantiation: dp-packet.c:free_dpdk_buf Unexecuted instantiation: dp-packet-gso.c:free_dpdk_buf |
162 | | |
163 | | #endif |
164 | | |
165 | | #endif /* netdev-dpdk.h */ |