From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 58C2F1B113 for ; Wed, 17 Oct 2018 11:41:53 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E308120F12; Wed, 17 Oct 2018 05:41:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 Oct 2018 05:41:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=NxoOPgabpGYEA8Hbe1+opothQpA9ihxAQ7OCrVce9H4=; b=DR+cIzmRAZgz 9V8WHGGlM/REry0Lbrg0/u/jF5fTH0/UrEkGgptkhV/HkjKJiijiawrp1Fpj/7vR ueNxxoE2aPKD9UdbDnpW9AE4X4djEC+UhXQVvdIarhih/8UD1Iz+X0K7Kqm97U6k AAeGxr68Lbm/bu7ZM3UZT+i9hoPk3jc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=NxoOPgabpGYEA8Hbe1+opothQpA9ihxAQ7OCrVce9 H4=; b=GjMh2xjhq62xou9+98otjnN6N5Ppn27UhMpwT3pZS1ykOrA7P1QXfP5vI u76qqrg907SFanA5ZmDhqHFSYYu3zUbNtKWXAonLNMbwlBPl/tb5BjI5LepGLcZ1 jxmsuQz8cQCSM9CfRA2z84UikQCWjp+tLFtTd75WTYzi+DOzfv6T3kZCnwxFuiG4 bYPJ6X0uxo7szpE82DgaOka2Pgjh/CqS57pP6KI0xPyF6pHi3sAt5kH6dsmxJGsc OL/rsx91HP/N4l+1OK6gdF2IW38oU9qm3yTIVyEfqA/tZaYgCY54OWVR2C0CjCG1 xzg96Tq4+XwW27/CMR25GLFe4cAuw== X-ME-Sender: X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id B72D0102D5; Wed, 17 Oct 2018 05:41:50 -0400 (EDT) From: Thomas Monjalon To: Kevin Laatz Cc: dev@dpdk.org, harry.van.haaren@intel.com, stephen@networkplumber.org, gaetan.rivet@6wind.com, shreyansh.jain@nxp.com, mattias.ronnblom@ericsson.com, bruce.richardson@intel.com Date: Wed, 17 Oct 2018 11:41:53 +0200 Message-ID: <25255353.InYxgXp6IK@xps> In-Reply-To: <20181016155802.2067-2-kevin.laatz@intel.com> References: <20181011165837.81030-1-kevin.laatz@intel.com> <20181016155802.2067-1-kevin.laatz@intel.com> <20181016155802.2067-2-kevin.laatz@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v5 01/13] eal: add param register infrastructure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2018 09:41:53 -0000 I still think all the wording is incorrect. Please start by describing what is "param", "flag" and "option" in your mind. They are all mentioned in this file. Are you sure rte_param is the right name? 16/10/2018 17:57, Kevin Laatz: > --- /dev/null > +++ b/lib/librte_eal/common/include/rte_param.h > @@ -0,0 +1,91 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation. > + */ > + > +#ifndef __INCLUDE_RTE_PARAM_H__ > +#define __INCLUDE_RTE_PARAM_H__ > + > +/** > + * @file > + * > + * This API introduces the ability to register callbacks with EAL. When > + * registering a callback, the application also provides an option as part > + * of the struct used to register. If the option is passed to EAL when > + * running a DPDK application, the relevant callback will be called at the > + * end of EAL init. For example, passing --telemetry will make the > + * telemetry init be called at the end of EAL init. > + * > + * The register API can be used to resolve circular dependency issues > + * between EAL and the library. The library uses EAL but is also initialized by > + * EAL. Hence, EAL depends on the init function of the library. The API > + * introduced in rte_param allows us to register the library init with EAL > + * (passing a function pointer) and avoid the circular dependency. > + */ > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +typedef int (*rte_param_cb)(void); > + > +/* > + * Structure containing parameters relating to the function being registered > + * with EAL. > + */ > +struct rte_param { > + TAILQ_ENTRY(rte_param) next; /** The next entry in the TAILQ*/ > + char *eal_option; /** The EAL option */ > + rte_param_cb cb; /** Function pointer of the callback */ > + > + /** > + * Enabled flag, should be 0 by default. This is set when the option > + * for the callback is passed to EAL and determines if the callback is > + * called or not. > + */ > + int enabled; > +}; > + > +/** > + * @internal Check if the passed option is valid > + * > + * @param option > + * The option to be parsed > + * > + * @return > + * 0 on success > + * @return > + * -1 on fail > + */ > +int > +rte_param_parse(char *option); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Register a function with EAL. Registering the function will enable the > + * function to be called at the end of EAL init. > + * > + * @param reg_param > + * Structure containing various params used to register the function. > + */ > +void __rte_experimental > +rte_param_register(struct rte_param *reg_param); > + > +/** > + * @internal Iterate through the registered params and call the callback for > + * the enabled ones. > + * > + * @return > + * 0 on success > + * @return > + * -1 on fail > + */ > +int > +rte_param_init(void); > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif [...] > --- /dev/null > +++ b/lib/librte_eal/common/rte_param.c > @@ -0,0 +1,47 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation. > + */ > + > +#include > +#include > + > +#include > +#include > + > +TAILQ_HEAD(rte_param_list, rte_param); > + > +struct rte_param_list rte_param_list = > + TAILQ_HEAD_INITIALIZER(rte_param_list); > + > +static struct rte_param *param; > + > +int > +rte_param_parse(char *option) > +{ > + /* Check if the option is in the registered inits */ > + TAILQ_FOREACH(param, &rte_param_list, next) { > + if (strcmp(option, param->eal_option) == 0) { > + param->enabled = 1; > + return 0; > + } > + } > + > + return -1; > +} > + > +void __rte_experimental > +rte_param_register(struct rte_param *reg_param) > +{ > + TAILQ_INSERT_HEAD(&rte_param_list, reg_param, next); > +} > + > +int > +rte_param_init(void) > +{ > + TAILQ_FOREACH(param, &rte_param_list, next) { > + if (param->enabled) > + param->cb(); > + } > + > + return 0; > +}