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 D75FFA046B for ; Mon, 24 Jun 2019 09:10:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CFE6C1BCAC; Mon, 24 Jun 2019 09:10:44 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 290C41BCAC for ; Mon, 24 Jun 2019 09:10:43 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id g4so6332321plb.5 for ; Mon, 24 Jun 2019 00:10:43 -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=8eWOapYgsfDaV6w3mq1n/jOd0+PsYXJ6BfgaPt1p0cE=; b=YNUJuZIK59/GMnRcJ5J6HuLH9MPZ5Uzt0o4yeTKdz4YFijjngh+zUw74WB79cLu/n9 6j2Y7I4ymQIKCqlivjOai6OkUHRi5E6M/AT5fHDjtn2bpUgTUVuSYT7TZaCoUI/e/JNi SzBnUXAo0mikg8xMOGUUBuDE4rBfsD2JoTS/I8jsz/WfTNSM4Gq66np6s2lWB9yMN+bb 8rJEv7fr0qZtaqzfWAS88DRArdiQDJ7OHro5borJdZJPd4Qa2C2Y3bcgZq4K0T66AufK 2A6e5hslp85DPA5pXkj62f3SsFfPPBFrSQoY9klw0JHYJeWoQkCwbFNVnfpl0IXP9Luw XbaA== 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=8eWOapYgsfDaV6w3mq1n/jOd0+PsYXJ6BfgaPt1p0cE=; b=ecqGgEs8UyTsnTLV2nFkOmyBkLK2Vyhrh9jgR5tB9mu3KOJWUQTKcaBRdn1IHIv/oI dPWZe5aQKlE+a1jG2oOe2fiRqP1FQZCSrZ5c8FM/3LO+3wWJh92L7VSmtVyDaVZcxbDO vEQwIU0NcFpS7KYU0ry19//Up/dCrghx8b0IrV9BZD4SC7JOHi5GIgZrRoPD4XHG5mJD Jld4Lzre4RSn6Zn6sHa3CSfj/55VWAQMzrNxMVdKXrUk14i76XUQkbFZoOukC3y4Pls/ HYlNPzwFXyR6tmSBnJnEfyGK4mn05K+CNKPpnfOjOfTkb0Qjx+U2xRIiEIqI7vU3bn4/ 6tfw== X-Gm-Message-State: APjAAAXy8IspcX5ihalo0/PZSNql1KwtGvr7XOEJyanJLg0ECcUx0y4J ae6E9wHvAnmheVh7UY23UaohSzcx X-Google-Smtp-Source: APXvYqxDPFMfM69GZeIInnCGxhEgt0/skKxnEsOqkNFoF7BLdj/KlpFreY6jGClikwJHfh7LR6h/Kg== X-Received: by 2002:a17:902:7581:: with SMTP id j1mr145527609pll.23.1561360242294; Mon, 24 Jun 2019 00:10:42 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id 128sm10928965pfd.66.2019.06.24.00.10.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 00:10:41 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 24 Jun 2019 16:10:26 +0900 Message-Id: <20190624071026.23286-3-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190624071026.23286-1-yasufum.o@gmail.com> References: <20190624071026.23286-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 2/2] shared/sec: move func add_classifier_table 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 add_classifier_table() from shared dir to `classifier_mac.c` because this functions is not shared function. Signed-off-by: Yasufumi Ogawa --- .../spp_worker_th/cmd_res_formatter.c | 55 ------------------ src/shared/secondary/spp_worker_th/vf_deps.h | 9 +++ src/vf/classifier_mac.c | 57 +++++++++++++++++++ src/vf/vf_cmd_runner.c | 1 - 4 files changed, 66 insertions(+), 56 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 a0c22d2..e4912d6 100644 --- a/src/shared/secondary/spp_worker_th/cmd_res_formatter.c +++ b/src/shared/secondary/spp_worker_th/cmd_res_formatter.c @@ -615,58 +615,3 @@ add_master_lcore(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/vf_deps.h b/src/shared/secondary/spp_worker_th/vf_deps.h index 7d77e87..72a6960 100644 --- a/src/shared/secondary/spp_worker_th/vf_deps.h +++ b/src/shared/secondary/spp_worker_th/vf_deps.h @@ -100,6 +100,15 @@ int add_classifier_table_val( */ int update_comp_info(struct sppwk_comp_info *p_comp_info, int *p_change_comp); +int append_classifier_element_value( + struct spp_iterate_classifier_table_params *params, + enum spp_classifier_type type, + int vid, const char *mac, + const struct sppwk_port_idx *port); + +int add_classifier_table(const char *name, char **output, + void *tmp __attribute__ ((unused))); + enum sppwk_worker_type get_comp_type_from_str(const char *type_str); #endif /* _SPPWK_TH_VF_DEPS_H_ */ diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c index 6d8e664..4387fd5 100644 --- a/src/vf/classifier_mac.c +++ b/src/vf/classifier_mac.c @@ -24,6 +24,9 @@ #include "classifier_mac.h" #include "spp_vf.h" #include "shared/secondary/return_codes.h" +#include "shared/secondary/string_buffer.h" +#include "shared/secondary/json_helper.h" +#include "shared/secondary/spp_worker_th/cmd_res_formatter.h" #include "shared/secondary/spp_worker_th/vf_deps.h" #include "shared/secondary/spp_worker_th/spp_port.h" @@ -956,3 +959,57 @@ add_classifier_table_val( return SPP_RET_OK; } + +/* 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, SPP_CLASSIFIER_MAC, + "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, SPP_CLASSIFIER_MAC, + /* 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; +} diff --git a/src/vf/vf_cmd_runner.c b/src/vf/vf_cmd_runner.c index ecb36ff..4c75b7e 100644 --- a/src/vf/vf_cmd_runner.c +++ b/src/vf/vf_cmd_runner.c @@ -5,7 +5,6 @@ #include "classifier_mac.h" #include "spp_forward.h" #include "shared/secondary/return_codes.h" -#include "shared/secondary/string_buffer.h" #include "shared/secondary/json_helper.h" #include "shared/secondary/spp_worker_th/cmd_parser.h" #include "shared/secondary/spp_worker_th/cmd_runner.h" -- 2.17.1