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: Wed, 13 Mar 2024 17:24:52 +0800
From: Yanteng Si <siyanteng@...ngson.cn>
To: Serge Semin <fancer.lancer@...il.com>
Cc: andrew@...n.ch, hkallweit1@...il.com, peppe.cavallaro@...com,
 alexandre.torgue@...s.st.com, joabreu@...opsys.com, Jose.Abreu@...opsys.com,
 chenhuacai@...ngson.cn, linux@...linux.org.uk, guyinggang@...ngson.cn,
 netdev@...r.kernel.org, chris.chenfeiyang@...il.com
Subject: Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half
 duplex


在 2024/2/6 06:06, Serge Semin 写道:
> On Tue, Feb 06, 2024 at 12:58:17AM +0300, Serge Semin wrote:
>> On Tue, Jan 30, 2024 at 04:49:14PM +0800, Yanteng Si wrote:
>>> Current GNET does not support half duplex mode.
>>>
>>> Signed-off-by: Yanteng Si <siyanteng@...ngson.cn>
>>> Signed-off-by: Feiyang Chen <chenfeiyang@...ngson.cn>
>>> Signed-off-by: Yinggang Gu <guyinggang@...ngson.cn>
>>> ---
>>>   drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
>>>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
>>>   include/linux/stmmac.h                               |  1 +
>>>   3 files changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>>> index 264c4c198d5a..1753a3c46b77 100644
>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
>>> @@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
>>>   				struct stmmac_resources *res,
>>>   				struct device_node *np)
>>>   {
>>> -	if (pdev->revision == 0x00 || pdev->revision == 0x01)
>>> +	switch (pdev->revision) {
>>> +	case 0x00:
>>> +		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
>>> +			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
>>> +		break;
>>> +	case 0x01:
>>>   		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
>>> +		break;
>>> +	default:
>>> +		break;
>>> +	}
>> Move this change into the patch
>> [PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support
>>
>>>   
>>>   	return 0;
>>>   }
>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>> index 5617b40abbe4..3aa862269eb0 100644
>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>>> @@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
>>>   static void stmmac_set_half_duplex(struct stmmac_priv *priv)
>>>   {
>>>   	/* Half-Duplex can only work with single tx queue */
>>> -	if (priv->plat->tx_queues_to_use > 1)
>>> +	if (priv->plat->tx_queues_to_use > 1 ||
>>> +	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
>>>   		priv->phylink_config.mac_capabilities &=
>>>   			~(MAC_10HD | MAC_100HD | MAC_1000HD);
>>>   	else
>>> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
>>> index 2810361e4048..197f6f914104 100644
>>> --- a/include/linux/stmmac.h
>>> +++ b/include/linux/stmmac.h
>>> @@ -222,6 +222,7 @@ struct dwmac4_addrs {
>>>   #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
>>>   #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
>>>   #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
>>> +#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
>>>   
>> Place the patch with this change before
>> [PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support
>> as a pre-requisite/preparation patch. Don't forget a thorough
>> description of what is wrong with the GNET Half-Duplex mode.
> BTW what about re-defining the stmmac_ops.phylink_get_caps() callback
> instead of adding fixup flags in this patch and in the next one?

ok.

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index ac1b48ff7199..b57e1325ce62 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -238,6 +234,13 @@ static int loongson_gnet_get_hw_feature(void 
__iomem *ioaddr,
      return 0;
  }

+static void loongson_phylink_get_caps(struct stmmac_priv *priv)
+{
+    priv->phylink_config.mac_capabilities = (MAC_10FD |
+        MAC_100FD | MAC_1000FD) & ~(MAC_10HD | MAC_100HD | MAC_1000HD);
+
+}
+
  struct stmmac_pci_info {
      int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
      int (*config)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
@@ -403,10 +405,15 @@ static void loongson_gnet_fix_speed(void *priv, 
unsigned int speed, unsigned int

  static struct mac_device_info *loongson_setup(void *apriv)
  {
+    struct stmmac_ops *loongson_dwmac_ops;
      struct stmmac_priv *priv = apriv;
      struct mac_device_info *mac;
      struct stmmac_dma_ops *dma;

+    loongson_dwmac_ops = devm_kzalloc(priv->device, 
sizeof(*loongson_dwmac_ops), GFP_KERNEL);
+    if (!loongson_dwmac_ops)
+        return NULL;
+
      mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
      if (!mac)
          return NULL;
@@ -417,6 +424,10 @@ static struct mac_device_info *loongson_setup(void 
*apriv)

      priv->synopsys_id = 0x37;    /*Overwrite custom IP*/

+    *loongson_dwmac_ops = dwmac1000_ops;
+    loongson_dwmac_ops->phylink_get_caps = loongson_phylink_get_caps;
+    mac->mac = loongson_dwmac_ops;
+
      *dma = dwmac1000_dma_ops;
      dma->init_chan = loongson_gnet_dma_init_channel;
      dma->dma_interrupt = loongson_gnet_dma_interrupt;
@@ -375,8 +375,6 @@ static int loongson_gmac_config(struct pci_dev *pdev,
                                 struct stmmac_resources *res,
                                 struct device_node *np)
  {
-       plat->flags |= STMMAC_FLAG_DISABLE_FLOW_CONTROL;
-
         return 0;
  }

@@ -489,17 +487,7 @@ static int loongson_gnet_config(struct pci_dev *pdev,
                                 struct stmmac_resources *res,
                                 struct device_node *np)
  {
-       switch (pdev->revision) {
-       case 0x00:
-               plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
-                              STMMAC_FLAG_DISABLE_HALF_DUPLEX;
-               break;
-       case 0x01:
-               plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
-               break;
-       default:
-               break;
-       }
+       plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;

         return 0;
  }
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8705e04913d1..7c656f970575 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1201,8 +1201,7 @@ static int stmmac_init_phy(struct net_device *dev)
  static void stmmac_set_half_duplex(struct stmmac_priv *priv)
  {
      /* Half-Duplex can only work with single tx queue */
-    if (priv->plat->tx_queues_to_use > 1 ||
-        (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
+    if (priv->plat->tx_queues_to_use > 1)
          priv->phylink_config.mac_capabilities &=
              ~(MAC_10HD | MAC_100HD | MAC_1000HD);
      else
@@ -1237,9 +1236,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
          xpcs_get_interfaces(priv->hw->xpcs,
priv->phylink_config.supported_interfaces);

-    priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD | 
MAC_1000FD;
-    if (!(priv->plat->flags & STMMAC_FLAG_DISABLE_FLOW_CONTROL))
-        priv->phylink_config.mac_capabilities |= MAC_ASYM_PAUSE | 
MAC_SYM_PAUSE;
+    priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | 
MAC_SYM_PAUSE |
+                        MAC_10FD | MAC_100FD |
+                        MAC_1000FD;

      stmmac_set_half_duplex(priv);
  -----


loongson_gmac/gnet_config()

I will try to remove these two functions according to your comment in 
another patch。


Thanks,

Yanteng

>
> -Serge()
>
>> -Serge(y)
>>
>>>   struct plat_stmmacenet_data {
>>>   	int bus_id;
>>> -- 
>>> 2.31.4
>>>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ