From patchwork Wed Sep 14 16:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12976339 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9B71C6FA82 for ; Wed, 14 Sep 2022 16:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiINQJS (ORCPT ); Wed, 14 Sep 2022 12:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiINQJK (ORCPT ); Wed, 14 Sep 2022 12:09:10 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A931E606B5 for ; Wed, 14 Sep 2022 09:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n6kSOHx1j6bRfzRyCjENnTVk34J3Wx3zCXgCsYlwYtWovrM4iLsLlKxf+4M/tbyP0sPceNYjYewIXkHrDXlaMDWh9wwgdAiK0PJtfLALE73vcMZyHSin8gFyAF5LaD8TEfnFQxjhbrb/hbssvt24xwqU0OFdHadW2zMiZFHOkFRqi6Z8TC1A/GUIsiViGIrwNArpQ0ezivNhDLm7R8DefgLvFmMruV4VvFk49sBi8lq4f8jVMBtRB5Z/ZBEpA5/Bbd0hq/B1UAOZeRQqGyvtoq6vrSmKpcrQo31lQ/DkwCD2A0aS9SUEntAI1EKFJUfpr7S+HfyO3knQIHgMHfXSSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=egimI0HY1WfJbytE1qaR71LpswfYK+jUjvhjEfcMeUo=; b=VTyRyM/A4V6vg7fXXvJ6ty63UpLG2RYfBZyu/kgCwlfUk1k4i/oEdovVjATLN+9bfw3uIuczumPMAW5xaivxySClgD91Rqg3DQSLWdJqDNIu8GZbvP3gV/fPQtNWj9wAaStQGSPdomLt+w2ycCS5jiWnmnBT356kpJkQoppTNL9PfXoJMbRi3ackSDWwta4d/R24wyrSB21hNUTotga0M55PsNh47aYLiZplIp8bGm4NucHLopDTDwnQ/X8Bi1+KVcDOiMmYNUKJd4i3czvpjnkvWCzEZV8I5zicQr9Mqzrk4jCkULdskqe7SjGqbIZXjDmayZwodnaQT6kO9D9ayg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=egimI0HY1WfJbytE1qaR71LpswfYK+jUjvhjEfcMeUo=; b=UU6s+DLzXhCD1OXiVlqpCQT0jG6wfhi2gJ6SRiY9k82g9k7Cmua7OPao5sOv1qgygyYiKtPNa+aeQ7r8MUbWT4vi4p90JjjbyiZqbPM6Wf0EPVTQ+IdxFjZfkwzSPonsxc3ItSYLUhCdjlwINvAbfYWeSRaHOcJLPRNkCY76J4A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by MN2PR13MB4070.namprd13.prod.outlook.com (2603:10b6:208:263::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12; Wed, 14 Sep 2022 16:09:06 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54%4]) with mapi id 15.20.5632.012; Wed, 14 Sep 2022 16:09:06 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Hui Zhou , Ziyang Chen Subject: [PATCH net-next 3/3] nfp: flower: support vlan action in pre_ct Date: Wed, 14 Sep 2022 17:06:04 +0100 Message-Id: <20220914160604.1740282-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220914160604.1740282-1-simon.horman@corigine.com> References: <20220914160604.1740282-1-simon.horman@corigine.com> X-ClientProxiedBy: LO4P123CA0368.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|MN2PR13MB4070:EE_ X-MS-Office365-Filtering-Correlation-Id: 84cada54-daf2-40a8-2599-08da966b72bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VuQN4BxelE0C/siNNJYremJ9sqNzI6hANYtvgEIf3ftemov1Ql7zZURH2LAjY6/aY6Qwc9vmqDkPiIKzC5hzX4I2YEfD18QCyhexJ/yPbK8b7JVwWfATncvcRk11G3zctAKFwwgILAf8cq9gSLzDGe5Th3Hvjc3rDP0ZMHkUF4KC/+/VmjoNQ5cZBvc2jNtDs6BIiYTSXIn402cG7tpRKBg2TgO/xBam49ZaE71Mkt2E4qj2L9K29ivF4yeOJAbIXg/rxJA5FL9o5shOFpcK9b4+OtoA9mdnFO0NBkgcxSH+PVU0L1aNrCIIKe5JO+KiuNYKr9svhgEZOQleJdNIUoBJvdzfQipcbWva+b5PROdpcjjFCqX0YyAFdHOtZrQPIpGKvSOsRc+6I9xZxbnoav0g++DeWvWyg1xnkmbs5HwUUuUkLDkg/70MKKgvR8Yn4cTjLrdaiWjMorXwUweH2D8D87zaLhiD+kJut/jvboxhsox2kIjub0gxawak9qIg5h3YTcJyub8oZPo+pLzdz+4y91iBImZm36ToNlNVx8YzwMLlUK6mBxuTp22DyDg9svA1OoEQoNMx8DC2jrw1MBLIOdHe1lH/eZWva2XlubyLjtnzaqFM9IcmResOgLLfd8oaRFJpo/1XfYn8KfFD3pflw32xQrskvPcIeNL77TP5WOF7YZyI7UqVj8tjM98TfvvlVSCheWE3v1zhUQt4HKe0VgufvO0PFLENL5ajngRh+KnIBHGNsaSBMH+csrXz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39840400004)(396003)(366004)(136003)(346002)(376002)(451199015)(83380400001)(52116002)(8936002)(1076003)(107886003)(8676002)(86362001)(2906002)(4326008)(6506007)(66556008)(186003)(41300700001)(38100700002)(26005)(44832011)(6512007)(6486002)(110136005)(478600001)(66946007)(2616005)(38350700002)(5660300002)(316002)(66476007)(54906003)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjUw5idSFFfDP76rxrKtdwSVNgZFBXWwC1pjP8O3JOtgZ6laIuoOeqJDyGpvyV7hngLu9dOcn+0OfM98KJ06tL1IgaOdCorO2sGRBM4kbzlVioJqzcoUp6oYZqpqeWPr6CPKw0J+ujJvKzzOS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vYHb+2ASVXiyyisdSPz5w4ZBcdPKK1tpKmp14I0DNADHChOR/djFRJvGjiVizbBFYTuVdJ2650dZuU/W9VUN8vkbcd0+Nmhm0ARs0Aa68HDNXuLx9dnUHlH/qV7Qlk035zAiqeMDQuGBwwLdxOWWrXbHe4EWDdtd+D25RgZKeIqN9trkyrpVtwYlkCW9OSzX8tQKJzlyNi8uiK716zxOVUh8ejDJnJ4PYwxElUPNT3x7LWfFz4MBFHRaVVcva85368qEfBWCzdwFPdPxUNw7k3ZIbPBWx+4k/hCKkkGRa4iR9Y46RriXymzVfOVi4Qi6nR9leuk1092ElJu3nxRXAkEHFMY226evkIucPx206WFuX0P2PMfWy1EUP7dizhFIUNQ1EoIw/28Q== X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB4070 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Hui Zhou Support hardware offload of rule which has both vlan push/pop/mangle and ct action. Signed-off-by: Hui Zhou Reviewed-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 235f02327f42..f693119541d5 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -468,12 +468,55 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, return -EINVAL; } +static int nfp_ct_check_vlan_merge(struct flow_action_entry *a_in, + struct flow_rule *rule) +{ + struct flow_match_vlan match; + + if (unlikely(flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN))) + return -EOPNOTSUPP; + + /* post_ct does not match VLAN KEY, can be merged. */ + if (likely(!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN))) + return 0; + + switch (a_in->id) { + /* pre_ct has pop vlan, post_ct cannot match VLAN KEY, cannot be merged. */ + case FLOW_ACTION_VLAN_POP: + return -EOPNOTSUPP; + + case FLOW_ACTION_VLAN_PUSH: + case FLOW_ACTION_VLAN_MANGLE: + flow_rule_match_vlan(rule, &match); + /* different vlan id, cannot be merged. */ + if ((match.key->vlan_id & match.mask->vlan_id) ^ + (a_in->vlan.vid & match.mask->vlan_id)) + return -EOPNOTSUPP; + + /* different tpid, cannot be merged. */ + if ((match.key->vlan_tpid & match.mask->vlan_tpid) ^ + (a_in->vlan.proto & match.mask->vlan_tpid)) + return -EOPNOTSUPP; + + /* different priority, cannot be merged. */ + if ((match.key->vlan_priority & match.mask->vlan_priority) ^ + (a_in->vlan.prio & match.mask->vlan_priority)) + return -EOPNOTSUPP; + + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, struct nfp_fl_ct_flow_entry *post_ct_entry, struct nfp_fl_ct_flow_entry *nft_entry) { struct flow_action_entry *act; - int i; + int i, err; /* Check for pre_ct->action conflicts */ flow_action_for_each(i, act, &pre_ct_entry->rule->action) { @@ -481,6 +524,10 @@ static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, case FLOW_ACTION_VLAN_PUSH: case FLOW_ACTION_VLAN_POP: case FLOW_ACTION_VLAN_MANGLE: + err = nfp_ct_check_vlan_merge(act, post_ct_entry->rule); + if (err) + return err; + break; case FLOW_ACTION_MPLS_PUSH: case FLOW_ACTION_MPLS_POP: case FLOW_ACTION_MPLS_MANGLE: