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 76F42378E for ; Mon, 30 Jul 2018 07:12:01 +0200 (CEST) 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 w6U5BxjZ003884; Mon, 30 Jul 2018 14:11:59 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id w6U5BwnT017313; Mon, 30 Jul 2018 14:11:58 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id QAA16631; Mon, 30 Jul 2018 14:10:51 +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 w6U5ApP7010224; Mon, 30 Jul 2018 14:10:51 +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 w6U5AoRU010221; Mon, 30 Jul 2018 14:10:50 +0900 Message-Id: <201807300510.w6U5AoRU010221@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id w6U5AoS7008102 ; Mon, 30 Jul 2018 14:10:50 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Cc: spp@dpdk.org Date: Mon, 30 Jul 2018 14:10:50 +0900 X-Mailer: git-send-email 2.18.0 X-TM-AS-MML: No Subject: [spp] [PATCH] spp_vf: fix unexpected tx port is shown in status 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: Mon, 30 Jul 2018 05:12:03 -0000 From: Hideyuki Yamashita Unexpected tx port is shown without adding it because of bug of status command. Here is an example. spp > sec 1;component start fwd1 12 forward spp > sec 1;port add ring:0 rx fwd1 spp > sec 1;flush spp > sec 1;status { "results": [ { "result": "success" } ],"info": { "client-id": 2, ... "tx_port": [ { "port": "phy:0", "vlan": { "operation": # Here ... It is because status command wrongly assumes the number of tx port is equal to rx if the number of rx port is greater than zero. To fix the problem, add 'num_tx' in struct forward_path to hold the number exactly. Signed-off-by: Hideyuki Yamashita Signed-off-by: Naoki Takada --- src/vf/spp_forward.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/vf/spp_forward.c b/src/vf/spp_forward.c index f8bd1d1..0a43608 100644 --- a/src/vf/spp_forward.c +++ b/src/vf/spp_forward.c @@ -21,7 +21,8 @@ struct forward_path { char name[SPP_NAME_STR_LEN]; /* component name */ volatile enum spp_component_type type; /* component type */ - int num; /* number of receive ports */ + int num_rx; /* number of receive ports */ + int num_tx; /* number of trans ports */ struct forward_rxtx ports[RTE_MAX_ETHPORTS]; /* port used for transfer */ }; @@ -93,7 +94,8 @@ spp_forward_update(struct spp_component_info *component) memcpy(&path->name, component->name, SPP_NAME_STR_LEN); path->type = component->type; - path->num = component->num_rx_port; + path->num_rx = component->num_rx_port; + path->num_tx = component->num_tx_port; for (cnt = 0; cnt < num_rx; cnt++) memcpy(&path->ports[cnt].rx, component->rx_ports[cnt], sizeof(struct spp_port_info)); @@ -137,7 +139,7 @@ change_forward_index(int id) int spp_forward(int id) { - int cnt, num, buf; + int cnt, buf; int nb_rx = 0; int nb_tx = 0; struct forward_info *info = &g_forward_info[id]; @@ -148,9 +150,8 @@ spp_forward(int id) change_forward_index(id); path = &info->path[info->ref_index]; - num = path->num; - for (cnt = 0; cnt < num; cnt++) { + for (cnt = 0; cnt < path->num_rx; cnt++) { rx = &path->ports[cnt].rx; tx = &path->ports[cnt].tx; @@ -179,7 +180,7 @@ spp_forward_get_component_status( struct spp_iterate_core_params *params) { int ret = -1; - int cnt, num_tx; + int cnt; const char *component_type = NULL; struct forward_info *info = &g_forward_info[id]; struct forward_path *path = &info->path[info->ref_index]; @@ -199,21 +200,22 @@ spp_forward_get_component_status( component_type = SPP_TYPE_FORWARD_STR; memset(rx_ports, 0x00, sizeof(rx_ports)); - for (cnt = 0; cnt < path->num; cnt++) { + for (cnt = 0; cnt < path->num_rx; cnt++) { rx_ports[cnt].iface_type = path->ports[cnt].rx.iface_type; rx_ports[cnt].iface_no = path->ports[cnt].rx.iface_no; } memset(tx_ports, 0x00, sizeof(tx_ports)); - num_tx = (path->num > 0)?1:0; - tx_ports[0].iface_type = path->ports[0].tx.iface_type; - tx_ports[0].iface_no = path->ports[0].tx.iface_no; + for (cnt = 0; cnt < path->num_tx; cnt++) { + tx_ports[cnt].iface_type = path->ports[cnt].tx.iface_type; + tx_ports[cnt].iface_no = path->ports[cnt].tx.iface_no; + } /* Set the information with the function specified by the command. */ ret = (*params->element_proc)( params, lcore_id, path->name, component_type, - path->num, rx_ports, num_tx, tx_ports); + path->num_rx, rx_ports, path->num_tx, tx_ports); if (unlikely(ret != 0)) return -1; -- 2.18.0