lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e010ec84-9d50-31ca-fdf2-af73dad5f718@nbd.name>
Date:   Thu, 10 Nov 2022 19:42:56 +0100
From:   Felix Fietkau <nbd@....name>
To:     Vladimir Oltean <olteanv@...il.com>
Cc:     netdev@...r.kernel.org, John Crispin <john@...ozen.org>,
        Sean Wang <sean.wang@...iatek.com>,
        Mark Lee <Mark-MC.Lee@...iatek.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Russell King <linux@...linux.org.uk>,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 09/12] net: ethernet: mtk_eth_soc: fix VLAN rx
 hardware acceleration

On 10.11.22 16:22, Vladimir Oltean wrote:
> On Wed, Nov 09, 2022 at 05:34:23PM +0100, Felix Fietkau wrote:
>> - enable VLAN untagging for PDMA rx
>> - make it possible to disable the feature via ethtool
>> - pass VLAN tag to the DSA driver
>> - untag special tag on PDMA only if no non-DSA devices are in use
>> - disable special tag untagging on 7986 for now, since it's not working yet
> 
> Each of these bullet points should be its own patch, really.
> "Fix VLAN rx hardware acceleration" isn't doing much to describe them
> and their motivation.
I think some minor things could be split off, but doing one patch per 
bullet point definitely does not make sense.

>>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 99 ++++++++++++++++-----
>>  drivers/net/ethernet/mediatek/mtk_eth_soc.h |  8 ++
>>  2 files changed, 84 insertions(+), 23 deletions(-)
>> 
>> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> index 92bdd69eed2e..ffaa9fe32b14 100644
>> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> @@ -23,6 +23,7 @@
>>  #include <linux/jhash.h>
>>  #include <linux/bitfield.h>
>>  #include <net/dsa.h>
>> +#include <net/dst_metadata.h>
>>  
>>  #include "mtk_eth_soc.h"
>>  #include "mtk_wed.h"
>> @@ -2008,23 +2009,27 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
>>  		if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
>>  			mtk_ppe_check_skb(eth->ppe[0], skb, hash);
>>  
>> -		if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) {
>> -			if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
>> -				if (trxd.rxd3 & RX_DMA_VTAG_V2)
>> -					__vlan_hwaccel_put_tag(skb,
>> -						htons(RX_DMA_VPID(trxd.rxd4)),
>> -						RX_DMA_VID(trxd.rxd4));
>> -			} else if (trxd.rxd2 & RX_DMA_VTAG) {
>> -				__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
>> -						       RX_DMA_VID(trxd.rxd3));
>> -			}
>> +		if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
>> +			if (trxd.rxd3 & RX_DMA_VTAG_V2)
>> +				__vlan_hwaccel_put_tag(skb,
>> +					htons(RX_DMA_VPID(trxd.rxd4)),
>> +					RX_DMA_VID(trxd.rxd4));
>> +		} else if (trxd.rxd2 & RX_DMA_VTAG) {
>> +			__vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)),
>> +					       RX_DMA_VID(trxd.rxd3));
>> +		}
>> +
>> +		/* When using VLAN untagging in combination with DSA, the
>> +		 * hardware treats the MTK special tag as a VLAN and untags it.
>> +		 */
>> +		if (skb_vlan_tag_present(skb) && netdev_uses_dsa(netdev)) {
>> +			unsigned int port = ntohs(skb->vlan_proto) & GENMASK(2, 0);
>> +
>> +			if (port < ARRAY_SIZE(eth->dsa_meta) &&
>> +			    eth->dsa_meta[port])
>> +				skb_dst_set_noref(skb, &eth->dsa_meta[port]->dst);
> 
> Why _noref?
In order to avoid the cost of unnecessary refcounting. The metadata dst 
is only held until dsa_switch_rcv processes it, after which it is 
removed. The driver only frees it after all its netdevs have been 
unregistered.

- Felix

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ