From patchwork Wed Jun 2 11:59:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453936 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 C712CC47092 for ; Wed, 2 Jun 2021 12:00:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A2FC613D6 for ; Wed, 2 Jun 2021 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbhFBMCB (ORCPT ); Wed, 2 Jun 2021 08:02:01 -0400 Received: from mail-dm6nam11on2100.outbound.protection.outlook.com ([40.107.223.100]:56833 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229604AbhFBMCA (ORCPT ); Wed, 2 Jun 2021 08:02:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSLw8qLlZ+al+btgkQDoFKkxzze30fXuWZ3Fy3xv4XXIwcfLXTDbGeUKjenZ95VY4eJel9eZS6wpnLUgug6G4WDl8H9j0o/pJAjbYaiumTDB1SxkNHSSzGM6JR6m64+UbPjDPKoxGSmEH6ZpC224cCRsxzi7VQxDDYuSUnfnDJ1EYNxjo7U4opebDIfBpYw/l0OQvz+X5A+LXfFEYQAYCbGa5ZgnGioqkmSpZynpZTRhes3ihGAPrY2WQkIwry9v9FFuJzt9A4s2zS0UYHIiLqzJuODVIQaXTAMqFSieVX3GqaCurIl+81y7fK2NW1X/vPbFVxot+3sGbSxWdUlZzw== 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=abh6auORIQRf9gGa4Nw4JmfejIc2U4p4JyWtRCXEUEk=; b=Hu9ztz8EXHXhqYeo7Co81XwhY06+gEcmGgQK9Gb3JRuUT0ltByHUvLQ5+o5SlnSxJJI54M9E0RYpQEedzaXPMlMmSn82XTk15CtDueciqzgTE+IA/h2HyYuR5vgmMysmEcwH0jwUofAt6xkSLfXzHMtx9t6RUlrIvbJSQL0MZU7QpSaGd2geohcHFOA+qD0NR9Id2TflrM9bCuU9hCWqQqCR6rEdfVaezuhH6e/smV1yW2k7wO5h3BuXmVBdAYdXcrloP8Na68+guMOHDgfYM2AKqm6E5TPCRViWYWmQTEgn8bcFQrMV7buww/4IhHMK+SL+NOpchpTIXufAqMwAxw== 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=abh6auORIQRf9gGa4Nw4JmfejIc2U4p4JyWtRCXEUEk=; b=MXQ6gkHSe5t0GaczeNr1CZWYXAwxoyMcGNM8QZFpr/qN9WKZxY5zRgXqVOxknvPmm8Y4KMyVgH24UE5wYr9OluecIqOgsv5ztABoEX3g1Of5edzOlrc5e6EI4pr1eDfdJgVOD7zltJ4M4rWmlue3GvT/ZyFb+gA5683x7I2ZbSg= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:14 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:14 +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 v3 1/8] nfp: flower: move non-zero chain check Date: Wed, 2 Jun 2021 13:59:45 +0200 Message-Id: <20210602115952.17591-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af554f61-099c-41fc-5a40-08d925bdfb23 X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: 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: 40gUBXXl3b7MmsZBYr41WKD6Vz4uw0qobap0srm2YVuuoAYp4MKqaAKP7Zy6BIOAeBew4Iemw2Qgo0dbR8/YveURNIMBbZmOl4R6pDIx5rFl/J10BnvU1PeCWqZ3w4xTBMTlMi7zj7iFmNMJX06ETh0fnhNSAW6qCZqnjftkgSdVMTeUzGGGyCtESRrpSdYO/O6+z8Uu5AAXHrGFBJpfGU8xWyqBBsiBqCwlGiV540COMSWqcBhVJdJJ0cUnhXdZRKyZ6TgGEgsdQug0ZL9mdqy8umugFQlNJ+xffq6EJ4hXKoZeE4Ma+Rv24UGyvkSR+qMDBtZNjT469ACOvwdk0v/WuR6oc/kY3ZESIsnt1Ssggtzpebcbe7uSzeOP/k6qgJYKpN02amwukqxgQ2C0+MiJcQqy8LJ+z515ANvt7EB2siW4CeIPBPZDFz1YFyu60873ZDQNAjy9+Tw7HPPKvTC3ZqsVhJkCh/jSHbz9oK3VFfGiR+/iHsRbLv54SNEm/OZ5W1+iUmW9wU8lBagy+skfDfpI8edjzll5NmLd88/PxYYUKVqhoMYB0vCIKq6F5rVnGLVANYcPvWElrQU9P8p6ZTPgQ3MVUwLPKNEMxG8= 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:(366004)(376002)(136003)(346002)(396003)(39830400003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(83380400001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: y1DguaeKnn1ZihPbTFa6MEe0qSPDlGCp+z/1P3IB1VtQQvg15h0JqEuInhiVqQ4RQn5l8Cw0D1APCqf/fy1WQefH5hSw/dD3reuX5PbPpIc+GNQ9M/A4gCrylaNrpnKHXc0Efc3PSg0F9Mnpn5iZSMg8Og9LqKJKtzsW103fKeRw1PPnmjn3/I2dww8ygtRFclW8ue4XIykZg//QaJS3WtzzKzp2eS8YcV33f0uUufulanwZTyOobgC/DwHWCOwsCuqZLce7PG1Iz4sLGkSxh+FzhQxk6hS3WqKlNufU9MQcvykBXMi40WaEnrp9+qDVKpu2MgamMVXgm7oKSbd3xeFkzmwHDqJHn+HgioMG/Hn1BFqfkksWeMUsuXvpdVxnZW+63LnJrXm3c4gLCmr8FLUgm7kx1RCM3QloVUYDQ2mb1IgaK+gJOsLj7mIb/sdWs2kcmeG4ji2Ynl9wJ803r2SQuekSOnvEs4ff3R2Z0UHkVywHvDECXFbwhORWN3F1pEpXPvuOnrqJm91TioOTLysV3iH9bSMt3fX2iig1HxPPhZaaVDsTBMOMGzKhyalR3AswcYdclCrDwnQKO1Z9FgBgVyoPU60hrJFThnfGicO6kyaXzbIg+36cZdrIzrr7D6imitZwhpCDwZGLrlinztSkozirqLjyKntGiTXi9kJ43TW2UN/0roKNIMkCAckR3CoeaNyishJUe6RTZY7uKmrEfnfh0dXYiJfaq+9Rkf5Gv7fchdG45F6Sn7rnV8H7KGCLaI6dNoNvZFM15+77mVzoMKoboBawC1ADJxRay3cHwWv2CMZ1v1sUgiRO0f2e8w11F+fO+l1ZSeeBwP2/5zsU1Oj069PebyTIhdvROm6pc/hsEg5+3n9fbIcCoDQoWazoSXAP90B2OtSTU9/kxLFHTAWCD6+BDscY3QGexiSq/NQiVHBnlqGv1e86oDgbd4RKDq9xtArrbZqzLADTMlEFLeHKWIU6Jx6m7wXqdWdHOBX8+bRnKBtzxImfwwNijLDpiaGWq2awYrYNE+z+QNekA8VYUKSfZwKZma2Zq5djSu7DrRY0rpEH79z7NJHDEtHZPh9rrtl1c+H1ECJKpPjUr623ctHsKuWGbb78JrRxVp77l8amCUlerYkEsAMl7N40ap+fcY3nJPM3GyZnZVzVmiDxiEya9WjTynATdP54Fbj37hWladwo8G4oXSw/mvvxz7FriEG4MHzREhQjzZL8nqs/eJhRVbmnVAqR7wRmB73DtII83iYlGHAoIMV6pjMYF5HIXgt34dPA6ApoNDM8yeIYv0kBPTf1WUmLnIFXMVrAJvKmgYhSvHOLvHpDHnDVzoCaLL52+vlHRMl5bqc10t8yTyLwAAVvRuPn7rp3E3MHVGvD+FgfWrEY9sq5 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: af554f61-099c-41fc-5a40-08d925bdfb23 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:14.3424 (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: KuZ0ZlPOXnvEMJxoygKvtw9M0NaVYB1GKB40icacfRRs0OR3XGfQeVNR6HsqPH/+XL/w15rSFZ7ov1aAK7SfL2qA9H7/YN1xxU7Zz88jEnM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens This is in preparation for conntrack offload support which makes used of different chains. Add explicit checks for conntrack and non-zero chains in the add_offload path. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/offload.c | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index e95969c462e4..16ef960a150d 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1276,6 +1276,20 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app, return 0; } +static bool offload_pre_check(struct flow_cls_offload *flow) +{ + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); + struct flow_dissector *dissector = rule->match.dissector; + + if (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CT)) + return false; + + if (flow->common.chain_index) + return false; + + return true; +} + /** * nfp_flower_add_offload() - Adds a new flow to hardware. * @app: Pointer to the APP handle @@ -1302,6 +1316,9 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (nfp_netdev_is_nfp_repr(netdev)) port = nfp_port_from_netdev(netdev); + if (!offload_pre_check(flow)) + return -EOPNOTSUPP; + key_layer = kmalloc(sizeof(*key_layer), GFP_KERNEL); if (!key_layer) return -ENOMEM; @@ -1646,9 +1663,10 @@ nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev, static int nfp_flower_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) { + struct flow_cls_common_offload *common = type_data; struct nfp_repr *repr = cb_priv; - if (!tc_cls_can_offload_and_chain0(repr->netdev, type_data)) + if (!tc_can_offload_extack(repr->netdev, common->extack)) return -EOPNOTSUPP; switch (type) { @@ -1746,10 +1764,6 @@ static int nfp_flower_setup_indr_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) { struct nfp_flower_indr_block_cb_priv *priv = cb_priv; - struct flow_cls_offload *flower = type_data; - - if (flower->common.chain_index) - return -EOPNOTSUPP; switch (type) { case TC_SETUP_CLSFLOWER: From patchwork Wed Jun 2 11:59:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453074 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 2E7A7C4708F for ; Wed, 2 Jun 2021 12:00:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C7B6613B1 for ; Wed, 2 Jun 2021 12:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbhFBMCE (ORCPT ); Wed, 2 Jun 2021 08:02:04 -0400 Received: from mail-dm6nam11on2100.outbound.protection.outlook.com ([40.107.223.100]:56833 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229665AbhFBMCB (ORCPT ); Wed, 2 Jun 2021 08:02:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ahbPa0dHLxxy+iK6pMFBx3FxS/5AwE+TL+MwIHehd2k1OW45dQdbHc4fYgJ3RkbCXb5gg9K+1noC5KJ7CcYPBssaaC7AHZC1XqhzlPAuRUkCtAGuyQyZsTg8mItAB/jyU1GNQYjvJHBIE7MV+wDO4pPNPzq5V1HPYN0ODpOauANwNEVhLSewVp0M8vN5uWH0Ygc7IPOQtjq4+WUtSeoBL7yyW4KcKrKH1uifNlhpOJGEC61gtFPPf51edQ6/cLctuDaNXLO95LLq9d6JCMAm3rEvH3QvX+5gW/6NJPNAhKcmhix8Z0f/rTs+EMIhoZPVwQa5l7BRdvvyx0NTCeEGWA== 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=2Cd/T3tgvy/Mkz4LJjfaKbDo3ToX4TqVnxVAQ3oq2AE=; b=BFLXhPW7+PbeVkGEHEmexKKAeQ2BaW5LPck5XMzbrHnUt5WFbCA+yCbx29xtyKhZHWA/uXiDG0Vwuxm/SdA++KGG9sexPQDT4B/VGsZuAC8QpAtsyht3gNjZ+/dDVFnvbn62szekt6wAL3fgNAgJRorwXYOFqzSq2GQdqZFEfa3w9WexDKXtVK1YVjcTN6in5bvHF6EzqtvmtCyZYwOBol5egRlxpo5xcpTgOBwRkKlOLRvQG9kf/v0hWCJWIdQjtdNkgOAH9V7aaUP36QF+33h9iu0YbSQyE/B6vc501NhTsvgsXoUQcDOXYKm8opOZzwxpfO9vJguAh7fg8E/LVQ== 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=2Cd/T3tgvy/Mkz4LJjfaKbDo3ToX4TqVnxVAQ3oq2AE=; b=cMiurRpir0s50Q16wD+dohNfKUFHkrsN3Nj44PG9aOW8KmG/9Qq0udB98kvUz3+KujjKR5eYhHz3fO0z3nX1/wSw42KoAZLw01mzEgryTqrCzG1b4RRpMIiclL4mnn9sVWno0886TyL7AFIb9RO3ODSvBpMbFSw1W61X9yFnXg0= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:16 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:16 +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 v3 2/8] nfp: flower-ct: add pre and post ct checks Date: Wed, 2 Jun 2021 13:59:46 +0200 Message-Id: <20210602115952.17591-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d09c6fe2-dea1-4f13-a7f4-08d925bdfc28 X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+bDig2+o8RMxhk1Nzqg2MpogHI5wjeOKtbwkD4qZmOx9lE1G9LgK+eFjDy45YzmjTGtYq46IkZgno/z+/UPZqU2PoNbeQ8P4WuDAeF6hj0GKEHRQzTGF6yTcrJiBNjiU4YIeP1hsnGGfAmiZ/+7WR4ZZsyIkqFWV765YF+oq7aQ3DUzg4if3NPG1gs/ty606k0tiov6KwHBKvhZrqk7iEQcrR9ojcuokErwxb1gPOVDx8L5M9/75w9RrpLd0GoyBmcsDiTjwqwEoA1TtUkrfiN5CssEihefMy1WWv9olurciDAnKAlLUvOg+fvrhzgLZyM6sesvRiiNWm1I0tzGqLMJgItBVLJMYDoHA3ToOemHgMdwbSVyeQjZasGKWyzDygpe+mpmqEVUvwzoOB4JGovlpnZqdQ1npWuhVxO+9R7MovKM8hieNbc9kg2WpyRBQ6N2ciU1D2xzf8yOOqAr0Lp53mLD5CoWVoYs0NFJ+wsxu1AS2aahwrpMlojrCw53FD38tu5cpAhsWAfyiTzDu8UXPAdCO9Nhats4udlIWPvz3NWvAqiIOL8qC3BVb3gE9tPg8ANx9pb0CVtv57WCRznLO7MXD8D9R5eAn707VCg= 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:(366004)(376002)(136003)(346002)(396003)(39830400003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(83380400001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: yqn/xi0Mf0LZx9nFPMqDfrifAIujRGEAYeM0KvGFzOX9QqQff0J61p5re50WOMs9KL3rskyg7wH2Wt+BfK7x1VCgM0WhBgVUQu7IVSa0yH20s4haJ9GrR8J0cuHBDDZMQgB0+bVbIkKaMXFlU/3zPi+yhO8HuvA+uEkOcsZjMmeb2uLedQgRqi0mbCCBLxGFPgeKFZg+gcoFHaJnN8EIQWbl+Glta/Zjgy+ez0V29JLjRh5rZe7Nw6YXn3SJhOidBtSbtKRnKdtYIHUhMVFetCTkzbh0NP+3hV2QYCLItQixe7sionIuOVqgruaosUSW+5uBzUTUcA6/ZEtJzHF26Q0TUP4KPgi0SBjj6ZyW0rviJg55iJWXDPBcpYpS0MGmM8RELQWTpIewjpnI/JwkcsRarnzvkTK2GM2tzTqpcpNhrPxakKoWIG56ix9dpSdqnWVkB0foqG615M+JodjPoUu81Om+qn4n9nJ3Ygzy4HNtl2kqkAf/ATocLYHWNLkkxHr0Yf+KNkhTKdtgXkihGgiGqp0Uf0aOAIQqQtm0BvNQN+8wfeyO1w952VulOaZVYNS7o4QCDe0aOIiP+4JKcW5ZrBpCX/rlW18bFeX68y3h8/RNOlzMNFfXHn4bqeCexmLRclx4QxSYB9/bURuLjOTFvWVzphaGU+5sH+/U9Dvi7kKDE7/1XA+wmRg3nvleFsoVjVKJqheqwC/ctBuO1siT6v9G6EtU1DJcZXfa1k1a7rnX2n7Viz80ygs3kzrBkKxSgFGHwi/bCUjmHL1qnMua/w5VFoRLHoB8Jfi+23zzbl5zqIpyr5KROs7R9AEtVqYYiCjFsBwfdG6rBXeY9UVqN0eDSqvuClh1PDg9HitjZrBhdoEVatAXFcy0OYWlFLndkqcw2qzYPhQMw6VP8kZiZGVZNhupLwTwFHtvtFt0CiF06F2ITv0tCaLw2w2vWagAi+KCvOkxElyeyj3eR8QXimO8NtXoDQkWFrFTZj9ghAia5bzHRYkA/yyFf/BjwFbnsG0fwnHes4zHFxGO9kBz9792j3MyYtaDRInpS22gvGHWDJhvyaMKRF9mvzOKkth6LlM14h+AD9+3w6ppcqPJ95FI2yw5ZFKtXSDLhBuRS441kstDDbkI3L+son8bUVK8zULo0STlVHcM5NeuiD/HSdt8ohsD4Ul7Io8VIv8oM/CB4OkL7CiErEpXNS1D/IGF6VhgvPe4xxOjCETDr3nLCGd5aS4u3Ri/06lh9cxl+1tXcbVyWxwRP10MRd8xQA4NUntxnRtJWs8kFPONMP0OlnPi9WneBmdfMUCoYXlJ70ADE9tWaw2eux/tyjXwNP6shOQyauxVEN+98ZmcbK4GdhRRwzfiZfiVt8lVwqScythS2ICQve0z3Yi2/STW X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d09c6fe2-dea1-4f13-a7f4-08d925bdfc28 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:16.0439 (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: bNmtPNaSfEsGaU0r1M2JJyeRV+hN18V1vEDFeJgbmALUZgMoJD4Mpd1/4vkl9mSavinVuMA9l/w2APr8t5Qf/dCj613LVzDkdtEbG+DuNME= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add checks to see if a flow is a conntrack flow we can potentially handle. Just stub out the handling the different conntrack flows. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- drivers/net/ethernet/netronome/nfp/Makefile | 3 +- .../ethernet/netronome/nfp/flower/conntrack.c | 48 +++++++++++++++++++ .../ethernet/netronome/nfp/flower/conntrack.h | 45 +++++++++++++++++ .../ethernet/netronome/nfp/flower/offload.c | 7 +++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/netronome/nfp/flower/conntrack.c create mode 100644 drivers/net/ethernet/netronome/nfp/flower/conntrack.h diff --git a/drivers/net/ethernet/netronome/nfp/Makefile b/drivers/net/ethernet/netronome/nfp/Makefile index d31772ae511d..9cff3d48acbc 100644 --- a/drivers/net/ethernet/netronome/nfp/Makefile +++ b/drivers/net/ethernet/netronome/nfp/Makefile @@ -51,7 +51,8 @@ nfp-objs += \ flower/metadata.o \ flower/offload.o \ flower/tunnel_conf.o \ - flower/qos_conf.o + flower/qos_conf.o \ + flower/conntrack.o endif ifeq ($(CONFIG_BPF_SYSCALL),y) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c new file mode 100644 index 000000000000..aeea37a0135e --- /dev/null +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +/* Copyright (C) 2021 Corigine, Inc. */ + +#include "conntrack.h" + +bool is_pre_ct_flow(struct flow_cls_offload *flow) +{ + struct flow_action_entry *act; + int i; + + flow_action_for_each(i, act, &flow->rule->action) { + if (act->id == FLOW_ACTION_CT && !act->ct.action) + return true; + } + return false; +} + +bool is_post_ct_flow(struct flow_cls_offload *flow) +{ + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); + struct flow_dissector *dissector = rule->match.dissector; + struct flow_match_ct ct; + + if (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CT)) { + flow_rule_match_ct(rule, &ct); + if (ct.key->ct_state & TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED) + return true; + } + return false; +} + +int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack) +{ + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action not supported"); + return -EOPNOTSUPP; +} + +int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack) +{ + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack match not supported"); + return -EOPNOTSUPP; +} diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h new file mode 100644 index 000000000000..e8d034bb9807 --- /dev/null +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* Copyright (C) 2021 Corigine, Inc. */ + +#ifndef __NFP_FLOWER_CONNTRACK_H__ +#define __NFP_FLOWER_CONNTRACK_H__ 1 + +#include "main.h" + +bool is_pre_ct_flow(struct flow_cls_offload *flow); +bool is_post_ct_flow(struct flow_cls_offload *flow); + +/** + * nfp_fl_ct_handle_pre_ct() - Handles -trk conntrack rules + * @priv: Pointer to app priv + * @netdev: netdev structure. + * @flow: TC flower classifier offload structure. + * @extack: Extack pointer for errors + * + * Adds a new entry to the relevant zone table and tries to + * merge with other +trk+est entries and offload if possible. + * + * Return: negative value on error, 0 if configured successfully. + */ +int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack); +/** + * nfp_fl_ct_handle_post_ct() - Handles +trk+est conntrack rules + * @priv: Pointer to app priv + * @netdev: netdev structure. + * @flow: TC flower classifier offload structure. + * @extack: Extack pointer for errors + * + * Adds a new entry to the relevant zone table and tries to + * merge with other -trk entries and offload if possible. + * + * Return: negative value on error, 0 if configured successfully. + */ +int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack); + +#endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 16ef960a150d..7e4ad5d58859 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -7,6 +7,7 @@ #include "cmsg.h" #include "main.h" +#include "conntrack.h" #include "../nfpcore/nfp_cpp.h" #include "../nfpcore/nfp_nsp.h" #include "../nfp_app.h" @@ -1316,6 +1317,12 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (nfp_netdev_is_nfp_repr(netdev)) port = nfp_port_from_netdev(netdev); + if (is_pre_ct_flow(flow)) + return nfp_fl_ct_handle_pre_ct(priv, netdev, flow, extack); + + if (is_post_ct_flow(flow)) + return nfp_fl_ct_handle_post_ct(priv, netdev, flow, extack); + if (!offload_pre_check(flow)) return -EOPNOTSUPP; From patchwork Wed Jun 2 11:59:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453073 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 C6104C47092 for ; Wed, 2 Jun 2021 12:00:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9941D613B1 for ; Wed, 2 Jun 2021 12:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbhFBMCP (ORCPT ); Wed, 2 Jun 2021 08:02:15 -0400 Received: from mail-dm6nam11on2124.outbound.protection.outlook.com ([40.107.223.124]:2142 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229533AbhFBMCC (ORCPT ); Wed, 2 Jun 2021 08:02:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zbga1k90hgcLqrbJrh4K4LGfdVLA+ziZGmN9M4+aeaTCzRkNTolGQgdL2H0XAh/x8LMwbooT28Gro2Yb7k8+D+VahJwXXsDYMBCxz1L92QzGIwLbwagODSRUewjgCCP9E9pCznLmD5+Eegv0R5cOvIywxQ92Is41FEvt0L7qVv/AbUXRxKsMLRcvj9vlcWJp1CCL0uMolHPJKwrypA/9vJEnBcNDShIC1cGMJiff5MPz1QLJySTuuRI6b9cKX1YNnGnCa8aR8c/4NPVUcBgLQzPXwHqzp8ByhBYcWYAWgEfYXMQMfY5ir6KGrE5VpRyzuvVMb6iIJ2Qg1FLIxtp36w== 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=rcPkcOJ7LLyIpdJhlg7GOENpE4afUtzxsvURmMpaiDM=; b=SBVWf6Qeo4Wl8DDYzv7hsTyRmvSEDKbkRuZVPRDj5Byb+sZWX/0bd3N9Yx280UmtVp/1M60gDgOiEEWRab0tJNqG9/ogJ05QG5S2SoR2G8REhbQvqoANo0Co+v/jTqoiXLHlMuPurktBLaPofPjsNAE6xY8hRFh80ekLRle3IwJv5IlclHSpWU2C/8x+u3+hpDVojw2mr+/jnZCA7vRyoW4ryF9tNr0x91pyNJKM7eK3vql0rJHqknNRrhBqzCONQzlO7BbYzqYYYyFKzl884uk8MqMsmYXhIjtWpcFbyiZ3vlVr/AgQre3guJZt3JklYhe7C5p8F2FodUk33nvoYg== 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=rcPkcOJ7LLyIpdJhlg7GOENpE4afUtzxsvURmMpaiDM=; b=F5ekgNDLvzCHnaPUagD0BlhOPAjcXglVmhy9+cKuVp+MREFJ3lWQDivtIeZxlet2Msd3UzU9Dc/t7P+/pY9vIW51AH1RHG10JZxk/F54GoMZOrfm+qHwpXyiavmAw4893BFCJRQmTgMxMJarJjS1GK7Jgrww28f9HfAv8crXqpQ= 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 PH0PR13MB4857.namprd13.prod.outlook.com (2603:10b6:510:93::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.9; Wed, 2 Jun 2021 12:00:18 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:18 +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 v3 3/8] nfp: flower-ct: add ct zone table Date: Wed, 2 Jun 2021 13:59:47 +0200 Message-Id: <20210602115952.17591-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d7633dbb-6c1a-411d-53ab-08d925bdfd2f X-MS-TrafficTypeDiagnostic: PH0PR13MB4857: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mvTXfY0VFy2gDnX+7jfB6GI2Q0JbRs8OfZ9cw4EujuBxnNgKFZ5rUYEZEuuVihiqlb2IVjG+QeWlV0N4MJGIvUYaqBf7caBLhVezKiWiY+r9GjnbIvASA8MPDyOSSXIq7ssiI2UoVou0LxXzeqhPCmmj9LRpejVHjz8u5Ky7cj7cSp6PVXUVJThl5IL3KfhoOVDE6isOuLSDgrSCVIJY6kTs235L6EsyMJTYKign4gJQEvMxW0NapZcxgqX3+1pNoWIUCGhjnzsdSfoXSq79YqU8hhihSNXVKvCR2MYe+MB8xDUuhBBP3T+O1+J1GQOO+MVDDKmG4yXhHN55dCQnv1wKbBlIshZK7w+zzawl5Yo1vo4mOrCpvrs3zKVaHlXgMPpicoCxYIrItg/hxbY+QxeaWAoJcuuXmbjvMd3+pxoZ+gkDwnNwU1Rm/BeD6T3+sbkgOW+TQYX1n02bGKpcGBE+MRpTQDognfW5S9/ayVSdC01CRiamcJQ8rsByQSq+uyGq21EEuawhGDdUciOAFENrZw1ZbaGoEnyQcadtcCXh62DxZpjmA+dFJaGLl0obIqkINLXU7K/HCnky8AW+hbpJ3ISq87Pvc+lynTw/0fI= 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:(346002)(376002)(396003)(136003)(366004)(39840400004)(6666004)(54906003)(44832011)(110136005)(66476007)(16526019)(2616005)(66946007)(66556008)(1076003)(478600001)(316002)(86362001)(6512007)(4326008)(83380400001)(5660300002)(38100700002)(36756003)(6506007)(6486002)(107886003)(52116002)(8936002)(2906002)(186003)(8676002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: tiXFNhP3XA+2Dm2k3FdxqhvCgdITo3NkMPafo8el9zQ8M0Q05UWZfIW6PO5X+UdiJBgC34IXJWnX5gQTXGI5lExTxroJ2OBMBy3ii6gixE0BXmjyhDxlu4JN8jFu4xIy4z0Ng24Jl7/MAnKYTz5+r5iwUtxUJUNRanol212ytIWt4yGX0Jp2ddKUhl6vFqEo129HcLt0wnegWCgxXnBprvh8kIDqUNDn0Ko4rhzo2fHYe7E54WInuCbD+Z0LenYUARkmFfeGHE5NNdTWzcdB+RjxCDSwjq3jLCEMd+LP5yR5GAIRoh0bYJLDfaIb2GYQng9o+P6ZoLR5+TuLeopxY+ptNvXP9eiW9IarQpZHMEl5ES2pyQO5UAj0fdrUNMOUqafgK0XN0NTYLgkqadldoy9VXDXn2Or5go0ppovTLt5bEsTE82Dw7qltCzA4ZLIvx7p1nrz1pDyIvzgjqp68R2SknRQhZRLxaXz4M++YgiYMrMeAEtliJ9WKFv+r1MHClLt7cXyVXgi0iNLGbwnYAO3OKKfoANEK+C6SxBdo/JjnL2E+2mWkPVZX3v0MbEYFIlUTHc/Tys4BIzhjlaKvkFye+z+MfqULzP9i55JSPL1c7DWfwmc0m8bvdBNAg5ObdKTZTN65Ut5X9kMMnjPoy6aRNYm8stuaSH2RYyyZS4ENhbXcqj8Xm66U+B4S9s5teSk5dcre53cNWjF1twV6XASo7xQ+/WiUKLZ96ko44W8Sg0reYmjjuKwzoYggpb70wfY/woixDpREiBhJoBC1HTCQxu9/ArPrvtH/uhtmZvNEZ6aG6ENL3g9Uctu/zfqClFnJJod0p1mLXS+fYSEGcv++ehUOYnFUK/uQwsP3sZRRPFiUltV2N1IUDfuVqBMPs4tqikVX5PRePnaKtpyEZ9lM7rIpcN42nFbChHbXEvhx+iXCGPE5nzF6Y18gjK3NWr7ZVMGp+QNB608B8Ol3nNIP6FDJ+wQiiI2UWIXMN9FSwRdZjFoYkm+L7fYMUU8EVroF9yszLvnOQbuc0M+tw5xfuz5gdcEh6JQQxK9M60s69NhFXtS/jVkSu7RNKRoKsZuteHJ3jQywFR47n5TFivipnyIM/5LlEsRfPkQQw0v3lnezRj97RoAsToRnyK8jaSI/+5tF+V/xT76Y7khJfhGTVaON7OhVS6mNuzBDhxjQufb5pKm5L4QlLENmURgP+8tCRhhLbBiVpiVaQbYAgC376YyyVLA/991kQzj8n7hgRrKx3NF54s0J7aBlI/w8JutqCq+8o+1AFhUjqFGNG1G3aiVStsdd/xuFHcGDdZxViBfoJMJ3miWZNCDDrLhrzCA6bi++6aPL2QdLu2PMQBxKaB80RPCUBv2ZDce9hK3W+ME78i2c8bGXTFFYugoB X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7633dbb-6c1a-411d-53ab-08d925bdfd2f X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:17.8988 (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: +v2UiL41NJxqHS1YPrhzkI/21L2uTpVi+uvaf+7m8qEdekSnLDs0KpfbsUJrNfa0rdNYAUGbJeeSc0h91Srjp38S6tqskrWvrnmrxHpNKkE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4857 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add initial zone table to nfp_flower_priv. This table will be used to store all the information required to offload conntrack. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.h | 17 ++++++++++++++ .../net/ethernet/netronome/nfp/flower/main.h | 2 ++ .../ethernet/netronome/nfp/flower/metadata.c | 22 ++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index e8d034bb9807..5f1f54ccc5a1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -6,6 +6,23 @@ #include "main.h" +extern const struct rhashtable_params nfp_zone_table_params; + +/** + * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information + * @zone: The zone number, used as lookup key in hashtable + * @hash_node: Used by the hashtable + * @priv: Pointer to nfp_flower_priv data + * @nft: Pointer to nf_flowtable for this zone + */ +struct nfp_fl_ct_zone_entry { + u16 zone; + struct rhash_head hash_node; + + struct nfp_flower_priv *priv; + struct nf_flowtable *nft; +}; + bool is_pre_ct_flow(struct flow_cls_offload *flow); bool is_post_ct_flow(struct flow_cls_offload *flow); diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 31377923ea3d..0073851f31d7 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -193,6 +193,7 @@ struct nfp_fl_internal_ports { * @qos_stats_lock: Lock on qos stats updates * @pre_tun_rule_cnt: Number of pre-tunnel rules offloaded * @merge_table: Hash table to store merged flows + * @ct_zone_table: Hash table used to store the different zones */ struct nfp_flower_priv { struct nfp_app *app; @@ -227,6 +228,7 @@ struct nfp_flower_priv { spinlock_t qos_stats_lock; /* Protect the qos stats */ int pre_tun_rule_cnt; struct rhashtable merge_table; + struct rhashtable ct_zone_table; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 327bb56b3ef5..4a00ce803df1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -9,6 +9,7 @@ #include #include "cmsg.h" +#include "conntrack.h" #include "main.h" #include "../nfp_app.h" @@ -496,6 +497,13 @@ const struct rhashtable_params merge_table_params = { .key_len = sizeof(u64), }; +const struct rhashtable_params nfp_zone_table_params = { + .head_offset = offsetof(struct nfp_fl_ct_zone_entry, hash_node), + .key_len = sizeof(u16), + .key_offset = offsetof(struct nfp_fl_ct_zone_entry, zone), + .automatic_shrinking = false, +}; + int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, unsigned int host_num_mems) { @@ -516,6 +524,10 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, if (err) goto err_free_stats_ctx_table; + err = rhashtable_init(&priv->ct_zone_table, &nfp_zone_table_params); + if (err) + goto err_free_merge_table; + get_random_bytes(&priv->mask_id_seed, sizeof(priv->mask_id_seed)); /* Init ring buffer and unallocated mask_ids. */ @@ -523,7 +535,7 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kmalloc_array(NFP_FLOWER_MASK_ENTRY_RS, NFP_FLOWER_MASK_ELEMENT_RS, GFP_KERNEL); if (!priv->mask_ids.mask_id_free_list.buf) - goto err_free_merge_table; + goto err_free_ct_zone_table; priv->mask_ids.init_unallocated = NFP_FLOWER_MASK_ENTRY_RS - 1; @@ -560,6 +572,8 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kfree(priv->mask_ids.last_used); err_free_mask_id: kfree(priv->mask_ids.mask_id_free_list.buf); +err_free_ct_zone_table: + rhashtable_destroy(&priv->ct_zone_table); err_free_merge_table: rhashtable_destroy(&priv->merge_table); err_free_stats_ctx_table: @@ -569,6 +583,10 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, return -ENOMEM; } +static void nfp_free_zone_table_entry(void *ptr, void *arg) +{ +} + void nfp_flower_metadata_cleanup(struct nfp_app *app) { struct nfp_flower_priv *priv = app->priv; @@ -582,6 +600,8 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) nfp_check_rhashtable_empty, NULL); rhashtable_free_and_destroy(&priv->merge_table, nfp_check_rhashtable_empty, NULL); + rhashtable_free_and_destroy(&priv->ct_zone_table, + nfp_free_zone_table_entry, NULL); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Wed Jun 2 11:59:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453935 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 216D6C47083 for ; Wed, 2 Jun 2021 12:00:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0163561360 for ; Wed, 2 Jun 2021 12:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbhFBMCM (ORCPT ); Wed, 2 Jun 2021 08:02:12 -0400 Received: from mail-dm6nam11on2100.outbound.protection.outlook.com ([40.107.223.100]:56833 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229668AbhFBMCD (ORCPT ); Wed, 2 Jun 2021 08:02:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nZkhakJEez6hUz3PlZdKPuXWsMBLdPhAUNAqrkB9tqy2YlTlnG4fYxHyIus1RVDWS5AEBlF9tv6G5R7NXzHZ04iBv5aVfMpElvG1Y1OkX0Yc0q/ZrSxOHdYKf7CbI//Jw2Ne9CxMevC2vzY8FrucW6418hi+auIsR97Fu6cXB1K28r44WiUXrZzV5YxVVjFxfNkKoVRz9VN1q8Q7w8xGlWbs+N5WPH75/UbQRJVR56w+k88lB+HiswCZXT/STcxE6dQUWLFUlPz4IMrLzw+0ywNR3aFCrtFFGbuXLT2D5eUEiTeINNTLMAuPB+B90lPmTmOrryTkj14o7rlbKR6E+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=FRlQXbWcTqGO9B01tc48EHVXxWMGKTiI54HptriGqCQ=; b=Xj0R/KP9cTl2/nFVhy0JEKt9G3Zl6okefiHkrel+fcljYzSlrSkm5EvlnktvWJ7ZbOLox0W9m1TZLJnLZxKjW0W+067lalrPO1aa8VET4+Y/WC4KzFuZqZuPLAU4Sf9CGAkOEKflh6YA9KC/KM4DkYGUggHRKI61rCWT3wwcSaovidQ6UlrIs0fl2tqeRRM6TAUk3+DaWDa1WLD8UslCvQN40V00v6H3BoEkVVhvYrEYzm7N1mhvskRHWRf035yg31PNqO10He8t7BAESqvrGC0itysdnjIAnltHsexvzR0tChaKLF4yF82DLqgLc8SPpFz2LLk4ZAVEdgzO1WagmA== 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=FRlQXbWcTqGO9B01tc48EHVXxWMGKTiI54HptriGqCQ=; b=RXGfhAR+ySq7YOcW6hTf1Wmfogp4CbVR4mwOwW4ZkWOaYAx3/P6u/rhL0oM91mLvfym87Oh0EUI99SWNNue9mGfCH+eLGeXDtHycQu/Av2jEvpeFoI6725IH+vtRZUBRattSy/XxsE4N0HeduSoO1hhGdu/hIkTUcgq3Vb3b2oU= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:19 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:19 +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 v3 4/8] nfp: flower-ct: add zone table entry when handling pre/post_ct flows Date: Wed, 2 Jun 2021 13:59:48 +0200 Message-Id: <20210602115952.17591-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d4e92b3-a9ea-4dc0-77e8-08d925bdfe47 X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wd1ahIBHHABG4A//jU66zs5K1cap9XRhkMz9+Uz9Vm8ooOTzDXJvNDVxHv3iN7I2fRnduJctW26nLFxnnUKS3O88+bYBN5KOR1IW5Wx2he2EFmg4VFpBmBQQ4urxT059xq6bPb2grFzH1DUSl6cgqFZHP971pZ7lYMx/aelYyf1rU9pMYsgft/6+OLFNo2tZbYqQd6CJcVLXKEXVRw3D/sSbwXk5WknLnAU/dlwPLrEHiDK0V9lS+srpr6Aw+wl67MObHg4r1LYnP8x1DUtfxCUUpYXXUxTGJ8xMl/0loY312YEmEeEMmU464ClBYxCk4bD7enlD6OmR0LHuFYjo01Zh6n46KGEIIToeJOl+UadO6j4ES+8Ij/wGWu/cqiKkYxLgrwksl2qr3GHuKKu/EmjBeInhrORcq8SUC9JKYH8/7FGNg88DMGImzEdzSS7WLU3PsjzyQJKoru/MU3yKHa7Co4jh5n1HR41p4MKqxzOJQKwlrqGa8poefnouluSETTRCBKo0IRtYn7UihUNUvHDxY2IHCWT4U830y6szinJyUjep0BzUscszfEC/v9/nxMdjpQTQsDzVWyQC0AmD1EuJu7vv3SCbPOPwkCUEkCU= 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:(366004)(39840400004)(376002)(136003)(346002)(396003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: HkvXEollsVtFf7O7IiQzErSc5L8UvfG8W0hlKRJky8yd0dF2+v/iqqqRKxKlMPeGT+ZnFwc3foVUKGfrd61cRHQUs+40dzovN7wxluxZ6vYB7alY9GCOzWEdSajE6IMjUpBM/rkrp4X0FmdJjktvXyKt7Q0Qg3eEFhTW85Rhq68mF8R0ZlIHQGzfgQuIN2vSM3MakSgRZF7B2Mrwsya5pgaiNErEeX/9E8e+54YlcyZRKx/PkNTbWqIHXbsNUafF/KTv7r3f7Z6fymj4mzWl8mJC/eAiEtqqPOZQwg/rGknrwzt0vpwxYzuPRPoImpuzq1lH4ftHCijNW4Q7Zw8lqDpMZqxBzuTyQUA6swj81hEByHvTw2e2PmRHTVsvYWUZP7immbvFTP6XStogv2IU3yBwPYdXaKpsO+1k0nWFDYa9EMR5C7227pzUjG14nND1ML9Ey1rRWwShSy/1GDCgJ5llUCsdVHs4DCvXFCYXQBxdCn7gFjnmojY/688iQ7sYP/WcPej8Eo9h4IiWncBKA8/FTTKYSf62UzgJQjlQ4QS7r9Dtwm5LxVTX0PX60eeiF7WUuIRg87/u8CkT4OzSEK3ot9wn/d9ryjqVyKUZm3Y3Q+qDfJwnAoqtcQJGcDIRpCJcHGMYz4KRqbKJOdrXz4VIwpnqMj4+STPLxoR31jnsw7LemkZdu+4i+96a2v7/Bpqz1iIcTCqpnob81BkkkNptNjj38ql7HdG3RkxcsSwwM+zolrVZJe32wuc3weVxemP3yV18fC1uhRQHfSq+XwHpjyP2Kph/ScwCG9X9O+vPWko9Gp4/HEv1iwXzu4mSLava7ZcXTWWgdagT41f/cQ8q4SoPBjrBiIEQOylCskLYt5GSRWt7y/6VH8e1U+5BvKClIW8whpOzeCNXQfIixc2QogH/0ZeWVXQ+ZqX6NVdrjfyTgKYCZ1c7qmpyahFpE1PtJZOnS+sXtFmyXHZiHoFI8ppUSVKaBLtCcnZFj2mDWAvNfiBGSnuSJq0KX0FyCTIRFRv5bdRxsf9TdGvTy9S9wAzdicVuWgnGvTcsnV0FyJ9Wd1CeH49R+9B/DAeqq17JP7CPIfUmgTJ80oBRh95/aAXgxbSIC7wTey1cwXrSWXFD5a8Zp2i2fPKTohsjAxdyMFC4qJKkC7NrSnJ/AQgsL/d03XZnxz/icSkfQVxXTe/xCZ2Dcp3/65w12XJmBFDdiH0qKxsvHN9cVHz5jzQDg091+TrFT6dIjvIlvUtFfo8i2dzHRDN0jZa/Y5rMvokbNDY2MCwMWX0CJBvNU8TS7SdUKYWF6jhttBz4ib4MRk/4ayLaxvu0aHS2R/692nyPOsJj6yeeOHhpmuYuk3I5CtgIGelXfvBPCqVg4d/SSpWD5FBjleo0EcuEagrj X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d4e92b3-a9ea-4dc0-77e8-08d925bdfe47 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:19.6033 (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: Jd3pvK/mhQOnNOK4zuzn39vyHwBV42UdrdN+pwafRGpgFPKwo9bQpBBBqSdljVWfMR+fij/V5Mfe10ObKGU0aCJkXCqXNbRWbQ/LAvT0XyM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Start populating the pre/post_ct handler functions. Add a zone entry to the zone table, based on the zone information from the flow. In the case of a post_ct flow which has a wildcarded match on the zone create a special entry. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 125 ++++++++++++++++++ .../net/ethernet/netronome/nfp/flower/main.h | 2 + .../ethernet/netronome/nfp/flower/metadata.c | 4 + 3 files changed, 131 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index aeea37a0135e..9d63a8f89397 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -3,6 +3,33 @@ #include "conntrack.h" +/** + * get_hashentry() - Wrapper around hashtable lookup. + * @ht: hashtable where entry could be found + * @key: key to lookup + * @params: hashtable params + * @size: size of entry to allocate if not in table + * + * Returns an entry from a hashtable. If entry does not exist + * yet allocate the memory for it and return the new entry. + */ +static void *get_hashentry(struct rhashtable *ht, void *key, + const struct rhashtable_params params, size_t size) +{ + void *result; + + result = rhashtable_lookup_fast(ht, key, params); + + if (result) + return result; + + result = kzalloc(size, GFP_KERNEL); + if (!result) + return ERR_PTR(-ENOMEM); + + return result; +} + bool is_pre_ct_flow(struct flow_cls_offload *flow) { struct flow_action_entry *act; @@ -29,11 +56,88 @@ bool is_post_ct_flow(struct flow_cls_offload *flow) return false; } +static struct +nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, + u16 zone, bool wildcarded) +{ + struct nfp_fl_ct_zone_entry *zt; + int err; + + if (wildcarded && priv->ct_zone_wc) + return priv->ct_zone_wc; + + if (!wildcarded) { + zt = get_hashentry(&priv->ct_zone_table, &zone, + nfp_zone_table_params, sizeof(*zt)); + + /* If priv is set this is an existing entry, just return it */ + if (IS_ERR(zt) || zt->priv) + return zt; + } else { + zt = kzalloc(sizeof(*zt), GFP_KERNEL); + if (!zt) + return ERR_PTR(-ENOMEM); + } + + zt->zone = zone; + zt->priv = priv; + zt->nft = NULL; + + if (wildcarded) { + priv->ct_zone_wc = zt; + } else { + err = rhashtable_insert_fast(&priv->ct_zone_table, + &zt->hash_node, + nfp_zone_table_params); + if (err) + goto err_zone_insert; + } + + return zt; + +err_zone_insert: + kfree(zt); + return ERR_PTR(err); +} + +static struct flow_action_entry *get_flow_act(struct flow_cls_offload *flow, + enum flow_action_id act_id) +{ + struct flow_action_entry *act = NULL; + int i; + + flow_action_for_each(i, act, &flow->rule->action) { + if (act->id == act_id) + return act; + } + return NULL; +} + int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct net_device *netdev, struct flow_cls_offload *flow, struct netlink_ext_ack *extack) { + struct flow_action_entry *ct_act; + struct nfp_fl_ct_zone_entry *zt; + + ct_act = get_flow_act(flow, FLOW_ACTION_CT); + if (!ct_act) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: Conntrack action empty in conntrack offload"); + return -EOPNOTSUPP; + } + + zt = get_nfp_zone_entry(priv, ct_act->ct.zone, false); + if (IS_ERR(zt)) { + NL_SET_ERR_MSG_MOD(extack, + "offload error: Could not create zone table entry"); + return PTR_ERR(zt); + } + + if (!zt->nft) + zt->nft = ct_act->ct.flow_table; + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action not supported"); return -EOPNOTSUPP; } @@ -43,6 +147,27 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, struct flow_cls_offload *flow, struct netlink_ext_ack *extack) { + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); + struct nfp_fl_ct_zone_entry *zt; + bool wildcarded = false; + struct flow_match_ct ct; + + flow_rule_match_ct(rule, &ct); + if (!ct.mask->ct_zone) { + wildcarded = true; + } else if (ct.mask->ct_zone != U16_MAX) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: partially wildcarded ct_zone is not supported"); + return -EOPNOTSUPP; + } + + zt = get_nfp_zone_entry(priv, ct.key->ct_zone, wildcarded); + if (IS_ERR(zt)) { + NL_SET_ERR_MSG_MOD(extack, + "offload error: Could not create zone table entry"); + return PTR_ERR(zt); + } + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack match not supported"); return -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 0073851f31d7..060c6de36c02 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -194,6 +194,7 @@ struct nfp_fl_internal_ports { * @pre_tun_rule_cnt: Number of pre-tunnel rules offloaded * @merge_table: Hash table to store merged flows * @ct_zone_table: Hash table used to store the different zones + * @ct_zone_wc: Special zone entry for wildcarded zone matches */ struct nfp_flower_priv { struct nfp_app *app; @@ -229,6 +230,7 @@ struct nfp_flower_priv { int pre_tun_rule_cnt; struct rhashtable merge_table; struct rhashtable ct_zone_table; + struct nfp_fl_ct_zone_entry *ct_zone_wc; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 4a00ce803df1..10d84ebf77bf 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -585,6 +585,9 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, static void nfp_free_zone_table_entry(void *ptr, void *arg) { + struct nfp_fl_ct_zone_entry *zt = ptr; + + kfree(zt); } void nfp_flower_metadata_cleanup(struct nfp_app *app) @@ -602,6 +605,7 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) nfp_check_rhashtable_empty, NULL); rhashtable_free_and_destroy(&priv->ct_zone_table, nfp_free_zone_table_entry, NULL); + kfree(priv->ct_zone_wc); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Wed Jun 2 11:59:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453934 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 161E5C47083 for ; Wed, 2 Jun 2021 12:00:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E449C613B1 for ; Wed, 2 Jun 2021 12:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbhFBMCZ (ORCPT ); Wed, 2 Jun 2021 08:02:25 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:6496 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229665AbhFBMCF (ORCPT ); Wed, 2 Jun 2021 08:02:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLhtSQY/ERmc2UAQbtxMNLjnUsMBEZdYMufwFyIbVtxntm+6aRhx11IvwG5gjY1RKer9sr4aEkij8PQhy+U46pcBh9Jatj0glXCwX3jLsrz6e/yNRm5lclUPYFQ5jYrEW1ZOklIklNP2a9bL82JDXR9wWiOlb5mQkY+r9FCNHXP3CiV2Ktr3BfaYUenatX5EpB5lt4q5MvWpXwcEO0tB/BrQ0oE++AfltcEnc4+2OMK76i8GhypvbIKvZ8u+E5t0e/FuIZj7kBuIWMm30m2J9JmlxJMOOesGo1itpqnxNts5zwwv20BSWJZ9gdsXcHhxdQi3AFx6pKDswh3k8gJr1Q== 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=F/ioLKxTs35z36oPNZG8q6glJc5x4RZXKLV/YIBZv+A=; b=IXT/QtaZ08vtCQbpIwipQpUYzXlpt0aR9xeu0PwKy2KGQ7VpH4HseiMNQuneJAGbGmAfM5UPZ+8VIZya84JWF8lQDFA4o9LoGw7W7pDndQSJaZsvGF4cRw7Y+arOYYfulYnmrIvoe1qYmqgArHgBDi1RZIXkRdO2J3za0AdtOLToTbrUlkB7pkW6W9+BJCb/m8fXxWbchIAB9DSs8kdycl7W7MfUGL1IUMAdmZH4G3Knok7xOka+Wdj7bp6J6ZA9QpKq1I2CwA3V3dc+0yNM28/ldMYzerKsNEe0k8JV9iRinstgI2h3O/XMdPDq8WZ3KEFy8l2U70VIvN0g3VYsLg== 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=F/ioLKxTs35z36oPNZG8q6glJc5x4RZXKLV/YIBZv+A=; b=mJ5rnZvc3f3u/0HWmneTNGgNgqnqg8rxwWEwQfWP/i9LzDiumnTQwuv/DI3RNGMhMZypG6myNQ+I8kx3jTuc4NIVlvw7LJ5vVwSbqOsBQpv6oCTzLe/1vuXNrVw8PNoK1FG04fJdTrhs0DdGuvi10yl3QBIU/jr4NrOJGzvWbuY= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:21 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:21 +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 v3 5/8] nfp: flower-ct: add nfp_fl_ct_flow_entries Date: Wed, 2 Jun 2021 13:59:49 +0200 Message-Id: <20210602115952.17591-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 726da3b0-4411-431d-c8fa-08d925bdff51 X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:525; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Onui2vzKpZsHvNVx8pV4OciSLfPbKJEnuQiQrAFiGQHuS6+fg/9rYU9t1yccqBe5sRwES+yCKpmJtYJ+/aK9oDpisAO2GREkICwV1YktmEZzVvjNXYxCJ/T0OjZg1RHScqCtDOQ/pRxEq5UVKXWVZE8eVVzvNgzLqe/qbvCy29SV66r5bDQevY7DpoJi8X7gd3WZWVC5GvkOU2v0zwi2ksBuk10O/iC1Xii2q7nLC1e07n4lEjGqQyvwS83og35T5WcPDp8W/Xg8ra0EbkPozw4JUf0TNdZW+/vXiMCATFQz/YMMShhUftrsKIKPdRSEtbHhoF56GzzgxdCTOBbH8RoH/w4Cp+zwRqbuHwoofpQiejEEzlYkn2L+9PaFqjc/ygF3qi9P9wWck0AcPwxPaK885UMh12ybhxz/2KzF27wDfspo+2Hg1iZkyNt7yNRbXZ9yfoKNfmowUfVBTccM3sK//ZJ5KCA49CMELSwmf4gQTzE9UUohsOV+2AfHkFnqbgUv7j1C5ZAu2eLJ031lGkQ4fRKPDiMgTbibTlsYoln5Bw+3EvTBmT59bW8afTeFMWeYL+iakwV8P4K6pPl/Fxwdw1xroYO0p0aQAEu/Pq4= 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:(366004)(39840400004)(376002)(136003)(346002)(396003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(30864003)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(83380400001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: xJXX6elrCBWI946b9w4PGD7GgJYT8jAJKB6OgKEzVukPUwtM9/AfAhyPb0w7v0uBkrpu8AXbvNq4R2OoNo5eKMaeIoajhTWiZKNPZqrz2kk+9UVnJ58dyjapCOFWH7pnyQaGR0XhEzWqa8TPDn5zYsODTX+j4rMmf4fu5VF3Negf154AdWnUiAY+CBYKa1I9UAyJMtYlYoiwBs0vKRRbqAomk3zflcdL1+XuKUzqm8rMyssPHO+UVHdYe9vN8+Dfpa1XA4+02KEpQdodekKDSpw9Su1XlTH2Amk9C3vNIakRXXnMTRPsoiEd1DrHUf37UjUFuSCOKClYMXTtGLDhrI6OVSMw4SJarFuiQubv2gSC4fJWSo9FV7wzP135kBB2YgUt/4QKSwDjKxoWYLHYx/XvBFW080sq/7athXrWo8I0I6qQ+7dvQCp/ymn5ZLU0sKYHJOSHv6AfFaP2gIu3slx4Ley+4tuw5HBcZPFC0I3BHuI/cOW4Zj9o2MVBNeY1CR32s2Dlth3ON90Y1t77R+Bi+GIBY/XSqATsuai8FjNPweKwmi4xkK+t49uKF1+QoUpPJuxgooW26KSQ5NJ74L9JBvf3+wqXZqzF8u+BLtGouwWhuw7YEEmZ7IJeCQBti8SSHaDI5yyjan7UpkHzE/I/jCtoHo/kyAE2o/22d7FlhFF2QRvh3SY/75G9w/b6pF3U99aYjTBhFZ+IVh+BE0uRWdhFjmaCZUe7uqzvuDByjpjNsc0abEz1UDTEB4Un3mJRMo9B5uswxUNBrLzJy5avUI27Iy98CVA+Prqcy1S/ClYmcFVVfFWSw1PKYGPqLvh3WyQN1twLqOrBi2qKFTNBz963IEVAXMa1Y4L21SbceKWSkns7es/D0Y4w+H30U0B4zfAqccmcC1ZJaJ/4DXX2jzPmOMnalm0N+ABGCZlacB7NpSgfeXOcZX5DtxQCgOC4BXxMx06189Y+Df3Uom3vFeIUaNb6M+qLAP/VgSO2NUmA3zYdR7Po8coXbz1oG0xGe/64ukyFs8WUFc0ljpOhmA6eiKHZ44QyqYqqNd+mAkLjoGflKIIrzWeMa6EZK8xFi8zTxE8s3abF4MBg777AQOFK0R8OyD4DJrgNQVZ5FgVwdtPyrdAstzqX9pDT7YqpMXwEsTHYrsILA36O1sxsReYj87STmKYG8k14OrY6XF9F3zfTQkuRZyeQ7Otqv5eaIlNVa2BJ74/Y06OY+CkhmZMeuBYFi5Z+uSK11llabw3vXX4Vi45Js5MQ1v4R9iuuKw66W5vYSnvFh1QarOeflVJvuhdlfaEiqPX7HpWmiXqmTlleuZmcrUBZXgExSiDnvdHG7MwZ6daJgAu354adsrvdWuY9E7v+UYovtbhONrwwLiQnt6xaA0PoYPGa X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 726da3b0-4411-431d-c8fa-08d925bdff51 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:21.4960 (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: BRyEAm7uoMvXsHn8WIWLTguKJf8qLxm8B/w8G0iEcXzHudT3jowRAW9eS88wq01F7MFTNrEAUbAdlEEKzepK47sLgGO6sgNwoyqp6ck0L6Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens This commit starts adding the structures and lists that will be used in follow up commits to enable offloading of conntrack. Some stub functions are also introduced as placeholders by this commit. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 130 +++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 51 +++++++ .../ethernet/netronome/nfp/flower/metadata.c | 31 ++++- 3 files changed, 209 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 9d63a8f89397..57a5ba5f2761 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -83,6 +83,10 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, zt->priv = priv; zt->nft = NULL; + /* init the various hash tables and lists*/ + INIT_LIST_HEAD(&zt->pre_ct_list); + INIT_LIST_HEAD(&zt->post_ct_list); + if (wildcarded) { priv->ct_zone_wc = zt; } else { @@ -100,6 +104,100 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, return ERR_PTR(err); } +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 nfp_fl_ct_flow_entry *entry; + struct flow_action_entry *act; + int err, i; + + entry = kzalloc(sizeof(*entry), GFP_KERNEL); + 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; + } + 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->chain_index = flow->common.chain_index; + entry->tun_offset = NFP_FL_CT_NO_TUN; + + /* Copy over action data. Unfortunately we do not get a handle to the + * original tcf_action data, and the flow objects gets destroyed, so we + * cannot just save a pointer to this either, so need to copy over the + * data unfortunately. + */ + entry->rule->action.num_entries = flow->rule->action.num_entries; + flow_action_for_each(i, act, &flow->rule->action) { + struct flow_action_entry *new_act; + + new_act = &entry->rule->action.entries[i]; + memcpy(new_act, act, sizeof(struct flow_action_entry)); + /* Entunnel is a special case, need to allocate and copy + * tunnel info. + */ + if (act->id == FLOW_ACTION_TUNNEL_ENCAP) { + struct ip_tunnel_info *tun = act->tunnel; + size_t tun_size = sizeof(*tun) + tun->options_len; + + new_act->tunnel = kmemdup(tun, tun_size, GFP_ATOMIC); + if (!new_act->tunnel) { + err = -ENOMEM; + goto err_pre_ct_tun_cp; + } + entry->tun_offset = i; + } + } + + INIT_LIST_HEAD(&entry->children); + + /* Creation of a ct_map_entry and adding it to a hashtable + * will happen here in follow up patches. + */ + + return entry; + +err_pre_ct_tun_cp: + kfree(entry->rule); +err_pre_ct_act: + kfree(entry); + return ERR_PTR(err); +} + +static void nfp_free_tc_merge_children(struct nfp_fl_ct_flow_entry *entry) +{ +} + +static void nfp_free_nft_merge_children(void *entry, bool is_nft_flow) +{ +} + +void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry) +{ + list_del(&entry->list_node); + + if (!list_empty(&entry->children)) { + if (entry->type == CT_TYPE_NFT) + nfp_free_nft_merge_children(entry, true); + else + nfp_free_tc_merge_children(entry); + } + + if (entry->tun_offset != NFP_FL_CT_NO_TUN) + kfree(entry->rule->action.entries[entry->tun_offset].tunnel); + kfree(entry->rule); + kfree(entry); +} + static struct flow_action_entry *get_flow_act(struct flow_cls_offload *flow, enum flow_action_id act_id) { @@ -118,7 +216,8 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct flow_cls_offload *flow, struct netlink_ext_ack *extack) { - struct flow_action_entry *ct_act; + struct flow_action_entry *ct_act, *ct_goto; + struct nfp_fl_ct_flow_entry *ct_entry; struct nfp_fl_ct_zone_entry *zt; ct_act = get_flow_act(flow, FLOW_ACTION_CT); @@ -128,6 +227,13 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, return -EOPNOTSUPP; } + ct_goto = get_flow_act(flow, FLOW_ACTION_GOTO); + if (!ct_goto) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: Conntrack requires ACTION_GOTO"); + return -EOPNOTSUPP; + } + zt = get_nfp_zone_entry(priv, ct_act->ct.zone, false); if (IS_ERR(zt)) { NL_SET_ERR_MSG_MOD(extack, @@ -138,7 +244,17 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, if (!zt->nft) zt->nft = ct_act->ct.flow_table; + /* Add entry to pre_ct_list */ + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow); + if (IS_ERR(ct_entry)) + return PTR_ERR(ct_entry); + ct_entry->type = CT_TYPE_PRE_CT; + ct_entry->chain_index = ct_goto->chain_index; + list_add(&ct_entry->list_node, &zt->pre_ct_list); + zt->pre_ct_count++; + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action not supported"); + nfp_fl_ct_clean_flow_entry(ct_entry); return -EOPNOTSUPP; } @@ -148,6 +264,7 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, struct netlink_ext_ack *extack) { struct flow_rule *rule = flow_cls_offload_flow_rule(flow); + struct nfp_fl_ct_flow_entry *ct_entry; struct nfp_fl_ct_zone_entry *zt; bool wildcarded = false; struct flow_match_ct ct; @@ -168,6 +285,17 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, return PTR_ERR(zt); } + /* Add entry to post_ct_list */ + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow); + if (IS_ERR(ct_entry)) + return PTR_ERR(ct_entry); + + ct_entry->type = CT_TYPE_POST_CT; + ct_entry->chain_index = flow->common.chain_index; + list_add(&ct_entry->list_node, &zt->post_ct_list); + zt->post_ct_count++; + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack match not supported"); + nfp_fl_ct_clean_flow_entry(ct_entry); return -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index 5f1f54ccc5a1..46437de4d75f 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -6,6 +6,8 @@ #include "main.h" +#define NFP_FL_CT_NO_TUN 0xff + extern const struct rhashtable_params nfp_zone_table_params; /** @@ -14,6 +16,12 @@ extern const struct rhashtable_params nfp_zone_table_params; * @hash_node: Used by the hashtable * @priv: Pointer to nfp_flower_priv data * @nft: Pointer to nf_flowtable for this zone + * + * @pre_ct_list: The pre_ct_list of nfp_fl_ct_flow_entry entries + * @pre_ct_count: Keep count of the number of pre_ct entries + * + * @post_ct_list: The post_ct_list of nfp_fl_ct_flow_entry entries + * @post_ct_count: Keep count of the number of post_ct entries */ struct nfp_fl_ct_zone_entry { u16 zone; @@ -21,6 +29,44 @@ struct nfp_fl_ct_zone_entry { struct nfp_flower_priv *priv; struct nf_flowtable *nft; + + struct list_head pre_ct_list; + unsigned int pre_ct_count; + + struct list_head post_ct_list; + unsigned int post_ct_count; +}; + +enum ct_entry_type { + CT_TYPE_PRE_CT, + CT_TYPE_NFT, + CT_TYPE_POST_CT, +}; + +/** + * struct nfp_fl_ct_flow_entry - Flow entry containing conntrack flow information + * @cookie: Flow cookie, same as original TC flow, used as key + * @list_node: Used by the list + * @chain_index: Chain index of the original flow + * @netdev: netdev structure. + * @type: Type of pre-entry from enum ct_entry_type + * @zt: Reference to the zone table this belongs to + * @children: List of tc_merge flows this flow forms part of + * @rule: Reference to the original TC flow rule + * @stats: Used to cache stats for updating + * @tun_offset: Used to indicate tunnel action offset in action list + */ +struct nfp_fl_ct_flow_entry { + unsigned long cookie; + struct list_head list_node; + u32 chain_index; + enum ct_entry_type type; + struct net_device *netdev; + struct nfp_fl_ct_zone_entry *zt; + struct list_head children; + struct flow_rule *rule; + struct flow_stats stats; + u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun }; bool is_pre_ct_flow(struct flow_cls_offload *flow); @@ -59,4 +105,9 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, struct flow_cls_offload *flow, struct netlink_ext_ack *extack); +/** + * nfp_fl_ct_clean_flow_entry() - Free a nfp_fl_ct_flow_entry + * @entry: Flow entry to cleanup + */ +void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 10d84ebf77bf..062e963a8838 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -583,11 +583,38 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, return -ENOMEM; } +static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) +{ + if (!zt) + return; + + if (!list_empty(&zt->pre_ct_list)) { + struct nfp_fl_ct_flow_entry *entry, *tmp; + + WARN_ONCE(1, "pre_ct_list not empty as expected, cleaning up\n"); + list_for_each_entry_safe(entry, tmp, &zt->pre_ct_list, + list_node) { + nfp_fl_ct_clean_flow_entry(entry); + } + } + + if (!list_empty(&zt->post_ct_list)) { + struct nfp_fl_ct_flow_entry *entry, *tmp; + + WARN_ONCE(1, "post_ct_list not empty as expected, cleaning up\n"); + list_for_each_entry_safe(entry, tmp, &zt->post_ct_list, + list_node) { + nfp_fl_ct_clean_flow_entry(entry); + } + } + kfree(zt); +} + static void nfp_free_zone_table_entry(void *ptr, void *arg) { struct nfp_fl_ct_zone_entry *zt = ptr; - kfree(zt); + nfp_zone_table_entry_destroy(zt); } void nfp_flower_metadata_cleanup(struct nfp_app *app) @@ -605,7 +632,7 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) nfp_check_rhashtable_empty, NULL); rhashtable_free_and_destroy(&priv->ct_zone_table, nfp_free_zone_table_entry, NULL); - kfree(priv->ct_zone_wc); + nfp_zone_table_entry_destroy(priv->ct_zone_wc); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Wed Jun 2 11:59:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453072 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 11FC2C47083 for ; Wed, 2 Jun 2021 12:01:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1776613B1 for ; Wed, 2 Jun 2021 12:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229590AbhFBMCl (ORCPT ); Wed, 2 Jun 2021 08:02:41 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:6496 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229818AbhFBMCV (ORCPT ); Wed, 2 Jun 2021 08:02:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oOPByxAB+8D0u5A8eZamlg+DZHUzw7erMfKHxFcf85nJMVzb7ngjb2tZs3/HAY9vYW/eI+6yzuXuxlFsrdQML1MIMwfbaLcxV69jl4OKPhMnh+xcdQwSzBXMovv/fL/LioTmsd2odsZReZ1/u8RKb8EL6/vj1kkwD6zXDs5Kjq6/p63RbL//EBFAz2QfJj5NGe4T78jq7MxAMA5N0eCK9KAsmmlOfcASf+pznoK4GyLTJ327afw5Rx0FrEkTONrZ4qbu68OK5iOaBKJPyqkSDBX57F9pXb9CqDjKg/Zut2WgIL6V4YFz33XLzacxYBU9CUl1y7flXRB3ptq2bLPSHw== 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=H7nsVdfJqq96wEqcxnlSgTU3TWhUWdbX7JNj8laYbRQ=; b=ETdIIHuIOojx+7w8G5rk6IhrMdernrm0vji16mRWaTuIALz4D1JuiNsTONj8z+tltx7bBdNhOOmWOcIcXK9zP93+d4sVxxPHuPNLRud1uD/WejN75i04ge3vGm480anU2QUCCvQSWGhe67iRi+eBaEpgzWS1XCLwqDxTl+flgvuqLTIu7hyqP6E6xfciaYUXQYk3VJneuZvXrNQzD2FwtiAtayDzVARyz06R8ncEnkhntglDqliUsDJomlfBzsubt2Zvxok6MXHJMlLOfN3N8K52FFMQh0gMqzHQFiaSzA3fS/cLcfW1U3t8rPmggQ57PMvH8y3LctdjtESZ5Zn7+w== 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=H7nsVdfJqq96wEqcxnlSgTU3TWhUWdbX7JNj8laYbRQ=; b=tKOlSOkDxzgSiTOPTSDoNBzoAimdMAlmZld/DYHCt4uJDDgHeepCIa+34dy3TKJV231b1xrw6OOFL/wjly9GChYOVwEO5ZvjbtBxHxxzfNkNxnTTOOJzWA3HStuN4JGp1r37fiNmQSVyfkDZ1BZcaVILPd473YMP5ulWL+hH/9g= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:23 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:23 +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 v3 6/8] nfp: flower-ct: add a table to map flow cookies to ct flows Date: Wed, 2 Jun 2021 13:59:50 +0200 Message-Id: <20210602115952.17591-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1653d7f2-801b-4e29-5b80-08d925be006c X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zOEhReagbNEUajkZUzfpzjFUhrdF/1uRhD/gGSshaosRV+DE6YX6QknRDJ1gP4M3HtBETK5AQDJMH2yV63subKJutdZDw6rGH2Ub4LTdDyjEgDW3l+dAWhGugoXRmRupo94GI+bY7aRXn4S1cnv0vPNBPHBaeAvh0fhzKZU7g/fFm8pHUUBED97Ozl5Iec8zf0Rr+PhCcUQMTb38SYuFPl6rQdVjGXN6cgOROzpkSBblI9sRQc7uk7TuInvg9rVNUOO1SY1HgUOYvSZxBJkqpDaiJIgzcbjnct5fjzhLHUXBsnUnZNgCS4/4neam7iluuMCSEkMBJSqfoVYqK2J+l/G5VtEkcqjK57ZmtXyU4tG6ygQJqvKxFVYgF5uyzVvDQn/IYNVc/0OJQUXFcWjvJgrFe1DeCX6ChauClxw9KI1maqB4hjkn8zmLYd4PivB5qyc1N9+hja9bMkSdo7TP5tyfUgktzAOqulzfXEzFbWUpHBQg0cU70EysmR2LYIhWbjEnvDCJRXTUJbIcytml0No6+iJGQ98VHIuzl30JJ8RRSOvGldcqgyu/3IGPtOCms9+HUI/ZAVYcJBI3KsLm/vHqNrNL8kV56I1cn1/cePU= 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:(366004)(39840400004)(376002)(136003)(346002)(396003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(83380400001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Vn7i2+WqnQlG1qxVmDN4L1Yq9sEA6kCH/Ce4TBljIdOHb2TAoIiYqycF8ATdfmr6j9RNny94WQYEEIRJVuso+BTfnFf/jt3MnEazA6JB7pfTUXNIOs2Cj3TFTcX/und4BE8xBdQj52IkOsKGFrD1YkhPoSY9FLbs8xku3vM704sDeLEE5t2aOkKcrXBU5Vqx2kP0GEdF23iuSXpwJojIWdH9AA41yxzO+ojaLsI86wlq1h/hpo0+6fm2tRKXURAoDt95IUIAmvZTTGbS2vdo+BmVqJqrgBX7wDv6pSHPw5+u6qxQE/t6JOPhZChoChJxWKrCq5Bf50I3TIcQBhz54f02L5sbw/dVzGRER77eyODOesgzpxTTu7oGCwh6DfMXMmkHPNLW7XSfg+eJDP/4maT1uBqj9n0RRz3k0QEw0PHzDoCp+s930MCwK2+g0o7RAQjMaQu3sfWXcGC744KN9LvB4cD8Fn9grbOF5uZfVwq4qNuIbE6coop0647q5rDwA5FX3YpU1YlDluteeG/cbABAWdGkZ8VJA/xhwtzY4pIR7uj+QG6ZlppZFR+KSfW0KwKFTkwVAawPwRrdb0eT15BEkk7BSB/zznEuyuPq3D9CJnPdWOww8+eq1LXIFkPVMZ9Z1iCTuqgq57GJWMPaK4W5Y0M3iODcz22iNNUwizMNC2nFwZGQPGXlt3Qu2yItI3myyiteKrWNaZV7gwEI46DOpykEAPOSBco35/CNNQpz1XYb0ROxUt2f2epz3TwhqOvLBiJVDH8fM5EtMRXeqlDHCgDohQmyr8JqTEQm6ELXt/hOuamJWlTCobMQL9gS8wMw/3S85psF8C2FpppLE+KGIqZ8i1BlJ95gSrVuYRbfdnlwVuqUXYu2I+ov/E8Cg1Z1cAUR8AZuuI1svP/DMgoCgRX3jv//oGZEAAI0XVCWJorSkhlv8Dy0RV+qwaBIgASKdJ6DXkpUWgMuQ+XQJzEkcgOnunpvSzOcXk57mGYdCQDRIraoPRScDatoYnKIsBaGYUaZE5PabpWAaTbxkAOBnva+PYgYVH+2xjSFpTYWQqJDffJB/m7KIdLt4ovFJwHHcqip/E5EZSF6xggN/TJnKf2GfXjL6aaqN9lL7wR+zoSbsgMQuBxSMG8np8j8Uvy9NFKgVwIp73E82sUVTHHJ6ug5h7Yd70o8dRKG3L5yGuo7/Z4+0ZejbW/C1yjXDIRpcV4FTZ/XY8uqP5/27EOpwmsRDK2PmNeIJAomDrFeynP3vYVU1Xd88AQ8b7mWuS2e4M+Dt68egvNfatXAWucgvf1HDPNg3F2/KskOTNrowSzugX/CYpQ6/jDgLtNtwaA27YYSMGnKJ0/Vu5nzLkFMzAzYnny41n6kLZXVHipkfrUrj39UCehQZ27TK7QC X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1653d7f2-801b-4e29-5b80-08d925be006c X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:23.2115 (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: NhfLaVhNbxxEboGTK/5sFiz513AvI1aOE7r8h6zzS2aN3B9kJrJ0zmcjth7pshg+sr4/qB1vIb30TKIfi9uDXqUkAB6mOiPK4NZ1WlfKpOU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add a hashtable which contains entries to map flow cookies to ct flow entries. Currently the entries are added and not used, but follow-up patches will use this for stats updates and flow deletes. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 35 +++++++++++--- .../ethernet/netronome/nfp/flower/conntrack.h | 13 ++++++ .../net/ethernet/netronome/nfp/flower/main.h | 2 + .../ethernet/netronome/nfp/flower/metadata.c | 46 ++++++++++++++++++- 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 57a5ba5f2761..f6f97224e773 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -107,9 +107,11 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, 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 flow_cls_offload *flow, + struct netlink_ext_ack *extack) { struct nfp_fl_ct_flow_entry *entry; + struct nfp_fl_ct_map_entry *map; struct flow_action_entry *act; int err, i; @@ -160,12 +162,33 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, INIT_LIST_HEAD(&entry->children); - /* Creation of a ct_map_entry and adding it to a hashtable - * will happen here in follow up patches. - */ + /* Now add a ct map entry to flower-priv */ + map = get_hashentry(&zt->priv->ct_map_table, &flow->cookie, + nfp_ct_map_params, sizeof(*map)); + if (IS_ERR(map)) { + NL_SET_ERR_MSG_MOD(extack, + "offload error: ct map entry creation failed"); + err = -ENOMEM; + goto err_ct_flow_insert; + } + map->cookie = flow->cookie; + map->ct_entry = entry; + err = rhashtable_insert_fast(&zt->priv->ct_map_table, + &map->hash_node, + nfp_ct_map_params); + if (err) { + NL_SET_ERR_MSG_MOD(extack, + "offload error: ct map entry table add failed"); + goto err_map_insert; + } return entry; +err_map_insert: + kfree(map); +err_ct_flow_insert: + 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); err_pre_ct_act: @@ -245,7 +268,7 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, zt->nft = ct_act->ct.flow_table; /* Add entry to pre_ct_list */ - ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow); + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); ct_entry->type = CT_TYPE_PRE_CT; @@ -286,7 +309,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); + ct_entry = nfp_fl_ct_add_flow(zt, netdev, flow, extack); if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index 46437de4d75f..a7f0d7c76b72 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -9,6 +9,7 @@ #define NFP_FL_CT_NO_TUN 0xff extern const struct rhashtable_params nfp_zone_table_params; +extern const struct rhashtable_params nfp_ct_map_params; /** * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information @@ -69,6 +70,18 @@ struct nfp_fl_ct_flow_entry { u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun }; +/** + * 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 + * @hash_node: Used by the hashtable + * @ct_entry: Pointer to corresponding ct_entry + */ +struct nfp_fl_ct_map_entry { + unsigned long cookie; + struct rhash_head hash_node; + struct nfp_fl_ct_flow_entry *ct_entry; +}; + bool is_pre_ct_flow(struct flow_cls_offload *flow); bool is_post_ct_flow(struct flow_cls_offload *flow); diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 060c6de36c02..0fbd682ccf72 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -195,6 +195,7 @@ struct nfp_fl_internal_ports { * @merge_table: Hash table to store merged flows * @ct_zone_table: Hash table used to store the different zones * @ct_zone_wc: Special zone entry for wildcarded zone matches + * @ct_map_table: Hash table used to referennce ct flows */ struct nfp_flower_priv { struct nfp_app *app; @@ -231,6 +232,7 @@ struct nfp_flower_priv { struct rhashtable merge_table; struct rhashtable ct_zone_table; struct nfp_fl_ct_zone_entry *ct_zone_wc; + struct rhashtable ct_map_table; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 062e963a8838..7654cf6a3222 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -504,6 +504,13 @@ const struct rhashtable_params nfp_zone_table_params = { .automatic_shrinking = false, }; +const struct rhashtable_params nfp_ct_map_params = { + .head_offset = offsetof(struct nfp_fl_ct_map_entry, hash_node), + .key_len = sizeof(unsigned long), + .key_offset = offsetof(struct nfp_fl_ct_map_entry, cookie), + .automatic_shrinking = true, +}; + int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, unsigned int host_num_mems) { @@ -528,6 +535,10 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, if (err) goto err_free_merge_table; + err = rhashtable_init(&priv->ct_map_table, &nfp_ct_map_params); + if (err) + goto err_free_ct_zone_table; + get_random_bytes(&priv->mask_id_seed, sizeof(priv->mask_id_seed)); /* Init ring buffer and unallocated mask_ids. */ @@ -535,7 +546,7 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kmalloc_array(NFP_FLOWER_MASK_ENTRY_RS, NFP_FLOWER_MASK_ELEMENT_RS, GFP_KERNEL); if (!priv->mask_ids.mask_id_free_list.buf) - goto err_free_ct_zone_table; + goto err_free_ct_map_table; priv->mask_ids.init_unallocated = NFP_FLOWER_MASK_ENTRY_RS - 1; @@ -572,6 +583,8 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kfree(priv->mask_ids.last_used); err_free_mask_id: kfree(priv->mask_ids.mask_id_free_list.buf); +err_free_ct_map_table: + rhashtable_destroy(&priv->ct_map_table); err_free_ct_zone_table: rhashtable_destroy(&priv->ct_zone_table); err_free_merge_table: @@ -589,22 +602,40 @@ static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) return; if (!list_empty(&zt->pre_ct_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, "pre_ct_list not empty as expected, cleaning up\n"); list_for_each_entry_safe(entry, tmp, &zt->pre_ct_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); } } if (!list_empty(&zt->post_ct_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, "post_ct_list not empty as expected, cleaning up\n"); list_for_each_entry_safe(entry, tmp, &zt->post_ct_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); } } kfree(zt); @@ -617,6 +648,16 @@ static void nfp_free_zone_table_entry(void *ptr, void *arg) nfp_zone_table_entry_destroy(zt); } +static void nfp_free_map_table_entry(void *ptr, void *arg) +{ + struct nfp_fl_ct_map_entry *map = ptr; + + if (!map) + return; + + kfree(map); +} + void nfp_flower_metadata_cleanup(struct nfp_app *app) { struct nfp_flower_priv *priv = app->priv; @@ -633,6 +674,9 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) rhashtable_free_and_destroy(&priv->ct_zone_table, nfp_free_zone_table_entry, NULL); nfp_zone_table_entry_destroy(priv->ct_zone_wc); + + rhashtable_free_and_destroy(&priv->ct_map_table, + nfp_free_map_table_entry, NULL); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Wed Jun 2 11:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453071 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 4CB14C47092 for ; Wed, 2 Jun 2021 12:01:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 330B561360 for ; Wed, 2 Jun 2021 12:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbhFBMCv (ORCPT ); Wed, 2 Jun 2021 08:02:51 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:6496 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229610AbhFBMCi (ORCPT ); Wed, 2 Jun 2021 08:02:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X06XFj8pxt8WHGrDk+bI9VAznn1afwZm1DRMrDAOMjDYKNIPYyD1oqw9NLFzMbTJLhQqYRGYkOtqvC+xkSzDJT1LG8ZXHVQ60zo2nXCh1uXHCGvPu9I1l7HSeNR/dFJ4Vvah79xjAkr5OFETG+6RgYd/D7Gs/ip/sTS/70vtSXfifqbIxYbTKrFkAUGod/ElJw7FA3CZY16paBoK1cClO122UPvgpzb3uQzyaXw0G/bTNpzoqOOapeari07w15iQqq5EeFZojaIleTJVANCa4SgJJHtx7p8V3e3yEpZoeOa/S+bnfseLQ92cU6lzbjw7WoPZ/jJQya+Iu9/0LQ701g== 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=8G49HKvd/w9FkAxnD9HWDRnCyLu6FCLtPoniswNkBSM=; b=DN7vCY3qE9R+rnVOG3WqyMgwzSWNXpT7m1gPfu3I5YrrFtuRLZjxsUvarjfHAAKoalXjJ5ZOPErngUFjjDcgFuybohnoCbKWw/FZpFzYpXUquG4vb2R6OG8mQJEi0vvNbfE6b58/eWC6CgBydnGB7+cBzd8AB0w714rsJxmoEX5g/P9f+eVxFF7R6I+1AXaZH19VPcZH6SyAzZzBw26c5NcNvMAuZKyV4DNh4JxCKhc6jU3SGMzGjLEt+pQnAvnZMXbabAYGjqs9n5JVUzrFsHoHftKJQ5P129ZWJR/I4AdO8WbWgiZgEpN/jKfjchiTa8JZ3CbJe2ulzQGwBKnnWQ== 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=8G49HKvd/w9FkAxnD9HWDRnCyLu6FCLtPoniswNkBSM=; b=k1zgDfyJr+1G2gAT88gp78pHcQ0/EMeL/uWkGPIUJBY9GaCANu1N1AODu3WwESeyFoSSMpWezHsm1i0L+qJLQWsMobnqe+O0L15OVcEINwZSiBTpCHcvSlTYh2iGNtyX70VJIMp9vc2ckiEkWmz1wt9L6p/ZdT9EEilepqNC5bI= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:25 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:24 +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 v3 7/8] nfp: flower-ct: add tc_merge_tb Date: Wed, 2 Jun 2021 13:59:51 +0200 Message-Id: <20210602115952.17591-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9889a285-67ef-4aad-5e69-08d925be016a X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: 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: uE6pQfVGjsO1M2HYL5Q+owAiK3A35z58mtfkQui0Uv5X4QlAtcZxKXRiiZGWktlQYegue2eJ5swKAm47M98BFzTFszsdHQEF4gl6f7yulC7f95s3GgJu2m3t9Hfq2udDoiDNriahmJ4+cB/HqEjBBGiOzRMpTlLuXqFEsnLsFYwzr6jSV6vmrOd5oxeSIu8xrraUH2jzJ8iGRbFFq65LAcAZ2pz/4/ZCq3sWfGEIM3KvZ+tYGdLfZZe1UY+C5walCJce+wUMEsguHdTszYVOLBJxd51rAVnzuudbTnhYhurEhMxZN2oTkUiuOohJ/1GRTJL58RvDHnM6TkhWy+3RVB3ae1bsGlP0YEG/VKVdHExtXREDSh1wmX0zo2SbK95e3wRseto103+vzhjyQU9MHIzenoO/Mkdgx+ZNWX4sY4Ze+EEMRPTNECRKKakTb6qInzCzearlIaQE58NulkSYq52/xK1ITnVUmbymIm+Cegs48CuxsyOHiZ0YCT9vCrppDgo6zrbLd5E08h7egoXbB7BFrC+AzPZosnkAuwj9/ZK9VeMglQ1pNFC4e8b9CyQYeKstJ5Sf2zaY3eS0FNasX/S5gZDHWyQg7S5yMZamhoY= 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:(366004)(39840400004)(376002)(136003)(346002)(396003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Avk1rdynEEYaPQ+xM/xJm5Qtzbt+IWU1wol/bKztbTHqArlIzksHs8ERYlmxbm5cB5YTzRXmWsa/UGo9zyLPlUbbc7jxsPpswQnulSGyr24NnXJib7c0Bu8463flEbzPCQ7Nl2JcBDLzcxFa21zOOFiAj8HYjxeQQVEllNcNklyrhie/JolLe1KhmlI+zQyrZT/qTggKKM+ZO9uRIqkyKgwblRo1WX+ZjmidrJwKeOpbbEUVy7s0zQSedCcp2wGmZqkzxrH6nGH/wwjEsRh7MqHq5EwY3oLQ2umfThjjSn6AGDwuU8myP3Dc5O4yf7PnDnDV1YwtopQ1oImy/dqo9Hyf0IKnCrf2zZ5aCZBnOc+66sbrzHi7NnK9ij6Wj9F9Kpk+OZc9IO/MTLSiJkB2l3L8LS+ERB6kxWO1R2f9sC/qR1SXitlwtO4IcBJxF8T85tLKrfwwUbQ+g6ks6Y+Jqf+Yz+Sbp8po7u+/dRjiIzHrFmkko4RFv48v5DdUbWGQq1wPhDb8NEnaXjoSsA/zIGJH4O/OURPyQ9wfc1hIHDzVo1QSymWuZhgFSYXmfzNdlQGxrIUzctaw8RzgGnyOHfQoybKfHx3Bp7MKgXYvfQzu0H5s5d1D57wDgJQkpGd0OWv2rN3rfzCQj2oTT9DXGJsbCa7cE4Ug9svyCqSHNu/vgZVr4Gtt0LAbbkrqIvjhywF7Ux2lWSBISO4tClYKwDNCc5GJsWZqIErBoStbMeGuLCnUU1LbkHradZAkSBc3QdHYnWk4c3L4D0pq3WNyaXSdlMGRM6PpcLX0nEW7OoE+VA//6qx2Q4nCZ3/fjMdvyPMQFc3uEuPnvpAak+7NGg4jSTo2M3VyUaV7sRFeEtItnU1IL2bfYCLhp15MPsjU/3agAKV0WoRqpFsu5TVL2Euv2G23wfCrZw2tkzyqAUQYae39VCCgthSifNuGCEp1eb0rc20kGdea2DWlcoNMzbtT5V0ZIgYogDpxm7sqrfVDA2tJuN70gSUl6LGwc+xf4aLC39wUjOcgTOnPsDSsbA6IgUddBsVpRSOygIkT93m2pGtY5sJsrL5CoAEUD/jMKdUKa+DrL8F5olOfUysmw00yhC0xPjfgmD5vzN6sfFxGAiuFDlDLOOPassjc1DKWAPJOOomwwQBECAohcVTw0a0AYHMeCL0M3KwrfBncYLEiGYRHFC5b4bcnzebH4LtNqq9oMsRxRh3NdmcJ0dcRpViewFQyN7UJ/6AGSyPefCphNf4hmdJpkOHZdamtFiU7a6u8/ayeJbZ3tj50zTo0xbf2RV75pSV2T+/rqEFHsZ/dF+epsp90YIhXMGrraecbBrnt+jp1/EUI/VPlDXcAUrdX7fVN4wtykilea6yf97+3PT9NR/uQSLHZqgS9Vcq6 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9889a285-67ef-4aad-5e69-08d925be016a X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:24.8473 (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: t0tZAk79m9SdKPE7L0fCXhDO0Kmnv21kWfFIsA6vxma0njo9WhBqL0dDUxj6nCPWX/OJHjpKLqnfqaJcK4e82R6plWxIgSTqPC2W0CQFOFY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add the table required to store the merge result of pre_ct and post_ct flows. This is just the initial setup and teardown of the table, the implementation will be 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 | 29 +++++++++++++++++++ .../ethernet/netronome/nfp/flower/metadata.c | 4 +++ 3 files changed, 47 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index f6f97224e773..afa024971c08 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -3,6 +3,14 @@ #include "conntrack.h" +const struct rhashtable_params nfp_tc_ct_merge_params = { + .head_offset = offsetof(struct nfp_fl_ct_tc_merge, + hash_node), + .key_len = sizeof(unsigned long) * 2, + .key_offset = offsetof(struct nfp_fl_ct_tc_merge, cookie), + .automatic_shrinking = true, +}; + /** * get_hashentry() - Wrapper around hashtable lookup. * @ht: hashtable where entry could be found @@ -87,6 +95,10 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, INIT_LIST_HEAD(&zt->pre_ct_list); INIT_LIST_HEAD(&zt->post_ct_list); + err = rhashtable_init(&zt->tc_merge_tb, &nfp_tc_ct_merge_params); + if (err) + goto err_tc_merge_tb_init; + if (wildcarded) { priv->ct_zone_wc = zt; } else { @@ -100,6 +112,8 @@ nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, return zt; err_zone_insert: + rhashtable_destroy(&zt->tc_merge_tb); +err_tc_merge_tb_init: kfree(zt); return ERR_PTR(err); } diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index a7f0d7c76b72..3d7d260c6e5c 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -10,6 +10,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; /** * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information @@ -23,6 +24,9 @@ extern const struct rhashtable_params nfp_ct_map_params; * * @post_ct_list: The post_ct_list of nfp_fl_ct_flow_entry entries * @post_ct_count: Keep count of the number of post_ct entries + * + * @tc_merge_tb: The table of merged tc flows + * @tc_merge_count: Keep count of the number of merged tc entries */ struct nfp_fl_ct_zone_entry { u16 zone; @@ -36,6 +40,9 @@ struct nfp_fl_ct_zone_entry { struct list_head post_ct_list; unsigned int post_ct_count; + + struct rhashtable tc_merge_tb; + unsigned int tc_merge_count; }; enum ct_entry_type { @@ -70,6 +77,28 @@ struct nfp_fl_ct_flow_entry { u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun }; +/** + * struct nfp_fl_ct_tc_merge - Merge of two flows from tc + * @cookie: Flow cookie, combination of pre and post ct cookies + * @hash_node: Used by the hashtable + * @pre_ct_list: This entry is part of a pre_ct_list + * @post_ct_list: This entry is part of a post_ct_list + * @zt: Reference to the zone table this belongs to + * @pre_ct_parent: The pre_ct_parent + * @post_ct_parent: The post_ct_parent + * @children: List of nft merged entries + */ +struct nfp_fl_ct_tc_merge { + unsigned long cookie[2]; + struct rhash_head hash_node; + struct list_head pre_ct_list; + struct list_head post_ct_list; + struct nfp_fl_ct_zone_entry *zt; + struct nfp_fl_ct_flow_entry *pre_ct_parent; + struct nfp_fl_ct_flow_entry *post_ct_parent; + struct list_head children; +}; + /** * 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 7654cf6a3222..8658c5cedf91 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -638,6 +638,10 @@ static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) kfree(map); } } + + rhashtable_free_and_destroy(&zt->tc_merge_tb, + nfp_check_rhashtable_empty, NULL); + kfree(zt); } From patchwork Wed Jun 2 11:59:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 453933 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 04DB7C47097 for ; Wed, 2 Jun 2021 12:01:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2B1361360 for ; Wed, 2 Jun 2021 12:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbhFBMCx (ORCPT ); Wed, 2 Jun 2021 08:02:53 -0400 Received: from mail-dm6nam12on2135.outbound.protection.outlook.com ([40.107.243.135]:6496 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229765AbhFBMCt (ORCPT ); Wed, 2 Jun 2021 08:02:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FrwhyMhzExZAxUpzzlIpeFcCbr0IgE/5cqVJAtUF5gA+236YnbxjRnetgRDm8X+3QmLSPAuPmHumNEiKQzlzt++kGddqvXZhgI2HPtyL+i1xyXFzVo2yHELW50a00o5sAk3gpiapON3Vgc+iuTARXMVdTm0xFklfjccH/3bYkBxa8F2lXp33E7CYd/OQQVSj5YgvTQtp+Jym5q/udYMOr6Cpn7QfHQ6HpmHxT8ojMqh9EvHsf3K80hnw/9mcKBkFffx4H5b2SXI4m13RBHjxoDhwIjsydDHesCykbfb4KxLy0qT7IGvwhVv74eIXVkBSHBV1Wze9aDyNEZfRj79vCA== 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=0bZf2r92aZyzHVMYvs8+PJ0xF5cqzQmo2N0d+moaspM=; b=eiWq3bLMrs6zhXi1fnCUxFkGJLH1HxfMuP53OYzZn446YYswn4dKsFSULeJK3w4Fnn5vIe+5y1sJ3Vt1XIO4vLM/WN28U+MZAEKpCpu+QmUyy0080Yj+VoWFW0dP/0fFwPmVBqhI3SSjFJvtVkaEY0jMGnEG/Nny1sXXBim7YJB6XcekHLRuR+7LLaV7CLLqdw5qzjB5I0WZ+hKLurbKqtk7VfS1v1Hzmhw1lX7ps03/CQjVUgCPgCGdqKtHn7FjypVg5A7X1njOZgzaUt86h38k44T7pJSG6UFd0nQSEYFQ3Z5W2eXDV3LHgWiyKph+gEwEMSOugmZLGXfdoUOLow== 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=0bZf2r92aZyzHVMYvs8+PJ0xF5cqzQmo2N0d+moaspM=; b=nmfCh9eCRYjBeiWa8g0hP1Sny3CZ933KjEuJpqWLUpPMp+PVAXctUpIy8eFJ2+4+SqcA3DwFcyG47hKgHdMrPV1FA8sq1GD39S0hBCqir+EjGd2fYNVt2UowemFKNdzItgDd9oJzNrkwoPXDLuVZcp6Z8WT3YkjuBoDxJa8wXcY= 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 PH0PR13MB4986.namprd13.prod.outlook.com (2603:10b6:510:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Wed, 2 Jun 2021 12:00:26 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.018; Wed, 2 Jun 2021 12:00:26 +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 v3 8/8] nfp: flower-ct: add tc merge functionality Date: Wed, 2 Jun 2021 13:59:52 +0200 Message-Id: <20210602115952.17591-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210602115952.17591-1-simon.horman@corigine.com> References: <20210602115952.17591-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a) by AM9P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 2 Jun 2021 12:00:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0535b9d5-9da5-4a4b-84bd-08d925be0263 X-MS-TrafficTypeDiagnostic: PH0PR13MB4986: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cdNfuhGiKM12uNgF9RIAuJRbtI7nW8ql5UEu5VRJ3QF3Hq6qiihxf7PU05celPt3bhTR6lURaRNQK2l1jvERR2eqEbz2pmUJop9amCEPlNgCO5qykMP3MV/DIvDu4TXEP5fZh5qEV+izXB6iFM7VKT926teGvB6PHP19eEw4qReYAyWXA52N2KehBb48bo4P+Z2ytU6Mt2so5hMOns0h5PoeJnNMoTHd6gzXl/0LgGYHujpDqQ3iXHG24aN8S/uY/1CWeW/GKVzxG0b7Ypg7LUYhb17fQuAoxlU8ARKhMHxadvdHzoUHp3Vceabm7kbjEPTVv0dK4qFDuQMr6Jq+dUYeBQ0bWXKMluJYKOJbsQbbQd6u3m5JkPEUFGpKCgXVuT4gCUXV1OI3HxVICn4RudHYW6wyr2ciplhAhnlTJOGQkr7R/S26mxuSCVUjTQaTHQCusxNlZH6YJm6EWxa84Aj7In7guH0+a4ih9HdPD13SZvYyHch5+DYIF2CtgbgA4iopriBnmdiqrXC5Lrk/ZA2ZGfivGGysKvYJ+4YriQW4zK/4u5Ke/FsVe3EegGTKrkHHLHjcsB3ss2+vz//jLRQb/9W4Yp5Ef2I4yA6bvV0= 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:(366004)(39840400004)(376002)(136003)(346002)(396003)(5660300002)(44832011)(36756003)(66556008)(6486002)(107886003)(66946007)(38100700002)(1076003)(8676002)(52116002)(6512007)(6666004)(16526019)(4326008)(66476007)(86362001)(83380400001)(2906002)(8936002)(478600001)(186003)(2616005)(54906003)(110136005)(6506007)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ejfqAH9fnr5vX/lzXinwrKT7+m8yIiFBtVLtd56mR9Bnxd0Fh2lik3APmyxw5SBhAZyd3m8EzE2vxWo5+TjCPZ0ty/n4IK+LHNV7z8CA3AOlQ+btqif33m9GW6xNugPjCcNfqU1ItIlqHJKM6KrtCcyOdscC6ivc13Aqph3iWS/uqFHNLqo92vWRKYwr7+/LpnNYdN+qcIKS+5B6Ug7ZOCvB7Wf+Nf4/bdwkD8r4pHHkwIbtQ5tf9EIwP5upc3gdy4N37z2Mt0uzx2nNBOBxUhVrKQdIj3ntXV2T2a4QOpHW6kmVSeisHxKtGvp2/XcjercOlGFmukTxqCMNxrQ/tqzw/pMsVHzwUqAEypwHogQ/ijd7P+OgPwX4dpFBHAG34KyvNPxzu0wafndJn3TQwetw84izzlq2zxnunpAYLJNlGEvDhosqqLYXymTZPOyX0UJ1XhjTzegVYCsUA4hG8byOFeNGtrWe6Lmb7+C1MFSYy0Y40h+HM0wfTrYbvvVYJOPXCwUgEv4/rn6DI07ZWgThhijsPo/umLPWyqWXz0yArQH0KdM3OIQE+y+qGjlcLMBUz9f2PEIrFZkDSW3jjV4dMzFigB6FTxVluQ15wcd9+Vg71ppnS1alna39XzEvLBotqt7qfOtUgRBK5o3cuSUP0SYDFMHBEEE1cil+7ej1hE0FafJWrJZX6t52ooLH5EyjVwmDLlHNh3zxFSw99X/hJsynpKEI8FJKNSFoz3flD+pA3hnsbp9xojIwc9nN/TGHyx5BcHc68xBiHwfVusC4c3Aj1k8mmcKdfGrSsYfLhBBzj2hnoA4VHfMyTVToK83AcvKdtY/WzlCZ9IqjShf+icjJGWiumlqPVIehKFoPX336ySepsUgnoeM2kj5/SCq45Ih1E8huM3e+eOupijd+TZ0VN70kzA5poBuALkoauHj4i1c3NpLO50zFA+5pOJZxWukaFUIR+VYf72WVyEsUEcFQGHWZK7WevjjCrawCTrnD8KZVTmbgngQb1Yxd1tq6+qujFt1Jim8L1jycSrk9SQcbA+v9PVBgCCCjRmVSEuqokecFZgFfzUEpqnZP/RLZJW+WPHPqCSV4zGj0sDGayy5zok+FgDRhb0TCMKmRJJMDUrc8Xkas4FxTPkrM3JdTW/9L+k/he/fLMjkAGzqPPTwawM8Agx0r/2HSLIUwxn2HSvuSEbk4/TELMFFDXK3k51r/iQbXtyACDEUawoAB8HFH3fsOhmaZOiMbaeGSaAhGBraJd6+RyZiD6yLkH278yS1xHOjfOoDZnyG/lqI7pOLbmu8FI2C3Vn9cFXVmiuohoSa3UB1PgXUclaDq2ESRtundGQqPSdD0qoxBdrNjT34yPi9rIXf1t7zyiOTEncuf/8rTexT/K6sTeNTG X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0535b9d5-9da5-4a4b-84bd-08d925be0263 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2021 12:00:26.5408 (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: Vm3XyUhHaB5kWVoKKk7Eu94cdK0Zy4vYU/Zt+vK1TJ4FxrMLVJ2k2irNEwNNs3x4o3TBlw/L6yE15BpzSyKgbo2ny/i2Dp+ZddcX8B9fIN0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4986 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add merging of pre/post_ct flow rules into the tc_merge table. Pre_ct flows needs to be merge with post_ct flows and vice versa. This needs to be done for all flows in the same zone table, as well as with the wc_zone_table, which is for flows masking out ct_zone info. Cleanup is happening when all the tables are cleared up and prints a warning traceback as this is not expected in the final version. At this point we are not actually returning success for the offload, so we do not get any delete requests for flows, so we can't delete them that way yet. This means that cleanup happens in what would usually be an exception path. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 162 +++++++++++++++++- 1 file changed, 158 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index afa024971c08..b1709affb52d 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -64,6 +64,77 @@ bool is_post_ct_flow(struct flow_cls_offload *flow) return false; } +static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, + struct nfp_fl_ct_flow_entry *entry2) +{ + return 0; +} + +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_tc_merge *m_entry; + unsigned long new_cookie[2]; + int err; + + if (ct_entry1->type == CT_TYPE_PRE_CT) { + pre_ct_entry = ct_entry1; + post_ct_entry = ct_entry2; + } else { + post_ct_entry = ct_entry1; + pre_ct_entry = ct_entry2; + } + + if (post_ct_entry->netdev != pre_ct_entry->netdev) + return -EINVAL; + /* Checks that the chain_index of the filter matches the + * chain_index of the GOTO action. + */ + if (post_ct_entry->chain_index != pre_ct_entry->chain_index) + return -EINVAL; + + err = nfp_ct_merge_check(post_ct_entry, pre_ct_entry); + if (err) + return err; + + new_cookie[0] = pre_ct_entry->cookie; + new_cookie[1] = post_ct_entry->cookie; + m_entry = get_hashentry(&zt->tc_merge_tb, &new_cookie, + nfp_tc_ct_merge_params, sizeof(*m_entry)); + if (IS_ERR(m_entry)) + return PTR_ERR(m_entry); + + /* m_entry already present, not merging again */ + if (!memcmp(&new_cookie, m_entry->cookie, sizeof(new_cookie))) + return 0; + + memcpy(&m_entry->cookie, &new_cookie, sizeof(new_cookie)); + m_entry->zt = zt; + m_entry->post_ct_parent = post_ct_entry; + m_entry->pre_ct_parent = pre_ct_entry; + + /* Add this entry to the pre_ct and post_ct lists */ + list_add(&m_entry->post_ct_list, &post_ct_entry->children); + list_add(&m_entry->pre_ct_list, &pre_ct_entry->children); + INIT_LIST_HEAD(&m_entry->children); + + err = rhashtable_insert_fast(&zt->tc_merge_tb, &m_entry->hash_node, + nfp_tc_ct_merge_params); + if (err) + goto err_ct_tc_merge_insert; + zt->tc_merge_count++; + + return 0; + +err_ct_tc_merge_insert: + list_del(&m_entry->post_ct_list); + list_del(&m_entry->pre_ct_list); + kfree(m_entry); + return err; +} + static struct nfp_fl_ct_zone_entry *get_nfp_zone_entry(struct nfp_flower_priv *priv, u16 zone, bool wildcarded) @@ -210,12 +281,48 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, return ERR_PTR(err); } -static void nfp_free_tc_merge_children(struct nfp_fl_ct_flow_entry *entry) +static void nfp_free_nft_merge_children(void *entry, bool is_nft_flow) { } -static void nfp_free_nft_merge_children(void *entry, bool is_nft_flow) +static void nfp_del_tc_merge_entry(struct nfp_fl_ct_tc_merge *m_ent) +{ + struct nfp_fl_ct_zone_entry *zt; + int err; + + zt = m_ent->zt; + err = rhashtable_remove_fast(&zt->tc_merge_tb, + &m_ent->hash_node, + nfp_tc_ct_merge_params); + if (err) + pr_warn("WARNING: could not remove merge_entry from hashtable\n"); + zt->tc_merge_count--; + list_del(&m_ent->post_ct_list); + list_del(&m_ent->pre_ct_list); + + if (!list_empty(&m_ent->children)) + nfp_free_nft_merge_children(m_ent, false); + kfree(m_ent); +} + +static void nfp_free_tc_merge_children(struct nfp_fl_ct_flow_entry *entry) { + struct nfp_fl_ct_tc_merge *m_ent, *tmp; + + switch (entry->type) { + case CT_TYPE_PRE_CT: + list_for_each_entry_safe(m_ent, tmp, &entry->children, pre_ct_list) { + nfp_del_tc_merge_entry(m_ent); + } + break; + case CT_TYPE_POST_CT: + list_for_each_entry_safe(m_ent, tmp, &entry->children, post_ct_list) { + nfp_del_tc_merge_entry(m_ent); + } + break; + default: + break; + } } void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry) @@ -248,6 +355,27 @@ static struct flow_action_entry *get_flow_act(struct flow_cls_offload *flow, return NULL; } +static void +nfp_ct_merge_tc_entries(struct nfp_fl_ct_flow_entry *ct_entry1, + struct nfp_fl_ct_zone_entry *zt_src, + struct nfp_fl_ct_zone_entry *zt_dst) +{ + struct nfp_fl_ct_flow_entry *ct_entry2, *ct_tmp; + struct list_head *ct_list; + + if (ct_entry1->type == CT_TYPE_PRE_CT) + ct_list = &zt_src->post_ct_list; + else if (ct_entry1->type == CT_TYPE_POST_CT) + ct_list = &zt_src->pre_ct_list; + else + return; + + list_for_each_entry_safe(ct_entry2, ct_tmp, ct_list, + list_node) { + nfp_ct_do_tc_merge(zt_dst, ct_entry2, ct_entry1); + } +} + int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, struct net_device *netdev, struct flow_cls_offload *flow, @@ -290,8 +418,13 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, list_add(&ct_entry->list_node, &zt->pre_ct_list); zt->pre_ct_count++; + nfp_ct_merge_tc_entries(ct_entry, zt, zt); + + /* Need to check and merge with tables in the wc_zone as well */ + 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"); - nfp_fl_ct_clean_flow_entry(ct_entry); return -EOPNOTSUPP; } @@ -332,7 +465,28 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, list_add(&ct_entry->list_node, &zt->post_ct_list); zt->post_ct_count++; + if (wildcarded) { + /* Iterate through all zone tables if not empty, look for merges with + * pre_ct entries and merge them. + */ + struct rhashtable_iter iter; + struct nfp_fl_ct_zone_entry *zone_table; + + rhashtable_walk_enter(&priv->ct_zone_table, &iter); + rhashtable_walk_start(&iter); + while ((zone_table = rhashtable_walk_next(&iter)) != NULL) { + if (IS_ERR(zone_table)) + continue; + rhashtable_walk_stop(&iter); + nfp_ct_merge_tc_entries(ct_entry, zone_table, zone_table); + rhashtable_walk_start(&iter); + } + rhashtable_walk_stop(&iter); + rhashtable_walk_exit(&iter); + } else { + nfp_ct_merge_tc_entries(ct_entry, zt, zt); + } + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack match not supported"); - nfp_fl_ct_clean_flow_entry(ct_entry); return -EOPNOTSUPP; }