/src/openvswitch/lib/dpif-provider.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2009-2014, 2018 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 DPIF_PROVIDER_H |
18 | | #define DPIF_PROVIDER_H 1 |
19 | | |
20 | | /* Provider interface to dpifs, which provide an interface to an Open vSwitch |
21 | | * datapath. A datapath is a collection of physical or virtual ports that are |
22 | | * exposed over OpenFlow as a single switch. Datapaths and the collections of |
23 | | * ports that they contain may be fixed or dynamic. */ |
24 | | |
25 | | #include "openflow/openflow.h" |
26 | | #include "dpif.h" |
27 | | #include "util.h" |
28 | | |
29 | | #ifdef __cplusplus |
30 | | extern "C" { |
31 | | #endif |
32 | | |
33 | | /* Open vSwitch datapath interface. |
34 | | * |
35 | | * This structure should be treated as opaque by dpif implementations. */ |
36 | | struct dpif { |
37 | | const struct dpif_class *dpif_class; |
38 | | char *base_name; |
39 | | char *full_name; |
40 | | uint8_t netflow_engine_type; |
41 | | uint8_t netflow_engine_id; |
42 | | long long int current_ms; |
43 | | }; |
44 | | |
45 | | struct dpif_ipf_status; |
46 | | struct ipf_dump_ctx; |
47 | | |
48 | | void dpif_init(struct dpif *, const struct dpif_class *, const char *name, |
49 | | uint8_t netflow_engine_type, uint8_t netflow_engine_id); |
50 | | void dpif_uninit(struct dpif *dpif, bool close); |
51 | | |
52 | | static inline void dpif_assert_class(const struct dpif *dpif, |
53 | | const struct dpif_class *dpif_class) |
54 | 0 | { |
55 | 0 | ovs_assert(dpif->dpif_class == dpif_class); |
56 | 0 | } Unexecuted instantiation: netdev-offload-tc.c:dpif_assert_class Unexecuted instantiation: dpif.c:dpif_assert_class Unexecuted instantiation: dpif-netlink.c:dpif_assert_class Unexecuted instantiation: ct-dpif.c:dpif_assert_class Unexecuted instantiation: dpctl.c:dpif_assert_class Unexecuted instantiation: dpif-netdev.c:dpif_assert_class Unexecuted instantiation: dpif-netdev-lookup-generic.c:dpif_assert_class |
57 | | |
58 | | struct dpif_flow_dump { |
59 | | struct dpif *dpif; |
60 | | bool terse; /* If true, key/mask/actions may be omitted. */ |
61 | | }; |
62 | | |
63 | | static inline void |
64 | | dpif_flow_dump_init(struct dpif_flow_dump *dump, const struct dpif *dpif) |
65 | 0 | { |
66 | 0 | dump->dpif = CONST_CAST(struct dpif *, dpif); |
67 | 0 | } Unexecuted instantiation: netdev-offload-tc.c:dpif_flow_dump_init Unexecuted instantiation: dpif.c:dpif_flow_dump_init Unexecuted instantiation: dpif-netlink.c:dpif_flow_dump_init Unexecuted instantiation: ct-dpif.c:dpif_flow_dump_init Unexecuted instantiation: dpctl.c:dpif_flow_dump_init Unexecuted instantiation: dpif-netdev.c:dpif_flow_dump_init Unexecuted instantiation: dpif-netdev-lookup-generic.c:dpif_flow_dump_init |
68 | | |
69 | | struct dpif_flow_dump_thread { |
70 | | struct dpif *dpif; |
71 | | }; |
72 | | |
73 | | static inline void |
74 | | dpif_flow_dump_thread_init(struct dpif_flow_dump_thread *thread, |
75 | | struct dpif_flow_dump *dump) |
76 | 0 | { |
77 | 0 | thread->dpif = dump->dpif; |
78 | 0 | } Unexecuted instantiation: netdev-offload-tc.c:dpif_flow_dump_thread_init Unexecuted instantiation: dpif.c:dpif_flow_dump_thread_init Unexecuted instantiation: dpif-netlink.c:dpif_flow_dump_thread_init Unexecuted instantiation: ct-dpif.c:dpif_flow_dump_thread_init Unexecuted instantiation: dpctl.c:dpif_flow_dump_thread_init Unexecuted instantiation: dpif-netdev.c:dpif_flow_dump_thread_init Unexecuted instantiation: dpif-netdev-lookup-generic.c:dpif_flow_dump_thread_init |
79 | | |
80 | | struct ct_dpif_dump_state; |
81 | | struct ct_dpif_entry; |
82 | | struct ct_dpif_exp; |
83 | | struct ct_dpif_tuple; |
84 | | struct ct_dpif_timeout_policy; |
85 | | enum ct_features; |
86 | | |
87 | | /* 'dpif_ipf_proto_status' and 'dpif_ipf_status' are presently in |
88 | | * sync with 'ipf_proto_status' and 'ipf_status', but more |
89 | | * generally represent a superset of present and future support. */ |
90 | | struct dpif_ipf_proto_status { |
91 | | uint64_t nfrag_accepted; |
92 | | uint64_t nfrag_completed_sent; |
93 | | uint64_t nfrag_expired_sent; |
94 | | uint64_t nfrag_too_small; |
95 | | uint64_t nfrag_overlap; |
96 | | uint64_t nfrag_purged; |
97 | | unsigned int min_frag_size; |
98 | | bool enabled; |
99 | | }; |
100 | | |
101 | | struct dpif_ipf_status { |
102 | | struct dpif_ipf_proto_status v4; |
103 | | struct dpif_ipf_proto_status v6; |
104 | | unsigned int nfrag; |
105 | | unsigned int nfrag_max; |
106 | | }; |
107 | | |
108 | | /* Datapath interface class structure, to be defined by each implementation of |
109 | | * a datapath interface. |
110 | | * |
111 | | * These functions return 0 if successful or a positive errno value on failure, |
112 | | * except where otherwise noted. |
113 | | * |
114 | | * These functions are expected to execute synchronously, that is, to block as |
115 | | * necessary to obtain a result. Thus, they may not return EAGAIN or |
116 | | * EWOULDBLOCK or EINPROGRESS. We may relax this requirement in the future if |
117 | | * and when we encounter performance problems. */ |
118 | | struct dpif_class { |
119 | | /* Type of dpif in this class, e.g. "system", "netdev", etc. |
120 | | * |
121 | | * One of the providers should supply a "system" type, since this is |
122 | | * the type assumed if no type is specified when opening a dpif. */ |
123 | | const char *type; |
124 | | |
125 | | /* If 'true', datapath ports should be destroyed on ofproto destruction. |
126 | | * |
127 | | * This is used by the vswitch at exit, so that it can clean any |
128 | | * datapaths that can not exist without it (e.g. netdev datapath). */ |
129 | | bool cleanup_required; |
130 | | |
131 | | /* If 'true' the specific dpif implementation synchronizes the various |
132 | | * datapath implementation layers, i.e., the dpif's layer in combination |
133 | | * with the underlying netdev offload layers. For example, dpif-netlink |
134 | | * does not sync its kernel flows with the tc ones, i.e., only one gets |
135 | | * installed. On the other hand, dpif-netdev installs both flows, |
136 | | * internally keeps track of both, and represents them as one. */ |
137 | | bool synced_dp_layers; |
138 | | |
139 | | /* Called when the dpif provider is registered, typically at program |
140 | | * startup. Returning an error from this function will prevent any |
141 | | * datapath with this class from being created. |
142 | | * |
143 | | * This function may be set to null if a datapath class needs no |
144 | | * initialization at registration time. */ |
145 | | int (*init)(void); |
146 | | |
147 | | /* Enumerates the names of all known created datapaths (of class |
148 | | * 'dpif_class'), if possible, into 'all_dps'. The caller has already |
149 | | * initialized 'all_dps' and other dpif classes might already have added |
150 | | * names to it. |
151 | | * |
152 | | * This is used by the vswitch at startup, so that it can delete any |
153 | | * datapaths that are not configured. |
154 | | * |
155 | | * Some kinds of datapaths might not be practically enumerable, in which |
156 | | * case this function may be a null pointer. */ |
157 | | int (*enumerate)(struct sset *all_dps, const struct dpif_class *dpif_class); |
158 | | |
159 | | /* Returns the type to pass to netdev_open() when a dpif of class |
160 | | * 'dpif_class' has a port of type 'type', for a few special cases |
161 | | * when a netdev type differs from a port type. For example, when |
162 | | * using the userspace datapath, a port of type "internal" needs to |
163 | | * be opened as "tap". |
164 | | * |
165 | | * Returns either 'type' itself or a string literal, which must not |
166 | | * be freed. */ |
167 | | const char *(*port_open_type)(const struct dpif_class *dpif_class, |
168 | | const char *type); |
169 | | |
170 | | /* Attempts to open an existing dpif called 'name', if 'create' is false, |
171 | | * or to open an existing dpif or create a new one, if 'create' is true. |
172 | | * |
173 | | * 'dpif_class' is the class of dpif to open. |
174 | | * |
175 | | * If successful, stores a pointer to the new dpif in '*dpifp', which must |
176 | | * have class 'dpif_class'. On failure there are no requirements on what |
177 | | * is stored in '*dpifp'. */ |
178 | | int (*open)(const struct dpif_class *dpif_class, |
179 | | const char *name, bool create, struct dpif **dpifp); |
180 | | |
181 | | /* Closes 'dpif' and frees associated memory. */ |
182 | | void (*close)(struct dpif *dpif); |
183 | | |
184 | | /* Attempts to destroy the dpif underlying 'dpif'. |
185 | | * |
186 | | * If successful, 'dpif' will not be used again except as an argument for |
187 | | * the 'close' member function. */ |
188 | | int (*destroy)(struct dpif *dpif); |
189 | | |
190 | | /* Performs periodic work needed by 'dpif', if any is necessary. |
191 | | * Returns true if need to revalidate. */ |
192 | | bool (*run)(struct dpif *dpif); |
193 | | |
194 | | /* Arranges for poll_block() to wake up if the "run" member function needs |
195 | | * to be called for 'dpif'. */ |
196 | | void (*wait)(struct dpif *dpif); |
197 | | |
198 | | /* Retrieves statistics for 'dpif' into 'stats'. */ |
199 | | int (*get_stats)(const struct dpif *dpif, struct dpif_dp_stats *stats); |
200 | | |
201 | | int (*set_features)(struct dpif *dpif, uint32_t user_features); |
202 | | |
203 | | /* Adds 'netdev' as a new port in 'dpif'. If '*port_no' is not |
204 | | * ODPP_NONE, attempts to use that as the port's port number. |
205 | | * |
206 | | * If port is successfully added, sets '*port_no' to the new port's |
207 | | * port number. Returns EBUSY if caller attempted to choose a port |
208 | | * number, and it was in use. */ |
209 | | int (*port_add)(struct dpif *dpif, struct netdev *netdev, |
210 | | odp_port_t *port_no); |
211 | | |
212 | | /* Removes port numbered 'port_no' from 'dpif'. */ |
213 | | int (*port_del)(struct dpif *dpif, odp_port_t port_no); |
214 | | |
215 | | /* Refreshes configuration of 'dpif's port. The implementation might |
216 | | * postpone applying the changes until run() is called. */ |
217 | | int (*port_set_config)(struct dpif *dpif, odp_port_t port_no, |
218 | | const struct smap *cfg); |
219 | | |
220 | | /* Queries 'dpif' for a port with the given 'port_no' or 'devname'. |
221 | | * If 'port' is not null, stores information about the port into |
222 | | * '*port' if successful. |
223 | | * |
224 | | * If the port doesn't exist, the provider must return ENODEV. Other |
225 | | * error numbers means that something wrong happened and will be |
226 | | * treated differently by upper layers. |
227 | | * |
228 | | * If 'port' is not null, the caller takes ownership of data in |
229 | | * 'port' and must free it with dpif_port_destroy() when it is no |
230 | | * longer needed. */ |
231 | | int (*port_query_by_number)(const struct dpif *dpif, odp_port_t port_no, |
232 | | struct dpif_port *port); |
233 | | int (*port_query_by_name)(const struct dpif *dpif, const char *devname, |
234 | | struct dpif_port *port); |
235 | | |
236 | | /* Returns the Netlink PID value to supply in OVS_ACTION_ATTR_USERSPACE |
237 | | * actions as the OVS_USERSPACE_ATTR_PID attribute's value, for use in |
238 | | * flows whose packets arrived on port 'port_no'. |
239 | | * |
240 | | * A 'port_no' of UINT32_MAX should be treated as a special case. The |
241 | | * implementation should return a reserved PID, not allocated to any port, |
242 | | * that the client may use for special purposes. |
243 | | * |
244 | | * The return value only needs to be meaningful when DPIF_UC_ACTION has |
245 | | * been enabled in the 'dpif''s listen mask, and it is allowed to change |
246 | | * when DPIF_UC_ACTION is disabled and then re-enabled. |
247 | | * |
248 | | * A dpif provider that doesn't have meaningful Netlink PIDs can use NULL |
249 | | * for this function. This is equivalent to always returning 0. */ |
250 | | uint32_t (*port_get_pid)(const struct dpif *dpif, odp_port_t port_no); |
251 | | |
252 | | /* Attempts to begin dumping the ports in a dpif. On success, returns 0 |
253 | | * and initializes '*statep' with any data needed for iteration. On |
254 | | * failure, returns a positive errno value. */ |
255 | | int (*port_dump_start)(const struct dpif *dpif, void **statep); |
256 | | |
257 | | /* Attempts to retrieve another port from 'dpif' for 'state', which was |
258 | | * initialized by a successful call to the 'port_dump_start' function for |
259 | | * 'dpif'. On success, stores a new dpif_port into 'port' and returns 0. |
260 | | * Returns EOF if the end of the port table has been reached, or a positive |
261 | | * errno value on error. This function will not be called again once it |
262 | | * returns nonzero once for a given iteration (but the 'port_dump_done' |
263 | | * function will be called afterward). |
264 | | * |
265 | | * The dpif provider retains ownership of the data stored in 'port'. It |
266 | | * must remain valid until at least the next call to 'port_dump_next' or |
267 | | * 'port_dump_done' for 'state'. */ |
268 | | int (*port_dump_next)(const struct dpif *dpif, void *state, |
269 | | struct dpif_port *port); |
270 | | |
271 | | /* Releases resources from 'dpif' for 'state', which was initialized by a |
272 | | * successful call to the 'port_dump_start' function for 'dpif'. */ |
273 | | int (*port_dump_done)(const struct dpif *dpif, void *state); |
274 | | |
275 | | /* Polls for changes in the set of ports in 'dpif'. If the set of ports in |
276 | | * 'dpif' has changed, then this function should do one of the |
277 | | * following: |
278 | | * |
279 | | * - Preferably: store the name of the device that was added to or deleted |
280 | | * from 'dpif' in '*devnamep' and return 0. The caller is responsible |
281 | | * for freeing '*devnamep' (with free()) when it no longer needs it. |
282 | | * |
283 | | * - Alternatively: return ENOBUFS, without indicating the device that was |
284 | | * added or deleted. |
285 | | * |
286 | | * Occasional 'false positives', in which the function returns 0 while |
287 | | * indicating a device that was not actually added or deleted or returns |
288 | | * ENOBUFS without any change, are acceptable. |
289 | | * |
290 | | * If the set of ports in 'dpif' has not changed, returns EAGAIN. May also |
291 | | * return other positive errno values to indicate that something has gone |
292 | | * wrong. */ |
293 | | int (*port_poll)(const struct dpif *dpif, char **devnamep); |
294 | | |
295 | | /* Arranges for the poll loop to wake up when 'port_poll' will return a |
296 | | * value other than EAGAIN. */ |
297 | | void (*port_poll_wait)(const struct dpif *dpif); |
298 | | |
299 | | /* Deletes all flows from 'dpif' and clears all of its queues of received |
300 | | * packets. */ |
301 | | int (*flow_flush)(struct dpif *dpif); |
302 | | |
303 | | /* Flow dumping interface. |
304 | | * |
305 | | * This is the back-end for the flow dumping interface described in |
306 | | * dpif.h. Please read the comments there first, because this code |
307 | | * closely follows it. |
308 | | * |
309 | | * 'flow_dump_create' and 'flow_dump_thread_create' must always return an |
310 | | * initialized and usable data structure and defer error return until |
311 | | * flow_dump_destroy(). This hasn't been a problem for the dpifs that |
312 | | * exist so far. |
313 | | * |
314 | | * 'flow_dump_create' and 'flow_dump_thread_create' must initialize the |
315 | | * structures that they return with dpif_flow_dump_init() and |
316 | | * dpif_flow_dump_thread_init(), respectively. |
317 | | * |
318 | | * If 'terse' is true, then only UID and statistics will |
319 | | * be returned in the dump. Otherwise, all fields will be returned. |
320 | | * |
321 | | * If 'types' isn't null, dumps only the flows of the passed types. */ |
322 | | struct dpif_flow_dump *(*flow_dump_create)( |
323 | | const struct dpif *dpif, |
324 | | bool terse, |
325 | | struct dpif_flow_dump_types *types); |
326 | | int (*flow_dump_destroy)(struct dpif_flow_dump *dump); |
327 | | |
328 | | struct dpif_flow_dump_thread *(*flow_dump_thread_create)( |
329 | | struct dpif_flow_dump *dump); |
330 | | void (*flow_dump_thread_destroy)(struct dpif_flow_dump_thread *thread); |
331 | | |
332 | | int (*flow_dump_next)(struct dpif_flow_dump_thread *thread, |
333 | | struct dpif_flow *flows, int max_flows); |
334 | | /* Executes each of the 'n_ops' operations in 'ops' on 'dpif', in the order |
335 | | * in which they are specified, placing each operation's results in the |
336 | | * "output" members documented in comments and the 'error' member of each |
337 | | * dpif_op. The offload_type argument tells the provider if 'ops' should |
338 | | * be submitted to to a netdev (only offload) or to the kernel datapath |
339 | | * (never offload) or to both (offload if possible; software fallback). */ |
340 | | void (*operate)(struct dpif *dpif, struct dpif_op **ops, size_t n_ops, |
341 | | enum dpif_offload_type offload_type); |
342 | | |
343 | | /* Get hardware-offloads activity counters from a dataplane. |
344 | | * Those counters are not offload statistics (which are accessible through |
345 | | * netdev statistics), but a status of hardware offload management: |
346 | | * how many offloads are currently waiting, inserted, etc. */ |
347 | | int (*offload_stats_get)(struct dpif *dpif, |
348 | | struct netdev_custom_stats *stats); |
349 | | |
350 | | /* Enables or disables receiving packets with dpif_recv() for 'dpif'. |
351 | | * Turning packet receive off and then back on is allowed to change Netlink |
352 | | * PID assignments (see ->port_get_pid()). The client is responsible for |
353 | | * updating flows as necessary if it does this. */ |
354 | | int (*recv_set)(struct dpif *dpif, bool enable); |
355 | | |
356 | | /* Attempts to refresh the poll loops and Netlink sockets used for handling |
357 | | * upcalls when the number of upcall handlers (upcall receiving thread) is |
358 | | * changed to 'n_handlers' and receiving packets for 'dpif' is enabled by |
359 | | * recv_set(). |
360 | | * |
361 | | * A dpif implementation may choose to ignore 'n_handlers' while returning |
362 | | * success. |
363 | | * |
364 | | * The method for distribution of upcalls between handler threads is |
365 | | * specific to the dpif implementation. |
366 | | */ |
367 | | int (*handlers_set)(struct dpif *dpif, uint32_t n_handlers); |
368 | | |
369 | | /* Queries 'dpif' to see if a certain number of handlers are required by |
370 | | * the implementation. |
371 | | * |
372 | | * If a certain number of handlers are required, returns 'true' and sets |
373 | | * 'n_handlers' to that number of handler threads. |
374 | | * |
375 | | * If not, returns 'false'. |
376 | | */ |
377 | | bool (*number_handlers_required)(struct dpif *dpif, uint32_t *n_handlers); |
378 | | |
379 | | /* Pass custom configuration options to the datapath. The implementation |
380 | | * might postpone applying the changes until run() is called. */ |
381 | | int (*set_config)(struct dpif *dpif, const struct smap *other_config); |
382 | | |
383 | | /* Translates OpenFlow queue ID 'queue_id' (in host byte order) into a |
384 | | * priority value used for setting packet priority. */ |
385 | | int (*queue_to_priority)(const struct dpif *dpif, uint32_t queue_id, |
386 | | uint32_t *priority); |
387 | | |
388 | | /* Polls for an upcall from 'dpif' for an upcall handler. Since there |
389 | | * can be multiple poll loops (see ->handlers_set()), 'handler_id' is |
390 | | * needed as index to identify the corresponding poll loop. If |
391 | | * successful, stores the upcall into '*upcall', using 'buf' for |
392 | | * storage. Should only be called if 'recv_set' has been used to enable |
393 | | * receiving packets from 'dpif'. |
394 | | * |
395 | | * The implementation should point 'upcall->key' and 'upcall->userdata' |
396 | | * (if any) into data in the caller-provided 'buf'. The implementation may |
397 | | * also use 'buf' for storing the data of 'upcall->packet'. If necessary |
398 | | * to make room, the implementation may reallocate the data in 'buf'. |
399 | | * |
400 | | * The caller owns the data of 'upcall->packet' and may modify it. If |
401 | | * packet's headroom is exhausted as it is manipulated, 'upcall->packet' |
402 | | * will be reallocated. This requires the data of 'upcall->packet' to be |
403 | | * released with ofpbuf_uninit() before 'upcall' is destroyed. However, |
404 | | * when an error is returned, the 'upcall->packet' may be uninitialized |
405 | | * and should not be released. |
406 | | * |
407 | | * This function must not block. If no upcall is pending when it is |
408 | | * called, it should return EAGAIN without blocking. */ |
409 | | int (*recv)(struct dpif *dpif, uint32_t handler_id, |
410 | | struct dpif_upcall *upcall, struct ofpbuf *buf); |
411 | | |
412 | | /* Arranges for the poll loop for an upcall handler to wake up when 'dpif' |
413 | | * has a message queued to be received with the recv member functions. |
414 | | * Since there can be multiple poll loops (see ->handlers_set()), |
415 | | * 'handler_id' is needed as index to identify the corresponding poll loop. |
416 | | * */ |
417 | | void (*recv_wait)(struct dpif *dpif, uint32_t handler_id); |
418 | | |
419 | | /* Throws away any queued upcalls that 'dpif' currently has ready to |
420 | | * return. */ |
421 | | void (*recv_purge)(struct dpif *dpif); |
422 | | |
423 | | /* When 'dpif' is about to purge the datapath, the higher layer may want |
424 | | * to be notified so that it could try reacting accordingly (e.g. grabbing |
425 | | * all flow stats before they are gone). |
426 | | * |
427 | | * Registers an upcall callback function with 'dpif'. This is only used |
428 | | * if 'dpif' needs to notify the purging of datapath. 'aux' is passed to |
429 | | * the callback on invocation. */ |
430 | | void (*register_dp_purge_cb)(struct dpif *, dp_purge_callback *, void *aux); |
431 | | |
432 | | /* For datapaths that run in userspace (i.e. dpif-netdev), threads polling |
433 | | * for incoming packets can directly call upcall functions instead of |
434 | | * offloading packet processing to separate handler threads. Datapaths |
435 | | * that directly call upcall functions should use the functions below to |
436 | | * to register an upcall function and enable / disable upcalls. |
437 | | * |
438 | | * Registers an upcall callback function with 'dpif'. This is only used |
439 | | * if 'dpif' directly executes upcall functions. 'aux' is passed to the |
440 | | * callback on invocation. */ |
441 | | void (*register_upcall_cb)(struct dpif *, upcall_callback *, void *aux); |
442 | | |
443 | | /* Enables upcalls if 'dpif' directly executes upcall functions. */ |
444 | | void (*enable_upcall)(struct dpif *); |
445 | | |
446 | | /* Disables upcalls if 'dpif' directly executes upcall functions. */ |
447 | | void (*disable_upcall)(struct dpif *); |
448 | | |
449 | | /* Get datapath version. Caller is responsible for freeing the string |
450 | | * returned. */ |
451 | | char *(*get_datapath_version)(void); |
452 | | |
453 | | /* Conntrack entry dumping interface. |
454 | | * |
455 | | * These functions are used by ct-dpif.c to provide a datapath-agnostic |
456 | | * dumping interface to the connection trackers provided by the |
457 | | * datapaths. |
458 | | * |
459 | | * ct_dump_start() should put in '*state' a pointer to a newly allocated |
460 | | * stucture that will be passed by the caller to ct_dump_next() and |
461 | | * ct_dump_done(). If 'zone' is not NULL, only the entries in '*zone' |
462 | | * should be dumped. |
463 | | * |
464 | | * ct_dump_next() should fill 'entry' with information from a connection |
465 | | * and prepare to dump the next one on a subsequest invocation. |
466 | | * |
467 | | * ct_dump_done() should perform any cleanup necessary (including |
468 | | * deallocating the 'state' structure, if applicable). */ |
469 | | int (*ct_dump_start)(struct dpif *, struct ct_dpif_dump_state **state, |
470 | | const uint16_t *zone, int *); |
471 | | int (*ct_dump_next)(struct dpif *, struct ct_dpif_dump_state *state, |
472 | | struct ct_dpif_entry *entry); |
473 | | int (*ct_dump_done)(struct dpif *, struct ct_dpif_dump_state *state); |
474 | | |
475 | | /* Starts the dump initializing the structures involved and the zone |
476 | | * filter. */ |
477 | | int (*ct_exp_dump_start)(struct dpif *, struct ct_dpif_dump_state **state, |
478 | | const uint16_t *zone); |
479 | | /* Fill the expectation 'entry' with the related information. */ |
480 | | int (*ct_exp_dump_next)(struct dpif *, struct ct_dpif_dump_state *state, |
481 | | struct ct_dpif_exp *entry); |
482 | | /* Ends the dump cleaning up any potential pending state, if any. */ |
483 | | int (*ct_exp_dump_done)(struct dpif *, struct ct_dpif_dump_state *state); |
484 | | |
485 | | /* Flushes the connection tracking tables. The arguments have the |
486 | | * following behavior: |
487 | | * |
488 | | * - If both 'zone' and 'tuple' are NULL, flush all the conntrack |
489 | | * entries. |
490 | | * - If 'zone' is not NULL, and 'tuple' is NULL, flush all the |
491 | | * conntrack entries in '*zone'. |
492 | | * - If 'tuple' is not NULL, flush the conntrack entry specified by |
493 | | * 'tuple' in '*zone'. If 'zone' is NULL, use the default zone |
494 | | * (zone 0). */ |
495 | | int (*ct_flush)(struct dpif *, const uint16_t *zone, |
496 | | const struct ct_dpif_tuple *tuple); |
497 | | /* Set max connections allowed. */ |
498 | | int (*ct_set_maxconns)(struct dpif *, uint32_t maxconns); |
499 | | /* Get max connections allowed. */ |
500 | | int (*ct_get_maxconns)(struct dpif *, uint32_t *maxconns); |
501 | | /* Get number of connections tracked. */ |
502 | | int (*ct_get_nconns)(struct dpif *, uint32_t *nconns); |
503 | | /* Enable or disable TCP sequence checking. */ |
504 | | int (*ct_set_tcp_seq_chk)(struct dpif *, bool enabled); |
505 | | /* Get the TCP sequence checking configuration. */ |
506 | | int (*ct_get_tcp_seq_chk)(struct dpif *, bool *enabled); |
507 | | /* Updates the sweep interval for the CT sweeper. */ |
508 | | int (*ct_set_sweep_interval)(struct dpif *, uint32_t ms); |
509 | | /* Get the current value of the sweep interval for the CT sweeper. */ |
510 | | int (*ct_get_sweep_interval)(struct dpif *, uint32_t *ms); |
511 | | |
512 | | |
513 | | /* Connection tracking per zone limit */ |
514 | | |
515 | | /* Per zone conntrack limit sets the maximum allowed connections in zones |
516 | | * to provide resource isolation. If a per zone limit for a particular |
517 | | * zone is not available in the datapath, it defaults to the default |
518 | | * per zone limit. Initially, the default per zone limit is |
519 | | * unlimited (0). */ |
520 | | |
521 | | /* Sets the max connections allowed per zone according to 'zone_limits', |
522 | | * a list of 'struct ct_dpif_zone_limit' entries (the 'count' member |
523 | | * is not used when setting limits). */ |
524 | | int (*ct_set_limits)(struct dpif *, const struct ovs_list *zone_limits); |
525 | | |
526 | | /* Looks up the per zone limits for all zones in the 'zone_limits_in' list |
527 | | * of 'struct ct_dpif_zone_limit' entries (the 'limit' and 'count' members |
528 | | * are not used), and stores the reply that includes the zone, the per |
529 | | * zone limit, and the number of connections in the zone into |
530 | | * 'zone_limits_out' list. If the 'zone_limits_in' list is empty the |
531 | | * report will contain all previously set zone limits and the default |
532 | | * limit. Note: The default zone limit "count" is not used. */ |
533 | | int (*ct_get_limits)(struct dpif *, const struct ovs_list *zone_limits_in, |
534 | | struct ovs_list *zone_limits_out); |
535 | | |
536 | | /* Deletes per zone limit of all zones specified in 'zone_limits', a |
537 | | * list of 'struct ct_dpif_zone_limit' entries. */ |
538 | | int (*ct_del_limits)(struct dpif *, const struct ovs_list *zone_limits); |
539 | | |
540 | | /* Connection tracking timeout policy */ |
541 | | |
542 | | /* A connection tracking timeout policy contains a list of timeout |
543 | | * attributes that specify timeout values on various connection states. |
544 | | * In a datapath, the timeout policy is identified by a 4-byte unsigned |
545 | | * integer. Unsupported timeout attributes are ignored. When a |
546 | | * connection is committed it can be associated with a timeout |
547 | | * policy, or it defaults to the datapath's default timeout policy. */ |
548 | | |
549 | | /* Sets timeout policy '*tp' into the datapath. */ |
550 | | int (*ct_set_timeout_policy)(struct dpif *, |
551 | | const struct ct_dpif_timeout_policy *tp); |
552 | | /* Gets a timeout policy specified by tp_id and stores it into '*tp'. */ |
553 | | int (*ct_get_timeout_policy)(struct dpif *, uint32_t tp_id, |
554 | | struct ct_dpif_timeout_policy *tp); |
555 | | /* Deletes a timeout policy identified by 'tp_id'. */ |
556 | | int (*ct_del_timeout_policy)(struct dpif *, uint32_t tp_id); |
557 | | |
558 | | /* Conntrack timeout policy dumping interface. |
559 | | * |
560 | | * These functions provide a datapath-agnostic dumping interface |
561 | | * to the conntrack timeout policy provided by the datapaths. |
562 | | * |
563 | | * ct_timeout_policy_dump_start() should put in '*statep' a pointer to |
564 | | * a newly allocated structure that will be passed by the caller to |
565 | | * ct_timeout_policy_dump_next() and ct_timeout_policy_dump_done(). |
566 | | * |
567 | | * ct_timeout_policy_dump_next() attempts to retrieve another timeout |
568 | | * policy from 'dpif' for 'state', which was initialized by a successful |
569 | | * call to ct_timeout_policy_dump_start(). On success, stores a new |
570 | | * timeout policy into 'tp' and returns 0. Returns EOF if the last |
571 | | * timeout policy has been dumped, or a positive errno value on error. |
572 | | * This function will not be called again once it returns nonzero once |
573 | | * for a given iteration (but the ct_timeout_policy_dump_done() will |
574 | | * be called afterward). |
575 | | * |
576 | | * ct_timeout_policy_dump_done() should perform any cleanup necessary |
577 | | * (including deallocating the 'state' structure, if applicable). */ |
578 | | int (*ct_timeout_policy_dump_start)(struct dpif *, void **statep); |
579 | | int (*ct_timeout_policy_dump_next)(struct dpif *, void *state, |
580 | | struct ct_dpif_timeout_policy *tp); |
581 | | int (*ct_timeout_policy_dump_done)(struct dpif *, void *state); |
582 | | |
583 | | /* Gets timeout policy based on 'tp_id', 'dl_type' and 'nw_proto'. |
584 | | * On success, returns 0, stores the timeout policy name in 'tp_name', |
585 | | * and sets 'is_generic'. 'is_generic' is false if the returned timeout |
586 | | * policy in the 'dpif' is specific to 'dl_type' and 'nw_proto' in the |
587 | | * datapath (e.g., the Linux kernel datapath). Sets 'is_generic' to |
588 | | * true, if the timeout policy supports all OVS supported L3/L4 |
589 | | * protocols. |
590 | | * |
591 | | * The caller is responsible for freeing 'tp_name'. */ |
592 | | int (*ct_get_timeout_policy_name)(struct dpif *, uint32_t tp_id, |
593 | | uint16_t dl_type, uint8_t nw_proto, |
594 | | char **tp_name, bool *is_generic); |
595 | | |
596 | | /* Stores the conntrack features supported by 'dpif' into features. |
597 | | * The value is a bitmap of CONNTRACK_F_* bits. */ |
598 | | int (*ct_get_features)(struct dpif *, enum ct_features *features); |
599 | | |
600 | | /* IP Fragmentation. */ |
601 | | |
602 | | /* Disables or enables conntrack fragment reassembly. The default |
603 | | * setting is enabled. */ |
604 | | int (*ipf_set_enabled)(struct dpif *, bool v6, bool enabled); |
605 | | |
606 | | /* Set minimum fragment allowed. */ |
607 | | int (*ipf_set_min_frag)(struct dpif *, bool v6, uint32_t min_frag); |
608 | | |
609 | | /* Set maximum number of fragments tracked. */ |
610 | | int (*ipf_set_max_nfrags)(struct dpif *, uint32_t max_nfrags); |
611 | | |
612 | | /* Get fragmentation configuration status and counters. */ |
613 | | int (*ipf_get_status)(struct dpif *, |
614 | | struct dpif_ipf_status *dpif_ipf_status); |
615 | | |
616 | | /* The following 3 apis find and print ipf lists by creating a string |
617 | | * representation of the state of an ipf list, to which 'dump' is pointed |
618 | | * to. 'ipf_dump_start()' allocates memory for 'ipf_dump_ctx'. |
619 | | * 'ipf_dump_next()' finds the next ipf list and copies it's |
620 | | * characteristics to a string, which is freed by the caller. |
621 | | * 'ipf_dump_done()' frees the 'ipf_dump_ctx' that was allocated in |
622 | | * 'ipf_dump_start'. */ |
623 | | int (*ipf_dump_start)(struct dpif *, struct ipf_dump_ctx **ipf_dump_ctx); |
624 | | int (*ipf_dump_next)(struct dpif *, void *ipf_dump_ctx, char **dump); |
625 | | int (*ipf_dump_done)(struct dpif *, void *ipf_dump_ctx); |
626 | | |
627 | | /* Meters */ |
628 | | |
629 | | /* Queries 'dpif' for supported meter features. |
630 | | * NULL pointer means no meter features are supported. */ |
631 | | void (*meter_get_features)(const struct dpif *, |
632 | | struct ofputil_meter_features *); |
633 | | |
634 | | /* Adds or modifies the meter in 'dpif' with the given 'meter_id' |
635 | | * and the configuration in 'config'. |
636 | | * |
637 | | * The meter id specified through 'config->meter_id' is ignored. */ |
638 | | int (*meter_set)(struct dpif *, ofproto_meter_id meter_id, |
639 | | struct ofputil_meter_config *); |
640 | | |
641 | | /* Queries 'dpif' for meter stats with the given 'meter_id'. Stores |
642 | | * maximum of 'n_bands' meter statistics, returning the number of band |
643 | | * stats returned in 'stats->n_bands' if successful. */ |
644 | | int (*meter_get)(const struct dpif *, ofproto_meter_id meter_id, |
645 | | struct ofputil_meter_stats *, uint16_t n_bands); |
646 | | |
647 | | /* Removes meter 'meter_id' from 'dpif'. Stores meter and band statistics |
648 | | * (for maximum of 'n_bands', returning the number of band stats returned |
649 | | * in 'stats->n_bands' if successful. 'stats' may be passed in as NULL if |
650 | | * no stats are needed, in which case 'n_bands' must be passed in as |
651 | | * zero. */ |
652 | | int (*meter_del)(struct dpif *, ofproto_meter_id meter_id, |
653 | | struct ofputil_meter_stats *, uint16_t n_bands); |
654 | | |
655 | | /* Adds a bond with 'bond_id' and the member-map to 'dpif'. */ |
656 | | int (*bond_add)(struct dpif *dpif, uint32_t bond_id, |
657 | | odp_port_t *member_map); |
658 | | |
659 | | /* Removes bond identified by 'bond_id' from 'dpif'. */ |
660 | | int (*bond_del)(struct dpif *dpif, uint32_t bond_id); |
661 | | |
662 | | /* Reads bond stats from 'dpif'. 'n_bytes' should be an array with size |
663 | | * sufficient to store BOND_BUCKETS number of elements. */ |
664 | | int (*bond_stats_get)(struct dpif *dpif, uint32_t bond_id, |
665 | | uint64_t *n_bytes); |
666 | | |
667 | | /* Cache configuration |
668 | | * |
669 | | * Multiple levels of cache can exist in a given datapath implementation. |
670 | | * An API has been provided to get the number of supported caches, which |
671 | | * can then be used to get/set specific configuration. Cache level is 0 |
672 | | * indexed, i.e. if 1 level is supported, the level value to use is 0. |
673 | | * |
674 | | * Get the number of cache levels supported. */ |
675 | | int (*cache_get_supported_levels)(struct dpif *dpif, uint32_t *levels); |
676 | | |
677 | | /* Get the cache name for the given level. */ |
678 | | int (*cache_get_name)(struct dpif *dpif, uint32_t level, |
679 | | const char **name); |
680 | | |
681 | | /* Get currently configured cache size. */ |
682 | | int (*cache_get_size)(struct dpif *dpif, uint32_t level, uint32_t *size); |
683 | | |
684 | | /* Set cache size. */ |
685 | | int (*cache_set_size)(struct dpif *dpif, uint32_t level, uint32_t size); |
686 | | }; |
687 | | |
688 | | extern const struct dpif_class dpif_netlink_class; |
689 | | extern const struct dpif_class dpif_netdev_class; |
690 | | |
691 | | #ifdef __cplusplus |
692 | | } |
693 | | #endif |
694 | | |
695 | | #endif /* dpif-provider.h */ |