DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Shani Peretz <shperetz@nvidia.com>, dev@dpdk.org
Cc: mkashani@nvidia.com, Ori Kam <orika@nvidia.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Yuying Zhang <yuying.zhang@intel.com>,
	Gregory Etelson <getelson@nvidia.com>
Subject: Re: [PATCH] app/testpmd: fix auto completion for indirect list action
Date: Tue, 19 Mar 2024 14:51:18 +0000	[thread overview]
Message-ID: <62669854-8add-4fdd-b882-a63d78f0d6e8@amd.com> (raw)
In-Reply-To: <20240318092109.87656-1-shperetz@nvidia.com>

On 3/18/2024 9:21 AM, Shani Peretz wrote:
> In the process of auto completion of a command in testpmd,
> the parser splits the command into tokens, where each token
> represents an argument and defines a parsing function.
> The parsing function of the indirect_list action argument was returning
> before having the opportunity to handle the argument.
> 

Hi Shani,

I can see a few other handles follows the updated logic, but to
understand more, was the problematic part following:
```
	if (!action)
		return -1;
```

If so why 'action' can be NULL and why need to continue for this case,
can you please help me understand?

Also even if 'action' is NULL, function will return output of
'parse_int()', is this expected?


Thanks,
ferruh

> The fix ensures that the function appropriately handles
> the argument before finishing.
> 
> Fixes: 72a3dec7126f ("ethdev: add indirect flow list action")
> 
> Signed-off-by: Shani Peretz <shperetz@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c | 46 ++++++++++++++++++++-----------------
>  1 file changed, 25 insertions(+), 21 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index fd6c51f72d..60ee9337cf 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -7839,11 +7839,13 @@ static const struct token token_list[] = {
>  		.type = "UNSIGNED",
>  		.help = "unsigned integer value",
>  		.call = parse_indlst_id2ptr,
> +		.comp = comp_none,
>  	},
>  	[INDIRECT_LIST_ACTION_ID2PTR_CONF] = {
>  		.type = "UNSIGNED",
>  		.help = "unsigned integer value",
>  		.call = parse_indlst_id2ptr,
> +		.comp = comp_none,
>  	},
>  	[ACTION_SHARED_INDIRECT] = {
>  		.name = "shared_indirect",
> @@ -11912,34 +11914,36 @@ parse_indlst_id2ptr(struct context *ctx, const struct token *token,
>  	uint32_t id;
>  	int ret;
>  
> -	if (!action)
> -		return -1;
>  	ctx->objdata = 0;
>  	ctx->object = &id;
>  	ctx->objmask = NULL;
>  	ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
> +	ctx->object = action;
>  	if (ret != (int)len)
>  		return ret;
> -	ctx->object = action;
> -	action_conf = (void *)(uintptr_t)action->conf;
> -	action_conf->conf = NULL;
> -	switch (ctx->curr) {
> -	case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
> -	action_conf->handle = (typeof(action_conf->handle))
> -				port_action_handle_get_by_id(ctx->port, id);
> -		if (!action_conf->handle) {
> -			printf("no indirect list handle for id %u\n", id);
> -			return -1;
> +
> +	/* set handle and conf */
> +	if (action) {
> +		action_conf = (void *)(uintptr_t)action->conf;
> +		action_conf->conf = NULL;
> +		switch (ctx->curr) {
> +		case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
> +		action_conf->handle = (typeof(action_conf->handle))
> +					port_action_handle_get_by_id(ctx->port, id);
> +			if (!action_conf->handle) {
> +				printf("no indirect list handle for id %u\n", id);
> +				return -1;
> +			}
> +			break;
> +		case INDIRECT_LIST_ACTION_ID2PTR_CONF:
> +			indlst_conf = indirect_action_list_conf_get(id);
> +			if (!indlst_conf)
> +				return -1;
> +			action_conf->conf = (const void **)indlst_conf->conf;
> +			break;
> +		default:
> +			break;
>  		}
> -		break;
> -	case INDIRECT_LIST_ACTION_ID2PTR_CONF:
> -		indlst_conf = indirect_action_list_conf_get(id);
> -		if (!indlst_conf)
> -			return -1;
> -		action_conf->conf = (const void **)indlst_conf->conf;
> -		break;
> -	default:
> -		break;
>  	}
>  	return ret;
>  }


  reply	other threads:[~2024-03-19 14:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18  9:21 Shani Peretz
2024-03-19 14:51 ` Ferruh Yigit [this message]
2024-03-19 15:29   ` Ferruh Yigit
2024-03-19 17:43     ` Ferruh Yigit
2024-03-20  6:06     ` Gregory Etelson
2024-03-20 10:08       ` Ferruh Yigit
2024-03-20 20:25         ` Patrick Robb
2024-03-23 10:09         ` Gregory Etelson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62669854-8add-4fdd-b882-a63d78f0d6e8@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=getelson@nvidia.com \
    --cc=mkashani@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=shperetz@nvidia.com \
    --cc=yuying.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).