🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10926

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

#10926
From: "Xin Tian"
Date: Wed, 04 Nov 2026 11:40
124 lines
12779 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.
Hi Junxian,

All ten are fixed in v1, which I'll post shortly.
> Why Mellanox?
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: <e3354620-abb4-4584-80d2-0251a0d49d10@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-356385-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-356385-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:40:17 +0800
Organization: Usenet Network
Message-ID: <e3354620-abb4-4584-80d2-0251a0d49d10@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="3381381"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:bGkzQ8mFsFq7/Q/Tzp4nn66CKlw= sha256:4Gwi56SIXA9uEv2Bvsw2boMHqrUwz/rh8uDVGMGp9P4=
	sha1:d257nLEqR8bIZV97LFsB2Pj4b4g= sha256:mWShuUJJTehrdR0Wu/006qdib6pr1/8SyKxbYXbSb2g=
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 313E6112B96; Wed,  4 Nov 2026 14:41:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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,
	URIBL_BLOCKED=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 emk0LupkJxFE;
	Wed,  4 Nov 2026 14:41:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356385-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 5AE04112ACA; Wed,  4 Nov 2026 14:40:52 +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 D0F3A2C259; Wed,  4 Nov 2026 11:40:34 +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=1793792433;
	b=0/G9ghekvPZbtok6oz/ofaIQK8NMKlffn7R9LyB9Rf4YskFTr/lfXklh1nmTKEsaDHez
	 +Q0ntDizrNdur4IskGrqoSawEoOBYVRUNjbgke9UqZTZBbLCY/GMVvZxfGg5pwOVNS33M
	 ZP3cAM1Jhs6ySxrM3zzWRUq3HEcR7p0+M2uAQLChpfcXEuL4GyofhbanjVGxpV/oKUwvN
	 AXj0/QH7dtbcJMWGRo0GihZwJCRWE/EHN+aJJJPECK4XMkFwxxaPvpS4YH5hgqURj3cH+
	 LI/VJleLCmGDqLSMBol2fOeTZiBj3Tkwk95MuepWIcEMGCD4tlD1Q9y2Ue9vr55S/3g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793792433;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Message-Id:
	 Received:References:X-Lms-Return-Path:From:Subject:Date:User-Agent:
	 Content-Transfer-Encoding:In-Reply-To:Content-Type:X-Original-From:To:
	 Cc:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:Mime-Version;
	bh=pPsOd91eue55DvpTTpIkJaM1e+sIzdW80J0vYdNAO4k=;
	b=yywB+ltv//xbeYir2o8FrwfQhH3IjeHJMAFWCRADirl1Z1uzANxJF4NPwaLGjAYa5fe+
	 twgYqgkr9z6nsAVLb8JPpcTzD2taXJdWNa8jcqfrP9sYRQLfGKxyr3yd9RLoTKd738qNJ
	 Ch1oBR3my41F6FqrfPoF+PldccqBEbIXoCKO1r05KKMfAtjfYORCt+7TnmMJq1gFskI/i
	 exj9/wX8GlvYwsIh6TEiMD8044ni4iC4+67W2PFvqC2Y59t9kvUcGr4Qp3OFB1bqtTG9n
	 aa7kAAvWJHnbdvRB6c+v0Ch6H7ecLeaE5T2t7tO50D68/46Pfgwzemay6Mj6F0wSqqQ==
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=HDzLbzH1;
	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 31F05606A337;
	Wed,  4 Nov 2026 11:40:33 +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=HDzLbzH1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.29
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793792427;
	b=lb7FCs5CIJ2X8mV2U0hEVUs35IPtF7cHZYknQZrpjPL7jxKtZY9rAD+tIZUgur8VkVaU
	 8jZCmBmAN8hoHt+x6+TY3mUDGCBGKO4XpIwtxwSVnrZl3jZFqFlsWYzIYFM8xFKQYaW+O
	 xr3mqvHepEKvO6WNSTM/+y7Q1uZTenbqYXn0sWi50AIN/EE5bMZYREcH3Coxwzz+hUPDl
	 UbnP00MDxC5i//OgvFQxRDvc91ongN6qOoUjDhZUoIFDC+gEY/pbBRZvH77RKExfHTVmD
	 lhRczZCZC7p/7/JhMidyHBg/TFFBeN5Qipo3m7d72MrSY2jIKk4Dcrjrqw9PZsKWxgQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793792427;
	h=DMARC-Filter:DKIM-Signature:Message-Id:Received:References:
	 X-Lms-Return-Path:From:Subject:Date:User-Agent:
	 Content-Transfer-Encoding:In-Reply-To:Content-Type:X-Original-From:To:
	 Cc:Mime-Version;
	bh=pPsOd91eue55DvpTTpIkJaM1e+sIzdW80J0vYdNAO4k=;
	b=VEr5SV1mppgUijpslK1nYjNvRHCR14J+4XFnUgE7Zw70ObT3eIym9uoNtTdv6sMeOOeL
	 livGY3pAwrk0AZ2+1yGCbLgL8HklbiOnnG7ab2tSCLXCGXC0shH7wuAyOgtQmcJQu4XrK
	 uGUYv/XaLdDSpzJH094PyHjd8DfPoRg6Z9k5u13VC+iqfwsrK+EpiOVt8XZMKlZoH5sGe
	 YRtX68MyHBFiy+DgBI/mG7P1O6EFBsvuI1xPGz2L3wNApuC2U/vbmTlAU9KxJOeYJwVEO
	 wJ+QQQqs4unk9IU7cyqHUzLweqpT9COivK46VpqIX1MZitLy+PFgKFJEKgpF83EDclg==
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=HDzLbzH1;
	arc=none smtp.remote-ip=209.127.231.29
X-Received: from va-2-29.ptr.blmpb.com (va-2-29.ptr.blmpb.com [209.127.231.29])
	(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 29617606A32C
	for <netdev@vger.kernel.org>; Wed,  4 Nov 2026 11:40:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 29617606A32C
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=1793792421; h=from:subject:
 mime-version:from:date:message-id:subject:to:cc:reply-to:content-type:
 mime-version:in-reply-to:message-id;
 bh=pPsOd91eue55DvpTTpIkJaM1e+sIzdW80J0vYdNAO4k=;
 b=HDzLbzH1CGbklSWoIPIQCsDnnq06UZAZKuSmKt3YDJH38gLB5kVOCf9QDEPl9IsiLA1F6K
 taPOduA/EpHBt35OgL0LEx9N3fBzvyFW0LWclogLaRRhceiXENVI3LEHrTvh57Tm5NIEP/
 vtZHR6eA1Vr42mn9sFBpDR93YZ6QwxuB9aRqpifxhY4GxmDRHtV1iM24fY0HgKiW2RLWIn
 C9FbcBdjmPJgYf40y3NzKiQ6aDWHqsUoGlz3zGrhgrxLcaKDSH+6A/oxg7nJmSvhkdACif
 uJeys8fao+axh+3rulPua3yDvkG9/dif6gmf2E4+8PeWre9rnjEF6tmxoVPuEw==
X-Received: from [127.0.0.1] ([180.152.18.210]) by smtp.feishu.cn with ESMTPS; Wed, 04 Nov 2026 19:40:18 +0800
X-Lms-Return-Path: <lba+26aeb19a3+759116+vger.kernel.org+tianx@yunsilicon.com>
X-User-Agent: Mozilla Thunderbird
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