Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp777892ybc; Sat, 16 Nov 2019 08:31:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxIMbmFDYnRSDVxi0SMVknSUmG7821yEClA/FF06JTtLGWa9hoDUrZn7I/3YF+8nwWuYD+k X-Received: by 2002:a5d:4810:: with SMTP id l16mr20500584wrq.127.1573921870625; Sat, 16 Nov 2019 08:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921870; cv=none; d=google.com; s=arc-20160816; b=gpJCVtJm1HMYhpe1cTF/+KLGdpACPB6gldeBEFOQ06G607FOF/HeDXUIV1Vtfbk2f1 Fzh6+MwtWbu6UZTmgOnJ0fwlEf7k5k1BIbWWPX8Of+0piDABuJ3D2xuhS4mauwGbKLBr B91GhzUZGlfcmNE+Uz+bd+S46oxyDbgfIe9RHJGx1WzXcw08eAyG2BndkZgjjsPKhc3K VcqSCpon+I1W1PLFNZ4+WtNEbmcGzXFrsd+TD24O+rVOgO7a0jtsr4tzseTZf7kalKHq pJWGgc8yauIh4lkuISSBAXwa3hux0UiwGQjfNooENNRk39AAPDV4i6PaD3RGReOOMjbe N9kg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DY+1daIZ3KZUoJPJDXNkB9qUUuCcDxI7rXeLeLVQZkA=; b=r2CZMbBpfuHzqfY3LqINKOoE4zsCW94C+UkvP1j2wD22KwNAdZh0q8qijSKLqIK5Ke S6O8Fjvr7EEkAYeoljTs+ay3EM/WdYFNKzDK4PxdHHUjTDoSRwoj6EoGgpFOH3EDrOYB UJc3/+yRRiFhWZMrXGE/ggnZSOjTvJ15j7cFZGb01nZs7x6SkUKEpcPy3cgoAZbjdxl+ 3pUBrPqNBtGY3+IT7QFf14k7k7YKAhjKYdQmgJfxRSaawOEM9s2cBUV7/NwoiLu7cXgy OjWIJsqHEb43rFl+BqXdK9iE7RCZScVBf3vzVH6P5UkztDXx5VFMO2kDORiBfcLrf9PK YOgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uMJUzoFb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si10900742edk.210.2019.11.16.08.30.46; Sat, 16 Nov 2019 08:31:10 -0800 (PST) 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=uMJUzoFb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730123AbfKPQ02 (ORCPT + 99 others); Sat, 16 Nov 2019 11:26:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:45264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727804AbfKPPlz (ORCPT ); Sat, 16 Nov 2019 10:41:55 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D02F2075E; Sat, 16 Nov 2019 15:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918914; bh=cTbj6kOszfLz/oxz/9GOU8X8ThfPuqYFmp+Zf3cX2vg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMJUzoFbOLWkXF0tTeIoqeDFDDnmQ0yWTv8ggkMJt7zaC9CWZxQdcuUV8Xv1vtqBJ VxWjyh6Ft+mTsuewIDyV4c360LsoArH50cd9psPugFare7Zj462IoZeSBo8ZHorCKB TSlwSnD9IsUWPUFcRBU5xXXTfG+MOEGh14SQtRKI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ivan Khoronzhuk , "David S . Miller" , Sasha Levin , linux-omap@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 037/237] net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update Date: Sat, 16 Nov 2019 10:37:52 -0500 Message-Id: <20191116154113.7417-37-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ivan Khoronzhuk [ Upstream commit 5da1948969bc1991920987ce4361ea56046e5a98 ] Whenever kernel or user decides to call rx mode update, it clears every multicast entry from forwarding table and in some time adds it again. This time can be enough to drop incoming multicast packets. That's why clear only staled multicast entries and update or add new one afterwards. Signed-off-by: Ivan Khoronzhuk Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/ti/cpsw.c | 46 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1afed85550c0a..ef79d2b6070b9 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -570,7 +570,7 @@ static inline int cpsw_get_slave_port(u32 slave_num) return slave_num + 1; } -static void cpsw_add_mcast(struct cpsw_priv *priv, u8 *addr) +static void cpsw_add_mcast(struct cpsw_priv *priv, const u8 *addr) { struct cpsw_common *cpsw = priv->cpsw; @@ -662,16 +662,35 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable) } } -static void cpsw_ndo_set_rx_mode(struct net_device *ndev) +static int cpsw_add_mc_addr(struct net_device *ndev, const u8 *addr) +{ + struct cpsw_priv *priv = netdev_priv(ndev); + + cpsw_add_mcast(priv, addr); + return 0; +} + +static int cpsw_del_mc_addr(struct net_device *ndev, const u8 *addr) { struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_common *cpsw = priv->cpsw; - int vid; + int vid, flags; - if (cpsw->data.dual_emac) + if (cpsw->data.dual_emac) { vid = cpsw->slaves[priv->emac_port].port_vlan; - else - vid = cpsw->data.default_vlan; + flags = ALE_VLAN; + } else { + vid = 0; + flags = 0; + } + + cpsw_ale_del_mcast(cpsw->ale, addr, 0, flags, vid); + return 0; +} + +static void cpsw_ndo_set_rx_mode(struct net_device *ndev) +{ + struct cpsw_common *cpsw = ndev_to_cpsw(ndev); if (ndev->flags & IFF_PROMISC) { /* Enable promiscuous mode */ @@ -684,19 +703,9 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev) } /* Restore allmulti on vlans if necessary */ - cpsw_ale_set_allmulti(cpsw->ale, priv->ndev->flags & IFF_ALLMULTI); - - /* Clear all mcast from ALE */ - cpsw_ale_flush_multicast(cpsw->ale, ALE_ALL_PORTS, vid); + cpsw_ale_set_allmulti(cpsw->ale, ndev->flags & IFF_ALLMULTI); - if (!netdev_mc_empty(ndev)) { - struct netdev_hw_addr *ha; - - /* program multicast address list into ALE register */ - netdev_for_each_mc_addr(ha, ndev) { - cpsw_add_mcast(priv, ha->addr); - } - } + __dev_mc_sync(ndev, cpsw_add_mc_addr, cpsw_del_mc_addr); } static void cpsw_intr_enable(struct cpsw_common *cpsw) @@ -1956,6 +1965,7 @@ static int cpsw_ndo_stop(struct net_device *ndev) struct cpsw_common *cpsw = priv->cpsw; cpsw_info(priv, ifdown, "shutting down cpsw device\n"); + __dev_mc_unsync(priv->ndev, cpsw_del_mc_addr); netif_tx_stop_all_queues(priv->ndev); netif_carrier_off(priv->ndev); -- 2.20.1