From patchwork Wed Jun 16 10:01:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324701 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 B7980C48BE6 for ; Wed, 16 Jun 2021 10:02:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CCBA61246 for ; Wed, 16 Jun 2021 10:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232237AbhFPKEr (ORCPT ); Wed, 16 Jun 2021 06:04:47 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231769AbhFPKEh (ORCPT ); Wed, 16 Jun 2021 06:04:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d2nKgOZAYYK5p0sAcNIUW9LL5MiKD6vyQScdrndN1xQI5l8QtAUzMBLTRAT5mXMyXFMp7L8gfNM8QMKBF9TDNU9EctkNV22qWVdCcFxsIxF5E0W0ounGhxe2Ke0nIcyX3DzCX//sEa0Uuqi9ULmKggUkVf+WtEGz+nLRximUjars4FxKK96S6O15uZ0mNf3YVLY1h4KPaYrwEleT25Ih/gGseiIo2A/sNspdRVq85yeXpMyYfu+8wF6gQl0v1A1h52b+Lr9cNg2IpxijKZXLfsDuykGsSD15vEHvRLzgn8gcIadaSpxonNvLpEM1sOmuSWlmnuZksDHgkhjY1zkjPg== 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-SenderADCheck; bh=YOW3bSCqo2HSWwCuw7fLoHH9RZrjXOCmtmkAzdl6Kok=; b=jhfJ6Jp7GKfR7R1OrNpBCDkqa+aRvTYxnR/0KKTp6qd6aK4/Kmnwl5KGwciw6SdGlLwnFvLGTe2Xlz8QFjqytcO1IOoefU5mkHQOZaMwwty5mjTmCcWYTz9LRL/AodWd/7M2lP5rxSVfx2LDgtsB2TheAXxFXgfdYS9RomqbsDqrxsu1bnslgLv3QcR3SwAZmhhSROpZ3f+2xY+gbnsUiLuVkJPgmEdsxbctblm3vwfAqaARjmy51atFLcRJE23uU1UR6RdwyECNvt47nG5ZzyQ154fPcQDQLJvyAq4jhpyxrDlIiIPZjKmbPuTd6h+VQBFsrc4VyDLrR1Ik7YDIiA== 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=YOW3bSCqo2HSWwCuw7fLoHH9RZrjXOCmtmkAzdl6Kok=; b=j1EN0Tll2/I+kTBZecPeLWmbvkGiJSpFdBn5RRHjxSgACQOPhWE8zbjw0ogLsgQMtFIdFxaFSDoSwbUv4aNRjvNvuDup6F3WiHubQGiXq+zpatJlFQzwAVxmLJ/vDOmYOUusi6bztEY//jl427ABd+spzdvkZVdJ0RPuUD4WeGI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:27 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:27 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 1/9] nfp: flower-ct: add delete flow handling for ct Date: Wed, 16 Jun 2021 12:01:59 +0200 Message-Id: <20210616100207.14415-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86363bc9-da18-4a7b-c0ad-08d930add869 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KUYleprRunGYmer1lNxxNg5qyDLkhOyQ9g7NKY54fq6FzERCO0baL3Njpbxs//YyANVVdqBUvaxdRYShNBbeNwxA5sNI0QFCGhh+T+7fWTNxuwev2D5aRaAi5ilckZIKzTJwMPM9G8yY70p5/sqSoNBc+eC7Y28CWj4kJ+kj6+XFoYDok51P0eyR6w5T+caWJ5zvpwjk8CXPson2k3W0Depvq3EryvNIHZ97+si598whjiUhpYUkeQlwxFwh9BA7qgPd+ui2bZPdXIcoDxeUJevYjnZM9N/Hmy1wtMfAmVFOYusy0/vh36t7/8EWQGeK5dDVVUOyFEt37d58UxdSko5OnY/DXVNl0JEmgJF5OvfjYA0YqzMSrs0+gJ5fOogXAnfCws5EMkPGkXVuImbPTEHxXbZRiQQUjXPwj5SXWvVyJPhdJO4yLQCpuLWahMIJjVO6L12uwbZXSea4Ge3CpFpcKj9UQeQEdhrybnMx5Mk0OAt6qidVq51iSfjik/2FHhE9UhSCm4xQBdkt8+GUObrVi4sgnVJqwBwGPSQ6AyLTP4+TXPP/r4VqZUp0l9ZBaFyh+u1U2b9j5J0kE0gTpuG/hThK/T4z9NSCF7+WuyL+NvXG4U2QwKQWIHL0TCvjx/TmcAv9UET+XQlfhLCtSQ== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wu3+L/eK9+tM768TtOhJXFosWTOGxMHhHhkINhREXjfZI4qbG33qEjYBSiSQRsV43NXHM7qy9LVWEvRAv8JAwE6XqwgIOXyzzuhVJr+8fuaWw9YuvIuGaY5klydHY4I+N3a78WahHlrZ9+I8OwrOVeg6+7maKrZCqDiOkjJOJpu4IW8Ewbq0C3yQoiN5h3wBKaVL6BmF81ZQVLQW9bt40Yl3YX9bLL6oea/3F4YFRP8LUCPhp0Kg2JOj1NJ6iQ05TymJT5XOYOZGsS+jqPElChRqIRWlxVOdk2hFFYXfewUXXYqPcZz8xC8luvT1z41A2/Ky8A5qEZrh5L9lLAJ/8HJkiWK3VqhfxcA0j5FhwPSFerHvhEk/TyAB8W8kcOMZHPDV1bsS6p83U4X70Tez4z05JxERMcbj97xFs93DbW9iB70dYEJbZdt8c3BR4AHXpNMs4ew7pvJED2AJBAliv0N6Kz1JWYdE6aRkjdAtJXmIsXqyk+vNinyGWiS47Xsr4lsbMQ1dx2Xq7Pw9Eh9bS9fRc3Btgzk7CSToctIw2TPs00o9FkjoyjWJgJgzqzhpCPSjpesh4dhNi1alVMZ/jHzI6/QOFngo7IMZJSl5gqFwZzOco8Ng3rp2bfD3MQgghZvAo3MjrVMO2fjMt4fCTcuJ4QHKvHt/beMXVvyFxoS5SKDUyDAylnXsiaTCG+0wdhWSlh2XF9ioPSHF/azMvDqjQ2oWV8uS62Ii3OhJDnt+7MmYCXD4iZu87M7V5h2FD4hTkyYlFhWPWPsBgYHZCFKofg0uxuJTnnYMVc35834bfd8Nk9k23qvIvK9pOmg5feMuFiotU2dZCMRymXCrqidhXIt26cAc/2RFdwOd6JZi92VVBQhl+6PE/aNmXOKmzhTLRVbFRykMR6f56mTS+MLulGb6iDQ6NgACXKil0ae5ynVkhyCaGbO4Y/IeYdnsehDyIzZ6O1FRQ1GxooPhqLgHrUSTj3TEyUwDu8m+nB6WD6wY0LxXw/CkfKc/bHITRNsM8H/El1xv5tZQSC+s0xRSYfOznmOz0MQSTrAwi+g1HJvaNZEkRihnq0LtRlZRflGb6dt7JDWcTnzuVnLrib6PM3fB9n/8VuGD+w33XDaGZQtTVjAFaI/w0xjloIL/q49KUdVe1gpWPpt++oW8Jbld43OLP9n5Dbw3TP+HUGS4Ieh6z/DcXnH90PlkMtQWu+nbiaq+oAe4HYHk6/76j3TODroEqEQq5SmtKjzwSN3KTvTVq6yPtBi8DpRmrIqvKjEYWySt+cSlI6zHgl+u08h4Pps0zWiPk9zNO/5bJVimpgt5/V3IGRkGrAJfEqUvOgROvmkqZpQstj3DB3alJOs4UbYLY/Pgman4QpEYMXSIiLJ7QTmFYD5ATF5dE5NJ X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86363bc9-da18-4a7b-c0ad-08d930add869 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:27.0329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1UuwtS9v6LUjgVFIMRLitk+Z/j5LkdqmVCQUN1B6sZ3Camn8P/BjqXQxzFqQQjo444skudTFTEpP68xAfevmM+FX2+uiJL0IYNniY8NiJoo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Add functions to handle delete flow callbacks for ct flows. Also accept the flows for offloading by returning 0 instead of -EOPNOTSUPP. Flows will still not actually be offloaded to hw, but at this point it's difficult to not accept the flows and also exercise the cleanup paths properly. Traffic will still be handled safely through the fallback path. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 38 +++++++++++++++++-- .../ethernet/netronome/nfp/flower/conntrack.h | 6 +++ .../ethernet/netronome/nfp/flower/offload.c | 9 +++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index b1709affb52d..ea70e02d170e 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -424,8 +424,7 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, if (priv->ct_zone_wc) nfp_ct_merge_tc_entries(ct_entry, priv->ct_zone_wc, zt); - NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action not supported"); - return -EOPNOTSUPP; + return 0; } int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, @@ -487,6 +486,37 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, nfp_ct_merge_tc_entries(ct_entry, zt, zt); } - NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack match not supported"); - return -EOPNOTSUPP; + return 0; +} + +int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) +{ + struct nfp_fl_ct_flow_entry *ct_entry; + struct nfp_fl_ct_zone_entry *zt; + struct rhashtable *m_table; + + zt = ct_map_ent->ct_entry->zt; + ct_entry = ct_map_ent->ct_entry; + m_table = &zt->priv->ct_map_table; + + switch (ct_entry->type) { + case CT_TYPE_PRE_CT: + zt->pre_ct_count--; + rhashtable_remove_fast(m_table, &ct_map_ent->hash_node, + nfp_ct_map_params); + nfp_fl_ct_clean_flow_entry(ct_entry); + kfree(ct_map_ent); + break; + case CT_TYPE_POST_CT: + zt->post_ct_count--; + rhashtable_remove_fast(m_table, &ct_map_ent->hash_node, + nfp_ct_map_params); + nfp_fl_ct_clean_flow_entry(ct_entry); + kfree(ct_map_ent); + break; + default: + break; + } + + return 0; } diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index 3d7d260c6e5c..dbb18fbbae69 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -152,4 +152,10 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, * @entry: Flow entry to cleanup */ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry); + +/** + * nfp_fl_ct_del_flow() - Handle flow_del callbacks for conntrack + * @ct_map_ent: ct map entry for the flow that needs deleting + */ +int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 7e4ad5d58859..2406d33356ad 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1505,6 +1505,7 @@ nfp_flower_del_offload(struct nfp_app *app, struct net_device *netdev, struct flow_cls_offload *flow) { struct nfp_flower_priv *priv = app->priv; + struct nfp_fl_ct_map_entry *ct_map_ent; struct netlink_ext_ack *extack = NULL; struct nfp_fl_payload *nfp_flow; struct nfp_port *port = NULL; @@ -1514,6 +1515,14 @@ nfp_flower_del_offload(struct nfp_app *app, struct net_device *netdev, if (nfp_netdev_is_nfp_repr(netdev)) port = nfp_port_from_netdev(netdev); + /* Check ct_map_table */ + ct_map_ent = rhashtable_lookup_fast(&priv->ct_map_table, &flow->cookie, + nfp_ct_map_params); + if (ct_map_ent) { + err = nfp_fl_ct_del_flow(ct_map_ent); + return err; + } + nfp_flow = nfp_flower_search_fl_table(app, flow->cookie, netdev); if (!nfp_flow) { NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot remove flow that does not exist"); From patchwork Wed Jun 16 10:02:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324703 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 DBE2BC48BE8 for ; Wed, 16 Jun 2021 10:02:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEDD56109D for ; Wed, 16 Jun 2021 10:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232307AbhFPKEw (ORCPT ); Wed, 16 Jun 2021 06:04:52 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231931AbhFPKEl (ORCPT ); Wed, 16 Jun 2021 06:04:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4sqyHaCBgxeUuzPp7d5wShjg3qG7iLwUS0zYOSwW1lBNTddoCaWQqFsDfUmNa/XxvpSAQY4Nv0l4PR0dtQlfjvsDvBbg9fACKKe5C7v7fP45UujCrn2EANlHETb8YXDARMTsJDhHygvDMGv74hRCHbKU9LKMR91mqEz/yXsQwyaICO6/HOa4l7fDzwzkF2oAIfCtzMwHCCUmnGr6zmxxUOMcG7UQWNJDsRYyJqUfvSFs8etiG2CoIk4mPi0oRv93tlnRbS+WVbb/dbR0guhLfgSPFRFDPH86repemnY1k0PlHmzdRw54iVzB3SM4EfaVCPHcxBb7LWOHIQH5bkQmw== 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-SenderADCheck; bh=j5jPKs4OvZv4XUWnf3Tb1yx9S46w/P2ePKl9QuzCaVc=; b=Z2sXIXs06bIVS9j7lQujTKDz6V35MXXxGYicGyOn22UkCN/Xzy+MIt42GxeqcmqlzHrmdFgOG6NcVh9sNET4qxqIz4UJQo+BYz/8bkC2VKnVyS8UY/rWY/f8hYP5nHEb9emUrD4nK+oRbGhSpmwQJfLh+OUTzvN6sVMZWp4kJdBCw2DshMUTNZTdh/oKjKsh5wkwlaxwH5Dr5NAed27bS6FQ2F0pytfRpJvKBvd3Xa6ODIlpDQ6k6SGBsWTp0yznoAiRfkN9wQPBKbPXfOnvrz+XKL7nNTNN3er/iRFlGihk9QYQJR4dKzmpPEt0SdDcHt8lX5bTOCBKsDkezT3DtA== 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=j5jPKs4OvZv4XUWnf3Tb1yx9S46w/P2ePKl9QuzCaVc=; b=rThYFnWpJUQPzJTZFxmtQMWXE+lbzN/OTG3wsHaEHL5Te9B0KNlYjgMPPlyfpqc5pytsWcmN6/dOEGHVs/D7YwBTilzTV3Lc+U8qplvS86yZa6VXLk5AS14zTVm+yIrQf1K/dEmCM18RO+4aan8jZFxZpsd2weFhdAvil0R/Ctg= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:28 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:28 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 2/9] nfp: flower-ct: add nft callback stubs Date: Wed, 16 Jun 2021 12:02:00 +0200 Message-Id: <20210616100207.14415-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6be393b1-e36d-49d8-f84d-08d930add97b X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: haI9X7zM4/MmdFbUqsDGOTc+9qrMU9qwn+AqMz6xVFxwCGy7SJZC9G1tx3dIpNti5uFRqaBm7qdztE/sscW00Jqw2TE3ltzj9rKKuchRXN1sTGjzB/oBPVKWL3mFSkZ/MJEgUfWavy5KzDseYE+F3ul65Y0i4ZIiQnUHKN+ObAi01aGlD4B5h0s4oPWypMcONsJTTIRHWW8NWeTmxIJ+p2RYkT/p1b/tnWc6GJuZ/mrDu0cYaruihCeLDFy4JlIYo10I4pSEap3t8PgdG8X+b9vRPL7VadgqZ8LHr/EiNdijES277vSRYNPP2wKfa+wq3V7GVuTu+3KI6uRt0zqzIwcENE32jBvP5xd4oS1I4PCF+1Dcp58PuIWCKqFFrMmeXGW+4sdvuiwQL3cspZAoWDe7wwVc6LzR+ttjnN0kUMDm5ddS3QWi5d/qljdhYGNafAMuBQigIUoa2AMoX72g0kd5JfMqD+B6RbjEU/zS1UQcSTlenUR6R5u0TXuwnSj84Zd5/Jln1GPctlTJ/aEbwQ6KJJ+CEGzJAn3v4mmH30V9EskBq0rBMPYFpJJx7Ru2NQhzthdqb2o4ZFMuLHpllwoCDAt178EpNf9IfQ3k6wMtv+wR9HObUmWe9T5Hdfba8YVlWARg7Z/rvmTmnuzE6A== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GooI5M73KgtGCc/BjQj7IjuGmVCOjhD+usQK3epnr0SXK3DZyjv6IMOCsYSXifxJgq6Q/A8ksYu3E2g/1TFNfavS1cgfdpXTe/7cDFLwKq5a5Bb1k0SIDTYFRknDzEnXTxt8yETqLw9huOxpVSVxhi7b2lNACt/st2lxcY0axOTv8jz6obnfRO3IwmP98iTTVWh3t4MJ7eLNRhogxl3x9v6xawvf3LfcXu5wL/2vp3KAdH5GnyBa/ztVSe0GbAy0Ld3AbXj3qD5EyU3ysnG/TIToTHGZGuIcXCcppLrakOcKWuRqLSa9LxbTnDYA2cI8ORu8/iUYQllxfDwz3V1CPJ4XmQZLDkXrDWeIZH90EL8K9znH7NuaKLbwXSDfzCzUkBep8ussqYGVVOTihWEbrwt7ilzWg7OXy2916VTBFAdrVjeRdE/aWIPaJaGGJdGOUTELxF56xNldUhi2RHmq1dy5vtdh51Yybnxps/Dijpxbu3NonTMzpSDgctu37lmcNKpZbehnTzGOn+1m9mRWK8/FUhYNYASBYUeIpHJvd5+jN8V1WD/N7pur05ipdoyNrq9xwGQnB+GIYJGRJlCpm4tgsnRhidUZtSjmhr08DJ2t3ugQf6gIjIRZTTxbCbgfNhtyBs7YNuUIVhbP3pyR+3cn9lBrdr4MDK7n9AV791zZYjirJQ1S/cDx4tIonFHTCRZGVKj1h2IgnuZoVVYzkmXBxdQTyrQTeVM3KKxeLkwl+qswCY4Ttpyy/BgEUcN0V2/2/a45wjKeGMOTRJUMAc/UWHMA2UeKMGpTj1Hk/CjToEwQ2OO8bBQCbCzKeA21WwzgEJR3gUyjNQQ77xIbaFSiCQZFpCydXOq+N9IHTs4aZ3IHwD4kzUr9eg+sJa9qGNNLgYoOqzDS7S05yNTNjdfRR/4ZO4Va72L6rxDGBtRYucHEroo1+H4Y8WPu463fln+B969Jz9KKq+n4/PxlWsjf8jGNa/I7INoCMu6WI2YvN3r4rQQ7mg1MIDpaL++jrlA0srCWE7QLlTBQ5yyjUDmi5F7ohHf7U7k9kmkrnsH7uiE/p6VkZEP7mR0xDu55a/uWmiPLxbs4pfJegkY4EW3Is6LNiJZMsTaOwu/GJyEh7/nG0xbeyzPFPORqhhqJE9UKEQ/QIEhlHqA7n/ckjg2M0xUHVGqpunpCteDznj+vvXxf6PH3Ff+OJrcIGHtVRQY/fWI9HqW7y5JHSUvQOm9gDw3nAGP8fuBsr/ZJlOqbGepFDu4wfk0e0U/9TYhCoaeRXyCbeoIfxZSgAQYQFelEoBiaZBIQPnhRcoqhuGTJnkt+8uTRq6HM1vqaudk40V3FZBeX1z8k8RYPzd1dB72RwtpD6yIFKL27lu2gr00QvsLd0xdx5pCwzoQhYkzJ X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6be393b1-e36d-49d8-f84d-08d930add97b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:28.6986 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rvyTYVLJWbNYQ+1ni2iGfhPSrmJZ1mfkiPPc+vgM1kB8sHzAmpUBT8l3e2r2P9p8XkrmfxHXWinvVPy5scvZl0K2nF4LjkYskr0rJJzRW7I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Add register/unregister of the nft callback. For now just add stub code to accept the flows, but don't do anything with it. Decided to accept the flows since netfilter will keep on trying to offload a flow if it was rejected, which is quite noisy. Follow-up patches will start implementing the functions to add nft flows to the relevant tables. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 63 ++++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 11 ++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index ea70e02d170e..7fb51e13faea 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -384,6 +384,7 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct flow_action_entry *ct_act, *ct_goto; struct nfp_fl_ct_flow_entry *ct_entry; struct nfp_fl_ct_zone_entry *zt; + int err; ct_act = get_flow_act(flow, FLOW_ACTION_CT); if (!ct_act) { @@ -406,8 +407,15 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, return PTR_ERR(zt); } - if (!zt->nft) + if (!zt->nft) { zt->nft = ct_act->ct.flow_table; + err = nf_flow_table_offload_add_cb(zt->nft, nfp_fl_ct_handle_nft_flow, zt); + if (err) { + NL_SET_ERR_MSG_MOD(extack, + "offload error: Could not register nft_callback"); + return err; + } + } /* Add entry to pre_ct_list */ ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); @@ -489,6 +497,42 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, return 0; } +static int +nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offload *flow) +{ + ASSERT_RTNL(); + + switch (flow->command) { + case FLOW_CLS_REPLACE: + return 0; + case FLOW_CLS_DESTROY: + return 0; + case FLOW_CLS_STATS: + return 0; + default: + break; + } + return -EINVAL; +} + +int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data, void *cb_priv) +{ + struct flow_cls_offload *flow = type_data; + struct nfp_fl_ct_zone_entry *zt = cb_priv; + int err = -EOPNOTSUPP; + + switch (type) { + case TC_SETUP_CLSFLOWER: + rtnl_lock(); + err = nfp_fl_ct_offload_nft_flow(zt, flow); + rtnl_unlock(); + break; + default: + return -EOPNOTSUPP; + } + return err; +} + int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) { struct nfp_fl_ct_flow_entry *ct_entry; @@ -506,6 +550,23 @@ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) nfp_ct_map_params); nfp_fl_ct_clean_flow_entry(ct_entry); kfree(ct_map_ent); + + /* If this is the last pre_ct_rule it means that it is + * very likely that the nft table will be cleaned up next, + * as this happens on the removal of the last act_ct flow. + * However we cannot deregister the callback on the removal + * of the last nft flow as this runs into a deadlock situation. + * So deregister the callback on removal of the last pre_ct flow + * and remove any remaining nft flow entries. We also cannot + * save this state and delete the callback later since the + * nft table would already have been freed at that time. + */ + if (!zt->pre_ct_count) { + nf_flow_table_offload_del_cb(zt->nft, + nfp_fl_ct_handle_nft_flow, + zt); + zt->nft = NULL; + } break; case CT_TYPE_POST_CT: zt->post_ct_count--; diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index dbb18fbbae69..b6e750dad929 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -4,6 +4,7 @@ #ifndef __NFP_FLOWER_CONNTRACK_H__ #define __NFP_FLOWER_CONNTRACK_H__ 1 +#include #include "main.h" #define NFP_FL_CT_NO_TUN 0xff @@ -158,4 +159,14 @@ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry); * @ct_map_ent: ct map entry for the flow that needs deleting */ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent); + +/** + * nfp_fl_ct_handle_nft_flow() - Handle flower flow callbacks for nft table + * @type: Type provided by callback + * @type_data: Callback data + * @cb_priv: Pointer to data provided when registering the callback, in this + * case it's the zone table. + */ +int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data, + void *cb_priv); #endif From patchwork Wed Jun 16 10:02:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324705 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 4D7A5C48BE5 for ; Wed, 16 Jun 2021 10:02:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DA616109D for ; Wed, 16 Jun 2021 10:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232220AbhFPKEy (ORCPT ); Wed, 16 Jun 2021 06:04:54 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232031AbhFPKEm (ORCPT ); Wed, 16 Jun 2021 06:04:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdFzlohdjaA7qiVviwJet7j/z+5y6keXUlgprzcrsI5OzM5OIUXuw6b4XwsIQFHUV6qMAx6Fo/nkF+AhLpkH0lkxzPjks5VzxTGzbnKoL9jwCMHhY9NbGxUKGWa+capHLciVDtWif0+NNMuuQG16EKZ0GFKKSUwSf3wt8JchxopqgyXq21F/N3/fXnOu43Y1AuvY8wwcCJnVm6XyAzAHHyL2/FG2bxU6LUIjLEJjRZ9NNdmIryfMwJrHIK8sAdmK1IFzmD/P1xrjBJpcNYXrHeuWnt2T+YV4IlVzMfw9E4+oxJkDxphmHJhUjiu0n/J32JKZOFR0k+h/4YDP3kfyaw== 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-SenderADCheck; bh=+rswEvOa2EoElM3NwVAtb5NVpaNA/NZ7/n8D1ajlThU=; b=kRhgjPVaRSCwOfcofsW5bBQ8AAG9SP9B25zCzdeCv/du3zcBmHYsswwbSbdtDkjmhCxiRxKsyOee6iiL/vStmDNfbDp3uRi0gmKRSWALGuxxO3OicxU119o1bLB5CTFxDqQ1/7e9fZKqnqE3cHWiWHGlEWWUxXPr4n1+0X61UsBoWPOewfca4GUb/Fht0H44uWvznoHkAqxfhDaMuyzHBOBQCG3xG0QxELyPa2HSrqnD/refNsowfZLkMrqQGzn1Ai73DBvyfZYLlk/7+kBjFNbJwzG7ivEmq5ZZZ8vX1vLy18tE0qj4O3fLhHYdVXFurdvtjY5b7QsKxHfwIHuJ0w== 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=+rswEvOa2EoElM3NwVAtb5NVpaNA/NZ7/n8D1ajlThU=; b=RrRyoY495gYk5diGNmOASLbh35bzmHS/V3XAkWJzRf4iOzsmoQ50DVUbxDqosWMHOxdybiQ16k6kVgpCFvZMuKHL6Suww70CFnhMhThVu7V0UWssXqW5BTDq05aCQAUe4m4zNQnPm2HNGTvNjSpFHMP8KKR+jJmgJPODeefB5/Q= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:30 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:30 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 3/9] nfp: flower-ct: add nft flows to nft list Date: Wed, 16 Jun 2021 12:02:01 +0200 Message-Id: <20210616100207.14415-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b87b713-c927-4773-2b90-08d930adda71 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6RROcBnt7PyOEJ62WyvY/ve1PMxYGcV5NcuRMMjGA34qC9w5i9hnWTfUjqLDtj3WDQ3q+yG5cDv6qhQZ9yNfgnCEfT6vX2k/pDbEecTCMugY4vgDo7HGsPCRBkev/o/yv6YCobSflcd7MOUCSRK8crVjSXwU8O63EI1/jSCDic/J/OHCe5STzmi2ZUubZpsF7J84Hq7G/caHf73BBBqVaDOg2ZpCiRfEAyKa3L+NfTYvgnIx84b/BCfrNgmRRBRTvB0bg2kRr8a/cirS3wybagIEmKyAqpk8JaA4heEXSilVmxgOzcfu+COGKZ2W2j+9w5wKS6lNkuc4I5jeG4Idi0TQtUCJOKWHV3EadWpwJUUg6uyxYAXJ5t9h0EvZCSKSQOeCIL4e9ObHDLboEy5oujt7lN/3XoaSZXkz0Z4YnL+sY1lpd1U/QHnH+9o8CSw7VKZxQGucsPr2ZifXA/+UYE2lSPpQv4uQLTHox4O1JXsx2S+kOfxj9U2n2LxXRMTe5QN9xGP2dNnW9U6Kaz23DD923Vk0CB4wrIBRLH65FZdsfXd9fXpQNJuIsVunnMzkr/7h9Hd9kprlcIV+LVcCmSItJxV2hxQz9qw1b+DoAUSp5c67TZ3OnGc4D+YCZ0LFM2AWKeQ88NP/i3529V/sKQ== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nThvSlFpF3yVBK2q0pzP7X/UH+k2UDmOHOxK/BB3CJrgykpYB2o+YxhANKKE4fPys0DD+lDPrkzuN9cu/BNLw9hJ1m3QkJugXoNFP5Qt2Yfz5PUOcloqDIc50bUdvg4hXWjPb4lBtGxmqjYTxNL0NzPy0j3nR8OdLHNBhiYdIlLHYxmoKEdN0Kex8F/ve7YK/8FH9skbT6/uGlztof/1/RPvEq0c+T31Asv4a2tVDsvKndVgSlpFitD5GLQnqoYN55cT0FC3Oj/ZeSGYGXaDtut6io/MsJRSZzYZUrnWQORuze5Wr1KAXl7jBIy+h06Wz8OJXmExkG7qSiaS/ea34IC5basqvHyomDe59LxBi3QViHn33QIsrzjebbaj+ZIJtmYXi+Hf+w1E9sQpceVxXOiu4IMngFO9EdUc2LNvUEM1DJAi9/RES2ZKYahc6a8qOczbXqsorjlSkpD/khjYvrxOZ8bl6n99IyMeDu5YQai4sF6+3RBQx21c3CXHxok7EIaCRFr0bmUCBAGsPodNIKIYCPAeNZo1o3aqIihaZUGGqmOjSCwWc9mEjc1EqOWfstS/QMktjiTPfOvk6Rc/BAd5rxxb6SKmgTzlTugiVVCWGPrKTFDowZZyzjwQ045D1Bv5eldmccnPrRhwcn1bBOlBe8GYr37QhTUKwcdErlnd/gIxABp7FpwrvYYoscMekfidsblZ3ZCyn736JS5NYTEpmse6/aOcbCWUQdeA17e32aIBWuMMZM22WOc/YHj7RhkDfkO9W/VCDLw6i5VQxQkSHWn8gGsEZgXKjLbjfeJCHtuPWrCRaKUZ3AJxlqbgcHtG+F3anP2PNmn0oBqDPaE35OfuVh4OfKRkBT2KT3riq8kLf2P6XWY5PFu1xkfqN7Mii3NvI0+jBv+xzO4LZnTuuTnB6vNkCTfV5JKhc5GKNXd6ZJWOcew9uFZ8EHNU8Ad2S6ax9GENGhUNrvEBc3xuSc4ERhCcAwMm0kAVClJhKtHV8X8byG1XI3jCoAoS6QDeqyBL0NlHtUS9XITP5D9pCwoeqlvtta2cx1GobVPvvvT005Kysl0RYzblRxqiNeIeyskbDJ+a0/fLV4ioA9WA9ss87MW6ouVPKI2LZdINAXxVLQkGwQwuHMOVsfHIdqwIzYMKt2bTdYpeFCAvLW3nHsyCqtt005vsPHCmv7UitA5f1IRgFg2eM+O7EV5KFUuDbMHw08P/em0LC0k4IYTcZaON701W32DZ7tBEjBWByCZQjuX8cA93wd/GdnyAte7sWWnbzhM3EflMSXApsSQEQff9ShtcYPgBQVQHnOlNxaTrx6Zb4HC1dia2PfCtkTirpCfzg+emzDbNlrCez88/nArW+BhQ2p0e7n9n5GBUp4vtyY8vOKjc4MCoTHqR X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b87b713-c927-4773-2b90-08d930adda71 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:30.3165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NEdG+7ECMOt+gAvCcr+vnHK6uX3tGZ1H5t2k1UT0oPlKt9D5gLzCuON5hlt58pgMCweN/Q1CtjK/b9VBN4YFd81GY/79pL8RkJv1rwO32wI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Implement code to add and remove nft flows to the relevant list. Registering and deregistering the callback function for the nft table is quite complicated. The safest is to delete the callback on the removal of the last pre_ct flow. This is because if this is also the latest pre_ct flow in software it means that this specific nft table will be freed, so there will not be a later opportunity to do this. Another place where it looks possible to delete the callback is when the last nft_flow is deleted, but this happens under the flow_table lock, which is also taken when deregistering the callback, leading to a deadlock situation. This means the final solution here is to delete the callback when removing the last pre_ct flow, and then clean up any remaining nft_flow entries which may still be present, since there will never be a callback now to do this, leaving them orphaned if not cleaned up here as well. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 46 ++++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 6 +++ .../ethernet/netronome/nfp/flower/metadata.c | 26 +++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 7fb51e13faea..1b527f0660a7 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -165,6 +165,7 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, /* init the various hash tables and lists*/ INIT_LIST_HEAD(&zt->pre_ct_list); INIT_LIST_HEAD(&zt->post_ct_list); + INIT_LIST_HEAD(&zt->nft_flows_list); err = rhashtable_init(&zt->tc_merge_tb, &nfp_tc_ct_merge_params); if (err) @@ -500,13 +501,31 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, static int nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offload *flow) { + struct nfp_fl_ct_map_entry *ct_map_ent; + struct nfp_fl_ct_flow_entry *ct_entry; + struct netlink_ext_ack *extack = NULL; + ASSERT_RTNL(); + extack = flow->common.extack; switch (flow->command) { case FLOW_CLS_REPLACE: + /* Netfilter can request offload multiple times for the same + * flow - protect against adding duplicates. + */ + ct_map_ent = rhashtable_lookup_fast(&zt->priv->ct_map_table, &flow->cookie, + nfp_ct_map_params); + if (!ct_map_ent) { + ct_entry = nfp_fl_ct_add_flow(zt, NULL, flow, extack); + ct_entry->type = CT_TYPE_NFT; + list_add(&ct_entry->list_node, &zt->nft_flows_list); + zt->nft_flows_count++; + } return 0; case FLOW_CLS_DESTROY: - return 0; + ct_map_ent = rhashtable_lookup_fast(&zt->priv->ct_map_table, &flow->cookie, + nfp_ct_map_params); + return nfp_fl_ct_del_flow(ct_map_ent); case FLOW_CLS_STATS: return 0; default: @@ -533,12 +552,30 @@ int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data, void *cb return err; } +static void +nfp_fl_ct_clean_nft_entries(struct nfp_fl_ct_zone_entry *zt) +{ + struct nfp_fl_ct_flow_entry *nft_entry, *ct_tmp; + struct nfp_fl_ct_map_entry *ct_map_ent; + + list_for_each_entry_safe(nft_entry, ct_tmp, &zt->nft_flows_list, + list_node) { + ct_map_ent = rhashtable_lookup_fast(&zt->priv->ct_map_table, + &nft_entry->cookie, + nfp_ct_map_params); + nfp_fl_ct_del_flow(ct_map_ent); + } +} + int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) { struct nfp_fl_ct_flow_entry *ct_entry; struct nfp_fl_ct_zone_entry *zt; struct rhashtable *m_table; + if (!ct_map_ent) + return -ENOENT; + zt = ct_map_ent->ct_entry->zt; ct_entry = ct_map_ent->ct_entry; m_table = &zt->priv->ct_map_table; @@ -566,6 +603,7 @@ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) nfp_fl_ct_handle_nft_flow, zt); zt->nft = NULL; + nfp_fl_ct_clean_nft_entries(zt); } break; case CT_TYPE_POST_CT: @@ -575,6 +613,12 @@ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent) nfp_fl_ct_clean_flow_entry(ct_entry); kfree(ct_map_ent); break; + case CT_TYPE_NFT: + zt->nft_flows_count--; + rhashtable_remove_fast(m_table, &ct_map_ent->hash_node, + nfp_ct_map_params); + nfp_fl_ct_clean_flow_entry(ct_map_ent->ct_entry); + kfree(ct_map_ent); default: break; } diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index b6e750dad929..def95c3e8bb7 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -28,6 +28,9 @@ extern const struct rhashtable_params nfp_tc_ct_merge_params; * * @tc_merge_tb: The table of merged tc flows * @tc_merge_count: Keep count of the number of merged tc entries + * + * @nft_flows_list: The list of nft relatednfp_fl_ct_flow_entry entries + * @nft_flows_count: Keep count of the number of nft_flow entries */ struct nfp_fl_ct_zone_entry { u16 zone; @@ -44,6 +47,9 @@ struct nfp_fl_ct_zone_entry { struct rhashtable tc_merge_tb; unsigned int tc_merge_count; + + struct list_head nft_flows_list; + unsigned int nft_flows_count; }; enum ct_entry_type { diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 8658c5cedf91..a0a0242567a6 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -639,6 +639,32 @@ static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) } } + if (zt->nft) { + nf_flow_table_offload_del_cb(zt->nft, + nfp_fl_ct_handle_nft_flow, + zt); + zt->nft = NULL; + } + + if (!list_empty(&zt->nft_flows_list)) { + struct rhashtable *m_table = &zt->priv->ct_map_table; + struct nfp_fl_ct_flow_entry *entry, *tmp; + struct nfp_fl_ct_map_entry *map; + + WARN_ONCE(1, "nft_flows_list not empty as expected, cleaning up\n"); + list_for_each_entry_safe(entry, tmp, &zt->nft_flows_list, + list_node) { + map = rhashtable_lookup_fast(m_table, + &entry->cookie, + nfp_ct_map_params); + WARN_ON_ONCE(rhashtable_remove_fast(m_table, + &map->hash_node, + nfp_ct_map_params)); + nfp_fl_ct_clean_flow_entry(entry); + kfree(map); + } + } + rhashtable_free_and_destroy(&zt->tc_merge_tb, nfp_check_rhashtable_empty, NULL); From patchwork Wed Jun 16 10:02:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324707 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 530A7C48BE6 for ; Wed, 16 Jun 2021 10:02:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 306526109D for ; Wed, 16 Jun 2021 10:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232272AbhFPKE5 (ORCPT ); Wed, 16 Jun 2021 06:04:57 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232110AbhFPKEo (ORCPT ); Wed, 16 Jun 2021 06:04:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ef3OBl5Qr2vshSmE1CANRL94/vXttNU9YylgJtQ3GnzeaVB39PPkDsInMJ+PlEV+3KlnfMSe4Jlvfx2KO514golh6sHr8yXxMDVHDYvzqxN5oqBBz3grCI+p4ZPyXjtL4mUqy8O/q5nNTJl9gJbWMAYfKs9F3mErWN68LRFvMHjra4DeD5RN4xVr+xj/3mHlzhFCgGXnA15YBE4CdXdwpmIWCd+NqI2PcwsCk+dclt/GWMbM76hnUHomORM5+h/8QcWt+MX1BFguXP/8fye0R0Q7tlNqbPgnq07DeUjd25FO+WMtvvLAN1RDl8ofp7eQzPXeTElVG+7sG4oOVmMGHA== 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-SenderADCheck; bh=6WWEvIETZASNikfojdEylJxGQ6jzCteaeYiYnJliRqY=; b=CGh7/PHh7RDSkvvlgJ/Ea+P7brSOXwzWaf5DZqwSQ0XICbBJGjhTZStqnlCfURa3J1n0lIPrDNuYloTLUNJrqXSeE2U1lV9K9QpY6XkaMru9fsoFYSVij2mHyCJtQnQzjgdiMHCMX6/9g6xvFk3YTvoJ6j2pF+TKYBJaauzp9g2B0RXNZBVBYHreLK35lkcsPidclhN1lkc/bmFEtnzOTq9U1wCFTzVF9vk9Buj4lSxTH0gEmVSteKZjw1CXdvAQiLQaLJwv2rnXcSq5ovC8r5kN/EfBYh4/NnvdpSrPJBYgRTFyX3SF9qmddIyyaNDVFYfOi2uM3YHdF8UpobviPw== 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=6WWEvIETZASNikfojdEylJxGQ6jzCteaeYiYnJliRqY=; b=L3o73i2ryH55Yh2DGC4jkGcJ8DPo4IRORMEYDL7T0N2JM5pSL04lusuDtLyeEEksFdsg7DYm5Lh1M8mu1U4rRU3P/DSL2HB1VMyJOgbHFKa5y2NSVIctaLWle484VjgMHnsusS+a6bpDMKa03GmYTV5BsStZQYCJp4+8YoFt3GI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:32 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:32 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 4/9] nfp: flower-ct: make a full copy of the rule when it is a NFT flow Date: Wed, 16 Jun 2021 12:02:02 +0200 Message-Id: <20210616100207.14415-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66772efb-3540-4d91-8f99-08d930addb69 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y9GVUtnKgx3f/zG8OjXweJERD336xBYR2s5h7XJwalTznVwyI49COReUzzGqryM9ByypOaYrqEXTvVOISYaPwZmy9T+CYSwGzt5+J5Mdxi5CS+/o2D9LS+DP0foxybQfKHzKKEJIIudQvHmeqcTZHmQH6mfolwbmJ/7umY0rym3UNzOHLMYdMIcBRZgYstNIRO2acXhrgdcbRR46zE9hDQJHI9L9tO0vP9/yGJMtNmeKABU5giAm2tLaeU4Fcf3B0S2AIFmswPHLwceRT1106cigyKboGaKbwJqGYTBXi2XOl26UtrqFEU1n3kGOAnotWkgoFgumatzviREmef5smbeKwPkT8nLC6+pMAZJTuq+U0ehF+30TRJ2fJ85ruodcFqbG4Rucp4AZ02pPPhg91p9kWq2Hq2E+vm3WVhU8RMCB5aTb3/EO6DjKXWqKsArMvyWoYKjwFWkxUAVtJhu8dgFnBD1SGOSIyLvwDC8GU9JmQX73O6O+yeps6b00waVcnJ0ovhPfAvdpIMgrPP1OYBD6Ld5RRSqmORrXsnjOf8Sv4pJrHB9O0fkXDFulT/Y90wIjOdb7q1UGtE2ONbX6lgFaI/AI7ji/tpfFG9RMzebltVA5JyBrBnaMOmaJx7wZ1//ITxT8s1WFKJsTceiRYw== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KuEHRHMn3ujUbSHybDgvCZkb5zC2nYczGlQgepf2U7ljFnN77EUMbwnPcfcxzlxuVX++bqlzUw+9sGb5YEU7uRjWiNwPrudhhvbW31FseQTk778VGsrEGAIN49TFaQvRr7+Vft4EqC4tlv6tp1ig6oUHulouAVuYkLieOc4cWTFHC9VsANxC4q3yS58+i1rT1pIsFDfNJS+VXedZHws8gpY82K9qsIhXc4yOSE00+xZT1b6TL9YucQyuI4+sWfNdV+F5r5MlCuftyCl34bLM0ojn8eIu8P7Ro/hUmKK/O+4bZHv7d6kKzJbackrXC2i7YyRqM84p1KtZZ1FdtDDClGj8GBqRQWArynZHlm3FtF+vEbHd1m9fe0WH7FI1J+QNTfrrOyGrBa+LAfwER4fCZxEloP1X5v0Gm3hKkgmWNhbFg1fvMtvt0Xr1RyMF9oYmzj13PypSJV2tmjLrirvUKkXOLOxAfy8wh6JYGvkaQesUK3NSrjLaWeDc9zqrl5jaJyUycTV0s5iLDlKsGTTAbwoQCuQoL9ndxbO5mDoozMlBX6DnMRscG3bRbsQnFSHE5RvAYzZlH/13d8B2EvehrFTD+w9JSDWqag6K856rCISV2BU2U5wmxSKBsI9H0Gd0dCl0uWDq5VNvfL8zmjCqAtAjR9Dq65cixDjg10sgQb9yinF/IQkc0BJb5dbAngoPcjXCgVH1EHFQjRkbqB/jU2+CoaOQDwmvObsrJZUslxYIFDoZEgoPnwKGQNiF3lwwOJytNVGJRStmmtlL9ZU/pbci/rixtl5CZSebhYX+limpef/YBEdIHdKFTc92WgqOb/E93hJ67Z8qyyiZ2cbVYssWiB62IH6j8mmZj5XSD8dPgqH+h050wHwtdfynAEFhcCUvOK/67dvPlS+OxBw+ZvVYh4A1jb3jWpEHNfmWSr3rOKKjp1CqNB/PbBnjDpi/8Yhv57aGgwXD9Bxw9DVf3Co/Lr/7RWDFewgauE4US4RieJuCA3nGVHanyMvs/VJgUFx3TgcGb3ZeD95LLT025FjL/KVel36oB1Zj2TU6NZmokCbQarnnJHgr5WLjWjDMbdgaR8UKkBWj97whATjmcZW/Jew5zoJSQTlGwYVuVP8LmWoMop+wiQl3hHe3SXcbNF4R3wgEUAa/Hk1GMG8pWq9HfgMhUfrlr7Bg73Mcj6ys8hVSjTXOkLUFEcB+JaqW2OCFKnaILuX2m4GvWpeqcBeKQJx6TLB1D1h9Avo27bKK2jSPdUxFN7IHnqOzZZ8CwcmwACdrFO8taM15GjhBom/U/72HCe/C3qCQhOD95Uqfd7vNvUrz6gQiSh9BK3D8Pkii3M+jWbDeRO6H33y0+86+SEYOqgQRi4sc7G40od+MVEHEHYjJAeBSwjFhIXxh X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66772efb-3540-4d91-8f99-08d930addb69 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:31.9295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y8l0AxWNOBpZfAQzF71S8Ch4WHNGnphQcm5um0fvrrIOAG81bDMAZ/8w3cc+L730dWhyZbKI1G6PWn4spJtgBB076f2TUgikaKCgmYYcM8M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang The nft flow will be destroyed after offload cb returns. This means we need save a full copy of it since it can be referenced through other paths other than just the offload cb, for example when a new pre_ct or post_ct entry is added, and it needs to be merged with an existing nft entry. Signed-off-by: Yinjun Zhang Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 1b527f0660a7..2c636f8490e1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -194,8 +194,9 @@ static struct nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, struct net_device *netdev, struct flow_cls_offload *flow, - struct netlink_ext_ack *extack) + bool is_nft, struct netlink_ext_ack *extack) { + struct nf_flow_match *nft_match = NULL; struct nfp_fl_ct_flow_entry *entry; struct nfp_fl_ct_map_entry *map; struct flow_action_entry *act; @@ -205,17 +206,39 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, if (!entry) return ERR_PTR(-ENOMEM); - entry->zt = zt; - entry->netdev = netdev; - entry->cookie = flow->cookie; entry->rule = flow_rule_alloc(flow->rule->action.num_entries); if (!entry->rule) { err = -ENOMEM; - goto err_pre_ct_act; + goto err_pre_ct_rule; } - entry->rule->match.dissector = flow->rule->match.dissector; - entry->rule->match.mask = flow->rule->match.mask; - entry->rule->match.key = flow->rule->match.key; + + /* nft flows gets destroyed after callback return, so need + * to do a full copy instead of just a reference. + */ + if (is_nft) { + nft_match = kzalloc(sizeof(*nft_match), GFP_KERNEL); + if (!nft_match) { + err = -ENOMEM; + goto err_pre_ct_act; + } + memcpy(&nft_match->dissector, flow->rule->match.dissector, + sizeof(nft_match->dissector)); + memcpy(&nft_match->mask, flow->rule->match.mask, + sizeof(nft_match->mask)); + memcpy(&nft_match->key, flow->rule->match.key, + sizeof(nft_match->key)); + entry->rule->match.dissector = &nft_match->dissector; + entry->rule->match.mask = &nft_match->mask; + entry->rule->match.key = &nft_match->key; + } else { + entry->rule->match.dissector = flow->rule->match.dissector; + entry->rule->match.mask = flow->rule->match.mask; + entry->rule->match.key = flow->rule->match.key; + } + + entry->zt = zt; + entry->netdev = netdev; + entry->cookie = flow->cookie; entry->chain_index = flow->common.chain_index; entry->tun_offset = NFP_FL_CT_NO_TUN; @@ -276,8 +299,10 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, if (entry->tun_offset != NFP_FL_CT_NO_TUN) kfree(entry->rule->action.entries[entry->tun_offset].tunnel); err_pre_ct_tun_cp: - kfree(entry->rule); + kfree(nft_match); err_pre_ct_act: + kfree(entry->rule); +err_pre_ct_rule: kfree(entry); return ERR_PTR(err); } @@ -339,6 +364,15 @@ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry) if (entry->tun_offset != NFP_FL_CT_NO_TUN) kfree(entry->rule->action.entries[entry->tun_offset].tunnel); + + if (entry->type == CT_TYPE_NFT) { + struct nf_flow_match *nft_match; + + nft_match = container_of(entry->rule->match.dissector, + struct nf_flow_match, dissector); + kfree(nft_match); + } + kfree(entry->rule); kfree(entry); } @@ -419,7 +453,7 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, } /* Add entry to pre_ct_list */ - ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, false, extack); if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); ct_entry->type = CT_TYPE_PRE_CT; @@ -464,7 +498,7 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, } /* Add entry to post_ct_list */ - ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, false, extack); if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); @@ -516,7 +550,7 @@ nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offl ct_map_ent = rhashtable_lookup_fast(&zt->priv->ct_map_table, &flow->cookie, nfp_ct_map_params); if (!ct_map_ent) { - ct_entry = nfp_fl_ct_add_flow(zt, NULL, flow, extack); + ct_entry = nfp_fl_ct_add_flow(zt, NULL, flow, true, extack); ct_entry->type = CT_TYPE_NFT; list_add(&ct_entry->list_node, &zt->nft_flows_list); zt->nft_flows_count++; From patchwork Wed Jun 16 10:02:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324709 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 EAEBCC48BE6 for ; Wed, 16 Jun 2021 10:02:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C79F261246 for ; Wed, 16 Jun 2021 10:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232323AbhFPKFD (ORCPT ); Wed, 16 Jun 2021 06:05:03 -0400 Received: from mail-mw2nam10on2094.outbound.protection.outlook.com ([40.107.94.94]:30432 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232223AbhFPKEr (ORCPT ); Wed, 16 Jun 2021 06:04:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FDRQ738bSD57fO5REYbW6sJHIvJ6FIJhpTeRRThyxrjvqO53nPuOfP3KmicaLrp/WhMQAofV6KmH8ljvdJbMuPa8giCh++khgr6KU0FvP3+3o6oUHbSnxkAUZEXQoezjNfnYvgWHR5wymcAPZhIBJ0as7QlaeJO+e9T1hJdURPLHEgDcZ3mEjMI8scVRH3xk/tqdSd2WgAoZZCN6ZXKvxlRAoTuBSxjo49RvIOM0Me+4WNIpvCseqXrAygUuOsIgOM3FkQIe13TwhlrRbFUvtXySO0DDA10BZk3+O8dmwRW80oc2N1gAqevW5bi4M9VFqS+iNo2vULAz+lbQRvRqfQ== 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-SenderADCheck; bh=SYMYoYCHUGr1nNeM7orHEPc7JMHLQ0fMYA7u/ktE9MY=; b=XOAg+aTafHkmNQ0g2bZWufIQkgr9WAHGMrgkwm3YsBA1OHSgvioGSL1WvJhQruxzc7wBX5PrIe1udDxapqIJExF1ZGe4t+HJgWE9YG/grmzk62b9jm5G/FWFqjjy+Xw7ziweySCf4P8GJW5e6Ca7uoyPxFndtcco9H7XWZzA5KambbE57/jFA2hLVwBFxqXSiAQ2V3/Wm1kUNjy1gvlLTtNibK+wkr8i+mhOL3oNv84zExdMmaiu2uvK3px5VYAxdpcGKLdYlVWB1x6XJguRnyoizp2+jaVfObFD7eLsxbH0+sUZUJ8b5eumg9Smib90Cb2MvLxkR6r+98qRURwIoQ== 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=SYMYoYCHUGr1nNeM7orHEPc7JMHLQ0fMYA7u/ktE9MY=; b=cvbn7s8jkAHtEf2gEWGXWA99sjwdHy1vKKjJh95D4aCxv+DKO0rR4xk4Aoe2PMYKlzheiPEnvADybOF5qVFuPA0rYhWr9DVqt5yh5hWjUwA4ik9TXsjWHg1wbEWouZgfXpntcDg93GXOivw6k/ghum6YOl1aK5dF7oFli0YDRxQ= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:33 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:33 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 5/9] nfp: flower-ct: add nft_merge table Date: Wed, 16 Jun 2021 12:02:03 +0200 Message-Id: <20210616100207.14415-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72228aa2-17bf-4be4-ac3b-08d930addc5f X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /83iLAbZuuYp0bWTrlCdCeh92Pg/vYmP/IDju5UeC3vguIE+gDiTlspSbJz3ShaH7+9vvW+z9RNYlevzhgskB2J4TuoRh3/07uEaIHUql6EwtQLpyZ/XCFIf4LYwujqvzpLp8OgCReFkW8ncGdyzjpaAmh7HilgNplbKtoixJ0HvaHfCRZ7AlfI1V6CbxX4BZ8CG2AnsxdR0dd0CcaVtgQA2u6sfyYvLVbtmPEuXPWQYoqiRxO43MXYshWnk/RwtwiKre3llD86lHIpA80ZywrQLzzGIxx30P/2xYuzj/6K5KXrcQuw/jRwK2caP+kxKs4bpfTTxzHCbqWTLu9FAgjT8YiC35w3V5TRRIpTGQb7oO3x54XgIkaurOX9MN7vwVRaGvok9CIc0zkorxyRjDKLiK0Mhx3Pqjc11XG1lfK5IPBQvSdBEdQaBGAN8nrc4Ol2Ouvpwx/W7LpYCCiYZC7qBaZREwhd+rOj+LTOiL4ozgRsA+Ib8B/R104NJovXD7SJObns7W9FWY/yCZssfFPbgSOTlIbEAUPc8wIrh3/EwMm4qDd9u2joM/pECszxnUUPPQUfFHo6StNEvqXgmDsZBq+g/iulPva6WECio++0pU6GAPehI3xd7Q/ijVAA8wGeCYrpIstrycyXU9S2lqg== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HBP1xhCbSCkw73aFRuI4WK/klK/EfRqJlWVV63rkNgvn7nbvIiRUH9thPoF4BwEj0p7lKzrSEph6s9eOzx5CFuan/YIjwJIuFMbMs6YfmQZ4JU4crGMsQ2mBmjjNblhLHjEpjewJYt0XlJuyaiG1EJic9RUwUJgu3swaZVUsJN498lwgBHu0UJmGwj/epFh8Vei/9jfmPxPCSjBPIKEgcEDmjIvthK/nrwlvcz20nfsEMzFdjSoPLzdPxaeIMyyyI2JO/kOH788gBCVewnpQD4jT0cT2VAvb6FO6Peam7k41/hXKezeJorK/uto6rvJHLNCV6m2JznVQzJi9bsXgZWjPBk5Eq9qfBUmzv9SueFPl7EkZo/r4ukPkB4KbIqn9KonwbG5997l7tPfCgEflg63EKEaKEFpIN6vCu+P5vCiV1/jXT2meFtl3wOgeFFmNS9u0tocGMIdOt8PXkdgD237W9EU7w88lYHLJCtciVazxJxWtn058+U3NCpvCnFFMoaOa4u9oBoRXrurnDT5HmbOWmK1jFjPvgxwiqzzBe2MoSy1qaVce7g7S3ksBkoebqbANH7bkiukzQsvws24CloYzSsFwtr2YWI8qhUZARWUeBNva52ltGNz0ndMIcrJNsWPXhf3DbgB6Sc+Undx8GNe5f4mO1Qkmw4XdRle2W/aYF6r4OGU6JXrj6UTm5wk5ZUixd5lM/pSUJwVEphRK9j45JU5ELikbcjkKhvfHAiTgkaf+ydYWF6HHUPZqKLMrsRQMaEi+Y/nzZkEOtDwsV3RIyH+nAPUxWT/k6LNMeobxFX9RZ/OZaK+O215qKME3Qll/s5DGgpu3AULaA0xZvk6Hls8SiLVpmuohxLEwcCo253+bPjixkNET3YTdwKLRdQNA/tu1Jpnlw9iQR7uhTG2Xlp8hcDom+xuI/u5Z2Ern9RwGCO1cOv9suWSYqKEUp/aPo/ouLhHh+C6b05cQJeEDlJcRf0n1uwX8MMxzXs7JXNAk9eufW/XBU+TjWLlOYqpHcT4RaOfZ/wgdFhhfcQ3PcfZEYM3n2jQW4FvRKMhpp5L1pMZlWAKcFDFUjvaJ7v3M9nAuQEM8c+yyym+HJuFQ9oGpLIGPugeIEOyBii5Tyk1kZRy5pw387IUbZtnH36t8KBtsTsZ11MP4XLSY4DWlVZUWbLGFp04mo2P3fZIDP2NEKu5fV3vaAU9SHDlWJqQIXSNHbbgykbozqbpvdZhmCI6AERMTLBQ/75eM8voirTgQkgLJel876fOq9BeWAJg1Y9pYCV8VQRtbWkX2ZMt/1tw1ePjKTlyIY0AorjAUk71/FJBa6ARG9jpqUcyQGzY6r/lZK0SDvHk7+bS5gWjluk6m4CUNPcM8i5ctl6GsURmw33W36bPB6MnTumzc X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72228aa2-17bf-4be4-ac3b-08d930addc5f X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:33.5663 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VEwOqvGfMOrXBMAEw4U0Q5NMAniFVPmGwe+M0jaT28DmBEuZnYtUQgRmvo8jNzo8XX6VKbpkf12qWfZCLhlCYEbh5bDgT5xRlMY6Gu8Bu1g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Add table and struct to save the result of the three-way merge between pre_ct,post_ct, and nft flows. Merging code is to be added in follow-up patches. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 14 ++++++++ .../ethernet/netronome/nfp/flower/conntrack.h | 33 +++++++++++++++++++ .../ethernet/netronome/nfp/flower/metadata.c | 2 ++ 3 files changed, 49 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 2c636f8490e1..3ab09d040d4c 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -11,6 +11,14 @@ const struct rhashtable_params nfp_tc_ct_merge_params = { .automatic_shrinking = true, }; +const struct rhashtable_params nfp_nft_ct_merge_params = { + .head_offset = offsetof(struct nfp_fl_nft_tc_merge, + hash_node), + .key_len = sizeof(unsigned long) * 3, + .key_offset = offsetof(struct nfp_fl_nft_tc_merge, cookie), + .automatic_shrinking = true, +}; + /** * get_hashentry() - Wrapper around hashtable lookup. * @ht: hashtable where entry could be found @@ -171,6 +179,10 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, if (err) goto err_tc_merge_tb_init; + err = rhashtable_init(&zt->nft_merge_tb, &nfp_nft_ct_merge_params); + if (err) + goto err_nft_merge_tb_init; + if (wildcarded) { priv->ct_zone_wc = zt; } else { @@ -184,6 +196,8 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, return zt; err_zone_insert: + rhashtable_destroy(&zt->nft_merge_tb); +err_nft_merge_tb_init: rhashtable_destroy(&zt->tc_merge_tb); err_tc_merge_tb_init: kfree(zt); diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index def95c3e8bb7..753a9eea5952 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -12,6 +12,7 @@ extern const struct rhashtable_params nfp_zone_table_params; extern const struct rhashtable_params nfp_ct_map_params; extern const struct rhashtable_params nfp_tc_ct_merge_params; +extern const struct rhashtable_params nfp_nft_ct_merge_params; /** * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information @@ -31,6 +32,9 @@ extern const struct rhashtable_params nfp_tc_ct_merge_params; * * @nft_flows_list: The list of nft relatednfp_fl_ct_flow_entry entries * @nft_flows_count: Keep count of the number of nft_flow entries + * + * @nft_merge_tb: The table of merged tc+nft flows + * @nft_merge_count: Keep count of the number of merged tc+nft entries */ struct nfp_fl_ct_zone_entry { u16 zone; @@ -50,6 +54,9 @@ struct nfp_fl_ct_zone_entry { struct list_head nft_flows_list; unsigned int nft_flows_count; + + struct rhashtable nft_merge_tb; + unsigned int nft_merge_count; }; enum ct_entry_type { @@ -106,6 +113,32 @@ struct nfp_fl_ct_tc_merge { struct list_head children; }; +/** + * struct nfp_fl_nft_tc_merge - Merge of tc_merge flows with nft flow + * @netdev: Ingress netdev name + * @cookie: Flow cookie, combination of tc_merge and nft cookies + * @hash_node: Used by the hashtable + * @zt: Reference to the zone table this belongs to + * @nft_flow_list: This entry is part of a nft_flows_list + * @tc_merge_list: This entry is part of a ct_merge_list + * @tc_m_parent: The tc_merge parent + * @nft_parent: The nft_entry parent + * @tc_flower_cookie: The cookie of the flow offloaded to the nfp + * @flow_pay: Reference to the offloaded flow struct + */ +struct nfp_fl_nft_tc_merge { + struct net_device *netdev; + unsigned long cookie[3]; + struct rhash_head hash_node; + struct nfp_fl_ct_zone_entry *zt; + struct list_head nft_flow_list; + struct list_head tc_merge_list; + struct nfp_fl_ct_tc_merge *tc_m_parent; + struct nfp_fl_ct_flow_entry *nft_parent; + unsigned long tc_flower_cookie; + struct nfp_fl_payload *flow_pay; +}; + /** * struct nfp_fl_ct_map_entry - Map between flow cookie and specific ct_flow * @cookie: Flow cookie, same as original TC flow, used as key diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index a0a0242567a6..621113650a9b 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -667,6 +667,8 @@ static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) rhashtable_free_and_destroy(&zt->tc_merge_tb, nfp_check_rhashtable_empty, NULL); + rhashtable_free_and_destroy(&zt->nft_merge_tb, + nfp_check_rhashtable_empty, NULL); kfree(zt); } From patchwork Wed Jun 16 10:02:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324711 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 2E804C49361 for ; Wed, 16 Jun 2021 10:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1695E610CA for ; Wed, 16 Jun 2021 10:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbhFPKFF (ORCPT ); Wed, 16 Jun 2021 06:05:05 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231931AbhFPKEx (ORCPT ); Wed, 16 Jun 2021 06:04:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n0XClGCTSAbuO3oo48+dWFtmW8wxR012caGFxRrZaMnahE/9LxMRhQmDRWAZ+pXqIOnqgfyV6daO8DJPGP+v3pqVM6fUms0OsEJ2PoCCNiXZU14wBJ97Zjhg5G0FJndNjX5wTOHdIRaw58bMzZLVADQi2PYx8GRc6qQVFt+RGBCfG87miHHyWkIy68DbPG4wHgj7x4Jdi4zo/vFHscnwSnwYfWoik/YRUlBfsnYIc/YdHJQ9BlrRIpoLMBx8RwUeLmCn6Mrm//VJPPJvAUR1S4Otwh4Psuds4LAJS8Jov+euZzQaflXSTsjgmmHVrpumUnVkN/N5NvJPJ0uU4dcg+A== 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-SenderADCheck; bh=Bc91i0xtuHqREnaM/aV4kk6GdZxHUp2FJJ7EM/j6CD4=; b=ZcwmwXUk9Ucs0NgaILj9yk0ZfyAiXSjERLuhekJxle1oZweR2zLQV5I241q181/bWygXZINcFkg3gr2v4qn8QMNYlcLxKjQ2B9ezX1JC6CVqb1gCHRWPM7UMCb5GbzkPdKuIVwp6PZ6izc1FwNIpWbopXIZ0gND4RsFXT51otU+qUAcqqs1IDjd8OPxiSgMZJkEWnJ3++FtVA//R68PlW2ahfZHBSuGshjaqWrkPsynxdxmWx4DTIG1jMoev45EaQb1b6aCwKgZMyp+pmbrdhvcB1ue0Iink6D6d1MTUhD+ThP7h9k7kMaYTStsDWzRCsl2pg1/KUa5aH1e31fIv5g== 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=Bc91i0xtuHqREnaM/aV4kk6GdZxHUp2FJJ7EM/j6CD4=; b=jgLu1VOmuOUIRfVwJrgMzcICv50SqEvS890PfGKceUk1ydlWu1sw6XVUNg/VA89Bv9AZT2KP8EGvtvXtHtG6uFFxIBh+sCvYsjngblLw0lm/QudlXOdvwQSe80TjMTJAaVGmJutgsYeMpNFDhd7HoRBUCYCAZXFtPW5EX/lcYPg= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:35 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:35 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 6/9] nfp: flower-ct: implement code to save merge of tc and nft flows Date: Wed, 16 Jun 2021 12:02:04 +0200 Message-Id: <20210616100207.14415-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d7501c9-c03a-45fd-1a16-08d930addd5b X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FDA16UFyfn40u+W16deDjnxpinkp6FPHEFQpOpvepS67X5be7PSvX/oJGbXGDqAhPXuE4E9xQmarGbkXbIOn/QkYySXtYSNi8P09EAOKWXSBCzvj4HdmVEYoB1dj4itIc1egSaLKItnUniS5jMi2TIGo1vkCFkE3K0YFkXll0L2wzzSWXWj1u8/Cb9Y8xd3Vhw85MBpBvurzJl+yDCGIL2vFjmn1OE1Tmz6U3reJkd9GWNTaOo0vtEwJm8tpPYj9KojTimhbNgd42Iyy7bVyO4ajRCy1KKVh4HiwK0su/IhNizh9VsHCsj5AiV0PKrUZns3C+IX6tOtv9kaL01eZl/4wmUw4bpSoSn9VFSGGXQgrI7rSgw1QU3E4gqHX9HC2lgadBK9Xb6jAO2CtwkTsZc/BL9O+yiTxP4tw6EfAiP4PjgMQG1Eu1SooSwFnyrNQr4ytcJqoHPZkKBaTJ77JK5ToFxzCtz+vnX6QCUEASvlWGgqj4FsyQ6WxUYcz4K5IXSSy+2HXFrL8teawXkX/fsLCBMCRxuPR1+wALT0x17SPBtv6tJbQ869Q/J9Xc0UNctDJLls4i4/Xfn1OimjR7muE/XXYOTXzy3YrL3mcEbbimGNZ4QNz2gEgJZ2k7bg4Bq755VVYoMXkUhSJKs9ayg== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qicpwqeHxjg45Pat+x4kPPpVVNbOexHBMIBTUL76uozvaaUtNw7D46gGjO/NCGcoFPMjyPwAEOE/R3lzz4amaoNHSYrBoEYT14fTIc1m6PiOTBSY3RV45SuOm6JX75xSLAj4uVl/89x1NvpRHFsvt3YOD4qNNR0Zx5GiGPeUqgxfdZx6f6rmh2waYoKAXD8dWhpCTb3m4Re3XXWhk7svkuJZJMR6myTeNX5i6NeiaROTfqN3HzLc6ocKUjZh7KDb1UqSIGwygeuTPrY/6GqPUN5RQBLKIKPGbROqzK4JyRsVgCK9tC8/tCPCMSExiI2AbRA+q6HscFzNYDLO+U5DafVk8ZC5zw5BmQct65TGVx2SpiFHzpW5x8LOkYpZ/rWBFyrxZoLhu9Yxm3hJ/GyW3OA0xMlFBtey188D6EyKRxx5LBqJzS3agFnuT/T7tGfyFYZe2UI1UsxEA5FRwEgrhomXWcXVWNKNVyas6kXfFSyKGERrds8t5eBiGi9e3VY6MlOkVM+oMch2tlhVQsN6nQKxp/MTKdDT+qvbeGPOevcXsYgc8Iedoxsnvq5GhCKShUsSf87dEo2kkBDsuId8sCXgaAB5xVBE31K/UKGdcV7ZqjHbjf00NIxMjb6Zrj6LkIryYnf1CWlal2vB7AurJ7qWT1HjWnA9DM8uoi9upc2EtamxKdcsOoi1CqmPyroLQEgsvpAmy2otHA0kXDWeO3ew2hh+5cPpQPuyPkUDYq5lcFcwb1+AyI8XZHPbzpwiPNGjsO6C7uv7R0aqfLtsmzuuHsLCNNdbHyJidy9BLFG9GbOBQqvsVzaF3BT37ZTki4GVNdiUL4MeyenNUzfrTU70Ci7ZjlFG1iTfbxXlzRB/BU0mAy1I22SyI2ZqMokDqzlOJH92dfbJq3UntUIKYaB4r8vUI60EQ2+p53EcQunnRngBDSJKiQFvhlJ6B15a80QQ3yeXLj1feNyDUs2MoNAG26ZGPxhRqlz2ph2v5H/BLyylf6xwPyS7GJbAAhybDj70a3c3TmM8ijBlerToFS96N9cIkvB/6+0uQBrgqsxGx7fRLgYhNmeneNZAQQXEdBHBixIKmlrHd9CY7tA6aZ2LLibvo6k/eea+gLHWQUF9wUYtiUmFzrIDmDCr8r6bgsW766Hx9QZGkHOV4+i/rhgh1KQUvPJFvl2vWlE9Bo4LjSgsge5s+TdU7XUb5f72c5q1KzSq21i9AHvwUJjDAmvNPTWFEefM3mrv3tpDaEvQqW4iFZFWZUVk+/s4VSU6Tg9vHnb1yxVIicQbyiYOCfoDvGYxoVOM/a7mH5JMRsp9QQwOGEJxhMqiHm0Pkmi1xRX4OazS86A79//tWx2zH7Qvf2e0OJuy/EGJVpZG1HLjsLR0OTPjGxwudI7MEbmD X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d7501c9-c03a-45fd-1a16-08d930addd5b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:35.2041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zBwbHzsm8Mla5fWbmzKqOWrVD1bklEvjxp11Iz+pFxIP76x7VcNeXDBfBj3X5p3QwTR0yalBfe78Z+HH0FlPXFPRm6dC2YA9CY4ZdTdkM9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Add in the code to merge the tc_merge objects with the flows received from nft. At the moment flows are just merged blindly as the validity check functions are stubbed out, this will be populated in follow-up patches. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 187 ++++++++++++++++++ 1 file changed, 187 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 3ab09d040d4c..e5d5ce7f0ead 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -78,11 +78,122 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, 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) +{ + return 0; +} + +static int nfp_ct_check_meta(struct nfp_fl_ct_flow_entry *post_ct_entry, + struct nfp_fl_ct_flow_entry *nft_entry) +{ + return 0; +} + +static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) +{ + return 0; +} + +static int nfp_fl_ct_del_offload(struct nfp_app *app, unsigned long cookie, + struct net_device *netdev) +{ + return 0; +} + +static int nfp_ct_do_nft_merge(struct nfp_fl_ct_zone_entry *zt, + struct nfp_fl_ct_flow_entry *nft_entry, + struct nfp_fl_ct_tc_merge *tc_m_entry) +{ + struct nfp_fl_ct_flow_entry *post_ct_entry, *pre_ct_entry; + struct nfp_fl_nft_tc_merge *nft_m_entry; + unsigned long new_cookie[3]; + int err; + + pre_ct_entry = tc_m_entry->pre_ct_parent; + post_ct_entry = tc_m_entry->post_ct_parent; + + err = nfp_ct_merge_act_check(pre_ct_entry, post_ct_entry, nft_entry); + if (err) + return err; + + /* Check that the two tc flows are also compatible with + * the nft entry. No need to check the pre_ct and post_ct + * entries as that was already done during pre_merge. + * The nft entry does not have a netdev or chain populated, so + * skip this check. + */ + err = nfp_ct_merge_check(pre_ct_entry, nft_entry); + if (err) + return err; + err = nfp_ct_merge_check(post_ct_entry, nft_entry); + if (err) + return err; + err = nfp_ct_check_meta(post_ct_entry, nft_entry); + if (err) + return err; + + /* Combine tc_merge and nft cookies for this cookie. */ + new_cookie[0] = tc_m_entry->cookie[0]; + new_cookie[1] = tc_m_entry->cookie[1]; + new_cookie[2] = nft_entry->cookie; + nft_m_entry = get_hashentry(&zt->nft_merge_tb, + &new_cookie, + nfp_nft_ct_merge_params, + sizeof(*nft_m_entry)); + + if (IS_ERR(nft_m_entry)) + return PTR_ERR(nft_m_entry); + + /* nft_m_entry already present, not merging again */ + if (!memcmp(&new_cookie, nft_m_entry->cookie, sizeof(new_cookie))) + return 0; + + memcpy(&nft_m_entry->cookie, &new_cookie, sizeof(new_cookie)); + nft_m_entry->zt = zt; + nft_m_entry->tc_m_parent = tc_m_entry; + nft_m_entry->nft_parent = nft_entry; + nft_m_entry->tc_flower_cookie = 0; + /* Copy the netdev from one the pre_ct entry. When the tc_m_entry was created + * it only combined them if the netdevs were the same, so can use any of them. + */ + nft_m_entry->netdev = pre_ct_entry->netdev; + + /* Add this entry to the tc_m_list and nft_flow lists */ + list_add(&nft_m_entry->tc_merge_list, &tc_m_entry->children); + list_add(&nft_m_entry->nft_flow_list, &nft_entry->children); + + /* Generate offload structure and send to nfp */ + err = nfp_fl_ct_add_offload(nft_m_entry); + if (err) + goto err_nft_ct_offload; + + err = rhashtable_insert_fast(&zt->nft_merge_tb, &nft_m_entry->hash_node, + nfp_nft_ct_merge_params); + if (err) + goto err_nft_ct_merge_insert; + + zt->nft_merge_count++; + + return err; + +err_nft_ct_merge_insert: + nfp_fl_ct_del_offload(zt->priv->app, nft_m_entry->tc_flower_cookie, + nft_m_entry->netdev); +err_nft_ct_offload: + list_del(&nft_m_entry->tc_merge_list); + list_del(&nft_m_entry->nft_flow_list); + kfree(nft_m_entry); + return err; +} + static int nfp_ct_do_tc_merge(struct nfp_fl_ct_zone_entry *zt, struct nfp_fl_ct_flow_entry *ct_entry1, struct nfp_fl_ct_flow_entry *ct_entry2) { struct nfp_fl_ct_flow_entry *post_ct_entry, *pre_ct_entry; + struct nfp_fl_ct_flow_entry *nft_entry, *nft_tmp; struct nfp_fl_ct_tc_merge *m_entry; unsigned long new_cookie[2]; int err; @@ -134,6 +245,12 @@ static int nfp_ct_do_tc_merge(struct nfp_fl_ct_zone_entry *zt, goto err_ct_tc_merge_insert; zt->tc_merge_count++; + /* Merge with existing nft flows */ + list_for_each_entry_safe(nft_entry, nft_tmp, &zt->nft_flows_list, + list_node) { + nfp_ct_do_nft_merge(zt, nft_entry, m_entry); + } + return 0; err_ct_tc_merge_insert: @@ -321,8 +438,57 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, return ERR_PTR(err); } +static void cleanup_nft_merge_entry(struct nfp_fl_nft_tc_merge *m_entry) +{ + struct nfp_fl_ct_zone_entry *zt; + int err; + + zt = m_entry->zt; + + /* Flow is in HW, need to delete */ + if (m_entry->tc_flower_cookie) { + err = nfp_fl_ct_del_offload(zt->priv->app, m_entry->tc_flower_cookie, + m_entry->netdev); + if (err) + return; + } + + WARN_ON_ONCE(rhashtable_remove_fast(&zt->nft_merge_tb, + &m_entry->hash_node, + nfp_nft_ct_merge_params)); + zt->nft_merge_count--; + list_del(&m_entry->tc_merge_list); + list_del(&m_entry->nft_flow_list); + + kfree(m_entry); +} + static void nfp_free_nft_merge_children(void *entry, bool is_nft_flow) { + struct nfp_fl_nft_tc_merge *m_entry, *tmp; + + /* These post entries are parts of two lists, one is a list of nft_entries + * and the other is of from a list of tc_merge structures. Iterate + * through the relevant list and cleanup the entries. + */ + + if (is_nft_flow) { + /* Need to iterate through list of nft_flow entries*/ + struct nfp_fl_ct_flow_entry *ct_entry = entry; + + list_for_each_entry_safe(m_entry, tmp, &ct_entry->children, + nft_flow_list) { + cleanup_nft_merge_entry(m_entry); + } + } else { + /* Need to iterate through list of tc_merged_flow entries*/ + struct nfp_fl_ct_tc_merge *ct_entry = entry; + + list_for_each_entry_safe(m_entry, tmp, &ct_entry->children, + tc_merge_list) { + cleanup_nft_merge_entry(m_entry); + } + } } static void nfp_del_tc_merge_entry(struct nfp_fl_ct_tc_merge *m_ent) @@ -425,6 +591,26 @@ nfp_ct_merge_tc_entries(struct nfp_fl_ct_flow_entry *ct_entry1, } } +static void +nfp_ct_merge_nft_with_tc(struct nfp_fl_ct_flow_entry *nft_entry, + struct nfp_fl_ct_zone_entry *zt) +{ + struct nfp_fl_ct_tc_merge *tc_merge_entry; + struct rhashtable_iter iter; + + rhashtable_walk_enter(&zt->tc_merge_tb, &iter); + rhashtable_walk_start(&iter); + while ((tc_merge_entry = rhashtable_walk_next(&iter)) != NULL) { + if (IS_ERR(tc_merge_entry)) + continue; + rhashtable_walk_stop(&iter); + nfp_ct_do_nft_merge(zt, nft_entry, tc_merge_entry); + rhashtable_walk_start(&iter); + } + rhashtable_walk_stop(&iter); + rhashtable_walk_exit(&iter); +} + int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct net_device *netdev, struct flow_cls_offload *flow, @@ -568,6 +754,7 @@ nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offl ct_entry->type = CT_TYPE_NFT; list_add(&ct_entry->list_node, &zt->nft_flows_list); zt->nft_flows_count++; + nfp_ct_merge_nft_with_tc(ct_entry, zt); } return 0; case FLOW_CLS_DESTROY: From patchwork Wed Jun 16 10:02:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324713 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A31B2C48BE6 for ; Wed, 16 Jun 2021 10:03:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BCD061246 for ; Wed, 16 Jun 2021 10:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232405AbhFPKFI (ORCPT ); Wed, 16 Jun 2021 06:05:08 -0400 Received: from mail-mw2nam10on2094.outbound.protection.outlook.com ([40.107.94.94]:30432 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232333AbhFPKEy (ORCPT ); Wed, 16 Jun 2021 06:04:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dsMuHPNctGo9gxW2ImZTOeV7CyvxpTtv3PaQFzkKlJ/yV2GGnXOpYKlI7nEdQlOJ/Cm3GjG1A5ytJ0yww1W0j3SPjLTAaxeFMOwb0bqujGuJFC2X7UkckaRMrNOyFCxdldfgJxe/sfIhAd6qjPeSCvtFsTh0vk6JKX4c6Sw6QDRmBV21sBTA4S+B3KaMGWc0tcQtMCkr5RuWrGhrMVlF1Hah1cvV3GT0lprmJCWgsmptadZojr/wk1jLCj+qje2DkGztcOgTfiSkZRZoap8BMD20YE0pc32JQKAsP6o28sC9SVCVOvzMOxyQoDCPU1oZ6pYUOZnsuHmFoedjD1dtHw== 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-SenderADCheck; bh=Di2/dmf2vRq6E99DTr8edjSLMNOD9qjiMejaEF4u68E=; b=SYp8HfAvmlPESe34vxeYFsSRbYQH9Ef+eUKKxN4NOTvK9vx0F3L9JpbQhRzMe+ltRMplWUQAgghmX0HOhaO2MUQl5Dm8JFRVoCDJ7ajXpAoZCDsJ57OJFcZOZmEA2BvRxoqnchM0rSpQeQ2BcRLFBMP/qrqkQ+NVKFXAKphb6dTUXJpqFfdKrkOrmacxxUL9lRcjdj5nRMhM8E/msVRiXNtnkVGCJj3+JV6dVa5WrrfdTIpfwr1TaIJuBpO1TU3JlZxAKI6lWvuuyns24N3PGS8C1xXq8PY/4cNE8/Ax8l8jlAT/Egnjq4mv2kiAXM1cp4Sadhu6xKbdYQcK31JSMQ== 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=Di2/dmf2vRq6E99DTr8edjSLMNOD9qjiMejaEF4u68E=; b=QQjgmeTQcAB5VAtdIEaNeRePEjeToNuJNhT5svsnUTNDi+OMkfoyOYz5iBHDzNzit6XZ5tS2qdhKheUGHtywVQBRsRs4pK46KCK1Sa8rnx0RQchq50sINILTo1fJA34UUPIaudtD22/JFZo8DCVrSKeY8vyPFOWe8mWfTTeYYGM= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:37 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:37 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 7/9] nfp: flower-ct: fill in ct merge check function Date: Wed, 16 Jun 2021 12:02:05 +0200 Message-Id: <20210616100207.14415-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69f852e1-cea6-4dcd-6475-08d930adde5b X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PsIbdUjnDu9u0mghlEpcerADi3d2zOLzCQKDEMGcrvTFH5Qz2bloPOEwqqWVxCspaAr1ebzHRfICWmHtClaGT0zMo272YhVKWQMtoBfyG9ZYgReheEv72Wigxhhdfv7RQOYK5j4J7Sqwox3EmXsyp7D6/Qy0rK5VRv+Av037nyI7pdfv9GdAEEl9LkBoKOaATkhgStspBdrdkH1nvsZ61im3J4zWak8HYxSSDNzjnNWaiybSHpSK58u79rJ21MT+68Kljh7qGCxSiAY8p0Wo0IA81WdXJIwrhp5zrcQSqOMpOJG7W+/RtyTf6Wc+zGYNE7qnYK7QV3NwMEjuhR7W6jqSY4mUPpS0l0bvu2XSd6UGwWzQ37rYwvI/xuJnMClptU4iF9cJOPSLkRW7Bc7QVsC+jtsFN75wgVrjRzXp5bAf2O6yG3nIhKozbx2/NSvENeR31c9rTrEl5vC/oI0lBvV1Ij2Ybkn6eecQAIL0EpGhb9kXKBVjaj9NsHW8jDAUu9kjtZ5XqnpmFYE3aNezFXJGv/TnbKKHAJ8JxPAYO6M+mMBxm5mB/3xP1lXUC33SqRenM1f4DDryUGPvHRZ5XpVRG6Ny5tzTPrsXd2YF7gRLZXr3AMsz+y5bSVVq9LZhtk5ZG3SKjVjvOyhg14izpQ== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KkpsApasKktg4rTWAQR1vg4EDC2pa7mpJCi7951vtQpiid7MpV65hhenvPU1VgWm/MwytrhQqTRWztwf4+gDUzx9nDUUsakGWDGktQSg2xoI//3NjQKrdFaFV+L2fkP60bS0sYqIfF83dYbl+JbYX4aOfYYK1N2AgjBFrwk2uZNZErPz7m377MMooEdn3+GfKpAJQXEyNbGMM5z/ZMb1fiuQi3ttCdWaof2NV7IK/LnePxfyQXk6blGFbwE5v/fgNgx64Dz91OtX3G8vSn8ePaTVwj9Ms8nkqROXYdWZzxoF3TXC4IIv2gSbwOqumtQ/oS++3nm9KuSmUAkVXr6ahExsWo+YWOwh+p7Z7uqIaQoOg3Hwtx3Irz6r7ZjWagUBNvIGQq7MQntMlUnu7d8i/5z8XZ16VNAeYnp1DdWCb8Ir0YpjwevojO3eVxc5BCa9MwJQr8kEDIzSQ58FO8IW5qK6VaJu+mg+L5/F0K+lFr3RJvBjhL86Wp1b4WKKQF7nt6GrF2W1HdznGH2QyNVJodMeJZmX2D3XIIMNb7SGKXWO1b/8w+WqAye9H5MbdJm4Bu+VeWjL9VUZpUZplu5H6p4XR97wl2Vtca8OR3TGk1p+8HIi+BJxG3RfNx8hLdPx9ibTEG+o54D7W1lcKCBbApSBazrtqL23OnzcCBaqiyBbhhXi4DDOo8Ci8HOgOoC2pUWYnE6HLeDzNwVRv3E7XthkW9pbIiTi21cfYQbwJwiieZhrvxtCeXwthh6w8pnFa0y22uT/6ina5zrue0gMGZ4LIxugE1OmYCerF0KAd8xLBY2mdoXfLIFPwujtjeovmL1mS8HcSyooOUm2KloUm5TlKg+qACPzyZTGdnXkZ3tWHiBQMu0ICS0/krUHn08WvjAE4HFIEzL0q6CeRHOjIq/ptzbPOlCP2vj8xPqmMWiT9W5a2V+S5EcW8lA+3cj1YIruOC9keSWaBqamEZmtugykIAsRhC2jIiymlLdAilr2dt0B6Ku+s9BjyeD5ziumvEB9xClV8dSLGWJ3xJMPgWx/3w6vZymLPH06qT7tCe3sKALkpVEgT1Cilf0bkRe3wJO4RXWQVCin0Ktq1S6htF/3Add5M+gm5QzzgHM2fSIJI93+x+NdkYeMAXzK8roT9XRYDgMMOdJ3KdIt3O+8ky4fajl//I9Hu7/zfoBK0AF4Za4Dgf+YrxStSOxzIhtkxWoC1C2ewh+ghF63e2jiXGue0FShy5IG/ZGcWLufpLH+itnxWqu22bUol0SeUSzJuvKiRWQ53r0Nb4/tmDhC6CCISTMVUAMm8x0l44T6GW/LdJB0jrLlXlTMt7YetHRziGNzy9DQxu/cm0QccVPNyyrjRWlCTfpYzWthOezkkq9vfN76rOgloL/e9fqa9fvr X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69f852e1-cea6-4dcd-6475-08d930adde5b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:36.8877 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F+dCXC41GFIx7Z/eLeehm5Ry/PjrvWBsDjk8bxnFbK4uxahvugIvpMMJp7eoxZPiLmqW2yj/RA9PTusrk06zjQIxRRJB/9AD8OQ58QgPyWo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Replace merge check stub code with the actual implementation. This checks that the match parts of two tc flows does not conflict. Only overlapping keys needs to be checked, and only the narrowest masked parts needs to be checked, so each key is masked with the AND'd result of both masks before comparing. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 170 ++++++++++++++++++ .../ethernet/netronome/nfp/flower/conntrack.h | 20 +++ 2 files changed, 190 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index e5d5ce7f0ead..8bab890390cf 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -75,7 +75,177 @@ bool is_post_ct_flow(struct flow_cls_offload *flow) static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, struct nfp_fl_ct_flow_entry *entry2) { + unsigned int ovlp_keys = entry1->rule->match.dissector->used_keys & + entry2->rule->match.dissector->used_keys; + bool out; + + /* check the overlapped fields one by one, the unmasked part + * should not conflict with each other. + */ + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_CONTROL)) { + struct flow_match_control match1, match2; + + flow_rule_match_control(entry1->rule, &match1); + flow_rule_match_control(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_BASIC)) { + struct flow_match_basic match1, match2; + + flow_rule_match_basic(entry1->rule, &match1); + flow_rule_match_basic(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { + struct flow_match_ipv4_addrs match1, match2; + + flow_rule_match_ipv4_addrs(entry1->rule, &match1); + flow_rule_match_ipv4_addrs(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { + struct flow_match_ipv6_addrs match1, match2; + + flow_rule_match_ipv6_addrs(entry1->rule, &match1); + flow_rule_match_ipv6_addrs(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_PORTS)) { + struct flow_match_ports match1, match2; + + flow_rule_match_ports(entry1->rule, &match1); + flow_rule_match_ports(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS)) { + struct flow_match_eth_addrs match1, match2; + + flow_rule_match_eth_addrs(entry1->rule, &match1); + flow_rule_match_eth_addrs(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_VLAN)) { + struct flow_match_vlan match1, match2; + + flow_rule_match_vlan(entry1->rule, &match1); + flow_rule_match_vlan(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_MPLS)) { + struct flow_match_mpls match1, match2; + + flow_rule_match_mpls(entry1->rule, &match1); + flow_rule_match_mpls(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_TCP)) { + struct flow_match_tcp match1, match2; + + flow_rule_match_tcp(entry1->rule, &match1); + flow_rule_match_tcp(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IP)) { + struct flow_match_ip match1, match2; + + flow_rule_match_ip(entry1->rule, &match1); + flow_rule_match_ip(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ENC_KEYID)) { + struct flow_match_enc_keyid match1, match2; + + flow_rule_match_enc_keyid(entry1->rule, &match1); + flow_rule_match_enc_keyid(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) { + struct flow_match_ipv4_addrs match1, match2; + + flow_rule_match_enc_ipv4_addrs(entry1->rule, &match1); + flow_rule_match_enc_ipv4_addrs(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS)) { + struct flow_match_ipv6_addrs match1, match2; + + flow_rule_match_enc_ipv6_addrs(entry1->rule, &match1); + flow_rule_match_enc_ipv6_addrs(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ENC_CONTROL)) { + struct flow_match_control match1, match2; + + flow_rule_match_enc_control(entry1->rule, &match1); + flow_rule_match_enc_control(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ENC_IP)) { + struct flow_match_ip match1, match2; + + flow_rule_match_enc_ip(entry1->rule, &match1); + flow_rule_match_enc_ip(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + + if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_ENC_OPTS)) { + struct flow_match_enc_opts match1, match2; + + flow_rule_match_enc_opts(entry1->rule, &match1); + flow_rule_match_enc_opts(entry2->rule, &match2); + COMPARE_UNMASKED_FIELDS(match1, match2, &out); + if (out) + goto check_failed; + } + return 0; + +check_failed: + return -EINVAL; } static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index 753a9eea5952..170b6cdb8cd0 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -9,6 +9,26 @@ #define NFP_FL_CT_NO_TUN 0xff +#define COMPARE_UNMASKED_FIELDS(__match1, __match2, __out) \ + do { \ + typeof(__match1) _match1 = (__match1); \ + typeof(__match2) _match2 = (__match2); \ + bool *_out = (__out); \ + int i, size = sizeof(*(_match1).key); \ + char *k1, *m1, *k2, *m2; \ + *_out = false; \ + k1 = (char *)_match1.key; \ + m1 = (char *)_match1.mask; \ + k2 = (char *)_match2.key; \ + m2 = (char *)_match2.mask; \ + for (i = 0; i < size; i++) \ + if ((k1[i] & m1[i] & m2[i]) ^ \ + (k2[i] & m1[i] & m2[i])) { \ + *_out = true; \ + break; \ + } \ + } while (0) \ + extern const struct rhashtable_params nfp_zone_table_params; extern const struct rhashtable_params nfp_ct_map_params; extern const struct rhashtable_params nfp_tc_ct_merge_params; From patchwork Wed Jun 16 10:02:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324715 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A5C08C48BE8 for ; Wed, 16 Jun 2021 10:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BFE861246 for ; Wed, 16 Jun 2021 10:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbhFPKFN (ORCPT ); Wed, 16 Jun 2021 06:05:13 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:37984 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232279AbhFPKE7 (ORCPT ); Wed, 16 Jun 2021 06:04:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WHwvUOwfLDP6fsPRiz/EPETcgaiJdbqW2o/wEd9FS7ecHOTP6wM1DJ7ApN5rEsZ63vnd7WZtZMaX+N2R9GLDmUw5pHzAO/P3cU0GKJn9RyFs4295Y8EMVfHYwiAZub3Bh/kPHAYX/+fJqe7St9vg4rJc9sZMKCkRulZb8nJbMoo5H+HDjwHRQGzAGPeURNGZ68ESEhGKvZke5rpH+k5fQ/w9l2ru4aAlvDBia6T8E80FXspze2i46S2lRWtSDPKgBwBXEbifK/fRORrrWQWaM5nUMCw+6QQg5lIJpfjmm08bcbCky/iv38SFk06R1aUKirOqopkibXI5QMDFGJ8JFw== 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-SenderADCheck; bh=WBkWBPXkAzdD91b6W43DLCVijcmWHOo2AMsqdXM5rRk=; b=cIoWSs6U9vTHD/l9UXwNPPGRqPzNzE2WAMq0/tSflZ8s5GMoiuM8jDFuK+HG+z/bcIppl7Rr/YrJMfSfwdLGGuO063xG6IlMcXOwVFWQgNdPkuzE3YSxL7XwqzbQcwy3q8Qn7jL5d3GBLF1tlpNkFi+q+8v4Ehf/6q84MtEBCDS1Q1HsXmfvU0yn//2cxc6Hc8JZ0YsiIlO1gteZU3Lx2LVjLXrkr5Z3kO7Qf9eDuaqjcXIwuw6fwUq0MhWJI5YbvIuz36+vYDmE9CKJqocAcTp0jN14rUvfoR8htPITIxfbg+Ve+IjGEnBXmF48TPToBb6ld2jOhRa97PVSew6Iqg== 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=WBkWBPXkAzdD91b6W43DLCVijcmWHOo2AMsqdXM5rRk=; b=pJBwzIR3u1efHyX7a3ymhYbBljGyq9bG7PV++8N0w+ulGKca6uGppAmMBFl9FeEU3uEhBiSjCvGp/g1pYpGDnqeImFlQAECDc0nudZWalhimTqCPESFyljKAsp9vSEAQZRUT7cLmkrIvmMY/i16RlIAgMrrk3v1mtLDApw89YdU= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:38 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:38 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 8/9] nfp: flower-ct: fill ct metadata check function Date: Wed, 16 Jun 2021 12:02:06 +0200 Message-Id: <20210616100207.14415-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbc5d0de-e3f1-47b0-b1cc-08d930addf54 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dS84D8dHX8oBYKnIs//F8e3DIpLFcrW/TIptFk7JaoSRnnIKs9DOdGI2IzqkVoabYJviPtEIJecrz0QyIYf5ho68XFBHQlk0hiWNHXOikufIQtmlMORpOYwn2IH215RTVX65c05A3FtcMyh/SF5jWM7NqMX3xqFgSKp3Xy2okl0SFLE4S8S0ng1rrR/bv+QuOeCdipOgqdLpTdoJoiMmvDzyD7gVQZxbDXsbh7xDL3toBYYzwLSru8H8qx9PA85XdH0yPjmZqbIORM8n8a85DN2iRu8ch0QQX/Zjy3XE960Pw9Y6Jsenv7+0O85bVSlGCT3SznSfeQihBcpjC9hmZWewihcIJGKCCXDOesK4Ui1/kN/QxxIdAE9KQT5LiRwp7Tu4BO5VynZhh5urzcbTKsZJ3qtHwCOUVm8bSRYih1NN13Rp26s+0E/cEBAC6CpEv/xO9z6XJzfpPphDIWJH9N7ho3zWGOov41wk3HpDrBx2mIcsj8geeGIADKNEMqwWbyl/nBBcd3gxoLxC6mFXauNey4RD3EzD9tAwqyEPhawzYYN08kHKmPInAFFdAvUaWSm19SLmUyKdHr1M1MBSOjDFHsbLkzB9s76DE1LvsNpv9ekvbjwOnAdF7UTHn73x7ec0TY4+mDoN2uHKqMinhg== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A6C6S4wdlCYuQRjSd9BpgJfGF3eVywfkC69xuIjs4/hT/k0zaa/0vB7hvZJnl5EdY6C/NHUGICyDI7QW2G5Aphs2HeprgpcRuYBFenwwtBNP6i/jb9CBvEq7geFGG2yOojuZl1fNnOu7Mjofk8/zyYP6kbyafviHViilKiBGB2yXw67VDZ/evRCD9w8jnG3AT4ULRiPEzoCeOUPpgeDruIcV9m/+c+BRVYbdjpCgLl8k0ZPicmO4JytQ8jr6gfHTw6zF+4vJ5WhWNAjuHvzJbt+oIHQgq26Mk4MDt7k7XqYXiuPBGKgxeZXX0Lk0UT9zgdV6P3oYONHcbi0tQZ38brF3po8xBRSFxauiETeSF8KThddh1Bt+Pyw7kh2cCVB5QsJtpyQKUpifUSHGJWcbM7uXeFppH701/AX5I3U7YngCSEagKEWMC8dc2lYHFBz0ZUCMStxtJMxvo+GQfmmDtndbBoqHXWTVlob0SPKc1v4MBA4ZFkLpUo3JWaqOzb0Y72sbhV1J+mjRouiiBeNrXe4fbkGzhwHg1Oad+9EEHPQ78GeN3xESsmzea8enYAh+iEM8kW8lFTTSLiFP01XK3MRBLEntiMeUHYkV8fb1EhY7o6Gj+CTjoFPeN7DrxJRs06bucYbfQExpkHyueGQ0stC1ughSntuonTKgv/ekJhCOkfmPxn6LF1PuwjzesU+bSRcfJroHYH0qivZAytBkGekXT5pCxfdnx0AqpJD6Nso544sK06VF56/aKtk2mZsPtORsNyBnvFP15G5//oCfZaG0e1lMTpVXnJm5Ioh0oyicz0rPvdxDPc6ic3W8wEWIBqZtTRih5CC4l7KSGMy1nSKqL5ytoUP+7vsCNvDWWmoIiL0ah6wWdfdhJm4y5pS8lXxZsbwWbdrNDgfHSZT6HBAOrL0BP+eEmoSe1JGDw3jZJMtW0k/Nlmcc04L2f6ilHz3kde2hGgZEnZMAUK1IlWmpTYWmZLIjs6B8xeyCFon0AkPQSPdtQq8k8S63F2qSkft1yFdw3hkK4qeNL6V0Zm1uKnfZakb047ivtylVjjoT8RT6BhicH+3MCLcoBAH1O7MA3GOSK+Mb4xRbJOUR4V0vrgON/V/qjd1AQv4e31vN5gGF31AULx3V0V1yhR9VEz56h0FK2V/D62/yLIS11oPq1URAzPkHivpcOeTfUpI32G1Q1b4Bn9j0Tuj2VQvy5eLUZ9KPzLN/hZtdYuYbl+vTPegLsz3FJN8Ytknf6lnJVYQQIKKqxPi/sqabF0lmhxCIGlk4DeDvLJukLhCcVj49NdyVouGdCvKuD8DVEU4bH6opqihlC6CkJnnp0UTVKN9yf3E1slngEjPWXNf+oVXP8HiWhauQwwWSTX66I3AQP6PMZYnXqAqHd+qogaoI X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc5d0de-e3f1-47b0-b1cc-08d930addf54 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:38.5524 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GBDhEzrew3LaRENQe4AfcHCRhQA27a+hn5ynnTBXurOmH0X8USYzuBCvYe0Q7X2FtjkKrGzW/j4F3Jdl6J5GmFoOZmrTteyescpFF/VAfcw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Fill in check_meta stub to check that ct_metadata action fields in the nft flow matches the ct_match data of the post_ct flow. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 8bab890390cf..6aecaf41d9cd 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -19,6 +19,9 @@ const struct rhashtable_params nfp_nft_ct_merge_params = { .automatic_shrinking = true, }; +static struct flow_action_entry *get_flow_act(struct flow_rule *rule, + enum flow_action_id act_id); + /** * get_hashentry() - Wrapper around hashtable lookup. * @ht: hashtable where entry could be found @@ -258,7 +261,31 @@ static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, static int nfp_ct_check_meta(struct nfp_fl_ct_flow_entry *post_ct_entry, struct nfp_fl_ct_flow_entry *nft_entry) { - return 0; + struct flow_dissector *dissector = post_ct_entry->rule->match.dissector; + struct flow_action_entry *ct_met; + struct flow_match_ct ct; + int i; + + ct_met = get_flow_act(nft_entry->rule, FLOW_ACTION_CT_METADATA); + if (ct_met && (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CT))) { + u32 *act_lbl; + + act_lbl = ct_met->ct_metadata.labels; + flow_rule_match_ct(post_ct_entry->rule, &ct); + for (i = 0; i < 4; i++) { + if ((ct.key->ct_labels[i] & ct.mask->ct_labels[i]) ^ + (act_lbl[i] & ct.mask->ct_labels[i])) + return -EINVAL; + } + + if ((ct.key->ct_mark & ct.mask->ct_mark) ^ + (ct_met->ct_metadata.mark & ct.mask->ct_mark)) + return -EINVAL; + + return 0; + } + + return -EINVAL; } static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) @@ -727,13 +754,13 @@ void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry) kfree(entry); } -static struct flow_action_entry *get_flow_act(struct flow_cls_offload *flow, +static struct flow_action_entry *get_flow_act(struct flow_rule *rule, enum flow_action_id act_id) { struct flow_action_entry *act = NULL; int i; - flow_action_for_each(i, act, &flow->rule->action) { + flow_action_for_each(i, act, &rule->action) { if (act->id == act_id) return act; } @@ -791,14 +818,14 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct nfp_fl_ct_zone_entry *zt; int err; - ct_act = get_flow_act(flow, FLOW_ACTION_CT); + ct_act = get_flow_act(flow->rule, FLOW_ACTION_CT); if (!ct_act) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action empty in conntrack offload"); return -EOPNOTSUPP; } - ct_goto = get_flow_act(flow, FLOW_ACTION_GOTO); + ct_goto = get_flow_act(flow->rule, FLOW_ACTION_GOTO); if (!ct_goto) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack requires ACTION_GOTO"); From patchwork Wed Jun 16 10:02:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12324717 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 DAA1EC48BE8 for ; Wed, 16 Jun 2021 10:03:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB3F161351 for ; Wed, 16 Jun 2021 10:03:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232450AbhFPKFT (ORCPT ); Wed, 16 Jun 2021 06:05:19 -0400 Received: from mail-mw2nam10on2094.outbound.protection.outlook.com ([40.107.94.94]:30432 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232382AbhFPKFA (ORCPT ); Wed, 16 Jun 2021 06:05:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nM9t0WBjzMD5dDALpGAHMxDIu+Eqo1ijIgEA577kaIJCnZumvR74aQZHR+ZzIf17+I6qLZbe9m0LIH2ab9x0Wb3QwAkI4pn+/cBRMGbxqBMRuvbE+RoWMkHa9H6wnOVqATrKjBgYfGw/XHL3O4D/8/SACZBpYWqH7Wu/gZfznkujRyXx/y04IG2zHoMv/QqbfFXqd+iwav4VnnaSNAafgkjUeqmxEzxSg5jMTkwx8OMa9xtxIIjXcB7Ovd9d2+ladiqbxmYwWvePO3ZPUfLAfnqzBr7zhW/yfiCkX9NGfOFs5GwQnPbw+3vIcwr/4yUVp0ijSelBfbhAWr9OjfOkCQ== 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-SenderADCheck; bh=NyGwdHklGMyTyvLY8oH+q0ulqcXgEdTgoDUI7R6BDDw=; b=JaQFOzjnGFER25tQULRmWzlVkq7LDM+OqvVXHJpEq90wKr3eArYceC28Zkj+WCC/zPfkWMczRBn1yjdFRadFp+tYFtxDfGHaejpuCnReEG0xsUhhGQz4NLk3yrvsFpPqs3+qyf7GKMeN4XGaYp/8TKK9Rpiv0nHbd8a0y2Xv52VOEAa909jtXUR2Md/CvwrRqnYuBhIzThrXcKkmRPA1L4qbGlIfchgzioB1F8DmDIQvTsSaJuWvlsUmyKwm/EdYWIfj8u6iuV1RfcwINvksi25YeagL3UMxu+PaWVpngIQn3Dwpgm51toRDz7knOfNy8sdteoqp38R6nrbR+fESYA== 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=NyGwdHklGMyTyvLY8oH+q0ulqcXgEdTgoDUI7R6BDDw=; b=u7eMwyMmL/G1Vdu+0GFrAKHElIPZuJw2AirAgHFEEsr6ekD4XGmiByKk95AE3jge+RNLiwZWSNAZVGfOFnBse6HPxDWQ1+7LSH4X0rzabvH3fIqfUcHBNR8eDJuYFL+LO/Dk0GUi+fGdzHbrFVjJqGANhCFNXocucRg3/DnGVJk= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4971.namprd13.prod.outlook.com (2603:10b6:510:98::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7; Wed, 16 Jun 2021 10:02:40 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 10:02:40 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 9/9] nfp: flower-ct: implement action_merge check Date: Wed, 16 Jun 2021 12:02:07 +0200 Message-Id: <20210616100207.14415-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210616100207.14415-1-simon.horman@corigine.com> References: <20210616100207.14415-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:756:703:d63d:7eff:fe99:ac9d] X-ClientProxiedBy: AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from momiji.horms.nl (2001:982:756:703:d63d:7eff:fe99:ac9d) by AM0PR10CA0022.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 10:02:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48354757-ee06-4635-4391-08d930ade057 X-MS-TrafficTypeDiagnostic: PH0PR13MB4971: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p4TrMDFveu3YaTTC6xlZM01s1el6O02i1aOwPGMxAJasT9tWtoWgL9H+GbFI0qulxSG8/nH5N7Bz9v7vWHNwAL7B9XwbBNedMQihR6XwPQGza6uQBP+wxmFAOwy+bz+Q5m6JDQwz98+O6CSmJqrGMgiYxwcNfl/iHunRO2Dha4BuFG3WwRLQq6qntw1+RxOt+0iXX60Gx5UAR6NC9wpLAPhALRDWvhkErzuqdogV64gV7XCTB3/Lvrzs2Fk7tMedxpi0hwmFE1qclXnYkFsRHmvgpmenfO+nn5CddLPFNFv4d2wakoyYWryEIgwL7tL79DX/g1/YYQkjMI9tv8a0fonp9LhLp6d0txFcGIbeF924cNlhfVeBKV+kGBncPuNE3Opn7QWcMDj033pigQpS1z15mpOLRvU7WkNFrKeZhXmK8s8864WG5LBE183GHqKOSud7dYzaxjfMPy9wIhPwcCCy7cli4WH3noZbqa6rJYZxgsEDnPSZiyI51KFghd7//ZqCWrwnzVYg4in/DbG0saOKqg8RtgslrN+oZbbIMjHO4P+nbEDKRgOwnX7izPLUjw4uZvWzXjhMe6QvKGYc4M7wGU0jBbVW5qFYdFHiTjQS5vKMMQu6L2mFI1nloiE8lBnWUqCXSuNJk9T6OhXNzg== 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:(376002)(396003)(136003)(366004)(346002)(39830400003)(66476007)(6512007)(8936002)(66556008)(66946007)(38100700002)(4326008)(86362001)(2616005)(6666004)(6506007)(5660300002)(8676002)(478600001)(1076003)(110136005)(2906002)(316002)(54906003)(16526019)(186003)(107886003)(83380400001)(52116002)(6486002)(36756003)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YtPtYg+jI2WxEGG4cNQ7Rm+YrDcJmerGuj+R8ot6zg6jxdHzt1IugrZJ/x7Rl5GgfIV40I/Ma+Cvzt/sWisO+6I/DMLUVGlyAobnU2BNt+dZXdmsmyJqVbPgvk74nMP7/qBJAI91GvuBGPBMG0NYBS9IAEdqscC1lrQLMHVjaEWQOhzX0YuGLAizjpmgiuZcoqJYcJCGUtwsPTL1AWJ+GW5ste/hfcIPWDxgf5W9394cBkvZJ6u+aAzXEjcN4C5lA9BHP37Ug7nI3ul3XZ/1TXRUArFeL8gpDocoEYRHvQeqGPQwe1khw/m+XBO3odCMN6JFlw/t/30jmnVcf8WF3yPOLcTDt2Vza3NYczh6MZxlQ9WrsretU3sJLMQ+A4ohmvC2sfw9gKoiBAHG1yB7LKGdYvM0AGVn+7H4vnmgPMbGvJOU8TpnbZblk8njGPqKS5yKtktK1QS2lOx/SS+DKxvhW0J/JBmbfPVU6/R6hqXnFHVNUdz/Ts2AESOxaotXc703P6KcWygwjx+64PDAF0/zhjYJlsS7mkNRyUulxBRbJAu/2Epl4jc/HW56tLiK1JRg4Wd+9Tod6CnDrrb5NZ4p+N2SxIHmnvhoUqxprt0t9vdWLIunwjZ6eY4t2bE8lg0tVUV98Z0JYebd/8JPU4S/2UKNlaqUFg+LWik1GltE9pyngnrV5edo+LMoARxzlStqQKr1NWp5H0nOgKHaDA4w1YIECijQ56KNK5xM0riO8bjKy1GPCNnDTZXN++DGMHlcZYGncvkIpVBlqD6sU60iD4hHofzmyk1dNndb+3NmripsgJNv3kZhoVSXz4ipzVcT8uJAngSLjrMrtALtAaKGX90QyMVvyZXEG6Fzrd5fPqh5zm+MQ+mQilKWRPt87iZgTVs8EY1gh+kUwKEnGlFHmARPV6GkM5ZTrmXtjFiTvWiS6ny+MaQqbpEw+kPtJrGkHV6RuYcKTdG4GPF1LzyW/adtGb8NVpLy68yha92uYPnQTWd+X1LeYyOhsZfY3Tnn4GONt0Yt6KHCwfiTudMn750bz+x4WRITHwbVW141CY5xFS49yDh6XrnQLiW3MkM28gO8V6mWEhxLrMcjaJ8D3ZfUB9nJCy7gBRyXpmQwiN8TEpFPumqLnRs6egMEb6XgFD/gJk6mEPg6A1mwygfS9GKHUD+7SU1mDwvHew0H3g4kr0ZMRJ1LjuNlQu7tORUtp1MA3z+DyVF1gGU4Hq72QUCyms49Q71ol2vXRACT5KlFNUi+SLh5gnju8Ujlq6rM3UWJOeOGWtZ+UXFSzqOt2H4sfolB/zq+JheyakX6K2jDcWhNkDMwNtDrcYjL3dIUC44qgCk+Ia9E4v1KAqxa8KlLbBd1Es7im43XSTPIyji2ojjG5B0niqDyUly2 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48354757-ee06-4635-4391-08d930ade057 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 10:02:40.2031 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ClRcss6/jrRmVKI28ZAtq83+C1SHWWeOZR/30eFTaLgmAjAgckBQdNmk2EqXjwQKRZo+LhAoUuEoehC+/lgVtm75YJsqKx8VzXb2Js5iKDw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4971 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Louis Peens Fill in code stub to check that the flow actions are valid for merge. The actions of the flow X should not conflict with the matches of flow X+1. For now this check is quite strict and set_actions are very limited, will need to update this when NAT support is added. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 6aecaf41d9cd..9ea77bb3b69c 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -251,10 +251,129 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, return -EINVAL; } +static int nfp_ct_check_mangle_merge(struct flow_action_entry *a_in, + struct flow_rule *rule) +{ + enum flow_action_mangle_base htype = a_in->mangle.htype; + u32 offset = a_in->mangle.offset; + + switch (htype) { + case FLOW_ACT_MANGLE_HDR_TYPE_ETH: + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) + return -EOPNOTSUPP; + break; + case FLOW_ACT_MANGLE_HDR_TYPE_IP4: + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) { + struct flow_match_ip match; + + flow_rule_match_ip(rule, &match); + if (offset == offsetof(struct iphdr, ttl) && + match.mask->ttl) + return -EOPNOTSUPP; + if (offset == round_down(offsetof(struct iphdr, tos), 4) && + match.mask->tos) + return -EOPNOTSUPP; + } + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { + struct flow_match_ipv4_addrs match; + + flow_rule_match_ipv4_addrs(rule, &match); + if (offset == offsetof(struct iphdr, saddr) && + match.mask->src) + return -EOPNOTSUPP; + if (offset == offsetof(struct iphdr, daddr) && + match.mask->dst) + return -EOPNOTSUPP; + } + break; + case FLOW_ACT_MANGLE_HDR_TYPE_IP6: + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) { + struct flow_match_ip match; + + flow_rule_match_ip(rule, &match); + if (offset == round_down(offsetof(struct ipv6hdr, hop_limit), 4) && + match.mask->ttl) + return -EOPNOTSUPP; + /* for ipv6, tos and flow_lbl are in the same word */ + if (offset == round_down(offsetof(struct ipv6hdr, flow_lbl), 4) && + match.mask->tos) + return -EOPNOTSUPP; + } + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { + struct flow_match_ipv6_addrs match; + + flow_rule_match_ipv6_addrs(rule, &match); + if (offset >= offsetof(struct ipv6hdr, saddr) && + offset < offsetof(struct ipv6hdr, daddr) && + memchr_inv(&match.mask->src, 0, sizeof(match.mask->src))) + return -EOPNOTSUPP; + if (offset >= offsetof(struct ipv6hdr, daddr) && + offset < sizeof(struct ipv6hdr) && + memchr_inv(&match.mask->dst, 0, sizeof(match.mask->dst))) + return -EOPNOTSUPP; + } + break; + case FLOW_ACT_MANGLE_HDR_TYPE_TCP: + case FLOW_ACT_MANGLE_HDR_TYPE_UDP: + /* currently only can modify ports */ + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) + return -EOPNOTSUPP; + break; + default: + break; + } + 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 err, i; + + /* Check for pre_ct->action conflicts */ + flow_action_for_each(i, act, &pre_ct_entry->rule->action) { + switch (act->id) { + case FLOW_ACTION_MANGLE: + err = nfp_ct_check_mangle_merge(act, nft_entry->rule); + if (err) + return err; + err = nfp_ct_check_mangle_merge(act, post_ct_entry->rule); + if (err) + return err; + break; + case FLOW_ACTION_VLAN_PUSH: + case FLOW_ACTION_VLAN_POP: + case FLOW_ACTION_VLAN_MANGLE: + case FLOW_ACTION_MPLS_PUSH: + case FLOW_ACTION_MPLS_POP: + case FLOW_ACTION_MPLS_MANGLE: + return -EOPNOTSUPP; + default: + break; + } + } + + /* Check for nft->action conflicts */ + flow_action_for_each(i, act, &nft_entry->rule->action) { + switch (act->id) { + case FLOW_ACTION_MANGLE: + err = nfp_ct_check_mangle_merge(act, post_ct_entry->rule); + if (err) + return err; + break; + case FLOW_ACTION_VLAN_PUSH: + case FLOW_ACTION_VLAN_POP: + case FLOW_ACTION_VLAN_MANGLE: + case FLOW_ACTION_MPLS_PUSH: + case FLOW_ACTION_MPLS_POP: + case FLOW_ACTION_MPLS_MANGLE: + return -EOPNOTSUPP; + default: + break; + } + } return 0; }