From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id BB8DFA046B for ; Mon, 24 Jun 2019 06:36:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B32ED1BF5B; Mon, 24 Jun 2019 06:36:58 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id C9F641BF5B for ; Mon, 24 Jun 2019 06:36:57 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id j2so6759152pfe.6 for ; Sun, 23 Jun 2019 21:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=p9ZUeGs5xPGDe3VlVhrfYjz1sa++WnCV+3dlqad3mdM=; b=KwQig75hUuijeh1y7Y/sSUyvNoJqMB3cqBvanmTxhmtbGMMnd8UEH+Ffi0V3y5JhOs 4BNTFQCdIt2ZtIhPG2BBlw92PYx1ZFGkrTKjyP5t8y9P7RiJiktHUTbaMsVVskO1BDbs zMdEuuLYc7QK9ZbtCkxSwBChzXFObf4E7NTsZtle3gyneRJ4UzEaQ69uYbFALFqwyoVL IFg98QebdABcBQHMl9BhcM5TG4hNDJvjCsImVd3cdxQ5LTq2PoLb5Q39Y/T7rz2Gls1B fZjcdn+rxbr9QND53d1rC9B3BSCtAOmVJx0LGNlLlK8G3onNTW3Im9RHJn7ia82cLocV whFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=p9ZUeGs5xPGDe3VlVhrfYjz1sa++WnCV+3dlqad3mdM=; b=e/0oBLhFRw8Fwx36YH3gzx69Yj1utNwudIdvb1Rbx3k2jCFoVTHUK++P5mD9h/KIHn +RCBaHZIWvzOLT2N7y4fXO1ZVzztzot8jO8OQUzcVIYFWltjaktEzqc/d0TCHC05+YyH p9Ta8uEhyqRH7arrti6EcylD8WgH6b/YpIGlAeY5oJSpIxvu41Cyndj76ogO31gptTey jE1cjh6XI16BwGbcmyd2ZHQQ/yHOUBeJT4PjLfndv8gRZTtJzalxOFQJZMkfGhcIjV5q BaQMzqm5ElFbrKwbTr/ehfq6Xi/k33zGVKEOJnjQE/DVAOYD4Pp6oZT/Qe9bSPNuzwU7 tFYg== X-Gm-Message-State: APjAAAUJHnMB21vQy57ywgZFPAj6iGjV7XtLP8Npm9RRC6rYANG9tppa t8xsFhNbXGkP4YnHNmMTq6PFyABv X-Google-Smtp-Source: APXvYqwqf8FDgCQzSCzTFplxOsbhL6Ufk16ji3xf9dgGTwWeMHv/V7TOGsP1FpPcw/aH4IWCIfivAA== X-Received: by 2002:a63:cc4e:: with SMTP id q14mr10137468pgi.84.1561351016843; Sun, 23 Jun 2019 21:36:56 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id c10sm9005178pjq.14.2019.06.23.21.36.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jun 2019 21:36:56 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 24 Jun 2019 13:36:11 +0900 Message-Id: <20190624043613.19271-12-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190624043613.19271-1-yasufum.o@gmail.com> References: <20190624043613.19271-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 11/13] shared/sec: move rest of ops in response_info_list X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa This update is to move the rest of operation functions for making command response which is defined in `cmd_runner.c` to `cmd_res_formatter.c`. Signed-off-by: Yasufumi Ogawa --- .../spp_worker_th/cmd_res_formatter.c | 106 +++++++++++++++++ .../spp_worker_th/cmd_res_formatter.h | 4 + .../secondary/spp_worker_th/cmd_runner.c | 108 ------------------ 3 files changed, 110 insertions(+), 108 deletions(-) diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c index 3476580..ab08fcd 100644 --- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c +++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c @@ -52,6 +52,31 @@ struct cmd_response response_result_list[] = { { "", NULL } }; +/** + * List of combination of tag and operator function. It is used to assemble + * a result of command in JSON like as following. + * + * { + * "client-id": 1, + * "ports": ["phy:0", "phy:1", "vhost:0", "ring:0"], + * "components": [ + * { + * "core": 2, + * ... + */ +struct cmd_response response_info_list[] = { + { "client-id", add_client_id }, + { "phy", add_interface }, + { "vhost", add_interface }, + { "ring", add_interface }, + { "master-lcore", add_master_lcore}, + { "core", add_core}, +#ifdef SPP_VF_MODULE + { "classifier_table", add_classifier_table}, +#endif /* SPP_VF_MODULE */ + { "", NULL } +}; + /* append a command result for JSON format */ int append_result_value(const char *name, char **output, void *tmp) @@ -535,6 +560,32 @@ append_command_results_value(const char *name, char **output, return ret; } +/* append a list of status information for JSON format. */ +int +append_info_value(const char *name, char **output) +{ + int ret = SPP_RET_NG; + char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE); + if (unlikely(tmp_buff == NULL)) { + RTE_LOG(ERR, WK_CMD_RES_FMT, + /* TODO(yasufum) refactor no meaning err msg */ + "allocate error. (name = %s)\n", + name); + return SPP_RET_NG; + } + + ret = append_response_list_value(&tmp_buff, + response_info_list, NULL); + if (unlikely(ret < SPP_RET_OK)) { + spp_strbuf_free(tmp_buff); + return SPP_RET_NG; + } + + ret = append_json_block_brackets(output, name, tmp_buff); + spp_strbuf_free(tmp_buff); + return ret; +} + /* Iterate core information to create response to status command */ static int spp_iterate_core_info(struct spp_iterate_core_params *params) @@ -694,3 +745,58 @@ add_core(const char *name, char **output, return ret; } +#ifdef SPP_VF_MODULE +/* Iterate classifier_table to create response to status command */ +static int +_add_classifier_table( + struct spp_iterate_classifier_table_params *params) +{ + int ret; + + ret = add_classifier_table_val(params); + if (unlikely(ret != 0)) { + RTE_LOG(ERR, WK_CMD_RES_FMT, + "Cannot iterate classifier_mac_table.\n"); + return SPP_RET_NG; + } + + return SPP_RET_OK; +} + +/** + * Add entries of classifier table in JSON. Before iterating the entries, + * this function calls several nested functions. + * add_classifier_table() // This function. + * -> _add_classifier_table() // Wrapper and doesn't almost nothing. + * -> add_classifier_table_val() // Setup data and call iterator. + * -> iterate_adding_mac_entry() + */ +int +add_classifier_table(const char *name, char **output, + void *tmp __attribute__ ((unused))) +{ + int ret = SPP_RET_NG; + struct spp_iterate_classifier_table_params itr_params; + char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE); + if (unlikely(tmp_buff == NULL)) { + RTE_LOG(ERR, WK_CMD_RES_FMT, + /* TODO(yasufum) refactor no meaning err msg */ + "allocate error. (name = %s)\n", + name); + return SPP_RET_NG; + } + + itr_params.output = tmp_buff; + itr_params.element_proc = append_classifier_element_value; + + ret = _add_classifier_table(&itr_params); + if (unlikely(ret != SPP_RET_OK)) { + spp_strbuf_free(itr_params.output); + return SPP_RET_NG; + } + + ret = append_json_array_brackets(output, name, itr_params.output); + spp_strbuf_free(itr_params.output); + return ret; +} +#endif /* SPP_VF_MODULE */ diff --git a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h index bc0109c..d9481e3 100644 --- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.h +++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.h @@ -72,6 +72,8 @@ int append_response_list_value(char **output, struct cmd_response *responses, int append_command_results_value(const char *name, char **output, int num, struct cmd_result *results); +int append_info_value(const char *name, char **output); + /** * Operator functions start with prefix `add_` defined in `response_info_list` * of struct `cmd_response` which are for making each of parts of command @@ -89,4 +91,6 @@ int add_master_lcore(const char *name, char **output, int add_core(const char *name, char **output, void *tmp __attribute__ ((unused))); +int add_classifier_table(const char *name, char **output, + void *tmp __attribute__ ((unused))); #endif diff --git a/src/shared/secondary/spp_worker_th/cmd_runner.c b/src/shared/secondary/spp_worker_th/cmd_runner.c index 007d62e..7c4c91c 100644 --- a/src/shared/secondary/spp_worker_th/cmd_runner.c +++ b/src/shared/secondary/spp_worker_th/cmd_runner.c @@ -408,24 +408,6 @@ flush_cmd(void) return ret; } -/* Iterate classifier_table to create response to status command */ -#ifdef SPP_VF_MODULE -static int -_add_classifier_table( - struct spp_iterate_classifier_table_params *params) -{ - int ret; - - ret = add_classifier_table_val(params); - if (unlikely(ret != 0)) { - RTE_LOG(ERR, WK_CMD_RUNNER, "Cannot iterate classifier_mac_table.\n"); - return SPP_RET_NG; - } - - return SPP_RET_OK; -} -#endif /* SPP_VF_MODULE */ - /* Execute one command. */ static int exec_one_cmd(const struct sppwk_cmd_attrs *cmd) @@ -572,96 +554,6 @@ prepare_parse_err_msg(struct cmd_result *results, } } -#ifdef SPP_VF_MODULE -/** - * Add entries of classifier table in JSON. Before iterating the entries, - * this function calls several nested functions. - * add_classifier_table() // This function. - * -> _add_classifier_table() // Wrapper and doesn't almost nothing. - * -> add_classifier_table_val() // Setup data and call iterator. - * -> iterate_adding_mac_entry() - */ -static int -add_classifier_table(const char *name, char **output, - void *tmp __attribute__ ((unused))) -{ - int ret = SPP_RET_NG; - struct spp_iterate_classifier_table_params itr_params; - char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE); - if (unlikely(tmp_buff == NULL)) { - RTE_LOG(ERR, WK_CMD_RUNNER, - /* TODO(yasufum) refactor no meaning err msg */ - "allocate error. (name = %s)\n", - name); - return SPP_RET_NG; - } - - itr_params.output = tmp_buff; - itr_params.element_proc = append_classifier_element_value; - - ret = _add_classifier_table(&itr_params); - if (unlikely(ret != SPP_RET_OK)) { - spp_strbuf_free(itr_params.output); - return SPP_RET_NG; - } - - ret = append_json_array_brackets(output, name, itr_params.output); - spp_strbuf_free(itr_params.output); - return ret; -} -#endif /* SPP_VF_MODULE */ - -/** - * List of combination of tag and operator function. It is used to assemble - * a result of command in JSON like as following. - * - * { - * "client-id": 1, - * "ports": ["phy:0", "phy:1", "vhost:0", "ring:0"], - * "components": [ - * { - * "core": 2, - * ... - */ -struct cmd_response response_info_list[] = { - { "client-id", add_client_id }, - { "phy", add_interface }, - { "vhost", add_interface }, - { "ring", add_interface }, - { "master-lcore", add_master_lcore}, - { "core", add_core}, -#ifdef SPP_VF_MODULE - { "classifier_table", add_classifier_table}, -#endif /* SPP_VF_MODULE */ - { "", NULL } -}; - -/* append a list of status information for JSON format. */ -static int -append_info_value(const char *name, char **output) -{ - int ret = SPP_RET_NG; - char *tmp_buff = spp_strbuf_allocate(CMD_RES_BUF_INIT_SIZE); - if (unlikely(tmp_buff == NULL)) { - RTE_LOG(ERR, WK_CMD_RUNNER, - /* TODO(yasufum) refactor no meaning err msg */ - "allocate error. (name = %s)\n", - name); - return SPP_RET_NG; - } - - ret = append_response_list_value(&tmp_buff, - response_info_list, NULL); - if (unlikely(ret < SPP_RET_OK)) { - spp_strbuf_free(tmp_buff); - return SPP_RET_NG; - } - - ret = append_json_block_brackets(output, name, tmp_buff); - spp_strbuf_free(tmp_buff); - return ret; -} - /* send response for decode error */ static void send_decode_error_response(int *sock, -- 2.17.1