[ovs-dev] [PATCH v2] doc: v2: fix bad link to dpdk advance installation guide

2016-10-20 Thread Mauricio Vasquez B
Previous fix was also wrong.

Fixes: 167703d ("doc: Convert INSTALL.DPDK to rST")

Signed-off-by: Mauricio Vasquez B <mauricio.vasq...@polito.it>
---
 INSTALL.DPDK.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/INSTALL.DPDK.rst b/INSTALL.DPDK.rst
index 5780909..4ca9b27 100644
--- a/INSTALL.DPDK.rst
+++ b/INSTALL.DPDK.rst
@@ -55,7 +55,7 @@ In addition to the requirements described in the 
`installation guide
 
 Detailed system requirements can be found at `DPDK requirements`_, while more
 detailed install information can be found in the `advanced installation guide
-`__.
+`__.
 
 .. _DPDK supported NIC: http://dpdk.org/doc/nics
 .. _DPDK requirements: http://dpdk.org/doc/guides/linux_gsg/sys_reqs.html
@@ -257,7 +257,7 @@ them to cores 1,2, run:
 $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6
 
 For details on using ivshmem with DPDK, refer to `the advanced installation
-guide `__.
+guide `__.
 
 Refer to ovs-vswitchd.conf.db(5) for additional information on configuration
 options.
@@ -386,7 +386,7 @@ DPDK 'testpmd' application can be run in the Guest VM for 
high speed packet
 forwarding between vhostuser ports. DPDK and testpmd application has to be
 compiled on the guest VM. Below are the steps for setting up the testpmd
 application in the VM. More information on the vhostuser ports can be found in
-the `advanced install guide `__.
+the `advanced install guide `__.
 
 .. note::
   Support for DPDK in the guest requires QEMU >= 2.2.0.
@@ -648,12 +648,12 @@ When you finish testing, bind the vNICs back to kernel:
 
 .. note::
   More information on the dpdkvhostuser ports can be found in the `advanced
-  installation guide `__.
+  installation guide `__.
 
 PHY-VM-PHY (IVSHMEM loopback)
 ~
 
-Refer to the `advanced installation guide `__.
+Refer to the `advanced installation guide `__.
 
 Limitations
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] doc: fix duplicated colons in rst documents

2016-10-20 Thread Mauricio Vasquez B
Signed-off-by: Mauricio Vasquez B <mauricio.vasq...@polito.it>
---
 INSTALL.DPDK.rst  | 148 +-
 INSTALL.Debian.rst|  20 +--
 INSTALL.Docker.rst|  76 +++---
 INSTALL.KVM.rst   |  24 ++--
 INSTALL.Windows.rst   | 136 ++
 INSTALL.XenServer.rst |  32 ---
 INSTALL.userspace.rst |  12 +++-
 7 files changed, 336 insertions(+), 112 deletions(-)

diff --git a/INSTALL.DPDK.rst b/INSTALL.DPDK.rst
index c4b9167..5780909 100644
--- a/INSTALL.DPDK.rst
+++ b/INSTALL.DPDK.rst
@@ -66,7 +66,9 @@ Installing
 DPDK
 
 
-1. Download the `DPDK sources`_, extract the file and set ``DPDK_DIR``:::
+1. Download the `DPDK sources`_, extract the file and set ``DPDK_DIR``:
+
+::
 
$ cd /usr/src/
$ wget http://dpdk.org/browse/dpdk/snapshot/dpdk-16.07.zip
@@ -76,13 +78,17 @@ DPDK
 
 2. Configure and install DPDK
 
-   Build and install the DPDK library:::
+   Build and install the DPDK library:
+
+::
 
$ export DPDK_TARGET=x86_64-native-linuxapp-gcc
$ export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
$ make install T=$DPDK_TARGET DESTDIR=install
 
-   If IVSHMEM support is required, use a different target:::
+   If IVSHMEM support is required, use a different target:
+
+::
 
$ export DPDK_TARGET=x86_64-ivshmem-linuxapp-gcc
 
@@ -106,7 +112,9 @@ has to be configured with DPDK support (``--with-dpdk``).
 2. Bootstrap, if required, as described in the `installation guide
`__.
 
-3. Configure the package using the ``--with-dpdk`` flag:::
+3. Configure the package using the ``--with-dpdk`` flag:
+
+::
 
$ ./configure --with-dpdk=$DPDK_BUILD
 
@@ -132,19 +140,27 @@ Setup Hugepages
 Allocate a number of 2M Huge pages:
 
 -  For persistent allocation of huge pages, write to hugepages.conf file
-   in `/etc/sysctl.d`:::
+   in `/etc/sysctl.d`:
+
+::
 
$ echo 'vm.nr_hugepages=2048' > /etc/sysctl.d/hugepages.conf
 
--  For run-time allocation of huge pages, use the ``sysctl`` utility:::
+-  For run-time allocation of huge pages, use the ``sysctl`` utility:
+
+::
 
$ sysctl -w vm.nr_hugepages=N  # where N = No. of 2M huge pages
 
-To verify hugepage configuration:::
+To verify hugepage configuration:
+
+::
 
 $ grep HugePages_ /proc/meminfo
 
-Mount the hugepages, if not already mounted by default:::
+Mount the hugepages, if not already mounted by default:
+
+::
 
 $ mount -t hugetlbfs none /dev/hugepages``
 
@@ -157,13 +173,17 @@ VFIO is prefered to the UIO driver when using recent 
versions of DPDK. VFIO
 support required support from both the kernel and BIOS. For the former, kernel
 version > 3.6 must be used. For the latter, you must enable VT-d in the BIOS
 and ensure this is configured via grub. To ensure VT-d is enabled via the BIOS,
-run:::
+run:
+
+::
 
 $ dmesg | grep -e DMAR -e IOMMU
 
 If VT-d is not enabled in the BIOS, enable it now.
 
-To ensure VT-d is enabled in the kernel, run:::
+To ensure VT-d is enabled in the kernel, run:
+
+::
 
 $ cat /proc/cmdline | grep iommu=pt
 $ cat /proc/cmdline | grep intel_iommu=on
@@ -171,7 +191,9 @@ To ensure VT-d is enabled in the kernel, run:::
 If VT-d is not enabled in the kernel, enable it now.
 
 Once VT-d is correctly configured, load the required modules and bind the NIC
-to the VFIO driver:::
+to the VFIO driver:
+
+::
 
 $ modprobe vfio-pci
 $ /usr/bin/chmod a+x /dev/vfio
@@ -187,7 +209,9 @@ Open vSwitch should be started as described in the 
`installation guide
 special configuration to enable DPDK functionality. DPDK configuration
 arguments can be passed to ovs-vswitchd via the ``other_config`` column of the
 ``Open_vSwitch`` table. At a minimum, the ``dpdk-init`` option must be set to
-``true``. For example:::
+``true``. For example:
+
+::
 
 $ export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
 $ ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
@@ -216,7 +240,9 @@ listed below. Defaults will be provided for all values not 
explicitly set.
 
 If allocating more than one GB hugepage (as for IVSHMEM), you can configure the
 amount of memory used from any given NUMA nodes. For example, to use 1GB from
-NUMA node 0, run:::
+NUMA node 0, run:
+
+::
 
 $ ovs-vsctl --no-wait set Open_vSwitch . \
 other_config:dpdk-socket-mem="1024,0"
@@ -224,7 +250,9 @@ NUMA node 0, run:::
 Similarly, if you wish to better scale the workloads across cores, then
 multiple pmd threads can be created and pinned to CPU cores by explicity
 specifying ``pmd-cpu-mask``. For example, to spawn two pmd threads and pin
-them to cores 1,2, run:::
+them to cores 1,2, run:
+
+::
 
 $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6
 
@@ -245,33 +273,43 @@ Creating bridges and ports
 ~~
 
 You can now use ovs-vsctl to set up bridges and other Open vSwitch features.
-Bri

[ovs-dev] [PATCH] doc: fix bad link to dpdk advance installation guide

2016-10-18 Thread Mauricio Vasquez B
The link was pointing to a wrong place after the file was converted to rst.

Fixes: 167703d664fc ("doc: Convert INSTALL.DPDK to rST")

Signed-off-by: Mauricio Vasquez B <mauricio.vasq...@polito.it>
---
 INSTALL.DPDK.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/INSTALL.DPDK.rst b/INSTALL.DPDK.rst
index f09abe2..c4b9167 100644
--- a/INSTALL.DPDK.rst
+++ b/INSTALL.DPDK.rst
@@ -55,7 +55,7 @@ In addition to the requirements described in the 
`installation guide
 
 Detailed system requirements can be found at `DPDK requirements`_, while more
 detailed install information can be found in the `advanced installation guide
-<../../INSTALL.DPDK-advanced.md>`__.
+`__.
 
 .. _DPDK supported NIC: http://dpdk.org/doc/nics
 .. _DPDK requirements: http://dpdk.org/doc/guides/linux_gsg/sys_reqs.html
@@ -229,7 +229,7 @@ them to cores 1,2, run:::
 $ ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=6
 
 For details on using ivshmem with DPDK, refer to `the advanced installation
-guide <../../INSTALL.DPDK-ADVANCED.md>`__.
+guide `__.
 
 Refer to ovs-vswitchd.conf.db(5) for additional information on configuration
 options.
@@ -338,7 +338,7 @@ DPDK 'testpmd' application can be run in the Guest VM for 
high speed packet
 forwarding between vhostuser ports. DPDK and testpmd application has to be
 compiled on the guest VM. Below are the steps for setting up the testpmd
 application in the VM. More information on the vhostuser ports can be found in
-the `advanced install guide <../../INSTALL.DPDK-ADVANCED.md>`__.
+the `advanced install guide `__.
 
 .. note::
   Support for DPDK in the guest requires QEMU >= 2.2.0.
@@ -574,12 +574,12 @@ When you finish testing, bind the vNICs back to kernel:::
 
 .. note::
   More information on the dpdkvhostuser ports can be found in the `advanced
-  installation guide <../../INSTALL.DPDK-ADVANCED.md>`__.
+  installation guide `__.
 
 PHY-VM-PHY (IVSHMEM loopback)
 ~
 
-Refer to the `advanced installation guide <../../INSTALL.DPDK-ADVANCED.md>`__.
+Refer to the `advanced installation guide `__.
 
 Limitations
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] ovn: make external_ids naming uniform

2016-08-11 Thread Mauricio Vasquez B
In some places it is called "external-ids" while in others "external_ids"
is used. This commit changes it to external_ids in all of them.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 ovn/controller/ovn-controller.8.xml | 12 ++--
 ovn/ovn-architecture.7.xml  |  8 
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/ovn/controller/ovn-controller.8.xml 
b/ovn/controller/ovn-controller.8.xml
index 3fda8e7..4681b3f 100644
--- a/ovn/controller/ovn-controller.8.xml
+++ b/ovn/controller/ovn-controller.8.xml
@@ -159,7 +159,7 @@
 Open vSwitch Database Usage
 
 
-  ovn-controller uses a number of external-ids
+  ovn-controller uses a number of external_ids
   keys in the Open vSwitch database to keep track of ports and interfaces.
   For proper operation, users should not change or clear these keys:
 
@@ -176,7 +176,7 @@
   
 
   
-external-ids:ovn-localnet-port in the Port
+external_ids:ovn-localnet-port in the Port
 table
   
   
@@ -193,13 +193,13 @@
 
   Each localnet logical port is implemented as a pair of
   patch ports, one in the integration bridge, one in a different
-  bridge, with the same external-ids:ovn-localnet-port
+  bridge, with the same external_ids:ovn-localnet-port
   value.
 
   
 
   
-external-ids:ovn-l2gateway-port in the Port
+external_ids:ovn-l2gateway-port in the Port
 table
   
   
@@ -216,13 +216,13 @@
 
   Each l2gateway logical port is implemented as a pair
   of patch ports, one in the integration bridge, one in a different
-  bridge, with the same external-ids:ovn-l2gateway-port
+  bridge, with the same external_ids:ovn-l2gateway-port
   value.
 
   
 
   
-external-ids:ovn-logical-patch-port in the
+external_ids:ovn-logical-patch-port in the
 Port table
   
 
diff --git a/ovn/ovn-architecture.7.xml b/ovn/ovn-architecture.7.xml
index 9c7166f..1a1bd39 100644
--- a/ovn/ovn-architecture.7.xml
+++ b/ovn/ovn-architecture.7.xml
@@ -447,7 +447,7 @@
   where the VM is powered on, the integration between the hypervisor and
   Open vSwitch (described in IntegrationGuide.md) adds the VIF
   to the OVN integration bridge and stores vif-id in
-  external-ids:iface-id to indicate that the
+  external_ids:iface-id to indicate that the
   interface is an instantiation of the new VIF.  (None of this code is new
   in OVN; this is pre-existing integration work that has already been done
   on hypervisors that support OVS.)
@@ -455,10 +455,10 @@
 
 
   On the hypervisor where the VM is powered on, ovn-controller
-  notices external-ids:iface-id in the new
+  notices external_ids:iface-id in the new
   Interface. In response, in the OVN Southbound DB, it updates the
   Binding table's chassis column for the
-  row that links the logical port from external-ids:
+  row that links the logical port from external_ids:
   iface-id to the hypervisor. Afterward, ovn-controller
   updates the local hypervisor's OpenFlow tables so that packets to and 
from
   the VIF are properly handled.
@@ -632,7 +632,7 @@
   parent_port column of Binding table, the
   ovn-controller in the hypervisor whose OVN integration 
bridge
   has that same value in vif-id in
-  external-ids:iface-id
+  external_ids:iface-id
   updates the local hypervisor's OpenFlow tables so that packets to and
   from the VIF with the particular VLAN tag are properly
   handled.  Afterward it updates the chassis column of
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/2] README: add missing reference to INSTALL.SELinux.md

2016-07-28 Thread Mauricio Vasquez B
Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 69c4912..13a132a 100644
--- a/README.md
+++ b/README.md
@@ -120,6 +120,7 @@ b...@openvswitch.org
 [INSTALL.KVM.md]:INSTALL.KVM.md
 [INSTALL.Libvirt.md]:INSTALL.Libvirt.md
 [INSTALL.RHEL.md]:INSTALL.RHEL.md
+[INSTALL.SELinux.md]:INSTALL.SELinux.md
 [INSTALL.SSL.md]:INSTALL.SSL.md
 [INSTALL.userspace.md]:INSTALL.userspace.md
 [INSTALL.XenServer.md]:INSTALL.XenServer.md
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 2/2] README: add referente to DPDK installation

2016-07-28 Thread Mauricio Vasquez B
there was not any reference to the DPDK installation in the main README file.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 README.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/README.md b/README.md
index 13a132a..cf53437 100644
--- a/README.md
+++ b/README.md
@@ -94,6 +94,8 @@ To use Open vSwitch...
 
 - ...without using a kernel module, read [INSTALL.userspace.md].
 
+- ...with DPDK, read [INSTALL.DPDK.md].
+
 - ...with SELinux, read [INSTALL.SELinux.md].
 
 For answers to common questions, read [FAQ.md].
@@ -116,6 +118,7 @@ b...@openvswitch.org
 [INSTALL.md]:INSTALL.md
 [INSTALL.Debian.md]:INSTALL.Debian.md
 [INSTALL.Docker.md]:INSTALL.Docker.md
+[INSTALL.DPDK.md]:INSTALL.DPDK.md
 [INSTALL.Fedora.md]:INSTALL.Fedora.md
 [INSTALL.KVM.md]:INSTALL.KVM.md
 [INSTALL.Libvirt.md]:INSTALL.Libvirt.md
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v7] netdev-dpdk: add hotplug support

2016-07-15 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds two appctl commands:
netdev-dpdk/port-attach and netdev-dpdk/port-detach

After the user attaches a new device, it has to be added to a bridge
using the add-port command, similarly, before detaching a device,
it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v7:
 - rebase to master
v6:
 - add explicit comment about supporting VFIO
 - rebase to master
v5:
 - use two appctl commands instead of a single one
 - rebase to master
v4:
 - fix typo in commit message
 - remove unnecessary whitespace change in INSTALL.DPDK.md
v3:
 - create dpdk_port_attach and dpdk_port_detach functions
 - modify mutex locking order
v2:
 - use rte_eth_dev_is_valid_port() to check if a port is valid
 INSTALL.DPDK-ADVANCED.md |  25 
 NEWS |   1 +
 lib/netdev-dpdk.c| 101 +++
 3 files changed, 120 insertions(+), 7 deletions(-)

diff --git a/INSTALL.DPDK-ADVANCED.md b/INSTALL.DPDK-ADVANCED.md
index 9ae536d..61b4e82 100644
--- a/INSTALL.DPDK-ADVANCED.md
+++ b/INSTALL.DPDK-ADVANCED.md
@@ -12,6 +12,7 @@ OVS DPDK ADVANCED INSTALL GUIDE
 7. [QOS](#qos)
 8. [Rate Limiting](#rl)
 9. [Vsperf](#vsperf)
+10. [Port Hotplug](#hotplug)
 
 ##  1. Overview
 
@@ -835,6 +836,29 @@ environment. More information can be found in below link.
 
 https://wiki.opnfv.org/display/vsperf/VSperf+Home
 
+##  10. Port Hotplug
+
+OvS supports port hotplugging, it allows to use ports that were not bound
+to DPDK when vswitchd was started.
+In order to attach a port, it has to be bound to DPDK using the
+dpdk_nic_bind.py script:
+
+`$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+Then it can be attached to OVS:
+
+`ovs-appctl netdev-dpdk/port-attach :01:00.0`
+
+At this point, the user can create a ovs port using the add-port command.
+
+It is also possible to detach a port from ovs, the user has to remove the
+port using the del-port command, then it can be detached using:
+
+`ovs-appctl netdev-dpdk/port-detach dpdk0`
+
+This feature is not supported with VFIO and could not work with some NICs,
+please refer to the [DPDK Port Hotplug Framework] in order to get more
+information.
 
 Bug Reporting:
 --
@@ -850,3 +874,4 @@ Please report problems to b...@openvswitch.org.
 [Guest VM using libvirt]: INSTALL.DPDK.md#ovstc
 [INSTALL DPDK]: INSTALL.DPDK.md#build
 [INSTALL OVS]: INSTALL.DPDK.md#build
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
diff --git a/NEWS b/NEWS
index 6496dc1..9064225 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,7 @@ Post-v2.5.0
  * PMD threads servicing vHost User ports can now come from the NUMA
node that device memory is located on if CONFIG_RTE_LIBRTE_VHOST_NUMA
is enabled in DPDK.
+ * Port Hotplug is now supported.
- Increase number of registers to 16.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 85b18fd..3fab52c 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -644,7 +644,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
OVS_REQUIRES(dpdk_mutex)
 int diag;
 int n_rxq, n_txq;
 
-if (dev->port_id < 0 || dev->port_id >= rte_eth_dev_count()) {
+if (!rte_eth_dev_is_valid_port(dev->port_id)) {
 return ENODEV;
 }
 
@@ -2172,6 +2172,83 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static void
+netdev_dpdk_port_attach(struct unixctl_conn *conn, int argc OVS_UNUSED,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+char response[128];
+uint8_t port_id;
+
+ovs_mutex_lock(_mutex);
+
+ret = rte_eth_dev_attach(argv[1], _id);
+if (ret < 0) {
+snprintf(response, sizeof(response),
+ "Error attaching device '%s'", argv[1]);
+ovs_mutex_unlock(_mutex);
+unixctl_command_reply_error(conn, response);
+return;
+}
+
+snprintf(response, sizeof(response),
+ "Device '%s' has been attached as 'dpdk%d'", argv[1], port_id);
+
+ovs_mutex_unlock(_mutex);
+unixctl_command_reply(conn, response);
+}
+
+static void
+netdev_dpdk_port_detach(struct unixctl_conn *conn, int argc OVS_UNUSED,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+char response[128];
+unsigned int parsed_port;
+uint8_t port_id;
+char devname[RTE_ETH_NAME_MAX_LEN];
+
+ovs_mutex_lock(_mutex);
+
+ret = dpdk_dev_parse_name(argv[1], "dpdk", _port);
+if (ret) {
+   

[ovs-dev] [PATCH] acinclude: fix issue when configuring with --with-dpdk

2016-06-01 Thread Mauricio Vasquez B
when an empty path is given to the --with-dpdk option
(--with-dpdk="" or --width-dpdk=$NON_SET_ENV_VARIABLE) the configure
script does not show any error and configures OvS without DPDK support,
this can create some confusion.

This patch modifies that behavior showing an explicity error in that case.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 acinclude.m4 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index f3de855..0a14856 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -161,10 +161,11 @@ dnl Configure DPDK source tree
 AC_DEFUN([OVS_CHECK_DPDK], [
   AC_ARG_WITH([dpdk],
   [AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
-  [Specify the DPDK build directory])])
+  [Specify the DPDK build directory])],
+  [have_dpdk=true])
 
   AC_MSG_CHECKING([whether dpdk datapath is enabled])
-  if test -z "$with_dpdk" || test "$with_dpdk" = no; then
+  if test "$have_dpdk" != true || test "$with_dpdk" = no; then
 AC_MSG_RESULT([no])
 DPDKLIB_FOUND=false
   else
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v6] netdev-dpdk: add hotplug support

2016-05-26 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds two appctl commands:
netdev-dpdk/port-attach and netdev-dpdk/port-detach

After the user attaches a new device, it has to be added to a bridge
using the add-port command, similarly, before detaching a device,
it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
Tested-by: ian.sto...@intel.com
---
v6:
 - add explicit comment about supporting VFIO
 - rebase to master
v5:
 - use two appctl commands instead of a single one
 - rebase to master
v4:
 - fix typo in commit message
 - remove unnecessary whitespace change in INSTALL.DPDK.md
v3:
 - create dpdk_port_attach and dpdk_port_detach functions
 - modify mutex locking order
v2:
 - use rte_eth_dev_is_valid_port() to check if a port is valid
 INSTALL.DPDK.md   |  25 ++
 NEWS  |   1 +
 lib/netdev-dpdk.c | 101 ++
 3 files changed, 120 insertions(+), 7 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 68735cc..948957b 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -286,6 +286,30 @@ Using the DPDK with ovs-vswitchd:
 
For more details regarding ingress-policer see the vswitch.xml.
 
+10. Port Hotplug
+
+   Ovs supports port hotplugging, it allows to use ports that were not bound
+   to DPDK when vswitchd was started.
+   In order to attach a port, it has to be bound to DPDK using the
+   dpdk_nic_bind.py script:
+
+   `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+   Then it can be attached to OVS:
+
+   `ovs-appctl netdev-dpdk/port-attach :01:00.0`
+
+   At this point, the user can create a ovs port using the add-port command.
+
+   It is also possible to detach a port from ovs, the user has to remove the
+   port using the del-port command, then it can be detached using:
+
+   `ovs-appctl netdev-dpdk/port-detach dpdk0`
+
+   This feature is not supported with VFIO and could not work with some NICs,
+   please refer to the [DPDK Port Hotplug Framework] in order to get more
+   information.
+
 Performance Tuning:
 ---
 
@@ -1018,3 +1042,4 @@ Please report problems to b...@openvswitch.org.
 [INSTALL.md]:INSTALL.md
 [DPDK Linux GSG]: 
http://www.dpdk.org/doc/guides/linux_gsg/build_dpdk.html#binding-and-unbinding-network-ports-to-from-the-igb-uioor-vfio-modules
 [DPDK Docs]: http://dpdk.org/doc
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
diff --git a/NEWS b/NEWS
index ba201cf..4018836 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,7 @@ Post-v2.5.0
arguments. Additional arguments can be passed via the dpdk-extra
entry.
  * Add ingress policing functionality.
+ * Port Hotplug is now supported.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 6cae930..f5a8678 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -649,7 +649,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
OVS_REQUIRES(dpdk_mutex)
 int diag;
 int n_rxq, n_txq;
 
-if (dev->port_id < 0 || dev->port_id >= rte_eth_dev_count()) {
+if (!rte_eth_dev_is_valid_port(dev->port_id)) {
 return ENODEV;
 }
 
@@ -2231,6 +2231,83 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static void
+netdev_dpdk_port_attach(struct unixctl_conn *conn, int argc OVS_UNUSED,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+char response[128];
+uint8_t port_id;
+
+ovs_mutex_lock(_mutex);
+
+ret = rte_eth_dev_attach(argv[1], _id);
+if (ret < 0) {
+snprintf(response, sizeof(response),
+ "Error attaching device '%s'", argv[1]);
+ovs_mutex_unlock(_mutex);
+unixctl_command_reply_error(conn, response);
+return;
+}
+
+snprintf(response, sizeof(response),
+ "Device '%s' has been attached as 'dpdk%d'", argv[1], port_id);
+
+ovs_mutex_unlock(_mutex);
+unixctl_command_reply(conn, response);
+}
+
+static void
+netdev_dpdk_port_detach(struct unixctl_conn *conn, int argc OVS_UNUSED,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+char response[128];
+unsigned int parsed_port;
+uint8_t port_id;
+char devname[RTE_ETH_NAME_MAX_LEN];
+
+ovs_mutex_lock(_mutex);
+
+ret = dpdk_dev_parse_name(argv[1], "dpdk", _port);
+if (ret) {
+snprintf(response, sizeof(response),
+ "'%s' is not a valid port", argv[1]);
+goto error;
+}
+
+por

[ovs-dev] [PATCH v5] netdev-dpdk: add hotplug support

2016-05-13 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds two appctl commands:
netdev-dpdk/port-attach and netdev-dpdk/port-detach

After the user attaches a new device, it has to be added to a bridge
using the add-port command, similarly, before detaching a device,
it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v5:
 - use two appctl commands instead of a single one
 - rebase to master
v4:
 - fix typo in commit message
 - remove unnecessary whitespace change in INSTALL.DPDK.md
v3:
 - create dpdk_port_attach and dpdk_port_detach functions
 - modify mutex locking order
v2:
 - use rte_eth_dev_is_valid_port() to check if a port is valid
 INSTALL.DPDK.md   |  24 +
 NEWS  |   1 +
 lib/netdev-dpdk.c | 101 ++
 3 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 93f92e4..8d5a0e0 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -267,6 +267,29 @@ Using the DPDK with ovs-vswitchd:
For more details regarding egress-policer parameters please refer to the
vswitch.xml.
 
+9. Port Hotplug
+
+   Ovs supports port hotplugging, it allows to use ports that were not bound
+   to DPDK when vswitchd was started.
+   In order to attach a port, it has to be bound to DPDK using the
+   dpdk_nic_bind.py script:
+
+   `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+   Then it can be attached to OVS:
+
+   `ovs-appctl netdev-dpdk/port-attach :01:00.0`
+
+   At this point, the user can create a ovs port using the add-port command.
+
+   It is also possible to detach a port from ovs, the user has to remove the
+   port using the del-port command, then it can be detached using:
+
+   `ovs-appctl netdev-dpdk/port-detach dpdk0`
+
+   This feature is not supported by all the NICs, please refer to the
+   [DPDK Port Hotplug Framework] in order to get more information.
+
 Performance Tuning:
 ---
 
@@ -999,3 +1022,4 @@ Please report problems to b...@openvswitch.org.
 [INSTALL.md]:INSTALL.md
 [DPDK Linux GSG]: 
http://www.dpdk.org/doc/guides/linux_gsg/build_dpdk.html#binding-and-unbinding-network-ports-to-from-the-igb-uioor-vfio-modules
 [DPDK Docs]: http://dpdk.org/doc
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
diff --git a/NEWS b/NEWS
index 4e81cad..d89d9a7 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ Post-v2.5.0
  * DB entries have been added for many of the DPDK EAL command line
arguments. Additional arguments can be passed via the dpdk-extra
entry.
+ * Port Hotplug is now supported.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index af86d19..6159a60 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -630,7 +630,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
OVS_REQUIRES(dpdk_mutex)
 int diag;
 int n_rxq, n_txq;
 
-if (dev->port_id < 0 || dev->port_id >= rte_eth_dev_count()) {
+if (!rte_eth_dev_is_valid_port(dev->port_id)) {
 return ENODEV;
 }
 
@@ -2118,6 +2118,83 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static void
+netdev_dpdk_port_attach(struct unixctl_conn *conn, int argc OVS_UNUSED,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+char response[128];
+uint8_t port_id;
+
+ovs_mutex_lock(_mutex);
+
+ret = rte_eth_dev_attach(argv[1], _id);
+if (ret < 0) {
+snprintf(response, sizeof(response),
+ "Error attaching device '%s'", argv[1]);
+ovs_mutex_unlock(_mutex);
+unixctl_command_reply_error(conn, response);
+return;
+}
+
+snprintf(response, sizeof(response),
+ "Device '%s' has been attached as 'dpdk%d'", argv[1], port_id);
+
+ovs_mutex_unlock(_mutex);
+unixctl_command_reply(conn, response);
+}
+
+static void
+netdev_dpdk_port_detach(struct unixctl_conn *conn, int argc OVS_UNUSED,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+char response[128];
+unsigned int parsed_port;
+uint8_t port_id;
+char devname[RTE_ETH_NAME_MAX_LEN];
+
+ovs_mutex_lock(_mutex);
+
+ret = dpdk_dev_parse_name(argv[1], "dpdk", _port);
+if (ret) {
+snprintf(response, sizeof(response),
+ "'%s' is not a valid port", argv[1]);
+goto error;
+}
+
+port_id = parsed_port;
+
+struct netdev *netdev = netdev_from_name(argv[1]);
+if (n

[ovs-dev] [PATCH v4] netdev-dpdk: add hotplug support

2016-05-10 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds an appctl command:
netdev-dpdk/port-clt

After the user attaches a new device, it has to be added to a bridge
using the add-port command, similarly, before detaching a device
it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v4:
 - fix typo in commit message
 - remove unnecessary whitespace change in INSTALL.DPDK.md
v3:
 - create dpdk_port_attach and dpdk_port_detach functions
 - modify mutex locking order 
v2:
 - use rte_eth_dev_is_valid_port() to check if a port is valid
 
 INSTALL.DPDK.md   |  24 +
 NEWS  |   1 +
 lib/netdev-dpdk.c | 102 ++
 3 files changed, 120 insertions(+), 7 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 9ec8bf6..026373d 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -227,6 +227,29 @@ Using the DPDK with ovs-vswitchd:
For more details regarding egress-policer parameters please refer to the
vswitch.xml.
 
+9. Port Hotplug
+
+   ovs supports port hotplugging, it allows to use ports that were not bound
+   to DPDK when vswitchd was started.
+   In order to attach a port, it has to be bound to DPDK using the
+   dpdk_nic_bind.py script:
+
+   `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+   Then it can be attached to OVS:
+
+   `ovs-appctl netdev-dpdk/port-ctl attach :01:00.0`
+
+   At this point, the user can create a ovs port using the add-port command.
+
+   It is also possible to detach a port from ovs, the user has to remove the
+   port using the del-port command, then it can be detached using:
+
+   `ovs-appctl netdev-dpdk/port-ctl detach dpdk0`
+
+   This feature is not supported by all the NICs, please refer to the
+   [DPDK Port Hotplug Framework] in order to get more information.
+
 Performance Tuning:
 ---
 
@@ -959,3 +982,4 @@ Please report problems to b...@openvswitch.org.
 [INSTALL.md]:INSTALL.md
 [DPDK Linux GSG]: 
http://www.dpdk.org/doc/guides/linux_gsg/build_dpdk.html#binding-and-unbinding-network-ports-to-from-the-igb-uioor-vfio-modules
 [DPDK Docs]: http://dpdk.org/doc
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
diff --git a/NEWS b/NEWS
index ea7f3a1..2ba8659 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Post-v2.5.0
assignment.
  * Type of log messages from PMD threads changed from INFO to DBG.
  * QoS functionality with sample egress-policer implementation.
+ * Port Hotplug is now supported.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e09b471..cd98a2b 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -599,7 +599,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
OVS_REQUIRES(dpdk_mutex)
 int diag;
 int n_rxq, n_txq;
 
-if (dev->port_id < 0 || dev->port_id >= rte_eth_dev_count()) {
+if (!rte_eth_dev_is_valid_port(dev->port_id)) {
 return ENODEV;
 }
 
@@ -1985,6 +1985,89 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static int
+dpdk_port_attach(const char * port, char * response, size_t size)
+OVS_REQUIRES(dpdk_mutex)
+{
+int ret;
+uint8_t port_id;
+
+ret = rte_eth_dev_attach(port, _id);
+if (ret < 0) {
+snprintf(response, size, "Error attaching device '%s'", port);
+return -1;
+}
+
+snprintf(response, size,
+ "Device '%s' has been attached as 'dpdk%d'", port, port_id);
+return 0;
+}
+
+static int
+dpdk_port_detach(const char * port, char * response, size_t size)
+OVS_REQUIRES(dpdk_mutex)
+{
+int ret;
+unsigned int parsed_port;
+uint8_t port_id;
+char devname[RTE_ETH_NAME_MAX_LEN];
+
+ret = dpdk_dev_parse_name(port, "dpdk", _port);
+if (ret) {
+snprintf(response, size, "'%s' is not a valid dpdk device", port);
+return -1;
+}
+
+port_id = parsed_port;
+
+struct netdev *netdev = netdev_from_name(port);
+if (netdev) {
+netdev_close(netdev);
+snprintf(response, size,
+ "Port '%s' is being used. Remove it before detaching", port);
+return -1;
+}
+
+rte_eth_dev_close(port_id);
+
+ret = rte_eth_dev_detach(port_id, devname);
+if (ret < 0) {
+snprintf(response, size, "Port '%s' can not be detached", port);
+return -1;
+}
+
+snprintf(response, size, "Port '%s' has been detached", port);
+return 0;
+}
+
+static void
+netdev_d

[ovs-dev] [PATCH v3] netdev-dpdk: add hotplug support

2016-04-13 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds an appctl command:
netdev-dpdk/port-clt

After the user attaches a new device, it has to be added to a bridge
using the to use the add-port command, similarly, before detaching a
device, it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 INSTALL.DPDK.md   |  26 +-
 NEWS  |   1 +
 lib/netdev-dpdk.c | 102 ++
 3 files changed, 121 insertions(+), 8 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 9ec8bf6..4095402 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -81,7 +81,7 @@ Using the DPDK with ovs-vswitchd:
 
 1. Setup system boot
Add the following options to the kernel bootline:
-   
+
`default_hugepagesz=1GB hugepagesz=1G hugepages=1`
 
 2. Setup DPDK devices:
@@ -227,6 +227,29 @@ Using the DPDK with ovs-vswitchd:
For more details regarding egress-policer parameters please refer to the
vswitch.xml.
 
+9. Port Hotplug
+
+   ovs supports port hotplugging, it allows to use ports that were not bound
+   to DPDK when vswitchd was started.
+   In order to attach a port, it has to be bound to DPDK using the
+   dpdk_nic_bind.py script:
+
+   `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+   Then it can be attached to OVS:
+
+   `ovs-appctl netdev-dpdk/port-ctl attach :01:00.0`
+
+   At this point, the user can create a ovs port using the add-port command.
+
+   It is also possible to detach a port from ovs, the user has to remove the
+   port using the del-port command, then it can be detached using:
+
+   `ovs-appctl netdev-dpdk/port-ctl detach dpdk0`
+
+   This feature is not supported by all the NICs, please refer to the
+   [DPDK Port Hotplug Framework] in order to get more information.
+
 Performance Tuning:
 ---
 
@@ -959,3 +982,4 @@ Please report problems to b...@openvswitch.org.
 [INSTALL.md]:INSTALL.md
 [DPDK Linux GSG]: 
http://www.dpdk.org/doc/guides/linux_gsg/build_dpdk.html#binding-and-unbinding-network-ports-to-from-the-igb-uioor-vfio-modules
 [DPDK Docs]: http://dpdk.org/doc
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
diff --git a/NEWS b/NEWS
index ea7f3a1..2ba8659 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Post-v2.5.0
assignment.
  * Type of log messages from PMD threads changed from INFO to DBG.
  * QoS functionality with sample egress-policer implementation.
+ * Port Hotplug is now supported.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e09b471..cd98a2b 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -599,7 +599,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
OVS_REQUIRES(dpdk_mutex)
 int diag;
 int n_rxq, n_txq;
 
-if (dev->port_id < 0 || dev->port_id >= rte_eth_dev_count()) {
+if (!rte_eth_dev_is_valid_port(dev->port_id)) {
 return ENODEV;
 }
 
@@ -1985,6 +1985,89 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static int
+dpdk_port_attach(const char * port, char * response, size_t size)
+OVS_REQUIRES(dpdk_mutex)
+{
+int ret;
+uint8_t port_id;
+
+ret = rte_eth_dev_attach(port, _id);
+if (ret < 0) {
+snprintf(response, size, "Error attaching device '%s'", port);
+return -1;
+}
+
+snprintf(response, size,
+ "Device '%s' has been attached as 'dpdk%d'", port, port_id);
+return 0;
+}
+
+static int
+dpdk_port_detach(const char * port, char * response, size_t size)
+OVS_REQUIRES(dpdk_mutex)
+{
+int ret;
+unsigned int parsed_port;
+uint8_t port_id;
+char devname[RTE_ETH_NAME_MAX_LEN];
+
+ret = dpdk_dev_parse_name(port, "dpdk", _port);
+if (ret) {
+snprintf(response, size, "'%s' is not a valid dpdk device", port);
+return -1;
+}
+
+port_id = parsed_port;
+
+struct netdev *netdev = netdev_from_name(port);
+if (netdev) {
+netdev_close(netdev);
+snprintf(response, size,
+ "Port '%s' is being used. Remove it before detaching", port);
+return -1;
+}
+
+rte_eth_dev_close(port_id);
+
+ret = rte_eth_dev_detach(port_id, devname);
+if (ret < 0) {
+snprintf(response, size, "Port '%s' can not be detached", port);
+return -1;
+}
+
+snprintf(response, size, "Port '%s' has been detached", port);
+return 0;
+}
+
+static void
+netdev_dpdk_port_ctl(str

[ovs-dev] [PATCH v2] netdev-dpdk: add hotplug support

2016-04-01 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds an appctl command:
netdev-dpdk/port-clt

After the user attaches a new device, it has to be added to a bridge
using the to use the add-port command, similarly, before detaching a
device, it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 INSTALL.DPDK.md   | 26 +++-
 NEWS  |  1 +
 lib/netdev-dpdk.c | 88 ++-
 3 files changed, 107 insertions(+), 8 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 9ec8bf6..4095402 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -81,7 +81,7 @@ Using the DPDK with ovs-vswitchd:
 
 1. Setup system boot
Add the following options to the kernel bootline:
-   
+
`default_hugepagesz=1GB hugepagesz=1G hugepages=1`
 
 2. Setup DPDK devices:
@@ -227,6 +227,29 @@ Using the DPDK with ovs-vswitchd:
For more details regarding egress-policer parameters please refer to the
vswitch.xml.
 
+9. Port Hotplug
+
+   ovs supports port hotplugging, it allows to use ports that were not bound
+   to DPDK when vswitchd was started.
+   In order to attach a port, it has to be bound to DPDK using the
+   dpdk_nic_bind.py script:
+
+   `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+   Then it can be attached to OVS:
+
+   `ovs-appctl netdev-dpdk/port-ctl attach :01:00.0`
+
+   At this point, the user can create a ovs port using the add-port command.
+
+   It is also possible to detach a port from ovs, the user has to remove the
+   port using the del-port command, then it can be detached using:
+
+   `ovs-appctl netdev-dpdk/port-ctl detach dpdk0`
+
+   This feature is not supported by all the NICs, please refer to the
+   [DPDK Port Hotplug Framework] in order to get more information.
+
 Performance Tuning:
 ---
 
@@ -959,3 +982,4 @@ Please report problems to b...@openvswitch.org.
 [INSTALL.md]:INSTALL.md
 [DPDK Linux GSG]: 
http://www.dpdk.org/doc/guides/linux_gsg/build_dpdk.html#binding-and-unbinding-network-ports-to-from-the-igb-uioor-vfio-modules
 [DPDK Docs]: http://dpdk.org/doc
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
diff --git a/NEWS b/NEWS
index ea7f3a1..2ba8659 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Post-v2.5.0
assignment.
  * Type of log messages from PMD threads changed from INFO to DBG.
  * QoS functionality with sample egress-policer implementation.
+ * Port Hotplug is now supported.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e09b471..4fcab36 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -599,7 +599,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
OVS_REQUIRES(dpdk_mutex)
 int diag;
 int n_rxq, n_txq;
 
-if (dev->port_id < 0 || dev->port_id >= rte_eth_dev_count()) {
+if (!rte_eth_dev_is_valid_port(dev->port_id)) {
 return ENODEV;
 }
 
@@ -1985,6 +1985,75 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static void
+netdev_dpdk_port_ctl(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+uint8_t port_id;
+unsigned int parsed_port;
+char devname[RTE_ETH_NAME_MAX_LEN];
+char response[512];
+
+ovs_mutex_lock(_mutex);
+
+if (strcmp(argv[1], "attach") == 0) {
+ret = rte_eth_dev_attach(argv[2], _id);
+if (ret < 0) {
+snprintf(response, sizeof(response),
+ "Error attaching device '%s'", argv[2]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+snprintf(response, sizeof(response),
+ "Device '%s' has been attached as 'dpdk%d'", argv[2], 
port_id);
+unixctl_command_reply(conn, response);
+
+} else if (strcmp(argv[1], "detach") == 0) {
+ret = dpdk_dev_parse_name(argv[2], "dpdk", _port);
+if (ret) {
+snprintf(response, sizeof(response),
+ "'%s' is not a valid dpdk device", argv[2]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+port_id = parsed_port;
+
+struct netdev *netdev = netdev_from_name(argv[2]);
+if (netdev) {
+netdev_close(netdev);
+snprintf(response, sizeof(response),
+ "Port '%s' is being used. Remove it before detaching",
+ 

[ovs-dev] [PATCH 3/3] NEWS: dpdk port hotplug is now supported

2016-03-28 Thread Mauricio Vasquez B
Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 NEWS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/NEWS b/NEWS
index ea7f3a1..2ba8659 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Post-v2.5.0
assignment.
  * Type of log messages from PMD threads changed from INFO to DBG.
  * QoS functionality with sample egress-policer implementation.
+ * Port Hotplug is now supported.
- ovs-benchmark: This utility has been removed due to lack of use and
  bitrot.
- ovs-appctl:
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/3] netdev-dpdk: add hotplug support

2016-03-28 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds an appctl command:
netdev-dpdk/port-clt

After the user attaches a new device, it has to be added to a bridge
using the to use the add-port command, similarly, before detaching a
device, it has to be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 lib/netdev-dpdk.c | 73 +++
 1 file changed, 73 insertions(+)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7c4cd07..05fa0df 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1982,6 +1982,75 @@ netdev_dpdk_set_admin_state(struct unixctl_conn *conn, 
int argc,
 unixctl_command_reply(conn, "OK");
 }
 
+static void
+netdev_dpdk_port_ctl(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+uint8_t port_id;
+unsigned int parsed_port;
+char devname[RTE_ETH_NAME_MAX_LEN];
+char response[512];
+
+ovs_mutex_lock(_mutex);
+
+if (strcmp(argv[1], "attach") == 0) {
+ret = rte_eth_dev_attach(argv[2], _id);
+if (ret < 0) {
+snprintf(response, sizeof(response),
+ "Error attaching device '%s'", argv[2]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+snprintf(response, sizeof(response),
+ "Device '%s' has been attached as 'dpdk%d'", argv[2], 
port_id);
+unixctl_command_reply(conn, response);
+
+} else if (strcmp(argv[1], "detach") == 0) {
+ret = dpdk_dev_parse_name(argv[2], "dpdk", _port);
+if (ret) {
+snprintf(response, sizeof(response),
+ "'%s' is not a valid dpdk device", argv[2]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+port_id = parsed_port;
+
+struct netdev * netdev = netdev_from_name(argv[2]);
+if (netdev) {
+netdev_close(netdev);
+snprintf(response, sizeof(response),
+ "Port '%s' is being used. Remove it before detaching",
+ argv[2]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+rte_eth_dev_close(port_id);
+
+ret = rte_eth_dev_detach(port_id, devname);
+if (ret < 0) {
+snprintf(response, sizeof(response),
+ "Port '%s' can not be detached", argv[2]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+snprintf(response, sizeof(response),
+ "Port '%s' has been detached", argv[2]);
+unixctl_command_reply(conn, response);
+} else {
+snprintf(response, sizeof(response),
+ "'%s' is not a valid argument", argv[1]);
+unixctl_command_reply_error(conn, response);
+}
+
+unlock:
+ovs_mutex_unlock(_mutex);
+}
+
 /*
  * Set virtqueue flags so that we do not receive interrupts.
  */
@@ -2262,6 +2331,10 @@ dpdk_common_init(void)
  "[netdev] up|down", 1, 2,
  netdev_dpdk_set_admin_state, NULL);
 
+unixctl_command_register("netdev-dpdk/port-ctl",
+ "attach/detach device", 2, 2,
+ netdev_dpdk_port_ctl, NULL);
+
 ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL);
 }
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 2/3] INSTALL.DPDK: add port hotplug documentation

2016-03-28 Thread Mauricio Vasquez B
Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 INSTALL.DPDK.md | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 9ec8bf6..4095402 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -81,7 +81,7 @@ Using the DPDK with ovs-vswitchd:
 
 1. Setup system boot
Add the following options to the kernel bootline:
-   
+
`default_hugepagesz=1GB hugepagesz=1G hugepages=1`
 
 2. Setup DPDK devices:
@@ -227,6 +227,29 @@ Using the DPDK with ovs-vswitchd:
For more details regarding egress-policer parameters please refer to the
vswitch.xml.
 
+9. Port Hotplug
+
+   ovs supports port hotplugging, it allows to use ports that were not bound
+   to DPDK when vswitchd was started.
+   In order to attach a port, it has to be bound to DPDK using the
+   dpdk_nic_bind.py script:
+
+   `$DPDK_DIR/tools/dpdk_nic_bind.py --bind=igb_uio :01:00.0`
+
+   Then it can be attached to OVS:
+
+   `ovs-appctl netdev-dpdk/port-ctl attach :01:00.0`
+
+   At this point, the user can create a ovs port using the add-port command.
+
+   It is also possible to detach a port from ovs, the user has to remove the
+   port using the del-port command, then it can be detached using:
+
+   `ovs-appctl netdev-dpdk/port-ctl detach dpdk0`
+
+   This feature is not supported by all the NICs, please refer to the
+   [DPDK Port Hotplug Framework] in order to get more information.
+
 Performance Tuning:
 ---
 
@@ -959,3 +982,4 @@ Please report problems to b...@openvswitch.org.
 [INSTALL.md]:INSTALL.md
 [DPDK Linux GSG]: 
http://www.dpdk.org/doc/guides/linux_gsg/build_dpdk.html#binding-and-unbinding-network-ports-to-from-the-igb-uioor-vfio-modules
 [DPDK Docs]: http://dpdk.org/doc
+[DPDK Port Hotplug Framework]: 
http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [RFC] lib/netdev-dpdk: add hotplug support

2016-03-19 Thread Mauricio Vasquez B
In order to use dpdk ports in ovs they have to be bound to a DPDK
compatible driver before ovs is started.

This patch adds the possibility to hotplug (or hot-unplug) a device
after ovs has been started. The implementation adds two appctl commands:
netdev-dpdk/attach and netdev-dpdk/detach.

After the user attaches a new device, it can use the add-port command
to use it in a switch, similarly, before detaching a device, it has to
be removed using the del-port command.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 lib/netdev-dpdk.c | 79 +++
 1 file changed, 79 insertions(+)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f402354..c3a99e7 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2253,12 +2253,91 @@ dpdk_vhost_user_class_init(void)
 }
 
 static void
+netdev_dpdk_attach(struct unixctl_conn *conn, int argc,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+uint8_t port_id;
+char response[512];
+
+ovs_mutex_lock(_mutex);
+
+ret = rte_eth_dev_attach(argv[1], _id);
+if(ret < 0) {
+snprintf(response, sizeof(response),
+"Error attaching device ''", argv[1]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+snprintf(response, sizeof(response),
+"Device '%s' has been attached as 'dpdk%d'", argv[1], port_id);
+unixctl_command_reply(conn, response);
+
+unlock:
+ovs_mutex_unlock(_mutex);
+}
+
+static void
+netdev_dpdk_detach(struct unixctl_conn *conn, int argc,
+const char *argv[], void *aux OVS_UNUSED)
+{
+int ret;
+unsigned int port_id;
+char name[RTE_ETH_NAME_MAX_LEN];
+char response[512];
+
+ret = dpdk_dev_parse_name(argv[1], "dpdk", _id);
+if(ret) {
+snprintf(response, sizeof(response),
+"'%s' is not a valid dpdk device", argv[1]);
+unixctl_command_reply_error(conn, response);
+return;
+}
+
+ovs_mutex_lock(_mutex);
+
+struct netdev * netdev = netdev_from_name(argv[1]);
+if(netdev) {
+netdev_close(netdev);
+snprintf(response, sizeof(response),
+"Port '%s' is being used. Remove it before detaching", 
argv[1]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+rte_eth_dev_close(port_id);
+
+ret = rte_eth_dev_detach(port_id, name);
+if(ret < 0) {
+snprintf(response, sizeof(response),
+"Port '%s' can not be detached", argv[1]);
+unixctl_command_reply_error(conn, response);
+goto unlock;
+}
+
+snprintf(response, sizeof(response), "Port '%s' has been detached", 
argv[1]);
+unixctl_command_reply(conn, response);
+
+unlock:
+ovs_mutex_unlock(_mutex);
+}
+
+static void
 dpdk_common_init(void)
 {
 unixctl_command_register("netdev-dpdk/set-admin-state",
  "[netdev] up|down", 1, 2,
  netdev_dpdk_set_admin_state, NULL);
 
+unixctl_command_register("netdev-dpdk/attach",
+ "device", 1, 1,
+ netdev_dpdk_attach, NULL);
+
+unixctl_command_register("netdev-dpdk/detach",
+ "port", 1, 1,
+ netdev_dpdk_detach, NULL);
+
 ovs_thread_create("dpdk_watchdog", dpdk_watchdog, NULL);
 }
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] INSTALL.DPDK: remove issue with QEMU v2.4.0 and dpdkvhostuser

2016-03-09 Thread Mauricio Vasquez B
The patch mentioned in the commit e73b7508fb58 ("INSTALL.DPDK: Mention
issue with QEMU v2.4.0 & dpdkvhostuser") is present in DPDK v2.2.0,
then this issue is not valid anymore.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 INSTALL.DPDK.md | 12 
 1 file changed, 12 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 1fc1b66..9ec8bf6 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -950,18 +950,6 @@ Restrictions:
 increased to the desired number of queues. Both DPDK and OVS must be
 recompiled for this change to take effect.
 
-  vHost and QEMU v2.4.0+:
-  - For versions of QEMU v2.4.0 and later, it is currently not possible to
-unbind more than one dpdkvhostuser port from the guest kernel driver
-without causing the ovs-vswitchd process to crash. If this is a requirement
-for your use case, it is recommended either to use a version of QEMU
-between v2.2.0 and v2.3.1 (inclusive), or alternatively, to apply the
-following patch to DPDK and rebuild:
-http://dpdk.org/dev/patchwork/patch/7736/
-This problem will likely be resolved in Open vSwitch at a later date, when
-the next release of DPDK (which includes the above patch) is available and
-integrated into OVS.
-
 Bug Reporting:
 --
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/2] lib/netdev-dpdk: make device name parsing more robust

2016-02-23 Thread Mauricio Vasquez B
Current implementation of dpdk_dev_parse_name does not perform a robust
error handling, port names as "dpdkr" and "dpdkr1x" are considered valid.

With this patch only positive port numbers in decimal notation are considered
valid.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v3:
- use str_to_uint

 lib/netdev-dpdk.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index de7e488..0fe0151 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -187,7 +187,7 @@ struct dpdk_ring {
 /* For the client rings */
 struct rte_ring *cring_tx;
 struct rte_ring *cring_rx;
-int user_port_id; /* User given port no, parsed from port name */
+unsigned int user_port_id; /* User given port no, parsed from port name */
 int eth_port_id; /* ethernet device port id */
 struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
 };
@@ -636,6 +636,8 @@ unlock:
 return err;
 }
 
+/* dev_name must be the prefix followed by a positive decimal number.
+ * (no leading + or - signs are allowed) */
 static int
 dpdk_dev_parse_name(const char dev_name[], const char prefix[],
 unsigned int *port_no)
@@ -647,8 +649,11 @@ dpdk_dev_parse_name(const char dev_name[], const char 
prefix[],
 }
 
 cport = dev_name + strlen(prefix);
-*port_no = strtol(cport, NULL, 0); /* string must be null terminated */
-return 0;
+
+if(str_to_uint(cport, 10, port_no))
+return 0;
+else
+return ENODEV;
 }
 
 static int
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 2/2] tests/dpdk/ring_client: extend range of supported dpdkr ports

2016-02-23 Thread Mauricio Vasquez B
Current implementation of the ring_client test only supports until the
dpdkr255 port, this patch extends it to support the full range of possible
dpdkr ports.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v3:
use str_to_uint
 tests/dpdk/ring_client.c | 46 +++---
 1 file changed, 15 insertions(+), 31 deletions(-)

diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c
index aeaeaca..089657a 100644
--- a/tests/dpdk/ring_client.c
+++ b/tests/dpdk/ring_client.c
@@ -42,6 +42,8 @@
 #include 
 #include 
 
+#include "util.h"
+
 /* Number of packets to attempt to read from queue. */
 #define PKT_READ_SIZE  ((uint16_t)32)
 
@@ -51,25 +53,21 @@
 
 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
 
-#define BASE_10 10
-
 /* Our client id number - tells us which rx queue to read, and tx
  * queue to write to.
  */
-static uint8_t client_id = 0;
+static unsigned int client_id;
 
 /*
  * Given the rx queue name template above, get the queue name.
  */
 static inline const char *
-get_rx_queue_name(unsigned id)
+get_rx_queue_name(unsigned int id)
 {
-/* Buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety).
- */
-static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2];
+/* Buffer for return value. */
+static char buffer[RTE_RING_NAMESIZE];
 
-snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_RXQ_NAME, id);
+snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id);
 return buffer;
 }
 
@@ -77,14 +75,12 @@ get_rx_queue_name(unsigned id)
  * Given the tx queue name template above, get the queue name.
  */
 static inline const char *
-get_tx_queue_name(unsigned id)
+get_tx_queue_name(unsigned int id)
 {
-/* Buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety).
- */
-static char buffer[sizeof(MP_CLIENT_TXQ_NAME) + 2];
+/* Buffer for return value. */
+static char buffer[RTE_RING_NAMESIZE];
 
-snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_TXQ_NAME, id);
+snprintf(buffer, sizeof(buffer), MP_CLIENT_TXQ_NAME, id);
 return buffer;
 }
 
@@ -98,27 +94,15 @@ usage(const char *progname)
 }
 
 /*
- * Convert the client id number from a string to an int.
+ * Convert the client id number from a string to an usigned int.
  */
 static int
 parse_client_num(const char *client)
 {
-char *end = NULL;
-unsigned long temp = 0;
-
-if (client == NULL || *client == '\0') {
+if(str_to_uint(client, 10, _id))
+return 0;
+ else
 return -1;
-}
-
-temp = strtoul(client, , BASE_10);
-/* If valid string argument is provided, terminating '/0' character
- * is stored in 'end'. */
-if (end == NULL || *end != '\0') {
-return -1;
-}
-
-client_id = (uint8_t)temp;
-return 0;
 }
 
 /*
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 1/2] lib/netdev-dpdk: make device name parsing more robust

2016-01-25 Thread Mauricio Vasquez B
Current implementation of dpdk_dev_parse_name does not perform a robust
error handling, port names as "dpdkr", "dpdkr1x", "dpdkr 5" are considered
valid.

With this path only positive port numbers in decimal notation are considered
valid.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v2:
- replace strtol by strtoul
- more strict parsing, ports as "dpdr 5" are now not valid.
Thanks to Aaron Conole!
 lib/netdev-dpdk.c | 30 --
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index de7e488..5d09230 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -18,7 +18,9 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -187,7 +189,7 @@ struct dpdk_ring {
 /* For the client rings */
 struct rte_ring *cring_tx;
 struct rte_ring *cring_rx;
-int user_port_id; /* User given port no, parsed from port name */
+unsigned int user_port_id; /* User given port no, parsed from port name */
 int eth_port_id; /* ethernet device port id */
 struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
 };
@@ -636,18 +638,42 @@ unlock:
 return err;
 }
 
+/* dev_name must be the prefix followed by a positive decimal number.
+ * (no leading + or - signs are allowed) */
 static int
 dpdk_dev_parse_name(const char dev_name[], const char prefix[],
 unsigned int *port_no)
 {
 const char *cport;
+unsigned long port;
+char *endptr;
 
 if (strncmp(dev_name, prefix, strlen(prefix))) {
 return ENODEV;
 }
 
+errno = 0;
 cport = dev_name + strlen(prefix);
-*port_no = strtol(cport, NULL, 0); /* string must be null terminated */
+
+if(!isdigit(cport[0])) {
+return ENODEV;
+}
+
+port = strtoul(cport, , 10);
+
+if(errno != 0) {
+return errno;
+}
+
+if(endptr == NULL || *endptr != '\0' || endptr == cport) {
+return ENODEV;
+}
+
+if(port > UINT_MAX) {
+return ENODEV;
+}
+
+*port_no = port;
 return 0;
 }
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2 2/2] tests/dpdk/ring_client: extend range of supported dpdkr ports

2016-01-25 Thread Mauricio Vasquez B
Current implementation of the ring_client test only supports up to the
dpdkr255 port, this patch extends it to support the full range of possible
dpdkr ports.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v2: 
- replace strtol by strtoul
Thanks to Aaron Conole!
 tests/dpdk/ring_client.c | 44 +++-
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c
index aeaeaca..d02c60b 100644
--- a/tests/dpdk/ring_client.c
+++ b/tests/dpdk/ring_client.c
@@ -33,6 +33,10 @@
  */
 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -56,20 +60,18 @@
 /* Our client id number - tells us which rx queue to read, and tx
  * queue to write to.
  */
-static uint8_t client_id = 0;
+static unsigned int client_id;
 
 /*
  * Given the rx queue name template above, get the queue name.
  */
 static inline const char *
-get_rx_queue_name(unsigned id)
+get_rx_queue_name(unsigned int id)
 {
-/* Buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety).
- */
-static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2];
+/* Buffer for return value. */
+static char buffer[RTE_RING_NAMESIZE];
 
-snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_RXQ_NAME, id);
+snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id);
 return buffer;
 }
 
@@ -77,14 +79,12 @@ get_rx_queue_name(unsigned id)
  * Given the tx queue name template above, get the queue name.
  */
 static inline const char *
-get_tx_queue_name(unsigned id)
+get_tx_queue_name(unsigned int id)
 {
-/* Buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety).
- */
-static char buffer[sizeof(MP_CLIENT_TXQ_NAME) + 2];
+/* Buffer for return value. */
+static char buffer[RTE_RING_NAMESIZE];
 
-snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_TXQ_NAME, id);
+snprintf(buffer, sizeof(buffer), MP_CLIENT_TXQ_NAME, id);
 return buffer;
 }
 
@@ -98,7 +98,7 @@ usage(const char *progname)
 }
 
 /*
- * Convert the client id number from a string to an int.
+ * Convert the client id number from a string to an usigned int.
  */
 static int
 parse_client_num(const char *client)
@@ -106,18 +106,28 @@ parse_client_num(const char *client)
 char *end = NULL;
 unsigned long temp = 0;
 
-if (client == NULL || *client == '\0') {
+if (client == NULL || !isdigit(client[0])) {
 return -1;
 }
 
+errno = 0;
 temp = strtoul(client, , BASE_10);
+
+if(errno != 0) {
+return -1;
+}
+
 /* If valid string argument is provided, terminating '/0' character
  * is stored in 'end'. */
-if (end == NULL || *end != '\0') {
+if(end == NULL || *end != '\0' || end == client) {
+return -1;
+}
+
+if(temp > UINT_MAX) {
 return -1;
 }
 
-client_id = (uint8_t)temp;
+client_id = (unsigned int)temp;
 return 0;
 }
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 2/3] tests/dpdk/ring_client: extend range of supported dpdkr ports

2016-01-23 Thread Mauricio Vasquez B
Current implementation allows to support only until the dpdkr255 port,
this patch extends it to support the full range of possible dpdkr ports.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 tests/dpdk/ring_client.c | 43 ++-
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c
index aeaeaca..9ccec4f 100644
--- a/tests/dpdk/ring_client.c
+++ b/tests/dpdk/ring_client.c
@@ -33,6 +33,9 @@
  */
 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -56,20 +59,18 @@
 /* Our client id number - tells us which rx queue to read, and tx
  * queue to write to.
  */
-static uint8_t client_id = 0;
+static unsigned int client_id;
 
 /*
  * Given the rx queue name template above, get the queue name.
  */
 static inline const char *
-get_rx_queue_name(unsigned id)
+get_rx_queue_name(unsigned int id)
 {
-/* Buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety).
- */
-static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2];
+/* Buffer for return value. */
+static char buffer[RTE_RING_NAMESIZE];
 
-snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_RXQ_NAME, id);
+snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id);
 return buffer;
 }
 
@@ -77,14 +78,12 @@ get_rx_queue_name(unsigned id)
  * Given the tx queue name template above, get the queue name.
  */
 static inline const char *
-get_tx_queue_name(unsigned id)
+get_tx_queue_name(unsigned int id)
 {
-/* Buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety).
- */
-static char buffer[sizeof(MP_CLIENT_TXQ_NAME) + 2];
+/* Buffer for return value. */
+static char buffer[RTE_RING_NAMESIZE];
 
-snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_TXQ_NAME, id);
+snprintf(buffer, sizeof(buffer), MP_CLIENT_TXQ_NAME, id);
 return buffer;
 }
 
@@ -98,7 +97,7 @@ usage(const char *progname)
 }
 
 /*
- * Convert the client id number from a string to an int.
+ * Convert the client id number from a string to an usigned int.
  */
 static int
 parse_client_num(const char *client)
@@ -110,14 +109,24 @@ parse_client_num(const char *client)
 return -1;
 }
 
-temp = strtoul(client, , BASE_10);
+errno = 0;
+temp = strtol(client, , BASE_10);
+
+if(errno != 0) {
+return -1;
+}
+
 /* If valid string argument is provided, terminating '/0' character
  * is stored in 'end'. */
-if (end == NULL || *end != '\0') {
+if(end == NULL || *end != '\0' || end == client) {
+return -1;
+}
+
+if(temp > UINT_MAX) {
 return -1;
 }
 
-client_id = (uint8_t)temp;
+client_id = (unsigned int)temp;
 return 0;
 }
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/3] lib/netdev-dpdk: make device name parsing more robust

2016-01-23 Thread Mauricio Vasquez B
Current implementation of dpdk_dev_parse_name does not perform a robust
error handling, port names as "dpdkr" or "dpdkr1x" are considered valid.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 lib/netdev-dpdk.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index de7e488..ac81f2f 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -187,7 +188,7 @@ struct dpdk_ring {
 /* For the client rings */
 struct rte_ring *cring_tx;
 struct rte_ring *cring_rx;
-int user_port_id; /* User given port no, parsed from port name */
+unsigned int user_port_id; /* User given port no, parsed from port name */
 int eth_port_id; /* ethernet device port id */
 struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
 };
@@ -641,13 +642,30 @@ dpdk_dev_parse_name(const char dev_name[], const char 
prefix[],
 unsigned int *port_no)
 {
 const char *cport;
+unsigned long port;
+char *endptr;
 
 if (strncmp(dev_name, prefix, strlen(prefix))) {
 return ENODEV;
 }
 
+errno = 0;
 cport = dev_name + strlen(prefix);
-*port_no = strtol(cport, NULL, 0); /* string must be null terminated */
+port = strtol(cport, , 10);
+
+if(errno != 0) {
+return errno;
+}
+
+if(endptr == NULL || *endptr != '\0' || endptr == cport) {
+return ENODEV;
+}
+
+if(port > UINT_MAX) {
+return ENODEV;
+}
+
+*port_no = port;
 return 0;
 }
 
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 3/3] lib/netdev-dpdk: increase ring name length for dpdkr ports

2016-01-23 Thread Mauricio Vasquez B
A ring name length of 10 characters is not enough for dpdkr ports
starting from dpdkr10, then it is increased to RTE_RING_NAMESIZE
characters.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 lib/netdev-dpdk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index ac81f2f..7caa70c 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1939,7 +1939,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
  unsigned int *eth_port_id)
 {
 struct dpdk_ring *ivshmem;
-char ring_name[10];
+char ring_name[RTE_RING_NAMESIZE];
 int err;
 
 ivshmem = dpdk_rte_mzalloc(sizeof *ivshmem);
@@ -1948,7 +1948,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 }
 
 /* XXX: Add support for multiquque ring. */
-err = snprintf(ring_name, 10, "%s_tx", dev_name);
+err = snprintf(ring_name, sizeof(ring_name), "%s_tx", dev_name);
 if (err < 0) {
 return -err;
 }
@@ -1961,7 +1961,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 return ENOMEM;
 }
 
-err = snprintf(ring_name, 10, "%s_rx", dev_name);
+err = snprintf(ring_name, sizeof(ring_name), "%s_rx", dev_name);
 if (err < 0) {
 return -err;
 }
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH v2] lib/netdev-dpdk: increase ring name length for dpdkr ports

2016-01-10 Thread Mauricio Vasquez B
A ring name length of 10 characters is not enough for dpdkr ports
starting from dpdkr10, then it is increased to RTE_RING_NAMESIZE
characters.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
v2:
- Use RTE_RING_NAMESIZE instead of a numerical constant.

 lib/netdev-dpdk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index b209df2..90512aa 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1921,7 +1921,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
  unsigned int *eth_port_id)
 {
 struct dpdk_ring *ivshmem;
-char ring_name[10];
+char ring_name[RTE_RING_NAMESIZE];
 int err;
 
 ivshmem = dpdk_rte_mzalloc(sizeof *ivshmem);
@@ -1930,7 +1930,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 }
 
 /* XXX: Add support for multiquque ring. */
-err = snprintf(ring_name, 10, "%s_tx", dev_name);
+err = snprintf(ring_name, sizeof(ring_name), "%s_tx", dev_name);
 if (err < 0) {
 return -err;
 }
@@ -1943,7 +1943,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 return ENOMEM;
 }
 
-err = snprintf(ring_name, 10, "%s_rx", dev_name);
+err = snprintf(ring_name, sizeof(ring_name), "%s_rx", dev_name);
 if (err < 0) {
 return -err;
 }
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] lib/netdev-dpdk: increase ring name length for dpdkr ports

2016-01-09 Thread Mauricio Vasquez B
A ring name length of 10 characters is not enough for dpdkr ports
starting from dpdkr10, then it is increased to 20 characters.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 lib/netdev-dpdk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index b209df2..60c4262 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1921,7 +1921,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
  unsigned int *eth_port_id)
 {
 struct dpdk_ring *ivshmem;
-char ring_name[10];
+char ring_name[20];
 int err;
 
 ivshmem = dpdk_rte_mzalloc(sizeof *ivshmem);
@@ -1930,7 +1930,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 }
 
 /* XXX: Add support for multiquque ring. */
-err = snprintf(ring_name, 10, "%s_tx", dev_name);
+err = snprintf(ring_name, sizeof(ring_name), "%s_tx", dev_name);
 if (err < 0) {
 return -err;
 }
@@ -1943,7 +1943,7 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 return ENOMEM;
 }
 
-err = snprintf(ring_name, 10, "%s_rx", dev_name);
+err = snprintf(ring_name, sizeof(ring_name), "%s_rx", dev_name);
 if (err < 0) {
 return -err;
 }
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] netdev-dpdk: assume dpdkr peer can be multi-producer/consumer

2015-11-16 Thread Mauricio Vasquez B
Although netdev does explicit locking, it is only valid from the ovs 
perspective, then only the ring ends used by ovs should be declared as
single producer/consumer.
The other ends that are used by the application should be declared as
multiple producer/consumer that is the most general case.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezber...@studenti.polito.it>
---
 lib/netdev-dpdk.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 4658416..e3a0771 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1931,9 +1931,9 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 return -err;
 }
 
-/* Create single consumer/producer rings, netdev does explicit locking. */
+/* Create single producer tx ring, netdev does explicit locking. */
 ivshmem->cring_tx = rte_ring_create(ring_name, DPDK_RING_SIZE, SOCKET0,
-RING_F_SP_ENQ | RING_F_SC_DEQ);
+RING_F_SP_ENQ);
 if (ivshmem->cring_tx == NULL) {
 rte_free(ivshmem);
 return ENOMEM;
@@ -1944,9 +1944,9 @@ dpdk_ring_create(const char dev_name[], unsigned int 
port_no,
 return -err;
 }
 
-/* Create single consumer/producer rings, netdev does explicit locking. */
+/* Create single consumer rx ring, netdev does explicit locking. */
 ivshmem->cring_rx = rte_ring_create(ring_name, DPDK_RING_SIZE, SOCKET0,
-RING_F_SP_ENQ | RING_F_SC_DEQ);
+RING_F_SC_DEQ);
 if (ivshmem->cring_rx == NULL) {
 rte_free(ivshmem);
 return ENOMEM;
-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev