From nobody Fri Dec 19 16:09:36 2025 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4A291F153C; Thu, 24 Apr 2025 07:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745479373; cv=none; b=KrlizAGu5oZ82p+N+twfNxFnTNuVK1ePG0laOP1hOEshkiMMmhnXKMprsTaeCCuCrmcPkT8I9vJSnHMry+s0/i7csYQG6Tv7XBrQii7/LzgGdvC1B5vGZh4q09PEdzwFb7pGtVDtxlxr5hAx3a/vUcmAQmkTKA61aYWeBr8dTWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745479373; c=relaxed/simple; bh=tcfZgMzg+sfw+anoWE/w1Xw3B5rpWogqZI+nYaVVg3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c6oxL8NyIJCmNZxwHDYWLSUHBH4dxTXT46Oi9DCbCsfxAqEuX2vDCW9FCDYQXtE6IbW7+jQBKI406XQikWSmW7ypV88YirABqC1WRbfsSBG1htsXp+rZZqtQRp8at1Qx/PTWHUImGVEHZcKKhbvor2lDwwGZdSS5zoQAt63tQ04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [223.64.68.238]) by gateway (Coremail) with SMTP id _____8Bx12nH5glo4CXFAA--.64587S3; Thu, 24 Apr 2025 15:22:47 +0800 (CST) Received: from localhost.localdomain (unknown [223.64.68.238]) by front1 (Coremail) with SMTP id qMiowMDxfRur5glo5CaTAA--.5456S3; Thu, 24 Apr 2025 15:22:44 +0800 (CST) From: Huacai Chen To: Huacai Chen , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Yanteng Si , Feiyang Chen , loongarch@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Huacai Chen , Henry Chen , Biao Dong , Baoqi Zhang Subject: [PATCH net-next V3 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function Date: Thu, 24 Apr 2025 15:22:07 +0800 Message-ID: <20250424072209.3134762-2-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250424072209.3134762-1-chenhuacai@loongson.cn> References: <20250424072209.3134762-1-chenhuacai@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMDxfRur5glo5CaTAA--.5456S3 X-CM-SenderInfo: hfkh0x5xdftxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBj93XoWxGw4fZFy5GFW3Gry3Kw45Arc_yoW5urWDp3 y3A3y7XrWfJr9xKws5t3yUCry5ArZYqr9FqF47Ka4rGryqkw1qv34rKFWvkFZ7AFZ8ua17 ZF4jkr47WF1qkrbCm3ZEXasCq-sJn29KB7ZKAUJUUUUD529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUB0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1ln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2 x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5 McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr4 1lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_ Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67 AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8I cVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI 8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v2 6r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU4YLvDUUUU Content-Type: text/plain; charset="utf-8" Currently, the tx and rx queue number initialization is duplicated in loongson_gmac_data() and loongson_gnet_data(), so move it to the common function loongson_default_data(). This is a preparation for later patches. Reviewed-by: Yanteng Si Tested-by: Henry Chen Tested-by: Biao Dong Signed-off-by: Baoqi Zhang Signed-off-by: Huacai Chen --- .../ethernet/stmicro/stmmac/dwmac-loongson.c | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac-loongson.c index 1a93787056a7..2fb7a137b312 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c @@ -83,6 +83,8 @@ struct stmmac_pci_info { static void loongson_default_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + struct loongson_data *ld =3D plat->bsp_priv; + /* Get bus_id, this can be overwritten later */ plat->bus_id =3D pci_dev_id(pdev); =20 @@ -116,32 +118,27 @@ static void loongson_default_data(struct pci_dev *pde= v, =20 plat->dma_cfg->pbl =3D 32; plat->dma_cfg->pblx8 =3D true; + + if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) { + plat->rx_queues_to_use =3D CHANNEL_NUM; + plat->tx_queues_to_use =3D CHANNEL_NUM; + + /* Only channel 0 supports checksum, + * so turn off checksum to enable multiple channels. + */ + for (int i =3D 1; i < CHANNEL_NUM; i++) + plat->tx_queues_cfg[i].coe_unsupported =3D 1; + } else { + plat->tx_queues_to_use =3D 1; + plat->rx_queues_to_use =3D 1; + } } =20 static int loongson_gmac_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { - struct loongson_data *ld; - int i; - - ld =3D plat->bsp_priv; - loongson_default_data(pdev, plat); =20 - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) { - plat->rx_queues_to_use =3D CHANNEL_NUM; - plat->tx_queues_to_use =3D CHANNEL_NUM; - - /* Only channel 0 supports checksum, - * so turn off checksum to enable multiple channels. - */ - for (i =3D 1; i < CHANNEL_NUM; i++) - plat->tx_queues_cfg[i].coe_unsupported =3D 1; - } else { - plat->tx_queues_to_use =3D 1; - plat->rx_queues_to_use =3D 1; - } - plat->phy_interface =3D PHY_INTERFACE_MODE_RGMII_ID; =20 return 0; @@ -172,27 +169,8 @@ static void loongson_gnet_fix_speed(void *priv, int sp= eed, unsigned int mode) static int loongson_gnet_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { - struct loongson_data *ld; - int i; - - ld =3D plat->bsp_priv; - loongson_default_data(pdev, plat); =20 - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) { - plat->rx_queues_to_use =3D CHANNEL_NUM; - plat->tx_queues_to_use =3D CHANNEL_NUM; - - /* Only channel 0 supports checksum, - * so turn off checksum to enable multiple channels. - */ - for (i =3D 1; i < CHANNEL_NUM; i++) - plat->tx_queues_cfg[i].coe_unsupported =3D 1; - } else { - plat->tx_queues_to_use =3D 1; - plat->rx_queues_to_use =3D 1; - } - plat->phy_interface =3D PHY_INTERFACE_MODE_GMII; plat->mdio_bus_data->phy_mask =3D ~(u32)BIT(2); plat->fix_mac_speed =3D loongson_gnet_fix_speed; --=20 2.47.1 From nobody Fri Dec 19 16:09:36 2025 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5DDF1F153C; Thu, 24 Apr 2025 07:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745479394; cv=none; b=sZYrTSaQ5iqj3WmXuqpxyz6tAKh86IeIiTadujsE5IGTivbCDglVr9O/P15187Q0B8wjUh5iGFurHwxUh3rqvfx+vbTXkFdkV7LyLr+7k4wg5i+jBMDzVDPSMLZYzpWAzooXsr38jYU9ArQAay4OmCw2Ta0Ph4Vwm+lwPonsopc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745479394; c=relaxed/simple; bh=z0RUvZlQbUDyScloRclDcIsoQxiJUD8eGaVrKzppNJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMG1nMuPLgugKw0MBQEBC85HQYW/kNlHRHEGhILkFxetLAhWyqXSzdrfVpgjWPbARDmfPmQ4Sd4T9l3E2DygDnOnOjtAUiMyxD0ejTvjUIA5HcEcGPiu1wJzRhe0JZuweYbG0q3VyoEWVwsdEczcuVQaazpY7OkYT/MpFFbfq6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [223.64.68.238]) by gateway (Coremail) with SMTP id _____8BxrOLd5gloDibFAA--.25653S3; Thu, 24 Apr 2025 15:23:09 +0800 (CST) Received: from localhost.localdomain (unknown [223.64.68.238]) by front1 (Coremail) with SMTP id qMiowMDxfRur5glo5CaTAA--.5456S4; Thu, 24 Apr 2025 15:23:06 +0800 (CST) From: Huacai Chen To: Huacai Chen , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Yanteng Si , Feiyang Chen , loongarch@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Huacai Chen , Andrew Lunn , Henry Chen , Biao Dong , Baoqi Zhang Subject: [PATCH net-next V3 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support Date: Thu, 24 Apr 2025 15:22:08 +0800 Message-ID: <20250424072209.3134762-3-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250424072209.3134762-1-chenhuacai@loongson.cn> References: <20250424072209.3134762-1-chenhuacai@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMDxfRur5glo5CaTAA--.5456S4 X-CM-SenderInfo: hfkh0x5xdftxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBj93XoW3Xr18Gw4kWryruF1xtr4UKFX_yoWxXFy5pF W3Aay2grWrWF4Y9an8J3yUZr15ArWYq3srXF42kw1vkF90yry2vFyrKFWYkrZ7CFZYyF42 vFyvvr4kWF4UCFbCm3ZEXasCq-sJn29KB7ZKAUJUUUUD529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYI kI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWr XwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI4 8JMxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwV AFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv2 0xvE14v26ryj6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4 v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AK xVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8XTm3UUUUU== Content-Type: text/plain; charset="utf-8" Add a new multi-chan IP core (0x12) support which is used in Loongson- 2K3000/Loongson-3B6000M. Compared with the 0x10 core, the new 0x12 core reduces channel numbers from 8 to 4, but checksum is supported for all channels. Add a "multichan" flag to loongson_data, so that we can simply use a "if (ld->multichan)" condition rather than the complicated condition "if (ld->loongson_id =3D=3D DWMAC_CORE_MULTICHAN_V1 || ld->loongson_id =3D= =3D DWMAC_CORE_MULTICHAN_V2)". Reviewed-by: Andrew Lunn Tested-by: Henry Chen Tested-by: Biao Dong Signed-off-by: Baoqi Zhang Signed-off-by: Huacai Chen Reviewed-by: Yanteng Si --- .../ethernet/stmicro/stmmac/dwmac-loongson.c | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac-loongson.c index 2fb7a137b312..57917f26ab4d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c @@ -68,10 +68,11 @@ =20 #define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03 #define PCI_DEVICE_ID_LOONGSON_GNET 0x7a13 -#define DWMAC_CORE_LS_MULTICHAN 0x10 /* Loongson custom ID */ -#define CHANNEL_NUM 8 +#define DWMAC_CORE_MULTICHAN_V1 0x10 /* Loongson custom ID 0x10 */ +#define DWMAC_CORE_MULTICHAN_V2 0x12 /* Loongson custom ID 0x12 */ =20 struct loongson_data { + u32 multichan; u32 loongson_id; struct device *dev; }; @@ -119,18 +120,29 @@ static void loongson_default_data(struct pci_dev *pde= v, plat->dma_cfg->pbl =3D 32; plat->dma_cfg->pblx8 =3D true; =20 - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) { - plat->rx_queues_to_use =3D CHANNEL_NUM; - plat->tx_queues_to_use =3D CHANNEL_NUM; + switch (ld->loongson_id) { + case DWMAC_CORE_MULTICHAN_V1: + ld->multichan =3D 1; + plat->rx_queues_to_use =3D 8; + plat->tx_queues_to_use =3D 8; =20 /* Only channel 0 supports checksum, * so turn off checksum to enable multiple channels. */ - for (int i =3D 1; i < CHANNEL_NUM; i++) + for (int i =3D 1; i < 8; i++) plat->tx_queues_cfg[i].coe_unsupported =3D 1; - } else { + + break; + case DWMAC_CORE_MULTICHAN_V2: + ld->multichan =3D 1; + plat->rx_queues_to_use =3D 4; + plat->tx_queues_to_use =3D 4; + break; + default: + ld->multichan =3D 0; plat->tx_queues_to_use =3D 1; plat->rx_queues_to_use =3D 1; + break; } } =20 @@ -328,14 +340,14 @@ static struct mac_device_info *loongson_dwmac_setup(v= oid *apriv) return NULL; =20 /* The Loongson GMAC and GNET devices are based on the DW GMAC - * v3.50a and v3.73a IP-cores. But the HW designers have changed the - * GMAC_VERSION.SNPSVER field to the custom 0x10 value on the - * network controllers with the multi-channels feature + * v3.50a and v3.73a IP-cores. But the HW designers have changed + * the GMAC_VERSION.SNPSVER field to the custom 0x10/0x12 value + * on the network controllers with the multi-channels feature * available to emphasize the differences: multiple DMA-channels, * AV feature and GMAC_INT_STATUS CSR flags layout. Get back the * original value so the correct HW-interface would be selected. */ - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) { + if (ld->multichan) { priv->synopsys_id =3D DWMAC_CORE_3_70; *dma =3D dwmac1000_dma_ops; dma->init_chan =3D loongson_dwmac_dma_init_channel; @@ -356,13 +368,13 @@ static struct mac_device_info *loongson_dwmac_setup(v= oid *apriv) if (mac->multicast_filter_bins) mac->mcast_bits_log2 =3D ilog2(mac->multicast_filter_bins); =20 - /* Loongson GMAC doesn't support the flow control. LS2K2000 - * GNET doesn't support the half-duplex link mode. + /* Loongson GMAC doesn't support the flow control. Loongson GNET + * without multi-channel doesn't support the half-duplex link mode. */ if (pdev->device =3D=3D PCI_DEVICE_ID_LOONGSON_GMAC) { mac->link.caps =3D MAC_10 | MAC_100 | MAC_1000; } else { - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) + if (ld->multichan) mac->link.caps =3D MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000; else @@ -391,9 +403,11 @@ static int loongson_dwmac_msi_config(struct pci_dev *p= dev, struct plat_stmmacenet_data *plat, struct stmmac_resources *res) { - int i, ret, vecs; + int i, ch_num, ret, vecs; =20 - vecs =3D roundup_pow_of_two(CHANNEL_NUM * 2 + 1); + ch_num =3D min(plat->tx_queues_to_use, plat->rx_queues_to_use); + + vecs =3D roundup_pow_of_two(ch_num * 2 + 1); ret =3D pci_alloc_irq_vectors(pdev, vecs, vecs, PCI_IRQ_MSI); if (ret < 0) { dev_warn(&pdev->dev, "Failed to allocate MSI IRQs\n"); @@ -402,14 +416,12 @@ static int loongson_dwmac_msi_config(struct pci_dev *= pdev, =20 res->irq =3D pci_irq_vector(pdev, 0); =20 - for (i =3D 0; i < plat->rx_queues_to_use; i++) { - res->rx_irq[CHANNEL_NUM - 1 - i] =3D - pci_irq_vector(pdev, 1 + i * 2); + for (i =3D 0; i < ch_num; i++) { + res->rx_irq[ch_num - 1 - i] =3D pci_irq_vector(pdev, 1 + i * 2); } =20 - for (i =3D 0; i < plat->tx_queues_to_use; i++) { - res->tx_irq[CHANNEL_NUM - 1 - i] =3D - pci_irq_vector(pdev, 2 + i * 2); + for (i =3D 0; i < ch_num; i++) { + res->tx_irq[ch_num - 1 - i] =3D pci_irq_vector(pdev, 2 + i * 2); } =20 plat->flags |=3D STMMAC_FLAG_MULTI_MSI_EN; @@ -571,7 +583,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, c= onst struct pci_device_id goto err_disable_device; =20 /* Use the common MAC IRQ if per-channel MSIs allocation failed */ - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) + if (ld->multichan) loongson_dwmac_msi_config(pdev, plat, &res); =20 ret =3D stmmac_dvr_probe(&pdev->dev, plat, &res); @@ -583,7 +595,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, c= onst struct pci_device_id err_plat_clear: if (dev_of_node(&pdev->dev)) loongson_dwmac_dt_clear(pdev, plat); - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) + if (ld->multichan) loongson_dwmac_msi_clear(pdev); err_disable_device: pci_disable_device(pdev); @@ -602,7 +614,7 @@ static void loongson_dwmac_remove(struct pci_dev *pdev) if (dev_of_node(&pdev->dev)) loongson_dwmac_dt_clear(pdev, priv->plat); =20 - if (ld->loongson_id =3D=3D DWMAC_CORE_LS_MULTICHAN) + if (ld->multichan) loongson_dwmac_msi_clear(pdev); =20 pci_disable_device(pdev); --=20 2.47.1 From nobody Fri Dec 19 16:09:36 2025 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2D7E20B1E8; Thu, 24 Apr 2025 07:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745479416; cv=none; b=DfPPu1l0c91oksX50y0Rh2grscX+8h5vEPkIvBDPeZ8t1RNfdKy5Dz0/0wzwT9R8AWc2k1sxR6VsT40kKar9RROuOmC+Rl5hlmVSNu0qWcFDR8i1NJtFXF6tgpMdJO7Qj3UoNd8/UC6ZLaVXHv7KUqAv0h+/HbLVDjVQESkXS/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745479416; c=relaxed/simple; bh=sCE3zOKQu+v4U8QbYK2c41yXFWGS4hqC53keo15tqbI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WxcOar5VGvZh/GkYhMB5jQ0IplF5BGwzgf5L240T59Z7TY7rLs1L96f5yqOZqFPNm8eXxicKtlAM1Gs169jVWUOVOO9OIoH9KPJEcp9ZXyCx2ultJkIEQXBEADBNC32XuHw+lRRA33/gsuAFA++FKfhq4f1wcMjMXPfkm/H1wjs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [223.64.68.238]) by gateway (Coremail) with SMTP id _____8Bxlmny5gloTibFAA--.64495S3; Thu, 24 Apr 2025 15:23:30 +0800 (CST) Received: from localhost.localdomain (unknown [223.64.68.238]) by front1 (Coremail) with SMTP id qMiowMDxfRur5glo5CaTAA--.5456S5; Thu, 24 Apr 2025 15:23:24 +0800 (CST) From: Huacai Chen To: Huacai Chen , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Yanteng Si , Feiyang Chen , loongarch@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Huacai Chen , Andrew Lunn , Henry Chen , Biao Dong , Baoqi Zhang Subject: [PATCH net-next V3 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support Date: Thu, 24 Apr 2025 15:22:09 +0800 Message-ID: <20250424072209.3134762-4-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250424072209.3134762-1-chenhuacai@loongson.cn> References: <20250424072209.3134762-1-chenhuacai@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMDxfRur5glo5CaTAA--.5456S5 X-CM-SenderInfo: hfkh0x5xdftxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBj93XoWxJrWrtrykCrW8Kw48Cr45Jwc_yoW8KFWxpr W5ZasFgrZ3GF45Cw4vqrWDWry5ZFZxG3srCF42yw4UWF93J342q3sF9Fs8Aw17ur45XFy2 vrWkCw48CFs8GwbCm3ZEXasCq-sJn29KB7ZKAUJUUUUD529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2kKe7AKxVWUAVWUtwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYI kI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWrXVW3 AwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI4 8JMxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMxCIbckI1I0E14v26r126r1DMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwV AFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv2 0xvE14v26ryj6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4 v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AK xVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU0XdjtUUUUU== Content-Type: text/plain; charset="utf-8" Add a new GMAC's PCI device ID (0x7a23) support which is used in Loongson-2K3000/Loongson-3B6000M. The new GMAC device use external PHY, so it reuses loongson_gmac_data() as the old GMAC device (0x7a03), and the new GMAC device still doesn't support flow control now. Reviewed-by: Andrew Lunn Reviewed-by: Yanteng Si Tested-by: Henry Chen Tested-by: Biao Dong Signed-off-by: Baoqi Zhang Signed-off-by: Huacai Chen --- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers= /net/ethernet/stmicro/stmmac/dwmac-loongson.c index 57917f26ab4d..e1591e6217d4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c @@ -66,7 +66,8 @@ DMA_STATUS_TPS | DMA_STATUS_TI | \ DMA_STATUS_MSK_COMMON_LOONGSON) =20 -#define PCI_DEVICE_ID_LOONGSON_GMAC 0x7a03 +#define PCI_DEVICE_ID_LOONGSON_GMAC1 0x7a03 +#define PCI_DEVICE_ID_LOONGSON_GMAC2 0x7a23 #define PCI_DEVICE_ID_LOONGSON_GNET 0x7a13 #define DWMAC_CORE_MULTICHAN_V1 0x10 /* Loongson custom ID 0x10 */ #define DWMAC_CORE_MULTICHAN_V2 0x12 /* Loongson custom ID 0x12 */ @@ -371,7 +372,7 @@ static struct mac_device_info *loongson_dwmac_setup(voi= d *apriv) /* Loongson GMAC doesn't support the flow control. Loongson GNET * without multi-channel doesn't support the half-duplex link mode. */ - if (pdev->device =3D=3D PCI_DEVICE_ID_LOONGSON_GMAC) { + if (pdev->device !=3D PCI_DEVICE_ID_LOONGSON_GNET) { mac->link.caps =3D MAC_10 | MAC_100 | MAC_1000; } else { if (ld->multichan) @@ -659,7 +660,8 @@ static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongso= n_dwmac_suspend, loongson_dwmac_resume); =20 static const struct pci_device_id loongson_dwmac_id_table[] =3D { - { PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_gmac_pci_info) }, + { PCI_DEVICE_DATA(LOONGSON, GMAC1, &loongson_gmac_pci_info) }, + { PCI_DEVICE_DATA(LOONGSON, GMAC2, &loongson_gmac_pci_info) }, { PCI_DEVICE_DATA(LOONGSON, GNET, &loongson_gnet_pci_info) }, {} }; --=20 2.47.1