🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10930

Re: [PATCH 03/15] yunsilicon: add the command queue

#10930
From: "Xin Tian"
Date: Wed, 04 Nov 2026 11:43
129 lines
12718 bytes
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@yunsilicon.com>
>> ---
>>   .../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


>
>> +}
Technical Details
Message-ID: <e63df858-d9f6-4d1c-8802-9a8b83c9f904@yunsilicon.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356387-linux-kernel-netdev=dewy.ru
References: <20261012114352.2471317-1-tianx@yunsilicon.com> <20261012114356.2471317-4-tianx@yunsilicon.com> <47c82da8-99cd-ec81-f264-d270fef057ee@hisilicon.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356387-linux-kernel-netdev=dewy.ru
From: tianx@yunsilicon.com ("Xin Tian")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH 03/15] yunsilicon: add the command queue
Date: Wed, 4 Nov 2026 19:43:42 +0800
Organization: Usenet Network
Message-ID: <e63df858-d9f6-4d1c-8802-9a8b83c9f904@yunsilicon.com>
References: <20261012114352.2471317-1-tianx@yunsilicon.com> <20261012114356.2471317-4-tianx@yunsilicon.com> <47c82da8-99cd-ec81-f264-d270fef057ee@hisilicon.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3382310"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xq1xF+C8lR2pPf4bfpb9NRjGV8Y= sha256:vAYFvmNHICoW3/P+j1QUYeSDoT6SbEbVFfMRLmxbioE=
	sha1:6XFyTNpbka3DQEgleFGdSgsajrM= sha256:yHF7L2+cr6px5bkJN0ZaR1MrZIfQAzqxiskQqKSo7yE=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1BC63112B9A; Wed,  4 Nov 2026 14:46:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, MSGID_FROM_MTA_HEADER=0.001,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=yunsilicon.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id SgdODaj17uDa;
	Wed,  4 Nov 2026 14:46:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356387-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=yunsilicon.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id D0109112B95; Wed,  4 Nov 2026 14:46:21 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 239662C692; Wed,  4 Nov 2026 11:43:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793792637;
	b=nFxIRp+nnHpN5s1BTANrA1XTSkp33MhAGgZ+JoFtUyrT7AvM7TcY/CPiY93vmrOGY3Il
	 gH0p3WIlVKauee1z45YM263h+TFYFeSUNQongYtY/5E6jxouo6+u1hyPBCl0NyJIgoJrW
	 CF5FOtkrvQkEDM3bUmkseOYsGpD0llm7g9P4LcqSLlTDdlmsFLSPd0mTrDW2oA3DECD9Z
	 eIMx9sCfYcVoRC0cOqd5ctg3Qv7X4CoceiR0vwowlxI65bhnA0u3H0RcxcVY8s0mkpgcr
	 EpjVCcemCJwzitbcmtfIyIyb0196FD/6yPvoxLedA2r9oqBoO4BYy0dXNXcLicRC2ww==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793792637;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Message-Id:To:
	 Received:References:From:Date:Content-Type:In-Reply-To:
	 Content-Transfer-Encoding:X-Original-From:Cc:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:Mime-Version:X-Lms-Return-Path:User-Agent:Subject;
	bh=9nOS00/4oT0JM3BaBnrKdFTphpzGiSyZVFHCo5yrkhs=;
	b=uieSbs9UMWsRxWAPFz7S6MgSmGwxaa4fLYFi2qVa9OdRlVbL1QZrfxmmNREIJ8kPnQ/T
	 aoI9bCPoZcz9QLs88c63PXCA3e9mMRvzBobRTytuXOz6yilDpGIOAKXekFCLMkXWdZ1Mj
	 KPDh2mPrv93BEmjftQ8HrvcitfQtYHGTWqOgyBCNGCYPq+/iL9uBpJSmMTHzVqEPLurz7
	 5S7rOVibbq4BbmSJBuqr0nK0OK+y6IrY/BmYdFx5KYwOIyNwsmcjKXfYbgstNl9KaaReT
	 UJmAaB/v4OaQRnCCI0vbxvNtD25mSPkz2ivjI81OM1ExKGBngtk/vj0gMQy6uHW3hwg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b="MtK/nnnj";
	dmarc=none header.from=yunsilicon.com;
	spf=pass smtp.mailfrom=yunsilicon.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AAF2606A336;
	Wed,  4 Nov 2026 11:43:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=MtK/nnnj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.36
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793792631;
	b=IDVH9ZTMofV/LV37WIuSSe5KrBFnwb0xY0So7MGgTp50N6MguYIgc6s8wshxhYI/dvjE
	 hRN0VGRUTecXNLE2IxwoDOOnGBh2e1ZYt7LDtadNWh7JC1NbQXPnp0/5OJvqwdvuUtXzU
	 kXU1IDWBrBqarctqWXpVEp5hLfh3lwvHNp1kfjzpBScVNJR7O/DwveE5B7B93Qoh3SBDP
	 iLleye9qrKskzl/+AzawPPZX4neNG95r6LQMfdlFpTYme3LzJwtO4sx2w3UCIbWMptSUb
	 RepIz43QQ3OkRbb8LL69B9xPsIBwTLeDa4IewOyphhXcSnGotpxDGSLmm1CU54d0eFw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793792631;
	h=DMARC-Filter:DKIM-Signature:Message-Id:To:Received:References:From:
	 Date:Content-Type:In-Reply-To:Content-Transfer-Encoding:
	 X-Original-From:Cc:Mime-Version:X-Lms-Return-Path:User-Agent:Subject;
	bh=9nOS00/4oT0JM3BaBnrKdFTphpzGiSyZVFHCo5yrkhs=;
	b=aTKLVNAyWMuNfwc2tqikUWAKYj1BU6snAuSkVMxGBUp6Xiv78kCv8yBdyowBYrT9+4c0
	 H5oy7cNxTxFBnTcCkT4Nq1xUnMFguCxQuewnXHJTq726S3MKonoO9IdWzrG0Xlf4k82Fp
	 pmZE4dBH5N3uXtMJE3gEKKfe4g9GvpkGhn2XggLCOtZkdb4J0oGeEKtob0lBTZvY4fMxw
	 npQOoLBIQlEBUgHoYYVdZUq2miCVpI7GNDodB0lnntL0Nb8kG4GBNPeo4re+IVCzr6rjm
	 2OdVi8PMBxH2fWTiaBd9Do6xHjUzcG+X+hauEEuRo9XLhV/gY6B1pTxWKtcND0h6jwA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=yunsilicon.com;
	spf=pass smtp.mailfrom=yunsilicon.com;
	dkim=pass header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b="MtK/nnnj";
	arc=none smtp.remote-ip=209.127.231.36
X-Received: from va-2-36.ptr.blmpb.com (va-2-36.ptr.blmpb.com [209.127.231.36])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD127606A32C
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 11:43:50 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AD127606A32C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=yunsilicon.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yunsilicon.com
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 s=feishu2403070942; d=yunsilicon.com; t=1793792626; h=from:subject:
 mime-version:from:date:message-id:subject:to:cc:reply-to:content-type:
 mime-version:in-reply-to:message-id;
 bh=9nOS00/4oT0JM3BaBnrKdFTphpzGiSyZVFHCo5yrkhs=;
 b=MtK/nnnjbdaeOpcgGZO4J+1NB9HjOGugK+u/DR3v3usbabbH0Xxcn4c4bnBKwyWeGfgy8d
 3DaObYDhWS4Dnd5B+ysAaWCtSkOdS/dDNOH9JCL40JqwSbEZ3Ez5bcD2zSxXSWY6P8MnL3
 LOv+ElHS2IpQWjhg+r9/gPtXukk4NCeeIAnQxi/wsSrVskM8KfaVlH5m2MBk3xWXOvS8Or
 XkIE6/PacORfaalQadAmCunVLAsnPsV/NmZCINe4aH24vCCPe+zZesv8zrNvdMe0MELm+4
 hgI9J/2N/UFSF+8kcon3UutnPRf1tlLDdJaqSND0+8yjJ80S7OKDZFk9WnzIEw==
X-Received: from [127.0.0.1] ([180.152.18.210]) by smtp.feishu.cn with ESMTPS; Wed, 04 Nov 2026 19:43:43 +0800
X-In-Reply-To: <47c82da8-99cd-ec81-f264-d270fef057ee@hisilicon.com>
X-Original-From: Xin Tian <tianx@yunsilicon.com>
X-Cc: <weihg@yunsilicon.com>, <linux-kernel@vger.kernel.org>, 
	<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Lms-Return-Path: <lba+26aeb1a70+954ab2+vger.kernel.org+tianx@yunsilicon.com>
X-User-Agent: Mozilla Thunderbird