From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D5C9011A4 for ; Wed, 20 Mar 2019 09:27:16 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2019 01:27:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,248,1549958400"; d="scan'208";a="328900444" Received: from dpdk-qiming2.sh.intel.com ([10.67.119.132]) by fmsmga006.fm.intel.com with ESMTP; 20 Mar 2019 01:27:15 -0700 From: Qiming Yang To: dev@dpdk.org Cc: qi.z.zhang@intel.com, paul.m.stillwell.jr@intel.com, Qiming Yang Date: Wed, 20 Mar 2019 23:50:22 +0800 Message-Id: <20190320155025.138173-2-qiming.yang@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190320155025.138173-1-qiming.yang@intel.com> References: <20190301124613.66527-1-qiming.yang@intel.com> <20190320155025.138173-1-qiming.yang@intel.com> Subject: [dpdk-dev] [PATCH v2 1/4] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2019 08:27:17 -0000 This patch enables package downloading to the device. The package is to be in the /lib/firmware/intel/ice/ddp directory and named ice.pkg. The package is shared by the kernel driver and the DPDK PMD. There is no per device package be supported so far, all the devices can only download the same package. This limitation will be removed in the future. Signed-off-by: Qiming Yang --- drivers/net/ice/ice_ethdev.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index a23c63a..13f2748 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2,6 +2,11 @@ * Copyright(c) 2018 Intel Corporation */ +#include +#include +#include +#include + #include #include "base/ice_sched.h" @@ -10,6 +15,7 @@ #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" int ice_logtype_init; int ice_logtype_driver; @@ -1259,6 +1265,62 @@ ice_pf_setup(struct ice_pf *pf) return 0; } +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; + int err; + uint8_t *buf; + int buf_len; + FILE *file; + struct stat fstat; + + file = fopen(pkg_path, "rb"); + if (!file) { + PMD_INIT_LOG(ERR, "failed to open file: %s", pkg_file); + return -1; + } + + err = stat(pkg_path, &fstat); + if (err) { + PMD_INIT_LOG(ERR, "failed to get file stats"); + fclose(file); + return err; + } + + buf_len = fstat.st_size; + buf = rte_malloc(NULL, buf_len, 0); + + if (!buf) { + PMD_INIT_LOG(ERR, "failed to allocate buf of size %d" + "for package", buf_len); + fclose(file); + return -1; + } + + err = fread(buf, buf_len, 1, file); + if (err != 1) { + PMD_INIT_LOG(ERR, "failed to read package data"); + fclose(file); + return -1; + } + + fclose(file); + + err = ice_copy_and_init_pkg(hw, buf, buf_len); + if (err) { + PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d\n", err); + return err; + } + err = ice_init_hw_tbls(hw); + if (err) { + PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err); + return err; + } + + return 0; +} + static int ice_dev_init(struct rte_eth_dev *dev) { @@ -1298,6 +1360,12 @@ ice_dev_init(struct rte_eth_dev *dev) return -EINVAL; } + ret = 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 +1411,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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 81E75A00E6 for ; Wed, 20 Mar 2019 09:27:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B5ABC493D; Wed, 20 Mar 2019 09:27:19 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D5C9011A4 for ; Wed, 20 Mar 2019 09:27:16 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2019 01:27:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,248,1549958400"; d="scan'208";a="328900444" Received: from dpdk-qiming2.sh.intel.com ([10.67.119.132]) by fmsmga006.fm.intel.com with ESMTP; 20 Mar 2019 01:27:15 -0700 From: Qiming Yang To: dev@dpdk.org Cc: qi.z.zhang@intel.com, paul.m.stillwell.jr@intel.com, Qiming Yang Date: Wed, 20 Mar 2019 23:50:22 +0800 Message-Id: <20190320155025.138173-2-qiming.yang@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190320155025.138173-1-qiming.yang@intel.com> References: <20190301124613.66527-1-qiming.yang@intel.com> <20190320155025.138173-1-qiming.yang@intel.com> Subject: [dpdk-dev] [PATCH v2 1/4] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190320155022.AZby1vrYKTzYs7P49mjBmj10E2Hf2jNfxAlhLZwpJKU@z> This patch enables package downloading to the device. The package is to be in the /lib/firmware/intel/ice/ddp directory and named ice.pkg. The package is shared by the kernel driver and the DPDK PMD. There is no per device package be supported so far, all the devices can only download the same package. This limitation will be removed in the future. Signed-off-by: Qiming Yang --- drivers/net/ice/ice_ethdev.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index a23c63a..13f2748 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2,6 +2,11 @@ * Copyright(c) 2018 Intel Corporation */ +#include +#include +#include +#include + #include #include "base/ice_sched.h" @@ -10,6 +15,7 @@ #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" int ice_logtype_init; int ice_logtype_driver; @@ -1259,6 +1265,62 @@ ice_pf_setup(struct ice_pf *pf) return 0; } +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; + int err; + uint8_t *buf; + int buf_len; + FILE *file; + struct stat fstat; + + file = fopen(pkg_path, "rb"); + if (!file) { + PMD_INIT_LOG(ERR, "failed to open file: %s", pkg_file); + return -1; + } + + err = stat(pkg_path, &fstat); + if (err) { + PMD_INIT_LOG(ERR, "failed to get file stats"); + fclose(file); + return err; + } + + buf_len = fstat.st_size; + buf = rte_malloc(NULL, buf_len, 0); + + if (!buf) { + PMD_INIT_LOG(ERR, "failed to allocate buf of size %d" + "for package", buf_len); + fclose(file); + return -1; + } + + err = fread(buf, buf_len, 1, file); + if (err != 1) { + PMD_INIT_LOG(ERR, "failed to read package data"); + fclose(file); + return -1; + } + + fclose(file); + + err = ice_copy_and_init_pkg(hw, buf, buf_len); + if (err) { + PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d\n", err); + return err; + } + err = ice_init_hw_tbls(hw); + if (err) { + PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err); + return err; + } + + return 0; +} + static int ice_dev_init(struct rte_eth_dev *dev) { @@ -1298,6 +1360,12 @@ ice_dev_init(struct rte_eth_dev *dev) return -EINVAL; } + ret = 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 +1411,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