Article View: linux.kernel.netdev
Article #23121[PATCH v2 04/11] net/xsc: query HCA capabilities and reset function
From: "Xin Tian"
Date: Thu, 26 Nov 2026 14:57
Date: Thu, 26 Nov 2026 14:57
138 lines
12358 bytes
12358 bytes
resources
Query the firmware HCA capabilities needed by the ethernet driver and
reset the function resources during probe.
Signed-off-by: Xin Tian <tianx@yunsilicon.com>
---
.../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) |
+ FIELD_PREP(XSC_CAP_MAC_PORT_MASK,
+ out->hca_cap.mac_port & 0xff);
+ xdev->mac_port = FIELD_GET(XSC_CAP_MAC_PORT_MASK, caps->nic_caps);
+
+ caps->msix_base = be16_to_cpu(out->hca_cap.msix_base);
+ caps->msix_num = be16_to_cpu(out->hca_cap.msix_num);
+
+ caps->log_max_qp_depth = out->hca_cap.log_max_qp_depth & 0xff;
+
+ xdev->pcie_no = out->hca_cap.pcie_no;
+ xdev->pf_id = out->hca_cap.pf_id;
+
+ kfree(out);
+ return 0;
+err_free:
+ kfree(out);
+ return err;
+}
+
+static int xsc_reset_function_resource(struct xsc_core_device *xdev)
+{
+ struct xsc_function_reset_mbox_out out;
+ struct xsc_function_reset_mbox_in in;
+
+ memset(&in, 0, sizeof(in));
+ in.hdr.opcode = cpu_to_be16(XSC_CMD_OP_FUNCTION_RESET);
+ in.glb_func_id = cpu_to_be16(xdev->glb_func_id);
+
+ return xsc_cmd_exec(xdev, &in, sizeof(in), &out, sizeof(out));
+}
+
static int xsc_pci_init(struct xsc_core_device *xdev,
const struct pci_device_id *id)
{
@@ -90,6 +147,19 @@ static int xsc_pci_init(struct xsc_core_device *xdev,
goto err_cmd_cleanup;
}
+ err = xsc_cmd_query_hca_cap(xdev, &xdev->caps);
+ if (err) {
+ pci_err(pdev, "failed to query hca caps: err=%d\n", err);
+ goto err_cmd_cleanup;
+ }
+
+ err = xsc_reset_function_resource(xdev);
+ if (err) {
+ pci_err(pdev, "failed to reset function resource: err=%d\n",
+ err);
+ goto err_cmd_cleanup;
+ }
+
return 0;
err_cmd_cleanup:
--
2.43.0
Technical Details
Message-ID:
<20261126145721.70868-5-tianx@yunsilicon.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372170-linux-kernel-netdev=dewy.ruReferences:
<20261126145711.70868-1-tianx@yunsilicon.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372170-linux-kernel-netdev=dewy.ru
From: tianx@yunsilicon.com ("Xin Tian")
Newsgroups: linux.kernel.netdev
Subject: [PATCH v2 04/11] net/xsc: query HCA capabilities and reset function
Date: Thu, 26 Nov 2026 22:57:23 +0800
Organization: Usenet Network
Message-ID: <20261126145721.70868-5-tianx@yunsilicon.com>
References: <20261126145711.70868-1-tianx@yunsilicon.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="490725"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TmHbglBZvmeAzlNDoh6rKMv23ds= sha256:ueXBup5p2nAkoxt0BYV/urd/RHnDJbqXVRYKZdQMYAY=
sha1:p30eDhDOzNBOo7TXRmczibpUEKw= sha256:HZVaCLKShV22vOAhYdFPLIxsA8a1ky8flmZyDf1pXa4=
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 8C86D125EE3; Thu, 26 Nov 2026 17:57:55 +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 7bGzFOmiZ4PD;
Thu, 26 Nov 2026 17:57:52 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-372170-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id DC81B125EE1; Thu, 26 Nov 2026 17:57:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id 7465A28035; Thu, 26 Nov 2026 14:57:36 +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=1795705052;
b=F0n/Rq97XdEdp9d5IrI+G1S+lJT54JGA/ETJjr9k2xrUCkWW4L16/EAB/HMz52jm+HVD
RntqeFfxe99AJGeSGSlJ09Td71Zrm/pJOhqaZ3qwtfsb4vSPLVbPVknyClVoxfBUphvv7
Wxg3AADxk2ZoiOIU4oFLRlRN76MbyKJ83JHZoxM3dKUgNDHGmU0oXkRUiPddUI2bCoEU0
hP8yElE9bHDKY+ckegfJWCIdUmAFoM1rOm9fvU6lJ21mYy22BmMdBlGArhG7+ZogfgE7F
NsnJGEvtQepwBAq56MiJkGoow3+T1QIkMiHCc7bHNP/gLIs8erU+qnhHlYiJ1+Avcbw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795705052;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Date:References:
X-Original-From:To:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:Mime-Version:
X-Mailer:Message-Id:In-Reply-To:Content-Transfer-Encoding:Cc:From:
Subject:Content-Type:X-Lms-Return-Path:Received;
bh=bTKveouMaT+A6TZaLVjzx5FaUHxsQsCtsYgSd5VZTEQ=;
b=vFi4mPyDTBL4MbEsNmLUxhYHdWhYehIB7CdRdJOFGnp9x5D3jYm86yvAK8ugxNWX0ALD
uWXU60hpofK4+zEgepq45Kov+GuKkGNrl7JP4J8bO7JcA0oU+y83FoCJPHAIsQDXom7L4
x3u5Rl23DIzzdjuGyFZTZd/8+f2kCFcf2kmGQ7pHXeIYn4TnhuY1UByB+RaHqc+an2I4j
avc9krH2jAVu4ludy0s0VCtUzIC+WV606XgUufMwwHXtCohypoI8YiLynTYvpsZdRl/HT
OttoSJydTGFNBlt0MbkEpat+YUYkjHc/zkLCRfkZ61G8T8ylJEsmg3trDTsvHhQufpA==
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=a9RByk+6;
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 DD351606A329;
Thu, 26 Nov 2026 14:57:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=a9RByk+6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.56
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795705051;
b=vBMik+0wvNuz106ezv4kuhrwsbXJ3HW9bycz+xlIctRuzM+jvXuhSEEhqrLCg1ezyebN
U4Rsq5eVPPz2G6v5NziEFTAJTLnN42Q6oHcSf63s1PNHxGFOTdXJgs+ZXf/pvNqmSw5Gg
jVpbkVl8ELOgmvYKoVvwD0wxlEDZ37mPU0Mjw3wplnA8R8oKokQiN69R+jhCs9owGppCx
+cxsaGAApkpbwSTUghrqwj0YsYL1x7430cDiwYcXAKUQZNCV1MqwUaByfAO2Wk4UwYxnU
eYDfkHI0YjdrJ3bUE6URTuhFmSokvsVLtKZctaPwsn3zQn0J+TfGhx0sSpNDOrHsSSA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795705051;
h=DMARC-Filter:DKIM-Signature:Date:References:X-Original-From:To:
Mime-Version:X-Mailer:Message-Id:In-Reply-To:
Content-Transfer-Encoding:Cc:From:Subject:Content-Type:
X-Lms-Return-Path:Received;
bh=bTKveouMaT+A6TZaLVjzx5FaUHxsQsCtsYgSd5VZTEQ=;
b=BvwC6ksGHymaNXVW8J8loLBNK/4NO3kQT1ZypdQDS45L+2chPIajaWLVch99bK14XKIf
sF/N7DBuUNLEsyuzaJ/gPoFMkuQjlrWuIiMYeoHWDHy9Cu4Pn90JKm+A3g+IzexuUbhzm
gJ4NCbxapa4hulLmC604Kr4BpegbBnA6p2e4tMf5Kz4iIVdtwv0oqsnwZiSWOVWe/z8+D
6CVb5PE1TkyR022ma+8Xq8D1Jr+lXEVLWMXNuIMsgS5H633tOihjViIybp+JRFxHshrC9
dE1FU55KTpw8s2+uN/peCXkFsjNdoFQAz7xr/BtZWbyMRDS79UfRhI4X4K1Shkago3Q==
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=a9RByk+6;
arc=none smtp.remote-ip=209.127.231.56
X-Received: from va-2-56.ptr.blmpb.com (va-2-56.ptr.blmpb.com [209.127.231.56])
(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 95636606A699
for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 14:57:30 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 95636606A699
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=1795705046; h=from:subject:
mime-version:from:date:message-id:subject:to:cc:reply-to:content-type:
mime-version:in-reply-to:message-id;
bh=bTKveouMaT+A6TZaLVjzx5FaUHxsQsCtsYgSd5VZTEQ=;
b=a9RByk+6DrsFgBVH7dIKiuM23hRcD62ujryWIrXTTp9atZTIGYbOUOnTSsPwLL1bw/iBS3
8SZFZMa0aL3/uBgiVIp9nJEM/caxKbTxK03Vc9dM674iJuYM4lh+EJBUfxQXocuB7BCaOT
OWd4tcK6oodDlqgaRAiZD99vESbS/w2rH9wIjUSRZfaVJ9ta/XQ43nkwGD9msPVfUxDiSf
Q3ytndqIz5r8TLW0Mw1/6zYTpMOxeI/S+vP9Z9j0cGU5ClxVVXSMZmuPJGzS8zTtWG2oFD
Y06oHkAHFtTXXsqWLQQDRtuDr77kxVh9eyn3YrskI/XyseI6nEpWFbTcqyBHJA==
X-Original-From: Xin Tian <tianx@yunsilicon.com>
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-Mailer: git-send-email 2.25.1
X-In-Reply-To: <20261126145711.70868-1-tianx@yunsilicon.com>
X-Cc: <weihg@yunsilicon.com>, <linux-kernel@vger.kernel.org>,
<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
<kerneljasonxing@gmail.com>
X-Lms-Return-Path: <lba+26b0848d4+4daa74+vger.kernel.org+tianx@yunsilicon.com>
X-Received: from DESKTOP-TGBQGEC.localdomain ([183.193.56.110]) by smtp.feishu.cn with ESMTPS; Thu, 26 Nov 2026 22:57:23 +0800