]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/ofproto-dpif-governor.h
unixctl: Make dpif/dump-flows fetch kernel flows.
[mirror_ovs.git] / ofproto / ofproto-dpif-governor.h
CommitLineData
9d6ac44e 1/*
e0edde6f 2 * Copyright (c) 2012 Nicira, Inc.
9d6ac44e
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 OFPROTO_DPIF_GOVERNOR_H
18#define OFPROTO_DPIF_GOVERNOR_H 1
19
20/* Flow setup rate limiter.
21 *
22 * A governor in an engine limits a vehicle's speed. This governor limits the
23 * rate at which flows are set up in the datapath. The client provides as
24 * input the hashes of observed packets. The governor keeps track of hashes
25 * seen multiple times. When a given hash is seen often enough, the governor
26 * indicates to its client that it should set up a facet and a subfacet and a
27 * datapath flow for that flow.
28 *
29 * The same tracking could be done in terms of facets and subfacets directly,
30 * but the governor code uses much less time and space to do the same job. */
31
32#include <stdbool.h>
33#include <stdint.h>
34
35struct governor {
36 char *name; /* Name, for log messages. */
37 uint8_t *table; /* Table of counters, two per byte. */
38 unsigned int size; /* Table size in bytes. */
39 long long int start; /* Time when the table was last cleared. */
40 unsigned int n_packets; /* Number of packets processed. */
42531d06
BP
41
42 /* Statistics for skipping counters when most flows get set up. */
43 unsigned int n_flows; /* Number of unique flows seen. */
44 unsigned int n_setups; /* Number of flows set up based on counters. */
45 unsigned int n_shortcuts; /* Number of flows set up based on history. */
9d6ac44e
BP
46};
47
c985ec94 48struct governor *governor_create(void);
9d6ac44e
BP
49void governor_destroy(struct governor *);
50
51void governor_run(struct governor *);
52void governor_wait(struct governor *);
53
54bool governor_is_idle(struct governor *);
55
56bool governor_should_install_flow(struct governor *, uint32_t hash, int n);
57
58#endif /* ofproto/ofproto-dpif-governor.h */