* [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support
@ 2025-04-16 14:41 Huacai Chen
2025-04-16 14:41 ` [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function Huacai Chen
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Huacai Chen @ 2025-04-16 14:41 UTC (permalink / raw)
To: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Yanteng Si, Feiyang Chen, loongarch, netdev, linux-kernel,
Huacai Chen, Biao Dong, Baoqi Zhang
This series add stmmac driver support for Loongson-2K3000/Loongson-3B6000M,
which introduces a new CORE ID (0x12) and a new PCI device ID (0x7a23). The
new core reduces channel numbers from 8 to 4, but checksum is supported for
all channels.
V1 -> V2:
1. Use correct coding style.
2. Add Tested-by and Reviewed-by.
Huacai Chen (3):
net: stmmac: dwmac-loongson: Move queue number init to common function
net: stmmac: dwmac-loongson: Add new multi-chan IP core support
net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support
Tested-by: Biao Dong <dongbiao@loongson.cn>
Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
.../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 105 ++++++++++-----------
1 file changed, 49 insertions(+), 56 deletions(-)
---
2.27.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function
2025-04-16 14:41 [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Huacai Chen
@ 2025-04-16 14:41 ` Huacai Chen
2025-04-21 1:21 ` Yanteng Si
2025-04-16 14:41 ` [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support Huacai Chen
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Huacai Chen @ 2025-04-16 14:41 UTC (permalink / raw)
To: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Yanteng Si, Feiyang Chen, loongarch, netdev, linux-kernel,
Huacai Chen, Henry Chen, Biao Dong, Baoqi Zhang
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.
Tested-by: Henry Chen <chenx97@aosc.io>
Tested-by: Biao Dong <dongbiao@loongson.cn>
Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
.../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 = plat->bsp_priv;
+
/* Get bus_id, this can be overwritten later */
plat->bus_id = pci_dev_id(pdev);
@@ -116,32 +118,27 @@ static void loongson_default_data(struct pci_dev *pdev,
plat->dma_cfg->pbl = 32;
plat->dma_cfg->pblx8 = true;
+
+ if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
+ plat->rx_queues_to_use = CHANNEL_NUM;
+ plat->tx_queues_to_use = CHANNEL_NUM;
+
+ /* Only channel 0 supports checksum,
+ * so turn off checksum to enable multiple channels.
+ */
+ for (int i = 1; i < CHANNEL_NUM; i++)
+ plat->tx_queues_cfg[i].coe_unsupported = 1;
+ } else {
+ plat->tx_queues_to_use = 1;
+ plat->rx_queues_to_use = 1;
+ }
}
static int loongson_gmac_data(struct pci_dev *pdev,
struct plat_stmmacenet_data *plat)
{
- struct loongson_data *ld;
- int i;
-
- ld = plat->bsp_priv;
-
loongson_default_data(pdev, plat);
- if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
- plat->rx_queues_to_use = CHANNEL_NUM;
- plat->tx_queues_to_use = CHANNEL_NUM;
-
- /* Only channel 0 supports checksum,
- * so turn off checksum to enable multiple channels.
- */
- for (i = 1; i < CHANNEL_NUM; i++)
- plat->tx_queues_cfg[i].coe_unsupported = 1;
- } else {
- plat->tx_queues_to_use = 1;
- plat->rx_queues_to_use = 1;
- }
-
plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
return 0;
@@ -172,27 +169,8 @@ static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
static int loongson_gnet_data(struct pci_dev *pdev,
struct plat_stmmacenet_data *plat)
{
- struct loongson_data *ld;
- int i;
-
- ld = plat->bsp_priv;
-
loongson_default_data(pdev, plat);
- if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
- plat->rx_queues_to_use = CHANNEL_NUM;
- plat->tx_queues_to_use = CHANNEL_NUM;
-
- /* Only channel 0 supports checksum,
- * so turn off checksum to enable multiple channels.
- */
- for (i = 1; i < CHANNEL_NUM; i++)
- plat->tx_queues_cfg[i].coe_unsupported = 1;
- } else {
- plat->tx_queues_to_use = 1;
- plat->rx_queues_to_use = 1;
- }
-
plat->phy_interface = PHY_INTERFACE_MODE_GMII;
plat->mdio_bus_data->phy_mask = ~(u32)BIT(2);
plat->fix_mac_speed = loongson_gnet_fix_speed;
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support
2025-04-16 14:41 [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Huacai Chen
2025-04-16 14:41 ` [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function Huacai Chen
@ 2025-04-16 14:41 ` Huacai Chen
2025-04-21 2:03 ` Yanteng Si
2025-04-16 14:41 ` [PATCH net-next V2 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support Huacai Chen
2025-04-21 2:14 ` [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Yanteng Si
3 siblings, 1 reply; 12+ messages in thread
From: Huacai Chen @ 2025-04-16 14:41 UTC (permalink / raw)
To: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Yanteng Si, Feiyang Chen, loongarch, netdev, linux-kernel,
Huacai Chen, Andrew Lunn, Henry Chen, Biao Dong, Baoqi Zhang
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.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Henry Chen <chenx97@aosc.io>
Tested-by: Biao Dong <dongbiao@loongson.cn>
Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
.../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 @@
#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 */
struct loongson_data {
+ u32 multichan;
u32 loongson_id;
struct device *dev;
};
@@ -119,18 +120,29 @@ static void loongson_default_data(struct pci_dev *pdev,
plat->dma_cfg->pbl = 32;
plat->dma_cfg->pblx8 = true;
- if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
- plat->rx_queues_to_use = CHANNEL_NUM;
- plat->tx_queues_to_use = CHANNEL_NUM;
+ switch (ld->loongson_id) {
+ case DWMAC_CORE_MULTICHAN_V1:
+ ld->multichan = 1;
+ plat->rx_queues_to_use = 8;
+ plat->tx_queues_to_use = 8;
/* Only channel 0 supports checksum,
* so turn off checksum to enable multiple channels.
*/
- for (int i = 1; i < CHANNEL_NUM; i++)
+ for (int i = 1; i < 8; i++)
plat->tx_queues_cfg[i].coe_unsupported = 1;
- } else {
+
+ break;
+ case DWMAC_CORE_MULTICHAN_V2:
+ ld->multichan = 1;
+ plat->rx_queues_to_use = 4;
+ plat->tx_queues_to_use = 4;
+ break;
+ default:
+ ld->multichan = 0;
plat->tx_queues_to_use = 1;
plat->rx_queues_to_use = 1;
+ break;
}
}
@@ -328,14 +340,14 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
return NULL;
/* 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 == DWMAC_CORE_LS_MULTICHAN) {
+ if (ld->multichan) {
priv->synopsys_id = DWMAC_CORE_3_70;
*dma = dwmac1000_dma_ops;
dma->init_chan = loongson_dwmac_dma_init_channel;
@@ -356,13 +368,13 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
if (mac->multicast_filter_bins)
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
- /* 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 == PCI_DEVICE_ID_LOONGSON_GMAC) {
mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
} else {
- if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
+ if (ld->multichan)
mac->link.caps = 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 *pdev,
struct plat_stmmacenet_data *plat,
struct stmmac_resources *res)
{
- int i, ret, vecs;
+ int i, ch_num, ret, vecs;
- vecs = roundup_pow_of_two(CHANNEL_NUM * 2 + 1);
+ ch_num = min(plat->tx_queues_to_use, plat->rx_queues_to_use);
+
+ vecs = roundup_pow_of_two(ch_num * 2 + 1);
ret = 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,
res->irq = pci_irq_vector(pdev, 0);
- for (i = 0; i < plat->rx_queues_to_use; i++) {
- res->rx_irq[CHANNEL_NUM - 1 - i] =
- pci_irq_vector(pdev, 1 + i * 2);
+ for (i = 0; i < ch_num; i++) {
+ res->rx_irq[ch_num - 1 - i] = pci_irq_vector(pdev, 1 + i * 2);
}
- for (i = 0; i < plat->tx_queues_to_use; i++) {
- res->tx_irq[CHANNEL_NUM - 1 - i] =
- pci_irq_vector(pdev, 2 + i * 2);
+ for (i = 0; i < ch_num; i++) {
+ res->tx_irq[ch_num - 1 - i] = pci_irq_vector(pdev, 2 + i * 2);
}
plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
@@ -571,7 +583,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
goto err_disable_device;
/* Use the common MAC IRQ if per-channel MSIs allocation failed */
- if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
+ if (ld->multichan)
loongson_dwmac_msi_config(pdev, plat, &res);
ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
@@ -583,7 +595,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
err_plat_clear:
if (dev_of_node(&pdev->dev))
loongson_dwmac_dt_clear(pdev, plat);
- if (ld->loongson_id == 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);
- if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
+ if (ld->multichan)
loongson_dwmac_msi_clear(pdev);
pci_disable_device(pdev);
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next V2 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support
2025-04-16 14:41 [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Huacai Chen
2025-04-16 14:41 ` [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function Huacai Chen
2025-04-16 14:41 ` [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support Huacai Chen
@ 2025-04-16 14:41 ` Huacai Chen
2025-04-21 2:09 ` Yanteng Si
2025-04-21 2:14 ` [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Yanteng Si
3 siblings, 1 reply; 12+ messages in thread
From: Huacai Chen @ 2025-04-16 14:41 UTC (permalink / raw)
To: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Yanteng Si, Feiyang Chen, loongarch, netdev, linux-kernel,
Huacai Chen, Andrew Lunn, Henry Chen, Biao Dong, Baoqi Zhang
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 <andrew@lunn.ch>
Tested-by: Henry Chen <chenx97@aosc.io>
Tested-by: Biao Dong <dongbiao@loongson.cn>
Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
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)
-#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(void *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 == PCI_DEVICE_ID_LOONGSON_GMAC) {
+ if (pdev->device != PCI_DEVICE_ID_LOONGSON_GNET) {
mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
} else {
if (ld->multichan)
@@ -659,7 +660,8 @@ static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongson_dwmac_suspend,
loongson_dwmac_resume);
static const struct pci_device_id loongson_dwmac_id_table[] = {
- { 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) },
{}
};
--
2.47.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function
2025-04-16 14:41 ` [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function Huacai Chen
@ 2025-04-21 1:21 ` Yanteng Si
0 siblings, 0 replies; 12+ messages in thread
From: Yanteng Si @ 2025-04-21 1:21 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Feiyang Chen, loongarch, netdev, linux-kernel, Henry Chen,
Biao Dong, Baoqi Zhang
在 4/16/25 10:41 PM, Huacai Chen 写道:
> 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.
>
> Tested-by: Henry Chen <chenx97@aosc.io>
> Tested-by: Biao Dong <dongbiao@loongson.cn>
> Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Thanks,
Yanteng
> ---
> .../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 = plat->bsp_priv;
> +
> /* Get bus_id, this can be overwritten later */
> plat->bus_id = pci_dev_id(pdev);
>
> @@ -116,32 +118,27 @@ static void loongson_default_data(struct pci_dev *pdev,
>
> plat->dma_cfg->pbl = 32;
> plat->dma_cfg->pblx8 = true;
> +
> + if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
> + plat->rx_queues_to_use = CHANNEL_NUM;
> + plat->tx_queues_to_use = CHANNEL_NUM;
> +
> + /* Only channel 0 supports checksum,
> + * so turn off checksum to enable multiple channels.
> + */
> + for (int i = 1; i < CHANNEL_NUM; i++)
> + plat->tx_queues_cfg[i].coe_unsupported = 1;
> + } else {
> + plat->tx_queues_to_use = 1;
> + plat->rx_queues_to_use = 1;
> + }
> }
>
> static int loongson_gmac_data(struct pci_dev *pdev,
> struct plat_stmmacenet_data *plat)
> {
> - struct loongson_data *ld;
> - int i;
> -
> - ld = plat->bsp_priv;
> -
> loongson_default_data(pdev, plat);
>
> - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
> - plat->rx_queues_to_use = CHANNEL_NUM;
> - plat->tx_queues_to_use = CHANNEL_NUM;
> -
> - /* Only channel 0 supports checksum,
> - * so turn off checksum to enable multiple channels.
> - */
> - for (i = 1; i < CHANNEL_NUM; i++)
> - plat->tx_queues_cfg[i].coe_unsupported = 1;
> - } else {
> - plat->tx_queues_to_use = 1;
> - plat->rx_queues_to_use = 1;
> - }
> -
> plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
>
> return 0;
> @@ -172,27 +169,8 @@ static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
> static int loongson_gnet_data(struct pci_dev *pdev,
> struct plat_stmmacenet_data *plat)
> {
> - struct loongson_data *ld;
> - int i;
> -
> - ld = plat->bsp_priv;
> -
> loongson_default_data(pdev, plat);
>
> - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
> - plat->rx_queues_to_use = CHANNEL_NUM;
> - plat->tx_queues_to_use = CHANNEL_NUM;
> -
> - /* Only channel 0 supports checksum,
> - * so turn off checksum to enable multiple channels.
> - */
> - for (i = 1; i < CHANNEL_NUM; i++)
> - plat->tx_queues_cfg[i].coe_unsupported = 1;
> - } else {
> - plat->tx_queues_to_use = 1;
> - plat->rx_queues_to_use = 1;
> - }
> -
> plat->phy_interface = PHY_INTERFACE_MODE_GMII;
> plat->mdio_bus_data->phy_mask = ~(u32)BIT(2);
> plat->fix_mac_speed = loongson_gnet_fix_speed;
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support
2025-04-16 14:41 ` [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support Huacai Chen
@ 2025-04-21 2:03 ` Yanteng Si
2025-04-21 4:20 ` Huacai Chen
0 siblings, 1 reply; 12+ messages in thread
From: Yanteng Si @ 2025-04-21 2:03 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Feiyang Chen, loongarch, netdev, linux-kernel, Andrew Lunn,
Henry Chen, Biao Dong, Baoqi Zhang
在 4/16/25 10:41 PM, Huacai Chen 写道:
> 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.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Tested-by: Henry Chen <chenx97@aosc.io>
> Tested-by: Biao Dong <dongbiao@loongson.cn>
> Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
> .../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 @@
>
> #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 */
>
> struct loongson_data {
> + u32 multichan;
In order to make the logic clearer, I suggest splitting this patch.:
2/4 Add multichan for loongson_data
3/4 Add new multi-chan IP core support
> u32 loongson_id;
> struct device *dev;
> };
> @@ -119,18 +120,29 @@ static void loongson_default_data(struct pci_dev *pdev,
> plat->dma_cfg->pbl = 32;
> plat->dma_cfg->pblx8 = true;
>
> - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
> - plat->rx_queues_to_use = CHANNEL_NUM;
> - plat->tx_queues_to_use = CHANNEL_NUM;
> + switch (ld->loongson_id) {
> + case DWMAC_CORE_MULTICHAN_V1:
How about adding some comments? For example:
case DWMAC_CORE_MULTICHAN_V1: /* 2K2000 */
case DWMAC_CORE_MULTICHAN_V2: /* 2K3000 and 3B6000M */
...
> + ld->multichan = 1;
> + plat->rx_queues_to_use = 8;
> + plat->tx_queues_to_use = 8;
>
> /* Only channel 0 supports checksum,
> * so turn off checksum to enable multiple channels.
> */
> - for (int i = 1; i < CHANNEL_NUM; i++)
> + for (int i = 1; i < 8; i++)
> plat->tx_queues_cfg[i].coe_unsupported = 1;
> - } else {
> +
> + break;
> + case DWMAC_CORE_MULTICHAN_V2:
> + ld->multichan = 1;
> + plat->rx_queues_to_use = 4;
> + plat->tx_queues_to_use = 4;
> + break;
> + default:
> + ld->multichan = 0;
> plat->tx_queues_to_use = 1;
> plat->rx_queues_to_use = 1;
> + break;
> }
> }
>
> @@ -328,14 +340,14 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
> return NULL;
>
> /* 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 == DWMAC_CORE_LS_MULTICHAN) {
> + if (ld->multichan) {
> priv->synopsys_id = DWMAC_CORE_3_70;
> *dma = dwmac1000_dma_ops;
> dma->init_chan = loongson_dwmac_dma_init_channel;
> @@ -356,13 +368,13 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
> if (mac->multicast_filter_bins)
> mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
>
> - /* 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 == PCI_DEVICE_ID_LOONGSON_GMAC) {
> mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
> } else {
> - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
> + if (ld->multichan)
> mac->link.caps = 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 *pdev,
> struct plat_stmmacenet_data *plat,
> struct stmmac_resources *res)
> {
> - int i, ret, vecs;
> + int i, ch_num, ret, vecs;
>
> - vecs = roundup_pow_of_two(CHANNEL_NUM * 2 + 1);
> + ch_num = min(plat->tx_queues_to_use, plat->rx_queues_to_use);
I'm curious. Will there still be hardware with RX not equal to TX in the
future?
Thanks,
Yanteng
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support
2025-04-16 14:41 ` [PATCH net-next V2 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support Huacai Chen
@ 2025-04-21 2:09 ` Yanteng Si
0 siblings, 0 replies; 12+ messages in thread
From: Yanteng Si @ 2025-04-21 2:09 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Feiyang Chen, loongarch, netdev, linux-kernel, Andrew Lunn,
Henry Chen, Biao Dong, Baoqi Zhang
在 4/16/25 10:41 PM, Huacai Chen 写道:
> 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 <andrew@lunn.ch>
> Tested-by: Henry Chen <chenx97@aosc.io>
> Tested-by: Biao Dong <dongbiao@loongson.cn>
> Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Thanks,
Yanteng
> ---
> 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)
>
> -#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(void *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 == PCI_DEVICE_ID_LOONGSON_GMAC) {
> + if (pdev->device != PCI_DEVICE_ID_LOONGSON_GNET) {
> mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
> } else {
> if (ld->multichan)
> @@ -659,7 +660,8 @@ static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongson_dwmac_suspend,
> loongson_dwmac_resume);
>
> static const struct pci_device_id loongson_dwmac_id_table[] = {
> - { 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) },
> {}
> };
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support
2025-04-16 14:41 [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Huacai Chen
` (2 preceding siblings ...)
2025-04-16 14:41 ` [PATCH net-next V2 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support Huacai Chen
@ 2025-04-21 2:14 ` Yanteng Si
3 siblings, 0 replies; 12+ messages in thread
From: Yanteng Si @ 2025-04-21 2:14 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Feiyang Chen, loongarch, netdev, linux-kernel, Biao Dong,
Baoqi Zhang
在 4/16/25 10:41 PM, Huacai Chen 写道:
> This series add stmmac driver support for Loongson-2K3000/Loongson-3B6000M,
> which introduces a new CORE ID (0x12) and a new PCI device ID (0x7a23). The
> new core reduces channel numbers from 8 to 4, but checksum is supported for
> all channels.
>
> V1 -> V2:
> 1. Use correct coding style.
> 2. Add Tested-by and Reviewed-by.
>
> Huacai Chen (3):
> net: stmmac: dwmac-loongson: Move queue number init to common function
> net: stmmac: dwmac-loongson: Add new multi-chan IP core support
> net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support
> Tested-by: Biao Dong <dongbiao@loongson.cn>
I checked version 1, and no one has signed this tag. It seems to have
been carried out internally by Loongson, and this is somewhat ......
Thanks,
Yanteng
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support
2025-04-21 2:03 ` Yanteng Si
@ 2025-04-21 4:20 ` Huacai Chen
2025-04-22 2:29 ` Yanteng Si
0 siblings, 1 reply; 12+ messages in thread
From: Huacai Chen @ 2025-04-21 4:20 UTC (permalink / raw)
To: Yanteng Si
Cc: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Feiyang Chen, loongarch, netdev,
linux-kernel, Andrew Lunn, Henry Chen, Biao Dong, Baoqi Zhang
Hi, Yanteng,
On Mon, Apr 21, 2025 at 10:04 AM Yanteng Si <si.yanteng@linux.dev> wrote:
>
>
> 在 4/16/25 10:41 PM, Huacai Chen 写道:
> > 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.
> >
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> > Tested-by: Henry Chen <chenx97@aosc.io>
> > Tested-by: Biao Dong <dongbiao@loongson.cn>
> > Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> > .../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 @@
> >
> > #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 */
> >
> > struct loongson_data {
> > + u32 multichan;
>
> In order to make the logic clearer, I suggest splitting this patch.:
>
>
> 2/4 Add multichan for loongson_data
>
> 3/4 Add new multi-chan IP core support
I don't think the patch is unclear now, the multichan flag is really a
combination of DWMAC_CORE_MULTICHAN_V1 and DWMAC_CORE_MULTICHAN_V2.
>
>
> > u32 loongson_id;
> > struct device *dev;
> > };
> > @@ -119,18 +120,29 @@ static void loongson_default_data(struct pci_dev *pdev,
> > plat->dma_cfg->pbl = 32;
> > plat->dma_cfg->pblx8 = true;
> >
> > - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
> > - plat->rx_queues_to_use = CHANNEL_NUM;
> > - plat->tx_queues_to_use = CHANNEL_NUM;
> > + switch (ld->loongson_id) {
> > + case DWMAC_CORE_MULTICHAN_V1:
>
> How about adding some comments? For example:
>
> case DWMAC_CORE_MULTICHAN_V1: /* 2K2000 */
> case DWMAC_CORE_MULTICHAN_V2: /* 2K3000 and 3B6000M */
Do you know why we deprecate PRID (a.k.a SOC name) detection and
prefer CPUCFG detection in cpu_probe()? Because SOC-types and function
features are orthogonal, they should not be strictly bound. There will
be other SOCs using MULTICHAN_V1 or MULTICHAN_V2, should we update the
comments every time when a new SOC publishes? There may also be one
SOC with different IP-cores, then how to comment on this case?
> ...
>
> > + ld->multichan = 1;
> > + plat->rx_queues_to_use = 8;
> > + plat->tx_queues_to_use = 8;
> >
> > /* Only channel 0 supports checksum,
> > * so turn off checksum to enable multiple channels.
> > */
> > - for (int i = 1; i < CHANNEL_NUM; i++)
> > + for (int i = 1; i < 8; i++)
> > plat->tx_queues_cfg[i].coe_unsupported = 1;
> > - } else {
> > +
> > + break;
> > + case DWMAC_CORE_MULTICHAN_V2:
> > + ld->multichan = 1;
> > + plat->rx_queues_to_use = 4;
> > + plat->tx_queues_to_use = 4;
> > + break;
> > + default:
> > + ld->multichan = 0;
> > plat->tx_queues_to_use = 1;
> > plat->rx_queues_to_use = 1;
> > + break;
> > }
> > }
> >
> > @@ -328,14 +340,14 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
> > return NULL;
> >
> > /* 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 == DWMAC_CORE_LS_MULTICHAN) {
> > + if (ld->multichan) {
> > priv->synopsys_id = DWMAC_CORE_3_70;
> > *dma = dwmac1000_dma_ops;
> > dma->init_chan = loongson_dwmac_dma_init_channel;
> > @@ -356,13 +368,13 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
> > if (mac->multicast_filter_bins)
> > mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
> >
> > - /* 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 == PCI_DEVICE_ID_LOONGSON_GMAC) {
> > mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
> > } else {
> > - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
> > + if (ld->multichan)
> > mac->link.caps = 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 *pdev,
> > struct plat_stmmacenet_data *plat,
> > struct stmmac_resources *res)
> > {
> > - int i, ret, vecs;
> > + int i, ch_num, ret, vecs;
> >
> > - vecs = roundup_pow_of_two(CHANNEL_NUM * 2 + 1);
> > + ch_num = min(plat->tx_queues_to_use, plat->rx_queues_to_use);
>
> I'm curious. Will there still be hardware with RX not equal to TX in the
> future?
Currently rx queue number is equal to tx queue number, but
min(plat->tx_queues_to_use, plat->rx_queues_to_use) is still the best
solution. If not, which one should be used here? tx_queues_to_use or
rx_queues_to_use?
Huacai
>
>
> Thanks,
>
> Yanteng
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support
2025-04-21 4:20 ` Huacai Chen
@ 2025-04-22 2:29 ` Yanteng Si
2025-04-22 13:27 ` Paolo Abeni
0 siblings, 1 reply; 12+ messages in thread
From: Yanteng Si @ 2025-04-22 2:29 UTC (permalink / raw)
To: Huacai Chen
Cc: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Feiyang Chen, loongarch, netdev,
linux-kernel, Andrew Lunn, Henry Chen, Biao Dong, Baoqi Zhang
在 4/21/25 12:20 PM, Huacai Chen 写道:
> Hi, Yanteng,
>
> On Mon, Apr 21, 2025 at 10:04 AM Yanteng Si <si.yanteng@linux.dev> wrote:
>>
>> 在 4/16/25 10:41 PM, Huacai Chen 写道:
>>> 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.
>>>
>>> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>>> Tested-by: Henry Chen <chenx97@aosc.io>
>>> Tested-by: Biao Dong <dongbiao@loongson.cn>
>>> Signed-off-by: Baoqi Zhang <zhangbaoqi@loongson.cn>
>>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>>> ---
>>> .../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 @@
>>>
>>> #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 */
>>>
>>> struct loongson_data {
>>> + u32 multichan;
>> In order to make the logic clearer, I suggest splitting this patch.:
>>
>>
>> 2/4 Add multichan for loongson_data
>>
>> 3/4 Add new multi-chan IP core support
> I don't think the patch is unclear now, the multichan flag is really a
> combination of DWMAC_CORE_MULTICHAN_V1 and DWMAC_CORE_MULTICHAN_V2.
OK, please describe this code modification in the commit message.
>
>>
>>> u32 loongson_id;
>>> struct device *dev;
>>> };
>>> @@ -119,18 +120,29 @@ static void loongson_default_data(struct pci_dev *pdev,
>>> plat->dma_cfg->pbl = 32;
>>> plat->dma_cfg->pblx8 = true;
>>>
>>> - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN) {
>>> - plat->rx_queues_to_use = CHANNEL_NUM;
>>> - plat->tx_queues_to_use = CHANNEL_NUM;
>>> + switch (ld->loongson_id) {
>>> + case DWMAC_CORE_MULTICHAN_V1:
>> How about adding some comments? For example:
>>
>> case DWMAC_CORE_MULTICHAN_V1: /* 2K2000 */
>> case DWMAC_CORE_MULTICHAN_V2: /* 2K3000 and 3B6000M */
> Do you know why we deprecate PRID (a.k.a SOC name) detection and
> prefer CPUCFG detection in cpu_probe()? Because SOC-types and function
> features are orthogonal, they should not be strictly bound. There will
> be other SOCs using MULTICHAN_V1 or MULTICHAN_V2, should we update the
> comments every time when a new SOC publishes? There may also be one
> SOC with different IP-cores, then how to comment on this case?
In my opinion, having something is better than having nothing.
I've come up with a way to address your concerns:
case DWMAC_CORE_MULTICHAN_V1: /* 2K2000 ... */
case DWMAC_CORE_MULTICHAN_V2: /* 2K3000, 3B6000M ...*/
These limited comments are very friendly to developers outside
Loongson Company. Of course, I don't want to discuss this matter
any further. If you don't want to add code comments, I won't object
to this patch because of that.
>
>> ...
>>
>>> + ld->multichan = 1;
>>> + plat->rx_queues_to_use = 8;
>>> + plat->tx_queues_to_use = 8;
>>>
>>> /* Only channel 0 supports checksum,
>>> * so turn off checksum to enable multiple channels.
>>> */
>>> - for (int i = 1; i < CHANNEL_NUM; i++)
>>> + for (int i = 1; i < 8; i++)
>>> plat->tx_queues_cfg[i].coe_unsupported = 1;
>>> - } else {
>>> +
>>> + break;
>>> + case DWMAC_CORE_MULTICHAN_V2:
>>> + ld->multichan = 1;
>>> + plat->rx_queues_to_use = 4;
>>> + plat->tx_queues_to_use = 4;
>>> + break;
>>> + default:
>>> + ld->multichan = 0;
>>> plat->tx_queues_to_use = 1;
>>> plat->rx_queues_to_use = 1;
>>> + break;
>>> }
>>> }
>>>
>>> @@ -328,14 +340,14 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
>>> return NULL;
>>>
>>> /* 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 == DWMAC_CORE_LS_MULTICHAN) {
>>> + if (ld->multichan) {
>>> priv->synopsys_id = DWMAC_CORE_3_70;
>>> *dma = dwmac1000_dma_ops;
>>> dma->init_chan = loongson_dwmac_dma_init_channel;
>>> @@ -356,13 +368,13 @@ static struct mac_device_info *loongson_dwmac_setup(void *apriv)
>>> if (mac->multicast_filter_bins)
>>> mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
>>>
>>> - /* 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 == PCI_DEVICE_ID_LOONGSON_GMAC) {
>>> mac->link.caps = MAC_10 | MAC_100 | MAC_1000;
>>> } else {
>>> - if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
>>> + if (ld->multichan)
>>> mac->link.caps = 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 *pdev,
>>> struct plat_stmmacenet_data *plat,
>>> struct stmmac_resources *res)
>>> {
>>> - int i, ret, vecs;
>>> + int i, ch_num, ret, vecs;
>>>
>>> - vecs = roundup_pow_of_two(CHANNEL_NUM * 2 + 1);
>>> + ch_num = min(plat->tx_queues_to_use, plat->rx_queues_to_use);
>> I'm curious. Will there still be hardware with RX not equal to TX in the
>> future?
> Currently rx queue number is equal to tx queue number, but
> min(plat->tx_queues_to_use, plat->rx_queues_to_use) is still the best
> solution. If not, which one should be used here? tx_queues_to_use or
> rx_queues_to_use?
All right.
Thanks,
Yanteng
>
> Huacai
>
>>
>> Thanks,
>>
>> Yanteng
>>
>>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support
2025-04-22 2:29 ` Yanteng Si
@ 2025-04-22 13:27 ` Paolo Abeni
2025-04-23 1:01 ` Huacai Chen
0 siblings, 1 reply; 12+ messages in thread
From: Paolo Abeni @ 2025-04-22 13:27 UTC (permalink / raw)
To: Yanteng Si, Huacai Chen
Cc: Huacai Chen, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Feiyang Chen, loongarch, netdev, linux-kernel,
Andrew Lunn, Henry Chen, Biao Dong, Baoqi Zhang
On 4/22/25 4:29 AM, Yanteng Si wrote:
> 在 4/21/25 12:20 PM, Huacai Chen 写道:
>> On Mon, Apr 21, 2025 at 10:04 AM Yanteng Si <si.yanteng@linux.dev> wrote:
>>>> 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 @@
>>>>
>>>> #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 */
>>>>
>>>> struct loongson_data {
>>>> + u32 multichan;
>>> In order to make the logic clearer, I suggest splitting this patch.:
>>>
>>>
>>> 2/4 Add multichan for loongson_data
>>>
>>> 3/4 Add new multi-chan IP core support
>> I don't think the patch is unclear now, the multichan flag is really a
>> combination of DWMAC_CORE_MULTICHAN_V1 and DWMAC_CORE_MULTICHAN_V2.
> OK, please describe this code modification in the commit message.
@Huacai, please extend the commit message, as per Yanteng's request.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support
2025-04-22 13:27 ` Paolo Abeni
@ 2025-04-23 1:01 ` Huacai Chen
0 siblings, 0 replies; 12+ messages in thread
From: Huacai Chen @ 2025-04-23 1:01 UTC (permalink / raw)
To: Paolo Abeni
Cc: Yanteng Si, Huacai Chen, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Feiyang Chen, loongarch, netdev,
linux-kernel, Andrew Lunn, Henry Chen, Biao Dong, Baoqi Zhang
On Tue, Apr 22, 2025 at 9:27 PM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On 4/22/25 4:29 AM, Yanteng Si wrote:
> > 在 4/21/25 12:20 PM, Huacai Chen 写道:
> >> On Mon, Apr 21, 2025 at 10:04 AM Yanteng Si <si.yanteng@linux.dev> wrote:
> >>>> 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 @@
> >>>>
> >>>> #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 */
> >>>>
> >>>> struct loongson_data {
> >>>> + u32 multichan;
> >>> In order to make the logic clearer, I suggest splitting this patch.:
> >>>
> >>>
> >>> 2/4 Add multichan for loongson_data
> >>>
> >>> 3/4 Add new multi-chan IP core support
> >> I don't think the patch is unclear now, the multichan flag is really a
> >> combination of DWMAC_CORE_MULTICHAN_V1 and DWMAC_CORE_MULTICHAN_V2.
> > OK, please describe this code modification in the commit message.
>
> @Huacai, please extend the commit message, as per Yanteng's request.
Sure, will do later.
Huacai
>
> Thanks,
>
> Paolo
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-04-23 1:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 14:41 [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Huacai Chen
2025-04-16 14:41 ` [PATCH net-next V2 1/3] net: stmmac: dwmac-loongson: Move queue number init to common function Huacai Chen
2025-04-21 1:21 ` Yanteng Si
2025-04-16 14:41 ` [PATCH net-next V2 2/3] net: stmmac: dwmac-loongson: Add new multi-chan IP core support Huacai Chen
2025-04-21 2:03 ` Yanteng Si
2025-04-21 4:20 ` Huacai Chen
2025-04-22 2:29 ` Yanteng Si
2025-04-22 13:27 ` Paolo Abeni
2025-04-23 1:01 ` Huacai Chen
2025-04-16 14:41 ` [PATCH net-next V2 3/3] net: stmmac: dwmac-loongson: Add new GMAC's PCI device ID support Huacai Chen
2025-04-21 2:09 ` Yanteng Si
2025-04-21 2:14 ` [PATCH net-next V2 0/3] net: stmmac: dwmac-loongson: Add Loongson-2K3000 support Yanteng Si
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).