Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp765276pxb; Tue, 12 Apr 2022 12:52:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmoQYx/RMUE0y5mJXqNvv0pMcrSEscuJPrY/ktitZB4NTaQtQ/wzUQAtrarDnpGYPDqmxf X-Received: by 2002:a63:540c:0:b0:39d:a755:99b3 with SMTP id i12-20020a63540c000000b0039da75599b3mr1946507pgb.594.1649793148378; Tue, 12 Apr 2022 12:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649793148; cv=none; d=google.com; s=arc-20160816; b=XcfbRkI9+qyImC1hAGYA2EYocXZKkCJF56sZueqjerrzf9THEiIgIuSp3PlwOsy0bF ELq9HedTCKA+z6+JZirbC7hSBDanWi6srsRdmAbn4/TosYDt/6grqrA3ijBO6WXmkIKg MRdzd5suxyQJCREiJwDyw2kD+YmZeKhp1KbQCbVzmyfrWj4cLaT3k9C45wXaVqDb6fxR hqgHz37JCAwgTDPFH40dSv6nbkqwP4fvg01ExF6o5XzrJyTDT34kb1f4Dt7Ff1SMhkvb FzHcDJe8hi4fX2/Z+xOvgA9XWcpaApwpJc7BjzdLU6gk5hztdLTBv47dZrmIx2GLW1O5 5OXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=siXsIFTv0iJUejxwOAzvUbsb/T5/As2BWNYw6PcaWME=; b=t73buKHJZIniUdeguMEMV0CqvYE6d7CXY1lfNyJz/5Fm27BTKcXfeBjIAAyXCx6d+8 XaCkirPVfBlpsPHVSEtLN5wy4yVHSv9wXKgCQ6VC6GJQtzUJ+oYjAKY2GNVI9kNGyKWs Nfjl5cxfQTbloEGmL8cl3/WRY5yLTe3NdObJblWBgF6iUN31yzUgCMyAMcLsapImQlkf mOEycCE+96ebT+FIgMJlRVrbCsokRoGMRRHiu9PdOjEsuByRHTBxkqc2Y9ASqSz2YEx1 LLFNpxzYiyiEWwbItkRybQt65gFQQECCyIQVVgTSXRbMNICCtLvP24P8f71vy5NRFzKM VQPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=44OSwrVN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j65-20020a625544000000b005060813b327si1422227pfb.168.2022.04.12.12.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 12:52:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=44OSwrVN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29A836F4A6; Tue, 12 Apr 2022 12:48:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358453AbiDLRkC (ORCPT + 99 others); Tue, 12 Apr 2022 13:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358530AbiDLRj4 (ORCPT ); Tue, 12 Apr 2022 13:39:56 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5645062C9D; Tue, 12 Apr 2022 10:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=siXsIFTv0iJUejxwOAzvUbsb/T5/As2BWNYw6PcaWME=; b=44OSwrVN1YpoBcUi3H++pRcShG mBftYT66PiYNaHZNAVNQfvB4d7oktMmkkxBpA9MMSMmPbQz09LmJSOQyR8KCRV/uTD3kK5i+3XBph Io2iVxxj7eGki2FSrRyMs4cciwahAmW8//0K/PwcZdUbek+rZ1YLwT6xflkwxDn3wU2I=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1neKS4-00FUdg-Kl; Tue, 12 Apr 2022 19:37:16 +0200 Date: Tue, 12 Apr 2022 19:37:16 +0200 From: Andrew Lunn To: Felix Fietkau Cc: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Jiri Pirko , Ido Schimmel , Florian Fainelli , Vladimir Oltean Subject: Re: [PATCH v2 14/14] net: ethernet: mtk_eth_soc: support creating mac address based offload entries Message-ID: References: <20220405195755.10817-1-nbd@nbd.name> <20220405195755.10817-15-nbd@nbd.name> <29cecc87-8689-6a73-a5ef-43eb2b8f33cd@nbd.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29cecc87-8689-6a73-a5ef-43eb2b8f33cd@nbd.name> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > It basically has to keep track of all possible destination ports, their STP > state, all their fdb entries, member VLANs of all ports. It has to quickly > react to changes in any of these. switchdev gives you all of those i think. DSA does not make use of them all, in particularly the fdb entries, because of the low bandwidth management link to the switch. But look at the Mellanox switch, it keeps its hardware fdb entries in sync with the software fdb. And you get every quick access to these, sometimes too quick in that it is holding a spinlock when it calls the switchdev functions, and you need to defer the handling in your driver if you want to use a mutex, perform blocking IO etc. > In order to implement this properly, I would also need to make more changes > to mac80211. Right now, mac80211 drivers do not have access to the > net_device pointer of virtual interfaces. So mac80211 itself would likely > need to implement the switchdev ops and handle some of this. So this again sounds like something which would be shared by IPA, and any other hardware which can accelerate forwarding between WiFi and some other sort of interface. > There are also some other issues where I don't know how this is supposed to > be solved properly: > On MT7622 most of the bridge ports are connected to a MT7531 switch using > DSA. Offloading (lan->wlan bridging or L3/L4 NAT/routing) is not handled by > the switch itself, it is handled by a packet processing engine in the SoC, > which knows how to handle the DSA tags of the MT7531 switch. > > So if I were to handle this through switchdev implemented on the wlan and > ethernet devices, it would technically not be part of the same switch, since > it's a behind a different component with a different driver. What is important here is the user experience. The user is not expected to know there is an accelerate being used. You setup the bridge just as normal, using iproute2. You add routes in the normal way, either by iproute2, or frr can add routes from OSPF, BGP, RIP or whatever, via zebra. I'm not sure anybody has yet accelerated NAT, but the same principle should be used, using iptables in the normal way, and the accelerate is then informed and should accelerate it if possible. switchdev gives you notification of when anything changes. You can have multiple receivers of these notifications, so the packet processor can act on them as well as the DSA switch. > Also, is switchdev able to handle the situation where only parts of the > traffic is offloaded and the rest (e.g. multicast) is handled through the > regular software path? Yes, that is not a problem. I deliberately use the term accelerator. We accelerate what Linux can already do. If the accelerator hardware is not capable of something, Linux still is, so just pass it the frames and it will do the right thing. Multicast is a good example of this, many of the DSA switch drivers don't accelerate it. > In my opinion, handling it through the TC offload has a number of > advantages: > - It's a lot simpler > - It uses the same kind of offloading rules that my software fastpath > already uses > - It allows more fine grained control over which traffic should be offloaded > (src mac -> destination MAC tuple) > > I also plan on extending my software fast path code to support emulating > bridging of WiFi client mode interfaces. This involves doing some MAC > address translation with some IP address tracking. I want that to support > hardware offload as well. > > I really don't think that desire for supporting switchdev based offload > should be a blocker for accepting this code now, especially since my > implementation relies on existing Linux network APIs without inventing any > new ones, and there are valid use cases for using it, even with switchdev > support in place. What we need to avoid is fragmentation of the way we do things. It has been decided that switchdev is how we use accelerators, and the user should not really know anything about the accelerator. No other in kernel network accelerator needs a user space component listening to netlink notifications and programming the accelerator from user space. Do we really want two ways to do this? Andrew