From patchwork Tue May 30 10:02:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Weglicki, MichalX" X-Patchwork-Id: 768530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wcTgH237wz9ryv for ; Tue, 30 May 2017 20:02:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A3C5B9E; Tue, 30 May 2017 10:02:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1A32B40F for ; Tue, 30 May 2017 10:02:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C63BF161 for ; Tue, 30 May 2017 10:02:30 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 30 May 2017 03:02:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,418,1491289200"; d="scan'208";a="267956690" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga004.fm.intel.com with ESMTP; 30 May 2017 03:02:29 -0700 From: mweglicx To: dev@openvswitch.org Date: Tue, 30 May 2017 11:02:27 +0100 Message-Id: <1496138547-23769-1-git-send-email-michalx.weglicki@intel.com> X-Mailer: git-send-email 1.7.0.7 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] Update relevant artifacts to add support for DPDK 17.05. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Following changes are applied: - netdev-dpdk: Changes required by DPDK API modifications. - doc: Because of DPDK API changes, backward compatibility with previous DPDK releases will be broken, thus all relevant documentation entries are updated. - .travis: DPDK version change from 16.11.1 to 17.05. - rhel/openvswitch-fedora.spec.in: DPDK version change from 16.11 to 17.05. Signed-off-by: Michal Weglicki --- .travis/linux-build.sh | 2 +- Documentation/faq/releases.rst | 2 +- Documentation/intro/install/dpdk.rst | 8 +- Documentation/topics/dpdk/vhost-user.rst | 8 +- lib/netdev-dpdk.c | 122 ++++++++++++++++--------------- rhel/openvswitch-fedora.spec.in | 2 +- tests/dpdk/ring_client.c | 6 +- 7 files changed, 78 insertions(+), 72 deletions(-) diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index 8750d68..ec15fd8 100755 --- a/.travis/linux-build.sh +++ b/.travis/linux-build.sh @@ -80,7 +80,7 @@ fi if [ "$DPDK" ]; then if [ -z "$DPDK_VER" ]; then - DPDK_VER="16.11.1" + DPDK_VER="17.05" fi install_dpdk $DPDK_VER if [ "$CC" = "clang" ]; then diff --git a/Documentation/faq/releases.rst b/Documentation/faq/releases.rst index c85eff8..4fe46bc 100644 --- a/Documentation/faq/releases.rst +++ b/Documentation/faq/releases.rst @@ -160,7 +160,7 @@ Q: What DPDK version does each Open vSwitch release work with? 2.4.x 2.0 2.5.x 2.2 2.6.x 16.07.2 - 2.7.x 16.11.1 + 2.7.0+ 17.05 ============ ======= Q: I get an error like this when I configure Open vSwitch: diff --git a/Documentation/intro/install/dpdk.rst b/Documentation/intro/install/dpdk.rst index e83f852..536450b 100644 --- a/Documentation/intro/install/dpdk.rst +++ b/Documentation/intro/install/dpdk.rst @@ -40,7 +40,7 @@ Build requirements In addition to the requirements described in :doc:`general`, building Open vSwitch with DPDK will require the following: -- DPDK 16.11 +- DPDK 17.05 - A `DPDK supported NIC`_ @@ -69,9 +69,9 @@ Install DPDK #. Download the `DPDK sources`_, extract the file and set ``DPDK_DIR``:: $ cd /usr/src/ - $ wget http://fast.dpdk.org/rel/dpdk-16.11.1.tar.xz - $ tar xf dpdk-16.11.1.tar.xz - $ export DPDK_DIR=/usr/src/dpdk-stable-16.11.1 + $ wget http://fast.dpdk.org/rel/dpdk-17.05.tar.xz + $ tar xf dpdk-17.05.tar.xz + $ export DPDK_DIR=/usr/src/dpdk-17.05 $ cd $DPDK_DIR #. (Optional) Configure DPDK as a shared library diff --git a/Documentation/topics/dpdk/vhost-user.rst b/Documentation/topics/dpdk/vhost-user.rst index ba22684..71098fd 100644 --- a/Documentation/topics/dpdk/vhost-user.rst +++ b/Documentation/topics/dpdk/vhost-user.rst @@ -278,9 +278,9 @@ To begin, instantiate a guest as described in :ref:`dpdk-vhost-user` or DPDK sources to VM and build DPDK:: $ cd /root/dpdk/ - $ wget http://fast.dpdk.org/rel/dpdk-16.11.1.tar.xz - $ tar xf dpdk-16.11.1.tar.xz - $ export DPDK_DIR=/root/dpdk/dpdk-stable-16.11.1 + $ wget http://fast.dpdk.org/rel/dpdk-17.05.tar.xz + $ tar xf dpdk-17.05.tar.xz + $ export DPDK_DIR=/root/dpdk/dpdk-17.05 $ export DPDK_TARGET=x86_64-native-linuxapp-gcc $ export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET $ cd $DPDK_DIR @@ -364,7 +364,7 @@ Sample XML - + diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 609b8da..813a59d 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -31,7 +31,10 @@ #include #include #include -#include +#include +#include +#include +#include #include "dirs.h" #include "dp-packet.h" @@ -56,6 +59,8 @@ #include "timeval.h" #include "unixctl.h" +enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM}; + VLOG_DEFINE_THIS_MODULE(netdev_dpdk); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); @@ -164,6 +169,21 @@ static const struct rte_eth_conf port_conf = { }, }; +/* + * These callbacks allow virtio-net devices to be added to vhost ports when + * configuration has been fully completed. + */ +static int new_device(int vid); +static void destroy_device(int vid); +static int vring_state_changed(int vid, uint16_t queue_id, int enable); +static const struct vhost_device_ops virtio_net_device_ops = +{ + .new_device = new_device, + .destroy_device = destroy_device, + .vring_state_changed = vring_state_changed, + .features_changed = NULL +}; + enum { DPDK_RING_SIZE = 256 }; BUILD_ASSERT_DECL(IS_POW2(DPDK_RING_SIZE)); enum { DRAIN_TSC = 200000ULL }; @@ -402,8 +422,8 @@ struct netdev_rxq_dpdk { int port_id; }; -static int netdev_dpdk_class_init(void); -static int netdev_dpdk_vhost_class_init(void); +static void netdev_dpdk_destruct(struct netdev *netdev); +static void netdev_dpdk_vhost_destruct(struct netdev *netdev); int netdev_dpdk_get_vid(const struct netdev_dpdk *dev); @@ -413,8 +433,8 @@ netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev); static bool is_dpdk_class(const struct netdev_class *class) { - return class->init == netdev_dpdk_class_init - || class->init == netdev_dpdk_vhost_class_init; + return class->destruct == netdev_dpdk_destruct + || class->destruct == netdev_dpdk_vhost_destruct; } /* DPDK NIC drivers allocate RX buffers at a particular granularity, typically @@ -922,7 +942,7 @@ netdev_dpdk_vhost_construct(struct netdev *netdev) { struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); const char *name = netdev->name; - int err; + int ret_value, result; /* 'name' is appended to 'vhost_sock_dir' and used to create a socket in * the file system. '/' or '\' would traverse directories, so they're not @@ -942,8 +962,9 @@ netdev_dpdk_vhost_construct(struct netdev *netdev) dpdk_get_vhost_sock_dir(), name); dev->vhost_driver_flags &= ~RTE_VHOST_USER_CLIENT; - err = rte_vhost_driver_register(dev->vhost_id, dev->vhost_driver_flags); - if (err) { + ret_value = rte_vhost_driver_register(dev->vhost_id, + dev->vhost_driver_flags); + if (ret_value) { VLOG_ERR("vhost-user socket device setup failure for socket %s\n", dev->vhost_id); } else { @@ -951,10 +972,38 @@ netdev_dpdk_vhost_construct(struct netdev *netdev) VLOG_INFO("Socket %s created for vhost-user port %s\n", dev->vhost_id, name); } - err = vhost_common_construct(netdev); + + result = rte_vhost_driver_callback_register(dev->vhost_id, + &virtio_net_device_ops); + if (result) { + VLOG_ERR("vhost-user callback register failed."); + ret_value = result; + } + + result = + rte_vhost_driver_disable_features(dev->vhost_id, + 1ULL << VIRTIO_NET_F_HOST_TSO4 + | 1ULL << VIRTIO_NET_F_HOST_TSO6 + | 1ULL << VIRTIO_NET_F_CSUM); + if (result) { + VLOG_ERR("vhost-user disable features failed!"); + return result; + } + + result = vhost_common_construct(netdev); + if (result) { + VLOG_ERR("vhost-user common construct failed."); + ret_value = result; + } + + result = rte_vhost_driver_start(dev->vhost_id); + if (result) { + VLOG_ERR("vhost-user driver start failed."); + ret_value = result; + } ovs_mutex_unlock(&dpdk_mutex); - return err; + return ret_value; } static int @@ -2483,12 +2532,9 @@ static void set_irq_status(int vid) { uint32_t i; - uint64_t idx; - for (i = 0; i < rte_vhost_get_queue_num(vid); i++) { - idx = i * VIRTIO_QNUM; - rte_vhost_enable_guest_notification(vid, idx + VIRTIO_RXQ, 0); - rte_vhost_enable_guest_notification(vid, idx + VIRTIO_TXQ, 0); + for (i = 0; i < rte_vhost_get_vring_num(vid); i++) { + rte_vhost_enable_guest_notification(vid, i, 0); } } @@ -2551,7 +2597,7 @@ new_device(int vid) LIST_FOR_EACH(dev, list_node, &dpdk_list) { ovs_mutex_lock(&dev->mutex); if (strncmp(ifname, dev->vhost_id, IF_NAME_SZ) == 0) { - uint32_t qp_num = rte_vhost_get_queue_num(vid); + uint32_t qp_num = rte_vhost_get_vring_num(vid)/2; /* Get NUMA information */ newnode = rte_vhost_get_numa_node(vid); @@ -2718,27 +2764,6 @@ netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev) return ovsrcu_get(struct ingress_policer *, &dev->ingress_policer); } -/* - * These callbacks allow virtio-net devices to be added to vhost ports when - * configuration has been fully complete. - */ -static const struct virtio_net_device_ops virtio_net_device_ops = -{ - .new_device = new_device, - .destroy_device = destroy_device, - .vring_state_changed = vring_state_changed -}; - -static void * -start_vhost_loop(void *dummy OVS_UNUSED) -{ - pthread_detach(pthread_self()); - /* Put the vhost thread into quiescent state. */ - ovsrcu_quiesce_start(); - rte_vhost_driver_session_start(); - return NULL; -} - static int netdev_dpdk_class_init(void) { @@ -2761,25 +2786,6 @@ netdev_dpdk_class_init(void) return 0; } -static int -netdev_dpdk_vhost_class_init(void) -{ - static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; - - /* This function can be called for different classes. The initialization - * needs to be done only once */ - if (ovsthread_once_start(&once)) { - rte_vhost_driver_callback_register(&virtio_net_device_ops); - rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_HOST_TSO4 - | 1ULL << VIRTIO_NET_F_HOST_TSO6 - | 1ULL << VIRTIO_NET_F_CSUM); - ovs_thread_create("vhost_thread", start_vhost_loop, NULL); - - ovsthread_once_done(&once); - } - - return 0; -} /* Client Rings */ @@ -3351,7 +3357,7 @@ static const struct netdev_class dpdk_ring_class = static const struct netdev_class dpdk_vhost_class = NETDEV_DPDK_CLASS( "dpdkvhostuser", - netdev_dpdk_vhost_class_init, + NULL, netdev_dpdk_vhost_construct, netdev_dpdk_vhost_destruct, NULL, @@ -3366,7 +3372,7 @@ static const struct netdev_class dpdk_vhost_class = static const struct netdev_class dpdk_vhost_client_class = NETDEV_DPDK_CLASS( "dpdkvhostuserclient", - netdev_dpdk_vhost_class_init, + NULL, netdev_dpdk_vhost_client_construct, netdev_dpdk_vhost_destruct, netdev_dpdk_vhost_client_set_config, diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index 3200040..596a4b3 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -84,7 +84,7 @@ BuildRequires: libcap-ng libcap-ng-devel %endif %if %{with dpdk} BuildRequires: libpcap-devel numactl-devel -BuildRequires: dpdk-devel >= 16.11 +BuildRequires: dpdk-devel >= 17.05 Provides: %{name}-dpdk = %{version}-%{release} %endif diff --git a/tests/dpdk/ring_client.c b/tests/dpdk/ring_client.c index b153713..8cc3fb5 100644 --- a/tests/dpdk/ring_client.c +++ b/tests/dpdk/ring_client.c @@ -185,15 +185,15 @@ main(int argc, char *argv[]) /* Try dequeuing max possible packets first, if that fails, get the * most we can. Loop body should only execute once, maximum. */ - while (unlikely(rte_ring_dequeue_bulk(rx_ring, pkts, rx_pkts) != 0) && - rx_pkts > 0) { + while (unlikely(rte_ring_dequeue_bulk(rx_ring, pkts, + rx_pkts, NULL) != 0) && rx_pkts > 0) { rx_pkts = (uint16_t)RTE_MIN(rte_ring_count(rx_ring), PKT_READ_SIZE); } if (rx_pkts > 0) { /* blocking enqueue */ do { - rslt = rte_ring_enqueue_bulk(tx_ring, pkts, rx_pkts); + rslt = rte_ring_enqueue_bulk(tx_ring, pkts, rx_pkts, NULL); } while (rslt == -ENOBUFS); } }