From nobody Thu Oct 2 17:52:12 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61DAF26F2AE; Mon, 15 Sep 2025 03:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757908709; cv=none; b=NvuVnxOlaQzuQdlSrlXy9jfG/w3NQnht2gBEA1QWX9KTb46ogCdPjQAYgV0+9RH6Me8fsroh3giOi0F5qm2rY9WkkXELBdmI8kICZr46g8bKqASeBNLBDdaKqfgfQfDeaIKfQhAmqCjDBIRAd7hoaYIrp9rIyKhFD3f6SkbHFiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757908709; c=relaxed/simple; bh=NxaMXmGTje9Te5CzVe1bbLoNOCEC/t8BNzdL3H2fMi4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=JXO8MA58aK1WCOB+wuUbKchcvwqaQ04+o7yYRqc5JMBqLYKrSvgb4KsGyAEflCZRjtjIKtdVBaJ5W3he/3rMLJg8MVrL+aBWBPyxFCFmlmpzLqXrmq9IJNBV0y3rkXubxllZZvH2TADCako8Ixc6qMSv8TlV1bEWF5I2paramWw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=IPV/z36w; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="IPV/z36w" Received: by linux.microsoft.com (Postfix, from userid 1173) id B3FB3211AF25; Sun, 14 Sep 2025 20:58:21 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B3FB3211AF25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1757908701; bh=XoCQ+vaz3XuPF1NWaCGoDNsZ/5O4ZiE5qhcHedj6+FI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IPV/z36w5JUJZgVFc652HvQnlM+Z2lxy1Po5WFefG+ckZG7xeGQapPuydU+1r0gDv joZRxNZXT4Xdp3ieWBjt1+Xt3oxGdouOMvfjbc97PgON1wfADjWaI2JXbUk5o2h1s5 ycy09lxXTNKmG9m7uavYD59FZVLMdvnw4lZC0KQM= From: Erni Sri Satya Vennela To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, longli@microsoft.com, kotaranov@microsoft.com, horms@kernel.org, shradhagupta@linux.microsoft.com, dipayanroy@linux.microsoft.com, shirazsaleem@microsoft.com, ernis@linux.microsoft.com, rosenp@gmail.com, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 2/2] net: mana: Add standard counter rx_missed_errors Date: Sun, 14 Sep 2025 20:58:18 -0700 Message-Id: <1757908698-16778-3-git-send-email-ernis@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1757908698-16778-1-git-send-email-ernis@linux.microsoft.com> References: <1757908698-16778-1-git-send-email-ernis@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Report standard counter stats->rx_missed_errors using hc_rx_discards_no_wqe from the hardware. Add a dedicated workqueue to periodically run mana_query_gf_stats every 2 seconds to get the latest info in eth_stats and define a driver capability flag to notify hardware of the periodic queries. To avoid repeated failures and log flooding, the workqueue is not rescheduled if mana_query_gf_stats fails. Signed-off-by: Erni Sri Satya Vennela Reviewed-By: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana_en.c | 38 +++++++++++++++++-- .../ethernet/microsoft/mana/mana_ethtool.c | 2 - include/net/mana/gdma.h | 6 ++- include/net/mana/mana.h | 5 ++- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/et= hernet/microsoft/mana/mana_en.c index 787644229897..9213ae6ba038 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -494,6 +494,8 @@ static void mana_get_stats64(struct net_device *ndev, =20 netdev_stats_to_stats64(st, &ndev->stats); =20 + st->rx_missed_errors =3D apc->ac->hc_stats.hc_rx_discards_no_wqe; + for (q =3D 0; q < num_queues; q++) { rx_stats =3D &apc->rxqs[q]->stats; =20 @@ -2779,7 +2781,7 @@ int mana_config_rss(struct mana_port_context *apc, en= um TRI_STATE rx, return 0; } =20 -void mana_query_gf_stats(struct mana_context *ac) +int mana_query_gf_stats(struct mana_context *ac) { struct mana_query_gf_stat_resp resp =3D {}; struct mana_query_gf_stat_req req =3D {}; @@ -2822,14 +2824,14 @@ void mana_query_gf_stats(struct mana_context *ac) sizeof(resp)); if (err) { dev_err(dev, "Failed to query GF stats: %d\n", err); - return; + return err; } err =3D mana_verify_resp_hdr(&resp.hdr, MANA_QUERY_GF_STAT, sizeof(resp)); if (err || resp.hdr.status) { dev_err(dev, "Failed to query GF stats: %d, 0x%x\n", err, resp.hdr.status); - return; + return err; } =20 ac->hc_stats.hc_rx_discards_no_wqe =3D resp.rx_discards_nowqe; @@ -2864,6 +2866,8 @@ void mana_query_gf_stats(struct mana_context *ac) ac->hc_stats.hc_tx_mcast_pkts =3D resp.hc_tx_mcast_pkts; ac->hc_stats.hc_tx_mcast_bytes =3D resp.hc_tx_mcast_bytes; ac->hc_stats.hc_tx_err_gdma =3D resp.tx_err_gdma; + + return 0; } =20 void mana_query_phy_stats(struct mana_port_context *apc) @@ -3400,6 +3404,19 @@ int mana_rdma_service_event(struct gdma_context *gc,= enum gdma_service_type even return 0; } =20 +#define MANA_GF_STATS_PERIOD (2 * HZ) + +static void mana_gf_stats_work_handler(struct work_struct *work) +{ + struct mana_context *ac =3D + container_of(to_delayed_work(work), struct mana_context, gf_stats_work); + + if (mana_query_gf_stats(ac)) + return; + + queue_delayed_work(ac->gf_stats_wq, &ac->gf_stats_work, MANA_GF_STATS_PER= IOD); +} + int mana_probe(struct gdma_dev *gd, bool resuming) { struct gdma_context *gc =3D gd->gdma_context; @@ -3488,6 +3505,15 @@ int mana_probe(struct gdma_dev *gd, bool resuming) } =20 err =3D add_adev(gd, "eth"); + ac->gf_stats_wq =3D create_singlethread_workqueue("mana_gf_stats"); + if (!ac->gf_stats_wq) { + err =3D -ENOMEM; + goto out; + } + + INIT_DELAYED_WORK(&ac->gf_stats_work, mana_gf_stats_work_handler); + queue_delayed_work(ac->gf_stats_wq, &ac->gf_stats_work, MANA_GF_STATS_PER= IOD); + out: if (err) { mana_remove(gd, false); @@ -3511,6 +3537,12 @@ void mana_remove(struct gdma_dev *gd, bool suspendin= g) int err; int i; =20 + if (ac->gf_stats_wq) { + cancel_delayed_work_sync(&ac->gf_stats_work); + destroy_workqueue(ac->gf_stats_wq); + ac->gf_stats_wq =3D NULL; + } + /* adev currently doesn't support suspending, always remove it */ if (gd->adev) remove_adev(gd); diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/n= et/ethernet/microsoft/mana/mana_ethtool.c index 3dfd96146424..99e811208683 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c @@ -213,8 +213,6 @@ static void mana_get_ethtool_stats(struct net_device *n= dev, =20 if (!apc->port_is_up) return; - /* we call mana function to update stats from GDMA */ - mana_query_gf_stats(apc->ac); =20 /* We call this mana function to get the phy stats from GDMA and includes * aggregate tx/rx drop counters, Per-TC(Traffic Channel) tx/rx and pause diff --git a/include/net/mana/gdma.h b/include/net/mana/gdma.h index 57df78cfbf82..88a81fb164a0 100644 --- a/include/net/mana/gdma.h +++ b/include/net/mana/gdma.h @@ -591,6 +591,9 @@ enum { /* Driver can self reset on FPGA Reconfig EQE notification */ #define GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE BIT(17) =20 +/* Driver can send HWC periodically to query stats */ +#define GDMA_DRV_CAP_FLAG_1_PERIODIC_STATS_QUERY BIT(21) + #define GDMA_DRV_CAP_FLAGS1 \ (GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \ GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX | \ @@ -599,7 +602,8 @@ enum { GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP | \ GDMA_DRV_CAP_FLAG_1_DYNAMIC_IRQ_ALLOC_SUPPORT | \ GDMA_DRV_CAP_FLAG_1_SELF_RESET_ON_EQE | \ - GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE) + GDMA_DRV_CAP_FLAG_1_HANDLE_RECONFIG_EQE | \ + GDMA_DRV_CAP_FLAG_1_PERIODIC_STATS_QUERY) =20 #define GDMA_DRV_CAP_FLAGS2 0 =20 diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index 519c4384c51f..74f112bcdc02 100644 --- a/include/net/mana/mana.h +++ b/include/net/mana/mana.h @@ -480,6 +480,9 @@ struct mana_context { struct mana_eq *eqs; struct dentry *mana_eqs_debugfs; =20 + struct workqueue_struct *gf_stats_wq; + struct delayed_work gf_stats_work; + struct net_device *ports[MAX_PORTS_IN_MANA_DEV]; }; =20 @@ -577,7 +580,7 @@ u32 mana_run_xdp(struct net_device *ndev, struct mana_r= xq *rxq, struct bpf_prog *mana_xdp_get(struct mana_port_context *apc); void mana_chn_setxdp(struct mana_port_context *apc, struct bpf_prog *prog); int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf); -void mana_query_gf_stats(struct mana_context *ac); +int mana_query_gf_stats(struct mana_context *ac); int mana_query_link_cfg(struct mana_port_context *apc); int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed, int enable_clamping); --=20 2.34.1