Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3818233ybi; Mon, 29 Jul 2019 13:13:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl2jZQdlu2EMl1Jm2v9vuQr3ru8BXqskLTU0HULnGj161hrK3zPEORUZ2HPdlXGYcUnInq X-Received: by 2002:a65:62d7:: with SMTP id m23mr105884115pgv.358.1564431201066; Mon, 29 Jul 2019 13:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431201; cv=none; d=google.com; s=arc-20160816; b=cCujfrpL4ksA4DuhEgt+lp6KqqKmZVjR3UJTdCyGkGKmvWE8rSQt4ShFy0Xn/Or+K6 GU3C3/LEBBWe99f2d+4RfpSVol48sI6XJI5fsywT+LEW3FrA2bLOxIt/Ut37GvDZeyjI CoNTmEyGpudUmCwttXFpEHK9hqngdQqVIFo32mrRAZ+QpJuvFl/6dxd5ZMHmEnP4NIm6 WywP+/3uJTu64T/dN8uD1SuZq/MLYdUIgc/vLGEuaH87sM77nDHA0+2pOS0armbNr8MP Hw08INWhHm8ZVGGsn3ZgZrw1X2PE7PaHpViqNoCIsz/n6Vwopkayu0aVIsQsq3akkjh+ sfDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jnbGgAaS08dvnT7BKZzB2S0BaQhNHIz2QJaD0E0JhTI=; b=adCtBRlVQF1mX7yWeW11991zPEWxTF4fMQGVXTlQyHIHHpI/IjqkMdjS4KHhKaW6YL ZmvHUzZLK5Y/pJOBiqnf5F7otXvfP3B+46gNOdVPNKjfpCawMqqQIc82eMec6gsHFeG8 1zt+/ZdBteC7889w0P23xAuHuYrVJ+AKBdeBU3+Ij0Y3pinsLTdDlo1kvz4ja7qnJNzh zDMFyHdsvO8d2cGvIIA26GeQ9uYqsBCwjOBp5Gt78vZotWizyd2vaT5E6Ai4sfdi41zk ecL2kk4k+2pUqTJPuLEKhS4SMQ2fkqCGrnYptZPtT3tKJHNI5EBMkaGyluX6F4aoIJqO lZtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GfgZHFTX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si24436751pjt.4.2019.07.29.13.13.05; Mon, 29 Jul 2019 13:13:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GfgZHFTX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730441AbfG2UKp (ORCPT + 99 others); Mon, 29 Jul 2019 16:10:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:48390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388157AbfG2TeC (ORCPT ); Mon, 29 Jul 2019 15:34:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FE2421655; Mon, 29 Jul 2019 19:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428841; bh=wiDEyZdYXykqNWuoM8qvCbURYYqsywdDXaN71XOl2YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfgZHFTXNXQpf3g+eeR8mepgE6bsyPaA8ByNHC//wzzXDKoA3EudWE6mREf/bD8zY 0Mg6wgDNGZ5NR9zbQi3d3HVV4xuxkV4eAlHf4MxwLAmin6Iqcb7gvJiNhko3OPFiHe rooGQPkXn2xEzst6ephCh8KZYOIID/Uja77xL0oQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Justin Chen , Florian Fainelli , "David S. Miller" Subject: [PATCH 4.14 186/293] net: bcmgenet: use promisc for unsupported filters Date: Mon, 29 Jul 2019 21:21:17 +0200 Message-Id: <20190729190838.747798668@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Justin Chen [ Upstream commit 35cbef9863640f06107144687bd13151bc2e8ce3 ] Currently we silently ignore filters if we cannot meet the filter requirements. This will lead to the MAC dropping packets that are expected to pass. A better solution would be to set the NIC to promisc mode when the required filters cannot be met. Also correct the number of MDF filters supported. It should be 17, not 16. Signed-off-by: Justin Chen Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 57 +++++++++++-------------- 1 file changed, 26 insertions(+), 31 deletions(-) --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -3088,39 +3088,42 @@ static void bcmgenet_timeout(struct net_ netif_tx_wake_all_queues(dev); } -#define MAX_MC_COUNT 16 +#define MAX_MDF_FILTER 17 static inline void bcmgenet_set_mdf_addr(struct bcmgenet_priv *priv, unsigned char *addr, - int *i, - int *mc) + int *i) { - u32 reg; - bcmgenet_umac_writel(priv, addr[0] << 8 | addr[1], UMAC_MDF_ADDR + (*i * 4)); bcmgenet_umac_writel(priv, addr[2] << 24 | addr[3] << 16 | addr[4] << 8 | addr[5], UMAC_MDF_ADDR + ((*i + 1) * 4)); - reg = bcmgenet_umac_readl(priv, UMAC_MDF_CTRL); - reg |= (1 << (MAX_MC_COUNT - *mc)); - bcmgenet_umac_writel(priv, reg, UMAC_MDF_CTRL); *i += 2; - (*mc)++; } static void bcmgenet_set_rx_mode(struct net_device *dev) { struct bcmgenet_priv *priv = netdev_priv(dev); struct netdev_hw_addr *ha; - int i, mc; + int i, nfilter; u32 reg; netif_dbg(priv, hw, dev, "%s: %08X\n", __func__, dev->flags); - /* Promiscuous mode */ + /* Number of filters needed */ + nfilter = netdev_uc_count(dev) + netdev_mc_count(dev) + 2; + + /* + * Turn on promicuous mode for three scenarios + * 1. IFF_PROMISC flag is set + * 2. IFF_ALLMULTI flag is set + * 3. The number of filters needed exceeds the number filters + * supported by the hardware. + */ reg = bcmgenet_umac_readl(priv, UMAC_CMD); - if (dev->flags & IFF_PROMISC) { + if ((dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) || + (nfilter > MAX_MDF_FILTER)) { reg |= CMD_PROMISC; bcmgenet_umac_writel(priv, reg, UMAC_CMD); bcmgenet_umac_writel(priv, 0, UMAC_MDF_CTRL); @@ -3130,32 +3133,24 @@ static void bcmgenet_set_rx_mode(struct bcmgenet_umac_writel(priv, reg, UMAC_CMD); } - /* UniMac doesn't support ALLMULTI */ - if (dev->flags & IFF_ALLMULTI) { - netdev_warn(dev, "ALLMULTI is not supported\n"); - return; - } - /* update MDF filter */ i = 0; - mc = 0; /* Broadcast */ - bcmgenet_set_mdf_addr(priv, dev->broadcast, &i, &mc); + bcmgenet_set_mdf_addr(priv, dev->broadcast, &i); /* my own address.*/ - bcmgenet_set_mdf_addr(priv, dev->dev_addr, &i, &mc); - /* Unicast list*/ - if (netdev_uc_count(dev) > (MAX_MC_COUNT - mc)) - return; + bcmgenet_set_mdf_addr(priv, dev->dev_addr, &i); - if (!netdev_uc_empty(dev)) - netdev_for_each_uc_addr(ha, dev) - bcmgenet_set_mdf_addr(priv, ha->addr, &i, &mc); - /* Multicast */ - if (netdev_mc_empty(dev) || netdev_mc_count(dev) >= (MAX_MC_COUNT - mc)) - return; + /* Unicast */ + netdev_for_each_uc_addr(ha, dev) + bcmgenet_set_mdf_addr(priv, ha->addr, &i); + /* Multicast */ netdev_for_each_mc_addr(ha, dev) - bcmgenet_set_mdf_addr(priv, ha->addr, &i, &mc); + bcmgenet_set_mdf_addr(priv, ha->addr, &i); + + /* Enable filters */ + reg = GENMASK(MAX_MDF_FILTER - 1, MAX_MDF_FILTER - nfilter); + bcmgenet_umac_writel(priv, reg, UMAC_MDF_CTRL); } /* Set the hardware MAC address. */