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 249BC1B023 for ; Thu, 28 Dec 2017 05:56:13 +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 vBS4uBbx025235 for unknown; Thu, 28 Dec 2017 13:56:11 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id vBS4u9kk027471 for unknown; Thu, 28 Dec 2017 13:56:09 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id PAA27455; Thu, 28 Dec 2017 13:56:09 +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 vBS4u8oO011201 for unknown; Thu, 28 Dec 2017 13:56:08 +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 vBS4u8fF011163 for unknown; Thu, 28 Dec 2017 13:56:08 +0900 Message-Id: <201712280456.vBS4u8fF011163@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id vBS4u4bU025622 ; Thu, 28 Dec 2017 13:56:07 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Thu, 28 Dec 2017 13:56:03 +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> X-TM-AS-MML: No Subject: [spp] [PATCH 56/57] spp_vf: fix status 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:15 -0000 From: Hiroyuki Nakamura Fix to display "unuse" even when the core is unused. Signed-off-by: Kentaro Watanabe Signed-off-by: Yasufum Ogawa --- src/vf/command_proc.c | 33 ++++++++++++++++++++------------- src/vf/spp_vf.c | 28 +++++++++++++++++++++------- src/vf/spp_vf.h | 1 + 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c index 6159e87..ec2da51 100644 --- a/src/vf/command_proc.c +++ b/src/vf/command_proc.c @@ -349,6 +349,7 @@ append_core_element_value( const int num_tx, const struct spp_port_index *tx_ports) { int ret = -1; + int unuse_flg = 0; json_t *parent_obj = (json_t *)opaque; json_t *tab_obj; @@ -356,16 +357,20 @@ append_core_element_value( if (unlikely(tab_obj == NULL)) return -1; + unuse_flg = strcmp(type, SPP_TYPE_UNUSE_STR); + ret = json_object_set_new(tab_obj, "core", json_integer(lcore_id)); if (unlikely(ret != 0)) { json_decref(tab_obj); return -1; } - ret = json_object_set_new(tab_obj, "name", json_string(name)); - if (unlikely(ret != 0)) { - json_decref(tab_obj); - return -1; + if (unuse_flg) { + ret = json_object_set_new(tab_obj, "name", json_string(name)); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } } ret = json_object_set_new(tab_obj, "type", json_string(type)); @@ -374,16 +379,18 @@ append_core_element_value( return -1; } - ret = apeend_port_array(tab_obj, "rx_port", num_rx, rx_ports); - if (unlikely(ret != 0)) { - json_decref(tab_obj); - return -1; - } + if (unuse_flg) { + ret = apeend_port_array(tab_obj, "rx_port", num_rx, rx_ports); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } - ret = apeend_port_array(tab_obj, "tx_port", num_tx, tx_ports); - if (unlikely(ret != 0)) { - json_decref(tab_obj); - return -1; + ret = apeend_port_array(tab_obj, "tx_port", num_tx, tx_ports); + if (unlikely(ret != 0)) { + json_decref(tab_obj); + return -1; + } } ret = json_array_append_new(parent_obj, tab_obj); diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c index f97c348..7626ba7 100644 --- a/src/vf/spp_vf.c +++ b/src/vf/spp_vf.c @@ -1338,30 +1338,44 @@ int spp_iterate_core_info(struct spp_iterate_core_params *params) { int ret; - int core_cnt, cnt; + int lcore_id, cnt; struct core_info *core = NULL; - for (core_cnt = 0; core_cnt < RTE_MAX_LCORE; core_cnt++) { - if (spp_get_core_status(core_cnt) == SPP_CORE_UNUSE) + RTE_LCORE_FOREACH_SLAVE(lcore_id) { + if (spp_get_core_status(lcore_id) == SPP_CORE_UNUSE) continue; - core = get_core_info(core_cnt); + core = get_core_info(lcore_id); + if (core->num == 0) { + ret = (*params->element_proc)( + params->opaque, lcore_id, + "", SPP_TYPE_UNUSE_STR, + 0, NULL, 0, NULL); + if (unlikely(ret != 0)) { + RTE_LOG(ERR, APP, "Cannot iterate core information. " + "(core = %d, type = %d)\n", + lcore_id, SPP_COMPONENT_UNUSE); + return SPP_RET_NG; + } + continue; + } + for (cnt = 0; cnt < core->num; cnt++) { if (core->type == SPP_COMPONENT_CLASSIFIER_MAC) { ret = spp_classifier_component_info_iterate( - core_cnt, + lcore_id, core->id[cnt], params); } else { ret = spp_forward_core_info_iterate( - core_cnt, + lcore_id, core->id[cnt], params); } if (unlikely(ret != 0)) { RTE_LOG(ERR, APP, "Cannot iterate core information. " "(core = %d, type = %d)\n", - core_cnt, core->type); + lcore_id, core->type); return SPP_RET_NG; } } diff --git a/src/vf/spp_vf.h b/src/vf/spp_vf.h index 9e846ef..ea2baf1 100644 --- a/src/vf/spp_vf.h +++ b/src/vf/spp_vf.h @@ -6,6 +6,7 @@ #define SPP_TYPE_CLASSIFIER_MAC_STR "classifier_mac" #define SPP_TYPE_MERGE_STR "merge" #define SPP_TYPE_FORWARD_STR "forward" +#define SPP_TYPE_UNUSE_STR "unuse" #define SPP_IFTYPE_NIC_STR "phy" #define SPP_IFTYPE_VHOST_STR "vhost" -- 1.9.1