From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 81DE01B00B for ; Tue, 16 Jan 2018 06:16:43 +0100 (CET) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id w0G5GgKN007947 for unknown; Tue, 16 Jan 2018 14:16:42 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id w0G5Ggwd025444 for unknown; Tue, 16 Jan 2018 14:16:42 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id QAA25439; Tue, 16 Jan 2018 14:16:42 +0900 Received: from imss03.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id w0G5GfZS009119 for unknown; Tue, 16 Jan 2018 14:16:41 +0900 Received: from mgate02.silk.ntt-tx.co.jp (smtp02.silk.ntt-tx.co.jp [10.107.0.37]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id w0G5GfrO009112 for unknown; Tue, 16 Jan 2018 14:16:41 +0900 Message-Id: <201801160516.w0G5GfrO009112@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate02.silk.ntt-tx.co.jp (unknown) id w0G5Gfwo026680 ; Tue, 16 Jan 2018 14:16:41 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Tue, 16 Jan 2018 14:16:17 +0900 X-Mailer: git-send-email 1.9.1 In-Reply-To: <3e13a243-6c3f-d849-f2f4-67732e5a44cb@intel.com> References: <3e13a243-6c3f-d849-f2f4-67732e5a44cb@intel.com> X-TM-AS-MML: No Subject: [spp] [PATCH 06/30] doc: add config section 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: , X-List-Received-Date: Tue, 16 Jan 2018 05:16:44 -0000 From: Hiroyuki Nakamura Add description for importing json config to explain about how it load config using jansson library. Signed-off-by: Naoki Takada --- docs/spp_vf/spp_vf.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/docs/spp_vf/spp_vf.md b/docs/spp_vf/spp_vf.md index b9ce299..2d06e2e 100644 --- a/docs/spp_vf/spp_vf.md +++ b/docs/spp_vf/spp_vf.md @@ -41,6 +41,78 @@ The following sections provide some explanation of the code. ### Configuration +The config file is imported after rte_eal_init() and initialization +of the application. +spp_config_load_file() is defined in spp_config.c and default file +path SPP_CONFIG_FILE_PATH is defined in its header file.. + + ```c:spp_vf.c + /* set default config file path */ + strcpy(config_file_path, SPP_CONFIG_FILE_PATH); + + unsigned int main_lcore_id = 0xffffffff; + while(1) { + /* Parse dpdk parameters */ + int ret_parse = parse_dpdk_args(argc, argv); + if (unlikely(ret_parse != 0)) { + break; + } + + /* DPDK initialize */ + int ret_dpdk = rte_eal_init(argc, argv); + if (unlikely(ret_dpdk < 0)) { + break; + } + + /* Skip dpdk parameters */ + argc -= ret_dpdk; + argv += ret_dpdk; + + /* Set log level */ + rte_log_set_global_level(RTE_LOG_LEVEL); + + /* Parse application parameters */ + ret_parse = parse_app_args(argc, argv); + if (unlikely(ret_parse != 0)) { + break; + } + + RTE_LOG(INFO, APP, "Load config file(%s)\n", config_file_path); + + /* Load config */ + int ret_config = spp_config_load_file(config_file_path, 0, &g_config); + if (unlikely(ret_config != 0)) { + break; + } + + /* Get core id. */ + main_lcore_id = rte_lcore_id(); + ``` + +spp_config_load_file() uses [jansson]() for parsing JSON. +json_load_file() is a function of jansson to parse raw JSON +file and return json_t object as a result. +In spp_config_load_file(), configuration of classifier table and +resource assignment of threads are loaded into config of spp. + +After importing config, each of threads are launched. + + ```c:spp_vf.c + /* Start thread */ + unsigned int lcore_id = 0; + RTE_LCORE_FOREACH_SLAVE(lcore_id) { + if (g_core_info[lcore_id].type == SPP_CONFIG_CLASSIFIER_MAC) { + rte_eal_remote_launch(spp_classifier_mac_do, + (void *)&g_core_info[lcore_id], + lcore_id); + } else { + rte_eal_remote_launch(spp_forward, + (void *)&g_core_info[lcore_id], + lcore_id); + } + } + ``` + ### Forwarding ### Packet Cloning -- 1.9.1