2 * Copyright (c) 2012 Nicira Networks.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef OFPROTO_DPIF_GOVERNOR_H
18 #define OFPROTO_DPIF_GOVERNOR_H 1
20 /* Flow setup rate limiter.
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.
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. */
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. */
43 struct governor *governor_create(const char *name);
44 void governor_destroy(struct governor *);
46 void governor_run(struct governor *);
47 void governor_wait(struct governor *);
49 bool governor_is_idle(struct governor *);
51 bool governor_should_install_flow(struct governor *, uint32_t hash, int n);
53 #endif /* ofproto/ofproto-dpif-governor.h */