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 171A02BB0 for ; Thu, 28 Dec 2017 05:56:08 +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 vBS4u7cV025110 for unknown; Thu, 28 Dec 2017 13:56:07 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id vBS4u5I3027217 for unknown; Thu, 28 Dec 2017 13:56:05 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id PAA27209; Thu, 28 Dec 2017 13:56:05 +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 vBS4u4fV010932 for unknown; Thu, 28 Dec 2017 13:56:05 +0900 Received: from mgate01.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 vBS4u45e010923 for unknown; Thu, 28 Dec 2017 13:56:04 +0900 Message-Id: <201712280456.vBS4u45e010923@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id vBS4u4ae025622 ; Thu, 28 Dec 2017 13:56:04 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Thu, 28 Dec 2017 13:55:13 +0900 X-Mailer: git-send-email 1.9.1 In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> References: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-MML: No Subject: [spp] [PATCH 06/57] spp_vf: change config format for upd command 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: Thu, 28 Dec 2017 04:56:10 -0000 From: Hiroyuki Nakamura spp_vf supports command for modifying classifier table. * Change the config file format. * Modify code to support the file format change. Signed-off-by: Kentaro Watanabe Signed-off-by: Yasufum Ogawa --- src/vf/spp_config.c | 91 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 13 deletions(-) diff --git a/src/vf/spp_config.c b/src/vf/spp_config.c index a4d8a67..1794e84 100644 --- a/src/vf/spp_config.c +++ b/src/vf/spp_config.c @@ -206,9 +206,8 @@ config_load_classifier_table(const json_t *obj, /* classifier_table用オブジェクト取得 */ json_t *classifier_obj = json_path_get(obj, JSONPATH_CLASSIFIER_TABLE); if (unlikely(classifier_obj == NULL)) { - RTE_LOG(ERR, APP, "Json object get failed. (path = %s)\n", - JSONPATH_CLASSIFIER_TABLE); - return -1; + RTE_LOG(INFO, APP, "No classifier table.\n"); + return 0; } /* name取得 */ @@ -428,6 +427,7 @@ config_set_tx_port(enum spp_core_type type, json_t *obj, struct spp_config_functions *functions, struct spp_config_classifier_table *classifier_table) { + int cnt = 0; struct spp_config_port_info *tmp_tx_port = NULL; char if_str[SPP_CONFIG_STR_LEN]; if ((type == SPP_CONFIG_MERGE) || (type == SPP_CONFIG_FORWARD)) { @@ -454,16 +454,81 @@ config_set_tx_port(enum spp_core_type type, json_t *obj, } } else { /* Classifier */ - int cnt = 0; - functions->num_tx_port = classifier_table->num_table; - struct spp_config_mac_table_element *tmp_mac_table = NULL; - for (cnt = 0; cnt < classifier_table->num_table; cnt++) { - tmp_tx_port = &functions->tx_ports[cnt]; - tmp_mac_table = &classifier_table->mac_tables[cnt]; - - /* MAC振り分けテーブルより設定 */ - tmp_tx_port->if_type = tmp_mac_table->port.if_type; - tmp_tx_port->if_no = tmp_mac_table->port.if_no; + json_t *table_obj = json_path_get(obj, JSONPATH_TX_TABLE); + if (unlikely(table_obj != NULL)) { + /* Classifier Tableから取得 */ + functions->num_tx_port = classifier_table->num_table; + struct spp_config_mac_table_element *tmp_mac_table = NULL; + for (cnt = 0; cnt < classifier_table->num_table; cnt++) { + tmp_tx_port = &functions->tx_ports[cnt]; + tmp_mac_table = &classifier_table->mac_tables[cnt]; + + /* MAC振り分けテーブルより設定 */ + tmp_tx_port->if_type = tmp_mac_table->port.if_type; + tmp_tx_port->if_no = tmp_mac_table->port.if_no; + } + + } + else + { + /* tx_portパラメータより取得 */ + /* 送信ポート用オブジェクト取得 */ + json_t *array_obj = json_path_get(obj, JSONPATH_TX_PORT); + if (unlikely(array_obj == NULL)) { + RTE_LOG(ERR, APP, "Json object get failed. (path = %s, route = classifier)\n", + JSONPATH_TX_PORT); + return -1; + } + + /* 送信ポート用オブジェクトが配列かチェック */ + if (unlikely(!json_is_array(array_obj))) { + RTE_LOG(ERR, APP, "Not an array. (path = %s, route = classifier)\n", + JSONPATH_TX_PORT); + return -1; + } + + /* 受信ポート用オブジェクトの要素数取得 */ + int port_num = json_array_size(array_obj); + if (unlikely(port_num <= 0) || + unlikely(port_num > RTE_MAX_ETHPORTS)) { + RTE_LOG(ERR, APP, "TX port out of range. (path = %s, port = %d, route = classifier)\n", + JSONPATH_TX_PORT, port_num); + return -1; + } + functions->num_tx_port = port_num; + + /* 要素毎にデータ取得 */ + int array_cnt = 0; + for (array_cnt = 0; array_cnt < port_num; array_cnt++) { + tmp_tx_port = &functions->tx_ports[array_cnt]; + + /* 要素取得 */ + json_t *elements_obj = json_array_get(array_obj, array_cnt); + if (unlikely(elements_obj == NULL)) { + RTE_LOG(ERR, APP, + "Element get failed. (No = %d, path = %s, route = classifier)\n", + array_cnt, JSONPATH_TX_PORT); + return -1; + } + + /* String type check */ + if (unlikely(!json_is_string(elements_obj))) { + RTE_LOG(ERR, APP, "Not a string. (path = %s, No = %d, route = classifier)\n", + JSONPATH_TX_PORT, array_cnt); + return -1; + } + strcpy(if_str, json_string_value(elements_obj)); + + /* IF種別とIF番号に分割 */ + int ret_if = config_get_if_info(if_str, &tmp_tx_port->if_type, + &tmp_tx_port->if_no); + if (unlikely(ret_if != 0)) { + RTE_LOG(ERR, APP, + "Interface change failed. (No = %d, port = %s, route = classifier)\n", + array_cnt, if_str); + return -1; + } + } } } -- 1.9.1