Re: [PATCH net] net: aquantia: vlan unicast address list correct handling

2018-07-05 Thread David Miller
From: Igor Russkikh 
Date: Thu,  5 Jul 2018 17:01:09 +0300

> Setting up macvlan/macvtap networks over atlantic NIC results
> in no traffic over these networks because ndo_set_rx_mode did
> not listed UC MACs as registered in unicast filter.
> 
> Here we fix that taking into account maximum number of UC
> filters supported by hardware. If more than MAX addresses were
> registered, we just enable promisc  and/or allmulti to pass
> the traffic in.
> 
> We also remove MULTICAST_ADDRESS_MAX constant from aq_cfg since
> thats not a configurable parameter at all.
> 
> Fixes: b21f502 ("net:ethernet:aquantia: Fix for multicast filter handling.")
> Signed-off-by: Igor Russkikh 

Applied and queued up for -stable.

Thanks!


[PATCH net] net: aquantia: vlan unicast address list correct handling

2018-07-05 Thread Igor Russkikh
Setting up macvlan/macvtap networks over atlantic NIC results
in no traffic over these networks because ndo_set_rx_mode did
not listed UC MACs as registered in unicast filter.

Here we fix that taking into account maximum number of UC
filters supported by hardware. If more than MAX addresses were
registered, we just enable promisc  and/or allmulti to pass
the traffic in.

We also remove MULTICAST_ADDRESS_MAX constant from aq_cfg since
thats not a configurable parameter at all.

Fixes: b21f502 ("net:ethernet:aquantia: Fix for multicast filter handling.")
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/aquantia/atlantic/aq_cfg.h|  2 -
 drivers/net/ethernet/aquantia/atlantic/aq_hw.h |  4 +-
 drivers/net/ethernet/aquantia/atlantic/aq_main.c   | 11 +
 drivers/net/ethernet/aquantia/atlantic/aq_nic.c| 47 +-
 drivers/net/ethernet/aquantia/atlantic/aq_nic.h|  2 +-
 .../ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c  |  2 +-
 .../ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c  |  4 +-
 7 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h 
b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
index fc73831..91eb891 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
@@ -63,8 +63,6 @@
 
 #define AQ_CFG_NAPI_WEIGHT 64U
 
-#define AQ_CFG_MULTICAST_ADDRESS_MAX 32U
-
 /*#define AQ_CFG_MAC_ADDR_PERMANENT {0x30, 0x0E, 0xE3, 0x12, 0x34, 0x56}*/
 
 #define AQ_NIC_FC_OFF0U
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h 
b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index a2d416b..2c6ebd9 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -98,6 +98,8 @@ struct aq_stats_s {
 #define AQ_HW_MEDIA_TYPE_TP1U
 #define AQ_HW_MEDIA_TYPE_FIBRE 2U
 
+#define AQ_HW_MULTICAST_ADDRESS_MAX 32U
+
 struct aq_hw_s {
atomic_t flags;
u8 rbl_enabled:1;
@@ -177,7 +179,7 @@ struct aq_hw_ops {
unsigned int packet_filter);
 
int (*hw_multicast_list_set)(struct aq_hw_s *self,
-u8 ar_mac[AQ_CFG_MULTICAST_ADDRESS_MAX]
+u8 ar_mac[AQ_HW_MULTICAST_ADDRESS_MAX]
 [ETH_ALEN],
 u32 count);
 
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
index ba5fe8c..e3ae29e 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
@@ -135,17 +135,10 @@ static int aq_ndev_set_mac_address(struct net_device 
*ndev, void *addr)
 static void aq_ndev_set_multicast_settings(struct net_device *ndev)
 {
struct aq_nic_s *aq_nic = netdev_priv(ndev);
-   int err = 0;
 
-   err = aq_nic_set_packet_filter(aq_nic, ndev->flags);
-   if (err < 0)
-   return;
+   aq_nic_set_packet_filter(aq_nic, ndev->flags);
 
-   if (netdev_mc_count(ndev)) {
-   err = aq_nic_set_multicast_list(aq_nic, ndev);
-   if (err < 0)
-   return;
-   }
+   aq_nic_set_multicast_list(aq_nic, ndev);
 }
 
 static const struct net_device_ops aq_ndev_ops = {
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 1a1a638..7a22d02 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -563,34 +563,41 @@ int aq_nic_set_packet_filter(struct aq_nic_s *self, 
unsigned int flags)
 
 int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev)
 {
+   unsigned int packet_filter = self->packet_filter;
struct netdev_hw_addr *ha = NULL;
unsigned int i = 0U;
 
-   self->mc_list.count = 0U;
-
-   netdev_for_each_mc_addr(ha, ndev) {
-   ether_addr_copy(self->mc_list.ar[i++], ha->addr);
-   ++self->mc_list.count;
+   self->mc_list.count = 0;
+   if (netdev_uc_count(ndev) > AQ_HW_MULTICAST_ADDRESS_MAX) {
+   packet_filter |= IFF_PROMISC;
+   } else {
+   netdev_for_each_uc_addr(ha, ndev) {
+   ether_addr_copy(self->mc_list.ar[i++], ha->addr);
 
-   if (i >= AQ_CFG_MULTICAST_ADDRESS_MAX)
-   break;
+   if (i >= AQ_HW_MULTICAST_ADDRESS_MAX)
+   break;
+   }
}
 
-   if (i >= AQ_CFG_MULTICAST_ADDRESS_MAX) {
-   /* Number of filters is too big: atlantic does not support this.
-* Force all multi filter to support this.
-* With this we disable all UC filters and setup "all pass"
-* multicast mask
-*/
-   self->packet_filter |=