From patchwork Tue Feb 16 07:14:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 10532 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3A955BE80; Tue, 16 Feb 2016 08:16:08 +0100 (CET) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 86F30BE12 for ; Tue, 16 Feb 2016 08:16:06 +0100 (CET) Received: by mail-wm0-f43.google.com with SMTP id g62so138541724wme.0 for ; Mon, 15 Feb 2016 23:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=ZtOwgwwDIFQG4Ct5513R8Uepv/g6swiakrOvuiWKZkg=; b=WxySOtMCor0qbQjZgL2jqQo+SyddE6qICQ4hmkqE5QFleZm8yP5pZW1Imzg7HXGaRO kaNWSE0Irr7FlAVG8cnj74/49gDox7g5IgaDIOAhpe1LJ3BieAtSpjG82aaYUtypbczt pQz/5cV/vmX1sIbKrDhhr5USZNZ6ynn3Z1/xdyHY2tJBG8CTutYPLY8Z5SpMg+Tn2q1a az+/Kp5kuFNDdL3dCpsz2JQA1NEX0KrAD/TaYoso/2nsS3KsPAcYWfD/Lnbzy15H/EzE 5qoUmdRS4RD4Y1cVESwr7pPLjXshvA5TFliwnKyLRZ6A4ECTbpG4UnGzoetn+LkEUD4Y RNDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=ZtOwgwwDIFQG4Ct5513R8Uepv/g6swiakrOvuiWKZkg=; b=KKy3qKEPEMsCnJCz/YZ4iL98sN4eCNDMnvwo9T1QPvimcZMpGiqtsfNSblNfh8Tjxv DabeNKL6mgRemTWd04VR58KNphO8gnlbgg9YGk7YLQn1jxW5UFUpBjBEgUkKKIcFQ+ho 3cYT6udfM4bFVOMj+ZlXY0cLlVL06fI1YzNy7zzx9v6FRAk9fzGWJ09+0wcPw1A5+Nyg iiIxWdqE5sr49T48vkfQc/PVCPdrPrqh5BfderNUdAVGG2hVzXMVkVxpD2vY+X9BKWKW DeYxWC4Wcy06Tk81rLU4I0tGdBfifS3PH0kkUu+i7q/SnRsx8InxOHhF6/svilAxk/KT z4Ww== X-Gm-Message-State: AG10YOTOARmNRvIwlQHuZeAAYSjTN77LuP5IBnWbLLasvVzFpfJneL6wQ4WjEqg/FotYlrXv X-Received: by 10.194.92.68 with SMTP id ck4mr20031788wjb.144.1455606966448; Mon, 15 Feb 2016 23:16:06 -0800 (PST) Received: from XPS13.localdomain (165.20.90.92.rev.sfr.net. [92.90.20.165]) by smtp.gmail.com with ESMTPSA id b5sm19032574wmh.15.2016.02.15.23.16.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Feb 2016 23:16:05 -0800 (PST) From: Thomas Monjalon To: pablo.de.lara.guarch@intel.com, declan.doherty@intel.com, remy.horton@intel.com Date: Tue, 16 Feb 2016 08:14:23 +0100 Message-Id: <1455606865-22680-2-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1455606865-22680-1-git-send-email-thomas.monjalon@6wind.com> References: <1454691969-25734-1-git-send-email-thomas.monjalon@6wind.com> <1455606865-22680-1-git-send-email-thomas.monjalon@6wind.com> MIME-Version: 1.0 Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH v2 1/3] eal: fix keep alive header for C++ X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When built in a C++ application, the keepalive include fails: rte_keepalive.h:142:41: error: ‘ALIVE’ was not declared in this scope keepcfg->state_flags[rte_lcore_id()] = ALIVE; ^ C++ requires to use a scope operator to access an enum inside a struct. There was also a namespace issue for the values (no RTE prefix). The solution is to move the struct and related code out of the header file. Fixes: 75583b0d1efd ("eal: add keep alive monitoring") Signed-off-by: Thomas Monjalon Acked-by: Remy Horton --- lib/librte_eal/common/include/rte_keepalive.h | 37 +++----------------------- lib/librte_eal/common/rte_keepalive.c | 38 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 34 deletions(-) v2: - move keep-alive struct out of header - uninline mark_alive function diff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h index 02472c0..f4cec04 100644 --- a/lib/librte_eal/common/include/rte_keepalive.h +++ b/lib/librte_eal/common/include/rte_keepalive.h @@ -64,35 +64,7 @@ typedef void (*rte_keepalive_failure_callback_t)( * Keepalive state structure. * @internal */ -struct rte_keepalive { - /** Core Liveness. */ - enum { - ALIVE = 1, - MISSING = 0, - DEAD = 2, - GONE = 3 - } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES]; - - /** Last-seen-alive timestamps */ - uint64_t last_alive[RTE_KEEPALIVE_MAXCORES]; - - /** - * Cores to check. - * Indexed by core id, non-zero if the core should be checked. - */ - uint8_t active_cores[RTE_KEEPALIVE_MAXCORES]; - - /** Dead core handler. */ - rte_keepalive_failure_callback_t callback; - - /** - * Dead core handler app data. - * Pointer is passed to dead core handler. - */ - void *callback_data; - uint64_t tsc_initial; - uint64_t tsc_mhz; -}; +struct rte_keepalive; /** @@ -136,11 +108,8 @@ void rte_keepalive_register_core(struct rte_keepalive *keepcfg, * This function needs to be called from within the main process loop of * the LCore to be checked. */ -static inline void -rte_keepalive_mark_alive(struct rte_keepalive *keepcfg) -{ - keepcfg->state_flags[rte_lcore_id()] = ALIVE; -} +void +rte_keepalive_mark_alive(struct rte_keepalive *keepcfg); #endif /* _KEEPALIVE_H_ */ diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c index 736fd0f..bd1f16b 100644 --- a/lib/librte_eal/common/rte_keepalive.c +++ b/lib/librte_eal/common/rte_keepalive.c @@ -39,6 +39,37 @@ #include #include +struct rte_keepalive { + /** Core Liveness. */ + enum rte_keepalive_state { + ALIVE = 1, + MISSING = 0, + DEAD = 2, + GONE = 3 + } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES]; + + /** Last-seen-alive timestamps */ + uint64_t last_alive[RTE_KEEPALIVE_MAXCORES]; + + /** + * Cores to check. + * Indexed by core id, non-zero if the core should be checked. + */ + uint8_t active_cores[RTE_KEEPALIVE_MAXCORES]; + + /** Dead core handler. */ + rte_keepalive_failure_callback_t callback; + + /** + * Dead core handler app data. + * Pointer is passed to dead core handler. + */ + void *callback_data; + uint64_t tsc_initial; + uint64_t tsc_mhz; +}; + + static void print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core) { @@ -111,3 +142,10 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core) if (id_core < RTE_KEEPALIVE_MAXCORES) keepcfg->active_cores[id_core] = 1; } + + +void +rte_keepalive_mark_alive(struct rte_keepalive *keepcfg) +{ + keepcfg->state_flags[rte_lcore_id()] = ALIVE; +}