Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1291781/?format=api
{ "id": 1291781, "url": "http://patchwork.ozlabs.org/api/patches/1291781/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200516005121.4963-9-anthony.l.nguyen@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20200516005121.4963-9-anthony.l.nguyen@intel.com>", "list_archive_url": null, "date": "2020-05-16T00:51:15", "name": "[S45,09/15] ice: Refactor VF reset", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "36cb1cf25def6c79d529b4fc30f728804fce07e2", "submitter": { "id": 68875, "url": "http://patchwork.ozlabs.org/api/people/68875/?format=api", "name": "Tony Nguyen", "email": "anthony.l.nguyen@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200516005121.4963-9-anthony.l.nguyen@intel.com/mbox/", "series": [ { "id": 177330, "url": "http://patchwork.ozlabs.org/api/series/177330/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=177330", "date": "2020-05-16T00:51:18", "name": "[S45,01/15] ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/177330/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1291781/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1291781/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Authentication-Results": [ "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=140.211.166.138; helo=whitealder.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=<UNKNOWN>)", "ozlabs.org;\n dmarc=fail (p=none dis=none) header.from=intel.com" ], "Received": [ "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49P6H73RwYz9sTC\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 16 May 2020 10:54:11 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 0F92D875CD;\n\tSat, 16 May 2020 00:54:10 +0000 (UTC)", "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id xAEQ+0igidos; Sat, 16 May 2020 00:54:03 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 86471890C5;\n\tSat, 16 May 2020 00:54:03 +0000 (UTC)", "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by ash.osuosl.org (Postfix) with ESMTP id DF36C1BF9CC\n for <intel-wired-lan@lists.osuosl.org>; Sat, 16 May 2020 00:53:58 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n by fraxinus.osuosl.org (Postfix) with ESMTP id DAF3F87F7D\n for <intel-wired-lan@lists.osuosl.org>; Sat, 16 May 2020 00:53:58 +0000 (UTC)", "from fraxinus.osuosl.org ([127.0.0.1])\n by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id x5YL9Jgstr4Y for <intel-wired-lan@lists.osuosl.org>;\n Sat, 16 May 2020 00:53:55 +0000 (UTC)", "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by fraxinus.osuosl.org (Postfix) with ESMTPS id 8FAD487F93\n for <intel-wired-lan@lists.osuosl.org>; Sat, 16 May 2020 00:53:55 +0000 (UTC)", "from orsmga003.jf.intel.com ([10.7.209.27])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 May 2020 17:53:54 -0700", "from unknown (HELO localhost.jf.intel.com) ([10.166.241.65])\n by orsmga003.jf.intel.com with ESMTP; 15 May 2020 17:53:54 -0700" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "IronPort-SDR": [ "\n TV3H7UEteUC+ClEdFBDjfQBPWOJsKNZ7WUMDhuBcSvo7QgqOrfSTGF+P/FeNjImxq5/8y94F1I\n aI+5+oysqyjw==", "\n LGShaQI+SJfns+SKAYiIgCCgj1t5KgQ2jRHeKIhqUCPV5pcILbQezAcLKDLKwSr/VlG0Z+sgiV\n 1/nG6bH9ebcQ==" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.73,397,1583222400\"; d=\"scan'208\";a=\"263360545\"", "From": "Tony Nguyen <anthony.l.nguyen@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Fri, 15 May 2020 17:51:15 -0700", "Message-Id": "<20200516005121.4963-9-anthony.l.nguyen@intel.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200516005121.4963-1-anthony.l.nguyen@intel.com>", "References": "<20200516005121.4963-1-anthony.l.nguyen@intel.com>", "MIME-Version": "1.0", "Subject": "[Intel-wired-lan] [PATCH S45 09/15] ice: Refactor VF reset", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "From: Brett Creeley <brett.creeley@intel.com>\n\nCurrently VF VSI are being reset twice during a PFR or greater. This is\ncausing reset, specifically resetting all VFs, to take too long. This is\ncausing various issues with VF drivers not being able to gracefully\nhandle the VF reset timeout. Fix this by refactoring how VF reset is\nhandled for the case mentioned previously and for the VFR/VFLR case.\n\nThe refactor was done by doing the following:\n\n1. Removing the call to ice_vsi_rebuild_by_type for\n ICE_VSI_VF VSI, which was causing the initial VSI rebuild.\n\n2. Adding functions for pre/post VSI rebuild functions that can be called\n in both the reset all VFs case and reset individual VF case.\n\n3. Adding VSI rebuild functions that are specific for the reset all VFs\n case and adding functions that are specific for the reset individual\n VF case.\n\n4. Calling the pre-rebuild function, then the specific VSI rebuild\n function based on the reset type, and then calling the post-rebuild\n function to handle VF resets.\n\nThis patch series makes some assumptions about how VSI are handling by\nFW during reset:\n\n1. During a PFR or greater all VSI in FW will be cleared.\n2. During a VFR/VFLR the VSI rebuild responsibility is in the hands of\n the PF software.\n3. There is code in the ice_reset_all_vfs() case to amortize operations\n if possible. This was left intact.\n4. PF software should not be replaying VSI based filters that were added\n other than host configured, PF software configured, or the VF's\n default/LAA MAC. This is the VF drivers job after it has been reset.\n\nSigned-off-by: Brett Creeley <brett.creeley@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice_main.c | 12 +-\n .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 304 +++++++-----------\n 2 files changed, 130 insertions(+), 186 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 14aa02b000cc..4107f6982543 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -4959,6 +4959,11 @@ static void ice_update_pf_netdev_link(struct ice_pf *pf)\n * ice_rebuild - rebuild after reset\n * @pf: PF to rebuild\n * @reset_type: type of reset\n+ *\n+ * Do not rebuild VF VSI in this flow because that is already handled via\n+ * ice_reset_all_vfs(). This is because requirements for resetting a VF after a\n+ * PFR/CORER/GLOBER/etc. are different than the normal flow. Also, we don't want\n+ * to reset/rebuild all the VF VSI twice.\n */\n static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)\n {\n@@ -5064,13 +5069,6 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)\n \t\t}\n \t\tice_for_each_peer(pf, vsi, ice_peer_update_vsi);\n \t}\n-\tif (test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) {\n-\t\terr = ice_vsi_rebuild_by_type(pf, ICE_VSI_VF);\n-\t\tif (err) {\n-\t\t\tdev_err(dev, \"VF VSI rebuild failed: %d\\n\", err);\n-\t\t\tgoto err_vsi_rebuild;\n-\t\t}\n-\t}\n \n \t/* If Flow Director is active */\n \tif (test_bit(ICE_FLAG_FD_ENA, pf->flags)) {\ndiff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\nindex 5a04589f76f2..9cd9904815b9 100644\n--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c\n@@ -413,10 +413,7 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr)\n \tclear_bit(ICE_VF_STATE_ACTIVE, vf->vf_states);\n \n \t/* Disable VF's configuration API during reset. The flag is re-enabled\n-\t * in ice_alloc_vf_res(), when it's safe again to access VF's VSI.\n-\t * It's normally disabled in ice_free_vf_res(), but it's safer\n-\t * to do it earlier to give some time to finish to any VF config\n-\t * functions that may still be running at this point.\n+\t * when it's safe again to access VF's VSI.\n \t */\n \tclear_bit(ICE_VF_STATE_INIT, vf->vf_states);\n \n@@ -616,57 +613,6 @@ static int ice_vf_rebuild_host_mac_cfg(struct ice_vf *vf)\n \treturn 0;\n }\n \n-/**\n- * ice_alloc_vsi_res - Setup VF VSI and its resources\n- * @vf: pointer to the VF structure\n- *\n- * Returns 0 on success, negative value on failure\n- */\n-static int ice_alloc_vsi_res(struct ice_vf *vf)\n-{\n-\tstruct ice_pf *pf = vf->pf;\n-\tstruct ice_vsi *vsi;\n-\tstruct device *dev;\n-\tint ret;\n-\n-\tdev = ice_pf_to_dev(pf);\n-\t/* first vector index is the VFs OICR index */\n-\tvf->first_vector_idx = ice_calc_vf_first_vector_idx(pf, vf);\n-\n-\tvsi = ice_vf_vsi_setup(pf, pf->hw.port_info, vf->vf_id);\n-\tif (!vsi) {\n-\t\tdev_err(dev, \"Failed to create VF VSI\\n\");\n-\t\treturn -ENOMEM;\n-\t}\n-\n-\tvf->lan_vsi_idx = vsi->idx;\n-\tvf->lan_vsi_num = vsi->vsi_num;\n-\n-\tret = ice_vf_rebuild_host_vlan_cfg(vf);\n-\tif (ret) {\n-\t\tdev_err(dev, \"failed to rebuild default MAC configuration for VF %d, error %d\\n\",\n-\t\t\tvf->vf_id, ret);\n-\t\tgoto ice_alloc_vsi_res_exit;\n-\t}\n-\n-\n-\tret = ice_vf_rebuild_host_mac_cfg(vf);\n-\tif (ret) {\n-\t\tdev_err(dev, \"failed to rebuild default MAC configuration for VF %d, error %d\\n\",\n-\t\t\tvf->vf_id, ret);\n-\t\tgoto ice_alloc_vsi_res_exit;\n-\t}\n-\n-\t/* Clear this bit after VF initialization since we shouldn't reclaim\n-\t * and reassign interrupts for synchronous or asynchronous VFR events.\n-\t * We don't want to reconfigure interrupts since AVF driver doesn't\n-\t * expect vector assignment to be changed unless there is a request for\n-\t * more vectors.\n-\t */\n-ice_alloc_vsi_res_exit:\n-\treturn ret;\n-}\n-\n /**\n * ice_vf_set_host_trust_cfg - set trust setting based on pre-reset value\n * @vf: VF to configure trust setting for\n@@ -679,43 +625,6 @@ static void ice_vf_set_host_trust_cfg(struct ice_vf *vf)\n \t\tclear_bit(ICE_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps);\n }\n \n-/**\n- * ice_alloc_vf_res - Allocate VF resources\n- * @vf: pointer to the VF structure\n- */\n-static int ice_alloc_vf_res(struct ice_vf *vf)\n-{\n-\tstruct ice_pf *pf = vf->pf;\n-\tint tx_rx_queue_left;\n-\tint status;\n-\n-\t/* Update number of VF queues, in case VF had requested for queue\n-\t * changes\n-\t */\n-\ttx_rx_queue_left = min_t(int, ice_get_avail_txq_count(pf),\n-\t\t\t\t ice_get_avail_rxq_count(pf));\n-\ttx_rx_queue_left += pf->num_qps_per_vf;\n-\tif (vf->num_req_qs && vf->num_req_qs <= tx_rx_queue_left &&\n-\t vf->num_req_qs != vf->num_vf_qs)\n-\t\tvf->num_vf_qs = vf->num_req_qs;\n-\n-\t/* setup VF VSI and necessary resources */\n-\tstatus = ice_alloc_vsi_res(vf);\n-\tif (status)\n-\t\tgoto ice_alloc_vf_res_exit;\n-\n-\tice_vf_set_host_trust_cfg(vf);\n-\n-\t/* VF is now completely initialized */\n-\tset_bit(ICE_VF_STATE_INIT, vf->vf_states);\n-\n-\treturn status;\n-\n-ice_alloc_vf_res_exit:\n-\tice_free_vf_res(vf);\n-\treturn status;\n-}\n-\n /**\n * ice_ena_vf_msix_mappings - enable VF MSIX mappings in hardware\n * @vf: VF to enable MSIX mappings for\n@@ -1042,48 +951,6 @@ static void ice_clear_vf_reset_trigger(struct ice_vf *vf)\n \tice_flush(hw);\n }\n \n-/**\n- * ice_cleanup_and_realloc_vf - Clean up VF and reallocate resources after reset\n- * @vf: pointer to the VF structure\n- *\n- * Cleanup a VF after the hardware reset is finished. Expects the caller to\n- * have verified whether the reset is finished properly, and ensure the\n- * minimum amount of wait time has passed. Reallocate VF resources back to make\n- * VF state active\n- */\n-static void ice_cleanup_and_realloc_vf(struct ice_vf *vf)\n-{\n-\tstruct ice_pf *pf = vf->pf;\n-\tstruct ice_hw *hw;\n-\n-\thw = &pf->hw;\n-\n-\t/* Allow HW to access VF memory after calling\n-\t * ice_clear_vf_reset_trigger(). If we did it any sooner, HW could\n-\t * access memory while it was being freed in ice_free_vf_res(), causing\n-\t * an IOMMU fault.\n-\t *\n-\t * On the other hand, this needs to be done ASAP, because the VF driver\n-\t * is waiting for this to happen and may report a timeout. It's\n-\t * harmless, but it gets logged into Guest OS kernel log, so best avoid\n-\t * it.\n-\t */\n-\tice_clear_vf_reset_trigger(vf);\n-\n-\t/* reallocate VF resources to finish resetting the VSI state */\n-\tif (!ice_alloc_vf_res(vf)) {\n-\t\tice_ena_vf_mappings(vf);\n-\t\tset_bit(ICE_VF_STATE_ACTIVE, vf->vf_states);\n-\t\tclear_bit(ICE_VF_STATE_DIS, vf->vf_states);\n-\t}\n-\n-\t/* Tell the VF driver the reset is done. This needs to be done only\n-\t * after VF has been fully initialized, because the VF driver may\n-\t * request resources immediately after setting this flag.\n-\t */\n-\twr32(hw, VFGEN_RSTAT(vf->vf_id), VIRTCHNL_VFR_VFACTIVE);\n-}\n-\n /**\n * ice_vf_set_vsi_promisc - set given VF VSI to given promiscuous mode(s)\n * @vf: pointer to the VF info\n@@ -1125,44 +992,134 @@ ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m,\n \treturn status;\n }\n \n+static void ice_vf_clear_counters(struct ice_vf *vf)\n+{\n+\tstruct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];\n+\n+\tvf->num_mac = 0;\n+\tvsi->num_vlan = 0;\n+\tmemset(&vf->mdd_tx_events, 0, sizeof(vf->mdd_tx_events));\n+\tmemset(&vf->mdd_rx_events, 0, sizeof(vf->mdd_rx_events));\n+}\n+\n /**\n- * ice_config_res_vfs - Finalize allocation of VFs resources in one go\n- * @pf: pointer to the PF structure\n+ * ice_vf_pre_vsi_rebuild - tasks to be done prior to VSI rebuild\n+ * @vf: VF to perfrom pre VSI rebuild tasks\n *\n- * This function is being called as last part of resetting all VFs, or when\n- * configuring VFs for the first time, where there is no resource to be freed\n- * Returns true if resources were properly allocated for all VFs, and false\n- * otherwise.\n+ * These tasks are items that don't need to be amortized since they are most\n+ * likely called in a for loop with all VF(s) in the reset_all_vfs() case.\n */\n-static bool ice_config_res_vfs(struct ice_pf *pf)\n+static void ice_vf_pre_vsi_rebuild(struct ice_vf *vf)\n {\n-\tstruct device *dev = ice_pf_to_dev(pf);\n-\tstruct ice_hw *hw = &pf->hw;\n-\tint v;\n+\tice_vf_clear_counters(vf);\n+\tice_clear_vf_reset_trigger(vf);\n+}\n \n-\tif (ice_set_per_vf_res(pf)) {\n-\t\tdev_err(dev, \"Cannot allocate VF resources, try with fewer number of VFs\\n\");\n-\t\treturn false;\n+/**\n+ * ice_vf_rebuild_host_cfg - host admin configuration is persistent across reset\n+ * @vf: VF to rebuild host configuration on\n+ */\n+static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)\n+{\n+\tstruct device *dev = ice_pf_to_dev(vf->pf);\n+\n+\tice_vf_set_host_trust_cfg(vf);\n+\n+\tif (ice_vf_rebuild_host_mac_cfg(vf))\n+\t\tdev_err(dev, \"failed to rebuild default MAC configuration for VF %d\\n\",\n+\t\t\tvf->vf_id);\n+\n+\tif (ice_vf_rebuild_host_vlan_cfg(vf))\n+\t\tdev_err(dev, \"failed to rebuild VLAN configuration for VF %u\\n\",\n+\t\t\tvf->vf_id);\n+}\n+\n+/**\n+ * ice_vf_rebuild_vsi_with_release - release and setup the VF's VSI\n+ * @vf: VF to release and setup the VSI for\n+ *\n+ * This is only called when a single VF is being reset (i.e. VFR, VFLR, host VF\n+ * configuration change, etc.).\n+ */\n+static int ice_vf_rebuild_vsi_with_release(struct ice_vf *vf)\n+{\n+\tstruct ice_pf *pf = vf->pf;\n+\tstruct ice_vsi *vsi;\n+\n+\tvsi = pf->vsi[vf->lan_vsi_idx];\n+\tice_vsi_release(vsi);\n+\tvsi = ice_vf_vsi_setup(pf, pf->hw.port_info, vf->vf_id);\n+\tif (!vsi) {\n+\t\tdev_err(ice_pf_to_dev(pf), \"Failed to create VF VSI\\n\");\n+\t\treturn -ENOMEM;\n \t}\n \n-\t/* rearm global interrupts */\n-\tif (test_and_clear_bit(__ICE_OICR_INTR_DIS, pf->state))\n-\t\tice_irq_dynamic_ena(hw, NULL, NULL);\n+\tvf->lan_vsi_idx = vsi->idx;\n+\tvf->lan_vsi_num = vsi->vsi_num;\n \n-\t/* Finish resetting each VF and allocate resources */\n-\tice_for_each_vf(pf, v) {\n-\t\tstruct ice_vf *vf = &pf->vf[v];\n+\treturn 0;\n+}\n \n-\t\tvf->num_vf_qs = pf->num_qps_per_vf;\n-\t\tdev_dbg(dev, \"VF-id %d has %d queues configured\\n\", vf->vf_id,\n-\t\t\tvf->num_vf_qs);\n-\t\tice_cleanup_and_realloc_vf(vf);\n+/**\n+ * ice_vf_rebuild_vsi - rebuild the VF's VSI\n+ * @vf: VF to rebuild the VSI for\n+ *\n+ * This is only called when all VF(s) are being reset (i.e. PCIe Reset on the\n+ * host, PFR, CORER, etc.).\n+ */\n+static int ice_vf_rebuild_vsi(struct ice_vf *vf)\n+{\n+\tstruct ice_pf *pf = vf->pf;\n+\tstruct ice_vsi *vsi;\n+\n+\tvsi = pf->vsi[vf->lan_vsi_idx];\n+\n+\tif (ice_vsi_rebuild(vsi, true)) {\n+\t\tdev_err(ice_pf_to_dev(pf), \"failed to rebuild VF %d VSI\\n\",\n+\t\t\tvf->vf_id);\n+\t\treturn -EIO;\n \t}\n+\t/* vsi->idx will remain the same in this case so don't update\n+\t * vf->lan_vsi_idx\n+\t */\n+\tvsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx);\n+\tvf->lan_vsi_num = vsi->vsi_num;\n \n-\tice_flush(hw);\n-\tclear_bit(__ICE_VF_DIS, pf->state);\n+\treturn 0;\n+}\n \n-\treturn true;\n+/**\n+ * ice_vf_set_initialized - VF is ready for VIRTCHNL communication\n+ * @vf: VF to set in initialized state\n+ *\n+ * After this function the VF will be ready to receive/handle the\n+ * VIRTCHNL_OP_GET_VF_RESOURCES message\n+ */\n+static void ice_vf_set_initialized(struct ice_vf *vf)\n+{\n+\tice_set_vf_state_qs_dis(vf);\n+\tclear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states);\n+\tclear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states);\n+\tclear_bit(ICE_VF_STATE_DIS, vf->vf_states);\n+\tset_bit(ICE_VF_STATE_INIT, vf->vf_states);\n+}\n+\n+/**\n+ * ice_vf_post_vsi_rebuild - tasks to do after the VF's VSI have been rebuilt\n+ * @vf: VF to perform tasks on\n+ */\n+static void ice_vf_post_vsi_rebuild(struct ice_vf *vf)\n+{\n+\tstruct ice_pf *pf = vf->pf;\n+\tstruct ice_hw *hw;\n+\n+\thw = &pf->hw;\n+\n+\tice_vf_rebuild_host_cfg(vf);\n+\n+\tice_vf_set_initialized(vf);\n+\tice_ena_vf_mappings(vf);\n+\twr32(hw, VFGEN_RSTAT(vf->vf_id), VIRTCHNL_VFR_VFACTIVE);\n }\n \n /**\n@@ -1232,21 +1189,13 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)\n \tice_for_each_vf(pf, v) {\n \t\tvf = &pf->vf[v];\n \n-\t\tice_free_vf_res(vf);\n-\n-\t\t/* Free VF queues as well, and reallocate later.\n-\t\t * If a given VF has different number of queues\n-\t\t * configured, the request for update will come\n-\t\t * via mailbox communication.\n-\t\t */\n-\t\tvf->num_vf_qs = 0;\n+\t\tice_vf_pre_vsi_rebuild(vf);\n+\t\tice_vf_rebuild_vsi(vf);\n+\t\tice_vf_post_vsi_rebuild(vf);\n \t}\n \n-\tif (ice_sriov_free_msix_res(pf))\n-\t\tdev_err(dev, \"Failed to free MSIX resources used by SR-IOV\\n\");\n-\n-\tif (!ice_config_res_vfs(pf))\n-\t\treturn false;\n+\tice_flush(hw);\n+\tclear_bit(__ICE_VF_DIS, pf->state);\n \n \treturn true;\n }\n@@ -1358,12 +1307,9 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)\n \t\t\tdev_err(dev, \"disabling promiscuous mode failed\\n\");\n \t}\n \n-\t/* free VF resources to begin resetting the VSI state */\n-\tice_free_vf_res(vf);\n-\n-\tice_cleanup_and_realloc_vf(vf);\n-\n-\tice_flush(hw);\n+\tice_vf_pre_vsi_rebuild(vf);\n+\tice_vf_rebuild_vsi_with_release(vf);\n+\tice_vf_post_vsi_rebuild(vf);\n \n \treturn true;\n }\n", "prefixes": [ "S45", "09/15" ] }