Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH] spp_vf: fix unexpected tx port is shown in status
@ 2018-07-30  5:10 x-fn-spp
  2018-08-09  2:24 ` Yasufumi Ogawa
  0 siblings, 1 reply; 3+ messages in thread
From: x-fn-spp @ 2018-07-30  5:10 UTC (permalink / raw)
  To: ferruh.yigit, ogawa.yasufumi; +Cc: spp

From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>

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 <yamashita.hideyuki@po.ntt-tx.co.jp>
Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [spp] [PATCH] spp_vf: fix unexpected tx port is shown in status
  2018-07-30  5:10 [spp] [PATCH] spp_vf: fix unexpected tx port is shown in status x-fn-spp
@ 2018-08-09  2:24 ` Yasufumi Ogawa
  2018-08-22  9:37   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Yasufumi Ogawa @ 2018-08-09  2:24 UTC (permalink / raw)
  To: x-fn-spp, ferruh.yigit; +Cc: spp

On 2018/07/30 14:10, x-fn-spp@sl.ntt-tx.co.jp wrote:
> From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
> 
> 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.
Thanks for your update.

Acked-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
> 
> Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
> Signed-off-by: Naoki Takada <takada.naoki@lab.ntt.co.jp>
> ---
>   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;
>   
> 


-- 
Yasufumi Ogawa
NTT Network Service Systems Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [spp] [PATCH] spp_vf: fix unexpected tx port is shown in status
  2018-08-09  2:24 ` Yasufumi Ogawa
@ 2018-08-22  9:37   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2018-08-22  9:37 UTC (permalink / raw)
  To: Yasufumi Ogawa, x-fn-spp; +Cc: spp

On 8/9/2018 3:24 AM, Yasufumi Ogawa wrote:
> On 2018/07/30 14:10, x-fn-spp@sl.ntt-tx.co.jp wrote:
>> From: Hideyuki Yamashita <yamashita.hideyuki@po.ntt-tx.co.jp>
>>
>> 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.
> Thanks for your update.
> 
> Acked-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-22  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30  5:10 [spp] [PATCH] spp_vf: fix unexpected tx port is shown in status x-fn-spp
2018-08-09  2:24 ` Yasufumi Ogawa
2018-08-22  9:37   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).