From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 859F9A00C5;
	Thu, 30 Apr 2020 18:05:43 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 4F6081DC3D;
	Thu, 30 Apr 2020 18:02:43 +0200 (CEST)
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by dpdk.org (Postfix) with ESMTP id 9BFE41DC30
 for <dev@dpdk.org>; Thu, 30 Apr 2020 18:02:38 +0200 (CEST)
IronPort-SDR: y3WtJ7a9tcgcgyrRWwOsA42z/ChbdFcFFX3tcwj/eP2JX39w/xXavQVacYnDHaLgsLY7zhZpIv
 O04XEITS7pfg==
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 30 Apr 2020 09:02:38 -0700
IronPort-SDR: SAcS7AdeRtwLObqk4cW3o/DdynF1xpARFM6xU0aSnWYZ9V0bllLdfC+6nw9cduBKyLbai3xChb
 SIRGhBDBLybg==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.73,336,1583222400"; d="scan'208";a="258345367"
Received: from silpixa00399953.ir.intel.com (HELO
 silpixa00399953.ger.corp.intel.com) ([10.237.222.53])
 by orsmga003.jf.intel.com with ESMTP; 30 Apr 2020 09:02:35 -0700
From: Ciara Power <ciara.power@intel.com>
To: dev@dpdk.org,
	kevin.laatz@intel.com
Cc: reshma.pattan@intel.com, jerinjacobk@gmail.com, david.marchand@redhat.com,
 keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net,
 stephen@networkplumber.org, bluca@debian.org,
 Ciara Power <ciara.power@intel.com>
Date: Thu, 30 Apr 2020 17:01:35 +0100
Message-Id: <20200430160137.59135-17-ciara.power@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200430160137.59135-1-ciara.power@intel.com>
References: <20200319171907.60891-1-ciara.power@intel.com>
 <20200430160137.59135-1-ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH v5 16/18] eal: remove rte-option infrastructure
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

As Telemetry no longer uses rte_option, and was the only user of this
infrastructure, it can now be removed.

Signed-off-by: Ciara Power <ciara.power@intel.com>
Reviewed-by: Keith Wiles <keith.wiles@intel.com>
---
 lib/librte_eal/common/eal_common_options.c |  1 -
 lib/librte_eal/common/eal_private.h        | 28 -------
 lib/librte_eal/common/meson.build          |  2 -
 lib/librte_eal/common/rte_option.c         | 95 ----------------------
 lib/librte_eal/freebsd/Makefile            |  1 -
 lib/librte_eal/freebsd/eal.c               | 14 +---
 lib/librte_eal/include/meson.build         |  1 -
 lib/librte_eal/include/rte_option.h        | 72 ----------------
 lib/librte_eal/linux/Makefile              |  1 -
 lib/librte_eal/linux/eal.c                 | 14 +---
 lib/librte_eal/rte_eal_version.map         |  1 -
 11 files changed, 2 insertions(+), 228 deletions(-)
 delete mode 100644 lib/librte_eal/common/rte_option.c
 delete mode 100644 lib/librte_eal/include/rte_option.h

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f44d147b4e..baaf8767eb 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -1785,5 +1785,4 @@ eal_common_usage(void)
 	       "  --"OPT_NO_HPET"           Disable HPET\n"
 	       "  --"OPT_NO_SHCONF"         No shared config (mmap'd files)\n"
 	       "\n", RTE_MAX_LCORE);
-	rte_option_usage();
 }
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index ecf827914f..869ce183ad 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -409,34 +409,6 @@ dev_sigbus_handler_register(void);
 int
 dev_sigbus_handler_unregister(void);
 
-/**
- * Check if the option is registered.
- *
- * @param option
- *  The option to be parsed.
- *
- * @return
- *  0 on success
- * @return
- *  -1 on fail
- */
-int
-rte_option_parse(const char *opt);
-
-/**
- * Iterate through the registered options and execute the associated
- * callback if enabled.
- */
-void
-rte_option_init(void);
-
-/**
- * Iterate through the registered options and show the associated
- * usage string.
- */
-void
-rte_option_usage(void);
-
 /**
  * Get OS-specific EAL mapping base address.
  */
diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build
index 155da29b4e..55aaeb18e1 100644
--- a/lib/librte_eal/common/meson.build
+++ b/lib/librte_eal/common/meson.build
@@ -14,7 +14,6 @@ if is_windows
 		'eal_common_log.c',
 		'eal_common_options.c',
 		'eal_common_thread.c',
-		'rte_option.c',
 	)
 	subdir_done()
 endif
@@ -53,7 +52,6 @@ sources += files(
 	'malloc_mp.c',
 	'rte_keepalive.c',
 	'rte_malloc.c',
-	'rte_option.c',
 	'rte_random.c',
 	'rte_reciprocal.c',
 	'rte_service.c',
diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c
deleted file mode 100644
index 6f8bd6e64c..0000000000
--- a/lib/librte_eal/common/rte_option.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018 Intel Corporation.
- */
-
-#include <getopt.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <rte_eal.h>
-#include <rte_option.h>
-
-#include "eal_private.h"
-#include "eal_internal_cfg.h" /* Necessary for eal_options.h */
-#include "eal_options.h"
-
-TAILQ_HEAD(rte_option_list, rte_option);
-
-struct rte_option_list rte_option_list =
-	TAILQ_HEAD_INITIALIZER(rte_option_list);
-
-int
-rte_option_parse(const char *opt)
-{
-	struct rte_option *option;
-
-	if (strlen(opt) <= 2 ||
-	    strncmp(opt, "--", 2))
-		return -1;
-
-	/* Check if the option is registered */
-	TAILQ_FOREACH(option, &rte_option_list, next) {
-		if (strcmp(&opt[2], option->name) == 0) {
-			option->enabled = 1;
-			return 0;
-		}
-	}
-
-	return -1;
-}
-
-int
-rte_option_register(struct rte_option *opt)
-{
-	struct rte_option *option;
-	const struct option *gopt;
-
-	gopt = &eal_long_options[0];
-	while (gopt->name != NULL) {
-		if (strcmp(gopt->name, opt->name) == 0) {
-			RTE_LOG(ERR, EAL, "Option %s is already a common EAL option.\n",
-					opt->name);
-			return -1;
-		}
-		gopt++;
-	}
-
-	TAILQ_FOREACH(option, &rte_option_list, next) {
-		if (strcmp(opt->name, option->name) == 0) {
-			RTE_LOG(ERR, EAL, "Option %s has already been registered.\n",
-					opt->name);
-			return -1;
-		}
-	}
-
-	TAILQ_INSERT_HEAD(&rte_option_list, opt, next);
-	return 0;
-}
-
-void
-rte_option_init(void)
-{
-	struct rte_option *option;
-
-	TAILQ_FOREACH(option, &rte_option_list, next) {
-		if (option->enabled)
-			option->cb();
-	}
-}
-
-void
-rte_option_usage(void)
-{
-	struct rte_option *option;
-	int opt_count = 0;
-
-	TAILQ_FOREACH(option, &rte_option_list, next)
-		opt_count += 1;
-	if (opt_count == 0)
-		return;
-
-	printf("EAL dynamic options:\n");
-	TAILQ_FOREACH(option, &rte_option_list, next)
-		printf("  --%-*s %s\n", 17, option->name, option->usage);
-	printf("\n");
-}
diff --git a/lib/librte_eal/freebsd/Makefile b/lib/librte_eal/freebsd/Makefile
index e95728e740..af95386d48 100644
--- a/lib/librte_eal/freebsd/Makefile
+++ b/lib/librte_eal/freebsd/Makefile
@@ -70,7 +70,6 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_elem.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_heap.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += malloc_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_keepalive.c
-SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_option.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_service.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_random.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += rte_reciprocal.c
diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c
index bc86dccc27..2379a94e8c 100644
--- a/lib/librte_eal/freebsd/eal.c
+++ b/lib/librte_eal/freebsd/eal.c
@@ -41,7 +41,6 @@
 #include <rte_devargs.h>
 #include <rte_version.h>
 #include <rte_vfio.h>
-#include <rte_option.h>
 #include <rte_atomic.h>
 #include <malloc_heap.h>
 #include <rte_telemetry.h>
@@ -537,20 +536,12 @@ eal_parse_args(int argc, char **argv)
 	argvopt = argv;
 	optind = 1;
 	optreset = 1;
-	opterr = 0;
 
 	while ((opt = getopt_long(argc, argvopt, eal_short_options,
 				  eal_long_options, &option_index)) != EOF) {
 
-		/*
-		 * getopt didn't recognise the option, lets parse the
-		 * registered options to see if the flag is valid
-		 */
+		/* getopt didn't recognise the option */
 		if (opt == '?') {
-			ret = rte_option_parse(argv[optind-1]);
-			if (ret == 0)
-				continue;
-
 			eal_usage(prgname);
 			ret = -1;
 			goto out;
@@ -972,9 +963,6 @@ rte_eal_init(int argc, char **argv)
 
 	eal_mcfg_complete();
 
-	/* Call each registered callback, if enabled */
-	rte_option_init();
-
 	return fctret;
 }
 
diff --git a/lib/librte_eal/include/meson.build b/lib/librte_eal/include/meson.build
index e9537c91f9..22684308d0 100644
--- a/lib/librte_eal/include/meson.build
+++ b/lib/librte_eal/include/meson.build
@@ -30,7 +30,6 @@ headers += files(
 	'rte_malloc.h',
 	'rte_memory.h',
 	'rte_memzone.h',
-	'rte_option.h',
 	'rte_pci_dev_feature_defs.h',
 	'rte_pci_dev_features.h',
 	'rte_per_lcore.h',
diff --git a/lib/librte_eal/include/rte_option.h b/lib/librte_eal/include/rte_option.h
deleted file mode 100644
index 7ad65a4eb4..0000000000
--- a/lib/librte_eal/include/rte_option.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2018 Intel Corporation.
- */
-
-#ifndef __INCLUDE_RTE_OPTION_H__
-#define __INCLUDE_RTE_OPTION_H__
-
-/**
- * @file
- *
- * This API offers the ability to register options to the EAL command line and
- * map those options to functions that will be executed at the end of EAL
- * initialization. These options will be available as part of the EAL command
- * line of applications and are dynamically managed.
- *
- * This is used primarily by DPDK libraries offering command line options.
- * Currently, this API is limited to registering options without argument.
- *
- * 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_option 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_option_cb)(void);
-
-/**
- * Structure describing an EAL command line option dynamically registered.
- *
- * Common EAL options are mostly statically defined.
- * Some libraries need additional options to be dynamically added.
- * This structure describes such options.
- */
-struct rte_option {
-	TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */
-	const char *name; /**< The option name. */
-	const char *usage; /**< Option summary string. */
-	rte_option_cb cb;          /**< Function called when option is used. */
-	int enabled;               /**< Set when the option is used. */
-};
-
-/**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice
- *
- * Register an option to the EAL command line.
- * When recognized, the associated function will be executed at the end of EAL
- * initialization.
- *
- * The associated structure must be available the whole time this option is
- * registered (i.e. not stack memory).
- *
- * @param opt
- *  Structure describing the option to parse.
- *
- * @return
- *  0 on success, <0 otherwise.
- */
-__rte_experimental
-int
-rte_option_register(struct rte_option *opt);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/lib/librte_eal/linux/Makefile b/lib/librte_eal/linux/Makefile
index be57a6d076..48cc34844a 100644
--- a/lib/librte_eal/linux/Makefile
+++ b/lib/librte_eal/linux/Makefile
@@ -77,7 +77,6 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_elem.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_heap.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += malloc_mp.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_keepalive.c
-SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_option.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_service.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_random.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += rte_reciprocal.c
diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c
index e4086c75a9..c30ed57f07 100644
--- a/lib/librte_eal/linux/eal.c
+++ b/lib/librte_eal/linux/eal.c
@@ -50,7 +50,6 @@
 #include <rte_atomic.h>
 #include <malloc_heap.h>
 #include <rte_vfio.h>
-#include <rte_option.h>
 #include <rte_telemetry.h>
 
 #include "eal_private.h"
@@ -701,20 +700,12 @@ eal_parse_args(int argc, char **argv)
 
 	argvopt = argv;
 	optind = 1;
-	opterr = 0;
 
 	while ((opt = getopt_long(argc, argvopt, eal_short_options,
 				  eal_long_options, &option_index)) != EOF) {
 
-		/*
-		 * getopt didn't recognise the option, lets parse the
-		 * registered options to see if the flag is valid
-		 */
+		/* getopt didn't recognise the option */
 		if (opt == '?') {
-			ret = rte_option_parse(argv[optind-1]);
-			if (ret == 0)
-				continue;
-
 			eal_usage(prgname);
 			ret = -1;
 			goto out;
@@ -1310,9 +1301,6 @@ rte_eal_init(int argc, char **argv)
 
 	eal_mcfg_complete();
 
-	/* Call each registered callback, if enabled */
-	rte_option_init();
-
 	return fctret;
 }
 
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 6088e7f6c3..d8038749a4 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -303,7 +303,6 @@ EXPERIMENTAL {
 	rte_memseg_get_fd_offset;
 	rte_memseg_get_fd_offset_thread_unsafe;
 	rte_memseg_get_fd_thread_unsafe;
-	rte_option_register;
 
 	# added in 19.02
 	rte_extmem_attach;
-- 
2.17.1