From: Stephen Hemminger <stephen@networkplumber.org>
To: Shaiq Wani <shaiq.wani@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v2] net/cpfl: get running host ID for CPFL PMD
Date: Thu, 23 May 2024 07:52:36 -0700 [thread overview]
Message-ID: <20240523075236.0a0e4431@hermes.local> (raw)
In-Reply-To: <20240523061045.483159-1-shaiq.wani@intel.com>
On Thu, 23 May 2024 06:10:45 +0000
Shaiq Wani <shaiq.wani@intel.com> wrote:
> +static uint8_t
> +get_running_host_id(void)
> +{
> + struct utsname unameData;
> + uint8_t host_id = CPFL_INVALID_HOST_ID;
> + uname(&unameData);
>
> + if (uname(&unameData) != 0) {
Why do it twice?
> + PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
> + return host_id;
> + }
> + /* get the first line */
> + if (strstr(unameData.nodename, "ipu_imc"))
Indentation is off.
> + PMD_INIT_LOG(ERR, "CPFL PMD cannot be running on IMC.");
> + else if (strstr(unameData.nodename, "ipu_acc"))
> + host_id = CPFL_HOST_ID_ACC;
> + else
> + host_id = CPFL_HOST_ID_HOST;
>
> + return host_id;
You could change this to be one string of ifs as:
+static uint8_t
+get_running_host_id(void)
+{
+ struct utsname unameData;
+ uint8_t host_id = CPFL_INVALID_HOST_ID;
+
+ if (uname(&unameData) != 0)
+ PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
+ else if (strstr(unameData.nodename, "ipu_imc"))
+ PMD_INIT_LOG(ERR, "CPFL PMD cannot be running on IMC.");
+ else if (strstr(unameData.nodename, "ipu_acc"))
+ host_id = CPFL_HOST_ID_ACC;
+ else
+ host_id = CPFL_HOST_ID_HOST;
+ return host_id;
+}
prev parent reply other threads:[~2024-05-23 14:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 6:10 Shaiq Wani
2024-05-23 14:52 ` Stephen Hemminger [this message]
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=20240523075236.0a0e4431@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=shaiq.wani@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).