DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: "Zeng, ZhichaoX" <zhichaox.zeng@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH v5] net/ice: support customized search path for DDP package
Date: Fri, 20 Sep 2024 10:04:01 +0100	[thread overview]
Message-ID: <Zu06gdzJIBY0bQFg@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <SJ0PR11MB561351C44139A5B8B0A9A775F16C2@SJ0PR11MB5613.namprd11.prod.outlook.com>

On Fri, Sep 20, 2024 at 09:34:55AM +0100, Zeng, ZhichaoX wrote:
> Hi Bruce, thanks for your reply.
> 
> > -----Original Message-----
> > From: Richardson, Bruce <bruce.richardson@intel.com>
> > Sent: Thursday, September 19, 2024 3:50 PM
> > To: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> > Cc: dev@dpdk.org
> > Subject: Re: [PATCH v5] net/ice: support customized search path for DDP
> > package
> > 
> > On Thu, Sep 19, 2024 at 11:29:34AM +0800, Zhichao Zeng wrote:
> > > This patch adds support for customizing firmware search path for DDP
> > > package like the kernel behavior, it will read the search path from
> > > "/sys/module/firmware_class/parameters/path", and try to load DDP
> > > package.
> > >
> > > Also, updates documentation for loading the DDP package in ice.rst.
> > >
> > > Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> > >
> > > ---
> > > v5: update documentation, fix code logic
> > > v4: fix CI error
> > > v3: update doc, fix code error
> > > v2: separate the patch and rewrite the log
> > > ---
> <snip>
> > > diff --git a/drivers/net/ice/ice_ethdev.c
> > > b/drivers/net/ice/ice_ethdev.c index 304f959b7e..f0389cc4ee 100644
> > > --- a/drivers/net/ice/ice_ethdev.c
> > > +++ b/drivers/net/ice/ice_ethdev.c
> > > @@ -1873,21 +1873,61 @@ ice_load_pkg_type(struct ice_hw *hw)
> > >  	return package_type;
> > >  }
> > >
> > > +static int ice_read_customized_path(char *pkg_file, uint16_t
> > > +buff_len) {
> > > +	FILE *fp = fopen(ICE_PKG_FILE_CUSTOMIZED_PATH, "r");
> > > +	int ret = 0;
> > > +
> > > +	if (fp == NULL) {
> > > +		PMD_INIT_LOG(INFO, "Failed to read CUSTOMIZED_PATH");
> > > +		return -EIO;
> > > +	}
> > > +
> > > +	if (fgets(pkg_file, buff_len, fp) == NULL) {
> > > +		ret = -EIO;
> > > +		goto exit;
> > > +	}
> > > +
> > > +	if (strlen(pkg_file) <= 1)
> > > +		goto exit;
> > > +
> > > +	pkg_file[strlen(pkg_file) - 1] = '\0';
> > 
> > This line is unnecessary and, if it were necessary, also incorrect:
> > * fgets already guarantees to null-terminate
> > * if it didn't null terminate, then strlen wouldn't even work so this
> >   statement would be completely broken.
> > 
> > Also, as this line is unnecessary, the lines above it, and the label below are
> > unnecessary too.
> 
> The string read by fgets ends with "\n", my intention was to remove the newline.
> 

Ah, apologies, my bad. That makes sense now. However, I think it would be
clearer for future readers if this was more explicitly called out. At
minimum use a comment, but even better is an explicit check for a '\n'
before you strip it.

> > > +exit:
> > > +	fclose(fp);
> > > +	return ret;
> > > +}
> > > +
> > >  int ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t
> > > dsn)  {
> > >  	struct ice_hw *hw = &adapter->hw;
> > >  	char pkg_file[ICE_MAX_PKG_FILENAME_SIZE];
> > > +	char customized_path[ICE_MAX_PKG_FILENAME_SIZE];
> > >  	char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE];
> > >  	void *buf;
> > >  	size_t bufsz;
> > >  	int err;
> > >
> > > -	if (!use_dsn)
> > > -		goto no_dsn;
> > > +	ice_read_customized_path(customized_path,
> > > +ICE_MAX_PKG_FILENAME_SIZE);
> > >
> > >  	memset(opt_ddp_filename, 0, ICE_MAX_PKG_FILENAME_SIZE);
> > >  	snprintf(opt_ddp_filename, ICE_MAX_PKG_FILENAME_SIZE,
> > >  		"ice-%016" PRIx64 ".pkg", dsn);
> > > +
> > > +	if (strlen(customized_path) > 1) {
> > 
> > Is this really the best way to check for validity of the search path?
> > I would tend to ignore length and use the return value from the function
> > "ice_read_customized_path". Again, maybe check the logic used in the kernel
> > for validating the path read.
> 
> Will use the return value instead of string length and check the logic in kernel.
> 
> > 
> > > +		if (use_dsn) {
> > > +			snprintf(pkg_file, RTE_DIM(pkg_file),
> > > +				"%s/%s", customized_path,
> > opt_ddp_filename);
> > > +			if (rte_firmware_read(pkg_file, &buf, &bufsz) == 0)
> > > +				goto load_fw;
> > > +		}
> > > +		snprintf(pkg_file, RTE_DIM(pkg_file), "%s/%s",
> > customized_path, "ice.pkg");
> > > +		if (rte_firmware_read(pkg_file, &buf, &bufsz) == 0)
> > > +			goto load_fw;
> > > +	}
> > > +
> > > +	if (!use_dsn)
> > > +		goto no_dsn;
> > > +
> > 
> > This is changing the search path logic compared to v4. Does it match what the
> > kernel does in finding a package?
> > 
> 
> The kernel searches for DDP packages in the CUSTOMIZED_PATH first, then the default path.
> 
Thanks for confirming.

  reply	other threads:[~2024-09-20  9:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28  3:53 [PATCH] net/ice: support for more flexible loading of " Zhichao Zeng
2024-08-28  7:55 ` Bruce Richardson
2024-08-28  8:53   ` Zeng, ZhichaoX
2024-08-29  3:35 ` [PATCH v2] net/ice: support customized search path for " Zhichao Zeng
2024-08-29  3:41 ` Zhichao Zeng
2024-09-09 12:13   ` Bruce Richardson
2024-09-12  7:47   ` [PATCH v3] " Zhichao Zeng
2024-09-12  8:01   ` Zhichao Zeng
2024-09-13  6:15     ` [PATCH v4] " Zhichao Zeng
2024-09-13 10:57       ` Bruce Richardson
2024-09-19  3:29       ` [PATCH v5] " Zhichao Zeng
2024-09-19  7:49         ` Bruce Richardson
2024-09-20  8:34           ` Zeng, ZhichaoX
2024-09-20  9:04             ` Bruce Richardson [this message]
2024-09-20 10:05         ` [PATCH v6] " Zhichao Zeng

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=Zu06gdzJIBY0bQFg@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=zhichaox.zeng@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).