From patchwork Thu Sep 8 10:54:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 1675527 X-Patchwork-Delegate: anthony.l.nguyen@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=3wuvPPTC; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MNbcX3zJhz1yj1 for ; Thu, 8 Sep 2022 20:55:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 81B5D61222; Thu, 8 Sep 2022 10:55:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 81B5D61222 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1662634502; bh=BVy531hF4rIlO6SXhzn60ueQdwXZb/KwrluH5Fl9gas=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=3wuvPPTCizexd6PyveOewJB3db2LZYZgIi1Rr85cLKSfC6bkZTpZmV3Iyv7l8qxWb 8jbUHFOYooINi6+5ylZvqe1h11DPouhwn61EnzSAeGPdT1Ean/PW+BhYdCq+XF5JFE y6kww/gkHLxQBqcVgjUNwVapLQ8hosJrMG+Q8s0qfzA/Ubva+ijVPus+wr8j/+Dujp GU9+vaNrAanz//vqfRPoFTtSKWdES8CSsa+Ei+9ANPu32YRVdlwGcnoCibkw7F7Ekb DCgIQGKUS83jMdeBgGrp9OJLJ1wZ0Fpx/u/LIaHyNMVw/BKQ+X/gYOVMKrmHb7rRdh kGvlZMsFywshw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uPPowSRhbQgB; Thu, 8 Sep 2022 10:55:01 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 6753F61236; Thu, 8 Sep 2022 10:55:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6753F61236 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id A308E1BF5A1 for ; Thu, 8 Sep 2022 10:54:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 547E883EF2 for ; Thu, 8 Sep 2022 10:54:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 547E883EF2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cHZdxRezNnAQ for ; Thu, 8 Sep 2022 10:54:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 87F8E84077 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by smtp1.osuosl.org (Postfix) with ESMTPS id 87F8E84077 for ; Thu, 8 Sep 2022 10:54:50 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="323329340" X-IronPort-AV: E=Sophos;i="5.93,299,1654585200"; d="scan'208";a="323329340" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 03:54:49 -0700 X-IronPort-AV: E=Sophos;i="5.93,299,1654585200"; d="scan'208";a="645033371" Received: from moradin.igk.intel.com ([10.123.220.12]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 03:54:48 -0700 From: Michal Wilczynski To: intel-wired-lan@lists.osuosl.org Date: Thu, 8 Sep 2022 12:54:25 +0200 Message-Id: <20220908105427.183225-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220908105427.183225-1-michal.wilczynski@intel.com> References: <20220908105427.183225-1-michal.wilczynski@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662634490; x=1694170490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XKH+ccZgf4b3B+ZE2nJhMpMyUqBhHRI0T4nc7uci5Ag=; b=fEQ6TvwF9XEi9StiXUcze58hbWkTRy7eU/KvWCyVGTrchq/50+19LcVm PboR3ThvgHNmP3F+Nk5deCRHSRecmX0lreG+IL5tpneS2wTDRNJoXicq8 UgrUBWmyws4X97Fw8ELzFdbFJQC9qZwSlydLwd+EKR7ZeZV+jkgeYabaf N32gQvoVvyY6id9IUNbnOApkTcXKxIadp86BNEgFuSnS39OXaFZIlMISM Rhe7ek/8o/TxOMxwXinczU1BCZOirtJBeNriNK48NUP9DR5v6dH+/0W6f 1UhwGqDPCiNhzG2iEnIiLkYIsi4MsJarcmvs38xC53/sfqCqL7ufEcBDy w==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=fEQ6TvwF Subject: [Intel-wired-lan] [PATCH net-next v9 3/5] ice: Enable switching default tx scheduler topology X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Introduce support for tx scheduler topology change, based on user selection, from default 9-layer to 5-layer. In order for switch to be successful there is a new NVM(version 3.20 or older) and DDP package(OS Package 1.3.29 or older). Enable 5-layer topology switch in init path of the driver. To accomplish that upload of the DDP package needs to be delayed, until change in Tx topology is finished. To trigger the Tx change user selection should be changed in NVM using devlink. Then the platform should be rebooted. Signed-off-by: Michal Wilczynski Tested-by: Gurucharan (A Contingent worker at Intel) --- drivers/net/ethernet/intel/ice/ice_common.c | 2 + .../net/ethernet/intel/ice/ice_flex_pipe.c | 3 +- drivers/net/ethernet/intel/ice/ice_main.c | 113 +++++++++++++++--- 3 files changed, 98 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c index b807e0c9a339..2a4b68ef7d55 100644 --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c @@ -1657,6 +1657,8 @@ ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf, case ice_aqc_opc_set_port_params: case ice_aqc_opc_get_vlan_mode_parameters: case ice_aqc_opc_set_vlan_mode_parameters: + case ice_aqc_opc_set_tx_topo: + case ice_aqc_opc_get_tx_topo: case ice_aqc_opc_add_recipe: case ice_aqc_opc_recipe_to_profile: case ice_aqc_opc_get_recipe: diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c index f72be7b7cd93..aa2c8ec5b7f4 100644 --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c @@ -1951,7 +1951,8 @@ int ice_cfg_tx_topo(struct ice_hw *hw, u8 *buf, u32 len) /* acquire global lock to make sure that set topology issued * by one PF */ - status = ice_acquire_global_cfg_lock(hw, ICE_RES_WRITE); + status = ice_acquire_res(hw, ICE_GLOBAL_CFG_LOCK_RES_ID, ICE_RES_WRITE, + ICE_GLOBAL_CFG_LOCK_TIMEOUT); if (status) { ice_debug(hw, ICE_DBG_INIT, "Failed to acquire global lock\n"); return status; diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 339c92dfc2ed..0b820cc3027d 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -4521,11 +4521,11 @@ static char *ice_get_opt_fw_name(struct ice_pf *pf) /** * ice_request_fw - Device initialization routine * @pf: pointer to the PF instance + * @firmware: double pointer to firmware struct */ -static void ice_request_fw(struct ice_pf *pf) +static int ice_request_fw(struct ice_pf *pf, const struct firmware **firmware) { char *opt_fw_filename = ice_get_opt_fw_name(pf); - const struct firmware *firmware = NULL; struct device *dev = ice_pf_to_dev(pf); int err = 0; @@ -4534,29 +4534,98 @@ static void ice_request_fw(struct ice_pf *pf) * and warning messages for other errors. */ if (opt_fw_filename) { - err = firmware_request_nowarn(&firmware, opt_fw_filename, dev); - if (err) { - kfree(opt_fw_filename); - goto dflt_pkg_load; - } - - /* request for firmware was successful. Download to device */ - ice_load_pkg(firmware, pf); + err = firmware_request_nowarn(firmware, opt_fw_filename, dev); kfree(opt_fw_filename); - release_firmware(firmware); - return; + if (!err) + return err; } -dflt_pkg_load: - err = request_firmware(&firmware, ICE_DDP_PKG_FILE, dev); - if (err) { + err = request_firmware(firmware, ICE_DDP_PKG_FILE, dev); + if (err) dev_err(dev, "The DDP package file was not found or could not be read. Entering Safe Mode\n"); - return; + + return err; +} + +/** + * ice_init_tx_topology - performs Tx topology initialization + * @hw: pointer to the hardware structure + * @firmware: pointer to firmware structure + */ +static int ice_init_tx_topology(struct ice_hw *hw, + const struct firmware *firmware) +{ + u8 num_tx_sched_layers = hw->num_tx_sched_layers; + struct ice_pf *pf = hw->back; + struct device *dev; + u8 *buf_copy; + int err; + + dev = ice_pf_to_dev(pf); + /* ice_cfg_tx_topo buf argument is not a constant, + * so we have to make a copy + */ + buf_copy = kmemdup(firmware->data, firmware->size, GFP_KERNEL); + + err = ice_cfg_tx_topo(hw, buf_copy, firmware->size); + if (!err) { + if (hw->num_tx_sched_layers > num_tx_sched_layers) + dev_info(dev, "Transmit balancing feature disabled\n"); + else + dev_info(dev, "Transmit balancing feature enabled\n"); + + /* if there was a change in topology ice_cfg_tx_topo triggered + * a CORER and we need to re-init hw. + */ + ice_deinit_hw(hw); + err = ice_init_hw(hw); + + /* in this case we're not allowing safe mode */ + kfree(buf_copy); + + return err; + + } else if (err == -EIO) { + dev_info(dev, "DDP package does not support transmit balancing feature - please update to the latest DDP package and try again\n"); + } + + kfree(buf_copy); + + return 0; +} + +/** + * ice_init_ddp_config - DDP related configuration + * @hw: pointer to the hardware structure + * @pf: pointer to pf structure + * + * This function loads DDP file from the disk, then initializes tx + * topology. At the end DDP package is loaded on the card. + */ +static int ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf) +{ + struct device *dev = ice_pf_to_dev(pf); + const struct firmware *firmware = NULL; + int err; + + err = ice_request_fw(pf, &firmware); + if (err) + /* we can still operate in safe mode if DDP package load fails */ + return 0; + + err = ice_init_tx_topology(hw, firmware); + if (err) { + dev_err(dev, "ice_init_hw during change of tx topology failed: %d\n", + err); + release_firmware(firmware); + return err; } - /* request for firmware was successful. Download to device */ + /* Download firmware to device */ ice_load_pkg(firmware, pf); release_firmware(firmware); + + return 0; } /** @@ -4709,9 +4778,15 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) ice_init_feature_support(pf); - ice_request_fw(pf); + err = ice_init_ddp_config(hw, pf); + + /* during topology change ice_init_hw may fail */ + if (err) { + err = -EIO; + goto err_exit_unroll; + } - /* if ice_request_fw fails, ICE_FLAG_ADV_FEATURES bit won't be + /* if ice_init_ddp_config fails, ICE_FLAG_ADV_FEATURES bit won't be * set in pf->state, which will cause ice_is_safe_mode to return * true */