Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1023239pxv; Thu, 15 Jul 2021 23:10:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTe15JPVAPGIXFZsJx3Iq9oMeH0lm9sNWCQhPhL5KQ28mdqJ5Aey0/PbjVFnaaDUk4kuOj X-Received: by 2002:a05:6402:1a38:: with SMTP id be24mr12165339edb.58.1626415810904; Thu, 15 Jul 2021 23:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626415810; cv=none; d=google.com; s=arc-20160816; b=AaDkDPPIWihzlY9ghmdVqMft4pvA7yH0SxHBpbe3A/FGKBF+k5cySfjogvQZoHhFFG mAN0nETv7q+X7IvJIFV9YHLCjYC/C5rHcqyiIyc771cjuAg/LXr1hu8IR/4tODHsBssk QJARmYjOqI/zP8JEtRXzaxkpY1lpyv1S7VrRTAljeamqhsQ20a/vuJ176XO46dLmLcgE NYFfLGq7GYWcTvoQbIoGz5u0P9PB7l2R7MHmxtcgv8ah+fDYXVPA7BN+Q0otX9dtxpXp Y/teuBv0UuiaQTaZVaaDv355f6+712SZaqvvuE1+G/9K20+WoC2NbK6ljynFU6AuMdhH mCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=rHxVMuUJUfdCqmA6JXmZIZSNi3VNgFpNTCKRuswm7zg=; b=q/bvL41E/wTOhjILpU+kY7VQA+28En1YkIBp+93TE45kWwe+ctfzd8exgbVec8kYX5 cQQrB1R7VzCzCJeydqJ/T21swq/hwe2xN2NQUE6kJPRvvBfkIU+EVhNQPIl2qv0azZx5 vqhD8c2sObspiGFt9wRzBxBtodLIyF5UqtjTbSBlIZuPrIsnNslWKQnBSX8WLnlBdEEm rezjP2rZhSE5G4dKZaSQcyO+92SLWsBjajfDMlOyVlI2NmgOPQFTbNeKjrEukUZ4GWbl 1lcHh6kZiT9b+wRJfk598+pTKrhBjpaW6czdFV42w6ghIyLDxaeBgWdAyTlkr/GuPFpL qR3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=MqAH+mJw; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si10263400edv.16.2021.07.15.23.09.41; Thu, 15 Jul 2021 23:10:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=MqAH+mJw; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233967AbhGPGMf (ORCPT + 99 others); Fri, 16 Jul 2021 02:12:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbhGPGMe (ORCPT ); Fri, 16 Jul 2021 02:12:34 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B11C06175F; Thu, 15 Jul 2021 23:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rHxVMuUJUfdCqmA6JXmZIZSNi3VNgFpNTCKRuswm7zg=; b=MqAH+mJwVPa3XWB+8MD5U7KT/x bQupkTjZNC5/U5QmYulpT2fnXFnXgrL32NGzED+Z/FsGC2H0WTFKpUOP75feP2xrNfylrwK66ZToc QhMrOjuu1WgxSdHu4Ftx3utYMzPbmz3iW5NFmQNPI4Qa+J5zzBwTmOl2n0BC3991g2DY=; Received: from p54ae93f7.dip0.t-ipconnect.de ([84.174.147.247] helo=nf.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1m4H2W-0000ll-J9; Fri, 16 Jul 2021 08:09:36 +0200 Subject: Re: [RFC 3/7] net: ethernet: mtk_eth_soc: implement flow offloading to WED devices To: Pablo Neira Ayuso Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, ryder.lee@mediatek.com References: <20210713160745.59707-1-nbd@nbd.name> <20210713160745.59707-4-nbd@nbd.name> <20210713185641.GB26070@salvia> <20210715213626.GA19271@salvia> From: Felix Fietkau Message-ID: Date: Fri, 16 Jul 2021 08:09:36 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210715213626.GA19271@salvia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2021-07-15 23:36, Pablo Neira Ayuso wrote: > On Wed, Jul 14, 2021 at 10:26:08AM +0200, Felix Fietkau wrote: >> On 2021-07-13 20:56, Pablo Neira Ayuso wrote: > [...] >> >> --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c >> >> +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c >> >> @@ -10,6 +10,7 @@ >> >> #include >> >> #include >> >> #include "mtk_eth_soc.h" >> >> +#include "mtk_wed.h" >> >> >> >> struct mtk_flow_data { >> >> struct ethhdr eth; >> >> @@ -39,6 +40,7 @@ struct mtk_flow_entry { >> >> struct rhash_head node; >> >> unsigned long cookie; >> >> u16 hash; >> >> + s8 wed_index; >> >> }; >> >> >> >> static const struct rhashtable_params mtk_flow_ht_params = { >> >> @@ -127,35 +129,38 @@ mtk_flow_mangle_ipv4(const struct flow_action_entry *act, >> >> } >> >> >> >> static int >> >> -mtk_flow_get_dsa_port(struct net_device **dev) >> >> +mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe, >> >> + struct net_device *dev, const u8 *dest_mac, >> >> + int *wed_index) >> >> { >> >> -#if IS_ENABLED(CONFIG_NET_DSA) >> >> - struct dsa_port *dp; >> >> - >> >> - dp = dsa_port_from_netdev(*dev); >> >> - if (IS_ERR(dp)) >> >> - return -ENODEV; >> >> - >> >> - if (dp->cpu_dp->tag_ops->proto != DSA_TAG_PROTO_MTK) >> >> - return -ENODEV; >> >> + struct net_device_path_ctx ctx = { >> >> + .dev = dev, >> >> + .daddr = dest_mac, >> >> + }; >> >> + struct net_device_path path = {}; >> >> + int pse_port; >> >> >> >> - *dev = dp->cpu_dp->master; >> >> + if (!dev->netdev_ops->ndo_fill_forward_path || >> >> + dev->netdev_ops->ndo_fill_forward_path(&ctx, &path) < 0) >> >> + path.type = DEV_PATH_ETHERNET; >> > >> > Maybe expose this through flow offload API so there is no need to call >> > ndo_fill_forward_path again from the driver? >> >> Can you give me a pseudo-code example? I'm not sure how you want it to >> be exposed through the flow offload API. > > in a few steps: > > 1) Extend nft_dev_path_info() to deal with DEV_PATH_WDMA, it will > just actually fetch a pointer to structure that is allocated > by the driver. > > - Update the net_device_path structure with this layout: > > struct flow_action_wdma { > enum wdma_type type; // MTK_WDMA goes here > union { > struct { > ...; > } mtk; > }; > } wdma; > > Add: > struct flow_action_wdma *wdma; > > to net_device_path. > > 2) Pass on this pointer to structure to the nf_flow_route > wheelbarrow. > > 3) Store this information in the struct flow_offload_tuple, > in a new struct flow_offload_hw *field to store all hardware > offload specific information (not needed by software path). There > is already hw_outdev that can be placed there. > > 4) Add a FLOW_ACTION_WDMA action to the flow offload API to > pass on the flow_action_wdma structure. I think it should probably be called FLOW_ACTION_MTK_WDMA (and be mediatek specific), or we should pick a more generic name for it. > It's a bit of work the first time to accomodate the requirements of > new API, but then all drivers will benefit from this. > > It's also a bit of layering, but with more drivers in the tree, this > API can be simplified incrementally. > > I can take a stab at it and send you a patch. Thanks. If we do this for WDMA, shouldn't we also do it for DSA to keep things consistent? - Felix