datapath/dpdk: MEMNIC: Introduce new vport type MEMNIC

New vport type MEMNIC.

MEMNIC is memory copy based virtual network interface, to use for ether
network communication between host and guest. MEMNIC uses IVSHMEM
(Inter VM Shared Memory in QEMU) mechanism. But the IVSHMEM region
completely separate from DPDK vSwitch hugepage, instead of DPDK
vSwitch's existing IVSHMEM interface.

We need a virtual network interface which is not affected from guest's
behavior.

MEMNIC is made simple as possible, to keep switching performance high
on DPDK application in guest.
Giving up zero-copy which causes security issue, but use simplified ring
memory structure accessed between host and guest with memory copy.
With MEMNIC, guests can use their own hugepages in DPDK, which can be larger
than 1GB, they can make dedicated objects in hugepages, which never affects
host's DPDK vSwitch hugepage.

Boot with -m <N> option, ovs_dpdk will have MEMNIC interface, N is the number
of MEMNICs you want to create.
Passing qemu "-device ivshmem,size=16,shm=/ovs_dpdk_48" as argument is needed
to attach MEMNIC device to guest.
Currently map vport ovs_dpdk_48 to ovs_dpdk_63 for MEMNIC, so you can provide
16 MEMNICs for guest, and the size is fixed to 16MB.
DPDK vSwitch will create POSIX shared memory under /dev/shm, like
/dev/shm/ovs_dpdk_48.

To use this MEMNIC interface from guest, you will need a driver to access
IVSHMEM as a network interface.
You can get PMD for DPDK and kernel driver from dpdk.org.

Internal ChangeLog
v2:
    memnic.h
      License Dual BSD/GPL
      use DPDK atomic function
    vport.c
      update messages
      use atomic for stats of MEMNIC
      make variable name readable
    vport-memnic.[ch]
      move init_memnic
      introduce memnic_rx and memnic_tx
    args.c
      add help message into usage
v3:
    memnic.h:
      remove code for kernel driver
    init.c
      increase the number of mbufs
    vport-memnic.c
      use DPDK function, rte_mb() instead of barrier()
      use rte_atomic32_cmpset() directly in memnic_tx()
      fix race condition between guest and host
v4:
    rebase to the latest development branch
    modify to use vport-types.h

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
Docs: MEMNIC document

Add MEMNIC document into docs directory.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
Tests: MEMNIC simple TX/RX test

Introduce MEMNIC unit test.
Implement simple TX/RX tests.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
Tests: Add MEMNIC test cases

Add MEMNIC simple TX/RX test cases into testsuite.

The testsuites shows the result as following.

MEMNIC unit tests - dpdk datapath

1363: MEMNIC simple TX                                ok
1364: MEMNIC simple RX                                ok

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
MEMNIC: integrate MEMNIC vports with arbitrary port naming

vport-memnic: change name of shm objects

Integrate MEMNIC vprots with arbitrary port naming.
All MEMNIC shared memory (shm) objects will be created at init time. Once the
MEMNIC ports are added the shm objects are renamed using the spcified port
name in ovs-ctl.
At init time shm objects will be called "ovs_dpdk_not_used_$vportid" so the
user can easily tell the shm objects aren't being used.
Remove any old shm object with the same name before renaming.
Fix wrong ivshm size when standard QEMU ivshm feature is used (not DPDK
ivshm - like MEMNIC)
Add patch to allow to set a MAC address to a MEMNIC virtual interface.
Add support into Makefile to apply the patch with config target.

Change-Id: Ia8b7f8613d9a6b084b577bd40a4abf24e67a0205
Signed-off-by: Nicolas Pernas Maradei <nicolasx.pernas.maradei@intel.com>
Reviewed-by: Mark D. Gray <mark.d.gray@intel.com>
Reviewed-by: Eimear Morrissey <eimear.morrissey@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
docs: Add sample configuration section for MEMNIC

Add an overview on configuring a MEMNIC setup
Change-Id: I074ef18326e93fffe71363180b395e4b1ea3adfa
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
Reviewed-by: Nicolas Pernsas <nicolasx.pernas.maradei@intel.com>
vport: perf. optimizations after adding MEMNIC vports

Make the lcore_map struct aligned to cache line size.
Add a local variable for each flush function with the same value as
global variables num_client, num_vhost, num_port in order to minimize
possible contention delays between threads.

Change-Id: Ie2bd67b598c01d993e628dbfaff275f697db0336
Signed-off-by: Nicolas Pernas Maradei <nicolasx.pernas.maradei@intel.com>
Reviewed-by: Mark D. Gray <mark.d.gray@intel.com>
Reviewed-by: Kevin Traynor <kevin.traynor@intel.com>
NEWS.md: Add MEMNIC

Add MEMNIC port type to NEWS.md

Change-Id: I470f67d0ee0ee42652386bdb7d9b7700a179ccbe
Signed-off-by: Kevin Traynor <kevin.traynor@intel.com>
Signed-off-by: Nicolas Pernas Maradei <nicolasx.pernas.maradei@intel.com>
Reviewed-by: Mark D. Gray <mark.d.gray@intel.com>