]> git.proxmox.com Git - mirror_ovs.git/blame - ofproto/connmgr.h
list: Move contents of lib/list.h to include/openvswitch directory.
[mirror_ovs.git] / ofproto / connmgr.h
CommitLineData
19a87e36 1/*
a930d4c5 2 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
19a87e36
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 CONNMGR_H
18#define CONNMGR_H 1
19
2b07c8b1 20#include "classifier.h"
19a87e36
BP
21#include "hmap.h"
22#include "list.h"
81a76618 23#include "match.h"
0fb7792a 24#include "ofp-util.h"
19a87e36 25#include "ofproto.h"
cdbdeeda 26#include "ofproto-provider.h"
19a87e36 27#include "openflow/nicira-ext.h"
e03c096d 28#include "openvswitch/ofp-errors.h"
19a87e36
BP
29#include "openvswitch/types.h"
30
a946b636 31struct nlattr;
19a87e36 32struct ofconn;
2b07c8b1 33struct rule;
0d085684 34struct simap;
81e2083f 35struct sset;
19a87e36
BP
36
37/* ofproto supports two kinds of OpenFlow connections:
38 *
39 * - "Primary" connections to ordinary OpenFlow controllers. ofproto
40 * maintains persistent connections to these controllers and by default
41 * sends them asynchronous messages such as packet-ins.
42 *
43 * - "Service" connections, e.g. from ovs-ofctl. When these connections
44 * drop, it is the other side's responsibility to reconnect them if
45 * necessary. ofproto does not send them asynchronous messages by default.
46 *
47 * Currently, active (tcp, ssl, unix) connections are always "primary"
48 * connections and passive (ptcp, pssl, punix) connections are always "service"
49 * connections. There is no inherent reason for this, but it reflects the
50 * common case.
51 */
52enum ofconn_type {
53 OFCONN_PRIMARY, /* An ordinary OpenFlow controller. */
54 OFCONN_SERVICE /* A service connection, e.g. "ovs-ofctl". */
55};
56
a2b53dec
BP
57/* An asynchronous message that might need to be queued between threads. */
58struct ofproto_async_msg {
ca6ba700 59 struct ovs_list list_node; /* For queuing. */
f11c7538 60 uint16_t controller_id; /* Controller ID to send to. */
a2b53dec
BP
61
62 enum ofputil_async_msg_type oam;
e8fed7d0
WT
63 /* OAM_PACKET_IN. */
64 struct {
65 struct ofputil_packet_in_private up;
66 int max_len; /* From action, or -1 if none. */
67 } pin;
0fb7792a 68};
a2b53dec 69void ofproto_async_msg_free(struct ofproto_async_msg *);
0fb7792a 70
19a87e36
BP
71/* Basics. */
72struct connmgr *connmgr_create(struct ofproto *ofproto,
73 const char *dpif_name, const char *local_name);
74void connmgr_destroy(struct connmgr *);
75
76void connmgr_run(struct connmgr *,
b20f4073 77 void (*handle_openflow)(struct ofconn *,
e03248b7 78 const struct ofpbuf *ofp_msg));
b20f4073 79void connmgr_wait(struct connmgr *);
19a87e36 80
0d085684
BP
81void connmgr_get_memory_usage(const struct connmgr *, struct simap *usage);
82
19a87e36
BP
83struct ofproto *ofconn_get_ofproto(const struct ofconn *);
84
7ee20df1
BP
85void connmgr_retry(struct connmgr *);
86
19a87e36
BP
87/* OpenFlow configuration. */
88bool connmgr_has_controllers(const struct connmgr *);
89void connmgr_get_controller_info(struct connmgr *, struct shash *);
72ba2ed3 90void connmgr_free_controller_info(struct shash *);
19a87e36 91void connmgr_set_controllers(struct connmgr *,
1d9ffc17
SH
92 const struct ofproto_controller[], size_t n,
93 uint32_t allowed_versions);
19a87e36
BP
94void connmgr_reconnect(const struct connmgr *);
95
81e2083f
BP
96int connmgr_set_snoops(struct connmgr *, const struct sset *snoops);
97bool connmgr_has_snoops(const struct connmgr *);
98void connmgr_get_snoops(const struct connmgr *, struct sset *snoops);
19a87e36
BP
99
100/* Individual connections to OpenFlow controllers. */
101enum ofconn_type ofconn_get_type(const struct ofconn *);
102
f4f1ea7e 103bool ofconn_get_master_election_id(const struct ofconn *, uint64_t *idp);
6ea4776b 104bool ofconn_set_master_election_id(struct ofconn *, uint64_t);
f4f1ea7e
BP
105enum ofp12_controller_role ofconn_get_role(const struct ofconn *);
106void ofconn_set_role(struct ofconn *, enum ofp12_controller_role);
19a87e36 107
e3d560db 108enum ofputil_protocol ofconn_get_protocol(const struct ofconn *);
27527aa0 109void ofconn_set_protocol(struct ofconn *, enum ofputil_protocol);
19a87e36 110
54834960
EJ
111enum nx_packet_in_format ofconn_get_packet_in_format(struct ofconn *);
112void ofconn_set_packet_in_format(struct ofconn *, enum nx_packet_in_format);
113
a7349929
BP
114void ofconn_set_controller_id(struct ofconn *, uint16_t controller_id);
115
f0fd1a17
PS
116void ofconn_set_invalid_ttl_to_controller(struct ofconn *, bool);
117bool ofconn_get_invalid_ttl_to_controller(struct ofconn *);
118
19a87e36
BP
119int ofconn_get_miss_send_len(const struct ofconn *);
120void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
121
80d5aefd 122void ofconn_set_async_config(struct ofconn *,
a930d4c5
BP
123 const struct ofputil_async_cfg *);
124struct ofputil_async_cfg ofconn_get_async_config(const struct ofconn *);
80d5aefd 125
19a87e36 126void ofconn_send_reply(const struct ofconn *, struct ofpbuf *);
ca6ba700 127void ofconn_send_replies(const struct ofconn *, struct ovs_list *);
1be5ff75 128void ofconn_send_error(const struct ofconn *, const struct ofp_header *request,
90bf1e07 129 enum ofperr);
19a87e36 130
90bf1e07 131enum ofperr ofconn_pktbuf_retrieve(struct ofconn *, uint32_t id,
cf62fa4c 132 struct dp_packet **bufferp, ofp_port_t *in_port);
19a87e36 133
ff09bc08
JR
134struct ofp_bundle;
135
136struct ofp_bundle *ofconn_get_bundle(struct ofconn *, uint32_t id);
137enum ofperr ofconn_insert_bundle(struct ofconn *, struct ofp_bundle *);
138enum ofperr ofconn_remove_bundle(struct ofconn *, struct ofp_bundle *);
777af88d 139
696d1bcf
BP
140/* Logging flow_mod summaries. */
141void ofconn_report_flow_mod(struct ofconn *, enum ofp_flow_mod_command);
142
19a87e36 143/* Sending asynchronous messages. */
6b83a3c5 144bool connmgr_wants_packet_in_on_miss(struct connmgr *mgr);
2a6f78e0 145void connmgr_send_port_status(struct connmgr *, struct ofconn *source,
9e1fd49b 146 const struct ofputil_phy_port *, uint8_t reason);
19a87e36
BP
147void connmgr_send_flow_removed(struct connmgr *,
148 const struct ofputil_flow_removed *);
a2b53dec
BP
149void connmgr_send_async_msg(struct connmgr *,
150 const struct ofproto_async_msg *);
00467f73
AC
151void ofconn_send_role_status(struct ofconn *ofconn, uint32_t role,
152 uint8_t reason);
19a87e36 153
3c35db62
NR
154void connmgr_send_requestforward(struct connmgr *, const struct ofconn *source,
155 const struct ofputil_requestforward *);
156
19a87e36
BP
157/* Fail-open settings. */
158enum ofproto_fail_mode connmgr_get_fail_mode(const struct connmgr *);
159void connmgr_set_fail_mode(struct connmgr *, enum ofproto_fail_mode);
160
161/* Fail-open implementation. */
162int connmgr_get_max_probe_interval(const struct connmgr *);
163bool connmgr_is_any_controller_connected(const struct connmgr *);
164bool connmgr_is_any_controller_admitted(const struct connmgr *);
165int connmgr_failure_duration(const struct connmgr *);
19a87e36
BP
166
167/* In-band configuration. */
168void connmgr_set_extra_in_band_remotes(struct connmgr *,
169 const struct sockaddr_in *, size_t);
170void connmgr_set_in_band_queue(struct connmgr *, int queue_id);
171
172/* In-band implementation. */
f7f1ea29 173bool connmgr_has_in_band(struct connmgr *);
19a87e36
BP
174
175/* Fail-open and in-band implementation. */
176void connmgr_flushed(struct connmgr *);
177
3fbbcba7
BP
178int connmgr_count_hidden_rules(const struct connmgr *);
179
2b07c8b1
BP
180/* A flow monitor managed by NXST_FLOW_MONITOR and related requests. */
181struct ofmonitor {
182 struct ofconn *ofconn; /* Owning 'ofconn'. */
183 struct hmap_node ofconn_node; /* In ofconn's 'monitors' hmap. */
184 uint32_t id;
185
186 enum nx_flow_monitor_flags flags;
187
188 /* Matching. */
4e022ec0 189 ofp_port_t out_port;
2b07c8b1 190 uint8_t table_id;
5cb7a798 191 struct minimatch match;
2b07c8b1
BP
192};
193
194struct ofputil_flow_monitor_request;
195
196enum ofperr ofmonitor_create(const struct ofputil_flow_monitor_request *,
4cd1bc9d
BP
197 struct ofconn *, struct ofmonitor **)
198 OVS_REQUIRES(ofproto_mutex);
199struct ofmonitor *ofmonitor_lookup(struct ofconn *, uint32_t id)
200 OVS_REQUIRES(ofproto_mutex);
201void ofmonitor_destroy(struct ofmonitor *)
202 OVS_REQUIRES(ofproto_mutex);
2b07c8b1
BP
203
204void ofmonitor_report(struct connmgr *, struct rule *,
205 enum nx_flow_update_event, enum ofp_flow_removed_reason,
cdbdeeda
SH
206 const struct ofconn *abbrev_ofconn, ovs_be32 abbrev_xid,
207 const struct rule_actions *old_actions)
15aaf599 208 OVS_REQUIRES(ofproto_mutex);
4cd1bc9d 209void ofmonitor_flush(struct connmgr *) OVS_REQUIRES(ofproto_mutex);
2b07c8b1 210
a8e547c1
BP
211
212struct rule_collection;
2b07c8b1 213void ofmonitor_collect_resume_rules(struct ofmonitor *, uint64_t seqno,
4cd1bc9d
BP
214 struct rule_collection *)
215 OVS_REQUIRES(ofproto_mutex);
a8e547c1 216void ofmonitor_compose_refresh_updates(struct rule_collection *rules,
ca6ba700 217 struct ovs_list *msgs)
4cd1bc9d 218 OVS_REQUIRES(ofproto_mutex);
2b07c8b1 219
6c6eedc5
SJ
220void connmgr_send_table_status(struct connmgr *,
221 const struct ofputil_table_desc *td,
222 uint8_t reason);
19a87e36 223#endif /* connmgr.h */