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 AB4AC440A2; Thu, 23 May 2024 08:11:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB57D40696; Thu, 23 May 2024 08:11:28 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by mails.dpdk.org (Postfix) with ESMTP id B86934025C for ; Thu, 23 May 2024 08:11:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716444686; x=1747980686; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=ygidGFgTmkTk1aky5W8Jj/gUd2YYEa8jX0xvd8zmEdc=; b=agCUS33zfQ0b6WPwgKM4DEvRvnLDyBxSFxJNPjHWmYwstComrug+R8rd ex70wVui8i46heNQRRTtb0IQAkpKuboWpRZiaj4AqOe2ndrsVlcx9SspF 6QD78sIE/3D+Mw3T9VyCTDCRBXH2imy6ad1fHiDn83xuCetkNm5T2aiTL 9DCB6GFi8f3vzfBU5VSSkzfv0tVW/g3nT08TBhusIuM/J4RephPOqXVMR j8rWAmTcmkMbk48xOsdO+ZvJDRC1GXNwjJKEubPsIz2vhBzzcgQn3tjVo mgEwK7KgDIiflFi9ZmACuVaKGhLLj+nSG9chhiW0LPIJS6FLMPWT1OetX w==; X-CSE-ConnectionGUID: NbZaTYgiSn++Wom2y8Gayw== X-CSE-MsgGUID: wf6NwPhuSZCHULSUGTPRgQ== X-IronPort-AV: E=McAfee;i="6600,9927,11080"; a="12915591" X-IronPort-AV: E=Sophos;i="6.08,181,1712646000"; d="scan'208";a="12915591" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2024 23:11:24 -0700 X-CSE-ConnectionGUID: 5eM8VbW+QEOBFes5tDmzdA== X-CSE-MsgGUID: INhnF8cXSpGIaUdJ2+/ZUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,181,1712646000"; d="scan'208";a="33534904" Received: from unknown (HELO srv24.iind.intel.com) ([10.138.167.40]) by fmviesa008.fm.intel.com with ESMTP; 22 May 2024 23:11:24 -0700 From: Shaiq Wani To: dev@dpdk.org Subject: [PATCH v2] net/cpfl: get running host ID for CPFL PMD Date: Thu, 23 May 2024 06:10:45 +0000 Message-Id: <20240523061045.483159-1-shaiq.wani@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Check whether CPFL PMD runs on Host or ACC Signed-off-by: Shaiq Wani --- drivers/net/cpfl/cpfl_ethdev.c | 21 +++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.h | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c index ef19aa1b6a..cce7d8251c 100644 --- a/drivers/net/cpfl/cpfl_ethdev.c +++ b/drivers/net/cpfl/cpfl_ethdev.c @@ -14,6 +14,7 @@ #include "cpfl_ethdev.h" #include +#include #include "cpfl_rxtx.h" #include "cpfl_flow.h" #include "cpfl_rules.h" @@ -2269,8 +2270,27 @@ cpfl_repr_allowlist_uninit(struct cpfl_adapter_ext *adapter) { rte_hash_free(adapter->repr_allowlist_hash); } +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) { + PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n"); + return host_id; + } + /* get the first line */ + 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; +} static int cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter, struct cpfl_devargs *devargs) @@ -2289,6 +2309,7 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a hw->vendor_id = pci_dev->id.vendor_id; hw->device_id = pci_dev->id.device_id; hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; + adapter->host_id = get_running_host_id(); strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE); diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h index 457db6d6be..3f6f9ca5ea 100644 --- a/drivers/net/cpfl/cpfl_ethdev.h +++ b/drivers/net/cpfl/cpfl_ethdev.h @@ -66,6 +66,7 @@ #define CPFL_PF_TYPE_NUM 2 #define CPFL_HOST_ID_HOST 0 #define CPFL_HOST_ID_ACC 1 +#define CPFL_INVALID_HOST_ID UINT8_MAX #define CPFL_PF_TYPE_APF 0 #define CPFL_PF_TYPE_CPF 1 @@ -230,6 +231,7 @@ struct cpfl_adapter_ext { uint8_t ctrl_vport_recv_info[IDPF_DFLT_MBX_BUF_SIZE]; struct idpf_ctlq_info *ctlqp[CPFL_CFGQ_NUM]; struct cpfl_ctlq_create_info cfgq_info[CPFL_CFGQ_NUM]; + uint8_t host_id; }; TAILQ_HEAD(cpfl_adapter_list, cpfl_adapter_ext); @@ -296,7 +298,8 @@ cpfl_get_vsi_id(struct cpfl_itf *itf) vport_identity.func_type = CPCHNL2_FTYPE_LAN_PF; /* host: CPFL_HOST0_CPF_ID, acc: CPFL_ACC_CPF_ID */ - vport_identity.pf_id = CPFL_ACC_CPF_ID; + vport_identity.pf_id = (itf->adapter->host_id == CPFL_HOST_ID_ACC) ? + CPFL_ACC_CPF_ID : CPFL_HOST0_CPF_ID; vport_identity.vf_id = 0; vport_identity.vport_id = vport_id; ret = rte_hash_lookup_data(itf->adapter->vport_map_hash, -- 2.34.1