From patchwork Tue Mar 16 18:13:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12143455 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,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 24AF0C433DB for ; Tue, 16 Mar 2021 18:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7BA365108 for ; Tue, 16 Mar 2021 18:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239933AbhCPSNs (ORCPT ); Tue, 16 Mar 2021 14:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239907AbhCPSNZ (ORCPT ); Tue, 16 Mar 2021 14:13:25 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FD03C061756 for ; Tue, 16 Mar 2021 11:13:25 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id p8so73719482ejb.10 for ; Tue, 16 Mar 2021 11:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lv/KQKri9I42MI3Uya+n/ItNZ1IT5XUkk3FfUCTEpt8=; b=bLC7jaFz6o0o6UJ91KHFIgpXVVura5qk7t5JJc42mOVbt7sgmbyVRjRrGr6wPllJoE 8lidjlq1cAkHV8WilzxYFmYbXnmt0jXxjkoHlahyKWp1sAqtZk97moxIjyi+JRmiz6vI fMQ0ZlHV3idomfRZyzXNevHfr95HuWUCgraRzBK0LXvkxjNES3pJsCbKEyQXZeGpaj6r eVX4FeXb8BSG46gsly/JfyLLN64H9LniVgq6XHsZXxPFA1e/UqocV0kBlZcLdkSQVFsS mFFhqthLfems4H4kl/jgH+rtaHLdd1JCaaffyKNrWunDXK7QiQ1QegR1xUttJXzGsbUD 2ohg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lv/KQKri9I42MI3Uya+n/ItNZ1IT5XUkk3FfUCTEpt8=; b=Uef5Ory6vUmpYN7WZN0QNnj5BUZ65PapSipaD3aY7HqHzm8qwmyXRQMfU2VQArw+uW vT5bue7ZnrHeu8wi0bSbnNYf+xHj59bnhU5jCMgyNdXv6e4E+pRmedpbeytj5bsNo/d/ aahIxza8m5f2J3ZJTSb/d6JWvjs4Sqws0Xbxrqnftsckli/QFv04TxIg7k/HkrZVZ0jz CKId0dp02zRewDyNNcJCeUUKrIFkwSE2AXMsb+LqKijJVSmQbsG/8IOvvYtjjz6AzQ4B SvtVlAE27T4wGRe1GB/IJaETIJ6im7uJJ7y0yVOUm5+JmOrlE9/T3hdUkm6qUhvzbXNX RXXQ== X-Gm-Message-State: AOAM533Saou9aNUbh0Utjjvly4DsmBd7/03EDfuhpbE+B82CYucnSoAn bpcy39muNCdKp1Jg8xclhJtRDA== X-Google-Smtp-Source: ABdhPJxElDa/j782W4jVEFb8Box/0EglW8RbI7g7b7FD1nKhyt4HgS9L6ZBe5QMz38OgHWGJnSu5AA== X-Received: by 2002:a17:906:c405:: with SMTP id u5mr31207500ejz.341.1615918403592; Tue, 16 Mar 2021 11:13:23 -0700 (PDT) Received: from madeliefje.horms.nl ([2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a]) by smtp.gmail.com with ESMTPSA id e26sm11537778edj.29.2021.03.16.11.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 11:13:22 -0700 (PDT) From: Simon Horman To: David Miller Cc: Jakub Kicinski , Louis Peens , netdev@vger.kernel.org, oss-drivers@netronome.com, Simon Horman Subject: [PATCH net 1/3] nfp: flower: fix unsupported pre_tunnel flows Date: Tue, 16 Mar 2021 19:13:08 +0100 Message-Id: <20210316181310.12199-2-simon.horman@netronome.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210316181310.12199-1-simon.horman@netronome.com> References: <20210316181310.12199-1-simon.horman@netronome.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens There are some pre_tunnel flows combinations which are incorrectly being offloaded without proper support, fix these. - Matching on MPLS is not supported for pre_tun. - Match on IPv4/IPv6 layer must be present. - Destination MAC address must match pre_tun.dev MAC Fixes: 120ffd84a9ec ("nfp: flower: verify pre-tunnel rules") Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/offload.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 1c59aff2163c..d72225d64a75 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1142,6 +1142,12 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app, return -EOPNOTSUPP; } + if (!(key_layer & NFP_FLOWER_LAYER_IPV4) && + !(key_layer & NFP_FLOWER_LAYER_IPV6)) { + NL_SET_ERR_MSG_MOD(extack, "unsupported pre-tunnel rule: match on ipv4/ipv6 eth_type must be present"); + return -EOPNOTSUPP; + } + /* Skip fields known to exist. */ mask += sizeof(struct nfp_flower_meta_tci); ext += sizeof(struct nfp_flower_meta_tci); @@ -1152,6 +1158,13 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app, mask += sizeof(struct nfp_flower_in_port); ext += sizeof(struct nfp_flower_in_port); + /* Ensure destination MAC address matches pre_tun_dev. */ + mac = (struct nfp_flower_mac_mpls *)ext; + if (memcmp(&mac->mac_dst[0], flow->pre_tun_rule.dev->dev_addr, 6)) { + NL_SET_ERR_MSG_MOD(extack, "unsupported pre-tunnel rule: dest MAC must match output dev MAC"); + return -EOPNOTSUPP; + } + /* Ensure destination MAC address is fully matched. */ mac = (struct nfp_flower_mac_mpls *)mask; if (!is_broadcast_ether_addr(&mac->mac_dst[0])) { @@ -1159,6 +1172,11 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app, return -EOPNOTSUPP; } + if (mac->mpls_lse) { + NL_SET_ERR_MSG_MOD(extack, "unsupported pre-tunnel rule: MPLS not supported"); + return -EOPNOTSUPP; + } + mask += sizeof(struct nfp_flower_mac_mpls); ext += sizeof(struct nfp_flower_mac_mpls); if (key_layer & NFP_FLOWER_LAYER_IPV4 || From patchwork Tue Mar 16 18:13:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12143459 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,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 B3909C433E0 for ; Tue, 16 Mar 2021 18:14:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8600465142 for ; Tue, 16 Mar 2021 18:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239950AbhCPSOb (ORCPT ); Tue, 16 Mar 2021 14:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236066AbhCPSN0 (ORCPT ); Tue, 16 Mar 2021 14:13:26 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D20C06174A for ; Tue, 16 Mar 2021 11:13:26 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id lr13so73801775ejb.8 for ; Tue, 16 Mar 2021 11:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p1ixn6gSCSw6mN/hi7S+8kDToFvH/MimcFCtZRBoQTA=; b=BiXeL0VOChA8iMcJIPJnpmXzYpOZFxZASprLm7aB8sKnPh+vN3xyAd0k6aMTlrJqW6 Jk757Kpk9rpMA2uzKF3IwxneoJ7RcRqDJzEwk6D0nHGSn3WZDZzCJfhfXJpJMH6auNM0 NUdPHnda18TM61w6m8TKqPevJIjtJjp87dXZeSwb0fJWbCACiZC5oYcMIl+p/QReQ6BI bEV+Lwodb50VNQDQ/D4mBZpgOVufmqVFZKv4RE3tQQWTRyjrGuZzObIBucobtZcjUwKm EEA1V33DeOBFt4BkplzHpgC19kmGS+aj0qliRUYTQVk6b1sCPyhFPVBp98g0JsYCI3G6 AMhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p1ixn6gSCSw6mN/hi7S+8kDToFvH/MimcFCtZRBoQTA=; b=mTI1/RzI9H6RVpz4iltvlD4PlzSwG3k4okQKKfGSufBXx+vl0riLFjyWkpKBEc0nM9 jaghhvZc+XegMLRk29+OdxqnmitSMJAZ4X/5YhmfcGtb69t0GcTdRdVt5RTzEFeIxevA WOhfKebvXVxFu6p1c3bbExxLjDQrDwVYJWjk849fe5RQbi1xVs6BGg91xVpUKhEf2wyC lfT/1jLGTd020QggMMRcEB0o/sFbiMJCQAf0vHPdECYE9hZMMRqyxwDKlLz8UkCP3+vk PvnSwuWzU4OmyPiisY6Mb+9IJDCrUWwv4HkVSSOAexb755j45pVIDS+xvlpjhS+nhDpx KKCw== X-Gm-Message-State: AOAM532QD+3T8yVZaMqCqtoY5GdJw+eq5ysg9gvNz2rJZI2jQ+xCvTzG r8y2n5Q8Kx0iIU9QyqPhQBsmEw== X-Google-Smtp-Source: ABdhPJyp2oxVymyiL58SwlQA/L8DUIFmBN+28qZSq+b9MDlmTnYa7H99JXhXuMntR8EJy31xR266oQ== X-Received: by 2002:a17:906:f6ce:: with SMTP id jo14mr31539950ejb.476.1615918404886; Tue, 16 Mar 2021 11:13:24 -0700 (PDT) Received: from madeliefje.horms.nl ([2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a]) by smtp.gmail.com with ESMTPSA id e26sm11537778edj.29.2021.03.16.11.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 11:13:24 -0700 (PDT) From: Simon Horman To: David Miller Cc: Jakub Kicinski , Louis Peens , netdev@vger.kernel.org, oss-drivers@netronome.com, Simon Horman Subject: [PATCH net 2/3] nfp: flower: add ipv6 bit to pre_tunnel control message Date: Tue, 16 Mar 2021 19:13:09 +0100 Message-Id: <20210316181310.12199-3-simon.horman@netronome.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210316181310.12199-1-simon.horman@netronome.com> References: <20210316181310.12199-1-simon.horman@netronome.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Differentiate between ipv4 and ipv6 flows when configuring the pre_tunnel table to prevent them trampling each other in the table. Fixes: 783461604f7e ("nfp: flower: update flow merge code to support IPv6 tunnels") Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/tunnel_conf.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c index 7248d248f604..d19c02e99114 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c @@ -16,8 +16,9 @@ #define NFP_FL_MAX_ROUTES 32 #define NFP_TUN_PRE_TUN_RULE_LIMIT 32 -#define NFP_TUN_PRE_TUN_RULE_DEL 0x1 -#define NFP_TUN_PRE_TUN_IDX_BIT 0x8 +#define NFP_TUN_PRE_TUN_RULE_DEL BIT(0) +#define NFP_TUN_PRE_TUN_IDX_BIT BIT(3) +#define NFP_TUN_PRE_TUN_IPV6_BIT BIT(7) /** * struct nfp_tun_pre_run_rule - rule matched before decap @@ -1268,6 +1269,7 @@ int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app, { struct nfp_flower_priv *app_priv = app->priv; struct nfp_tun_offloaded_mac *mac_entry; + struct nfp_flower_meta_tci *key_meta; struct nfp_tun_pre_tun_rule payload; struct net_device *internal_dev; int err; @@ -1290,6 +1292,15 @@ int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app, if (!mac_entry) return -ENOENT; + /* Set/clear IPV6 bit. cpu_to_be16() swap will lead to MSB being + * set/clear for port_idx. + */ + key_meta = (struct nfp_flower_meta_tci *)flow->unmasked_data; + if (key_meta->nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV6) + mac_entry->index |= NFP_TUN_PRE_TUN_IPV6_BIT; + else + mac_entry->index &= ~NFP_TUN_PRE_TUN_IPV6_BIT; + payload.port_idx = cpu_to_be16(mac_entry->index); /* Copy mac id and vlan to flow - dev may not exist at delete time. */ From patchwork Tue Mar 16 18:13:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12143461 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00,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 C0404C433E9 for ; Tue, 16 Mar 2021 18:14:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A5DF65108 for ; Tue, 16 Mar 2021 18:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239915AbhCPSOh (ORCPT ); Tue, 16 Mar 2021 14:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239916AbhCPSN1 (ORCPT ); Tue, 16 Mar 2021 14:13:27 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507F6C06174A for ; Tue, 16 Mar 2021 11:13:27 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id c10so73670458ejx.9 for ; Tue, 16 Mar 2021 11:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tfnqgA69l95OzR61vRkmYo53EzSzWKDDyx/WHMJRznw=; b=NoRVZW7KIFYdWE8s1sVCdoH6NkkGhHvcsP5sAE4TKx7E91NfTTPf0zY1LxKmQld4NJ iUUGfCj1byTQdlJbLM/s+kFBg0oLO1P4IQvTo3habTyh0puc9HqAe5FviGNK2xfEGo+G wv0xbetFPQEa6yi7cA9wM33xODAvwy1MTt0kLPLW4LKbde3NcfSpX/NAjoebzq0hQ11h kiL0GN9FeRXQ34/zz0yZrqU3Q9OrWkKva2xBhpusB9xxori/iOHSevdOLqmy3wYwDXTR 64IW8k//CI568pF3iSWxKfPi5I6hh3oRoAc20KNAhDYyjqoMu0sgQmXNFmKLVeFpJ6Gt GB1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tfnqgA69l95OzR61vRkmYo53EzSzWKDDyx/WHMJRznw=; b=dvzrWWfCs3tV3uQ2tCskEnFEFDnczNjdle1weNNHmZOeEKHjPJjnqePs6DCPjXlfy0 NlwUCmqt7t9EkcmoyqwJnEM1EfRlKCiiZjoDjbcEsijNIa4JHl1Gzv2CwnYZSgc4L6sK q8N9pkSROOqwnTbuK3NNe7SBbW4R0kn/doG8E9gdq7eRgkDheAh9MgebsAuukcnx6tiV tX9UlaPBcWKAp/8SRiHWXeM9iO5oE8v/3SyQTekvjNYT/8kXsiKuQiHtDvmoH2fjRHUX 6PyigOOv2geCwXDvI1+LuuBt7YZwfXTsXQsLCVmMj8eND0OiEGpCFlf1GRY/kRrZtTKZ mQew== X-Gm-Message-State: AOAM53158nNVkJl5L7S9e4mWCjl0UxqUrDlX83pgPfYKQEmhrcYJ5Bk9 RL5jsmKyBZHJw4opHVeLMorlEA== X-Google-Smtp-Source: ABdhPJwpBa1ffNqwiW75ZAi2ZguFivAQg5XpUcy8jPT/9K1Qv0v+ztxYx8AYLTf3yYGyske3++CCnw== X-Received: by 2002:a17:906:eda3:: with SMTP id sa3mr31233962ejb.147.1615918406013; Tue, 16 Mar 2021 11:13:26 -0700 (PDT) Received: from madeliefje.horms.nl ([2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a]) by smtp.gmail.com with ESMTPSA id e26sm11537778edj.29.2021.03.16.11.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 11:13:25 -0700 (PDT) From: Simon Horman To: David Miller Cc: Jakub Kicinski , Louis Peens , netdev@vger.kernel.org, oss-drivers@netronome.com, Simon Horman Subject: [PATCH net 3/3] nfp: flower: fix pre_tun mask id allocation Date: Tue, 16 Mar 2021 19:13:10 +0100 Message-Id: <20210316181310.12199-4-simon.horman@netronome.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210316181310.12199-1-simon.horman@netronome.com> References: <20210316181310.12199-1-simon.horman@netronome.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens pre_tun_rule flows does not follow the usual add-flow path, instead they are used to update the pre_tun table on the firmware. This means that if the mask-id gets allocated here the firmware will never see the "NFP_FL_META_FLAG_MANAGE_MASK" flag for the specific mask id, which triggers the allocation on the firmware side. This leads to the firmware mask being corrupted and causing all sorts of strange behaviour. Fixes: f12725d98cbe ("nfp: flower: offload pre-tunnel rules") Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/metadata.c | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 5defd31d481c..aa06fcb38f8b 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -327,8 +327,14 @@ int nfp_compile_flow_metadata(struct nfp_app *app, goto err_free_ctx_entry; } + /* Do net allocate a mask-id for pre_tun_rules. These flows are used to + * configure the pre_tun table and are never actually send to the + * firmware as an add-flow message. This causes the mask-id allocation + * on the firmware to get out of sync if allocated here. + */ new_mask_id = 0; - if (!nfp_check_mask_add(app, nfp_flow->mask_data, + if (!nfp_flow->pre_tun_rule.dev && + !nfp_check_mask_add(app, nfp_flow->mask_data, nfp_flow->meta.mask_len, &nfp_flow->meta.flags, &new_mask_id)) { NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot allocate a new mask id"); @@ -359,7 +365,8 @@ int nfp_compile_flow_metadata(struct nfp_app *app, goto err_remove_mask; } - if (!nfp_check_mask_remove(app, nfp_flow->mask_data, + if (!nfp_flow->pre_tun_rule.dev && + !nfp_check_mask_remove(app, nfp_flow->mask_data, nfp_flow->meta.mask_len, NULL, &new_mask_id)) { NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot release mask id"); @@ -374,8 +381,10 @@ int nfp_compile_flow_metadata(struct nfp_app *app, return 0; err_remove_mask: - nfp_check_mask_remove(app, nfp_flow->mask_data, nfp_flow->meta.mask_len, - NULL, &new_mask_id); + if (!nfp_flow->pre_tun_rule.dev) + nfp_check_mask_remove(app, nfp_flow->mask_data, + nfp_flow->meta.mask_len, + NULL, &new_mask_id); err_remove_rhash: WARN_ON_ONCE(rhashtable_remove_fast(&priv->stats_ctx_table, &ctx_entry->ht_node, @@ -406,9 +415,10 @@ int nfp_modify_flow_metadata(struct nfp_app *app, __nfp_modify_flow_metadata(priv, nfp_flow); - nfp_check_mask_remove(app, nfp_flow->mask_data, - nfp_flow->meta.mask_len, &nfp_flow->meta.flags, - &new_mask_id); + if (!nfp_flow->pre_tun_rule.dev) + nfp_check_mask_remove(app, nfp_flow->mask_data, + nfp_flow->meta.mask_len, &nfp_flow->meta.flags, + &new_mask_id); /* Update flow payload with mask ids. */ nfp_flow->unmasked_data[NFP_FL_MASK_ID_LOCATION] = new_mask_id;