Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp902065imm; Fri, 12 Oct 2018 08:29:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV616IGcd34VsphYCznZ6cOSgMe4K8sstnucceYYkj5TO4DWGYfuk2650DjUlHRugTxpDLriw X-Received: by 2002:a65:655a:: with SMTP id a26-v6mr5934101pgw.389.1539358157262; Fri, 12 Oct 2018 08:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539358157; cv=none; d=google.com; s=arc-20160816; b=JDNma0q818Y0Cp6WA6T/4jcFxcQWAUueIHaffGmkMvTSN4egmqw3hVplKHdaSoffvq YmC8eWyEiTy1tPDE4zVM2o5pXjHRp8ZLskT5tAtiGvanuVdxlfDWQkEixWicdPMAsBED HZFFGesknbGeeKMSkHw0o0WaD/hRTg+mH6slxmPBzcT3qZRhH+Pb7pzvlWSXr5P8T/CR C75yjs4TznTFb//M14wo8o/CPpWlvIIXIBRQuRG0WWPRPezNBaoW12vxd57zWqL0l5Zs Y5BL/bo2JXzPMFH++ukWnYO2ADTPmLC/W98r35oC9xXssL3saAVu/xM2E5ygI1FsQKpM u5yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=uL0gQCH5nRToPUTiJMZIUbGu30iF186CtuKZDfZZDX4=; b=wK/eUMwJl0Vklr1xcODy+36gleiO1eALSt3Ph+GQvoIFSOl/C7lbnpYHPIc6nIwdWA u7H3Ri4Nffj8kyhAqs9gxkVDlD4qL1JLGWE4BKr1nvTjdjtRdQhSQgQ25VSD3xs7pZVn y3D3PcctV1LaLgqSkxTMvfRcdFKxu/MboXVBb+XsgQKtSRoM/uQNRtzWwEQap1boaUlg UpKSRtsSc+3uQOvEiDQFWTPnn9+4Dli+sbBoG6HAbtdZEdfNEuiBxH4EtpeSI00rMJw5 3rOJyTMP68nz6oil0j8avMM0kpeZi68X+fjb5ANXlXHNCEJOt0/YXlveE8+S0cFEssQd DS+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mgnt0SvG; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11-v6si1590818pgj.276.2018.10.12.08.29.02; Fri, 12 Oct 2018 08:29:17 -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=@linaro.org header.s=google header.b=Mgnt0SvG; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbeJLXBX (ORCPT + 99 others); Fri, 12 Oct 2018 19:01:23 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41077 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729164AbeJLXBX (ORCPT ); Fri, 12 Oct 2018 19:01:23 -0400 Received: by mail-lf1-f66.google.com with SMTP id q39-v6so9602013lfi.8 for ; Fri, 12 Oct 2018 08:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uL0gQCH5nRToPUTiJMZIUbGu30iF186CtuKZDfZZDX4=; b=Mgnt0SvGPqFs/AZ8lavJIGEBb4aSqhnddvXwgozoJoS7jAbUTuWFUD2ObA1nC1Gnp8 bue0FfkZjVMBiVJqf7G0DCKOeToRqUYbKtOdH60gTdPSpJ+U3XSUGiPq5DBtd7rG15WY 3hq3pgznBmnbk3manpcFfujZgeMqsvZmJabkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uL0gQCH5nRToPUTiJMZIUbGu30iF186CtuKZDfZZDX4=; b=M1P4VqbkhAnb3wkd4CiuxogtoGFLlkV81HtaME0YQI23YX1c2mGugE0iWY5bdJBDUX dJDE7UgokfI4DHTT2oeh76O7xdvvQE6wktXgVU864ak02YxNA5BtBcK7xaCJUlfV1XG+ 3kbFulI/nCvALFHej54ASEJH47GmpyIOiE8N2MU1z5CsHP1suioGIgG9irlqSKrKn5C/ aPpkS9ZN7dCV+PEh+VSKtfoO56ImTe0hjgQq+JnbTDrGyIRfhZKGDXMOeFbJBMQDbIU7 XY2RoinNIuGwCWsAwetY+t593MEYmNLvk3LLDlO1NgVR+xFnRQ9QAdt3kibmGnSVpErX UMMg== X-Gm-Message-State: ABuFfoh5kZZQV5siL/eDrHPdL6d1OzmTZCKVey7ukaEjgOLaStXAbU9E w2/JgtwOr4POH+odDgEnwrVwdA== X-Received: by 2002:a19:ab1a:: with SMTP id u26-v6mr4360863lfe.103.1539358102146; Fri, 12 Oct 2018 08:28:22 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id a63-v6sm325923ljf.54.2018.10.12.08.28.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 08:28:21 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH 2/2] net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update Date: Fri, 12 Oct 2018 18:28:15 +0300 Message-Id: <20181012152815.31320-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181012152815.31320-1-ivan.khoronzhuk@linaro.org> References: <20181012152815.31320-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 832bce07c385..b7a6a2a0f71d 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.17.1