From patchwork Mon Jul 3 20:27:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 783631 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 3x1fDl0Ch1z9s9Y for ; Tue, 4 Jul 2017 06:41:27 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4EAA2B5E; Mon, 3 Jul 2017 20:36:29 +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 F375AB4A for ; Mon, 3 Jul 2017 20:36:26 +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 9374E175 for ; Mon, 3 Jul 2017 20:36:26 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP; 03 Jul 2017 13:36:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,305,1496127600"; d="scan'208";a="104096460" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2017 13:36:25 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Mon, 3 Jul 2017 21:27:22 +0100 Message-Id: <1499113653-19440-10-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1499113653-19440-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1499113653-19440-1-git-send-email-bhanuprakash.bodireddy@intel.com> 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 09/20] dpif-netdev: Enable heartbeats for DPDK datapath. 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 This commit adds heartbeat mechanism support for DPDK datapath. Heartbeats are sent to registered PMD threads at predefined intervals (as set in ovsdb with 'keepalive-interval'). The heartbeats are only enabled when there is atleast one port added to the bridge and with active PMD thread polling the port. Signed-off-by: Bhanuprakash Bodireddy --- lib/dpdk-stub.c | 6 ++++++ lib/dpdk.c | 7 +++++++ lib/dpdk.h | 2 ++ lib/dpif-netdev.c | 9 ++++++++- lib/keepalive.c | 9 +++++++++ lib/keepalive.h | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/dpdk-stub.c b/lib/dpdk-stub.c index 60ea34c..d6e64dd 100644 --- a/lib/dpdk-stub.c +++ b/lib/dpdk-stub.c @@ -78,3 +78,9 @@ dpdk_mark_pmd_core_sleep(void) { /* Nothing */ } + +void +dpdk_dispatch_pmd_hb(void) +{ + /* Nothing */ +} diff --git a/lib/dpdk.c b/lib/dpdk.c index 79fdd10..79bc739 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -542,3 +542,10 @@ dpdk_mark_pmd_core_sleep(void) { rte_keepalive_mark_sleep(rte_global_keepalive_info); } + +/* Dispatch pings */ +void +dpdk_dispatch_pmd_hb(void) +{ + rte_keepalive_dispatch_pings(NULL, rte_global_keepalive_info); +} diff --git a/lib/dpdk.h b/lib/dpdk.h index 7619730..2532cb7 100644 --- a/lib/dpdk.h +++ b/lib/dpdk.h @@ -47,4 +47,6 @@ void dpdk_unregister_pmd_core(unsigned core_id); void dpdk_mark_pmd_core_alive(void); void dpdk_mark_pmd_core_sleep(void); +void dpdk_dispatch_pmd_hb(void); + #endif /* dpdk.h */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index ea41a0b..2347345 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -971,11 +971,18 @@ sorted_poll_thread_list(struct dp_netdev *dp, } static void * -ovs_keepalive(void *f_ OVS_UNUSED) +ovs_keepalive(void *f_) { + struct dp_netdev *dp = f_; + pthread_detach(pthread_self()); for (;;) { + int n_pmds = cmap_count(&dp->poll_threads) - 1; + if (n_pmds > 0) { + dispatch_heartbeats(); + } + ovsrcu_quiesce_start(); usleep(get_ka_interval() * 1000); ovsrcu_quiesce_end(); diff --git a/lib/keepalive.c b/lib/keepalive.c index 241a236..3270de7 100644 --- a/lib/keepalive.c +++ b/lib/keepalive.c @@ -249,6 +249,15 @@ ka_destroy_portstats(void) } } +/* Dispatch pings */ +void +dispatch_heartbeats(void) +{ +#ifdef DPDK_NETDEV + dpdk_dispatch_pmd_hb(); +#endif +} + static struct keepalive_info * keepalive_info_create(void) { diff --git a/lib/keepalive.h b/lib/keepalive.h index 605e41c..31ee34c 100644 --- a/lib/keepalive.h +++ b/lib/keepalive.h @@ -101,4 +101,5 @@ int get_ka_init_status(void); int ka_alloc_portstats(unsigned, int); void ka_destroy_portstats(void); +void dispatch_heartbeats(void); #endif /* keepalive.h */