Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yanze Zhang" <zhang.yanze@zte.com.cn>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma v10 2/7] RDMA/zrdma: Add core data structures and ABI definitions
Date: Thu, 03 Dec 2026 13:21:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-247849@kernel.org> (raw)
In-Reply-To: <20261203124928.48716-3-zhang.yanze@zte.com.cn>

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] RDMA/zrdma: UAPI naming, legacy versioning, and comment
  defects in zrdma_abi.h
- [Medium] RDMA/zrdma: unimplemented tool flags and physical DB mode in
  UAPI zrdma_abi.h
- [Medium] RDMA/zrdma: private untyped auxiliary device contract in
  zrdma_type.h
- [Low] RDMA/zrdma: missing linux/types.h in zrdma_ctrl.h and unused
  header includes
- [Low] RDMA/zrdma: zrdma_type.h includes disallowed internal header
  linux/msi.h
- [Low] RDMA/zrdma: ucontext feature_flags bits omitted from UAPI header
  zrdma_abi.h
--

commit 4a62fdca8db6526c72b37236b1beb85ab11eb48b
Author: Yanze Zhang <zhang.yanze@zte.com.cn>

RDMA/zrdma: Add core data structures and ABI definitions

This commit adds the initial internal data structure headers and the
user-space ABI header for the ZTE DingHai RDMA driver.

> diff --git a/drivers/infiniband/hw/zrdma/zrdma_ctrl.h b/drivers/infiniband/hw/zrdma/zrdma_ctrl.h
> new file mode 100644
> index 0000000000000..935b4cbd3e4a9
> --- /dev/null
> +++ b/drivers/infiniband/hw/zrdma/zrdma_ctrl.h
> @@ -0,0 +1,20 @@
[ ... ]
> +struct zxdh_hw {
> +	struct device *device;
> +};
> +
> +struct zxdh_sc_dev {
> +	u32 max_ceqs;
> +	u8 ep_id;
> +	u8 driver_load;
> +};
> diff --git a/drivers/infiniband/hw/zrdma/zrdma_defs.h b/drivers/infiniband/hw/zrdma/zrdma_defs.h
> new file mode 100644
> index 0000000000000..208f1f60bbaee
> --- /dev/null
> +++ b/drivers/infiniband/hw/zrdma/zrdma_defs.h
> @@ -0,0 +1,19 @@
[ ... ]
> +#include <linux/bitfield.h>
> +#include <rdma/ib_verbs.h>

[Severity: Low]
Can zrdma_ctrl.h fail to compile when included standalone?  struct
zxdh_sc_dev uses u32 and u8 without including linux/types.h, and struct
zxdh_hw references struct device * without forward-declaring struct
device.

Also, zrdma_defs.h includes linux/bitfield.h and rdma/ib_verbs.h even
though neither header is used anywhere in the file.  Adding linux/types.h
and a struct device forward declaration to zrdma_ctrl.h and dropping the
unused includes from zrdma_defs.h would keep both headers self-contained.

> diff --git a/drivers/infiniband/hw/zrdma/zrdma_type.h b/drivers/infiniband/hw/zrdma/zrdma_type.h
> new file mode 100644
> index 0000000000000..ded4052453455
> --- /dev/null
> +++ b/drivers/infiniband/hw/zrdma/zrdma_type.h
> @@ -0,0 +1,86 @@
[ ... ]
> +#include <linux/auxiliary_bus.h>
> +#include <linux/msi.h>

[Severity: Low]
Should zrdma_type.h include linux/msi.h?  include/linux/msi.h is
restricted to interrupt, PCI/MSI, and IOMMU core code and explicitly
states that regular device drivers have no business including it
(driver-facing MSI APIs live in linux/msi_api.h).

The only MSI-related type here is struct msix_entry *, which belongs to
linux/pci.h, and both struct pci_dev and struct msix_entry are only
referenced by pointer.  Removing linux/msi.h and using forward
declarations or linux/pci.h (alongside linux/bits.h and linux/types.h)
would avoid the core-internal header.

[ ... ]

> +struct zxdh_rdma_core_ops {
> +	int (*request_reset)(struct zxdh_rdma_core_dev *cdev,
> +			     enum zxdh_rdma_reset_type reset_type);
> +	int (*zxdh_common_func)(void *in_param, void *out_param, u32 opcode);
> +};
> +
> +struct zxdh_rdma_ver_info {
> +	u16 major;
> +	u16 minor;
> +	u64 support; /* 0~7:net_major,8~15:net_minor,16~23:rdma_minor,24~63:rscv */
> +};
[ ... ]
> +struct zxdh_rdma_core_dev {
> +	struct pci_dev *pdev;
> +	struct auxiliary_device *adev;
> +	u8 __iomem *hw_addr;
> +	int zdev_info_id;
> +	struct zxdh_rdma_ver_info ver;
> +	void *auxiliary_priv;
> +	enum zxdh_function_type ftype;
> +	u16 vport_id;
> +	u16 slot_id;
> +	enum zxdh_rdma_protocol rdma_protocol;
> +
> +	struct zxdh_qos_params qos_info;
> +	struct msix_entry *msix_entries;
> +	u16 msix_count;
> +	const struct zxdh_rdma_core_ops *ops;
> +	void *dh_dev;
> +};
> +
> +struct zxdh_rdma_if {
> +	void *(*get_rdma_netdev)(void *dh_dev);
> +};
> +
> +struct zxdh_auxiliary_dev {
> +	struct auxiliary_device adev;
> +	struct zxdh_rdma_core_dev *zxdh_info;
> +	struct zxdh_rdma_if *rdma_ops;
> +	void *ops;
> +	void *parent;
> +	s32 aux_id;
> +	void *auxiliary_ops[18];
> +};

[Severity: Medium]
Should struct zxdh_auxiliary_dev and the shared PF-to-RDMA interface
structures live in a shared header under include/linux/ rather than
privately in zrdma_type.h?

As documented in include/linux/auxiliary_bus.h, the parent object
embedding struct auxiliary_device and the shared objects it points to
must be defined in a shared header included by both drivers.  Keeping
private copies here bypasses compile-time layout and signature checking,
so any divergence from the PF driver causes silent type confusion or
memory corruption when zxdh_probe() casts the auxiliary device with
container_of().

These definitions also carry untyped void * fields (such as
auxiliary_ops[18], get_rdma_netdev() returning void *, and the
zxdh_common_func() opcode multiplexer), internal kernel-to-kernel ABI
versioning in struct zxdh_rdma_ver_info, and legacy struct msix_entry *.
In addition, the in-tree dinghai10e PF driver under
drivers/net/ethernet/zte/dinghai/ defines none of these structures and
registers no auxiliary device, leaving this driver unable to bind
in-tree.

> diff --git a/include/uapi/rdma/zrdma_abi.h b/include/uapi/rdma/zrdma_abi.h
> new file mode 100644
> index 0000000000000..53f15591f894e
> --- /dev/null
> +++ b/include/uapi/rdma/zrdma_abi.h
> @@ -0,0 +1,114 @@
[ ... ]
> +#define ZXDH_ABI_VER 5
> +
> +/* The versions of the context that the user space can ask for with
> + * struct zxdh_alloc_ucontext_req.userspace_ver. A version tells the
> + * driver which features of the user space are available.
> + */
> +#define ZXDH_CONTEXT_VER_V1 5
> +#define ZXDH_CONTEXT_VER_V2 6
> +#define ZXDH_CONTEXT_VER_V3 7

[Severity: Medium]
Should this UAPI header follow the <driver>-abi.h naming convention and
drop legacy out-of-tree ABI versioning before it becomes permanent UAPI?

All existing RDMA provider headers in include/uapi/rdma/ use a hyphen
(such as irdma-abi.h and mlx5-abi.h), so zrdma_abi.h introduces a
permanent naming inconsistency once merged.  For a brand-new upstream
driver, starting ZXDH_ABI_VER at 5 with three legacy context versions
(ZXDH_CONTEXT_VER_V1..V3), carrying an unused leading rsvd32 field in
struct zxdh_alloc_ucontext_req, omitting comp_mask, and ending struct
zxdh_alloc_ucontext_resp with 12 trailing reserved bytes (__u16 rsv[6])
hinders future udata->outlen-based UAPI extension.

The struct comments also reference non-existent commands
(INFINIBAND_UVERBS_CMD_ALLOC_CONTEXT and INFINIBAND_UVERBS_CMD_ALLOC_PD
instead of IB_USER_VERBS_CMD_GET_CONTEXT and IB_USER_VERBS_CMD_ALLOC_PD),
and describe the rdma_tool_flags bitmask as "one of the enum
zxdh_rdma_tool_flags".

> +enum zxdh_rdma_tool_flags {
> +	ZXDH_QP_EXTEND_OP = 1 << 0,
> +	ZXDH_CAPTURE = 1 << 1,
> +	ZXDH_GET_HW_DATA = 1 << 2,
> +	ZXDH_GET_HW_OBJECT_DATA = 1 << 3,
> +	ZXDH_CHECK_HW_HEALTH = 1 << 4,
> +	ZXDH_RDMA_TOOL_CFG_DEV_PARAM = 1 << 5,
> +	ZXDH_RDMA_TOOL_READ_RAM = 1 << 6,
> +	ZXDH_RDMA_TOOL_DEVX_MODIFY_CQ = 1 << 7,
> +	ZXDH_RDMA_SET_CREDIT_CAP = 1 << 8,
> +	ZXDH_RDMA_SWITCH = 1 << 9,
> +	ZXDH_RDMA_TOOL_DEVX_EXT_MEM = 1 << 10,
> +	ZXDH_RDMA_TOOL_PRIV_EXT = 1 << 11,
> +	ZXDH_RDMA_TOOL_IOVA_CAP = 1 << 12,
> +};
> +
> +enum zxdh_db_addr_type {
> +	ZXDH_DB_ADDR_PHY = 0,
> +	ZXDH_DB_ADDR_BAR = 1,
> +};

[Severity: Medium]
Should unimplemented vendor tool flags and a physical-address doorbell
mode be exposed in a permanent UAPI header?

None of the 13 flags in enum zxdh_rdma_tool_flags have any backing
implementation in the driver, yet zxdh_alloc_ucontext() later in the
series unconditionally advertises all 13 bits to userspace.  Exposing
proprietary RAM reads, packet capture, hardware parameter configuration,
and private extensions through ucontext flags bypasses standard
interfaces (devlink, rdma netlink, fwctl, debugfs) and locks unreviewed
vendor tooling into UAPI.

Similarly, ZXDH_DB_ADDR_PHY in enum zxdh_db_addr_type is never used and
conflicts with kernel-userspace isolation and the rdma_user_mmap_entry
BAR-mapping model.

[ ... ]

> +	/* The features that the driver supports. */
> +	__aligned_u64 feature_flags;

[Severity: Low]
Should the feature_flags bit constants be defined in zrdma_abi.h?

The driver populates uresp.feature_flags using ZXDH_FEATURE_RTS_AE,
ZXDH_FEATURE_CQ_RESIZE, and ZXDH_FEATURE_64_BYTE_CQE from the private
kernel header drivers/infiniband/hw/zrdma/zrdma_defs.h.  Leaving them out
of the installed UAPI header forces userspace providers to duplicate
private magic bit values and risks silent ABI divergence.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203124928.48716-1-zhang.yanze@zte.com.cn?part=2

  reply	other threads:[~2026-12-03 13:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 12:49 [PATCH rdma v10 0/7] Add ZTE DingHai Ethernet Protocol Driver for RDMA Yanze Zhang
2026-12-03 12:49 ` [PATCH rdma v10 1/7] RDMA/zrdma: Add build infrastructure and module skeleton Yanze Zhang
2026-12-03 13:19   ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 2/7] RDMA/zrdma: Add core data structures and ABI definitions Yanze Zhang
2026-12-03 13:21   ` sashiko-bot [this message]
2026-12-03 12:49 ` [PATCH rdma v10 3/7] RDMA/zrdma: Add internal headers and hardware register definitions Yanze Zhang
2026-12-03 13:17   ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 4/7] RDMA/zrdma: Add hardware resource initialization and verbs skeleton Yanze Zhang
2026-12-03 13:20   ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 5/7] RDMA/zrdma: Implement device and port query operations Yanze Zhang
2026-12-03 13:32   ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 6/7] RDMA/zrdma: Add device probe and remove logic Yanze Zhang
2026-12-03 13:28   ` sashiko-bot
2026-12-03 12:49 ` [PATCH rdma v10 7/7] RDMA/zrdma: Implement context, PD, and mmap operations Yanze Zhang

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-247849@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhang.yanze@zte.com.cn \
    /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