[ovs-dev] [PATCH v5 3/3] netdev-dpdk: Add support for virtual DPDK PMDs (vdevs)

Ciara Loftus ciara.loftus at intel.com
Thu Jan 5 10:42:10 UTC 2017


Prior to this commit, the 'dpdk' port type could only be used for
physical DPDK devices. Now, virtual devices (or 'vdevs') are supported.
'vdev' devices are those which use virtual DPDK Poll Mode Drivers eg.
null, pcap. To add a DPDK vdev, a valid 'dpdk-devargs' must be set for
the given dpdk port. The format expected is 'eth_<driver_name><x>' where
'x' is a number between 0 and RTE_MAX_ETHPORTS -1.

For example to add a port that uses the 'null' DPDK PMD driver:

ovs-vsctl set Interface null0 options:dpdk-devargs=eth_null0

Not all DPDK vdevs have been verified to work at this point in time.

Signed-off-by: Ciara Loftus <ciara.loftus at intel.com>
---
Changelog:
* Updated process_vdevargs to work with Daniele's incremental in the
  previous patch.
* Allow vdev detach
* Update docs to show af_packet example
* Fix af_packet docs example
* Fix style issues in docs

 Documentation/howto/dpdk.rst | 29 +++++++++++++++++++++++++++++
 NEWS                         |  1 +
 lib/netdev-dpdk.c            | 35 +++++++++++------------------------
 vswitchd/vswitch.xml         |  9 +++++++--
 4 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
index 1ff672c..fbb4b53 100644
--- a/Documentation/howto/dpdk.rst
+++ b/Documentation/howto/dpdk.rst
@@ -324,6 +324,35 @@ This feature is not supported with VFIO and does not work with some NICs.
 For more information please refer to the `DPDK Port Hotplug Framework
 <http://dpdk.org/doc/guides/prog_guide/port_hotplug_framework.html#hotplug>`__.
 
+.. _vdev-support:
+
+Vdev Support
+------------
+
+DPDK provides drivers for both physical and virtual devices. Physical DPDK
+devices are added to OVS by specifying a valid PCI address in 'dpdk-devargs'.
+Virtual DPDK devices which do not have PCI addresses can be added using a
+different format for 'dpdk-devargs'.
+
+Typically, the format expected is 'eth_<driver_name><x>' where 'x' is a
+number between 0 and RTE_MAX_ETHPORTS -1 (31).
+
+For example to add a dpdk port that uses the 'null' DPDK PMD driver::
+
+       $ ovs-vsctl add-port br0 null0 -- set Interface null0 type=dpdk \
+           options:dpdk-devargs=eth_null0
+
+Similarly, to add a dpdk port that uses the 'af_packet' DPDK PMD driver::
+
+       $ ovs-vsctl add-port br0 myeth0 -- set Interface myeth0 type=dpdk \
+           options:dpdk-devargs=eth_af_packet0,iface=eth0
+
+More information on the different types of virtual DPDK PMDs can be found in
+the `DPDK documentation
+<http://dpdk.org/doc/guides/nics/overview.html>`__.
+
+Note: Not all DPDK virtual PMD drivers have been tested and verified to work.
+
 .. _dpdk-ovs-in-guest:
 
 OVS with DPDK Inside VMs
diff --git a/NEWS b/NEWS
index d66d402..cc319a9 100644
--- a/NEWS
+++ b/NEWS
@@ -53,6 +53,7 @@ Post-v2.6.0
        with the old dpdk<portid> naming scheme is broken, and as such a
        device will not be available for use until a valid dpdk-devargs is
        specified.
+     * Virtual DPDK Poll Mode Driver (vdev PMD) support.
    - Fedora packaging:
      * A package upgrade does not automatically restart OVS service.
    - ovs-vswitchd/ovs-vsctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e66ff27..79eddb5 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1134,25 +1134,19 @@ netdev_dpdk_lookup_by_port_id(int port_id)
 static int
 netdev_dpdk_process_devargs(const char *devargs)
 {
-    struct rte_pci_addr addr;
     uint8_t new_port_id = UINT8_MAX;
 
-    if (!eal_parse_pci_DomBDF(devargs, &addr)) {
-        /* Valid PCI address format detected - configure physical device */
-        if (!rte_eth_dev_count()
-                || rte_eth_dev_get_port_by_name(devargs, &new_port_id)
-                || !rte_eth_dev_is_valid_port(new_port_id)) {
-            /* PCI device not found in DPDK, attempt to attach it */
-            if (!rte_eth_dev_attach(devargs, &new_port_id)) {
-                /* Attach successful */
-                VLOG_INFO("Device "PCI_PRI_FMT" has been attached to DPDK",
-                          addr.domain, addr.bus, addr.devid, addr.function);
-            } else {
-                /* Attach unsuccessful */
-                VLOG_INFO("Error attaching device "PCI_PRI_FMT" to DPDK",
-                          addr.domain, addr.bus, addr.devid, addr.function);
-                return -1;
-            }
+    if (!rte_eth_dev_count()
+            || rte_eth_dev_get_port_by_name(devargs, &new_port_id)
+            || !rte_eth_dev_is_valid_port(new_port_id)) {
+        /* Device not found in DPDK, attempt to attach it */
+        if (!rte_eth_dev_attach(devargs, &new_port_id)) {
+            /* Attach successful */
+            VLOG_INFO("Device '%s' attached to DPDK", devargs);
+        } else {
+            /* Attach unsuccessful */
+            VLOG_INFO("Error attaching device '%s' to DPDK", devargs);
+            return -1;
         }
     }
 
@@ -2459,17 +2453,10 @@ netdev_dpdk_detach(struct unixctl_conn *conn, int argc OVS_UNUSED,
     char *response;
     uint8_t port_id;
     char devname[RTE_ETH_NAME_MAX_LEN];
-    struct rte_pci_addr addr;
     struct netdev_dpdk *dev;
 
     ovs_mutex_lock(&dpdk_mutex);
 
-    if (eal_parse_pci_DomBDF(argv[1], &addr)) {
-        response = xasprintf("Invalid PCI address '%s'. Cannot detach.",
-                             argv[1]);
-        goto error;
-    }
-
     if (!rte_eth_dev_count() || rte_eth_dev_get_port_by_name(argv[1],
                                                              &port_id)) {
         response = xasprintf("Device '%s' not found in DPDK", argv[1]);
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index c34c295..b899617 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -2306,8 +2306,13 @@
       <column name="options" key="dpdk-devargs"
               type='{"type": "string"}'>
         <p>
-          Specifies the PCI address of a physical dpdk device.
-          Only supported by 'dpdk' devices.
+          Specifies the PCI address associated with the port for physical
+          devices, or the virtual driver to be used for the port when a virtual
+          PMD is intended to be used. For the latter, the argument string
+          typically takes the form of eth_&lt;driver_name&gt;&lt;x&gt; where
+          'driver_name' is a valid virtual DPDK PMD driver name and where 'x'
+          lies in the range of 0 to RTE_MAX_ETHPORTS-1.
+          Only supported by the dpdk port type.
         </p>
       </column>
 
-- 
2.4.3



More information about the dev mailing list