]>
Commit | Line | Data |
---|---|---|
96fba48f | 1 | /* |
ac64794a | 2 | * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. |
96fba48f BP |
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 | |
bc34d060 BP |
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. */ | |
96fba48f | 24 | |
43253595 | 25 | #include "openflow/openflow.h" |
96fba48f | 26 | #include "dpif.h" |
43253595 | 27 | #include "util.h" |
96fba48f | 28 | |
1acb6baa BP |
29 | #ifdef __cplusplus |
30 | extern "C" { | |
31 | #endif | |
32 | ||
96fba48f BP |
33 | /* Open vSwitch datapath interface. |
34 | * | |
35 | * This structure should be treated as opaque by dpif implementations. */ | |
36 | struct dpif { | |
1acb6baa | 37 | const struct dpif_class *dpif_class; |
1a6f1e2a JG |
38 | char *base_name; |
39 | char *full_name; | |
96fba48f BP |
40 | uint8_t netflow_engine_type; |
41 | uint8_t netflow_engine_id; | |
42 | }; | |
43 | ||
44 | void dpif_init(struct dpif *, const struct dpif_class *, const char *name, | |
45 | uint8_t netflow_engine_type, uint8_t netflow_engine_id); | |
999401aa JG |
46 | void dpif_uninit(struct dpif *dpif, bool close); |
47 | ||
96fba48f | 48 | static inline void dpif_assert_class(const struct dpif *dpif, |
1acb6baa | 49 | const struct dpif_class *dpif_class) |
96fba48f | 50 | { |
cb22974d | 51 | ovs_assert(dpif->dpif_class == dpif_class); |
96fba48f BP |
52 | } |
53 | ||
ac64794a BP |
54 | struct dpif_flow_dump { |
55 | struct dpif *dpif; | |
64bb477f | 56 | bool terse; /* If true, key/mask/actions may be omitted. */ |
ac64794a BP |
57 | }; |
58 | ||
59 | static inline void | |
60 | dpif_flow_dump_init(struct dpif_flow_dump *dump, const struct dpif *dpif) | |
61 | { | |
62 | dump->dpif = CONST_CAST(struct dpif *, dpif); | |
63 | } | |
64 | ||
65 | struct dpif_flow_dump_thread { | |
66 | struct dpif *dpif; | |
67 | }; | |
68 | ||
69 | static inline void | |
70 | dpif_flow_dump_thread_init(struct dpif_flow_dump_thread *thread, | |
71 | struct dpif_flow_dump *dump) | |
72 | { | |
73 | thread->dpif = dump->dpif; | |
74 | } | |
75 | ||
b77d9629 DDP |
76 | struct ct_dpif_dump_state; |
77 | struct ct_dpif_entry; | |
817a7657 | 78 | struct ct_dpif_tuple; |
b77d9629 | 79 | |
96fba48f | 80 | /* Datapath interface class structure, to be defined by each implementation of |
f20279af | 81 | * a datapath interface. |
96fba48f BP |
82 | * |
83 | * These functions return 0 if successful or a positive errno value on failure, | |
84 | * except where otherwise noted. | |
85 | * | |
86 | * These functions are expected to execute synchronously, that is, to block as | |
87 | * necessary to obtain a result. Thus, they may not return EAGAIN or | |
88 | * EWOULDBLOCK or EINPROGRESS. We may relax this requirement in the future if | |
89 | * and when we encounter performance problems. */ | |
90 | struct dpif_class { | |
1a6f1e2a | 91 | /* Type of dpif in this class, e.g. "system", "netdev", etc. |
96fba48f | 92 | * |
1a6f1e2a JG |
93 | * One of the providers should supply a "system" type, since this is |
94 | * the type assumed if no type is specified when opening a dpif. */ | |
95 | const char *type; | |
96fba48f | 96 | |
c8973eb6 DDP |
97 | /* Called when the dpif provider is registered, typically at program |
98 | * startup. Returning an error from this function will prevent any | |
99 | * datapath with this class from being created. | |
100 | * | |
101 | * This function may be set to null if a datapath class needs no | |
102 | * initialization at registration time. */ | |
103 | int (*init)(void); | |
104 | ||
2240af25 DDP |
105 | /* Enumerates the names of all known created datapaths (of class |
106 | * 'dpif_class'), if possible, into 'all_dps'. The caller has already | |
107 | * initialized 'all_dps' and other dpif classes might already have added | |
108 | * names to it. | |
d3d22744 BP |
109 | * |
110 | * This is used by the vswitch at startup, so that it can delete any | |
111 | * datapaths that are not configured. | |
112 | * | |
113 | * Some kinds of datapaths might not be practically enumerable, in which | |
114 | * case this function may be a null pointer. */ | |
2240af25 | 115 | int (*enumerate)(struct sset *all_dps, const struct dpif_class *dpif_class); |
d3d22744 | 116 | |
0aeaabc8 JP |
117 | /* Returns the type to pass to netdev_open() when a dpif of class |
118 | * 'dpif_class' has a port of type 'type', for a few special cases | |
119 | * when a netdev type differs from a port type. For example, when | |
120 | * using the userspace datapath, a port of type "internal" needs to | |
121 | * be opened as "tap". | |
122 | * | |
123 | * Returns either 'type' itself or a string literal, which must not | |
124 | * be freed. */ | |
125 | const char *(*port_open_type)(const struct dpif_class *dpif_class, | |
126 | const char *type); | |
127 | ||
1a6f1e2a JG |
128 | /* Attempts to open an existing dpif called 'name', if 'create' is false, |
129 | * or to open an existing dpif or create a new one, if 'create' is true. | |
96fba48f | 130 | * |
4a387741 BP |
131 | * 'dpif_class' is the class of dpif to open. |
132 | * | |
133 | * If successful, stores a pointer to the new dpif in '*dpifp', which must | |
134 | * have class 'dpif_class'. On failure there are no requirements on what | |
135 | * is stored in '*dpifp'. */ | |
136 | int (*open)(const struct dpif_class *dpif_class, | |
137 | const char *name, bool create, struct dpif **dpifp); | |
96fba48f BP |
138 | |
139 | /* Closes 'dpif' and frees associated memory. */ | |
140 | void (*close)(struct dpif *dpif); | |
141 | ||
142 | /* Attempts to destroy the dpif underlying 'dpif'. | |
143 | * | |
144 | * If successful, 'dpif' will not be used again except as an argument for | |
145 | * the 'close' member function. */ | |
1acb6baa | 146 | int (*destroy)(struct dpif *dpif); |
96fba48f | 147 | |
a36de779 PS |
148 | /* Performs periodic work needed by 'dpif', if any is necessary. |
149 | * Returns true if need to revalidate. */ | |
150 | bool (*run)(struct dpif *dpif); | |
640e1b20 BP |
151 | |
152 | /* Arranges for poll_block() to wake up if the "run" member function needs | |
153 | * to be called for 'dpif'. */ | |
154 | void (*wait)(struct dpif *dpif); | |
155 | ||
96fba48f | 156 | /* Retrieves statistics for 'dpif' into 'stats'. */ |
a8d9304d | 157 | int (*get_stats)(const struct dpif *dpif, struct dpif_dp_stats *stats); |
96fba48f | 158 | |
232dfa4a | 159 | /* Adds 'netdev' as a new port in 'dpif'. If '*port_no' is not |
8eff7d8a | 160 | * ODPP_NONE, attempts to use that as the port's port number. |
232dfa4a JP |
161 | * |
162 | * If port is successfully added, sets '*port_no' to the new port's | |
163 | * port number. Returns EBUSY if caller attempted to choose a port | |
164 | * number, and it was in use. */ | |
c3827f61 | 165 | int (*port_add)(struct dpif *dpif, struct netdev *netdev, |
4e022ec0 | 166 | odp_port_t *port_no); |
96fba48f BP |
167 | |
168 | /* Removes port numbered 'port_no' from 'dpif'. */ | |
4e022ec0 | 169 | int (*port_del)(struct dpif *dpif, odp_port_t port_no); |
96fba48f | 170 | |
91364d18 IM |
171 | /* Refreshes configuration of 'dpif's port. The implementation might |
172 | * postpone applying the changes until run() is called. */ | |
173 | int (*port_set_config)(struct dpif *dpif, odp_port_t port_no, | |
174 | const struct smap *cfg); | |
175 | ||
4afba28d JP |
176 | /* Queries 'dpif' for a port with the given 'port_no' or 'devname'. |
177 | * If 'port' is not null, stores information about the port into | |
178 | * '*port' if successful. | |
4c738a8d | 179 | * |
0f6a066f DDP |
180 | * If the port doesn't exist, the provider must return ENODEV. Other |
181 | * error numbers means that something wrong happened and will be | |
182 | * treated differently by upper layers. | |
183 | * | |
4afba28d JP |
184 | * If 'port' is not null, the caller takes ownership of data in |
185 | * 'port' and must free it with dpif_port_destroy() when it is no | |
186 | * longer needed. */ | |
4e022ec0 | 187 | int (*port_query_by_number)(const struct dpif *dpif, odp_port_t port_no, |
4c738a8d | 188 | struct dpif_port *port); |
96fba48f | 189 | int (*port_query_by_name)(const struct dpif *dpif, const char *devname, |
4c738a8d | 190 | struct dpif_port *port); |
96fba48f | 191 | |
98403001 BP |
192 | /* Returns the Netlink PID value to supply in OVS_ACTION_ATTR_USERSPACE |
193 | * actions as the OVS_USERSPACE_ATTR_PID attribute's value, for use in | |
769b5034 | 194 | * flows whose packets arrived on port 'port_no'. |
98403001 | 195 | * |
9b56fe13 | 196 | * A 'port_no' of UINT32_MAX should be treated as a special case. The |
625b0720 BP |
197 | * implementation should return a reserved PID, not allocated to any port, |
198 | * that the client may use for special purposes. | |
199 | * | |
98403001 BP |
200 | * The return value only needs to be meaningful when DPIF_UC_ACTION has |
201 | * been enabled in the 'dpif''s listen mask, and it is allowed to change | |
202 | * when DPIF_UC_ACTION is disabled and then re-enabled. | |
203 | * | |
204 | * A dpif provider that doesn't have meaningful Netlink PIDs can use NULL | |
205 | * for this function. This is equivalent to always returning 0. */ | |
769b5034 | 206 | uint32_t (*port_get_pid)(const struct dpif *dpif, odp_port_t port_no); |
98403001 | 207 | |
b0ec0f27 BP |
208 | /* Attempts to begin dumping the ports in a dpif. On success, returns 0 |
209 | * and initializes '*statep' with any data needed for iteration. On | |
210 | * failure, returns a positive errno value. */ | |
211 | int (*port_dump_start)(const struct dpif *dpif, void **statep); | |
212 | ||
213 | /* Attempts to retrieve another port from 'dpif' for 'state', which was | |
214 | * initialized by a successful call to the 'port_dump_start' function for | |
4c738a8d | 215 | * 'dpif'. On success, stores a new dpif_port into 'port' and returns 0. |
b0ec0f27 BP |
216 | * Returns EOF if the end of the port table has been reached, or a positive |
217 | * errno value on error. This function will not be called again once it | |
218 | * returns nonzero once for a given iteration (but the 'port_dump_done' | |
4c738a8d BP |
219 | * function will be called afterward). |
220 | * | |
221 | * The dpif provider retains ownership of the data stored in 'port'. It | |
222 | * must remain valid until at least the next call to 'port_dump_next' or | |
223 | * 'port_dump_done' for 'state'. */ | |
b0ec0f27 | 224 | int (*port_dump_next)(const struct dpif *dpif, void *state, |
4c738a8d | 225 | struct dpif_port *port); |
b0ec0f27 BP |
226 | |
227 | /* Releases resources from 'dpif' for 'state', which was initialized by a | |
228 | * successful call to the 'port_dump_start' function for 'dpif'. */ | |
229 | int (*port_dump_done)(const struct dpif *dpif, void *state); | |
96fba48f | 230 | |
e9e28be3 BP |
231 | /* Polls for changes in the set of ports in 'dpif'. If the set of ports in |
232 | * 'dpif' has changed, then this function should do one of the | |
233 | * following: | |
234 | * | |
235 | * - Preferably: store the name of the device that was added to or deleted | |
236 | * from 'dpif' in '*devnamep' and return 0. The caller is responsible | |
237 | * for freeing '*devnamep' (with free()) when it no longer needs it. | |
238 | * | |
239 | * - Alternatively: return ENOBUFS, without indicating the device that was | |
240 | * added or deleted. | |
241 | * | |
242 | * Occasional 'false positives', in which the function returns 0 while | |
243 | * indicating a device that was not actually added or deleted or returns | |
244 | * ENOBUFS without any change, are acceptable. | |
245 | * | |
246 | * If the set of ports in 'dpif' has not changed, returns EAGAIN. May also | |
247 | * return other positive errno values to indicate that something has gone | |
248 | * wrong. */ | |
249 | int (*port_poll)(const struct dpif *dpif, char **devnamep); | |
250 | ||
251 | /* Arranges for the poll loop to wake up when 'port_poll' will return a | |
252 | * value other than EAGAIN. */ | |
253 | void (*port_poll_wait)(const struct dpif *dpif); | |
254 | ||
96fba48f BP |
255 | /* Deletes all flows from 'dpif' and clears all of its queues of received |
256 | * packets. */ | |
257 | int (*flow_flush)(struct dpif *dpif); | |
258 | ||
ac64794a | 259 | /* Flow dumping interface. |
e6cc0bab | 260 | * |
ac64794a BP |
261 | * This is the back-end for the flow dumping interface described in |
262 | * dpif.h. Please read the comments there first, because this code | |
263 | * closely follows it. | |
e6cc0bab | 264 | * |
ac64794a BP |
265 | * 'flow_dump_create' and 'flow_dump_thread_create' must always return an |
266 | * initialized and usable data structure and defer error return until | |
267 | * flow_dump_destroy(). This hasn't been a problem for the dpifs that | |
268 | * exist so far. | |
704a1e09 | 269 | * |
ac64794a BP |
270 | * 'flow_dump_create' and 'flow_dump_thread_create' must initialize the |
271 | * structures that they return with dpif_flow_dump_init() and | |
64bb477f JS |
272 | * dpif_flow_dump_thread_init(), respectively. |
273 | * | |
274 | * If 'terse' is true, then only UID and statistics will | |
7e8b7199 PB |
275 | * be returned in the dump. Otherwise, all fields will be returned. |
276 | * | |
a692410a GT |
277 | * If 'types' isn't null, dumps only the flows of the passed types. */ |
278 | struct dpif_flow_dump *(*flow_dump_create)( | |
279 | const struct dpif *dpif, | |
280 | bool terse, | |
281 | struct dpif_flow_dump_types *types); | |
ac64794a BP |
282 | int (*flow_dump_destroy)(struct dpif_flow_dump *dump); |
283 | ||
284 | struct dpif_flow_dump_thread *(*flow_dump_thread_create)( | |
285 | struct dpif_flow_dump *dump); | |
286 | void (*flow_dump_thread_destroy)(struct dpif_flow_dump_thread *thread); | |
287 | ||
288 | int (*flow_dump_next)(struct dpif_flow_dump_thread *thread, | |
289 | struct dpif_flow *flows, int max_flows); | |
96fba48f | 290 | |
6bc60024 BP |
291 | /* Executes each of the 'n_ops' operations in 'ops' on 'dpif', in the order |
292 | * in which they are specified, placing each operation's results in the | |
1a0c894a BP |
293 | * "output" members documented in comments and the 'error' member of each |
294 | * dpif_op. */ | |
c2b565b5 | 295 | void (*operate)(struct dpif *dpif, struct dpif_op **ops, size_t n_ops); |
6bc60024 | 296 | |
a12b3ead BP |
297 | /* Enables or disables receiving packets with dpif_recv() for 'dpif'. |
298 | * Turning packet receive off and then back on is allowed to change Netlink | |
98403001 BP |
299 | * PID assignments (see ->port_get_pid()). The client is responsible for |
300 | * updating flows as necessary if it does this. */ | |
a12b3ead | 301 | int (*recv_set)(struct dpif *dpif, bool enable); |
96fba48f | 302 | |
1954e6bb AW |
303 | /* Refreshes the poll loops and Netlink sockets associated to each port, |
304 | * when the number of upcall handlers (upcall receiving thread) is changed | |
305 | * to 'n_handlers' and receiving packets for 'dpif' is enabled by | |
306 | * recv_set(). | |
307 | * | |
308 | * Since multiple upcall handlers can read upcalls simultaneously from | |
309 | * 'dpif', each port can have multiple Netlink sockets, one per upcall | |
310 | * handler. So, handlers_set() is responsible for the following tasks: | |
311 | * | |
312 | * When receiving upcall is enabled, extends or creates the | |
313 | * configuration to support: | |
314 | * | |
315 | * - 'n_handlers' Netlink sockets for each port. | |
316 | * | |
317 | * - 'n_handlers' poll loops, one for each upcall handler. | |
318 | * | |
319 | * - registering the Netlink sockets for the same upcall handler to | |
320 | * the corresponding poll loop. | |
321 | * */ | |
322 | int (*handlers_set)(struct dpif *dpif, uint32_t n_handlers); | |
323 | ||
d4f6865c DDP |
324 | /* Pass custom configuration options to the datapath. The implementation |
325 | * might postpone applying the changes until run() is called. */ | |
326 | int (*set_config)(struct dpif *dpif, const struct smap *other_config); | |
f2eee189 | 327 | |
aae51f53 | 328 | /* Translates OpenFlow queue ID 'queue_id' (in host byte order) into a |
abff858b | 329 | * priority value used for setting packet priority. */ |
aae51f53 BP |
330 | int (*queue_to_priority)(const struct dpif *dpif, uint32_t queue_id, |
331 | uint32_t *priority); | |
332 | ||
1954e6bb AW |
333 | /* Polls for an upcall from 'dpif' for an upcall handler. Since there |
334 | * can be multiple poll loops (see ->handlers_set()), 'handler_id' is | |
335 | * needed as index to identify the corresponding poll loop. If | |
336 | * successful, stores the upcall into '*upcall', using 'buf' for | |
337 | * storage. Should only be called if 'recv_set' has been used to enable | |
338 | * receiving packets from 'dpif'. | |
96fba48f | 339 | * |
da546e07 JR |
340 | * The implementation should point 'upcall->key' and 'upcall->userdata' |
341 | * (if any) into data in the caller-provided 'buf'. The implementation may | |
342 | * also use 'buf' for storing the data of 'upcall->packet'. If necessary | |
343 | * to make room, the implementation may reallocate the data in 'buf'. | |
344 | * | |
345 | * The caller owns the data of 'upcall->packet' and may modify it. If | |
346 | * packet's headroom is exhausted as it is manipulated, 'upcall->packet' | |
347 | * will be reallocated. This requires the data of 'upcall->packet' to be | |
837a88dc JR |
348 | * released with ofpbuf_uninit() before 'upcall' is destroyed. However, |
349 | * when an error is returned, the 'upcall->packet' may be uninitialized | |
350 | * and should not be released. | |
856081f6 BP |
351 | * |
352 | * This function must not block. If no upcall is pending when it is | |
353 | * called, it should return EAGAIN without blocking. */ | |
1954e6bb AW |
354 | int (*recv)(struct dpif *dpif, uint32_t handler_id, |
355 | struct dpif_upcall *upcall, struct ofpbuf *buf); | |
356 | ||
357 | /* Arranges for the poll loop for an upcall handler to wake up when 'dpif' | |
358 | * has a message queued to be received with the recv member functions. | |
359 | * Since there can be multiple poll loops (see ->handlers_set()), | |
360 | * 'handler_id' is needed as index to identify the corresponding poll loop. | |
361 | * */ | |
362 | void (*recv_wait)(struct dpif *dpif, uint32_t handler_id); | |
1ba530f4 BP |
363 | |
364 | /* Throws away any queued upcalls that 'dpif' currently has ready to | |
365 | * return. */ | |
366 | void (*recv_purge)(struct dpif *dpif); | |
6b31e073 | 367 | |
e4e74c3a AW |
368 | /* When 'dpif' is about to purge the datapath, the higher layer may want |
369 | * to be notified so that it could try reacting accordingly (e.g. grabbing | |
370 | * all flow stats before they are gone). | |
371 | * | |
372 | * Registers an upcall callback function with 'dpif'. This is only used | |
373 | * if 'dpif' needs to notify the purging of datapath. 'aux' is passed to | |
374 | * the callback on invocation. */ | |
375 | void (*register_dp_purge_cb)(struct dpif *, dp_purge_callback *, void *aux); | |
376 | ||
6b31e073 RW |
377 | /* For datapaths that run in userspace (i.e. dpif-netdev), threads polling |
378 | * for incoming packets can directly call upcall functions instead of | |
379 | * offloading packet processing to separate handler threads. Datapaths | |
380 | * that directly call upcall functions should use the functions below to | |
381 | * to register an upcall function and enable / disable upcalls. | |
382 | * | |
e4e74c3a | 383 | * Registers an upcall callback function with 'dpif'. This is only used |
623540e4 EJ |
384 | * if 'dpif' directly executes upcall functions. 'aux' is passed to the |
385 | * callback on invocation. */ | |
386 | void (*register_upcall_cb)(struct dpif *, upcall_callback *, void *aux); | |
6b31e073 RW |
387 | |
388 | /* Enables upcalls if 'dpif' directly executes upcall functions. */ | |
389 | void (*enable_upcall)(struct dpif *); | |
390 | ||
391 | /* Disables upcalls if 'dpif' directly executes upcall functions. */ | |
392 | void (*disable_upcall)(struct dpif *); | |
b5cbbcf6 AZ |
393 | |
394 | /* Get datapath version. Caller is responsible for freeing the string | |
395 | * returned. */ | |
396 | char *(*get_datapath_version)(void); | |
b77d9629 DDP |
397 | |
398 | /* Conntrack entry dumping interface. | |
399 | * | |
400 | * These functions are used by ct-dpif.c to provide a datapath-agnostic | |
9dcd5910 | 401 | * dumping interface to the connection trackers provided by the |
b77d9629 DDP |
402 | * datapaths. |
403 | * | |
404 | * ct_dump_start() should put in '*state' a pointer to a newly allocated | |
405 | * stucture that will be passed by the caller to ct_dump_next() and | |
406 | * ct_dump_done(). If 'zone' is not NULL, only the entries in '*zone' | |
407 | * should be dumped. | |
408 | * | |
409 | * ct_dump_next() should fill 'entry' with information from a connection | |
410 | * and prepare to dump the next one on a subsequest invocation. | |
411 | * | |
9dcd5910 | 412 | * ct_dump_done() should perform any cleanup necessary (including |
b77d9629 DDP |
413 | * deallocating the 'state' structure, if applicable). */ |
414 | int (*ct_dump_start)(struct dpif *, struct ct_dpif_dump_state **state, | |
ded30c74 | 415 | const uint16_t *zone, int *); |
9dcd5910 | 416 | int (*ct_dump_next)(struct dpif *, struct ct_dpif_dump_state *state, |
b77d9629 DDP |
417 | struct ct_dpif_entry *entry); |
418 | int (*ct_dump_done)(struct dpif *, struct ct_dpif_dump_state *state); | |
a0f7b6d5 | 419 | |
817a7657 YHW |
420 | /* Flushes the connection tracking tables. The arguments have the |
421 | * following behavior: | |
422 | * | |
423 | * - If both 'zone' and 'tuple' are NULL, flush all the conntrack | |
424 | * entries. | |
425 | * - If 'zone' is not NULL, and 'tuple' is NULL, flush all the | |
426 | * conntrack entries in '*zone'. | |
427 | * - If 'tuple' is not NULL, flush the conntrack entry specified by | |
428 | * 'tuple' in '*zone'. If 'zone' is NULL, use the default zone | |
429 | * (zone 0). */ | |
430 | int (*ct_flush)(struct dpif *, const uint16_t *zone, | |
431 | const struct ct_dpif_tuple *tuple); | |
c92339ad DB |
432 | /* Set max connections allowed. */ |
433 | int (*ct_set_maxconns)(struct dpif *, uint32_t maxconns); | |
434 | /* Get max connections allowed. */ | |
435 | int (*ct_get_maxconns)(struct dpif *, uint32_t *maxconns); | |
875075b3 DB |
436 | /* Get number of connections tracked. */ |
437 | int (*ct_get_nconns)(struct dpif *, uint32_t *nconns); | |
5dddf960 | 438 | |
cd015a11 YHW |
439 | /* Connection tracking per zone limit */ |
440 | ||
441 | /* Per zone conntrack limit sets the maximum allowed connections in zones | |
442 | * to provide resource isolation. If a per zone limit for a particular | |
443 | * zone is not available in the datapath, it defaults to the default | |
444 | * per zone limit. Initially, the default per zone limit is | |
445 | * unlimited (0). */ | |
446 | ||
447 | /* Sets the max connections allowed per zone according to 'zone_limits', | |
448 | * a list of 'struct ct_dpif_zone_limit' entries (the 'count' member | |
449 | * is not used when setting limits). If 'default_limit' is not NULL, | |
450 | * modifies the default limit to '*default_limit'. */ | |
451 | int (*ct_set_limits)(struct dpif *, const uint32_t *default_limit, | |
452 | const struct ovs_list *zone_limits); | |
453 | ||
454 | /* Looks up the default per zone limit and stores that in | |
455 | * 'default_limit'. Look up the per zone limits for all zones in | |
456 | * the 'zone_limits_in' list of 'struct ct_dpif_zone_limit' entries | |
457 | * (the 'limit' and 'count' members are not used), and stores the | |
458 | * reply that includes the zone, the per zone limit, and the number | |
459 | * of connections in the zone into 'zone_limits_out' list. */ | |
460 | int (*ct_get_limits)(struct dpif *, uint32_t *default_limit, | |
461 | const struct ovs_list *zone_limits_in, | |
462 | struct ovs_list *zone_limits_out); | |
463 | ||
464 | /* Deletes per zone limit of all zones specified in 'zone_limits', a | |
465 | * list of 'struct ct_dpif_zone_limit' entries. */ | |
466 | int (*ct_del_limits)(struct dpif *, const struct ovs_list *zone_limits); | |
467 | ||
5dddf960 JR |
468 | /* Meters */ |
469 | ||
470 | /* Queries 'dpif' for supported meter features. | |
471 | * NULL pointer means no meter features are supported. */ | |
472 | void (*meter_get_features)(const struct dpif *, | |
473 | struct ofputil_meter_features *); | |
474 | ||
8101f03f JP |
475 | /* Adds or modifies the meter in 'dpif' with the given 'meter_id' |
476 | * and the configuration in 'config'. | |
5dddf960 | 477 | * |
8101f03f JP |
478 | * The meter id specified through 'config->meter_id' is ignored. */ |
479 | int (*meter_set)(struct dpif *, ofproto_meter_id meter_id, | |
5dddf960 JR |
480 | struct ofputil_meter_config *); |
481 | ||
482 | /* Queries 'dpif' for meter stats with the given 'meter_id'. Stores | |
483 | * maximum of 'n_bands' meter statistics, returning the number of band | |
484 | * stats returned in 'stats->n_bands' if successful. */ | |
485 | int (*meter_get)(const struct dpif *, ofproto_meter_id meter_id, | |
486 | struct ofputil_meter_stats *, uint16_t n_bands); | |
487 | ||
488 | /* Removes meter 'meter_id' from 'dpif'. Stores meter and band statistics | |
489 | * (for maximum of 'n_bands', returning the number of band stats returned | |
490 | * in 'stats->n_bands' if successful. 'stats' may be passed in as NULL if | |
491 | * no stats are needed, in which case 'n_bands' must be passed in as | |
492 | * zero. */ | |
493 | int (*meter_del)(struct dpif *, ofproto_meter_id meter_id, | |
494 | struct ofputil_meter_stats *, uint16_t n_bands); | |
96fba48f BP |
495 | }; |
496 | ||
93451a0a | 497 | extern const struct dpif_class dpif_netlink_class; |
72865317 | 498 | extern const struct dpif_class dpif_netdev_class; |
96fba48f | 499 | |
1acb6baa BP |
500 | #ifdef __cplusplus |
501 | } | |
502 | #endif | |
503 | ||
96fba48f | 504 | #endif /* dpif-provider.h */ |