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]
Date: Fri, 28 Jul 2023 12:06:27 +0530
From: Ravi Gunasekaran <r-gunasekaran@...com>
To: Feiyang Chen <chenfeiyang@...ngson.cn>, <andrew@...n.ch>,
        <hkallweit1@...il.com>, <peppe.cavallaro@...com>,
        <alexandre.torgue@...s.st.com>, <joabreu@...opsys.com>,
        <chenhuacai@...ngson.cn>
CC: <linux@...linux.org.uk>, <dongbiao@...ngson.cn>,
        <loongson-kernel@...ts.loongnix.cn>, <netdev@...r.kernel.org>,
        <loongarch@...ts.linux.dev>, <chris.chenfeiyang@...il.com>
Subject: Re: [PATCH v2 06/10] net: stmmac: Add Loongson HWIF entry



On 7/27/23 12:48 PM, Feiyang Chen wrote:
> Add a new entry to HWIF table for Loongson.
> 
> Signed-off-by: Feiyang Chen <chenfeiyang@...ngson.cn>
> ---
>  drivers/net/ethernet/stmicro/stmmac/common.h  |  3 ++
>  .../ethernet/stmicro/stmmac/dwmac1000_dma.c   |  6 +++
>  drivers/net/ethernet/stmicro/stmmac/hwif.c    | 48 ++++++++++++++++++-
>  .../net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++----
>  include/linux/stmmac.h                        |  1 +
>  5 files changed, 73 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
> index 16e67c18b6f7..267f9a7913ac 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> @@ -29,11 +29,13 @@
>  /* Synopsys Core versions */
>  #define	DWMAC_CORE_3_40		0x34
>  #define	DWMAC_CORE_3_50		0x35
> +#define	DWMAC_CORE_3_70		0x37
>  #define	DWMAC_CORE_4_00		0x40
>  #define DWMAC_CORE_4_10		0x41
>  #define DWMAC_CORE_5_00		0x50
>  #define DWMAC_CORE_5_10		0x51
>  #define DWMAC_CORE_5_20		0x52
> +#define DWLGMAC_CORE_1_00	0x10
>  #define DWXGMAC_CORE_2_10	0x21
>  #define DWXLGMAC_CORE_2_00	0x20
>  
> @@ -547,6 +549,7 @@ int dwmac1000_setup(struct stmmac_priv *priv);
>  int dwmac4_setup(struct stmmac_priv *priv);
>  int dwxgmac2_setup(struct stmmac_priv *priv);
>  int dwxlgmac2_setup(struct stmmac_priv *priv);
> +int dwmac_loongson_setup(struct stmmac_priv *priv);
>  
>  void stmmac_set_mac_addr(void __iomem *ioaddr, const u8 addr[6],
>  			 unsigned int high, unsigned int low);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> index 7aa450d6a81a..5da5f111d7e0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
> @@ -172,6 +172,12 @@ static void dwmac1000_dma_init_rx(struct stmmac_priv *priv,
>  		       chan * DMA_CHAN_OFFSET);
>  		writel(upper_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR_HI +
>  		       chan * DMA_CHAN_OFFSET);
> +		if (priv->plat->has_lgmac) {
> +			writel(upper_32_bits(dma_rx_phy),
> +			       ioaddr + DMA_RCV_BASE_ADDR_SHADOW1);
> +			writel(upper_32_bits(dma_rx_phy),
> +			       ioaddr + DMA_RCV_BASE_ADDR_SHADOW2);
> +		}
>  	} else {
>  		/* RX descriptor base address list must be written into DMA CSR3 */
>  		writel(lower_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR +
> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
> index b8ba8f2d8041..b376ac4f80d5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
> @@ -58,7 +58,8 @@ static int stmmac_dwmac1_quirks(struct stmmac_priv *priv)
>  		dev_info(priv->device, "Enhanced/Alternate descriptors\n");
>  
>  		/* GMAC older than 3.50 has no extended descriptors */
> -		if (priv->synopsys_id >= DWMAC_CORE_3_50) {
> +		if (priv->synopsys_id >= DWMAC_CORE_3_50 ||
> +		    priv->plat->has_lgmac) {>  			dev_info(priv->device, "Enabled extended descriptors\n");
>  			priv->extend_desc = 1;
>  		} else {
> @@ -104,6 +105,7 @@ static const struct stmmac_hwif_entry {
>  	bool gmac;
>  	bool gmac4;
>  	bool xgmac;
> +	bool lgmac;

Similar to Andrew's comment on dwmac_is_loongson, can lgmac also be
renamed to some other name? 

I believe the 'gmac' and 'xgmac' refer to 1Gbps and 10Gbps which sounds generic,
while 'lgmac' sounds vendor specific. 

>  	u32 min_id;
>  	u32 dev_id;
>  	const struct stmmac_regs_off regs;


[...]

> +	}, {
> +		.gmac = true,
> +		.gmac4 = false,
> +		.xgmac = false,
> +		.lgmac = true,
> +		.min_id = DWLGMAC_CORE_1_00,
> +		.regs = {
> +			.ptp_off = PTP_GMAC3_X_OFFSET,
> +			.mmc_off = MMC_GMAC3_X_OFFSET,
> +		},
> +		.desc = NULL,
> +		.dma = &dwmac1000_dma_ops,
> +		.mac = &dwmac1000_ops,
> +		.hwtimestamp = &stmmac_ptp,
> +		.mode = NULL,
> +		.tc = NULL,
> +		.setup = dwmac_loongson_setup,
> +		.quirks = stmmac_dwmac1_quirks,
> +	}, {
> +		.gmac = true,
> +		.gmac4 = false,
> +		.xgmac = false,
> +		.lgmac = true,
> +		.min_id = DWMAC_CORE_3_50,
> +		.regs = {
> +			.ptp_off = PTP_GMAC3_X_OFFSET,
> +			.mmc_off = MMC_GMAC3_X_OFFSET,
> +		},
> +		.desc = NULL,
> +		.dma = &dwmac1000_dma_ops,
> +		.mac = &dwmac1000_ops,
> +		.hwtimestamp = &stmmac_ptp,
> +		.mode = NULL,
> +		.tc = NULL,
> +		.setup = dwmac1000_setup,
> +		.quirks = stmmac_dwmac1_quirks,
>  	},
>  };
>  
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index e8619853b6d6..829de274e75d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3505,17 +3505,21 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
>  {
>  	struct stmmac_priv *priv = netdev_priv(dev);
>  	enum request_irq_err irq_err;
> +	unsigned long flags = 0;
>  	cpumask_t cpu_mask;
>  	int irq_idx = 0;
>  	char *int_name;
>  	int ret;
>  	int i;
>  
> +	if (priv->plat->has_lgmac)
> +		flags |= IRQF_TRIGGER_RISING;

How about introducing a struct member such as "irq_flags"?

> +
>  	/* For common interrupt */
>  	int_name = priv->int_name_mac;
>  	sprintf(int_name, "%s:%s", dev->name, "mac");
>  	ret = request_irq(dev->irq, stmmac_mac_interrupt,
> -			  0, int_name, dev);
> +			  flags, int_name, dev);

[...]

> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> index 46bccc34814d..e21076f57205 100644
> --- a/include/linux/stmmac.h
> +++ b/include/linux/stmmac.h
> @@ -344,5 +344,6 @@ struct plat_stmmacenet_data {
>  	bool has_integrated_pcs;
>  	const struct dwmac_regs *dwmac_regs;
>  	bool dwmac_is_loongson;
> +	int has_lgmac;
>  };
>  #endif

-- 
Regards,
Ravi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ