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

Ciara Loftus ciara.loftus at intel.com
Thu Dec 15 11:54:16 UTC 2016


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

 Documentation/intro/install/dpdk-advanced.rst | 27 ++++++++++++++++++++++++
 NEWS                                          |  1 +
 lib/netdev-dpdk.c                             | 30 ++++++++-------------------
 vswitchd/vswitch.xml                          |  9 ++++++--
 4 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/Documentation/intro/install/dpdk-advanced.rst b/Documentation/intro/install/dpdk-advanced.rst
index 147fcca..d16cc75 100644
--- a/Documentation/intro/install/dpdk-advanced.rst
+++ b/Documentation/intro/install/dpdk-advanced.rst
@@ -956,6 +956,33 @@ This feature is not supported with VFIO and could 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
+------------
+
+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 af0 -- set Interface af0 type=dpdk \
+           options:dpdk-devargs=eth_af_packet0
+
+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.
+
 Bug Reporting
 -------------
 
diff --git a/NEWS b/NEWS
index 8c7f38e..cb1b96c 100644
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,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 aa14181..75559fe 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1095,22 +1095,17 @@ 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_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 */
-                return -1;
-            }
+    if (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 */
+            return -1;
         }
     }
 
@@ -2398,17 +2393,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_get_port_by_name(argv[1], &port_id)) {
         response = xasprintf("Device '%s' not found in DPDK", argv[1]);
         goto error;
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 23ab469..7c6f229 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