From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <paul.m.stillwell.jr@intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 1DAB6493D
 for <dev@dpdk.org>; Mon,  4 Mar 2019 18:54:38 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 04 Mar 2019 09:54:29 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.58,440,1544515200"; d="scan'208";a="131161322"
Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202])
 by orsmga003.jf.intel.com with ESMTP; 04 Mar 2019 09:54:27 -0800
Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by
 fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS)
 id 14.3.408.0; Mon, 4 Mar 2019 09:54:20 -0800
Received: from fmsmsx120.amr.corp.intel.com ([169.254.15.225]) by
 fmsmsx115.amr.corp.intel.com ([169.254.4.119]) with mapi id 14.03.0415.000;
 Mon, 4 Mar 2019 09:54:20 -0800
From: "Stillwell Jr, Paul M" <paul.m.stillwell.jr@intel.com>
To: "Yang, Qiming" <qiming.yang@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
CC: "Yang, Qiming" <qiming.yang@intel.com>
Thread-Topic: [dpdk-dev] [PATCH 1/2] net/ice: suppport package download
Thread-Index: AQHUz+4X5skKJ3wPgkGrAUT0eEkhoKX7xfcQ
Date: Mon, 4 Mar 2019 17:54:18 +0000
Message-ID: <F8A4ECA1C1D86B4081DD6BF503D1F436C74490E4@fmsmsx120.amr.corp.intel.com>
References: <20190301124613.66527-1-qiming.yang@intel.com>
In-Reply-To: <20190301124613.66527-1-qiming.yang@intel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ctpclassification: CTP_NT
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmJmNmY4ZjEtMDQ4MC00OWM5LTgwMjQtMmNkOWNlNDI4MzFkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUERHcnBKT0VGdVZPRjZ3bEFOUkFwemtWejFWcTVXZXNcL3EzR2x0dFJlSXNnQnh6dHhqVDU2WU9vNUtsODkzMVYifQ==
dlp-product: dlpe-windows
dlp-version: 11.0.400.15
dlp-reaction: no-action
x-originating-ip: [10.1.200.108]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH 1/2] net/ice: suppport package download
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>
X-List-Received-Date: Mon, 04 Mar 2019 17:54:39 -0000

NACK, see comments below

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Qiming Yang
> Sent: Friday, March 1, 2019 4:46 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>
> Subject: [dpdk-dev] [PATCH 1/2] net/ice: suppport package download
>=20
> Columbiaville requires a package to be downloaded if need advanced
> features. This patch add package download support in two ways.
> If it configured package path in devargs, will use this path, if not, wil=
l load the

We can't support downloading the package through devargs. Please remove thi=
s.

> package at /lib/firmware/intel/ice/ddp/ice.pkg.
>=20

The location is /lib/firmware. No need for extra indirection

> When package download failed, will initialize in safe mode, some advanced
> features will not be supported.
>=20
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.c | 134
> +++++++++++++++++++++++++++++++++++++++++++
>  drivers/net/ice/ice_ethdev.h |   2 +
>  2 files changed, 136 insertions(+)
>=20
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> index a23c63a..c097259 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -2,12 +2,19 @@
>   * Copyright(c) 2018 Intel Corporation
>   */
>=20
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
>  #include <rte_ethdev_pci.h>
>=20
>  #include "base/ice_sched.h"
>  #include "ice_ethdev.h"
>  #include "ice_rxtx.h"
>=20
> +#define ETH_ICE_PKG_PATH_ARG	"package_path"
> +
>  #define ICE_MAX_QP_NUM "max_queue_pair_num"
>  #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100
>=20
> @@ -72,6 +79,10 @@ static int ice_xstats_get_names(struct rte_eth_dev
> *dev,
>  				struct rte_eth_xstat_name *xstats_names,
>  				unsigned int limit);
>=20
> +static const char *const valid_keys[] =3D {
> +	ETH_ICE_PKG_PATH_ARG,
> +	NULL};
> +
>  static const struct rte_pci_id pci_id_ice_map[] =3D {
>  	{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID,
> ICE_DEV_ID_E810C_BACKPLANE) },
>  	{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID,
> ICE_DEV_ID_E810C_QSFP) }, @@ -1260,6 +1271,119 @@ ice_pf_setup(struct
> ice_pf *pf)  }
>=20
>  static int
> +ice_parse_pkg_path_handler(__rte_unused const char *key,
> +			  const char *value,
> +			  void *opaque)
> +{
> +	struct ice_adapter *ad;
> +
> +	ad =3D (struct ice_adapter *)opaque;
> +	ad->pkg_path =3D value;
> +
> +	return 0;
> +}
> +
> +static void
> +ice_find_pkg_path(struct rte_eth_dev *dev) {
> +	struct rte_kvargs *kvlist;
> +	struct ice_adapter *ad =3D
> +		ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> +	int kvargs_count;
> +
> +	if (!(dev->device->devargs))
> +		return;
> +
> +	kvlist =3D rte_kvargs_parse(dev->device->devargs->args, valid_keys);
> +	if (kvlist =3D=3D NULL)
> +		return;
> +
> +	kvargs_count =3D rte_kvargs_count(kvlist, ETH_ICE_PKG_PATH_ARG);
> +
> +	if (!kvargs_count) {
> +		rte_kvargs_free(kvlist);
> +		return;
> +	}
> +
> +	if (kvargs_count > 1)
> +		PMD_DRV_LOG(WARNING, "More than one argument
> \"%s\" and only "
> +		"the first invalid or last valid one is used !",
> +		ETH_ICE_PKG_PATH_ARG);
> +
> +	if (rte_kvargs_process(kvlist, ETH_ICE_PKG_PATH_ARG,
> +			       ice_parse_pkg_path_handler, ad) < 0) {
> +		rte_kvargs_free(kvlist);
> +		return;
> +	}
> +	rte_kvargs_free(kvlist);
> +}
> +
> +static int ice_load_pkg(struct rte_eth_dev *dev, const char *pkg_path)
> +{
> +	struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> +	struct ice_adapter *ad =3D
> +			ICE_DEV_PRIVATE_TO_ADAPTER(dev->data-
> >dev_private);
> +	int err;
> +	uint8_t *buf;
> +	int buf_len;
> +	FILE *file;
> +	struct stat fstat;
> +
> +	file =3D fopen(pkg_path, "rb");
> +	if (file =3D=3D NULL)  {
> +		PMD_INIT_LOG(ERR, "failed to open file");
> +		return 0;
> +	}
> +
> +	err =3D stat(pkg_path, &fstat);
> +	if (err) {
> +		PMD_INIT_LOG(ERR, "failed to get file stats");
> +		fclose(file);
> +		return 0;
> +	}
> +
> +	buf_len =3D fstat.st_size;
> +	printf("buf_len =3D %d\n", buf_len);
> +	buf =3D rte_malloc(NULL, buf_len, 0);
> +
> +	if (buf =3D=3D NULL) {
> +		PMD_INIT_LOG(ERR, "failed to allocate buf for package");
> +		fclose(file);
> +		return 0;
> +	}
> +
> +	err =3D fread(buf, buf_len, 1, file);
> +	if (err !=3D 1) {
> +		PMD_INIT_LOG(ERR, "failed to read package data");
> +		fclose(file);
> +		return 0;
> +	}
> +
> +	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 err_go_to_safe_mode;
> +	}
> +
> +	err =3D ice_init_hw_tbls(hw);
> +	if (err) {
> +		PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err);
> +		goto err_go_to_safe_mode;
> +	}
> +
> +	ad->is_safe_mode =3D 0;
> +	return 0;
> +
> +err_go_to_safe_mode:
> +	ad->is_safe_mode =3D 1;
> +
> +	return err;
> +}
> +
> +static int
>  ice_dev_init(struct rte_eth_dev *dev)
>  {
>  	struct rte_pci_device *pci_dev;
> @@ -1267,6 +1391,7 @@ ice_dev_init(struct rte_eth_dev *dev)
>  	struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
>  	struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data-
> >dev_private);
>  	struct ice_vsi *vsi;
> +	const char *pkg_path;
>  	int ret;
>=20
>  	dev->dev_ops =3D &ice_eth_dev_ops;
> @@ -1322,6 +1447,15 @@ ice_dev_init(struct rte_eth_dev *dev)
>  		goto err_pf_setup;
>  	}
>=20
> +	ice_find_pkg_path(dev);
> +	if (!(pf->adapter->pkg_path))
> +		pkg_path =3D "/lib/firmware/intel/ice/ddp/ice.pkg";
> +	else
> +		pkg_path =3D pf->adapter->pkg_path;
> +	ret =3D ice_load_pkg(dev, pkg_path);
> +	if (ret)
> +		PMD_INIT_LOG(ERR, "Failed to load default OS package");
> +
>  	vsi =3D pf->main_vsi;
>=20
>  	/* Disable double vlan by default */
> diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
> index 3cefa5b..796459a 100644
> --- a/drivers/net/ice/ice_ethdev.h
> +++ b/drivers/net/ice/ice_ethdev.h
> @@ -264,6 +264,8 @@ struct ice_adapter {
>  	bool tx_simple_allowed;
>  	/* ptype mapping table */
>  	uint32_t ptype_tbl[ICE_MAX_PKT_TYPE] __rte_cache_min_aligned;
> +	const char *pkg_path;
> +	bool is_safe_mode;
>  };
>=20
>  struct ice_vsi_vlan_pvid_info {
> --
> 2.9.5