]> git.proxmox.com Git - mirror_ovs.git/blame - PORTING
ovsdb: Implement table uniqueness constraints ("indexes").
[mirror_ovs.git] / PORTING
CommitLineData
bc34d060
BP
1 How to Port Open vSwitch to New Software or Hardware
2 ====================================================
3
4Open vSwitch (OVS) is intended to be easily ported to new software and
5hardware platforms. This document describes the types of changes that
6are most likely to be necessary in porting OVS to Unix-like platforms.
7(Porting OVS to other kinds of platforms is likely to be more
8difficult.)
9
abe529af 10
fa066f01
BP
11Vocabulary
12----------
13
14For historical reasons, different words are used for essentially the
15same concept in different areas of the Open vSwitch source tree. Here
16is a concordance, indexed by the area of the source tree:
17
18 datapath/ vport ---
19 vswitchd/ iface port
20 ofproto/ port bundle
21 lib/bond.c slave bond
22 lib/lacp.c slave lacp
23 lib/netdev.c netdev ---
24 database Interface Port
25
26
bc34d060
BP
27Open vSwitch Architectural Overview
28-----------------------------------
29
abe529af 30The following diagram shows the very high-level architecture of Open
bc34d060 31vSwitch from a porter's perspective.
bc34d060 32
abe529af
BP
33 +-------------------+
34 | ovs-vswitchd |<-->ovsdb-server
35 +-------------------+
36 | ofproto |<-->OpenFlow controllers
37 +--------+-+--------+
38 | netdev | | ofproto|
39 +--------+ |provider|
40 | netdev | +--------+
41 |provider|
42 +--------+
43
44Some of the components are generic. Modulo bugs or inadequacies,
45these components should not need to be modified as part of a port:
46
47 - "ovs-vswitchd" is the main Open vSwitch userspace program, in
48 vswitchd/. It reads the desired Open vSwitch configuration from
49 the ovsdb-server program over an IPC channel and passes this
50 configuration down to the "ofproto" library. It also passes
51 certain status and statistical information from ofproto back
52 into the database.
53
54 - "ofproto" is the Open vSwitch library, in ofproto/, that
55 implements an OpenFlow switch. It talks to OpenFlow controllers
56 over the network and to switch hardware or software to an
57 "ofproto provider", explained further below.
58
59 - "netdev" is the Open vSwitch library, in lib/netdev.c, that
60 abstracts interacting with network devices, that is, Ethernet
61 interfaces. The netdev library is a thin layer over "netdev
62 provider" code, explained further below.
63
64The other components may need attention during a port. You will
65almost certainly have to implement a "netdev provider". Depending on
66the type of port you are doing and the desired performance, you may
67also have to implement an "ofproto provider" or a lower-level
68component called a "dpif" provider.
bc34d060 69
abe529af 70The following sections talk about these components in more detail.
bc34d060 71
bc34d060 72
abe529af
BP
73Writing a netdev Provider
74-------------------------
bc34d060 75
abe529af
BP
76A "netdev provider" implements an operating system and hardware
77specific interface to "network devices", e.g. eth0 on Linux. Open
78vSwitch must be able to open each port on a switch as a netdev, so you
79will need to implement a "netdev provider" that works with your switch
80hardware and software.
bc34d060 81
abe529af
BP
82struct netdev_class, in lib/netdev-provider.h, defines the interfaces
83required to implement a netdev. That structure contains many function
84pointers, each of which has a comment that is meant to describe its
85behavior in detail. If the requirements are unclear, please report
86this as a bug.
bc34d060 87
abe529af 88The netdev interface can be divided into a few rough categories:
bc34d060
BP
89
90 * Functions required to properly implement OpenFlow features. For
91 example, OpenFlow requires the ability to report the Ethernet
92 hardware address of a port. These functions must be implemented
93 for minimally correct operation.
94
95 * Functions required to implement optional Open vSwitch features.
96 For example, the Open vSwitch support for in-band control
97 requires netdev support for inspecting the TCP/IP stack's ARP
98 table. These functions must be implemented if the corresponding
99 OVS features are to work, but may be omitted initially.
100
abe529af
BP
101 * Functions needed in some implementations but not in others. For
102 example, most kinds of ports (see below) do not need
103 functionality to receive packets from a network device.
bc34d060
BP
104
105The existing netdev implementations may serve as useful examples
106during a port:
107
108 * lib/netdev-linux.c implements netdev functionality for Linux
109 network devices, using Linux kernel calls. It may be a good
110 place to start for full-featured netdev implementations.
111
abe529af 112 * lib/netdev-vport.c provides support for "virtual ports"
59348dba
JP
113 implemented by the Open vSwitch datapath module for the Linux
114 kernel. This may serve as a model for minimal netdev
115 implementations.
bc34d060 116
abe529af
BP
117 * lib/netdev-dummy.c is a fake netdev implementation useful only
118 for testing.
119
120
121Porting Strategies
122------------------
123
124After a netdev provider has been implemented for a system's network
125devices, you may choose among three basic porting strategies.
126
127The lowest-effort strategy is to use the "userspace switch"
128implementation built into Open vSwitch. This ought to work, without
129writing any more code, as long as the netdev provider that you
130implemented supports receiving packets. It yields poor performance,
131however, because every packet passes through the ovs-vswitchd process.
132See INSTALL.userspace for instructions on how to configure a userspace
133switch.
134
135If the userspace switch is not the right choice for your port, then
136you will have to write more code. You may implement either an
137"ofproto provider" or a "dpif provider". Which you should choose
138depends on a few different factors:
139
140 * Only an ofproto provider can take full advantage of hardware
141 with built-in support for wildcards (e.g. an ACL table or a
142 TCAM).
143
144 * A dpif provider can take advantage of the Open vSwitch built-in
145 implementations of bonding, LACP, 802.1ag, 802.1Q VLANs, and
146 other features. An ofproto provider has to provide its own
147 implementations, if the hardware can support them at all.
148
149 * A dpif provider is usually easier to implement.
150
151The following sections describe how to implement each kind of port.
152
153
154ofproto Providers
155-----------------
156
157An "ofproto provider" is what ofproto uses to directly monitor and
158control an OpenFlow-capable switch. struct ofproto_class, in
159ofproto/private.h, defines the interfaces to implement a ofproto
160provider for new hardware or software. That structure contains many
161function pointers, each of which has a comment that is meant to
162describe its behavior in detail. If the requirements are unclear,
163please report this as a bug.
164
165The ofproto provider interface is preliminary. Please let us know if
166it seems unsuitable for your purpose. We will try to improve it.
167
168
169Writing a dpif Provider
170-----------------------
171
172Open vSwitch has a built-in ofproto provider named "ofproto-dpif",
173which is built on top of a library for manipulating datapaths, called
174"dpif". A "datapath" is a simple flow table, one that supports only
175exact-match flows, that is, flows without wildcards. When a packet
176arrives on a network device, the datapath looks for it in this
177exact-match table. If there is a match, then it performs the
178associated actions. If there is no match, the datapath passes the
179packet up to ofproto-dpif, which maintains an OpenFlow flow table
180(that supports wildcards). If the packet matches in this flow table,
181then ofproto-dpif executes its actions and inserts a new exact-match
182entry into the dpif flow table. (Otherwise, ofproto-dpif passes the
183packet up to ofproto to send the packet to the OpenFlow controller, if
184one is configured.)
185
186The "dpif" library in turn delegates much of its functionality to a
187"dpif provider". The following diagram shows how dpif providers fit
188into the Open vSwitch architecture:
189
190 _
191 | +-------------------+
192 | | ovs-vswitchd |<-->ovsdb-server
193 | +-------------------+
194 | | ofproto |<-->OpenFlow controllers
195 | +--------+-+--------+
196 | | netdev | |ofproto-|
197 userspace | +--------+ | dpif |
198 | | netdev | +--------+
199 | |provider| | dpif |
200 | +---||---+ +--------+
201 | || | dpif |
202 | || |provider|
203 |_ || +---||---+
204 || ||
205 _ +---||-----+---||---+
206 | | |datapath|
207 kernel | | +--------+
208 | | |
209 |_ +--------||---------+
210 ||
211 physical
212 NIC
213
214struct dpif_class, in lib/dpif-provider.h, defines the interfaces
215required to implement a dpif provider for new hardware or software.
216That structure contains many function pointers, each of which has a
217comment that is meant to describe its behavior in detail. If the
218requirements are unclear, please report this as a bug.
219
220There are two existing dpif implementations that may serve as
221useful examples during a port:
222
223 * lib/dpif-linux.c is a Linux-specific dpif implementation that
224 talks to an Open vSwitch-specific kernel module (whose sources
225 are in the "datapath" directory). The kernel module performs
226 all of the switching work, passing packets that do not match any
227 flow table entry up to userspace. This dpif implementation is
228 essentially a wrapper around calls into the kernel module.
229
230 * lib/dpif-netdev.c is a generic dpif implementation that performs
231 all switching internally. This is how the Open vSwitch
232 userspace switch is implemented.
233
234
6e8e271c
BP
235Miscellaneous Notes
236-------------------
237
da40ecac
BP
238Open vSwitch source code uses uint16_t, uint32_t, and uint64_t as
239fixed-width types in host byte order, and ovs_be16, ovs_be32, and
240ovs_be64 as fixed-width types in network byte order. Each of the
241latter is equivalent to the one of the former, but the difference in
242name makes the intended use obvious.
243
abe529af
BP
244ovs-vswitchd is the most sophisticated of ofproto's clients, but
245ofproto can have other clients as well. ovs-openflowd, in the
246utilities directory, is much simpler than ovs-vswitchd. It may be
247easier to initially bring up ovs-openflowd as part of a port.
248
e251c8d0
BP
249lib/entropy.c assumes that it can obtain high-quality random number
250seeds at startup by reading from /dev/urandom. You will need to
251modify it if this is not true on your platform.
6e8e271c 252
ce887677
BP
253vswitchd/system-stats.c only knows how to obtain some statistics on
254Linux. Optionally you may implement them for your platform as well.
255
abe529af 256
bc34d060
BP
257Questions
258---------
259
260Please direct porting questions to dev@openvswitch.org. We will try
261to use questions to improve this porting guide.