Re: [PATCH v2 04/11] net/xsc: query HCA capabilities and reset function

From: Jason Xing

Date: Sun Nov 29 2026 - 02:48:54 EST


On Thu, Nov 26, 2026 at 10:57 PM Xin Tian <tianx@xxxxxxxxxxxxxx> wrote:
>
> resources

Please say more than one word :)

I just saw you CC'd the kernel mailing list. Please trim it in the
next revision.

>
> Query the firmware HCA capabilities needed by the ethernet driver and
> reset the function resources during probe.
>
> Signed-off-by: Xin Tian <tianx@xxxxxxxxxxxxxx>
> ---
> .../ethernet/yunsilicon/xsc/common/xsc_core.h | 18 +++++
> .../net/ethernet/yunsilicon/xsc/pci/main.c | 70 +++++++++++++++++++
> 2 files changed, 88 insertions(+)
>
> diff --git a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
> index a6f0149ed..1ffbc2daa 100644
> --- a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
> +++ b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
> @@ -24,6 +24,18 @@
> #define XSC_PAGE_SHIFT_4K 12
> #define XSC_PAGE_SIZE_4K (_AC(1, UL) << XSC_PAGE_SHIFT_4K)
>
> +struct xsc_caps {
> + u32 max_cqes;
> + u32 send_ds_num;
> + u32 recv_ds_num;
> + u8 log_max_qp_depth;
> + u16 msix_base;
> + u16 msix_num;
> + u32 nic_caps;
> +};
> +
> +#define XSC_CAP_MAC_PORT_MASK GENMASK(15, 8)
> +
> struct xsc_cmd;
>
> struct xsc_core_device {
> @@ -33,6 +45,12 @@ struct xsc_core_device {
> void __iomem *bar;
> int bar_num;
>
> + u8 mac_port;
> + u8 pcie_no;
> + u8 pf_id;
> + u16 glb_func_id;
> +
> + struct xsc_caps caps;
> struct xsc_cmd *cmd;
> };
>
> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/main.c b/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
> index 9b08580f5..42c5a1bae 100644
> --- a/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
> @@ -29,6 +29,63 @@ static int xsc_set_dma_caps(struct pci_dev *pdev)
> return err;
> }
>
> +static int xsc_cmd_query_hca_cap(struct xsc_core_device *xdev,
> + struct xsc_caps *caps)
> +{
> + struct xsc_cmd_query_hca_cap_mbox_out *out;
> + struct xsc_cmd_query_hca_cap_mbox_in in;
> + int err;
> +
> + out = kzalloc_obj(*out, GFP_KERNEL);
> + if (!out)
> + return -ENOMEM;
> +
> + memset(&in, 0, sizeof(in));
> + in.hdr.opcode = cpu_to_be16(XSC_CMD_OP_QUERY_HCA_CAP);
> + in.cpu_num = cpu_to_be16(num_online_cpus());
> +
> + err = xsc_cmd_exec(xdev, &in, sizeof(in), out, sizeof(*out));
> + if (err)
> + goto err_free;
> +
> + xdev->glb_func_id = be32_to_cpu(out->hca_cap.glb_func_id);
> +
> + caps->max_cqes = 1 << out->hca_cap.log_max_cq_sz;
> + caps->send_ds_num = out->hca_cap.send_seg_num;
> + caps->recv_ds_num = out->hca_cap.recv_seg_num;
> +
> + caps->nic_caps = (caps->nic_caps & ~XSC_CAP_MAC_PORT_MASK) |

xdev/caps is allocated via kzalloc, so caps is already zeroed.

> + FIELD_PREP(XSC_CAP_MAC_PORT_MASK,
> + out->hca_cap.mac_port & 0xff);

mac_port is an u8 field. 0xff should be dead code here?

Then 'xdev->mac_port = out->hca_cap.mac_port;' is fine.

Thanks,
Jason