From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8684C49ED7 for ; Fri, 13 Sep 2019 10:53:56 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 48F852084F for ; Fri, 13 Sep 2019 10:53:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48F852084F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C75A1F095; Fri, 13 Sep 2019 12:53:55 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id A25B71F089 for ; Fri, 13 Sep 2019 12:53:53 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2019 03:53:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,492,1559545200"; d="scan'208";a="176250832" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.5]) by orsmga007.jf.intel.com with ESMTP; 13 Sep 2019 03:53:50 -0700 Date: Fri, 13 Sep 2019 18:51:28 +0800 From: Ye Xiaolong To: Ting Xu Cc: dev@dpdk.org, qi.z.zhang@intel.com, john.mcnamara@intel.com, marko.kovacevic@intel.com Message-ID: <20190913105128.GB86692@intel.com> References: <6c47d7e03e43713756e746b3c459798283b13993.1567694027.git.ting.xu@intel.com> <8560c4c7f3547a2a9263a916d03b9f76a1bd9602.1568204462.git.ting.xu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8560c4c7f3547a2a9263a916d03b9f76a1bd9602.1568204462.git.ting.xu@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v6] net/ice: support device-specific DDP package loading X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, Ting On 09/11, Ting Xu wrote: >This patch adds the feature that supports loading DDP package >according to the device serial number. Prior to loading the >default DDP package (ice.pkg), the driver will check for the >presence of a device-specific DDP package with the name containing >64-bit PCIe Device Serial Number (ice-xxxxxxxxxxxxxxxx.pkg) >during initialization. Users can use "lspci -vs" to get the device >serial number. >The pkg search path are /lib/firmware/updates/intel/ice/ddp/ >and /lib/firmware/intel/ice/ddp/. If the package exists, >the driver will download it to the device instead of the default >one. The loaded package type (OS default and COMMS) will be >stored in ice_adapter->active_pkg_type. The package version is >stored in ice_hw->active_pkg_ver. > >Signed-off-by: Ting Xu > >--- >v6: update doc and release note; reduce redundant variables; >change some log levels. >v5: optimize the operation when dsn is not found. >v4: correct the commit message format. >v3: fix compile error; modify to change the pkg loading order. >v2: modify codes according to the comments. >--- > doc/guides/nics/ice.rst | 20 +++- > doc/guides/rel_notes/release_19_11.rst | 5 + > drivers/net/ice/ice_ethdev.c | 134 ++++++++++++++++++++++++- > drivers/net/ice/ice_ethdev.h | 8 ++ > 4 files changed, 161 insertions(+), 6 deletions(-) > >diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst >index 45b6749a1..161e1452c 100644 >--- a/doc/guides/nics/ice.rst >+++ b/doc/guides/nics/ice.rst >@@ -125,10 +125,22 @@ The Intel E810 requires a programmable pipeline package be downloaded > by the driver to support normal operations. The E810 has a limited > functionality built in to allow PXE boot and other use cases, but the > driver must download a package file during the driver initialization >-stage. The file must be in the /lib/firmware/intel/ice/ddp directory >-and it must be named ice.pkg. A symbolic link to this file is also ok. >-The same package file is used by both the kernel driver and the DPDK PMD. >- >+stage. >+ >+The default DDP package file name is ice.pkg. For a specific NIC, the >+DDP package supposed to be loaded can have a filename: ice-xxxxxx.pkg, >+where 'xxxxxx' is the 64-bit PCIe Device Serial Number of the NIC. For >+example, if the NIC's device serial number is 00-CC-BB-FF-FF-AA-05-68, >+the device-specific DDP package filename is ice-00ccbbffffaa0568.pkg >+(in hex and all low case). During initialization, the driver searches >+in the following paths in order: /lib/firmware/updates/intel/ice/ddp >+and /lib/firmware/intel/ice/ddp. The correponding device-specific DDP >+package will be downloaded first if the file exists. If not, then the >+driver tries to load the default package. The type of loaded package >+is stored in ``ice_adapter->active_pkg_type``. >+ >+A symbolic link to the DDP package file is also ok. The same package >+file is used by both the kernel driver and the DPDK PMD. > > 19.02 limitation > ~~~~~~~~~~~~~~~~ >diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst >index 8490d897c..ef5048829 100644 >--- a/doc/guides/rel_notes/release_19_11.rst >+++ b/doc/guides/rel_notes/release_19_11.rst >@@ -56,6 +56,11 @@ New Features > Also, make sure to start the actual text at the margin. > ========================================================= > >+* **Support device-specific DDP package loading.** >+ >+ Added support to load device-specific DDP package. The package file >+ with name including NIC's device serial number would be searched and >+ loaded (if existed) prior to the default package (ice.pkg). > > Removed Items > ------------- >diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c >index 686d6f00f..0811d8053 100644 >--- a/drivers/net/ice/ice_ethdev.c >+++ b/drivers/net/ice/ice_ethdev.c >@@ -28,7 +28,16 @@ static const char * const ice_valid_args[] = { > }; > > #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100 >-#define ICE_DFLT_PKG_FILE "/lib/firmware/intel/ice/ddp/ice.pkg" >+ >+/* DDP package search path */ >+#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg" >+#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg" >+#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/" >+#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/" >+ >+#define ICE_OS_DEFAULT_PKG_NAME "ICE OS Default Package" >+#define ICE_COMMS_PKG_NAME "ICE COMMS Package" >+#define ICE_MAX_PKG_FILENAME_SIZE 256 > > int ice_logtype_init; > int ice_logtype_driver; >@@ -1265,15 +1274,132 @@ ice_pf_setup(struct ice_pf *pf) > return 0; > } > >+/* PCIe configuration space setting */ >+#define PCI_CFG_SPACE_SIZE 256 >+#define PCI_CFG_SPACE_EXP_SIZE 4096 >+#define PCI_EXT_CAP_ID(header) (int)((header) & 0x0000ffff) >+#define PCI_EXT_CAP_NEXT(header) (((header) >> 20) & 0xffc) >+#define PCI_EXT_CAP_ID_DSN 0x03 >+ >+static int >+ice_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap) >+{ >+ uint32_t header; >+ int ttl; >+ int pos = PCI_CFG_SPACE_SIZE; >+ >+ /* minimum 8 bytes per capability */ >+ ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; >+ >+ if (rte_pci_read_config(dev, &header, 4, pos) < 0) { >+ PMD_INIT_LOG(ERR, "ice error reading extended capabilities\n"); >+ return -1; >+ } >+ >+ /* >+ * If we have no capabilities, this is indicated by cap ID, >+ * cap version and next pointer all being 0. >+ */ >+ if (header == 0) >+ return 0; >+ >+ while (ttl-- > 0) { >+ if (PCI_EXT_CAP_ID(header) == cap) >+ return pos; >+ >+ pos = PCI_EXT_CAP_NEXT(header); >+ >+ if (pos < PCI_CFG_SPACE_SIZE) >+ break; >+ >+ if (rte_pci_read_config(dev, &header, 4, pos) < 0) { >+ PMD_INIT_LOG(ERR, "ice error reading extended capabilities\n"); >+ return -1; >+ } >+ } >+ >+ return 0; >+} Above code is common pci helper function, and it shares the same code in nfp pmd, could you try to move them into lib/librte_ethdev/rte_ethdev_pci.h? Thanks, Xiaolong >+ >+/* >+ * Extract device serial number from PCIe Configuration Space and >+ * determine the pkg file path according to the DSN. >+ */ >+static int >+ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file) >+{ >+ int pos; >+ char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE]; >+ uint32_t dsn_low, dsn_high; >+ memset(opt_ddp_filename, 0, ICE_MAX_PKG_FILENAME_SIZE); >+ >+ pos = ice_pci_find_next_ext_capability(pci_dev, PCI_EXT_CAP_ID_DSN); >+ >+ if (pos) { >+ rte_pci_read_config(pci_dev, &dsn_low, 4, pos + 4); >+ rte_pci_read_config(pci_dev, &dsn_high, 4, pos + 8); >+ snprintf(opt_ddp_filename, ICE_MAX_PKG_FILENAME_SIZE, >+ "ice-%08x%08x.pkg", dsn_high, dsn_low); >+ } else { >+ PMD_INIT_LOG(ERR, "Failed to read device serial number\n"); >+ goto fail_dsn; >+ } >+ >+ strncpy(pkg_file, ICE_PKG_FILE_SEARCH_PATH_UPDATES, >+ ICE_MAX_PKG_FILENAME_SIZE); >+ if (!access(strcat(pkg_file, opt_ddp_filename), 0)) >+ return 0; >+ >+ strncpy(pkg_file, ICE_PKG_FILE_SEARCH_PATH_DEFAULT, >+ ICE_MAX_PKG_FILENAME_SIZE); >+ if (!access(strcat(pkg_file, opt_ddp_filename), 0)) >+ return 0; >+ >+fail_dsn: >+ strncpy(pkg_file, ICE_PKG_FILE_UPDATES, ICE_MAX_PKG_FILENAME_SIZE); >+ if (!access(pkg_file, 0)) >+ return 0; >+ strncpy(pkg_file, ICE_PKG_FILE_DEFAULT, ICE_MAX_PKG_FILENAME_SIZE); >+ return 0; >+} >+ >+static enum ice_pkg_type >+ice_load_pkg_type(struct ice_hw *hw) >+{ >+ enum ice_pkg_type package_type; >+ >+ /* store the activated package type (OS default or Comms) */ >+ if (!strncmp((char *)hw->active_pkg_name, ICE_OS_DEFAULT_PKG_NAME, >+ ICE_PKG_NAME_SIZE)) >+ package_type = ICE_PKG_TYPE_OS_DEFAULT; >+ else if (!strncmp((char *)hw->active_pkg_name, ICE_COMMS_PKG_NAME, >+ ICE_PKG_NAME_SIZE)) >+ package_type = ICE_PKG_TYPE_COMMS; >+ else >+ package_type = ICE_PKG_TYPE_UNKNOWN; >+ >+ PMD_INIT_LOG(NOTICE, "Active package is: %d.%d.%d.%d, %s", >+ hw->active_pkg_ver.major, hw->active_pkg_ver.minor, >+ hw->active_pkg_ver.update, hw->active_pkg_ver.draft, >+ hw->active_pkg_name); >+ >+ return package_type; >+} >+ > static int ice_load_pkg(struct rte_eth_dev *dev) > { > struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); >- const char *pkg_file = ICE_DFLT_PKG_FILE; >+ char pkg_file[ICE_MAX_PKG_FILENAME_SIZE]; > int err; > uint8_t *buf; > int buf_len; > FILE *file; > struct stat fstat; >+ struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device); >+ struct ice_adapter *ad = >+ ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); >+ >+ ice_pkg_file_search_path(pci_dev, pkg_file); > > file = fopen(pkg_file, "rb"); > if (!file) { >@@ -1313,6 +1439,10 @@ static int ice_load_pkg(struct rte_eth_dev *dev) > PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d\n", err); > goto fail_exit; > } >+ >+ /* store the loaded pkg type info */ >+ ad->active_pkg_type = ice_load_pkg_type(hw); >+ > err = ice_init_hw_tbls(hw); > if (err) { > PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err); >diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h >index 5063960a8..d1d07641d 100644 >--- a/drivers/net/ice/ice_ethdev.h >+++ b/drivers/net/ice/ice_ethdev.h >@@ -124,6 +124,13 @@ > #define ICE_ETH_OVERHEAD \ > (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + ICE_VLAN_TAG_SIZE * 2) > >+/* DDP package type */ >+enum ice_pkg_type { >+ ICE_PKG_TYPE_UNKNOWN, >+ ICE_PKG_TYPE_OS_DEFAULT, >+ ICE_PKG_TYPE_COMMS, >+}; >+ > struct ice_adapter; > > /** >@@ -296,6 +303,7 @@ struct ice_adapter { > uint32_t ptype_tbl[ICE_MAX_PKT_TYPE] __rte_cache_min_aligned; > bool is_safe_mode; > struct ice_devargs devargs; >+ enum ice_pkg_type active_pkg_type; /* loaded ddp package type */ > }; > > struct ice_vsi_vlan_pvid_info { >-- >2.17.1 >