From patchwork Fri Oct 12 16:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 148791 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp906380lji; Fri, 12 Oct 2018 09:06:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV619qYLMBCEriTw5Ark+oB75vZQEfcpZXHjoUaDvOwuWia6nNM+x6/p2CnMaz36HzQnoegb7 X-Received: by 2002:a63:2251:: with SMTP id t17-v6mr5975186pgm.275.1539360396701; Fri, 12 Oct 2018 09:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539360396; cv=none; d=google.com; s=arc-20160816; b=h3whUI0LjPHzNRzFpj7zaZ8+wrfCR0fjLSvstW9M5PZRbvwnsqGfvySN4mQC09SjB9 /JWQxP58bic+sdMilK6rfTz+Htr4C1yh0/YNqYQJ5z3ngNy9QRUtmzONdnTJM2uVxc15 PDE3HqzaDX5UzzCiS36l8sTnljEc9nzMZMwkHUdA05UsVWMefMwHtpiqyULoZoy+EGjx W1ukLdS4CpuVEKIc9LZ5rNW7pq/KRlzE+kQVn9dtzPbXjj6vjFmhtGMkD4d+36HiCt/5 9ioOmiNevwCPFVtGU9D6glb1SXWbOGsJKm5XwsJAofjcUs0k4DQWrpABod/gNtP20Nu+ JSbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ugxvMaHgww4tCznq8+Zrv/s/hrVuJo2pMgDC2pw469c=; b=hOhfd0aZ0dv827KaxaiNZ4bflYXgB7RQEEiZDIM96/YH2IyDMPtqrH0u15M9kBA5n6 FWzuC2bxTF5YAywhzmlU8lXKyIHtzA1jfOfnpq10O7HafcYSzoyvHqFimcZWXnMgbGs6 dHA+TRDtcHSMM3Qyge7nyugHgA0OIQjZ2hBUk4MT8iBJjdn6pyKhwqOlX7ZijFmZrd8b AJFQxSYdhJKbRcy2HBMTPp5z6I05NwZvSJFfMg6LmwpYx574/pRuvbBX2bBT1t+ZSYrM pxX84r36vvH70g1nEo2bI2tZTn2JchebSRyg1bQEgUa1Q7Jzo/LrTk9bBHaXKXdWFEwh a6sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e3c60FRu; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-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 m138-v6si1656183pfd.80.2018.10.12.09.06.36; Fri, 12 Oct 2018 09:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-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=e3c60FRu; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-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 S1728731AbeJLXjp (ORCPT + 5 others); Fri, 12 Oct 2018 19:39:45 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:47076 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728670AbeJLXjp (ORCPT ); Fri, 12 Oct 2018 19:39:45 -0400 Received: by mail-lj1-f196.google.com with SMTP id x3-v6so11797815lji.13 for ; Fri, 12 Oct 2018 09:06:34 -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; bh=ugxvMaHgww4tCznq8+Zrv/s/hrVuJo2pMgDC2pw469c=; b=e3c60FRuz9kFhciQ50JNXUyVX20s+6Ko3fG3Yf22hDiQFSW9jh45eXxzinMPhsssJ3 hVZp5dYePoqVFQR9Stgl6hm42IoiSPrqXFwJBzBZqmqmeOy0Cd8rsVJ74oYmQLBE2ijr aU7ZZV+kmHTMX9gUSGfYOzIbjGygcLCOHISZs= 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; bh=ugxvMaHgww4tCznq8+Zrv/s/hrVuJo2pMgDC2pw469c=; b=citXOVdiMfScRMRcJu8tMDmOP2CwTzu7a4BSl3els015S/+0x1JeXWCYbPyltLvA25 i8807vjByHpbgvknfkFo1icGVIDLif9XCicIrHWZeRmA+eMDZl0ZBTdMpIVNFNsdjTv9 ry8epFXsj8G1zQQ1eMn+RhC0RR7dJdJDCgRR7lYKJfbfWFoUXeT7AYiPMmq8gvz6G8Jf INPM194iFAFW0byhe2CGeO33slQBAYKiFziKvO6g0RZt3mw8UYJx10EZ76fp2mw/hWuO YhAZE2VGArbnr96YM0nAGqyrU0H+E422IbFlu/b84G16Ml6oVCrxULN13AQuloPJPUZ3 5mpw== X-Gm-Message-State: ABuFfoit0Kno4q6HE+qcjI7wZilykjxluJ5pUZ8ggNy1j0vaodvQVLHo 4ljvqR5ij57FjNrEY215gY/eRA== X-Received: by 2002:a2e:98c2:: with SMTP id s2-v6mr4474534ljj.19.1539360393130; Fri, 12 Oct 2018 09:06:33 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id b10-v6sm335622lje.47.2018.10.12.09.06.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 09:06:32 -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 net-next] net: ethernet: ti: cpsw: use for mcast entries only host port Date: Fri, 12 Oct 2018 19:06:29 +0300 Message-Id: <20181012160629.7245-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In dual-emac mode the cpsw driver sends directed packets, that means that packets go to the directed port, but an ALE lookup is performed to determine untagged egress only. It means that on tx side no need to add port bit for ALE mcast entry mask, and basically ALE entry for port identification is needed only on rx side. So, add only host port in dual_emac mode as used directed transmission, and no need in one more port. For single port boards and switch mode all ports used, as usual, so no changes for them. Also it simplifies farther changes. In other words, mcast entries for dual-emac should behave exactly like unicast. It also can help avoid leaking packets between ports with same vlan on h/w level if ports could became members of same vid. So now, for instance, if mcast address 33:33:00:00:00:01 is added then entries in ALE table: vid = 1, addr = 33:33:00:00:00:01, port_mask = 0x1 vid = 2, addr = 33:33:00:00:00:01, port_mask = 0x1 Instead of: vid = 1, addr = 33:33:00:00:00:01, port_mask = 0x3 vid = 2, addr = 33:33:00:00:00:01, port_mask = 0x5 With the same considerations, set only host port for unregistered mcast for dual-emac mode in case of IFF_ALLMULTI is set, exactly like it's done in cpsw_ale_set_allmulti(). Signed-off-by: Ivan Khoronzhuk --- Based on net-next/master drivers/net/ethernet/ti/cpsw.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.17.1 Reviewed-by: Grygorii Strashko diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 16dcbf36f8cc..7bfb7ee3a261 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -576,10 +576,8 @@ static void cpsw_add_mcast(struct cpsw_priv *priv, u8 *addr) if (cpsw->data.dual_emac) { struct cpsw_slave *slave = cpsw->slaves + priv->emac_port; - int slave_port = cpsw_get_slave_port(slave->slave_num); - cpsw_ale_add_mcast(cpsw->ale, addr, - 1 << slave_port | ALE_PORT_HOST, + cpsw_ale_add_mcast(cpsw->ale, addr, ALE_PORT_HOST, ALE_VLAN, slave->port_vlan, 0); return; } @@ -1410,7 +1408,7 @@ static inline void cpsw_add_dual_emac_def_ale_entries( cpsw_ale_add_vlan(cpsw->ale, slave->port_vlan, port_mask, port_mask, port_mask, 0); cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, - port_mask, ALE_VLAN, slave->port_vlan, 0); + ALE_PORT_HOST, ALE_VLAN, slave->port_vlan, 0); cpsw_ale_add_ucast(cpsw->ale, priv->mac_addr, HOST_PORT_NUM, ALE_VLAN | ALE_SECURE, slave->port_vlan); @@ -2293,16 +2291,19 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv, { int ret; int unreg_mcast_mask = 0; + int mcast_mask; u32 port_mask; struct cpsw_common *cpsw = priv->cpsw; if (cpsw->data.dual_emac) { port_mask = (1 << (priv->emac_port + 1)) | ALE_PORT_HOST; + mcast_mask = ALE_PORT_HOST; if (priv->ndev->flags & IFF_ALLMULTI) - unreg_mcast_mask = port_mask; + unreg_mcast_mask = mcast_mask; } else { port_mask = ALE_ALL_PORTS; + mcast_mask = port_mask; if (priv->ndev->flags & IFF_ALLMULTI) unreg_mcast_mask = ALE_ALL_PORTS; @@ -2321,7 +2322,7 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv, goto clean_vid; ret = cpsw_ale_add_mcast(cpsw->ale, priv->ndev->broadcast, - port_mask, ALE_VLAN, vid, 0); + mcast_mask, ALE_VLAN, vid, 0); if (ret != 0) goto clean_vlan_ucast; return 0;