From: sashiko-bot@kernel.org
To: "Xin Tian" <tianx@yunsilicon.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH v1 15/15] RDMA/xsc: add RDMA counters and sysfs
Date: Thu, 05 Nov 2026 16:09:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-199437@kernel.org> (raw)
In-Reply-To: <20261104155726.37053-16-tianx@yunsilicon.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] RDMA/xsc: cast counter pointers to __be64 * in xsc_ib_get_hw_stats()
--
commit 9a3d01fb1064f09ed97cbe2bb05c71e3ed77198c
Author: Xin Tian <tianx@yunsilicon.com>
RDMA/xsc: add RDMA counters and sysfs
This commit adds the RDMA hw_stats callbacks to query per-function and
card-global statistics from firmware, and exposes the hca_type and hw_rev
sysfs attributes on the ib_device class device.
> diff --git a/drivers/infiniband/hw/xsc/counters.c b/drivers/infiniband/hw/xsc/counters.c
> new file mode 100644
> index 0000000000000..c29a5bf8007f1
> --- /dev/null
> +++ b/drivers/infiniband/hw/xsc/counters.c
> @@ -0,0 +1,134 @@
[ ... ]
> +int xsc_ib_get_hw_stats(struct ib_device *ib_dev, struct rdma_hw_stats *stats,
> + u32 port_num, int index)
> +{
> + struct xsc_core_device *xdev = to_xdev(ib_dev)->xdev;
> + struct xsc_hw_stats_rdma stats_rdma;
> + u8 *hw_stats;
> + int ret;
> + int i;
> +
> + ret = xsc_ib_query_hw_stats_rdma(xdev, &stats_rdma);
> + if (ret)
> + return ret;
> +
> + hw_stats = (u8 *)&stats_rdma.stats.pf_stats;
> +
> + for (i = 0; i < stats->num_counters && i < XSC_NUM_PF_STATS; i++)
> + stats->value[i] =
> + be64_to_cpu(*(u64 *)(hw_stats + (uintptr_t)stats->descs[i].priv));
> +
> + if (stats->num_counters > XSC_NUM_PF_STATS) {
> + struct xsc_hw_global_stats_mbox_in gin = {};
> + struct xsc_hw_global_stats_mbox_out gout = {};
> +
> + gin.hdr.opcode = cpu_to_be16(XSC_CMD_OP_QUERY_HW_GLOBAL_STATS);
> + ret = xsc_cmd_exec(xdev, &gin, sizeof(gin), &gout, sizeof(gout));
> + if (ret || gout.hdr.status)
> + return -EIO;
> +
> + hw_stats = (u8 *)&gout.hw_stats;
> + for (i = XSC_NUM_PF_STATS; i < stats->num_counters; i++)
> + stats->value[i] = be64_to_cpu(
> + *(u64 *)(hw_stats + (uintptr_t)stats->descs[i].priv));
> + }
[Severity: Low]
In xsc_ib_get_hw_stats(), both loops cast the counter field address to
u64 * before passing the dereferenced value to be64_to_cpu().
In drivers/net/ethernet/yunsilicon/xsc/common/xsc_cmd.h, the counter
fields in struct xsc_hw_stats_rdma_pf and struct xsc_hw_global_stats_rdma
are declared as __be64. Passing a host-typed u64 expression to
be64_to_cpu() triggers Sparse endianness warnings (cast to restricted
__be64) when building with C=1.
Should these casts in xsc_ib_get_hw_stats() use (__be64 *) instead of
(u64 *)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261104155650.37053-1-tianx@yunsilicon.com?part=15
prev parent reply other threads:[~2026-11-05 16:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 15:57 [PATCH v1 00/15] Yunsilicon XSC ethernet and RDMA drivers Xin Tian
2026-11-04 15:56 ` [PATCH v1 01/15] MAINTAINERS: add the Yunsilicon XSC drivers Xin Tian
2026-11-04 15:56 ` [PATCH v1 02/15] net/xsc: add PCI core driver skeleton Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:56 ` [PATCH v1 03/15] net/xsc: add the register HAL Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 04/15] net/xsc: add the command queue Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 05/15] net/xsc: add event queues, interrupts and the Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 06/15] net/xsc: add the CQ and QP resource pools Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 07/15] net/xsc: add ethernet netdev registration Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 08/15] net/xsc: add ethernet TX path Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 09/15] net/xsc: add ethernet RX path and statistics Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 10/15] RDMA/xsc: add RDMA device support Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 11/15] RDMA/xsc: add RDMA PD/MR Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 12/15] RDMA/xsc: add RDMA CQ/SRQ/AH Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 13/15] RDMA/xsc: add QP verbs Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 14/15] RDMA/xsc: add the RDMA send path Xin Tian
2026-11-05 16:09 ` sashiko-bot
2026-11-04 15:57 ` [PATCH v1 15/15] RDMA/xsc: add RDMA counters and sysfs Xin Tian
2026-11-05 16:09 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-199437@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tianx@yunsilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox