Re: [PATCH 03/15] yunsilicon: add the command queue
From: Xin Tian
Date: Wed Nov 04 2026 - 06:44:02 EST
On 10/13/2026 11:11 AM, Junxian Huang wrote:
>
> On 2026/10/12 19:43, Xin Tian wrote:
>> Add the command queue that is shared by the ethernet and RDMA functions:
>> the request/response rings, the command work handling and the device
>> initialisation sequence that queries the HCA capabilities, the GUID and
>> the message opcode table.
>>
>> Signed-off-by: Xin Tian <tianx@xxxxxxxxxxxxxx>
>> ---
>> .../net/ethernet/yunsilicon/xsc/pci/Makefile | 2 +-
>> .../net/ethernet/yunsilicon/xsc/pci/cmdq.c | 1247 +++++++++++++++++
>> drivers/net/ethernet/yunsilicon/xsc/pci/hw.c | 310 ++++
>> drivers/net/ethernet/yunsilicon/xsc/pci/hw.h | 18 +
>> .../net/ethernet/yunsilicon/xsc/pci/main.c | 55 +
>> 5 files changed, 1631 insertions(+), 1 deletion(-)
>> create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/cmdq.c
>> create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/hw.c
>> create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/hw.h
>>
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> index 81b65232e..656cdffa1 100644
>> --- a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> @@ -6,4 +6,4 @@ ccflags-y += -I$(srctree)/drivers/net/ethernet/yunsilicon/xsc
>>
>> obj-$(CONFIG_YUNSILICON_XSC_PCI) += xsc_pci.o
>>
>> -xsc_pci-y := main.o hal/andes_impl.o
>> +xsc_pci-y := main.o cmdq.o hw.o hal/andes_impl.o
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/cmdq.c b/drivers/net/ethernet/yunsilicon/xsc/pci/cmdq.c
>> new file mode 100644
>> index 000000000..48832b26d
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/cmdq.c
>> @@ -0,0 +1,1247 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (c) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> + * All rights reserved.
>> + * Copyright (c) 2013-2016, Mellanox Technologies. All rights reserved.
> Why Mellanox?
Hi Junxian,
This is intentional—the code is derived from the Mellanox driver, as Leon
noted. I'll keep it as is.
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/errno.h>
>> +#include <linux/pci.h>
>> +#include <linux/dma-mapping.h>
>> +#include <linux/slab.h>
>> +#include <linux/delay.h>
>> +#include <linux/random.h>
>> +#include <linux/kthread.h>
>> +#include <linux/io-mapping.h>
>> +
>> +#include "common/xsc_cmd_api.h"
>> +#include "common/xsc_cmd.h"
>> +#include "common/xsc_core.h"
>> +#include "hal/xsc_hal.h"
>> +
>> +enum {
>> + CMD_IF_REV = 3,
>> +};
>> +
>> +enum {
>> + NUM_LONG_LISTS = 2,
>> + NUM_MED_LISTS = 64,
>> + LONG_LIST_SIZE = (2ULL * 1024 * 1024 * 1024 / PAGE_SIZE) * 8 + 16 +
>> + XSC_CMD_DATA_BLOCK_SIZE,
>> + MED_LIST_SIZE = 16 + XSC_CMD_DATA_BLOCK_SIZE,
>> +};
>> +
>> +enum {
>> + XSC_CMD_DELIVERY_STAT_OK = 0x0,
>> + XSC_CMD_DELIVERY_STAT_SIGNAT_ERR = 0x1,
>> + XSC_CMD_DELIVERY_STAT_TOK_ERR = 0x2,
>> + XSC_CMD_DELIVERY_STAT_BAD_BLK_NUM_ERR = 0x3,
>> + XSC_CMD_DELIVERY_STAT_OUT_PTR_ALIGN_ERR = 0x4,
>> + XSC_CMD_DELIVERY_STAT_IN_PTR_ALIGN_ERR = 0x5,
>> + XSC_CMD_DELIVERY_STAT_FW_ERR = 0x6,
>> + XSC_CMD_DELIVERY_STAT_IN_LENGTH_ERR = 0x7,
>> + XSC_CMD_DELIVERY_STAT_OUT_LENGTH_ERR = 0x8,
>> + XSC_CMD_DELIVERY_STAT_RES_FLD_NOT_CLR_ERR = 0x9,
>> + XSC_CMD_DELIVERY_STAT_CMD_DESCR_ERR = 0x10,
>> +};
>> +
>> +static struct xsc_cmd_work_ent *xsc_alloc_cmd(struct xsc_cmd *cmd,
>> + struct xsc_cmd_msg *in,
>> + struct xsc_rsp_msg *out)
>> +{
>> + struct xsc_cmd_work_ent *ent;
>> +
>> + ent = kzalloc_obj(*ent, GFP_KERNEL);
>> + if (!ent)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ent->in = in;
>> + ent->out = out;
>> + ent->cmd = cmd;
>> +
>> + return ent;
>> +}
>> +
>> +static void xsc_free_cmd(struct xsc_cmd_work_ent *ent)
>> +{
>> + kfree(ent);
> One line function is unnecessary.
>
> Junxian
Fixed in v1.
Thanks,
Xin Tian
>
>> +}