lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <65b1dc40d509676f81669bbc6b32531b1e6f3441.1692696115.git.chenfeiyang@loongson.cn>
Date: Tue, 22 Aug 2023 17:41:16 +0800
From: Feiyang Chen <chenfeiyang@...ngson.cn>
To: andrew@...n.ch,
	hkallweit1@...il.com,
	peppe.cavallaro@...com,
	alexandre.torgue@...s.st.com,
	joabreu@...opsys.com,
	chenhuacai@...ngson.cn
Cc: Feiyang Chen <chenfeiyang@...ngson.cn>,
	linux@...linux.org.uk,
	dongbiao@...ngson.cn,
	guyinggang@...ngson.cn,
	siyanteng@...ngson.cn,
	loongson-kernel@...ts.loongnix.cn,
	netdev@...r.kernel.org,
	loongarch@...ts.linux.dev,
	chris.chenfeiyang@...il.com
Subject: [PATCH v4 08/11] net: stmmac: dwegmac: Fix channel numbers

Some Loongson platforms cannot obtain the TX and RX number of channels.
Add the dwegmac_flag for them and specify the number of channels.

Signed-off-by: Feiyang Chen <chenfeiyang@...ngson.cn>
Signed-off-by: Yinggang Gu <guyinggang@...ngson.cn>
---
 drivers/net/ethernet/stmicro/stmmac/dwegmac_dma.c    | 10 ++++++++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c |  1 +
 include/linux/stmmac.h                               |  5 +++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwegmac_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwegmac_dma.c
index 9bb0564fbeff..157f0e3687be 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwegmac_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwegmac_dma.c
@@ -479,8 +479,14 @@ static int dwegmac_get_hw_feature(struct stmmac_priv *priv,
 	dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
 	dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
 	/* TX and RX number of channels */
-	dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
-	dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+	if (FIELD_GET(DWEGMAC_FIX_CHANNEL_NUM, priv->plat->dwegmac_flags) &&
+	    ((hw_cap & (DMA_HW_FEAT_RXCHCNT | DMA_HW_FEAT_TXCHCNT)) >> 20) == 0) {
+		dma_cap->number_rx_channel = 8;
+		dma_cap->number_tx_channel = 8;
+	} else {
+		dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+		dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+	}
 	/* Alternate (enhanced) DESC mode */
 	dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 0748bafd3aec..9fb27fc94d2a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -175,6 +175,7 @@ static int loongson_gmac_config(struct pci_dev *pdev,
 	switch (version & 0xff) {
 	case DWEGMAC_CORE_1_00:
 		ret = loongson_dwmac_config_multi_msi(pdev, plat, res, np, 8);
+		plat->dwegmac_flags |= FIELD_PREP(DWEGMAC_FIX_CHANNEL_NUM, 1);
 		break;
 	default:
 		ret = loongson_dwmac_config_single_irq(pdev, plat, res, np);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 75da4c7eb85c..e4088d2a0f39 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -14,6 +14,8 @@
 
 #include <linux/platform_device.h>
 #include <linux/phy.h>
+#include <linux/bitfield.h>
+#include <linux/bits.h>
 
 #define MTL_MAX_RX_QUEUES	8
 #define MTL_MAX_TX_QUEUES	8
@@ -205,6 +207,8 @@ struct dwmac4_addrs {
 	u32 mtl_low_cred_offset;
 };
 
+#define DWEGMAC_FIX_CHANNEL_NUM		BIT(0)
+
 struct plat_stmmacenet_data {
 	int bus_id;
 	int phy_addr;
@@ -297,5 +301,6 @@ struct plat_stmmacenet_data {
 	bool has_integrated_pcs;
 	int has_egmac;
 	u32 irq_flags;
+	unsigned int dwegmac_flags;
 };
 #endif
-- 
2.39.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ