From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85944A00E6 for ; Wed, 10 Jul 2019 09:29:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5BE8D1D9E; Wed, 10 Jul 2019 09:29:16 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 1F7E41D9E for ; Wed, 10 Jul 2019 09:29:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2019 00:29:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,473,1557212400"; d="scan'208";a="176755566" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga002.jf.intel.com with ESMTP; 10 Jul 2019 00:29:12 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jul 2019 00:29:12 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 10 Jul 2019 00:29:05 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.134]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.240]) with mapi id 14.03.0439.000; Wed, 10 Jul 2019 15:29:03 +0800 From: "Yang, Qiming" To: "Zhang, Qi Z" , "Lu, Wenzhuo" CC: "dev@dpdk.org" Thread-Topic: [PATCH v3 2/2] net/ice: add safe mode support devarg Thread-Index: AQHVNtXxTYWfF0EQj0yweES4m9tFFKbDdDwg Date: Wed, 10 Jul 2019 07:29:03 +0000 Message-ID: References: <20190710041630.47927-1-qi.z.zhang@intel.com> <20190710041630.47927-2-qi.z.zhang@intel.com> In-Reply-To: <20190710041630.47927-2-qi.z.zhang@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 2/2] net/ice: add safe mode support devarg 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" -----Original Message----- From: Zhang, Qi Z=20 Sent: Wednesday, July 10, 2019 12:17 PM To: Yang, Qiming ; Lu, Wenzhuo Cc: dev@dpdk.org; Zhang, Qi Z Subject: [PATCH v3 2/2] net/ice: add safe mode support devarg Safe mode support is not necessary by default. Driver be initialized without OS package silently may confuse users since m= ost advanced feature are disabled. Add devarg for safe mode enabling only for when user intend to do this. Signed-off-by: Qi Zhang --- -v3: fix wrong logic in parse_bool. -v2: fix missing return value check from ice_parse_devargs. minor document update. doc/guides/nics/ice.rst | 11 +++++++ drivers/net/ice/ice_ethdev.c | 68 ++++++++++++++++++++++++++++++++++++++++= +++- drivers/net/ice/ice_ethdev.h | 8 ++++++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst index e9b3a4= 8bc..03819d29f 100644 --- a/doc/guides/nics/ice.rst +++ b/doc/guides/nics/ice.rst @@ -49,6 +49,17 @@ Please note that enabling debugging options may affect s= ystem performance. Runtime Config Options ~~~~~~~~~~~~~~~~~~~~~~ =20 +- ``Safe Mode Support`` (default ``0``) + + If driver failed to load OS package, by default driver's initialization = failed. + But if user intend to use the device without OS package, user can=20 + take ``devargs`` parameter ``safe-mode-support``, for example:: + + -w 80:00.0,safe-mode-support=3D1 + + Then the driver will be initialized successfully and the device will ent= er Safe Mode. + NOTE: In Safe mode, only very limited features are available,=20 + features like RSS, checksum, fdir, tunneling ... are all disabled. =20 Driver compilation and testing ------------------------------ diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c in= dex 4b5cd8269..a7cbe0848 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -17,6 +17,14 @@ #include "ice_rxtx.h" #include "ice_switch_filter.h" =20 +/* devargs */ +#define ICE_SAFE_MODE_SUPPORT_ARG "safe-mode-support" + +static const char * const ice_valid_args[] =3D { + ICE_SAFE_MODE_SUPPORT_ARG, + NULL +}; + #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100 #define IC= E_DFLT_PKG_FILE "/lib/firmware/intel/ice/ddp/ice.pkg" =20 @@ -1334,6 +1342,50 @@ ice_base_queue_get(struct ice_pf *pf) } =20 static int +parse_bool(const char *key, const char *value, void *args) { + int *i =3D (int *)args; + char *end; + int num; + + num =3D strtoul(value, &end, 10); + + if (num !=3D 0 && num !=3D 1) { + PMD_DRV_LOG(WARNING, "invalid value:\"%s\" for key:\"%s\", " + "value must be 0 or 1", + value, key); + return -1; + } + + *i =3D num; + return 0; +} + +static int ice_parse_devargs(struct rte_eth_dev *dev) { + struct ice_adapter *ad =3D + ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct rte_devargs *devargs =3D dev->device->devargs; + struct rte_kvargs *kvlist; + int ret; + + if (devargs =3D=3D NULL) + return 0; + + kvlist =3D rte_kvargs_parse(devargs->args, ice_valid_args); + if (kvlist =3D=3D NULL) { + PMD_INIT_LOG(ERR, "Invalid kvargs key\n"); + return -EINVAL; + } + + ret =3D rte_kvargs_process(kvlist, ICE_SAFE_MODE_SUPPORT_ARG, + &parse_bool, &ad->devargs.safe_mode_support); + + rte_kvargs_free(kvlist); + return ret; +} + +static int ice_dev_init(struct rte_eth_dev *dev) { struct rte_pci_device *pci_dev; @@ -1366,6 +1418,12 @@ ice_dev_init(struct rte_eth_dev *dev) hw->bus.device =3D pci_dev->addr.devid; hw->bus.func =3D pci_dev->addr.function; =20 + ret =3D ice_parse_devargs(dev); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to parse devargs"); + return -EINVAL; + } + ice_init_controlq_parameter(hw); =20 ret =3D ice_init_hw(hw); @@ -1376,8 +1434,14 @@ ice_dev_init(struct rte_eth_dev *dev) =20 ret =3D ice_load_pkg(dev); if (ret) { + if (ad->devargs.safe_mode_support =3D=3D 0) { + PMD_INIT_LOG(ERR, "Failed to load the DDP package," + "Use safe-mode-support=3D1 to enter Safe Mode"); + return ret; + } + PMD_INIT_LOG(WARNING, "Failed to load the DDP package," - "Entering Safe Mode"); + "Entering Safe Mode"); ad->is_safe_mode =3D 1; } =20 @@ -3693,6 +3757,8 @@ static struct rte_pci_driver rte_ice_pmd =3D { RTE_P= MD_REGISTER_PCI(net_ice, rte_ice_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_ice,= pci_id_ice_map); RTE_PMD_REGISTER_KMOD_DEP(net_ice, "* igb_uio | uio_pci_= generic | vfio-pci"); +RTE_PMD_REGISTER_PARAM_STRING(net_ice, + ICE_SAFE_MODE_SUPPORT_ARG "=3D<0|1>"); =20 RTE_INIT(ice_init_log) { diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h in= dex 8a52239f5..f569da833 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -274,6 +274,13 @@ struct ice_pf { }; =20 /** + * Cache devargs parse result. + */ +struct ice_devargs { + int safe_mode_support; +}; + +/** * Structure to store private data for each PF/VF instance. */ struct ice_adapter { @@ -286,6 +293,7 @@ struct ice_adapter { /* ptype mapping table */ uint32_t ptype_tbl[ICE_MAX_PKT_TYPE] __rte_cache_min_aligned; bool is_safe_mode; + struct ice_devargs devargs; }; =20 struct ice_vsi_vlan_pvid_info { -- 2.13.6 Acked-by: Qiming Yang