vconn: Add ofputil_version_bitmap

Functions to manipulate a bitmap of allowed versions.

The bitmap is simple a uint32_t, allowing
for versions up until wire-protocol number 31.

Bit offsets correspond to ofp_version numbers which in turn
correspond to wire-protocol numbers for Open Flow versions..
E.g. (1 << OFP10_VERSION) is the mask for Open Flow 1.1.
If the bit for a version is set then it is allowed, otherwise it is
disallowed.

This is in preparation for allowing the range of allowed OpenFlow
versions to be configured.

Signed-off-by: Simon Horman <horms@verge.net.au>
vconn: Allowed OpenFlow versions

Replace minimum version with bitmap of allowed versions.

This is in preparation for allowing the range of allowed OpenFlow
versions to be configured.

As part of this change pvconn_open() is now paramatised over the allowed
versions.  this is to avoid avoids needing to provide version information
as a parameter to pvconn_accept().  This will in turn avoid the need to
pass version information to connmgr_run().

Signed-off-by: Simon Horman <horms@verge.net.au>
ofp-util: Add version bitmap support to hello messages

Allow encoding and decoding of version bitmap in hello messages
as specified in Open Flow 1.3.1.

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

---

v3
* As suggested by Ben Pfaff
  - Skip unknown hello elements
  - Use bitmap directly in the form of a uint32_t
    instead of creating a struct ofp_hello

v2
* Initial post
connmgr: Paramatise ofservice_create() over allowed OpenFlow versions

This is in preparation for allowing configuration of the
allowed OpenFlow versions.

Signed-off-by: Simon Horman <horms@verge.net.au>
ofproto: Make set_pvconns() aware of OpenFlow versions

Paramatise the allowed OpenFlow verion for snoops.
This is in preparation for making the allow OpenFlow verions to
be configured.

Signed-off-by: Simon Horman <horms@verge.net.au>
rconn: Add allowed OpenFlow versions

Add allowed OpenFlow versions to struct rconn to allow
reconnect to use these parameters rather than hard-coded defaults.

This is in preparation for allowing configuration of the
allowed OpenFlow versions.

Signed-off-by: Simon Horman <horms@verge.net.au>
ofproto, connmgr: Parameterise OpenFlow versions for adding controller

Allow allowed Open Flow versions to be passed rather
than relying on hard-coded defaults.

This is in preparation for allowing configuration of the
allowed OpenFlow versions.

Signed-off-by: Simon Horman <horms@verge.net.au>
ofp-util: Allow use of OpenFlow 12 flow format

This enables the use of the OpenFlow 12 flow format.

Signed-off-by: Simon Horman <horms@verge.net.au>
connmgr: Use version of underlying rconn

Signed-off-by: Simon Horman <horms@verge.net.au>
vswitchd: Configuration of allowed OpenFlow versions

Versions may be configured using a comma delimited list as
the value for 'openflow-versions' the 'other-config' column
of the Bridge table.

Currently list elements other than 'OpenFlow10' and 'OpenFlow12' will
be ignored.

If the list is empty, then OpenFlow10 is used.
This default is consistent with the behaviour of ovs-vswtichd
prior to this patch.

Signed-off-by: Simon Horman <horms@verge.net.au>
lib: Add helpers for OpenFlow version command line options

Signed-off-by: Simon Horman <horms@verge.net.au>
ovs-ofctl: Add option to set allowed OpenFlow versions

--allowed-ofp-versions allows configuration of the versions
that may be used when establishing an OpenFlow connection.

The default is 'OpenFlow10' which is consistent with
the behaviour prior to this patch.

The useful values at this time are:
'OpenFlow10', 'OpenFlow12' and 'OpenFlow10,OpenFlow12'.

Signed-off-by: Simon Horman <horms@verge.net.au>
ovs-controller: Allow setting of allowed OpenFlow versions

--allowed-ofp-versions allows configuration of the versions
that may be used when establishing an OpenFlow connection.

The default is 'OpenFlow10' which is consistent with
the behaviour prior to this patch.

The useful values at this time are:
'OpenFlow10', 'OpenFlow12' and 'OpenFlow10,OpenFlow12'.

Signed-off-by: Simon Horman <horms@verge.net.au>
ovs-ofctl: By default, do not set flow format for OpenFlow 1.1+

Only set the default format for ovs-ofctl monitor if
OpenFlow 1.0 is the prevailing version. IMHO that is
the only case where it makes sense.

Signed-off-by: Simon Horman <horms@verge.net.au>
ofp-util: Open Flow 1.1 and 1.2 flow format capabilities

Open Flow and 1.1 and 1.2 support some of the same
flow format capabilities as NXM.

Signed-off-by: Simon Horman <horms@verge.net.au>
ofp-util: Flow Dump Protocol for OpenFlow 12

Allow only OpenFlow 12 as a flow dump protocol for OpenFlow12.
Allow OpenFlow10 and NXM as flow dump protocols for other OpenFlow versions.
This only changes the behaviour prior to this patch in the case of OpenFlow12
which seemed broken as an attempt would be made to set NXM as the
flow dump format using an OpenFlow 1.0 message even though an OpenFlow 1.2
connection had been negotiated..

Signed-off-by: Simon Horman <horms@verge.net.au>
test: add ofproto OpenFlow1.2 tests

These were useful in isolating a number of bugs.

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

---

The "ofproto - flow table configuration (OpenFlow 1.2)]" test
will need to be updated for the MPLS changes that are outstanding
as they change the following:

wild=0xfffffffff -> wild=0x1fffffffff
match=0xfffffffff -> match=0x1fffffffff
write_setfields=0x0000000fffffffff -> write_setfields=0x0000001fffffffff
apply_setfields=0x0000000fffffffff -> write_setfields=0x0000001fffffffff
ofp-util: Optimize ofputil_version_bitmap_scanr

Make use of __builtin_clz if available which should optimize
ofputil_version_bitmap_scanr() by replacing a loop with
a single CLZ instruction when available.

I'm unsure if this approach is worth it or not.
But a similar approach could be taken to use ffs()
in bitmap_scan().

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