Netdev List
 help / color / mirror / Atom feed
From: "Xin Tian" <tianx@yunsilicon.com>
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: "Andrew Lunn" <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	 "Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	 "Paolo Abeni" <pabeni@redhat.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	 "Leon Romanovsky" <leon@kernel.org>,
	 "Junxian Huang" <huangjunxian6@hisilicon.com>,
	<weihg@yunsilicon.com>,  <netdev@vger.kernel.org>
Subject: [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver
Date: Tue, 1 Dec 2026 17:13:29 +0800	[thread overview]
Message-ID: <6cbcaecb-b0be-4ce9-afa6-9736f74d6766@yunsilicon.com> (raw)
In-Reply-To: <a3487fb5-8c74-434c-9605-75ef1a430e99@yunsilicon.com>

(Resending as plain text; the previous copy was rejected by the
mailing list.)

On 11/29/2026 10:53 AM, Jason Xing wrote:
> On Thu, Nov 26, 2026 at 10:57 PM Xin Tian<tianx@yunsilicon.com> wrote:
>> skeleton
> nit: make it a complete sentence instead of a simple word
    The split subject you saw was a send-side folding bug
    in our SMTP script (not git send-email); already fixed on that side.
>> Add the Yunsilicon vendor Kbuild glue and the PCI layer of the XSC
>> ethernet driver. For now the PCI core only enables the device, maps
>> BAR0 and records DMA capabilities; the doorbell, command queue and
>> netdev layer are added by subsequent patches.
>>
>> Signed-off-by: Xin Tian<tianx@yunsilicon.com>
>> ---
>>   MAINTAINERS                                   |   7 +
>>   drivers/net/ethernet/Kconfig                  |   1 +
>>   drivers/net/ethernet/Makefile                 |   1 +
>>   drivers/net/ethernet/yunsilicon/Kconfig       |  26 +++
>>   drivers/net/ethernet/yunsilicon/Makefile      |   8 +
>>   .../ethernet/yunsilicon/xsc/common/xsc_core.h |  35 ++++
>>   .../ethernet/yunsilicon/xsc/common/xsc_reg.h  |  23 +++
>>   .../net/ethernet/yunsilicon/xsc/pci/Kconfig   |  16 ++
>>   .../net/ethernet/yunsilicon/xsc/pci/Makefile  |   9 +
>>   .../net/ethernet/yunsilicon/xsc/pci/main.c    | 170 ++++++++++++++++++
>>   10 files changed, 296 insertions(+)
>>   create mode 100644 drivers/net/ethernet/yunsilicon/Kconfig
>>   create mode 100644 drivers/net/ethernet/yunsilicon/Makefile
>>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
>>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/common/xsc_reg.h
>>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/Kconfig
>>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/main.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index c24144478..bc9e7d267 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -30069,6 +30069,13 @@ S:     Maintained
>>   F:     Documentation/input/devices/yealink.rst
>>   F:     drivers/input/misc/yealink.*
>>
>> +YUNSILICON XSC DRIVERS
>> +M:     Honggang Wei<weihg@yunsilicon.com>
>> +M:     Xin Tian<tianx@yunsilicon.com>
>> +L:netdev@vger.kernel.org
>> +S:     Maintained
>> +F:     drivers/net/ethernet/yunsilicon/xsc
>> +
>>   ZD1211RW WIRELESS DRIVER
>>   L:linux-wireless@vger.kernel.org
>>   S:     Orphan
>> diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
>> index 8581ccba1..88cdf87b0 100644
>> --- a/drivers/net/ethernet/Kconfig
>> +++ b/drivers/net/ethernet/Kconfig
>> @@ -189,6 +189,7 @@ source "drivers/net/ethernet/wangxun/Kconfig"
>>   source "drivers/net/ethernet/wiznet/Kconfig"
>>   source "drivers/net/ethernet/xilinx/Kconfig"
>>   source "drivers/net/ethernet/xircom/Kconfig"
>> +source "drivers/net/ethernet/yunsilicon/Kconfig"
>>   source "drivers/net/ethernet/zte/Kconfig" endif # ETHERNET diff --git a/drivers/net/ethernet/Makefile 
>> b/drivers/net/ethernet/Makefile index 2b1153d35..5b571d761 100644 --- 
>> a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile 
>> @@ -101,6 +101,7 @@ obj-$(CONFIG_NET_VENDOR_VIA) += via/ 
>> obj-$(CONFIG_NET_VENDOR_WANGXUN) += wangxun/ 
>> obj-$(CONFIG_NET_VENDOR_WIZNET) += wiznet/ 
>> obj-$(CONFIG_NET_VENDOR_XILINX) += xilinx/ 
>> +obj-$(CONFIG_NET_VENDOR_YUNSILICON) += yunsilicon/ 
>> obj-$(CONFIG_NET_VENDOR_XIRCOM) += xircom/ 
>> obj-$(CONFIG_NET_VENDOR_SYNOPSYS) += synopsys/ 
>> obj-$(CONFIG_NET_VENDOR_PENSANDO) += pensando/ diff --git 
>> a/drivers/net/ethernet/yunsilicon/Kconfig 
>> b/drivers/net/ethernet/yunsilicon/Kconfig new file mode 100644 index 
>> 000000000..ffdfdf4bf --- /dev/null +++ 
>> b/drivers/net/ethernet/yunsilicon/Kconfig @@ -0,0 +1,26 @@ +# 
>> SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2021-2026, Shanghai 
>> Yunsilicon Technology Co., Ltd. +# All rights reserved. +# +# 
>> Yunsilicon driver configuration +# + +config NET_VENDOR_YUNSILICON + 
>> bool "Yunsilicon devices"
>> +       default y
>> +       depends on PCI
>> +       depends on 64BIT || COMPILE_TEST
>> +       help
>> +         If you have a network (Ethernet) device belonging to this class,
>> +         say Y.
>> +
>> +         Note that the answer to this question doesn't directly affect the
>> +         kernel: saying N will just cause the configurator to skip all
>> +         the questions about Yunsilicon cards. If you say Y, you will be asked
>> +         for your specific card in the following questions.
>> +
>> +if NET_VENDOR_YUNSILICON
>> +
>> +source "drivers/net/ethernet/yunsilicon/xsc/pci/Kconfig"
>> +
>> +endif # NET_VENDOR_YUNSILICON
>> diff --git a/drivers/net/ethernet/yunsilicon/Makefile b/drivers/net/ethernet/yunsilicon/Makefile
>> new file mode 100644
>> index 000000000..b2924ccaf
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/Makefile
>> @@ -0,0 +1,8 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> +# All rights reserved.
>> +#
>> +# Makefile for the Yunsilicon device drivers.
>> +#
>> +
>> +obj-$(CONFIG_YUNSILICON_XSC_PCI) += xsc/pci/
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
>> new file mode 100644
>> index 000000000..2d0eda8a2
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_core.h
>> @@ -0,0 +1,35 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/* Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> + * All rights reserved.
>> + */
>> +
>> +#ifndef __XSC_CORE_H
>> +#define __XSC_CORE_H
>> +
>> +#include <linux/pci.h>
>> +#include <linux/bitfield.h>
>> +
>> +#define XSC_PCI_VENDOR_ID              0x1f67
>> +
>> +#define XSC_MC_PF_DEV_ID               0x1011
>> +
>> +#define XSC_MF_HOST_PF_DEV_ID          0x1051
>> +#define XSC_MF_SOC_PF_DEV_ID           0x1053
>> +
>> +#define XSC_MS_PF_DEV_ID               0x1111
>> +
>> +#define XSC_MV_HOST_PF_DEV_ID          0x1151
>> +#define XSC_MV_SOC_PF_DEV_ID           0x1153
>> +
>> +#define XSC_PAGE_SHIFT_4K              12
>> +#define XSC_PAGE_SIZE_4K               (_AC(1, UL) << XSC_PAGE_SHIFT_4K)
>> +
>> +struct xsc_core_device {
>> +       struct pci_dev          *pdev;
>> +       struct device           *device;
>> +
>> +       void __iomem            *bar;
>> +       int                     bar_num;
>> +};
>> +
>> +#endif
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/common/xsc_reg.h b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_reg.h
>> new file mode 100644
>> index 000000000..26773383f
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/common/xsc_reg.h
>> @@ -0,0 +1,23 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/* Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> + * All rights reserved.
>> + */
>> +
>> +#ifndef __XSC_REG_H
>> +#define __XSC_REG_H
>> +#define CMDQM_HOST_REQ_BUF_BASE_H_ADDR_MEM_ADDR 0x0
>> +#define CMDQM_HOST_REQ_BUF_BASE_L_ADDR_MEM_ADDR 0x4
>> +#define CMDQM_HOST_REQ_PID_MEM_ADDR 0x8
>> +#define CMDQM_HOST_RSP_BUF_BASE_H_ADDR_MEM_ADDR 0x10
>> +#define CMDQM_HOST_RSP_BUF_BASE_L_ADDR_MEM_ADDR 0x14
>> +#define CMDQM_HOST_RSP_PID_MEM_ADDR 0x18
>> +#define CMDQM_HOST_RSP_CID_MEM_ADDR 0x1c
>> +#define CMDQM_HOST_VF_ERR_STS_MEM_ADDR 0x20
>> +
>> +#define DB_CQ_FUNC_MEM_ADDR 0x8c4
>> +#define DB_EQ_FUNC_MEM_ADDR 0x8c8
>> +#define DB_CQ_CID_DIRECT_MEM_ADDR 0x8cc
>> +#define TX_DB_FUNC_MEM_ADDR 0x8d0
>> +#define RX_DB_FUNC_MEM_ADDR 0x8d4
>> +
>> +#endif
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/Kconfig b/drivers/net/ethernet/yunsilicon/xsc/pci/Kconfig
>> new file mode 100644
>> index 000000000..a27a37b3a
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/Kconfig
>> @@ -0,0 +1,16 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> +# All rights reserved.
>> +# Yunsilicon PCI configuration
>> +#
>> +
>> +config YUNSILICON_XSC_PCI
>> +       tristate "Yunsilicon XSC PCI driver"
>> +       depends on PCI
>> +       depends on NET
>> +       help
>> +         This driver provides the PCI core for Yunsilicon XSC
>> +         ethernet devices.
>> +
>> +         To compile this driver as a module, choose M here. The module
>> +         will be called xsc_pci.
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> new file mode 100644
>> index 000000000..c163aa950
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/Makefile
>> @@ -0,0 +1,9 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> +# All rights reserved.
>> +
>> +ccflags-y += -I$(srctree)/drivers/net/ethernet/yunsilicon/xsc
>> +
>> +obj-$(CONFIG_YUNSILICON_XSC_PCI) += xsc_pci.o
>> +
>> +xsc_pci-y := main.o
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/main.c b/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
>> new file mode 100644
>> index 000000000..c926507a7
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/main.c
>> @@ -0,0 +1,170 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
>> + * All rights reserved.
>> + */
>> +
>> +#include <linux/slab.h>
>> +
>> +#include "common/xsc_core.h"
>> +
>> +static const struct pci_device_id xsc_pci_id_table[] = {
>> +       { PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_MC_PF_DEV_ID) },
>> +       { PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_MF_HOST_PF_DEV_ID) },
>> +       { PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_MF_SOC_PF_DEV_ID) },
>> +       { PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_MS_PF_DEV_ID) },
>> +       { PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_MV_HOST_PF_DEV_ID) },
>> +       { PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_MV_SOC_PF_DEV_ID) },
>> +       { 0 }
>> +};
>> +
>> +static int xsc_set_dma_caps(struct pci_dev *pdev)
>> +{
>> +       int err;
>> +
>> +       err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
>> +       if (!err)
>> +               dma_set_max_seg_size(&pdev->dev, SZ_2G);
>> +
>> +       return err;
>> +}
>> +
>> +static int xsc_pci_init(struct xsc_core_device *xdev,
>> +                       const struct pci_device_id *id)
> Dead @id parameter.
>
> To check for unneeded parameters like this, you can use
> -Wunused-parameter under W=2 to flag them.

Will drop the unused @id parameter.

Thanks for the suggestion. I've scanned the other patches with
-Wunused-parameter and W=2 enabled. No new unused parameters showed up, 
and I'll keep this check in mind before future submissions.

>> +{
>> +       struct pci_dev *pdev = xdev->pdev;
>> +       void __iomem *bar_base;
>> +       int bar_num = 0;
>> +       int err;
>> +
>> +       err = pci_enable_device(pdev);
>> +       if (err) {
>> +               pci_err(pdev, "failed to enable PCI device: err=%d\n", err);
>> +               goto err_out;
>> +       }
>> +
>> +       err = pci_request_region(pdev, bar_num, KBUILD_MODNAME);
>> +       if (err) {
>> +               pci_err(pdev, "failed to request %s pci_region=%d: err=%d\n",
>> +                       KBUILD_MODNAME, bar_num, err);
>> +               goto err_disable;
>> +       }
>> +
>> +       pci_set_master(pdev);
>> +
>> +       err = xsc_set_dma_caps(pdev);
>> +       if (err) {
>> +               pci_err(pdev, "failed to set DMA capabilities mask: err=%d\n",
>> +                       err);
>> +               goto err_clr_master;
>> +       }
>> +
>> +       bar_base = pci_ioremap_bar(pdev, bar_num);
>> +       if (!bar_base) {
>> +               pci_err(pdev, "failed to ioremap %s bar%d\n", KBUILD_MODNAME,
>> +                       bar_num);
>> +               err = -ENOMEM;
>> +               goto err_clr_master;
>> +       }
>> +
>> +       err = pci_save_state(pdev);
>> +       if (err) {
>> +               pci_err(pdev, "pci_save_state failed: err=%d\n", err);
>> +               goto err_io_unmap;
>> +       }
>> +
>> +       xdev->bar_num = bar_num;
>> +       xdev->bar = bar_base;
>> +
>> +       return 0;
>> +
>> +err_io_unmap:
>> +       pci_iounmap(pdev, bar_base);
>> +err_clr_master:
>> +       pci_clear_master(pdev);
> IIUC, pci_clear_master is redundant since pci_disable_device gets
> called soon. A similar patch can be seen in the commit 2f48b1d854e8
> ("pds_core: remove redundant pci_clear_master()").
>
>> +       pci_release_region(pdev, bar_num);
>> +err_disable:
>> +       pci_disable_device(pdev);
>> +err_out:
>> +       return err;
>> +}
>> +
>> +static void xsc_pci_fini(struct xsc_core_device *xdev)
>> +{
>> +       struct pci_dev *pdev = xdev->pdev;
>> +
>> +       pci_iounmap(pdev, xdev->bar);
>> +       pci_clear_master(pdev);
> Same here
Will remove both pci_clear_master() calls.
>
>> +       pci_release_region(pdev, xdev->bar_num);
>> +       pci_disable_device(pdev);
>> +}
>> +
>> +static int xsc_pci_probe(struct pci_dev *pci_dev,
>> +                        const struct pci_device_id *id)
>> +{
>> +       struct xsc_core_device *xdev;
>> +       int err;
>> +
>> +       xdev = kzalloc_obj(*xdev, GFP_KERNEL);
>> +       if (!xdev)
>> +               return -ENOMEM;
>> +
>> +       xdev->pdev = pci_dev;
>> +       xdev->device = &pci_dev->dev;
>> +
>> +       pci_set_drvdata(pci_dev, xdev);
>> +       err = xsc_pci_init(xdev, id);
>> +       if (err) {
>> +               pci_err(pci_dev, "xsc_pci_init failed %d\n", err);
> Error logs in xsc_pci_init are enough for users/admins to pinpoint
> the issue. How about removing it?
   Will remove the duplicate pci_err() in probe.

    Thanks for the detailed review,

    Xin
>
> Thanks,
> Jason
>
>> +               goto err_unset_pci_drvdata;
>> +       }
>> +
>> +       return 0;
>> +
>> +err_unset_pci_drvdata:
>> +       pci_set_drvdata(pci_dev, NULL);
>> +       kfree(xdev);
>> +
>> +       return err;
>> +}
>> +
>> +static void xsc_pci_remove(struct pci_dev *pci_dev)
>> +{
>> +       struct xsc_core_device *xdev = pci_get_drvdata(pci_dev);
>> +
>> +       xsc_pci_fini(xdev);
>> +       pci_set_drvdata(pci_dev, NULL);
>> +       kfree(xdev);
>> +}
>> +
>> +static struct pci_driver xsc_pci_driver = {
>> +       .name           = "xsc-pci",
>> +       .id_table       = xsc_pci_id_table,
>> +       .probe          = xsc_pci_probe,
>> +       .remove         = xsc_pci_remove,
>> +};
>> +
>> +static int __init xsc_init(void)
>> +{
>> +       int err;
>> +
>> +       err = pci_register_driver(&xsc_pci_driver);
>> +       if (err) {
>> +               pr_err("failed to register pci driver\n");
>> +               return err;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>> +static void __exit xsc_fini(void)
>> +{
>> +       pci_unregister_driver(&xsc_pci_driver);
>> +}
>> +
>> +module_init(xsc_init);
>> +module_exit(xsc_fini);
>> +
>> +MODULE_DEVICE_TABLE(pci, xsc_pci_id_table);
>> +
>> +MODULE_LICENSE("GPL");
>> +MODULE_DESCRIPTION("Yunsilicon XSC PCI driver");
>> --
>> 2.43.0

       reply	other threads:[~2026-12-01  9:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a3487fb5-8c74-434c-9605-75ef1a430e99@yunsilicon.com>
2026-12-01  9:13 ` Xin Tian [this message]
2026-12-02  6:26   ` [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver Jason Xing
2026-11-26 14:57 [PATCH v2 00/11] net/xsc: add the Yunsilicon XSC ethernet driver Xin Tian
2026-11-26 14:57 ` [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver Xin Tian
2026-11-27 15:57   ` netdev-bot+sashiko
2026-12-06  2:56     ` Xin Tian
2026-11-28 17:32   ` Andrew Lunn
2026-12-01  9:48     ` Xin Tian
2026-11-29  2:53   ` Jason Xing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6cbcaecb-b0be-4ce9-afa6-9736f74d6766@yunsilicon.com \
    --to=tianx@yunsilicon.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=huangjunxian6@hisilicon.com \
    --cc=jgg@ziepe.ca \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=weihg@yunsilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox