DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	"dev@dpdk.org" <dev@dpdk.org>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Ajit Khaparde <ajit.khaparde@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>,
	John Daley <johndale@cisco.com>,
	Hyong Youb Kim <hyonkim@cisco.com>,
	Yuying Zhang <Yuying.Zhang@intel.com>,
	Beilei Xing <beilei.xing@intel.com>,
	Qiming Yang <qiming.yang@intel.com>,
	Qi Zhang <qi.z.zhang@intel.com>, Wenjun Wu <wenjun1.wu@intel.com>,
	Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: RE: [EXT] Re: [PATCH v3 1/1] ethdev: parsing multiple representor devargs string
Date: Sun, 21 Jan 2024 19:30:08 +0000	[thread overview]
Message-ID: <BN9PR18MB420409D57085867A608D46E9C5762@BN9PR18MB4204.namprd18.prod.outlook.com> (raw)
In-Reply-To: <b890f07e-d9e5-47f7-8097-988ac6e4019b@oktetlabs.ru>

Hi Andrew,

Thanks for the review comments.
Please see responses inline.
Kindly review V4 as well.

> -----Original Message-----


<snip>

> > @@ -459,9 +460,23 @@ eth_dev_devargs_tokenise(struct rte_kvargs
> *arglist, const char *str_in)
> >   			break;
> >
> >   		case 3: /* Parsing list */
> > -			if (*letter == ']')
> > -				state = 2;
> > -			else if (*letter == '\0')
> > +			if (*letter == ']') {
> > +				/* Multiple representor case has ']' dual
> meaning, first end of
> > +				 * individual pfvf list and other end of
> consolidated list of
> > +				 * representors.
> > +				 * Complete multiple representors list to be
> considered as one
> > +				 * pair value.
> > +				 */
> > +				if ((strcmp("representor", pair->key) == 0)
> &&
> > +				    ((*(letter + 2) == 'p' && *(letter + 3) == 'f')
> ||
> 
> Sorry, but it is unclear why it is not out-of-bound access.

Sorry I missed that, added in V4

> 
> > +				     (*(letter + 2) == 'v' && *(letter + 3) == 'f')
> ||
> > +				     (*(letter + 2) == 's' && *(letter + 3) == 'f')
> ||
> 
> may be it is better to use strncmp() instead?.

Yes strncmp can be used but I kept as is for symmetry with other comparisons.
Moreover I needed 2nd and 3rd letter comparison from current position, so just
for ease I kept as is.

> IMHO it is a bit hard to follow
I reworded the comment in V4 to explain the changes, I hope it is making sense now.


> 
> > +				     (*(letter + 2) == 'c' && isdigit(*(letter + 3)))
> ||
> > +				     (*(letter + 2) == '[' && isdigit(*(letter +
> 3)))))
> > +					state = 3;
> > +				else
> > +					state = 2;
> > +			} else if (*letter == '\0')
> >   				return -EINVAL;
> >   			break;
> >   		}
> > @@ -469,16 +484,56 @@ eth_dev_devargs_tokenise(struct rte_kvargs
> *arglist, const char *str_in)
> >   	}
> >   }
> >
> > +static int
> > +eth_dev_tokenise_representor_list(char *p_val, struct rte_eth_devargs
> *eth_devargs,
> > +				  uint8_t nb_da)
> > +{
> > +	struct rte_eth_devargs *eth_da;
> > +	char da_val[BUFSIZ];
> > +	char delim[] = "]";
> > +	int devargs = 0;
> > +	int result = 0;
> > +	char *token;
> > +
> > +	token = strtok(&p_val[1], delim);
> 
> since strtok() is MT-unsafe, I'd recommend to use strtok_r()

Thanks, changed in V4

> 
> > +	while (token != NULL) {
> > +		eth_da = &eth_devargs[devargs];
> > +		memset(eth_da, 0, sizeof(*eth_da));
> > +		snprintf(da_val, BUFSIZ, "%s%c", (token[0] == ',') ? ++token :
> token, ']');
> > +		/* Parse the tokenised devarg value */
> > +		result = rte_eth_devargs_parse_representor_ports(da_val,
> eth_da);
> > +		if (result < 0)
> > +			goto parse_cleanup;
> > +		devargs++;
> > +		if (devargs > nb_da) {
> > +			RTE_ETHDEV_LOG_LINE(ERR,
> > +					    "Devargs parsed %d > max array
> size %d",
> > +					    devargs, nb_da);
> > +			result = -1;
> > +			goto parse_cleanup;
> > +		}
> > +		token = strtok(NULL, delim);
> > +	}
> > +
> > +	result = devargs;
> > +
> > +parse_cleanup:
> > +	return result;
> > +
> > +}
> > +
> >   int
> > -rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs
> > *eth_da)
> > +rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs
> *eth_devargs,
> > +		      uint8_t nb_da)
> 
> I see no single reason to limit nb_da to uint8_t type. IMHO it should be
> 'unsigned int' as an unsigned number of default type.
> 'unsigned int' is used for number of stats and ptypes in array.

Ack, changed in V4

Thanks
Harman

> 
> [snip]

  reply	other threads:[~2024-01-21 19:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11  6:44 [PATCH 0/2] multiple representors in one device Harman Kalra
2024-01-11  6:44 ` [PATCH 1/2] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-12  7:25   ` Andrew Rybchenko
2024-01-12  9:37     ` [EXT] " Harman Kalra
2024-01-12 12:42   ` David Marchand
2024-01-15 16:01     ` [EXT] " Harman Kalra
2024-01-11  6:44 ` [PATCH 2/2] doc: multiple representors in one device Harman Kalra
2024-01-12  7:26   ` Andrew Rybchenko
2024-01-15 16:01     ` [EXT] " Harman Kalra
2024-01-15 15:57 ` [PATCH v2 0/1] " Harman Kalra
2024-01-15 15:57   ` [PATCH v2 1/1] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-16  9:55 ` [PATCH v3 0/1] multiple representors in one device Harman Kalra
2024-01-16  9:55   ` [PATCH v3 1/1] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-17  8:47     ` Andrew Rybchenko
2024-01-21 19:30       ` Harman Kalra [this message]
2024-01-21 19:19 ` [PATCH v4 0/1] multiple representors in one device Harman Kalra
2024-01-21 19:19   ` [PATCH v4 1/1] ethdev: parsing multiple representor devargs string Harman Kalra
2024-01-22  1:13     ` Chaoyong He
2024-01-22  9:07       ` Harman Kalra
2024-01-22 10:10         ` Chaoyong He
2024-01-25  5:28     ` Harman Kalra
2024-01-26 13:43     ` Ferruh Yigit
2024-01-29 18:20       ` [EXT] " Harman Kalra
2024-01-30 23:09         ` Ferruh Yigit
2024-02-01 10:10           ` Harman Kalra
2024-02-01 10:02 ` [PATCH v5 0/2] multiple representors in one device Harman Kalra
2024-02-01 10:02   ` [PATCH v5 1/2] ethdev: parsing multiple representor devargs string Harman Kalra
2024-02-01 10:02   ` [PATCH v5 2/2] test/devargs: add eth devargs parse cases Harman Kalra
2024-02-01 18:35   ` [PATCH v5 0/2] multiple representors in one device Ferruh Yigit

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=BN9PR18MB420409D57085867A608D46E9C5762@BN9PR18MB4204.namprd18.prod.outlook.com \
    --to=hkalra@marvell.com \
    --cc=Yuying.Zhang@intel.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=beilei.xing@intel.com \
    --cc=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=ferruh.yigit@amd.com \
    --cc=hyonkim@cisco.com \
    --cc=johndale@cisco.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    --cc=wenjun1.wu@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).