Re: [PATCH net-next 1/3] net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available

2019-10-06 Thread kbuild test robot
Hi Jose,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Jose-Abreu/net-stmmac-Improvements-for-next/20191007-013324
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-42-g38eda53-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 


sparse warnings: (new ones prefixed by >>)

   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2613:17: sparse: sparse: 
incorrect type in argument 1 (different address spaces) @@expected void 
[noderef]  *ioaddr @@got void [noderef]  *ioaddr @@
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2613:17: sparse:
expected void [noderef]  *ioaddr
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2613:17: sparse:got 
struct mac_device_info *hw
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4224:21: sparse: sparse: 
>> incorrect type in assignment (different base types) @@expected unsigned 
>> short [assigned] [usertype] vid @@got  short [assigned] [usertype] vid @@
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4224:21: sparse:
>> expected unsigned short [assigned] [usertype] vid
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:4224:21: sparse:got 
>> restricted __le16 [usertype]

vim +4224 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

  4206  
  4207  static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
  4208  {
  4209  u32 crc, hash = 0;
  4210  int count = 0;
  4211  u16 vid = 0;
  4212  
  4213  for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
  4214  __le16 vid_le = cpu_to_le16(vid);
  4215  crc = bitrev32(~stmmac_vid_crc32_le(vid_le)) >> 28;
  4216  hash |= (1 << crc);
  4217  count++;
  4218  }
  4219  
  4220  if (!priv->dma_cap.vlhash) {
  4221  if (count > 2) /* VID = 0 always passes filter */
  4222  return -EOPNOTSUPP;
  4223  
> 4224  vid = cpu_to_le16(vid);
  4225  hash = 0;
  4226  }
  4227  
  4228  return stmmac_update_vlan_hash(priv, priv->hw, hash, vid, 
is_double);
  4229  }
  4230  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH net-next 1/3] net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available

2019-10-06 Thread Jose Abreu
From: Jose Abreu 

If VLAN Hash Filtering is not available we can fallback to perfect
filtering instead. Let's implement this in XGMAC and GMAC cores and let
the user use this filter.

VLAN VID=0 always passes filter so we check if more than 2 VLANs are
created and return proper error code if so because perfect filtering
only supports 1 VID at a time.

Signed-off-by: Jose Abreu 

---
Cc: Giuseppe Cavallaro 
Cc: Alexandre Torgue 
Cc: Jose Abreu 
Cc: "David S. Miller" 
Cc: Maxime Coquelin 
Cc: net...@vger.kernel.org
Cc: linux-st...@st-md-mailman.stormreply.com
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c   | 12 +++-
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 17 -
 drivers/net/ethernet/stmicro/stmmac/hwif.h  |  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   | 18 --
 4 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 5a7b0aca1d31..1a04815d1d65 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -733,7 +733,7 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, 
bool enable)
 }
 
 static void dwmac4_update_vlan_hash(struct mac_device_info *hw, u32 hash,
-   bool is_double)
+   u16 perfect_match, bool is_double)
 {
void __iomem *ioaddr = hw->pcsr;
 
@@ -748,6 +748,16 @@ static void dwmac4_update_vlan_hash(struct mac_device_info 
*hw, u32 hash,
}
 
writel(value, ioaddr + GMAC_VLAN_TAG);
+   } else if (perfect_match) {
+   u32 value = GMAC_VLAN_ETV;
+
+   if (is_double) {
+   value |= GMAC_VLAN_EDVLP;
+   value |= GMAC_VLAN_ESVL;
+   value |= GMAC_VLAN_DOVLTC;
+   }
+
+   writel(value | perfect_match, ioaddr + GMAC_VLAN_TAG);
} else {
u32 value = readl(ioaddr + GMAC_VLAN_TAG);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c 
b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
index 5031398e612c..5cda360d5d07 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -555,7 +555,7 @@ static int dwxgmac2_rss_configure(struct mac_device_info 
*hw,
 }
 
 static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
- bool is_double)
+ u16 perfect_match, bool is_double)
 {
void __iomem *ioaddr = hw->pcsr;
 
@@ -576,6 +576,21 @@ static void dwxgmac2_update_vlan_hash(struct 
mac_device_info *hw, u32 hash,
}
 
writel(value, ioaddr + XGMAC_VLAN_TAG);
+   } else if (perfect_match) {
+   u32 value = readl(ioaddr + XGMAC_PACKET_FILTER);
+
+   value |= XGMAC_FILTER_VTFE;
+
+   writel(value, ioaddr + XGMAC_PACKET_FILTER);
+
+   value = XGMAC_VLAN_ETV;
+   if (is_double) {
+   value |= XGMAC_VLAN_EDVLP;
+   value |= XGMAC_VLAN_ESVL;
+   value |= XGMAC_VLAN_DOVLTC;
+   }
+
+   writel(value | perfect_match, ioaddr + XGMAC_VLAN_TAG);
} else {
u32 value = readl(ioaddr + XGMAC_PACKET_FILTER);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h 
b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index ddb851d99618..1303d1e9a18f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -357,7 +357,7 @@ struct stmmac_ops {
 struct stmmac_rss *cfg, u32 num_rxq);
/* VLAN */
void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
-bool is_double);
+u16 perfect_match, bool is_double);
void (*enable_vlan)(struct mac_device_info *hw, u32 type);
/* TX Timestamp */
int (*get_mac_tx_timestamp)(struct mac_device_info *hw, u64 *ts);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b8ac1744950e..8b76745a7ec4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4207,15 +4207,25 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)
 static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
 {
u32 crc, hash = 0;
-   u16 vid;
+   int count = 0;
+   u16 vid = 0;
 
for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
__le16 vid_le = cpu_to_le16(vid);
crc = bitrev32(~stmmac_vid_crc32_le(vid_le))