Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp44769pxm; Fri, 25 Feb 2022 03:42:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7spEzhnKKYbSZ1qds7Lj+FwojAa8pdYYTn+MgTK6V4oFK/HbpzuFN+4HVy3Si8SIIv9aR X-Received: by 2002:a17:906:5f96:b0:6bb:3024:9444 with SMTP id a22-20020a1709065f9600b006bb30249444mr6229947eju.298.1645789340999; Fri, 25 Feb 2022 03:42:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645789340; cv=none; d=google.com; s=arc-20160816; b=PZtsBtYOnIDXkJ+No6GPcAQeyQJxtCLEWEi+adk+HbBLrv9tpZi3mLVchXOUbXMDCf g3XERe8+mke0Xx0p+ScqlUhKziNxs+cY1UKBngRzxlv0vMLZUHzm3yYR266PVe2UyNDF FYvBalOAv8iMlHWXXNTsBl7rY3Kqj4qfE7udV/P7qvPlT9E15o0X6BgNQ3S4HItYihbh Zr9RwFDk1FxhJz1X2diBTbT/8YqL1RocoWa/1Y+B7TB4RWtZtel78c52GgN4jVznSJqW YqE9qLEeHYMuzr47OhC5QkMjaQNWOSzkOFyA4+1FPijtaCVlnYEV5/foLM1vb23yR1Pi lBpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M6t65cwOUuBGDbHJK0sMurL9y2EPfQSv/Exhw8Fx+nA=; b=Lrs9hLVr/TgIzBlHml7Xdfr+KVwWkFMRoThL/8K3ETdG8WGWPNCq98RjPyJwFXSjHj jAsqHv5N8r++f1RiwmgiGbdQDTc0PK3JiqFYuP2Rv/te4QriuZ7BzHGmR5DCfhZBKv9g D1//Ayzylm655G5DPAFT1WxLZR9n7IxdW/1Ej8doEDFj486E5xGrGL4epP+E9gnpiUMp crTO9CaqUYHwjFFlQ3O+HpKKRY/w8H67mtkMyPDnQyaba/Q6pUtZm32IUGpiHNihRFPN JnoC48OtF1gXjPvSAUQRwPHrBVp5CZKmH/r/Z/J/ISBE15MMjlBWLH/HDhe5TzXOW7jf umCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=hej7Bda+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a05640250cc00b00410cec4b895si2399771edb.192.2022.02.25.03.41.55; Fri, 25 Feb 2022 03:42:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=hej7Bda+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234280AbiBYKTJ (ORCPT + 99 others); Fri, 25 Feb 2022 05:19:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239386AbiBYKS5 (ORCPT ); Fri, 25 Feb 2022 05:18:57 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9212119F444; Fri, 25 Feb 2022 02:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=M6t65cwOUuBGDbHJK0sMurL9y2EPfQSv/Exhw8Fx+nA=; b=hej7Bda+3BCyQ5s97vFrY++P5n 70iuaMdcped/cDKvjuZck3P/NjieODF7pDy/Et86ThFC3tva/IeM8fmaG4ZxHa84HqY0bAGBAhwTy pnGIvmXGS2OFhEJptHBqiDQWsw1v8GDlQ+I0EjoOBIboLGcPSAQJArUqftrY7r3ewNLI=; Received: from p200300daa7204f00f847964d075b2b3d.dip0.t-ipconnect.de ([2003:da:a720:4f00:f847:964d:75b:2b3d] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nNXg1-0007J1-VK; Fri, 25 Feb 2022 11:18:18 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger Cc: David Bentham , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/11] net: ethernet: mtk_eth_soc: add ipv6 flow offload support Date: Fri, 25 Feb 2022 11:18:05 +0100 Message-Id: <20220225101811.72103-7-nbd@nbd.name> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220225101811.72103-1-nbd@nbd.name> References: <20220225101811.72103-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: David Bentham Add the missing IPv6 flow offloading support for routing only. Hardware flow offloading is done by the packet processing engine (PPE) of the Ethernet MAC and as it doesn't support mangling of IPv6 packets, IPv6 NAT cannot be supported. Signed-off-by: David Bentham Signed-off-by: Felix Fietkau --- .../net/ethernet/mediatek/mtk_ppe_offload.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c index bcf342bb9051..0113cddcebf4 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c @@ -6,6 +6,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; @@ -65,6 +71,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) { @@ -296,6 +310,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; } @@ -331,6 +348,17 @@ 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; -- 2.32.0 (Apple Git-132)