From patchwork Tue Oct 31 14:48:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egil Hjelmeland X-Patchwork-Id: 832531 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yRDlG0Zqjz9sP1 for ; Wed, 1 Nov 2017 01:49:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753516AbdJaOsm (ORCPT ); Tue, 31 Oct 2017 10:48:42 -0400 Received: from aibo.runbox.com ([91.220.196.211]:42968 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753513AbdJaOsk (ORCPT ); Tue, 31 Oct 2017 10:48:40 -0400 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1e9XqG-0002pO-2T; Tue, 31 Oct 2017 15:48:36 +0100 Received: from 93.89.113.32.ip.vitnett.no ([93.89.113.32] helo=localhost.localdomain) by mailfront11.runbox.com with esmtpsa (uid:646232 ) (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1e9Xps-0003AG-9G; Tue, 31 Oct 2017 15:48:12 +0100 From: Egil Hjelmeland To: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Egil Hjelmeland Subject: [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast Date: Tue, 31 Oct 2017 15:48:00 +0100 Message-Id: <20171031144802.12686-2-privat@egil-hjelmeland.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171031144802.12686-1-privat@egil-hjelmeland.no> References: <20171031144802.12686-1-privat@egil-hjelmeland.no> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org lan9303_xmit_use_arl() introduced in previous patch set is wrong. The chip flood broadcast and unknown multicast frames. The effect is that broadcasts and multicasts are duplicated on egress. It is not possible to configure the chip to direct unknown multicasts to CPU port only. This means that only unicast frames can be transmitted using ALR lookup. Signed-off-by: Egil Hjelmeland Reviewed-by: Andrew Lunn --- net/dsa/tag_lan9303.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index 64092325aac3..537ca991fafe 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -46,7 +46,7 @@ /* Decide whether to transmit using ALR lookup, or transmit directly to * port using tag. ALR learning is performed only when using ALR lookup. - * If the two external ports are bridged and the packet is not STP BPDU, + * If the two external ports are bridged and the frame is unicast, * then use ALR lookup to allow ALR learning on CPU port. * Otherwise transmit directly to port with STP state override. * See also: lan9303_separate_ports() and lan9303.pdf 6.4.10.1 @@ -55,7 +55,7 @@ static int lan9303_xmit_use_arl(struct dsa_port *dp, u8 *dest_addr) { struct lan9303 *chip = dp->ds->priv; - return chip->is_bridged && !ether_addr_equal(dest_addr, eth_stp_addr); + return chip->is_bridged && !is_multicast_ether_addr(dest_addr); } static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev) From patchwork Tue Oct 31 14:48:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egil Hjelmeland X-Patchwork-Id: 832532 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yRDlX4zTHz9sP1 for ; Wed, 1 Nov 2017 01:49:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753535AbdJaOsm (ORCPT ); Tue, 31 Oct 2017 10:48:42 -0400 Received: from aibo.runbox.com ([91.220.196.211]:50736 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753516AbdJaOsk (ORCPT ); Tue, 31 Oct 2017 10:48:40 -0400 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1e9XqH-0006A8-36; Tue, 31 Oct 2017 15:48:37 +0100 Received: from 93.89.113.32.ip.vitnett.no ([93.89.113.32] helo=localhost.localdomain) by mailfront11.runbox.com with esmtpsa (uid:646232 ) (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1e9Xps-0003AG-Cw; Tue, 31 Oct 2017 15:48:12 +0100 From: Egil Hjelmeland To: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Egil Hjelmeland Subject: [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0 Date: Tue, 31 Oct 2017 15:48:01 +0100 Message-Id: <20171031144802.12686-3-privat@egil-hjelmeland.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171031144802.12686-1-privat@egil-hjelmeland.no> References: <20171031144802.12686-1-privat@egil-hjelmeland.no> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org STP BPDUs arriving on user ports must sent to CPU port only, for processing by the SW bridge. Add an ALR entry with STP state override to fix that. Signed-off-by: Egil Hjelmeland Reviewed-by: Andrew Lunn --- drivers/net/dsa/lan9303-core.c | 2 ++ include/linux/dsa/lan9303.h | 2 ++ net/dsa/tag_lan9303.c | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 4c412bd52319..c4afc8f1a66d 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -773,6 +773,7 @@ static int lan9303_separate_ports(struct lan9303 *chip) { int ret; + lan9303_alr_del_port(chip, eth_stp_addr, 0); ret = lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR, LAN9303_SWE_PORT_MIRROR_SNIFFER_PORT0 | LAN9303_SWE_PORT_MIRROR_MIRRORED_PORT1 | @@ -797,6 +798,7 @@ static void lan9303_bridge_ports(struct lan9303 *chip) lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_STATE, chip->swe_port_state); + lan9303_alr_add_port(chip, eth_stp_addr, 0, true); } static int lan9303_handle_reset(struct lan9303 *chip) diff --git a/include/linux/dsa/lan9303.h b/include/linux/dsa/lan9303.h index 05d8d136baab..b2110e69630f 100644 --- a/include/linux/dsa/lan9303.h +++ b/include/linux/dsa/lan9303.h @@ -34,3 +34,5 @@ struct lan9303 { **/ struct lan9303_alr_cache_entry alr_cache[LAN9303_NUM_ALR_RECORDS]; }; + +#define eth_stp_addr eth_reserved_addr_base diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index 537ca991fafe..18f45cd9f625 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -42,7 +42,6 @@ #define LAN9303_TAG_LEN 4 # define LAN9303_TAG_TX_USE_ALR BIT(3) # define LAN9303_TAG_TX_STP_OVERRIDE BIT(4) -#define eth_stp_addr eth_reserved_addr_base /* Decide whether to transmit using ALR lookup, or transmit directly to * port using tag. ALR learning is performed only when using ALR lookup. From patchwork Tue Oct 31 14:48:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egil Hjelmeland X-Patchwork-Id: 832529 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yRDkt5hR3z9sP1 for ; Wed, 1 Nov 2017 01:49:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753513AbdJaOso (ORCPT ); Tue, 31 Oct 2017 10:48:44 -0400 Received: from aibo.runbox.com ([91.220.196.211]:42966 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753515AbdJaOsk (ORCPT ); Tue, 31 Oct 2017 10:48:40 -0400 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1e9XqG-0002pS-Cd; Tue, 31 Oct 2017 15:48:36 +0100 Received: from 93.89.113.32.ip.vitnett.no ([93.89.113.32] helo=localhost.localdomain) by mailfront11.runbox.com with esmtpsa (uid:646232 ) (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1e9Xps-0003AG-Ge; Tue, 31 Oct 2017 15:48:12 +0100 From: Egil Hjelmeland To: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Egil Hjelmeland Subject: [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark Date: Tue, 31 Oct 2017 15:48:02 +0100 Message-Id: <20171031144802.12686-4-privat@egil-hjelmeland.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171031144802.12686-1-privat@egil-hjelmeland.no> References: <20171031144802.12686-1-privat@egil-hjelmeland.no> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The chip flood broadcast and unknown multicast frames. On receive set skb->offload_fwd_mark to prevent the SW from flooding to the same ports. One exception: Because the ALR is set up to forward STP BPDUs only to CPU, the SW bridge should flood STP BPDUs if local STP is not enabled. This is archived by not setting skb->offload_fwd_mark on STP BPDUs. Signed-off-by: Egil Hjelmeland Reviewed-by: Andrew Lunn --- net/dsa/tag_lan9303.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index 18f45cd9f625..e526c8967b98 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -126,6 +126,8 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, skb_pull_rcsum(skb, 2 + 2); memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN), 2 * ETH_ALEN); + skb->offload_fwd_mark = !ether_addr_equal(skb->data - ETH_HLEN, + eth_stp_addr); return skb; }