From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 27FEA385D68 for ; Fri, 11 Sep 2026 11:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789126748; cv=none; b=VmD6iocvNRlZ1+p2UNK8whe7FuxSHOfv5mcSKULBIcRmCd8miaomWoIZFQunquGFHLIxJXtDdz3jq8iSFaR1iM4hhnnMcBEk9pZbAzIHGf01NI/Geq+m1UwuOp3NWG3d9hXRLcWj3UXa5L33S9b03yPlC6IiWPjEf/7Z+FRPla0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789126748; c=relaxed/simple; bh=yZGMqDQKZVafTUD6mXjzgg/r+vPOzWaA5vBTGT1HiBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PMH/D1Kp/LxM9s07nKNtjFmNwUr79TuTUh8RdGlzx/qLfLj3O9zPYW0Lzmekl/Gep550TfWWRfhAS3ijTNbJSoIslKmTyJvNGTbd8SYm21+f5kCQOvluEVXxR5WjcpJ4itQwaG27XRBvgSj97Tld+jo2kKOE3i8Q8w6bBDf7JtQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=l2xTsta+; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l2xTsta+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789126746; x=1820662746; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yZGMqDQKZVafTUD6mXjzgg/r+vPOzWaA5vBTGT1HiBU=; b=l2xTsta+t7l3gB42n4YCRpnT5HFZhEACpwc/5eNoqkbYNZR3vQty0Wbl JWSu6RnVW54Aw63ljW36+4f9uzXDW51r4MNX07GvwEVdIXEvafqq1Kz/E zi0nlrz68tR45Zu36eESae3By04Xrg4RRPuSPLZhY+/mtrX1suLtIUtkG 2jRWur6TiL1FNhxU5JrvuJNBuZB4STh/ImPcMPnN7GLzi9AArHRWS+lnM vo2uMeh5NMuDwao8CQe6c9iNo+z+OjrLb9il0cdUFYtHTTc29mjB9o1+L Pu1AUxeVTPbcDVwx6bXAS89wKl0SDzsU3rAkApTO7Efyyui9DLD8WyJP7 Q==; X-CSE-ConnectionGUID: 8RlMHTxFQ9WY9AAMoKUDIA== X-CSE-MsgGUID: 0h6GheJVREGdqWBNomMoiA== X-IronPort-AV: E=McAfee;i="6800,10657,11901"; a="112359895" X-IronPort-AV: E=Sophos;i="6.27,97,1787036400"; d="scan'208";a="112359895" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2026 04:39:05 -0700 X-CSE-ConnectionGUID: zAEWc20WTMGT7Sfm8kklEQ== X-CSE-MsgGUID: sX7sgY+cR9uAvZdEtPIeSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,97,1787036400"; d="scan'208";a="270135848" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa006.jf.intel.com with ESMTP; 11 Sep 2026 04:39:03 -0700 Received: from pkitszel-desk.intel.com (unknown [10.245.244.110]) by irvmail002.ir.intel.com (Postfix) with ESMTP id C2FB42877D; Fri, 11 Sep 2026 12:39:01 +0100 (IST) From: Przemek Kitszel To: netdev@vger.kernel.org, Jakub Kicinski Cc: Tony Nguyen , Aleksandr Loktionov , Michal Schmidt , intel-wired-lan@lists.osuosl.org, edumazet@google.com, horms@kernel.org, pabeni@redhat.com, davem@davemloft.net, Przemek Kitszel Subject: [PATCH net v3 2/5] ice: extract ice_vsi_new_stat_arrays() Date: Fri, 11 Sep 2026 13:26:17 +0200 Message-ID: <20260911113848.44086-3-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260911113848.44086-1-przemyslaw.kitszel@intel.com> References: <20260911113848.44086-1-przemyslaw.kitszel@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Split the allocation of a struct ice_vsi_stats and its two ring stats arrays out of ice_vsi_alloc_stat_arrays(), which is left with just the lookup and the store into pf->vsi_stats[]. The sole caller keeps passing the very same queue counts as before, vsi->alloc_txq and vsi->alloc_rxq. A later commit adds a second caller in the rebuild path, which cannot use vsi->alloc_* because it has to size the arrays before the VSI is reconfigured. Note that the error path no longer clears pf->vsi_stats[vsi->idx]; the early return above guarantees it is already NULL. No functional change intended. Signed-off-by: Przemek Kitszel --- drivers/net/ethernet/intel/ice/ice_lib.c | 47 +++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index cd78c5c69a30..9c2863fc696c 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -519,6 +519,30 @@ static irqreturn_t ice_msix_clean_rings(int __always_unused irq, void *data) return IRQ_HANDLED; } +static struct ice_vsi_stats *ice_vsi_new_stat_arrays(int txq, int rxq) +{ + struct ice_ring_stats **tx_ring_stats; + struct ice_ring_stats **rx_ring_stats; + struct ice_vsi_stats *vsi_stat; + + vsi_stat = kzalloc_obj(*vsi_stat); + tx_ring_stats = kzalloc_objs(*tx_ring_stats, txq); + rx_ring_stats = kzalloc_objs(*rx_ring_stats, rxq); + if (!vsi_stat || !tx_ring_stats || !rx_ring_stats) { + kfree(vsi_stat); + kfree(tx_ring_stats); + kfree(rx_ring_stats); + return NULL; + } + + vsi_stat->tx_ring_stats = tx_ring_stats; + vsi_stat->rx_ring_stats = rx_ring_stats; + vsi_stat->tx_ring_stats_len = txq; + vsi_stat->rx_ring_stats_len = rxq; + + return vsi_stat; +} + /** * ice_vsi_alloc_stat_arrays - Allocate statistics arrays * @vsi: VSI pointer @@ -537,33 +561,12 @@ static int ice_vsi_alloc_stat_arrays(struct ice_vsi *vsi) /* realloc will happen in rebuild path */ return 0; - vsi_stat = kzalloc_obj(*vsi_stat); + vsi_stat = ice_vsi_new_stat_arrays(vsi->alloc_txq, vsi->alloc_rxq); if (!vsi_stat) return -ENOMEM; - vsi_stat->tx_ring_stats = - kzalloc_objs(*vsi_stat->tx_ring_stats, vsi->alloc_txq); - if (!vsi_stat->tx_ring_stats) - goto err_alloc_tx; - vsi_stat->tx_ring_stats_len = vsi->alloc_txq; - - vsi_stat->rx_ring_stats = - kzalloc_objs(*vsi_stat->rx_ring_stats, vsi->alloc_rxq); - if (!vsi_stat->rx_ring_stats) - goto err_alloc_rx; - vsi_stat->rx_ring_stats_len = vsi->alloc_rxq; - pf->vsi_stats[vsi->idx] = vsi_stat; - return 0; - -err_alloc_rx: - kfree(vsi_stat->rx_ring_stats); -err_alloc_tx: - kfree(vsi_stat->tx_ring_stats); - kfree(vsi_stat); - pf->vsi_stats[vsi->idx] = NULL; - return -ENOMEM; } /** -- 2.51.1