linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, John Crispin <john@phrozen.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 14/14] net: ethernet: mtk_eth_soc: support creating mac address based offload entries
Date: Tue, 12 Apr 2022 09:13:54 +0200	[thread overview]
Message-ID: <ece29b0d-bbbe-7c03-a6b4-60e44453ca31@nbd.name> (raw)
In-Reply-To: <YlQmf7qGAnq/3nW0@lunn.ch>


On 11.04.22 15:00, Andrew Lunn wrote:
> On Thu, Apr 07, 2022 at 08:21:43PM +0200, Felix Fietkau wrote:
>> 
>> On 07.04.22 20:10, Andrew Lunn wrote:
>> > On Tue, Apr 05, 2022 at 09:57:55PM +0200, Felix Fietkau wrote:
>> > > This will be used to implement a limited form of bridge offloading.
>> > > Since the hardware does not support flow table entries with just source
>> > > and destination MAC address, the driver has to emulate it.
>> > > 
>> > > The hardware automatically creates entries entries for incoming flows, even
>> > > when they are bridged instead of routed, and reports when packets for these
>> > > flows have reached the minimum PPS rate for offloading.
>> > > 
>> > > After this happens, we look up the L2 flow offload entry based on the MAC
>> > > header and fill in the output routing information in the flow table.
>> > > The dynamically created per-flow entries are automatically removed when
>> > > either the hardware flowtable entry expires, is replaced, or if the offload
>> > > rule they belong to is removed
>> > 
>> > > +
>> > > +	if (found)
>> > > +		goto out;
>> > > +
>> > > +	eh = eth_hdr(skb);
>> > > +	ether_addr_copy(key.dest_mac, eh->h_dest);
>> > > +	ether_addr_copy(key.src_mac, eh->h_source);
>> > > +	tag = skb->data - 2;
>> > > +	key.vlan = 0;
>> > > +	switch (skb->protocol) {
>> > > +#if IS_ENABLED(CONFIG_NET_DSA)
>> > > +	case htons(ETH_P_XDSA):
>> > > +		if (!netdev_uses_dsa(skb->dev) ||
>> > > +		    skb->dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK)
>> > > +			goto out;
>> > > +
>> > > +		tag += 4;
>> > > +		if (get_unaligned_be16(tag) != ETH_P_8021Q)
>> > > +			break;
>> > > +
>> > > +		fallthrough;
>> > > +#endif
>> > > +	case htons(ETH_P_8021Q):
>> > > +		key.vlan = get_unaligned_be16(tag + 2) & VLAN_VID_MASK;
>> > > +		break;
>> > > +	default:
>> > > +		break;
>> > > +	}
>> > 
>> > I'm trying to understand the architecture here.
>> > 
>> > We have an Ethernet interface and a Wireless interface. The slow path
>> > is that frames ingress from one of these interfaces, Linux decides
>> > what to do with them, either L2 or L3, and they then egress probably
>> > out the other interface.
>> > 
>> > The hardware will look at the frames and try to spot flows? It will
>> > then report any it finds. You can then add an offload, telling it for
>> > a flow it needs to perform L2 or L3 processing, and egress out a
>> > specific port? Linux then no longer sees the frame, the hardware
>> > handles it, until the flow times out?
>> Yes, the hw handles it until either the flow times out, or the corresponding
>> offload entry is removed.
>> 
>> For OpenWrt I also wrote a daemon that uses tc classifier BPF to accelerate
>> the software bridge and create hardware offload entries as well via hardware
>> TC flower rules: https://github.com/nbd168/bridger
>> It works in combination with these changes.
> 
> What about the bridge? In Linux, it is the software bridge which
> controls all this at L2, and it should be offloading the flows, via
> switchdev. The egress port you derive here is from the software bridge
> FDB?
My code uses netlink to fetch and monitor the bridge configuration, 
including fdb, port state, vlans, etc. and it uses that for the offload 
path - no extra configuration needed.

>> > So i'm wondering what is going on here. So is this a frame which has
>> > ingressed, either from the WiFi, or another switch port, gone to the
>> > software bridge, bridges to a DSA slave interface, the DSA tagger has
>> > added a tag and now it is in the master interface? Can you accelerate
>> > such frames? What is adding the DSA tag on the fast path? And in the
>> > opposite direction, frames which egress the switch which have a DSA
>> > tag and are heading to the WiFi, what is removing the tag? Does the
>> > accelerator also understand the tag and know what to do with it?WiFi ->
>> > Ethernet is not supported by MT7622, but will be added for newer
> 
>> SoCs like MT7986. The PPE supports both parsing and inserting MT7530
>> compatible DSA tags. For Ethernet->WiFi flows, the PPE will also add
>> required metadata that is parsed by the MT7915 WiFi Firmware in order to
>> figure out what vif/station the packets were meant for.
> 
> O.K. What about IGMP and multicast? Does the accelerate match on IGMP
> and forwards it to the CPU, rather than follow the flow rules? Can you
> set multiple egress destinations for multicast so that it can go both
> to the switch and the host, when the host has a local interest in the
> traffic?
IGMP/multicast isn't handled yet at the moment. I still need to do some 
research on what can be offloaded and how. The offload only handles 
unicast and everything else is going through the CPU.

- Felix

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-04-12  7:15 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 19:57 [PATCH v2 00/14] MediaTek SoC flow offload improvements + wireless support Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 01/14] dt-bindings: net: mediatek: add optional properties for the SoC ethernet core Felix Fietkau
2022-04-07 17:20   ` Rob Herring
2022-04-08  9:34     ` Lorenzo Bianconi
2022-04-05 19:57 ` [PATCH v2 02/14] net: ethernet: mtk_eth_soc: add support for coherent DMA Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 03/14] arm64: dts: mediatek: mt7622: " Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 04/14] dt-bindings: arm: mediatek: document WED binding for MT7622 Felix Fietkau
2022-04-06  8:09   ` Krzysztof Kozlowski
2022-04-06  8:18     ` Felix Fietkau
2022-04-06  8:29       ` Arnd Bergmann
2022-04-06  8:32         ` Felix Fietkau
2022-04-06  8:57           ` Krzysztof Kozlowski
2022-04-07 16:59             ` Felix Fietkau
2022-04-07 15:50       ` Andrew Lunn
2022-04-07 16:10         ` Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 05/14] dt-bindings: arm: mediatek: document the pcie mirror node on MT7622 Felix Fietkau
2022-04-06  8:20   ` Krzysztof Kozlowski
2022-04-06 11:01     ` Felix Fietkau
2022-04-07 17:16       ` Rob Herring
2022-04-07 17:29         ` Felix Fietkau
2022-04-07 17:19   ` Rob Herring
2022-04-08  9:03     ` Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 06/14] net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED) Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 07/14] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 08/14] arm64: dts: mediatek: mt7622: introduce nodes for Wireless Ethernet Dispatch Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 09/14] net: ethernet: mtk_eth_soc: add ipv6 flow offload support Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 10/14] net: ethernet: mtk_eth_soc: support TC_SETUP_BLOCK for PPE offload Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 11/14] net: ethernet: mtk_eth_soc: allocate struct mtk_ppe separately Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 12/14] net: ethernet: mtk_eth_soc: rework hardware flow table management Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 13/14] net: ethernet: mtk_eth_soc: remove bridge flow offload type entry support Felix Fietkau
2022-04-05 19:57 ` [PATCH v2 14/14] net: ethernet: mtk_eth_soc: support creating mac address based offload entries Felix Fietkau
2022-04-07 18:10   ` Andrew Lunn
2022-04-07 18:21     ` Felix Fietkau
2022-04-11 13:00       ` Andrew Lunn
2022-04-12  7:13         ` Felix Fietkau [this message]
2022-04-12 13:07           ` Andrew Lunn
2022-04-12 13:49             ` Felix Fietkau
2022-04-12 14:21               ` Andrew Lunn
2022-04-12 15:51                 ` Felix Fietkau
2022-04-12 17:37                   ` Andrew Lunn
2022-04-12 17:51                     ` Felix Fietkau
2022-04-06 13:30 ` [PATCH v2 00/14] MediaTek SoC flow offload improvements + wireless support patchwork-bot+netdevbpf
2022-04-07 15:57   ` Andrew Lunn
2022-04-07 17:00     ` Felix Fietkau
2022-04-07 17:28       ` Andrew Lunn
2022-04-07 17:34         ` Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ece29b0d-bbbe-7c03-a6b4-60e44453ca31@nbd.name \
    --to=nbd@nbd.name \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).