Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1849045lql; Wed, 13 Mar 2024 09:45:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVCtx5ADCGHXH7j0lQffKPIVqBsf9GPRfknFqfth2Ex0HoxQ9Cg5zpR/w1Tx1atZ/zdi8+d+m7bA/+AAwVwWX7aB4IEvQinfzKs32mOOA== X-Google-Smtp-Source: AGHT+IFVXuruGWxdLkoaqToDp/jlAqmq6xCuuex21Xx28JObW1BatKcArQ3RMiSTXnrfB+JNZyfn X-Received: by 2002:a05:6a00:4fcb:b0:6e6:7af6:2201 with SMTP id le11-20020a056a004fcb00b006e67af62201mr2875104pfb.8.1710348315135; Wed, 13 Mar 2024 09:45:15 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u13-20020a63d34d000000b005cfc084b80esi9431970pgi.221.2024.03.13.09.45.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:45:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=aHgRohfR; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-101753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CCCB128A5B8 for ; Wed, 13 Mar 2024 16:36:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BB194CE04; Wed, 13 Mar 2024 16:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aHgRohfR" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 493425B697; Wed, 13 Mar 2024 16:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347576; cv=none; b=JQCUTaOtWQd+udLo5WrFHwAEokiaxSbva7uwcY/PsrB9e6pNAAK4qEMh0ycKJmko/j7NzvZIR7iMGEXSw16hLBk85Ql1zH38U+8XTLrhiKojPQD8TAMBjJ/BpR/x8DnAzGXijbD0tT1n9tTI6WiKcolNTCa3o1fLY7Fife6e3/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347576; c=relaxed/simple; bh=iwV/fblvI1VOEpcS3mFyNF4i49FmQMh+toJyOiB6s3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qd1Q5sh6X6jeex8ZRfwWxHBckky9fmrMZ0CpjKd9xRB3ZrHJz2jmGO3Ux0iUkePj8BQvMHYMKXimlHhePI6gx2lbLhPKAFd1cOpjX3O42jcxwubnbNflpfflAdI3rcfMXit+6yJKMBC3ECLfdmBBChe89tcxtmQyhd1jJ8y+Wmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aHgRohfR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D6F8C43399; Wed, 13 Mar 2024 16:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710347576; bh=iwV/fblvI1VOEpcS3mFyNF4i49FmQMh+toJyOiB6s3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHgRohfRdh6l9E6o0lbYdkD57KTOfX3ff0bZFg0UUsCTjqHk/6NAQbYtZURqa+QK1 b7O/GH5TyFfXPve3YITSB3opnyZR3iDIcpy63b8P9MrpmENMc586lNpwZwrKwdF1rW W8oinIA3Ou3VioeJB4yKWaLTtrKWjQ4vTXPkHvDX2QqpPiOgl4wLSXM9K6O4MMDsZu Ey2eouUuG+LXQxc1qvBmBuTjtN+Wf8kiR6IReGaBWS2F+PIPulJjmTdApHQIK/zKWv ydJZdxAgUU9+gyUxsoYiSYm9p9vtyAypkgqON0wRNe8vMb6mIB1pYI7N9n+Fdk2O95 iMFsBydC3rWjg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jacob Keller , Przemek Kitszel , Petr Oros , Rafal Romanowski , Tony Nguyen , Sasha Levin Subject: [PATCH 6.7 14/61] ice: replace ice_vf_recreate_vsi() with ice_vf_reconfig_vsi() Date: Wed, 13 Mar 2024 12:31:49 -0400 Message-ID: <20240313163236.613880-15-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163236.613880-1-sashal@kernel.org> References: <20240313163236.613880-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.7.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.7.10-rc1 X-KernelTest-Deadline: 2024-03-15T16:32+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jacob Keller [ Upstream commit 2a2cb4c6c18130e9f14d2e39deb75590744d98ef ] The ice_vf_create_vsi() function and its VF ops helper introduced by commit a4c785e8162e ("ice: convert vf_ops .vsi_rebuild to .create_vsi") are used during an individual VF reset to re-create the VSI. This was done in order to ensure that the VSI gets properly reconfigured within the hardware. This is somewhat heavy handed as we completely release the VSI memory and structure, and then create a new VSI. This can also potentially force a change of the VSI index as we will re-use the first open slot in the VSI array which may not be the same. As part of implementing devlink reload, commit 6624e780a577 ("ice: split ice_vsi_setup into smaller functions") split VSI setup into smaller functions, introducing both ice_vsi_cfg() and ice_vsi_decfg() which can be used to configure or deconfigure an existing software VSI structure. Rather than completely removing the VSI and adding a new one using the create_vsi() VF operation, simply use ice_vsi_decfg() to remove the current configuration. Save the VSI type and then call ice_vsi_cfg() to reconfigure the VSI as the same type that it was before. The existing reset logic assumes that all hardware filters will be removed, so also call ice_fltr_remove_all() before re-configuring the VSI. This new operation does not re-create the VSI, so rename it to ice_vf_reconfig_vsi(). The new approach can safely share the exact same flow for both SR-IOV VFs as well as the Scalable IOV VFs being worked on. This uses less code and is a better abstraction over fully deleting the VSI and adding a new one. Signed-off-by: Jacob Keller Reviewed-by: Przemek Kitszel Reviewed-by: Petr Oros Tested-by: Rafal Romanowski Signed-off-by: Tony Nguyen Stable-dep-of: 4035c72dc1ba ("ice: reconfig host after changing MSI-X on VF") Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_sriov.c | 24 ++----------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 35 +++++++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 - .../ethernet/intel/ice/ice_vf_lib_private.h | 1 + 4 files changed, 28 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c index e1494f24f661d..c4caa9df473b5 100644 --- a/drivers/net/ethernet/intel/ice/ice_sriov.c +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c @@ -762,24 +762,6 @@ static void ice_sriov_clear_reset_trigger(struct ice_vf *vf) ice_flush(hw); } -/** - * ice_sriov_create_vsi - Create a new VSI for a VF - * @vf: VF to create the VSI for - * - * This is called by ice_vf_recreate_vsi to create the new VSI after the old - * VSI has been released. - */ -static int ice_sriov_create_vsi(struct ice_vf *vf) -{ - struct ice_vsi *vsi; - - vsi = ice_vf_vsi_setup(vf); - if (!vsi) - return -ENOMEM; - - return 0; -} - /** * ice_sriov_post_vsi_rebuild - tasks to do after the VF's VSI have been rebuilt * @vf: VF to perform tasks on @@ -799,7 +781,6 @@ static const struct ice_vf_ops ice_sriov_vf_ops = { .poll_reset_status = ice_sriov_poll_reset_status, .clear_reset_trigger = ice_sriov_clear_reset_trigger, .irq_close = NULL, - .create_vsi = ice_sriov_create_vsi, .post_vsi_rebuild = ice_sriov_post_vsi_rebuild, }; @@ -1147,8 +1128,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count) if (vf->first_vector_idx < 0) goto unroll; - ice_vf_vsi_release(vf); - if (vf->vf_ops->create_vsi(vf)) { + if (ice_vf_reconfig_vsi(vf)) { /* Try to rebuild with previous values */ needs_rebuild = true; goto unroll; @@ -1175,7 +1155,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count) return -EINVAL; if (needs_rebuild) - vf->vf_ops->create_vsi(vf); + ice_vf_reconfig_vsi(vf); ice_ena_vf_mappings(vf); ice_put_vf(vf); diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c index b7ae099521566..88e3cd09f8d0c 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -248,29 +248,44 @@ static void ice_vf_pre_vsi_rebuild(struct ice_vf *vf) } /** - * ice_vf_recreate_vsi - Release and re-create the VF's VSI - * @vf: VF to recreate the VSI for + * ice_vf_reconfig_vsi - Reconfigure a VF VSI with the device + * @vf: VF to reconfigure the VSI for * - * This is only called when a single VF is being reset (i.e. VVF, VFLR, host - * VF configuration change, etc) + * This is called when a single VF is being reset (i.e. VVF, VFLR, host VF + * configuration change, etc). * - * It releases and then re-creates a new VSI. + * It brings the VSI down and then reconfigures it with the hardware. */ -static int ice_vf_recreate_vsi(struct ice_vf *vf) +int ice_vf_reconfig_vsi(struct ice_vf *vf) { + struct ice_vsi *vsi = ice_get_vf_vsi(vf); + struct ice_vsi_cfg_params params = {}; struct ice_pf *pf = vf->pf; int err; - ice_vf_vsi_release(vf); + if (WARN_ON(!vsi)) + return -EINVAL; + + params = ice_vsi_to_params(vsi); + params.flags = ICE_VSI_FLAG_NO_INIT; - err = vf->vf_ops->create_vsi(vf); + ice_vsi_decfg(vsi); + ice_fltr_remove_all(vsi); + + err = ice_vsi_cfg(vsi, ¶ms); if (err) { dev_err(ice_pf_to_dev(pf), - "Failed to recreate the VF%u's VSI, error %d\n", + "Failed to reconfigure the VF%u's VSI, error %d\n", vf->vf_id, err); return err; } + /* Update the lan_vsi_num field since it might have been changed. The + * PF lan_vsi_idx number remains the same so we don't need to change + * that. + */ + vf->lan_vsi_num = vsi->vsi_num; + return 0; } @@ -929,7 +944,7 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) ice_vf_pre_vsi_rebuild(vf); - if (ice_vf_recreate_vsi(vf)) { + if (ice_vf_reconfig_vsi(vf)) { dev_err(dev, "Failed to release and setup the VF%u's VSI\n", vf->vf_id); err = -EFAULT; diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h index 93c774f2f4376..6b41e0f3d37ed 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h @@ -62,7 +62,6 @@ struct ice_vf_ops { bool (*poll_reset_status)(struct ice_vf *vf); void (*clear_reset_trigger)(struct ice_vf *vf); void (*irq_close)(struct ice_vf *vf); - int (*create_vsi)(struct ice_vf *vf); void (*post_vsi_rebuild)(struct ice_vf *vf); }; diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib_private.h b/drivers/net/ethernet/intel/ice/ice_vf_lib_private.h index 0c7e77c0a09fa..91ba7fe0eaee1 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib_private.h @@ -23,6 +23,7 @@ #warning "Only include ice_vf_lib_private.h in CONFIG_PCI_IOV virtualization files" #endif +int ice_vf_reconfig_vsi(struct ice_vf *vf); void ice_initialize_vf_entry(struct ice_vf *vf); void ice_dis_vf_qs(struct ice_vf *vf); int ice_check_vf_init(struct ice_vf *vf); -- 2.43.0