From nobody Mon May 25 09:57:06 2026 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0EF43890F7 for ; Mon, 18 May 2026 05:31:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779082322; cv=none; b=cWSJghv3d7ghYH4+YdFE0/Pr7np60o4uAQ4hhAonVpDC0dQ270mDZhrl0EV58obgLAjFs4htuXZqIFL5cKVLDlOG6s96w5ACp+oWwMvzQXsyxNsMtvuTxMA/EoYw+bI+A78apfYh0GxIxP2NyYEra0NumIVhUcB0fL8xFTtjPsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779082322; c=relaxed/simple; bh=Ned4ol8vz7Bh1l/p1mUYhTl5oKEAmZypE4u6wrnLdZY=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=NVf8xk8Qu9zR1X/FSJkhw2Tly+DFGdieLzkmh7f/Guffjb7fZjCKDCmOBr17Rt7788iFycRy/WRdJyKX8sYwdnISOEWDgI9ViEjEsOpaoBHWCk9rxoqnvP3iZWtJ8xD9tZ8BkHgty/YTfXhn9ajlLlH2jtZ5o9QLpTPNsnN9tJ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=juliahub.com; spf=pass smtp.mailfrom=juliahub.com; dkim=pass (2048-bit key) header.d=juliahub.com header.i=@juliahub.com header.b=EWEnZj37; arc=none smtp.client-ip=209.85.222.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=juliahub.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=juliahub.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=juliahub.com header.i=@juliahub.com header.b="EWEnZj37" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-912575fa768so387222785a.2 for ; Sun, 17 May 2026 22:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliahub.com; s=google; t=1779082294; x=1779687094; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=YaCqS9VEHADAY4+Ko1Sdf5gqYjwOEBQdqfe6uNonwPQ=; b=EWEnZj37P+dGh9qdL5QCdeRIWmi1qg3dNKetN3BvT8sjOFA2RR8SqDw3eAvachszp5 ek0+hMK2W2g8q/bgSrNoe/GfzetpKSOHvjbaxH7IRLkjmOq+KdPRuT4VAil0FfRsBIMb jC5xeLvur3FTN6ygL9l9HFr7THiXx2dZ14Uaqw6AVVenN9lRExKFVORHBErqH23kVgQP 6ZoInaQrUZW7j8IPM03Hwg4hofJKG/dkdJJzudUf7IpMiHiGMlBru0zw44MtI8Nd8XUD +Wmao7+A8LRSqLvJJgf5vzMH5N9iiuEJ5lkUJxrnAuA5/oBfCHXCiwPWKB+/ijUFx3nL OQUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779082294; x=1779687094; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YaCqS9VEHADAY4+Ko1Sdf5gqYjwOEBQdqfe6uNonwPQ=; b=l4pQzRI8tpq6nb6Gvmz7r2O4P7fTUuu2Nh3yHtD4tJBSh8drEJhSbUXMYiMVnFkBxn p7PNFSM+frLrdDkJfyyPi+eBngQa+1awiJoWwrUeIbSUSVGW0ewjnulnbMi9s4DFRRXj GKWwsP5Ciph5w98009SVcSPgBH6FZ73luXflgycGiCtkKt3g1Rjy5VLle3aaN5VLMQ5A G5kZs/M5J71RkKs390k+vsjfVNmh+aEVnbkubTcma6GFvPgqgeRV5oeGtJIt4FY8CfLT j94ZXs2X3t1eLICYzbzBoZ6/CMQbFx9ol1Ld7QH7TE90loK87TucYvJHpcpSTvSDjR8E 0/wQ== X-Forwarded-Encrypted: i=1; AFNElJ+n1yY0UDEfpLz8vAFBmZ5/kZi80JtSuig1GN7bBhMuf15kuGIrWmo8ZHDfvv9Gq+NL17pS05X/lUVqbsQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwEtPT6/bmCuBqY8UWi2+CUYUHALCUlknsQ+TBcGmzxanJlr8lq +k0piKIxJCtRnTd1E7Df729SJPztjFVWmUybLFyb2HuLrPouMVMI4T1XFEKiIwG105c= X-Gm-Gg: Acq92OE2EPSatoXrFt86qiEnaE8ldPWA0pdRQqm0TvKP3nGfgkSByElYnJ9tpCd4UcZ mLblm74SEXc2ACRgXvFbT6t+BfNzM/wluvFkNyl+bP0uuxxycRdAHjSzpiDNipA+6ZFTAfwarp8 VSGvbP1zPzTVq2j0PS1cu7IkugaSgAoVVwe1sumYfF5pOiDRn1s2811WSiOjdVICj9j7u2DfjgP cP2nT9ea/M5iQoex144zvERvGaoQ44miUjh8BY50bXu6Ch947ZqZa9S3dB7R1keHF2Xj4W3CibF QnE1uqOCxu8OOwYeadyWv1zXsNFgbVGCPzmbiRs0eo8uKhtPXsKJZO5mfO+eAt9voUyg+xIBiF5 P4DGHqD/bbTzEaveLkFZ+SLSzZmWUpyYC9M9KBRFx6QpMmaBJ261grCw0uYE9bkG577FnfE18A/ UauLNDEJDPMW+oeWLlVmm0x6HDO0GFFgCqaj1AvnasI+CZeZY00ZC6 X-Received: by 2002:a05:620a:4514:b0:913:7bc8:79b9 with SMTP id af79cd13be357-9137bc88256mr898007585a.22.1779082293918; Sun, 17 May 2026 22:31:33 -0700 (PDT) Received: from juliahub.com ([66.31.114.203]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910ba36e1acsm1381641185a.3.2026.05.17.22.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2026 22:31:33 -0700 (PDT) Date: Mon, 18 May 2026 01:31:31 -0400 From: Keno Fischer To: netdev@vger.kernel.org Cc: Ido Schimmel , Petr Machata , linux-kernel@vger.kernel.org Subject: [PATCH net-next] mlxsw: spectrum_ethtool: expose per-PG rx_discards Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" PPCNT group 0x10 (per-priority counters) carries an rx_discards field at offset 0x78. These counters aggregate up into if_in_discards, but don't show up anywhere else. Since there are many things that aggregate into `if_in_discards`, having these counters helps distinguish what caused those discards (in my case they were caused by headroom buffer overruns due to inappropriately configured buffer sizes). Of note, from emperical testing, these counter are per-"priority group" (PG) not per-"switch priority". It's a bit confusing, because the rest of these counter are per-"switch priority" and the header file calls these "Per Priority Group Counters". However, that should be read as "(Per Priority) Group Counters", not "Per (Priority Group) Counters". I attempted to distinguish this in the counter naming by calling these `rx_discards_pg_N` rather than `rx_discards_prio_N` (which is the naming scheme of the other counters in this PPCNT group). I will also note that the mlx5 driver (which already has this counter) uses the schme `rx_prioN_discards` (and same for the other counters in this group). However, I was unable to determine whether the mlx5 counters behave the same as the mlxsw counters with respect to PG mapping. An attempt to remap to a different PG there did not change which counter incremented, but the mlx5 configuration code is quite different, so it's possible the remapping needs to be done differently. Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Keno Fischer Reviewed-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 8 ++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethern= et/mellanox/mlxsw/reg.h index 3bb89045eaf5..01fcbd1c8d01 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -5651,6 +5651,14 @@ MLXSW_ITEM64(reg, ppcnt, tx_pause_duration, MLXSW_ITEM64(reg, ppcnt, tx_pause_transition, MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64); =20 +/* reg_ppcnt_rx_discards + * Per-PG (ingress priority group) drop count. + * index slot is the PG, switch priority. + * Access: RO + */ +MLXSW_ITEM64(reg, ppcnt, rx_discards, + MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64); + /* Ethernet Per Traffic Class Counters */ =20 /* reg_ppcnt_tc_transmit_queue diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c b/drive= rs/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c index 0a8fb9c842d3..7f78b1ef61cc 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c @@ -542,6 +542,10 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_= prio_stats[] =3D { .str =3D "tx_pause_duration_prio", .getter =3D mlxsw_reg_ppcnt_tx_pause_duration_get, }, + { + .str =3D "rx_discards_pg", + .getter =3D mlxsw_reg_ppcnt_rx_discards_get, + }, }; =20 #define MLXSW_SP_PORT_HW_PRIO_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_prio_s= tats) --=20 2.54.0