From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw0128.ocn.ad.jp (mogw0128.ocn.ad.jp [118.23.109.102]) by dpdk.org (Postfix) with ESMTP id 61D84A499 for ; Tue, 23 Jan 2018 01:28:47 +0100 (CET) Received: from mf-smf-ucb018.ocn.ad.jp (mf-smf-ucb018.ocn.ad.jp [153.149.227.67]) by mogw0128.ocn.ad.jp (Postfix) with ESMTP id 70DD111027C; Tue, 23 Jan 2018 09:28:45 +0900 (JST) Received: from mf-smf-ucb018.ocn.ad.jp (mf-smf-ucb018 [153.149.227.67]) by mf-smf-ucb018.ocn.ad.jp (Postfix) with ESMTP id 5579820629; Tue, 23 Jan 2018 09:28:45 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb019 (mv-mta-ucb019.ocn.ad.jp [153.149.142.82]) by mf-smf-ucb018.ocn.ad.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id w0N0SZWV043770; Tue, 23 Jan 2018 09:28:45 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.133]) by ntt.pod01.mv-mta-ucb019 with id 1cUk1x0072tKTyH01cUk8r; Tue, 23 Jan 2018 00:28:44 +0000 Received: from mugwort.jp (p1247-ipngn8903marunouchi.tokyo.ocn.ne.jp [153.221.64.247]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Tue, 23 Jan 2018 09:28:44 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, x-fn-spp@sl.ntt-tx.co.jp Cc: Hiroyuki Nakamura , Naoki Takada Date: Tue, 23 Jan 2018 09:28:51 +0900 Message-Id: <20180123002854.28345-6-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180123002854.28345-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180123002854.28345-1-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 06/28] 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, 23 Jan 2018 00:28:48 -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 -- 2.13.1