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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 38523C3A5A2 for ; Wed, 4 Sep 2019 02:41:02 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 9F26B22CEA for ; Wed, 4 Sep 2019 02:41:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F26B22CEA 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 2EC7B1BEB1; Wed, 4 Sep 2019 04:41:00 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2D27B1BE9E for ; Wed, 4 Sep 2019 04:40:57 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2019 19:40:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="187471739" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 03 Sep 2019 19:40:55 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 3 Sep 2019 19:40:55 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 3 Sep 2019 19:40:54 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 3 Sep 2019 19:40:53 -0700 Received: from shsmsx106.ccr.corp.intel.com ([169.254.10.86]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.146]) with mapi id 14.03.0439.000; Wed, 4 Sep 2019 10:40:52 +0800 From: "Xu, Ting" To: "Ye, Xiaolong" CC: "dev@dpdk.org" , "Lu, Wenzhuo" , "Yang, Qiming" , "Zhang, Qi Z" Thread-Topic: [dpdk-dev] [PATCH v3] net/ice: support device-specific DDP package loading Thread-Index: AQHVYjxmlk409ij7CUec2e/HpNUGFacaypmQ Date: Wed, 4 Sep 2019 02:40:51 +0000 Message-ID: <8C448DD570D7CD459EACDF44AB3869D701910286@SHSMSX106.ccr.corp.intel.com> References: <20190829131758.12648-1-ting.xu@intel.com> <20190903142943.64992-1-ting.xu@intel.com> <20190903094353.GB15462@intel.com> In-Reply-To: <20190903094353.GB15462@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] 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, Xiaolong, As for the pkg_file, we first determine the pkg file path according to the = search order. And then it will be given to the original pkg loading functio= n, ice_load_pkg, to check if the pkg is available. If not, an error is retu= rned.=20 I do not check the access because it will be checked in the next step, so I= want to reduce some operations.=20 Thanks! ------------------ Best Regards, Xu Ting -----Original Message----- From: Ye, Xiaolong=20 Sent: Tuesday, September 3, 2019 5:44 PM To: Xu, Ting Cc: dev@dpdk.org; Lu, Wenzhuo ; Yang, Qiming ; Zhang, Qi Z Subject: Re: [dpdk-dev] [PATCH v3] net/ice: support device-specific DDP pac= kage loading Hi, Ting On 09/03, Ting Xu wrote: >This patch adds the feature that supports loading DDP package according=20 >to the device serial number. Prior to loading the default DDP package=20 >(ice.pkg), the driver will check for the presence of a device-specific=20 >DDP package with the name containing 64-bit PCIe Device Serial Number=20 >(ice-xxxxxxxxxxxxxxxx.pkg) during initialization. Users can use "lspci=20 >-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=20 >will download it to the device instead of the default one. The loaded=20 >package type (OS default and COMMS) will be stored in=20 >ice_adapter->active_pkg_type. The package version is stored in=20 >ice_hw->active_pkg_ver. > >Signed-off-by: Ting Xu > >------------------------------------------------------------------- > >v3: try to fix compile error; modify to change the pkg loading order. > >v2: modify codes according to the comments. >--- You should put your change log after '---' marker, then it will be ignored = when applying by `git am`, other separator like '----------------------...'= =20 you used will still show in the commit log. > drivers/net/ice/ice_ethdev.c | 138 ++++++++++++++++++++++++++++++++++- > drivers/net/ice/ice_ethdev.h | 8 ++ > 2 files changed, 144 insertions(+), 2 deletions(-) > >diff --git a/drivers/net/ice/ice_ethdev.c=20 >b/drivers/net/ice/ice_ethdev.c index 686d6f00f..922b71ac6 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[] =3D { }; >=20 > #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100=20 >-#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 >=20 > int ice_logtype_init; > int ice_logtype_driver; >@@ -1265,15 +1274,137 @@ ice_pf_setup(struct ice_pf *pf) > return 0; > } >=20 >+/* 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)=20 >+{ >+ uint32_t header; >+ int ttl; >+ int pos =3D PCI_CFG_SPACE_SIZE; >+ >+ /* minimum 8 bytes per capability */ >+ ttl =3D (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 =3D=3D 0) >+ return 0; >+ >+ while (ttl-- > 0) { >+ if (PCI_EXT_CAP_ID(header) =3D=3D cap) >+ return pos; >+ >+ pos =3D 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; >+} >+ >+/* 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=20 >+*pkg_file) { >+ int pos; >+ char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE]; >+ uint32_t dword; >+ uint32_t dsn_low, dsn_high; >+ >+ pos =3D ice_pci_find_next_ext_capability(pci_dev, PCI_EXT_CAP_ID_DSN); >+ >+ if (pos) { >+ rte_pci_read_config(pci_dev, &dword, 4, pos + 4); >+ dsn_low =3D dword; >+ rte_pci_read_config(pci_dev, &dword, 4, pos + 8); >+ dsn_high =3D dword; >+ snprintf(opt_ddp_filename, ICE_MAX_PKG_FILENAME_SIZE, >+ "ice-%08x%08x.pkg", dsn_high, dsn_low); >+ } else { >+ PMD_INIT_LOG(INFO, "Failed to read device serial number\n"); >+ strncpy(pkg_file, ICE_PKG_FILE_DEFAULT, >+ ICE_MAX_PKG_FILENAME_SIZE); >+ >+ return 0; >+ } >+ >+ 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; >+ >+ 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); Do we need to check access for the pkg_file here too? What if the file does= n't exist or user doesn't have access to it? Thanks, Xiaolong >+ >+ return 0; >+} >+ >+static enum ice_pkg_type >+ice_get_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 =3D ICE_PKG_TYPE_OS_DEFAULT; >+ else if (!strncmp((char *)hw->active_pkg_name, ICE_COMMS_PKG_NAME, >+ ICE_PKG_NAME_SIZE)) >+ package_type =3D ICE_PKG_TYPE_COMMS; >+ else >+ package_type =3D ICE_PKG_TYPE_UNKNOWN; >+ >+ PMD_INIT_LOG(INFO, "Active package is: %d.%d.%d.%d, %s\n", >+ 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 =3D ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); >- const char *pkg_file =3D 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 =3D RTE_DEV_TO_PCI(dev->device); >+ struct ice_adapter *ad =3D >+ ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); >+ >+ ice_pkg_file_search_path(pci_dev, pkg_file); >=20 > file =3D fopen(pkg_file, "rb"); > if (!file) { >@@ -1313,6 +1444,9 @@ 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; > } >+ >+ ad->active_pkg_type =3D ice_get_pkg_type(hw); >+ > err =3D ice_init_hw_tbls(hw); > if (err) { > PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err); diff --git=20 >a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index=20 >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) >=20 >+/* DDP package type */ >+enum ice_pkg_type { >+ ICE_PKG_TYPE_UNKNOWN, >+ ICE_PKG_TYPE_OS_DEFAULT, >+ ICE_PKG_TYPE_COMMS, >+}; >+ > struct ice_adapter; >=20 > /** >@@ -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 */ > }; >=20 > struct ice_vsi_vlan_pvid_info { >-- >2.17.1 >