Makefile: Allow "make modules_install" to work from top-level directory.

INSTALL recommends running "make modules_install" but it didn't mention
that this has to be done from datapath/linux.  This commit makes this work
from the top-level build directory.

(Another solution would be to update INSTALL, but this approach seems a
little easier for the user.)

Signed-off-by: Ben Pfaff <blp@nicira.com>
odp: Enable parsing ipv4_tunnel key.

We can format ipv4_tunnel keys from the kernel but can't currently
parse them.  Userspace doesn't know how to do anything with this
information but this support enables utilities like ovs-dpctl and
ovs-appctl ofproto/trace to show useful information.

Bug #13785

Signed-off-by: Jesse Gross <jesse@nicira.com>
dpif: Fix minor typo in comment.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
sset: Add sset_at_position() function.

This will be useful in a future commit.

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Always treat datapath ports as 32 bits.

Most of the code referred to datapath ports as 32-bit values, but a few
places still used 16-bit references.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Use ODP ports in dpif layer and below.

The current code has a simple mapping between datapath and OpenFlow port
numbers (the port numbers were the same other than OFPP_LOCAL which maps
to datapath port 0).  Since the translation was know at compile time,
this allowed different layers to easily translate between the two, so
the translation often occurred late.

A future commit will break this simple mapping, so this commit draws a
line between where datapath and OpenFlow port numbers are used.  The
ofproto-dpif layer will be responsible for the translations.  Callers
above will use OpenFlow port numbers.  Providers below will use
datapath port numbers.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Allow the OpenFlow port to be requested for a port.

A new "ofport_request" column makes it possible to request the OpenFlow
port number when adding a port.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ofproto: Add initialization function.

A future commit will make all bridges of a particular dpif share a
single backing datapath.  In order to handle restart, the datapath will
need to have some idea of what the initial state looks like.  Otherwise,
it won't know which ports belong to which bridges and orphaned ports may
never be cleaned up.

This commit introduces an initialization method to ofproto, which takes
as an argument a high-level description of the bridges and ports.  An
ofproto provider can then use this information to initialize its state.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
tests: Define new ADD_OF_PORTS macro for ofproto tests.

A future commit will break the relation between OpenFlow and datapath
port numbers.  The new ADD_OF_PORTS macro adds an interface to a bridge
and configures it such that both the OpenFlow and datapath port numbers
are the same.  This is important in tests that deal with both OpenFlow
and datapath port numbers (e.g., ones that use ofproto/trace).

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Separate OpenFlow port numbers from datapath ones.

In a future commit, we will make multiple bridges share a single backing
datapath.  Our simple mapping from datapath to OpenFlow port numbers
won't work, since we'll want the same OpenFlow port numbers on different
bridges.  For example, the OFPP_LOCAL port must be the same on all
bridges, but will have to be a different datapath port on the converged
datapath.

This commit makes it the responsibility of ofproto to assign the
OpenFlow port numbers instead of doing a simple translation from the
datapath ones.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
tests: Rewrite unit tests to not expect bridge with odp zero.

A future commit will make all bridges of a particular type share a
single backing datapath.  That backing datapath will have a datapath
port number of zero and bridges will be assigned other numbers.  This
commit modifies the tests so that they don't expect port zero.

It adopts the convention that bridges of type "dummy" with a name of the
form "br<n>" will be assigned a port number of 100+<n>.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ofproto-dpif: Add ovs-appctl commands for ovs-dpctl functions.

These commands will be useful in a future commit that makes multiple
bridges share a single backing datapath.  The ovs-dpctl commands will
show information about the backing datapath, so it will be difficult to
determine which information belongs to which bridge.  The new "dpif/*"
ovs-appctl commands return information about the bridge--regardless of
how the backing datapath is configured.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ofproto-dpif: Introduce subfacet_destroy_batch().

A future commit will introduce another caller that wants to destroy
batches of subfacets.  Repurpose expire_batch() to be a more generic
method for destroying batches of subfacets.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ovs-dpctl: Make specifying datapath optional for some commands.

A future commit will make all bridges use a single backing datapath.
This commit makes the "dp" argument for "dump-flows" and "del-flows"
optional, since there will typically only be one actual datapath.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
ofproto: Add type "run", "run_fast", and "wait" provider methods.

Add the ability for ofproto providers to have top-level "run",
"run_fast", and "wait" methods, similar to the current ofproto ones.
There are no current users, but this will be useful in a future commit.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
dpif: Add new dpif_port_exists() function.

Provide the ability to determine whether a port exists in a datapath
without having to deal with a "dpif_port" structure as with
dpif_port_query_by_name().  A future patch will use this function.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
dpif: Add function to get the dpif type.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
dpif-sflow: Remove unused parameter from dpif_sflow_create().

Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
ofproto-dpif: Use a single underlying datapath across multiple bridges.

This commit switches to using a single backing datapath (called
"ovs-datapath") for all bridges of that datapath's type.  Previously,
resources couldn't be shared across bridges, since each was in its own
datapath.  This change will allow sharing of tunnels and cheaper patch
ports to be added in the future.

Since bridges share a common datapath, the ovs-dpctl commands won't
provide bridge-specific information.  Users wishing to have that
information should use the new "ovs-appctl dpif/*" commands as
documented in ovs-vswitchd(8).

Signed-off-by: Justin Pettit <jpettit@nicira.com>
FAQ: Explain the difference between a switch and a bridge.

(There isn't any difference.)

Based on a conversation in #openvswitch.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>