From patchwork Mon Mar 22 11:21:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 12154585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A51C1C433C1 for ; Mon, 22 Mar 2021 11:22:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D4F16198E for ; Mon, 22 Mar 2021 11:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D4F16198E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xzcssd37LVfdydJYZx4LShcplzHkhcVRmpkSi3FrjVQ=; b=lyLz7j+Xu2gDaNB1fNykC+i/j Ga7WR0mlim0r9KjVfIVIC2GHsiaNaQ6koyvFL09RO+mJtLa5HOdN+uwUf8z4cy6/340qGGD3Ix8/b mTonCWWFxT4J4HGPoGd+TUjM/EyAGMzcbK9/GRgLp2AJDKACwpLzZ2caL8GPyIQPPHl8GIhCz88+O FRcL6UCqg3FU4bs70xPG6ofcTMNZcXqjiQ6N1BcyNBGb8HSwBW0xYEjzVJsPQMpjsqPjGPQjC5bl5 i4NBO6DzlwAgC+EZj6/4yHWEhZU0OdQ5eqiZ2x0bXvGgrYe/A8QmIcS38WVTOI+ZFP+Fhvpx/cET4 1pM7aJ0WQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOIdJ-00BQm4-Ee; Mon, 22 Mar 2021 11:22:05 +0000 Received: from mxout3.routing.net ([2a03:2900:1:a::8]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOIcw-00BQgE-Q6; Mon, 22 Mar 2021 11:21:45 +0000 Received: from mxbox3.masterlogin.de (unknown [192.168.10.78]) by mxout3.routing.net (Postfix) with ESMTP id BB1DD604CD; Mon, 22 Mar 2021 11:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1616412100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TuB5JOSUV2Mjm5gg71dyaHF7i8Fm6qxQ4YPT46nvR3Q=; b=loqjsueuK9GN1cOYY9FEVio5w/ZHhVzTwHZkU6dxdX6V1LcohctljMTCiyBiz5W6g9tRFs 8iSAu24hIENojEdunvVN/cGBI14I0MT8fu8/CJ30uASCwvRxUkHz+vWuQ/h4M1GohzVWNF iwIDnHeCnHwpP9Z2/FfN4dUZnaKlcPo= Received: from localhost.localdomain (unknown [80.245.73.88]) by mxbox3.masterlogin.de (Postfix) with ESMTPSA id 00FC236009F; Mon, 22 Mar 2021 11:21:39 +0000 (UTC) From: Frank Wunderlich To: linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] net: mediatek: add flow offload for mt7623 Date: Mon, 22 Mar 2021 12:21:16 +0100 Message-Id: <20210322112117.16162-2-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210322112117.16162-1-linux@fw-web.de> References: <20210322112117.16162-1-linux@fw-web.de> MIME-Version: 1.0 X-Mail-ID: ef0cd896-2961-4f04-8e14-c2c83bb8fd6e X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210322_112143_116890_AEFEAEE8 X-CRM114-Status: UNSURE ( 9.13 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Frank Wunderlich mt7623 uses offload version 2 too tested on Bananapi-R2 Signed-off-by: Frank Wunderlich --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 0396f0db855f..810def064f11 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3202,6 +3202,7 @@ static const struct mtk_soc_data mt7623_data = { .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, + .offload_version = 2, }; static const struct mtk_soc_data mt7629_data = { From patchwork Mon Mar 22 11:21:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 12154589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50C4CC433DB for ; Mon, 22 Mar 2021 11:22:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCEDD6191A for ; Mon, 22 Mar 2021 11:22:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCEDD6191A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v4ex1ez+nubkojJ/JQS/U2xMj+iUms3Fj0vFQJ8wgfg=; b=S/IRgRgUcsCn+8nc/O7w0XbU7 Cv2/vunD1LaoHXhub7dsPW2mnLgEWzgvGl6Lwk6WGnbGG7/AZV+9xYsJ1XgizG4j3/6wb8esQeBgy ulSGHTrwTQb1ckrxzPc4L1PnJwtUkM8aGzEYLFwhNupNU6jnO8dWiqzcVlMZWNaQ4VkKD4dZ3rzF3 Zi8KdxgmJdSU4tmQl4Um7kOa8m/8kchpi4Y58FtBFFyFxYeB/xp1u5ioDYQ0yuCT6ZQTOBvAvXYHQ T9K2+O8e/FlKGS+1rBPYSez5vu17Ordjjenoh6fCGrRV+vyETC2oLJOepLmV2NYwIjbRoEIuJyZLR /bfq9wm9g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOIdY-00BQrm-7i; Mon, 22 Mar 2021 11:22:20 +0000 Received: from mxout4.routing.net ([2a03:2900:1:a::9]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOIcx-00BQgF-0B; Mon, 22 Mar 2021 11:21:47 +0000 Received: from mxbox3.masterlogin.de (unknown [192.168.10.78]) by mxout4.routing.net (Postfix) with ESMTP id 692E51007B4; Mon, 22 Mar 2021 11:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1616412101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XYeVx8d4LjQCrMjqtdwToyONIZtgo42NmTTPNbi924c=; b=ug9Ij2wqVs5oPGAjn8m8HMPznXHwXLmTNqJMlob3uRaB5fQPY/2E12aV+pZc65+yxC+9RN WubOvEBS1NhliP5ZGYApPt/8Jl9tPaMzERFP8zbW/sEE+W6xkM8Fv3SKrKtqSpskAZTkmf aZAiDp/JC2BNK0qNoJQZnAU1d7JKV6c= Received: from localhost.localdomain (unknown [80.245.73.88]) by mxbox3.masterlogin.de (Postfix) with ESMTPSA id B761436010D; Mon, 22 Mar 2021 11:21:40 +0000 (UTC) From: Frank Wunderlich To: linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] [RFC] net: ethernet: mtk_eth_soc: add ipv6 flow offload support Date: Mon, 22 Mar 2021 12:21:17 +0100 Message-Id: <20210322112117.16162-3-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210322112117.16162-1-linux@fw-web.de> References: <20210322112117.16162-1-linux@fw-web.de> MIME-Version: 1.0 X-Mail-ID: ce223c4d-bd77-4263-a479-9b2339e766b7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210322_112143_263154_94C2F121 X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Frank Wunderlich adding ipv6 hardware offload support patch by user graphine (https://github.com/graphine27/) http://forum.banana-pi.org/u/graphine/summary Signed-off-by: Frank Wunderlich --- .../net/ethernet/mediatek/mtk_ppe_offload.c | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c index d0c46786571f..29cf0eb25a22 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,11 @@ struct mtk_flow_data { __be32 src_addr; __be32 dst_addr; } v4; + + struct { + struct in6_addr src_addr; + struct in6_addr dst_addr; + } v6; }; __be16 src_port; @@ -64,6 +70,14 @@ mtk_flow_set_ipv4_addr(struct mtk_foe_entry *foe, struct mtk_flow_data *data, data->v4.dst_addr, data->dst_port); } +static int +mtk_flow_set_ipv6_addr(struct mtk_foe_entry *foe, struct mtk_flow_data *data) +{ + return mtk_foe_entry_set_ipv6_tuple(foe, + data->v6.src_addr.s6_addr32, data->src_port, + data->v6.dst_addr.s6_addr32, data->dst_port); +} + static void mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth) { @@ -127,6 +141,29 @@ mtk_flow_mangle_ipv4(const struct flow_action_entry *act, return 0; } +static int +mtk_flow_mangle_ipv6(const struct flow_action_entry *act, + struct mtk_flow_data *data) +{ + __be32 *dest; + size_t offset_of_ip6_daddr = offsetof(struct ipv6hdr, daddr); + size_t offset_of_ip6_saddr = offsetof(struct ipv6hdr, saddr); + u32 idx; + + if (act->mangle.offset >= offset_of_ip6_daddr && act->mangle.offset < offset_of_ip6_daddr) { + idx = (act->mangle.offset - offset_of_ip6_saddr) / 4; + dest = &data->v6.src_addr.s6_addr32[idx]; + } else if (act->mangle.offset >= offset_of_ip6_daddr && + act->mangle.offset < offset_of_ip6_daddr + 16) { + idx = (act->mangle.offset - offset_of_ip6_daddr) / 4; + dest = &data->v6.dst_addr.s6_addr32[idx]; + } + + memcpy(dest, &act->mangle.val, sizeof(u32)); + + return 0; +} + static int mtk_flow_get_dsa_port(struct net_device **dev) { @@ -249,6 +286,9 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f) case FLOW_DISSECTOR_KEY_IPV4_ADDRS: offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT; break; + case FLOW_DISSECTOR_KEY_IPV6_ADDRS: + offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T; + break; default: return -EOPNOTSUPP; } @@ -284,6 +324,18 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f) mtk_flow_set_ipv4_addr(&foe, &data, false); } + + if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) { + struct flow_match_ipv6_addrs addrs; + + flow_rule_match_ipv6_addrs(rule, &addrs); + + data.v6.src_addr = addrs.key->src; + data.v6.dst_addr = addrs.key->dst; + + mtk_flow_set_ipv6_addr(&foe, &data); + } + flow_action_for_each(i, act, &rule->action) { if (act->id != FLOW_ACTION_MANGLE) continue; @@ -296,6 +348,9 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f) case FLOW_ACT_MANGLE_HDR_TYPE_IP4: err = mtk_flow_mangle_ipv4(act, &data); break; + case FLOW_ACT_MANGLE_HDR_TYPE_IP6: + err = mtk_flow_mangle_ipv6(act, &data); + break; case FLOW_ACT_MANGLE_HDR_TYPE_ETH: /* handled earlier */ break;