From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 39996440A7; Thu, 23 May 2024 16:52:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C57AC402B3; Thu, 23 May 2024 16:52:38 +0200 (CEST) Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) by mails.dpdk.org (Postfix) with ESMTP id C0BF04026C for ; Thu, 23 May 2024 16:52:37 +0200 (CEST) Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5b680c1fdd4so1400783eaf.1 for ; Thu, 23 May 2024 07:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1716475957; x=1717080757; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=EXjpKo0qh0f3h+OsdVZrtMGuFbV3cBD50DGNJ01ZHPI=; b=xqB0fsU3BIcFhPiXSgscaaJP0VVRKdBpD8erZ/5DlSuhbIv9mf6JfRv06gW71Ik/+3 eup+hx1hZqEQG/+RCqzBH8tBh2qcoHfWdSiebUIDo56y0B0DhetAPvzainfW1V2lzo78 FNmLJiK/mWmB+kvCFATfeKJvSnrDwY+rc/unmaOmSbtwG8klGZ/5KSmwWR0olpLM925k wn3Yf1n6tPH1nlOJFtUY4R5tbTGliIBc4UvQyiBYeCgnJjPlM2l/VuxZSu7xCtJbIPKj Tk/evxd5Fr3ahMLGbIJ7/pRrabedykL747pbNPzA/FFf1nanivtZ894yzuufI3TEjAv1 o3Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716475957; x=1717080757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EXjpKo0qh0f3h+OsdVZrtMGuFbV3cBD50DGNJ01ZHPI=; b=HJmdgY6xdGuyKvQhGv1sv7DO6P28HXkCc5E/QJ46q6mcgU6F6kEE05b/yLxa+LkSDZ 6dVj4wUdnQXPiD+ZwYMDdSFFl6K68Llj6uC6dryHM/h2vJbpxlEttjiL9vCq27y6aazF l0eo/xNQZhmngt71n0I3tDCqXCG/Cn5pHH8aEmvyA3q9JAv45t1z5hW1v3yOxi8THoG1 pRp1fnA5rBpbU7d6XkIMNz5YFqTJIWgEv2Uah3+skd1ENpWTVL0GMqkYUUgu+oYFVtSC F47NZemdkIcP9HzqT0dEtYyzzau4WB5T3Tl/W6Yf2oJx89CkxnZvWXIh2TeRSjHQJTeq 3Sjw== X-Gm-Message-State: AOJu0Yw+5fR9I36h4PkJ9ho3s+PnukCbv6Ds+6AUqig+cgLD5SXbo5aY R7za4i/I0dzGiOWVt+L9yiBIf/g2b6nyCOSZ6pWO3EmLT5RcgHI2zHLqUB+dGCM= X-Google-Smtp-Source: AGHT+IHwHMhf9ejNxHkzzS/FOXdjCKiKMt2gx3XGh58kmiUtFi12BiC2nMe6XGXOkZl5cHQYMotEWg== X-Received: by 2002:a05:6358:7f19:b0:192:2717:4ed4 with SMTP id e5c5f4694b2df-19791b77a85mr665112055d.19.1716475956689; Thu, 23 May 2024 07:52:36 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-680d3e8c847sm123387a12.34.2024.05.23.07.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 07:52:36 -0700 (PDT) Date: Thu, 23 May 2024 07:52:36 -0700 From: Stephen Hemminger To: Shaiq Wani Cc: dev@dpdk.org Subject: Re: [PATCH v2] net/cpfl: get running host ID for CPFL PMD Message-ID: <20240523075236.0a0e4431@hermes.local> In-Reply-To: <20240523061045.483159-1-shaiq.wani@intel.com> References: <20240523061045.483159-1-shaiq.wani@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, 23 May 2024 06:10:45 +0000 Shaiq Wani 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; +}