From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 BC9092E8DEB; Sat, 17 Oct 2026 15:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792252513; cv=none; b=FQevBZ2ClEiBM8Bpc9bKWUjjnC8tUE9LhEgNNqH+nPCMpJ+1yTYBKdwSWvsO8aBYwh5w9BlDabigtmiY5cW8Tk7o3jWvC+npuBfYydtzWvhwHLljmPZbeialBSCkpwx5+G4U8aIViHN0be7orGeIIK7vxkyc9I3Qa8wplxCnNQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792252513; c=relaxed/simple; bh=UnJLthOkVMKcfRKgH+9gjG1zPiDouRbr5kgO9Dz2G1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qCJV3saL2ev86jkxuRnW2tdL+viQBnDC+twQOECNU7fmRkKJBR8EPEtuWFTb0ZrWr54gfOpRLDesZSq3u8NjwdbtX/fZlhHS/7FZoeGhGJO2cpZOgKRZOlu93okLun1tcJtUzRF3onjq2Jx5hsEMBbzxm5ZQvkOp4K5Hv39euy0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bNDuPdVu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bNDuPdVu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B33941F000C4; Sat, 17 Oct 2026 15:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792252511; bh=u2eZPRcJg1bgcQ9OiG+n/FGz8Qo/uRfi/0BoOrVnQk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bNDuPdVuJxOTjfqAoD/m0BF4/yo2FJLqg6gBiO4Zd+cZs8Dz15Dc5MllQabUitPa2 s3aAmekd5k4e8FFhkv7LAw4hV7uIK2Eg1yPQEzs7hZG8NnQaPR5YIRUB0L32Yd0kPc tSdgq0oPC99W6cBB2Iomj/vjSlvplsvWMZ4fKlSE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haiyang Zhang , Dipayaan Roy , Jakub Kicinski , Sasha Levin Subject: [PATCH 7.2 07/10] net: mana: refactor mana_get_strings() and mana_get_sset_count() to use switch Date: Sat, 17 Oct 2026 17:54:36 +0200 Message-ID: <20261017155059.959758790@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017155059.698368299@linuxfoundation.org> References: <20261017155059.698368299@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dipayaan Roy [ Upstream commit d52f80731055ee43b36bf60088679aca97a484da ] Refactor mana_get_strings() and mana_get_sset_count() from if/else to switch statements in preparation for adding ethtool private flags support which requires handling ETH_SS_PRIV_FLAGS. No functional change. Reviewed-by: Haiyang Zhang Signed-off-by: Dipayaan Roy Link: https://patch.msgid.link/20260729063347.3388035-2-dipayanroy@linux.microsoft.com Signed-off-by: Jakub Kicinski Stable-dep-of: 259c4a519100 ("net: mana: reserve RX buffer headroom to fix forwarding performance") Signed-off-by: Sasha Levin --- .../ethernet/microsoft/mana/mana_ethtool.c | 75 ++++++++++++------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c index 881df597d7f9c..3531abfdaf433 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c @@ -138,53 +138,70 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset) struct mana_port_context *apc = netdev_priv(ndev); unsigned int num_queues = apc->num_queues; - if (stringset != ETH_SS_STATS) + switch (stringset) { + case ETH_SS_STATS: + return ARRAY_SIZE(mana_eth_stats) + + ARRAY_SIZE(mana_phy_stats) + + ARRAY_SIZE(mana_hc_stats) + + num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT); + default: return -EINVAL; - - return ARRAY_SIZE(mana_eth_stats) + ARRAY_SIZE(mana_phy_stats) + ARRAY_SIZE(mana_hc_stats) + - num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT); + } } -static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) +static void mana_get_strings_stats(struct mana_port_context *apc, u8 **data) { - struct mana_port_context *apc = netdev_priv(ndev); unsigned int num_queues = apc->num_queues; int i, j; - if (stringset != ETH_SS_STATS) - return; for (i = 0; i < ARRAY_SIZE(mana_eth_stats); i++) - ethtool_puts(&data, mana_eth_stats[i].name); + ethtool_puts(data, mana_eth_stats[i].name); for (i = 0; i < ARRAY_SIZE(mana_hc_stats); i++) - ethtool_puts(&data, mana_hc_stats[i].name); + ethtool_puts(data, mana_hc_stats[i].name); for (i = 0; i < ARRAY_SIZE(mana_phy_stats); i++) - ethtool_puts(&data, mana_phy_stats[i].name); + ethtool_puts(data, mana_phy_stats[i].name); for (i = 0; i < num_queues; i++) { - ethtool_sprintf(&data, "rx_%d_packets", i); - ethtool_sprintf(&data, "rx_%d_bytes", i); - ethtool_sprintf(&data, "rx_%d_xdp_drop", i); - ethtool_sprintf(&data, "rx_%d_xdp_tx", i); - ethtool_sprintf(&data, "rx_%d_xdp_redirect", i); - ethtool_sprintf(&data, "rx_%d_pkt_len0_err", i); + ethtool_sprintf(data, "rx_%d_packets", i); + ethtool_sprintf(data, "rx_%d_bytes", i); + ethtool_sprintf(data, "rx_%d_xdp_drop", i); + ethtool_sprintf(data, "rx_%d_xdp_tx", i); + ethtool_sprintf(data, "rx_%d_xdp_redirect", i); + ethtool_sprintf(data, "rx_%d_pkt_len0_err", i); for (j = 0; j < MANA_RXCOMP_OOB_NUM_PPI - 1; j++) - ethtool_sprintf(&data, "rx_%d_coalesced_cqe_%d", i, j + 2); + ethtool_sprintf(data, + "rx_%d_coalesced_cqe_%d", + i, + j + 2); } for (i = 0; i < num_queues; i++) { - ethtool_sprintf(&data, "tx_%d_packets", i); - ethtool_sprintf(&data, "tx_%d_bytes", i); - ethtool_sprintf(&data, "tx_%d_xdp_xmit", i); - ethtool_sprintf(&data, "tx_%d_tso_packets", i); - ethtool_sprintf(&data, "tx_%d_tso_bytes", i); - ethtool_sprintf(&data, "tx_%d_tso_inner_packets", i); - ethtool_sprintf(&data, "tx_%d_tso_inner_bytes", i); - ethtool_sprintf(&data, "tx_%d_long_pkt_fmt", i); - ethtool_sprintf(&data, "tx_%d_short_pkt_fmt", i); - ethtool_sprintf(&data, "tx_%d_csum_partial", i); - ethtool_sprintf(&data, "tx_%d_mana_map_err", i); + ethtool_sprintf(data, "tx_%d_packets", i); + ethtool_sprintf(data, "tx_%d_bytes", i); + ethtool_sprintf(data, "tx_%d_xdp_xmit", i); + ethtool_sprintf(data, "tx_%d_tso_packets", i); + ethtool_sprintf(data, "tx_%d_tso_bytes", i); + ethtool_sprintf(data, "tx_%d_tso_inner_packets", i); + ethtool_sprintf(data, "tx_%d_tso_inner_bytes", i); + ethtool_sprintf(data, "tx_%d_long_pkt_fmt", i); + ethtool_sprintf(data, "tx_%d_short_pkt_fmt", i); + ethtool_sprintf(data, "tx_%d_csum_partial", i); + ethtool_sprintf(data, "tx_%d_mana_map_err", i); + } +} + +static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) +{ + struct mana_port_context *apc = netdev_priv(ndev); + + switch (stringset) { + case ETH_SS_STATS: + mana_get_strings_stats(apc, &data); + break; + default: + break; } } -- 2.53.0