From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id DDC2EA05D3
	for <public@inbox.dpdk.org>; Mon, 25 Mar 2019 14:56:08 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 775AC2C19;
	Mon, 25 Mar 2019 14:56:08 +0100 (CET)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by dpdk.org (Postfix) with ESMTP id 536972BF7
 for <dev@dpdk.org>; Mon, 25 Mar 2019 14:56:07 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga008.fm.intel.com ([10.253.24.58])
 by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 25 Mar 2019 06:56:06 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,269,1549958400"; d="scan'208";a="134547230"
Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204])
 by fmsmga008.fm.intel.com with ESMTP; 25 Mar 2019 06:56:05 -0700
Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by
 FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS)
 id 14.3.408.0; Mon, 25 Mar 2019 06:56:05 -0700
Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by
 FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS)
 id 14.3.408.0; Mon, 25 Mar 2019 06:56:05 -0700
Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.134]) by
 SHSMSX101.ccr.corp.intel.com ([169.254.1.158]) with mapi id 14.03.0415.000;
 Mon, 25 Mar 2019 21:56:03 +0800
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Yang, Qiming" <qiming.yang@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [PATCH v6 1/3] net/ice: load OS default package
Thread-Index: AQHU4ulcw6YSo4g/E0y+QyTKegj75qYcXrtA
Date: Mon, 25 Mar 2019 13:56:02 +0000
Message-ID:
 <039ED4275CED7440929022BC67E7061153351FD3@SHSMSX103.ccr.corp.intel.com>
References: <20190321150232.13536-2-qiming.yang@intel.com>
 <20190325090102.85918-1-qiming.yang@intel.com>
 <20190325090102.85918-2-qiming.yang@intel.com>
In-Reply-To: <20190325090102.85918-2-qiming.yang@intel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjZmMTM3N2ItMWEzNC00OGM2LWE1MDMtMTFhOWRhZDZhODVjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSTB5VEMxYmk2SEN6cGhtVlJUYUtNR3ltN2h5Y1R0d1pwZmFvdWowRG5CWEFkNkFNY1lGSGxLZUE2RU9XcE1uZyJ9
x-ctpclassification: CTP_NT
dlp-product: dlpe-windows
dlp-version: 11.0.400.15
dlp-reaction: no-action
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH v6 1/3] net/ice: load OS default package
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Message-ID: <20190325135602.rI1QobSqV8Y8wGCbZ4cmXWyBn3w8qRsQS71MA3FWg7M@z>



> -----Original Message-----
> From: Yang, Qiming
> Sent: Monday, March 25, 2019 5:01 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming <qiming.yang@intel.c=
om>
> Subject: [PATCH v6 1/3] net/ice: load OS default package
>=20
> This patch enables package downloading to the device. The package is to b=
e in
> the /lib/firmware/intel/ice/ddp directory and named ice.pkg.
> The package is shared by the kernel driver and the DPDK PMD.
>=20
> There is no per device package be supported so far, all the devices can o=
nly
> download the same package. This limitation will be removed in the future.
>=20
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
>  doc/guides/nics/ice.rst                |  9 ++++
>  doc/guides/rel_notes/release_19_05.rst |  4 ++
>  drivers/net/ice/ice_ethdev.c           | 77
> ++++++++++++++++++++++++++++++++++
>  3 files changed, 90 insertions(+)
>=20
> diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst index
> 3998d5e..6410ec5 100644
> --- a/doc/guides/nics/ice.rst
> +++ b/doc/guides/nics/ice.rst
> @@ -84,6 +84,15 @@ To start ``testpmd``, and add vlan 10 to port 0:
>  Limitations or Known issues
>  ---------------------------
>=20
> +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=
.
> +
> +
>  19.02 limitation
>  ~~~~~~~~~~~~~~~~
>=20
> diff --git a/doc/guides/rel_notes/release_19_05.rst
> b/doc/guides/rel_notes/release_19_05.rst
> index 61a2c73..b73938a 100644
> --- a/doc/guides/rel_notes/release_19_05.rst
> +++ b/doc/guides/rel_notes/release_19_05.rst
> @@ -91,6 +91,10 @@ New Features
>=20
>    * Added promiscuous mode support.
>=20
> +* **Updated the ice driver.**
> +
> +  * Added package download support.
> +
>=20
>  Removed Items
>  -------------
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c =
index
> a23c63a..c2a03c3 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -4,12 +4,19 @@
>=20
>  #include <rte_ethdev_pci.h>
>=20
> +=09
Unnecessary empty line.

> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
>  #include "base/ice_sched.h"
>  #include "ice_ethdev.h"
>  #include "ice_rxtx.h"
>=20
>  #define ICE_MAX_QP_NUM "max_queue_pair_num"
>  #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"
>=20
>  int ice_logtype_init;
>  int ice_logtype_driver;
> @@ -1259,6 +1266,69 @@ ice_pf_setup(struct ice_pf *pf)
>  	return 0;
>  }
>=20
> +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;
> +	int err;
> +	uint8_t *buf;
> +	int buf_len;
> +	FILE *file;
> +	struct stat fstat;
> +
> +	file =3D fopen(pkg_file, "rb");
> +	if (!file)  {
> +		PMD_INIT_LOG(ERR, "failed to open file: %s\n", pkg_file);
> +		return -1;
> +	}
> +
> +	err =3D stat(pkg_file, &fstat);
> +	if (err) {
> +		PMD_INIT_LOG(ERR, "failed to get file stats\n");
> +		fclose(file);
> +		return err;
> +	}
> +
> +	buf_len =3D fstat.st_size;
> +	buf =3D rte_malloc(NULL, buf_len, 0);
> +
> +	if (!buf) {
> +		PMD_INIT_LOG(ERR, "failed to allocate buf of size %d"
> +				  "for package\n", buf_len);

No need to split a string.

> +		fclose(file);
> +		return -1;
> +	}
> +
> +	err =3D fread(buf, buf_len, 1, file);
> +	if (err !=3D 1) {
> +		PMD_INIT_LOG(ERR, "failed to read package data\n");
> +		fclose(file);
> +		err =3D -1;
> +		goto fail_exit;
> +	}
> +
> +	fclose(file);
> +
> +	err =3D ice_copy_and_init_pkg(hw, buf, buf_len);
> +	if (err) {
> +		PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d\n", err);
> +		goto fail_exit;
> +	}
> +	err =3D ice_init_hw_tbls(hw);
> +	if (err) {
> +		PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err);
> +		goto fail_init_tbls;
> +	}
> +
> +	return 0;
> +
> +fail_init_tbls:
> +	rte_free(hw->pkg_copy);
> +fail_exit:
> +	rte_free(buf);
> +	return err;
> +}
> +
>  static int
>  ice_dev_init(struct rte_eth_dev *dev)
>  {
> @@ -1298,6 +1368,12 @@ ice_dev_init(struct rte_eth_dev *dev)
>  		return -EINVAL;
>  	}
>=20
> +	ret =3D ice_load_pkg(dev);
> +	if (ret) {
> +		PMD_INIT_LOG(ERR, "Failed to load the DDP package");
> +		goto err_load_pkg;
> +	}
> +
>  	PMD_INIT_LOG(INFO, "FW %d.%d.%05d API %d.%d",
>  		     hw->fw_maj_ver, hw->fw_min_ver, hw->fw_build,
>  		     hw->api_maj_ver, hw->api_min_ver); @@ -1343,6 +1419,7 @@
> ice_dev_init(struct rte_eth_dev *dev)
>  err_msix_pool_init:
>  	rte_free(dev->data->mac_addrs);
>  err_init_mac:
> +err_load_pkg:
>  	ice_sched_cleanup_all(hw);
>  	rte_free(hw->port_info);
>  	ice_shutdown_all_ctrlq(hw);
> --
> 2.9.5