From patchwork Wed Sep 11 12:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13800503 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 ABE7D192D7A for ; Wed, 11 Sep 2024 12:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726058739; cv=none; b=eEH5mCfMlSzgQP4GPdtlwAK7yL8hIhkalskQkJOvTR4jHMpRGAXsEFwq8TbVZzahcSeZ3r2IN4OFROt7oDzl+bjyToIpfsNDZG+YCaBCz/G2IJ3JgBO1CNEzsg8ABiscJ4Vr09W7aGiFb79cN/xyiQDxNpH9jIxWcurgQgPJOLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726058739; c=relaxed/simple; bh=GpBXJ8l4uJQtDS8IPiAFVquc6Shzyo155zcTOx1QMks=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BxT/KiWOCDuG1xxj/MDaHRRvklKEM75yd2qIpUzzrr1t1+mTAEqtwyJaVvXJ5+YGg+wY2ues0Wjq0sTP/W3wM+sylHRo+0SfmQbqSFFT0mur/vmhqWxwmu2doHpTDsZU7xldgIg4pIYacuUqvUPGR5YCqLM3tf29fZpZAGxpJGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=McJMPhis; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="McJMPhis" Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48BCCF8m009245; Wed, 11 Sep 2024 05:45:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= s2048-2021-q4; bh=ljhP+KQA00AA/EipLhihfTlRgwLjy5uWG6bRs2zyf0I=; b= McJMPhisw1WtUQKu5kHPOCyw3ygIukalKb+4cVrV7nr/szVLXTMVBzmvA1uqlPrA f6vAPyK+XVvFtal2ruyqyjlh5hLm4CCOl3P0q8tHim+7Yt4VF+yyuMB4l0mdH0q5 nqGbwjtMM6omG6rWfAv1BqQ9eQ1qd9eOldOquhoiYjcDH3vafXrN9BlyH36Ttj8r SR15f4yj/Z19EAkk3xMoCO0Uy4AfNVJspAq4AHHL/wEjIPYh3tfYyNuRA4IVB5Zv SwrrybUZPzN3Tt3cDWy4L5gN93hOfWRkgmUs9EqstvOpqsJ41sqfuHN11lq/viSY fGol2LyrJ28g8RLMz377ag== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 41jh2eh7vp-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 11 Sep 2024 05:45:29 -0700 (PDT) Received: from devvm4158.cln0.facebook.com (2620:10d:c0a8:1c::11) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server id 15.2.1544.11; Wed, 11 Sep 2024 12:45:26 +0000 From: Vadim Fedorenko To: Vadim Fedorenko , Jakub Kicinski , David Ahern , Paolo Abeni , "David S. Miller" , Alexander Duyck CC: Vadim Fedorenko , Subject: [PATCH net-next 5/5] eth: fbnic: add ethtool timestamping statistics Date: Wed, 11 Sep 2024 05:45:13 -0700 Message-ID: <20240911124513.2691688-6-vadfed@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240911124513.2691688-1-vadfed@meta.com> References: <20240911124513.2691688-1-vadfed@meta.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: agwLqlqyOh1ZeMqk8x8Qgf4JND4SPT1B X-Proofpoint-ORIG-GUID: agwLqlqyOh1ZeMqk8x8Qgf4JND4SPT1B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_12,2024-09-09_02,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org Add counters of packets with HW timestamps requests and lost timestamps with no associated skbs. Use ethtool interface to report these counters. Signed-off-by: Vadim Fedorenko --- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 24 +++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 9 ++++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c index 24e059443264..1117d5a32867 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -93,9 +93,33 @@ fbnic_get_eth_mac_stats(struct net_device *netdev, &mac_stats->eth_mac.FrameTooLongErrors); } +static void fbnic_get_ts_stats(struct net_device *netdev, + struct ethtool_ts_stats *ts_stats) +{ + struct fbnic_net *fbn = netdev_priv(netdev); + u64 ts_packets, ts_lost; + struct fbnic_ring *ring; + unsigned int start; + int i; + + ts_stats->pkts = fbn->tx_stats.ts_packets; + ts_stats->lost = fbn->tx_stats.ts_lost; + for (i = 0; i < fbn->num_tx_queues; i++) { + ring = fbn->tx[i]; + do { + start = u64_stats_fetch_begin(&ring->stats.syncp); + ts_packets = ring->stats.ts_packets; + ts_lost = ring->stats.ts_lost; + } while (u64_stats_fetch_retry(&ring->stats.syncp, start)); + ts_stats->pkts += ts_packets; + ts_stats->lost += ts_lost; + } +} + static const struct ethtool_ops fbnic_ethtool_ops = { .get_drvinfo = fbnic_get_drvinfo, .get_ts_info = fbnic_get_ts_info, + .get_ts_stats = fbnic_get_ts_stats, .get_eth_mac_stats = fbnic_get_eth_mac_stats, }; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c index 5659fb69ac06..7f6d0d0c2969 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c @@ -382,7 +382,7 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget, struct fbnic_ring *ring, bool discard, unsigned int hw_head) { - u64 total_bytes = 0, total_packets = 0; + u64 total_bytes = 0, total_packets = 0, ts_lost = 0; unsigned int head = ring->head; struct netdev_queue *txq; unsigned int clean_desc; @@ -401,6 +401,7 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget, FBNIC_XMIT_CB(skb)->hw_head = hw_head; if (likely(!discard)) break; + ts_lost++; } ring->tx_buf[head] = NULL; @@ -440,6 +441,7 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget, if (unlikely(discard)) { u64_stats_update_begin(&ring->stats.syncp); ring->stats.dropped += total_packets; + ring->stats.ts_lost += ts_lost; u64_stats_update_end(&ring->stats.syncp); netdev_tx_completed_queue(txq, total_packets, total_bytes); @@ -501,6 +503,9 @@ static void fbnic_clean_tsq(struct fbnic_napi_vector *nv, } skb_tstamp_tx(skb, &hwtstamp); + u64_stats_update_begin(&ring->stats.syncp); + ring->stats.ts_packets++; + u64_stats_update_end(&ring->stats.syncp); } static void fbnic_page_pool_init(struct fbnic_ring *ring, unsigned int idx, @@ -1057,6 +1062,8 @@ static void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn, fbn->tx_stats.bytes += stats->bytes; fbn->tx_stats.packets += stats->packets; fbn->tx_stats.dropped += stats->dropped; + fbn->tx_stats.ts_lost += stats->ts_lost; + fbn->tx_stats.ts_packets += stats->ts_packets; } static void fbnic_remove_tx_ring(struct fbnic_net *fbn, diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h index 682d875f08c0..8d626287c3f4 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.h @@ -57,6 +57,8 @@ struct fbnic_queue_stats { u64 packets; u64 bytes; u64 dropped; + u64 ts_packets; + u64 ts_lost; struct u64_stats_sync syncp; };