bridge: Simplify VLAN splinter memory management.

Before this patch, the VLAN splinter memory management operated on
blocks of memory instead of ovsrec_ports.  This strategy is
problematic in future patches when more than simply calling
'free()' needs to be done to destroy splinter ports.  This patch
solves the problem by keeping track of entire ovsrec_ports instead
of just the memory allocated to create them.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
lib: New data structure - smap.

A smap is a string to string hash map.  It has a cleaner interface
than shash's which were traditionally used for the same purpose.
This patch implements the data structure, and changes netdev and
its providers to use it.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
lib: Utilize smaps in the idl.

String to string maps are used all over the Open vSwitch database.
Before this patch, they were implemented in the idl as parallel
string arrays.  This strategy has proven a bit cumbersome.  With
this patch, string to string maps are implemented using the smap
library.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
openflow: Add ofp11_group

OFPG11_ANY may be used as the out_group for ofp11_flow_mod and
ofp11_flow_stats_request.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Add OFPUTIL_ACTION_INVALID to enum ofputil_action_code.

Possibly the ofputil_decode_action() interface should be rethought now
that ofputil_action_code has an invalid value.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Introduce ofpacts, an abstraction of OpenFlow actions.

OpenFlow actions have always been somewhat awkward to handle.
Moreover, over time we've started creating actions that require more
complicated parsing.  When we maintain those actions internally in
their wire format, we end up parsing them multiple times, whenever
we have to look at the set of actions.

When we add support for OpenFlow 1.1 or later protocols, the situation
will get worse, because these newer protocols support many of the same
actions but with different representations.  It becomes unrealistic to
handle each protocol in its wire format.

This commit adopts a new strategy, by converting OpenFlow actions into
an internal form from the wire format when they are read, and converting
them back to the wire format when flows are dumped.  I believe that this
will be more maintainable over time.

Signed-off-by: Ben Pfaff <blp@nicira.com>

---

v2:

- Fix confusion between NXAST_RESUBMIT and NXAST_RESUBMIT_TABLE.

- Rename functions for NXAST_ actions to mention nxast in their
  names instead of openflow10, since they are not OpenFlow 1.0
  specific.

- Move the code for NXAST_ encoding into a separate function so
  that later on it can be reused for encoding these actions into
  OpenFlow 1.1 also.
ofp-util: Remove unused functions.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
openflow: Separate flow stats headers from their bodies.

For some time, Open vSwitch has combined both ofp_stats_msg and
the data that follows it into single structures, because we found
that this is usually easier to handle.than having them separated.
But OpenFlow 1.1+ has a different stats message header (it has 4
extra bytes of padding) whereas many of the bodies are the same
or similar and so this approach falls down there.  Therefore, this
commit switches back to separated header and body for stats
messages.

Signed-off-by: Ben Pfaff <blp@nicira.com>
openflow: Rename OpenFlow 1.0 statistics messages with "10" infix.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-actions: Support decoding OpenFlow 1.1 instructions and actions.

This builds and doesn't break any existing unit tests, but nothing
calls it yet (and it doesn't have any unit tests of its own) so it
can hardly be called useful.

Left to do:

    - Instructions other than Apply-Actions.

    - Actions other than the ones that have identical semantics to
      OpenFlow 1.0 actions.

    - Unit tests.

    - Encoding.
ofp-actions: Support encoding OpenFlow 1.1 instructions and actions.

I am unsure about what to do about some of the messages,
as noted with 'FIXME' in the code.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* Initial posting
ofp-actions: Adjust encoding OpenFlow 1.1 actions.

This mainly changes ofpact_to_openflow11() to use the
ofpact_to_nxast() function that I introduced.  I think this makes
ofpact_to_openflow11() more readable; certainly shorter.

I also broke ofpacts_to_openflow() into two functions
ofpacts_to_openflow10() and ofpacts_to_openflow11().  I might be
wrong, but my feeling is that the messages and circumstances in
which actions are present in OpenFlow 1.0 and 1.1 are different
enough that there won't be any caller that would want to blindly
pass along a protocol value.

We don't have any functions for encoding instructions yet.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Refactor ofputil_decode_msg_type__() for extensibility.

There's an upcoming need to decode yet another variant of OpenFlow
messages: OpenFlow 1.1 statistics requests and replies.  The code for
decoding messages types is getting unmanageable.  This commit refactors it
to make it easier to maintain and extend.

Before this is committed it needs the following work:

    - One unit test fails because this commit removes a log message that
      was previously omitted.  That needs to be resolved somehow.

    - Figure out whether the nasty macros here are really the best way to
      construct the table.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: work on OF1.1 stats messages

This is a start at extending the stats message helpers to support OF1.1
stats messages too.  It isn't complete, doesn't compile, and I'm not fond
of the approach.

Signed-off-by: Ben Pfaff <blp@nicira.com>
openflow: Separate OF1.0, OF1.1 flow_mod constants and types.

Probably incomplete.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-util: Work on decoding OF1.1 flow_mods.

A work in progress.  Doesn't build.

I'm not really sure I want separate OFPUTIL_ constants for OF1.0 and OF1.1
versions of each message.  It's something I'm trying out as I write the
code.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Local Fix: ofp-util: Work on decoding OF1.1 flow_mods.

This is a local change to fix some compile errors in
Ben Pfaff's "ofp-util: Work on decoding OF1.1 flow_mods." patch.

It should either be rolled into those changes or dropped.
nx-match: Take into account leading header when calculating pad

In the case of Open Flow 1.2, which is currently the only
time that OXM is be used, there is a 4 byte header before
the match which needs to be taken into account when calculating
the pad length.

This is not entirely pretty, but it does seem to be correct.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v4
* Initial post
ofp-util: Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12

Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12 for Open Flow 1.2

OFPUTIL_P_OF12_TID and in turn OFPUTIL_P_OF12_ANY is not provided as
OFPUTIL_P_OF12 supports the use of table ids in modify flow messages.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v4
* No change

v3
* Don't add NXPIF_OPENFLOW12, it doesn't seem to be needed

v2
* No change
openflow: Add Open Flow 1.2 to ofp_to_string__()

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v4
* No change

v3
* Add "openflow: " prefix to title

v2
* No change