ovs-ofctl: Accept port keywords, OF1.1 port numbers, reject port number 0.

OpenFlow 1.0 has special reserved ports in the range 0xfff8 to 0xffff.
OpenFlow 1.1 and later has the same ports in the range 0xfffffff8 to
0xffffffff and allows the OF1.0 range to be used for ordinary ("physical")
switch ports.  This means that, naively, the meaning of a port number in
the range 0xfff8 to 0xffff given on the ovs-ofctl command line depends on
the protocol in use.  This commit implements something a little smarter:

    - Accept keyword names (e.g. LOCAL) for special reserved ports
      everywhere that such a port can plausibly be used (previously they
      were only accepted in some places).

    - Translate 0xfff8...0xffff to 0xfffffff8...0xffffffff for now, since
      OF1.1+ isn't in widespread use and those particular ports aren't
      likely to be in use in OF1.1+ anyway.

    - Log warnings about those ports when they are specified by number, to
      allow users to fix their invocations.

Also:

    - Accept the OF1.1+ port numbers for these ports, without warning, for
      compatibility with the upcoming OF1.1+ support.

    - Stop accepting port number 0, which has never been a valid port
      number in OpenFlow 1.0 and later.  (This required fixing some tests
      that inadvertently used this port number).

[horms@verge.net.au: removed trailing whitespace]
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Simon Horman <horms@verge.net.au>
ofp-msgs: Open Flow 1.1 and 1.2 Port Status Messages

This allows for encoding and decoding Open Flow 1.1 and 1.2 Port Stats
Request and Reply message

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

---

v14
* Manual rebase

v13
* Merge the following patches
  - ofp-msgs: Split OFPRAW_OFPST_PORT_{REQUEST,REPLY}
  - ovs-ofctl: Teach dump-ports about Open Flow 1.1 & 1.2
  - ofp-util: Allow encoding of Open Flow 1.1 & 1.2 Port Statistics Reply Messages
  - ofp-print: Allow printing of Open Flow 1.1 & 1.2 Port Reply Messages
  - ofp-util: Allow decoding of Open Flow 1.1 & 1.2 Port Status Request Messages
  - ofp-print: Allow printing of Open Flow 1.1 & 1.2 Port Status Request Messages
* Move encoding and decoding into a helper functions

v12
* No change

v11
* No change

v10
* No change

v9
* Update description - this only prepares for both encoding and decoding
* Add ofp-print test
* Make use of enum ofp_version
* Correct printing of port number for Open Flow 1.0
* Replace UINT64_MAX with htonll(UINT64_MAX) in ofp_print_port_stat()
  to correct byte-order problem detected by sparse

v8
* Manual rebase
* Make use of enum ofp_version
* Add ofp-print test

v7
* Omitted

v6
* No change

v5
* No change

v4
* Initial post
ofp-msgs: Open Flow 1.1 and 1.2 Queue Status Messages

This allows for encoding and decoding Open Flow 1.1 and 1.2 Queue Stats
Request and Reply messages.

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

---

v14
* No change

v13
* Merged the following patches
  - ofp-msgs: Split OFPRAW_OFPST_QUEUE_{REQUEST,REPLY}
  - ofp-print: Enable display of Open Flow 1.1 & 1.2 Queue Status Reply Messages
  - ofp-util: Allow encoding of Open Flow 1.1 & 1.2 Queue Stats Reply Messages
  - ofp-util: Allow decoding of Open Flow 1.1 & 1.2 Queue Stats Request Messages
  - ovs-print: Enable display of Open Flow 1.1 & 1.2 Queue Stats Request
* Move ofp_print_ofpst_queue_reply() decode code into a helper function
* Move put_queue_stats() encode code into helper functions
* Move ofp_print_ofpst_queue_request parse code to helper functions
* Merged revision history of above patches follows

v12
* No change

v11
* No change

v10
* Manual rebase
* Make use of enum ofp_version
* Change subject name from "ovs-print: Enable display of Open Flow 1.1 &
  1.2 Queue Stats Response" to "ovs-print: Enable display of Open Flow 1.1
  & 1.2 Queue Stats Request"
* Add ofp-print test
* Use ofputil_port_from_ofp11 to decode port number

v9
* Omitted

v8
* Omitted

v7
* Omitted

v6
* No change

v5
* Initial Post
ovs-ofpctl: Enable queue-stats for Open Flow 1.1 & 1.2

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

---

v14
* Manual rebase

v13
* Move encoder into helper functions

v12
* No change

v11
* No change

v10
* Manual rebase
* Make use of enum ofp_version

v9
* Omitted

v8
* Omitted

v7
* Omitted

v6
* The queue_id variable in do_dump_aggregate() should be uint32_t not
  uint16_t.

v5
* Initial Post
ofp-msgs: Update for OpenFlow 1.1 & 1.2 Port Desc Stats

* Split OFPRAW_OFPST_PORT_DESC_REPLY into OpenFlow 1.0
  and OpenFlow 1.1+ versions.
* Allow OFPRAW_OFPST_PORT_DESC_REQUEST to be used for
  OpenFlow 1.0+ instead of only OpenFlow 1.0.

This appears to be necessary and sufficient to allow encoding of Port Desc
Stats reply messages and decoding of Port Desc Stats request messages. Or
in other words both the client and server side of ovs-ofctl dump-ports-desc

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

---

v14
* No change

v13
* No change

v12
* No change

v11
* Initial post
ofproto: Use OFPERR_OFPFMFC_TABLE_FULL for OpenFlow 1.1+

Use OFPERR_OFPFMFC_ALL_TABLES_FULL in place of
OFPERR_OFPFMFC_TABLE_FULL for OpenFlow 1.1+.

OFPERR_OFPFMFC_ALL_TABLES_FULL only exists in OpenFlow 1.0.
OFPERR_OFPFMFC_TABLE_FULL was added in OpenFlow 1.1.

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

---

v14
* No change

v13
* No change

v12
* No change

v11
* Initial post
ofp-util: Correct setting of Flow Mod cookie on encode

When the command of a Flow Mod messages is ADD the cookie should be set as
fm->cookie, internally this is the new cookie value to be set. Otherwise it
should be set as fm->cookie, internally this is the cookie value to match.

Also remove 'XXX' marker from the matching code in the decoder.
I am now comfortable with the implementation.

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

---

v14
* No change

v13
* No change

v12
* No change

v11
* Initial post
ofproto: Do not add flow on flow mod if new_cookie is UINT64_MAX

Internally a new_cookie value UINT64_MAX is used for
an OpenFlow 1.2 flow mod whose command is not Add.
Open Flow 1.2 does not permit adding flows for such commands.
Also, UINT64_MAX is a prohibited cookie value, and the
existing code created a flow with that value as for the cookie.

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

---

v14
* No change

v13
* Fix logic error in modify_flows_add.
  - Zero should be returned if fm->cookie_mask is non-zero.
* Fix endienness issues in modify_flows_add()

v12
* No change

v11
* Initial post
ofp-print: Do not display flow mod cookie if it is UINT64_MAX

Internally UINT64_MAX is used to denote that the cookie
should not be changed, so it seems appropriate
to omit this value when pretty printing flow mods.

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

---

v14
* No change

v13
* No change

v12
* No change

v11
* Initial post
Use enum ofperr in ofputil_decode_flow_removed()

The return type of both ofputil_decode_flow_removed() and
nx_pull_match() so it makes sense for error be of that type too.

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

---

v14
* No change

v13
* No change

v12
* No change

v11
* Initial post
ofp-util: Allow OF1.2 to be used as a dump protocol

Allow OF1.2 to be used as a dump protocol and limit
the underling OpenFlow version for which a dump
protocol may be used.

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

---

v14
* No change

v13
* No change

v12
* No change

v11
* Initial post
ofp-util: Set Packet In Format: Use prevailing OpenFlow version

Signed-off-by: Simon Horman <horms@verge.net.au>
vconn: Allow passing a maximum Open Flow version

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

This enables the use of the OF12 format, the prerequisites of which were
added by "Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12" and patches to fill out
other functions that use OFPUTIL_P_OF12 directly.

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

---

v12
* No change

v11
* No change

v10
* No change

v9
* No change

v8
* Initial post
connmgr: Use version of underlying rconn

Signed-off-by: Simon Horman <horms@verge.net.au>
connmgr: connmgr_destroy(): Paramatise Open Flow version

Signed-off-by: Simon Horman <horms@verge.net.au>
ofproto: ofproto_run(): Paramatise Open Flow version

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

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

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

Allow minimum and maximum versions to be passed rather
than relying on hard-coded defaults.

Signed-off-by: Simon Horman <horms@verge.net.au>
ofp-util: Add ofputil_protocols_{from,to}_string()

This is preparation for adding minimum and maximum OpenFlow versions as
command-line options for vswitchd and various utilities.

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