From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796151830; b=PXKi/p/FBEYy4NruqrITgXBlYvxZCU+d52JTvNvg7yR0IxvFzyCHek4cURL2CztUdbi5 nrsnWqHfrqLP2EeuMpuu/Ew0eSAnlcoMZuPiZodmv7qDfC5VpiQn0MwtlygFgmCHj7m2o Fu2U+i/51yb/4iWKNOigsN5egP1mBgKiZR/FiZkykaX26Dy95ENqIMyxu+9tQXstjW5on 7DMach/JAE0R7gynf4YhpqWMfLYsfBCc35lfWnsOj0Q4u+w/UL7YshUdkX5g8GJh7wYFc Key+uGJrmhW0IDqc9G6frgMJ/ZNF+rZbqVcmnsSOH966tIF0DZeUDwezpHHWOZl2ocA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796151830; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=kCzp5cKPkD0NTHEp5ksGEySv5gOPp3xf/vNBzLeRx+4=; b=YJ6XHO/b21MT31B1xqSeiGcAVPEPGPYEojSv/FBswD+6iD90+GaRa70I7zgt/9GpTikl LHCv1YKXpZIbNWE8qUOMczzipMHXGoV56j1zdiBtNZr6foKP9smOUgv5pKizEdQoK4xH3 k+UmpOOZoSYELPwIPe/8dx0gbmbqTof2al6nXN4NVxAqcI5YnzacY6xtnj2aY86zn3VI1 om9UkHXYx9EpU/bMGWzYIhw8X1poYo8hn5u6NDy1dh9xrE5yUk5CB+X1O2sQfoehYirtW PeAQOg7qpQ+Pq53ye0u0VymGlXtGip212K79nHyd8CUGqfzxwImELScPGWkT1z35poQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=dSCAG5ki; arc=none smtp.remote-ip=148.163.158.5 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC7EB606A330 for ; Tue, 1 Dec 2026 19:03:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC7EB606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=dSCAG5ki Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F5qX62125326; Tue, 1 Dec 2026 19:03:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=kCzp5cKPkD0NTHEp5 ksGEySv5gOPp3xf/vNBzLeRx+4=; b=dSCAG5kimb/HLw0efuwpOoUp4nqLbPrho Zy7uExFdqnDcgLZyokno55Qi7kIAleh4gDS7I96PpNUJXc08wEgaLUvznw1LG9yq MYUAO3GBUi3DvfCsmtEfpwBF0eegHySZD6Xesp7d2YSDogpRDF8RMyHHhev5+Ksg hPm2R7OxrDW5UIznbsXvDRFs+oS+0vzSP21DCf+x+XV00TSenuLMJn3oVwOMOlrP LnoCwKa3WcDi9dy5zyQNgSOClEoaCL2PU3QPRv8FicpZSkeFUb5tbgJ81X9+EPWp BYDOxuCnHWs2SECzjNEvqkXOW4Ulh6GPco+4o4iOk5uZFz7Hf9/eQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pku5qwq-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 19:03:23 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1ItnTA3146973; Tue, 1 Dec 2026 19:03:23 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j9u5ft4dj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 19:03:23 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B1J3LCm57606452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 19:03:21 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E0295806F; Tue, 1 Dec 2026 19:03:20 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DAC958067; Tue, 1 Dec 2026 19:03:17 +0000 (GMT) Received: from localhost.localdomain (unknown [9.67.162.22]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 1 Dec 2026 19:03:17 +0000 (GMT) From: Mingming Cao To: netdev@vger.kernel.org Cc: Mingming Cao , maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com, nnac123@linux.ibm.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linuxppc-dev@lists.ozlabs.org, horms@kernel.org, davemarq@linux.ibm.com, haren@linux.ibm.com, ricklind@linux.ibm.com, bjking1@linux.ibm.com, shaik.abdulla1@ibm.com, willemb@google.com Subject: [PATCH net-next v9 11/13] ibmveth: Report per-queue statistics through netdev_stat_ops Date: Tue, 1 Dec 2026 11:02:14 -0800 Message-Id: <20261201190216.62407-12-mmc@linux.ibm.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20261201190216.62407-1-mmc@linux.ibm.com> References: <20261201190216.62407-1-mmc@linux.ibm.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=KZZHIgYD c=1 sm=1 tr=0 ts=6b0f19fc cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=h76Pv5blzH-fL-vHPGkA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA3NCBTYWx0ZWRfXx7HteHNqr+LI LmcPg8w9IlH/FWhpHlTv5QoT3eIp8jBQke33ov+4M/Tm9vVDlE7lfpdc6J5sYTZTKXH/H65GBU0 ix++Xw2ErJWCnG8a9inPj070NUsQwpPty4YSU2/qV+TKkC/hEGatf0QsX1bQwo8z4fjFkB9lhsZ ee1blIU4i+GQKddEAsFSD7bgO+jrB2oTslFRmTshH5WLRbiaqZHXp9YZEyAHzYnPTNH8PsF8SNh lHDjgDbzw28OzCTrOwdmggnAFEcf/797YBjfaCQKsbQCBtM/+xZbqwxOU+ePn8WvLUc0C5eJheL 4u8RWX5x3ab7FUH0CxCGvXXXRBwKA+zDAYYdOH/BDWyr0rklbpIZd+5z91REuHcqghmwJ3FcPM5 KGJ29AT6oNtPQNJGn9yf9/U0OQGizURNVc19DgvVpo6JWhpmqWpINAggUmE5pCm9rdH3OG8UCtB 7Az9z7fQTr6BYHn/Srw== X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA3NCBTYWx0ZWRfX9Miqspa26Svv lvJnIa72lTmMf9ovsIpfRtOVzbm0VvTj1pzljSnyY/QAxkqbNR3DSUajH8BnvggSvEohZcYW/Y3 51Cc0D5oIG5MSu6w6aeIYXNAJnGlsuU= X-Proofpoint-ORIG-GUID: DMhkFmbYgBdWuuEq8kPuJyfjFGXUpB1E X-Proofpoint-GUID: L3uzC8bnpOkpvLOx14Ax0OCg3l7bx8xY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010074 ip -s link and ethtool -S only show device totals, so they cannot show whether traffic is spread over the queues or which queue drops. Implement netdev_stat_ops so qstats-get shows each queue: packets and bytes, and for RX alloc_fail and PHYP's no-buffer drops as hw_drops and hw_drop_overruns. This already covers today's TX queues. RX alloc_fail counts failed skb allocations both when refilling buffers and for copybreak, which then passes the frame up in its pool buffer. Nothing counted the copybreak failures before. An invalid buffer PHYP hands back carries no frame, so it is not a hw_drop; it stays in ethtool -S as rx_invalid_buffer. A frame PHYP delivered but the driver then dropped is rx_dropped, not a hw_drop. TX hw_drops is left unset, because the TX drop count includes frames rejected before they reached PHYP. Queues above the live count are reported in the base stats, so the qstats total still matches ndo_get_stats64 after the queue count goes down. Signed-off-by: Mingming Cao --- drivers/net/ethernet/ibm/ibmveth.c | 75 +++++++++++++++++++++++++++++- drivers/net/ethernet/ibm/ibmveth.h | 1 + 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 56b645ffb18c..f30d8ba23320 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "ibmveth.h" @@ -2577,8 +2578,11 @@ static void ibmveth_poll_deliver_frame(struct napi_struct *napi, } new_skb = NULL; - if (length < rx_copybreak) + if (length < rx_copybreak) { new_skb = netdev_alloc_skb(netdev, length); + if (unlikely(!new_skb)) + IBMVETH_STAT_INC(rxs->copybreak_no_mem); + } if (new_skb) { skb_copy_to_linear_data(new_skb, skb->data + offset, length); @@ -2928,6 +2932,74 @@ static void ibmveth_get_stats64(struct net_device *dev, } } +static void ibmveth_get_queue_stats_rx(struct net_device *dev, int idx, + struct netdev_queue_stats_rx *stats) +{ + struct ibmveth_adapter *adapter = netdev_priv(dev); + u64 no_buffer; + + stats->packets = READ_ONCE(adapter->rx_qstats[idx].packets); + stats->bytes = READ_ONCE(adapter->rx_qstats[idx].bytes); + /* Frames PHYP dropped for lack of a posted buffer: the last sample + * of the live page plus pages this queue already released. + */ + no_buffer = ibmveth_rx_no_buffer_total(adapter, idx); + stats->hw_drops = no_buffer; + stats->hw_drop_overruns = no_buffer; + stats->alloc_fail = + READ_ONCE(adapter->rx_qstats[idx].replenish_no_mem) + + READ_ONCE(adapter->rx_qstats[idx].copybreak_no_mem); +} + +static void ibmveth_get_queue_stats_tx(struct net_device *dev, int idx, + struct netdev_queue_stats_tx *stats) +{ + struct ibmveth_adapter *adapter = netdev_priv(dev); + + stats->packets = READ_ONCE(adapter->tx_qstats[idx].packets); + stats->bytes = READ_ONCE(adapter->tx_qstats[idx].bytes); + /* TX hw_drops left unset: dropped_packets includes + * software xmit rejects that never reached PHYP. + */ +} + +/** + * ibmveth_get_base_stats - account for traffic not on a live queue + * @dev: network device + * @rx: RX base statistics storage + * @tx: TX base statistics storage + * + * The core sums get_queue_stats_{rx,tx}() only below + * real_num_{rx,tx}_queues, while ibmveth_get_stats64() walks every + * slot. Report the slots at or above real_num here so the two agree + * after the queue count goes down. + * + * Every field the queue callbacks set must be set here too: the core + * drops a field from the device total if the base leaves it unset. + */ +static void ibmveth_get_base_stats(struct net_device *dev, + struct netdev_queue_stats_rx *rx, + struct netdev_queue_stats_tx *tx) +{ + rx->packets = 0; + rx->bytes = 0; + rx->alloc_fail = 0; + rx->hw_drops = 0; + rx->hw_drop_overruns = 0; + tx->packets = 0; + tx->bytes = 0; + + netdev_stat_queue_sum(dev, dev->real_num_rx_queues, + IBMVETH_MAX_RX_QUEUES, rx, + dev->real_num_tx_queues, IBMVETH_MAX_QUEUES, tx); +} + +static const struct netdev_stat_ops ibmveth_stat_ops = { + .get_queue_stats_rx = ibmveth_get_queue_stats_rx, + .get_queue_stats_tx = ibmveth_get_queue_stats_tx, + .get_base_stats = ibmveth_get_base_stats, +}; + static const struct net_device_ops ibmveth_netdev_ops = { .ndo_open = ibmveth_open, .ndo_stop = ibmveth_close, @@ -3032,6 +3104,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) netdev->irq = dev->irq; netdev->netdev_ops = &ibmveth_netdev_ops; netdev->ethtool_ops = &netdev_ethtool_ops; + netdev->stat_ops = &ibmveth_stat_ops; SET_NETDEV_DEV(netdev, &dev->dev); netdev->hw_features = NETIF_F_SG; if (vio_get_attribute(dev, "ibm,illan-options", NULL) != NULL) { diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h index d6d28b75dd99..588209144de7 100644 --- a/drivers/net/ethernet/ibm/ibmveth.h +++ b/drivers/net/ethernet/ibm/ibmveth.h @@ -260,6 +260,7 @@ struct ibmveth_rx_queue_stats { u64 replenish_no_mem; u64 replenish_add_buff_failure; u64 replenish_add_buff_success; + u64 copybreak_no_mem; } ____cacheline_aligned_in_smp; /* Per-queue TX counters; serialized by the stack's per-queue TX lock. */ -- 2.50.1 (Apple Git-155)