From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 017F2C87FDA for ; Fri, 8 Aug 2025 20:33:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A7E8E811FE; Fri, 8 Aug 2025 20:33:21 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id uCaTzLx0QDFl; Fri, 8 Aug 2025 20:33:21 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0ED018120E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1754685201; bh=83pEEJ3EH9xiLisnJqrBX5cyQMN+wvtYIT3ozfAy2U8=; h=Date:From:To:Cc:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WqpuUPEaMCZ5DJdE/l6wwdcAnQBu3H4FZqgnRHFJSb5xi5vwgTuMGypth/XtgYXNF d3nEF44pFqOhtjF/JB+EqwePJXt0bRfMxRWlw/B9m2HDOsvzEmLRwWnCXOnvmY9v3x Z16imFTDtLWlj9oxgPNFxjyYgqpRkRBU5EzEX/eqSpUKtRZi8YoUa1yG6+omzSoxNN 9sX0y3q6pQe7GvY16q1IosfKY/pS/cTPpM5ouMCFahOurLaznoh6fNOLdoHryBsruw rBVvbWF0QlhduElJ+VpV2DwzlbEuEeXzsDnTmt4aVVBiVKZREuyIUUtm0qe3tdLID0 74/79giW8IHtA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 0ED018120E; Fri, 8 Aug 2025 20:33:21 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists1.osuosl.org (Postfix) with ESMTP id 5DBA49D6 for ; Fri, 8 Aug 2025 20:33:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4333260B11 for ; Fri, 8 Aug 2025 20:33:19 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id uLoq2PoVtqIB for ; Fri, 8 Aug 2025 20:33:18 +0000 (UTC) X-Greylist: delayed 1073 seconds by postgrey-1.37 at util1.osuosl.org; Fri, 08 Aug 2025 20:33:18 UTC DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org B366160ADC DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B366160ADC Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2604:1380:4641:c500::1; helo=dfw.source.kernel.org; envelope-from=kuba@kernel.org; receiver= Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by smtp3.osuosl.org (Postfix) with ESMTPS id B366160ADC for ; Fri, 8 Aug 2025 20:33:18 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E65385C6B45; Fri, 8 Aug 2025 20:15:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 271DDC4CEED; Fri, 8 Aug 2025 20:15:23 +0000 (UTC) Date: Fri, 8 Aug 2025 13:15:22 -0700 From: Jakub Kicinski To: Vadim Fedorenko Cc: Andrew Lunn , Michael Chan , Pavan Chebbi , Tariq Toukan , Gal Pressman , , Donald Hunter , Carolina Jubran , Paolo Abeni , Simon Horman , , Vadim Fedorenko Message-ID: <20250808131522.0dc26de4@kernel.org> In-Reply-To: <20250807155924.2272507-1-vadfed@meta.com> References: <20250807155924.2272507-1-vadfed@meta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754684123; bh=b0vC1D2LWBsSz1Gq4TjUw1tPlccN4Nq4ISgtAe4DlFg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=V2BhD5Md2HU5mz0K7D853WNotiUvhi4qNx/WfKoz7Y5NwhYelP2gk39VIr8kuDM4+ Rw8Eb5/ivEHBa5xvNzjoRoC+TIQRNMvQW9BJP547vcqR6e8mI1HPP/0k6IQbSt9La7 G8gXFsyfdBzVxa1zIUeBpkfG0SVQy6vHnopM1rGCaPdCkhpCM7S2ybaVXmV6cPDFXY esotkpwVHTBY1TW36nZRWQB5OHg8t7/4lvoNaep6ZH9rQ0VGFcN38jVP+o72B2YWy7 sYBur4K3cGnxp42uHV0AS0S8QF2vVvIAGyZ+jvCO1PCOs5t9AOM30ZTl0mrIBvMJ6L LaCvwiy3R1fNQ== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=V2BhD5Md Subject: Re: [Intel-wired-lan] [RFC PATCH v4] ethtool: add FEC bins histogramm report X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 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" On Thu, 7 Aug 2025 08:59:24 -0700 Vadim Fedorenko wrote: > + /* add FEC bins information */ > + len += (nla_total_size(0) + /* _A_FEC_HIST */ > + nla_total_size(4) + /* _A_FEC_HIST_BIN_LOW */ > + nla_total_size(4) + /* _A_FEC_HIST_BIN_HI */ > + /* _A_FEC_HIST_BIN_VAL + per-lane values */ > + nla_total_size_64bit(sizeof(u64) * > + (1 + ETHTOOL_MAX_LANES))) * That's the calculation for basic stats because they are reported as a raw array. Each nla_put() should correspond to a nla_total_size(). This patch nla_put()s things individually. > + ETHTOOL_FEC_HIST_MAX; > + } > > return len; > } > > +static int fec_put_hist(struct sk_buff *skb, const struct ethtool_fec_hist *hist) > +{ > + const struct ethtool_fec_hist_range *ranges = hist->ranges; > + const struct ethtool_fec_hist_value *values = hist->values; > + struct nlattr *nest; > + int i, j; > + > + if (!ranges) > + return 0; > + > + for (i = 0; i < ETHTOOL_FEC_HIST_MAX; i++) { > + if (i && !ranges[i].low && !ranges[i].high) > + break; > + > + if (WARN_ON_ONCE(values[i].bin_value == ETHTOOL_STAT_NOT_SET)) > + break; > + > + nest = nla_nest_start(skb, ETHTOOL_A_FEC_STAT_HIST); > + if (!nest) > + return -EMSGSIZE; > + > + if (nla_put_u32(skb, ETHTOOL_A_FEC_HIST_BIN_LOW, > + ranges[i].low) || > + nla_put_u32(skb, ETHTOOL_A_FEC_HIST_BIN_HIGH, > + ranges[i].high) || > + nla_put_uint(skb, ETHTOOL_A_FEC_HIST_BIN_VAL, > + values[i].bin_value)) > + goto err_cancel_hist; > + for (j = 0; j < ETHTOOL_MAX_LANES; j++) { > + if (values[i].bin_value_per_lane[j] == ETHTOOL_STAT_NOT_SET) > + break; > + nla_put_uint(skb, ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE, > + values[i].bin_value_per_lane[j]); TBH I'm a bit unsure if this is really worth breaking out into individual nla_puts(). We generally recommend that, but here it's an array of simple ints.. maybe we're better of with a binary / C array of u64. Like the existing FEC stats but without also folding the total value into index 0. From mboxrd@z Thu Jan 1 00:00:00 1970 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 BCE9A1F2BBB for ; Fri, 8 Aug 2025 20:15:23 +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=1754684123; cv=none; b=YqnwkVL/sWpBuE1mzvqgSIZ9sOLwH3aLRZdtf0JnLOOC5maiV7FlFGmUJk7aQdSuR8cFDJ1BBrRaYFHz+s8uK9JWXHcB4CZi8jIaoVsUItJWjRRUtp2r+zBbNBTgQBMt8B6SrkCLCSS55Tz6t9QS4EgzfJ/sIvix89oXjuS1w1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754684123; c=relaxed/simple; bh=b0vC1D2LWBsSz1Gq4TjUw1tPlccN4Nq4ISgtAe4DlFg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BgQSvct2u511vaLiKRQrbD+TGlhDQuy/TzIDlgU4NSMBeGaZdv3zQ1QptJqM5z2SGstgUd+7n/vuvmSgBY8SxU6xgjQ+Bdb2gQk9CXQXLSjm5wEyWC1cqP9iJhVoFWDxDAJ2T8xnouyZTEkNOAQtznGHAcZOIQAJZ5S/dZrSUNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V2BhD5Md; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V2BhD5Md" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 271DDC4CEED; Fri, 8 Aug 2025 20:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754684123; bh=b0vC1D2LWBsSz1Gq4TjUw1tPlccN4Nq4ISgtAe4DlFg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=V2BhD5Md2HU5mz0K7D853WNotiUvhi4qNx/WfKoz7Y5NwhYelP2gk39VIr8kuDM4+ Rw8Eb5/ivEHBa5xvNzjoRoC+TIQRNMvQW9BJP547vcqR6e8mI1HPP/0k6IQbSt9La7 G8gXFsyfdBzVxa1zIUeBpkfG0SVQy6vHnopM1rGCaPdCkhpCM7S2ybaVXmV6cPDFXY esotkpwVHTBY1TW36nZRWQB5OHg8t7/4lvoNaep6ZH9rQ0VGFcN38jVP+o72B2YWy7 sYBur4K3cGnxp42uHV0AS0S8QF2vVvIAGyZ+jvCO1PCOs5t9AOM30ZTl0mrIBvMJ6L LaCvwiy3R1fNQ== Date: Fri, 8 Aug 2025 13:15:22 -0700 From: Jakub Kicinski To: Vadim Fedorenko Cc: Andrew Lunn , Michael Chan , Pavan Chebbi , Tariq Toukan , Gal Pressman , , Donald Hunter , Carolina Jubran , Paolo Abeni , Simon Horman , , Vadim Fedorenko Subject: Re: [RFC PATCH v4] ethtool: add FEC bins histogramm report Message-ID: <20250808131522.0dc26de4@kernel.org> In-Reply-To: <20250807155924.2272507-1-vadfed@meta.com> References: <20250807155924.2272507-1-vadfed@meta.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 7 Aug 2025 08:59:24 -0700 Vadim Fedorenko wrote: > + /* add FEC bins information */ > + len += (nla_total_size(0) + /* _A_FEC_HIST */ > + nla_total_size(4) + /* _A_FEC_HIST_BIN_LOW */ > + nla_total_size(4) + /* _A_FEC_HIST_BIN_HI */ > + /* _A_FEC_HIST_BIN_VAL + per-lane values */ > + nla_total_size_64bit(sizeof(u64) * > + (1 + ETHTOOL_MAX_LANES))) * That's the calculation for basic stats because they are reported as a raw array. Each nla_put() should correspond to a nla_total_size(). This patch nla_put()s things individually. > + ETHTOOL_FEC_HIST_MAX; > + } > > return len; > } > > +static int fec_put_hist(struct sk_buff *skb, const struct ethtool_fec_hist *hist) > +{ > + const struct ethtool_fec_hist_range *ranges = hist->ranges; > + const struct ethtool_fec_hist_value *values = hist->values; > + struct nlattr *nest; > + int i, j; > + > + if (!ranges) > + return 0; > + > + for (i = 0; i < ETHTOOL_FEC_HIST_MAX; i++) { > + if (i && !ranges[i].low && !ranges[i].high) > + break; > + > + if (WARN_ON_ONCE(values[i].bin_value == ETHTOOL_STAT_NOT_SET)) > + break; > + > + nest = nla_nest_start(skb, ETHTOOL_A_FEC_STAT_HIST); > + if (!nest) > + return -EMSGSIZE; > + > + if (nla_put_u32(skb, ETHTOOL_A_FEC_HIST_BIN_LOW, > + ranges[i].low) || > + nla_put_u32(skb, ETHTOOL_A_FEC_HIST_BIN_HIGH, > + ranges[i].high) || > + nla_put_uint(skb, ETHTOOL_A_FEC_HIST_BIN_VAL, > + values[i].bin_value)) > + goto err_cancel_hist; > + for (j = 0; j < ETHTOOL_MAX_LANES; j++) { > + if (values[i].bin_value_per_lane[j] == ETHTOOL_STAT_NOT_SET) > + break; > + nla_put_uint(skb, ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE, > + values[i].bin_value_per_lane[j]); TBH I'm a bit unsure if this is really worth breaking out into individual nla_puts(). We generally recommend that, but here it's an array of simple ints.. maybe we're better of with a binary / C array of u64. Like the existing FEC stats but without also folding the total value into index 0.