datapath: Exit immediately on invalid arg

Return codes are used to indicate that an invalid parameter was
encountered. However, these return codes are not checked in the
main function. Mitigate this issue by exiting immediately upon
encountering an issue.

Change-Id: I40151679ccee056ac078fcfbaaf6e29ef914bb02
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Refactor ovdk_args code

Refactor the file some amount to better document the workings of
functions, and to group related functions together. Remove some
unnecessary includes.

Change-Id: I106e7efa0bcef557b707653c6c21f2d2c3e46c1a
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Improve error msg for invalid opts

The value of an option is printed when said option is invalid.
However, there are two issues with this:

* 'getopt' (and 'getopt_long') do not return the option itself
  when the option is invalid, but it was assumed that they did.
* It doesn't handle error conditions for long options in any way.

Fix both of these issues.

Change-Id: I1bc8e3cdaeac198d32329324b1a99f0f1fdf32ca
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Fix typos in 'ovdk_vport_phy'

Change-Id: I742a59e4535aa8b932fd06b35dc5f1e76b0df02b
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Don't initialise non-portmask ports

All phy ports on the system are initialised and bound on startup,
despite the presence of a user-supplied portmask. Check if a port
is supposed to be used before configuring it.

Change-Id: I17cbf8498d51218a32815b7b0d22c99bcc7230ba
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Remove unused variable

Change-Id: I0f5fab751b0639594a8de0c0e7b7971db52399ef
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Add 'usage' function using DPDK API

The usage function is only shown when the EAL args parse successfully.
Use the DPDK API to show this usage message always. This requires
making the function "public".

Change-Id: Id69ed152e065329f8060fcad0b5b71a3da855540
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavanagh@intel.com>
datapath: Remove 'secs' from 'usage' message

The 'stats_int' parameter defines the interval to be used between
stat displays. Previously this could be measure in seconds. However,
with the introduction of multi-core support this is no longer the
case. This makes the usage message misleading, therefore remove
'secs'.

Change-Id: I28b387c2aa3be466ce800481e4d2da6b0cbbc22f
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Mark B. Kavanagh <mark.b.kavnagh@intel.com>
ovs-dpdk: add command-line log level param

Enable configuration of ovs-dpdk logging level via a command-line
parameter.

Logging level  may be set to a value between 1 (least loggging) to 8
(most verbose logging). There is a 1:1 correlation between these log
levels and Intel(R) DPDK log levels;

    * 1 = Print EMERGENCY messages
    * 2 = Print ALERT messages
    * 3 = Print CRITICAL messages
    * 4 = Print ERROR messages (default)
    * 5 = Print WARNING messages
    * 6 = Print NOTICE messages
    * 7 = Print INFORMATION messages
    * 8 = Print DEBUG messages

**  Note ** Higher log levels also report all lower-level messages.

Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>

Reviewed-By: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-By: Stephen Finucane <stephen.finucane@intel.com>
Change-Id: I8b830b2ef104456d8cf648ff8a18c62df419518e
dpif-dpdk: Added debug for port and flow adds/deletes

* Added debug level logs for normal conditions
* Added error level logs for error conditions

Change-Id: I95dab09108c948231df9ceeedcd9590141e5338e
Signed-off-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-By: Stephen Finucane <stephen.finucane@intel.com>
datapath: Added debug for port and flow adds/deletes

* Added debug level logs for normal conditions
* Added error level logs for error conditions

Change-Id: I09db4b9042ba989bd8e877322706d1be268a9438
Signed-off-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-By: Stephen Finucane <stephen.finucane@intel.com>
ovdk_jobs: Add jobs system tests again

This code was added in
commit 5ccfcee8d8e74 (datapath/dpdk: Introducing unit tests for Job System)
commit 5b91b202b0283 (datapath/dpdk: Introducing Job System)
but removed when integrating the packet framework.

This patch adds this code in again. A future patch will
integrate it into the datapath.

Change-Id: Ica47888a0b8a350cf946fa727eb5c3c2004c26dd
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Signed-off-by: Mark D. Gray <mark.d.gray@intel.com>
ovdk_jobs: Add ovdk prefix

In order to maintain a clean namespace, add an
ovdk_ prefix to all relevant jobs code.

Change-Id: I3a80a889926548efb6a8fc31d1fdb250e8c761f0
Signed-off-by: Mark D. Gray <mark.d.gray@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
ovdk_args: Add jumbo frames again

This adds the following change which was removed when
adding support for the packet framework:

commit 1e631b8251 (datapath/dpdk: Support Jumbo frame)

Change-Id: I658e79f29eab7b54bc249013b0343ec388b6e8ac
Signed-off-by: Mark D. Gray <mark.d.gray@intel.com>
ovdk-flow: Fix byte order of ICMP type and code

In ovdk_flow_key, ICMP type and code are stored in 16-bit network
byte order, using 16-bit transport port fields.

The counterpart in Linux kernel module datapath is found in
datapath/flow.c:ovs_flow_extract:

936        struct icmphdr *icmp = icmp_hdr(skb);
937        /* The ICMP type and code fields use the 16-bit
938         * transport port fields, so we need to store
939         * them in 16-bit network byte order. */
940        key->ipv4.tp.src = htons(icmp->type);
941        key->ipv4.tp.dst = htons(icmp->code);

Signed-off-by: Takayuki Usui <takayuki@midokura.com>
ovdk_main: Integrate jobs system again

This patch integrates the job system from the following
commit to the packet framework enabled pipeline.

abbe5a49 (ovdk_jobs: Add jobs system again)

Each ovs-dpdk lcore processes packets. At initialization time,
ovdk_datapath_init() and ovdk_pipeline_init() is called on each
lcore to set up the resources required.

The packet processing job is then added to each lcore and the
stats job is added to one lcore.

All jobs are then executed on all available lcores, including
the master lcore.

Change-Id: Ifb9a8a7c37abf58ed02a3187cebf62f9d8b56e44
Signed-off-by: Mark D. Gray <mark.d.gray@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Fix coding standards

Change-Id: Icca0a2a34c5fe96091baa44950fc148a08700cfc
Signed-off-by: Mark D. Gray <mark.d.gray@intel.com>
Reviewed-by: Ciara Loftus <ciara.loftus@intel.com>
Reviewed-by: Meghan Halton <meghan.halton@intel.com>
dpif-dpdk-flow-table: Update tmp file name

Name is not consistent with the vport table.

Signed-off-by: Mark D. Gray <mark.d.gray@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Send action upcall packet out of exception port

Signed-off-by: Jipan Yang <jipan.yang@gmail.com>
dpif: resolve bug (repeated mbuf enqueue)

'dpdk_link.c' contains numerous macros and functions that invoke
Intel(R) DPDK 'rte_ring_enqueue_*' functions. Within 'dpdk_link.c',
a call to these functions is deemed successful by a return value of
0. However, the 'rte_ring_dequeue' functions can return one of two
values upon success: 0, or -EDQUOTA (signifying that packets were
successfully enqueued on the ring, but that the 'high watermark'
value for that ring has been exceeded).

The impact of this bug is that packets may be repeatedly enqueued
onto the target rings until a value of 0 is returned, even though
they may have already successfully been enqueued (albeit with a
negative return value).

Fix this issue by modifying the macros and functions to check for
the correct return value.

Change-Id: I4936694f84e7d9bb43e26b984ff4096d5dbc2dd4
Signed-off-By: Kevin Traynor <kevin.traynor@intel.com>
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Reviewed-By: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-By: Mark Gray <mark.d.gray@intel.com>
Reviewed-By: Kevin Traynor <kevin.traynor@intel.com>