From patchwork Fri May 28 14:42:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12287173 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 8B6DBC47087 for ; Fri, 28 May 2021 14:43:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6909C613D1 for ; Fri, 28 May 2021 14:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235513AbhE1Oom (ORCPT ); Fri, 28 May 2021 10:44:42 -0400 Received: from mail-bn8nam08on2116.outbound.protection.outlook.com ([40.107.100.116]:44832 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233627AbhE1Ooj (ORCPT ); Fri, 28 May 2021 10:44:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WHdv9UJ4Ft3vDJfV90cA4TVne6eHN47LJTHbu3KMDsPBdCE323B2sVJ94Z91AdXZk8PoA2OHBNe+xfprUmR5/jpWPpGWhpDCIGJ77lTRS9L/1/do6dSqykF4Qa3CgO0JFzDaQoz+Xw0R59gDbNwKTkTk3Nv0dLQs1jpWjJyigcAllAV6c8MzrWje6MCRFY96Mbl87/f/xJXW5Sdiee3SQm/HuYIHK7kh/dYTKWjiCiN0UaMd57lTR3Idqapttj/ZHDQwSFFREMCnAHrjrIqOzA2v8QWWtC/6PcS5w+Kz6/7AVq5ksiX9Bc1UT6xu896Soiv4ZpSiJtnBsyjiBCWJzQ== 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=BGbDd1bxLnEQ5zeNAxH4GWX/R5o9v75OkcL2AJBEkRW9U0tQrO+IeuR9YGZ9r06NKEdU2K3eekev9MiCRBxRIEZVw+IoftlPd5WGhMu3+pI0egkqdIF6mekx9kQymkenvN7PTvEKh0J8gjZZbfLJtz0jcs+c18PrlM4+fiovPLiOx2q4o7V3ZOzgAGRYnD2yqm6LijreCeG7WWuWYTy8QuX8+cgr1VzQ/N9RikevtyPh6gri6xqCpU/cB7amSlYKAZXB1DyglT3QIUZVET9dFh/oEJ337Iwb4Bc9RbS0j9x0EkgRMHv55fejMctMJcJ10oxOlO5qRqUFsbZo7edaHg== 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=nCs+qgBUg+/s/XyjQjxTAZW0/C0uBwloiQDtbvmNjoMwu6eX/UV0uzKwJvXzvqxxYmcKtqFOzSuQbrEd90mukBszUyIkEt6EacFK9xPzZvVVBue6uHSvNFuMD1Be8fOe4T0lQshlOMNUS/uc4kJ4b1Lg2JatcotGgbc72YX3Tc8= 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 PH0PR13MB4826.namprd13.prod.outlook.com (2603:10b6:510:7a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.12; Fri, 28 May 2021 14:43:02 +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.4173.020; Fri, 28 May 2021 14:43:02 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 1/8] nfp: flower: move non-zero chain check Date: Fri, 28 May 2021 16:42:39 +0200 Message-Id: <20210528144246.11669-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c8b33f1-444e-4bce-a7e3-08d921e6e53a X-MS-TrafficTypeDiagnostic: PH0PR13MB4826: 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: w36aZMzhbJEAMbLSEF0Ed7jtgoJiJFJM9djw0LVL0zIbyFA7EzJKqTKiqo+KacGupXyrg2rA9QeCD0Ye4NMP6VGuGyLjLD4xvVrQ5F0ny11t7x3VnOrfuN0pGUSpGKH6o2urtuAD4YYMJJwF9dwYo/yziDttJHKaF18CArxWhKJgR8X7NW6DaRPc8sbqOeRx2fJrZJnz/Re54VbI2UC3Vyfva5fDcQ3b6UJR8bRRvp1QP2Q/kydRK4GbzBePMEnyxqt+VRby5ird9Wb+Dl1dwXDGHM7cC3ILD87TvsKYOU6jgKAnML+HlrjbLdWZ427bh3eUBWUOPTO4e8Qu5QW8hFHPVEqJHq2p0t3dBSS/s5rBoeugJDavXmbgzJtYgAdYlH3BOuVEQaaPbQODxXRobAG8NaTYc1qcZJMAFL61KpwQEmPww6xFYqP/yaHymmNVKCsFz5+pPbbUhMy6b3lOH7cyF2HqtYJ9sTyM6bf9nHi9SYPYHrOFpMojMweWmogoT7Aon8zDRerkp50vCAzhXmi7DyhwVMZL/NptEf/YIgPyEDNjcQBwOxe5rc6vE0GQ8f2lb0/0D9pujX3GdxJa3VdltaBLjpWHUOawYoMvHHg= 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:(39830400003)(346002)(376002)(136003)(366004)(396003)(2906002)(8936002)(316002)(38100700002)(66556008)(54906003)(52116002)(1076003)(6506007)(16526019)(6486002)(86362001)(4326008)(44832011)(110136005)(66476007)(5660300002)(8676002)(83380400001)(6512007)(478600001)(2616005)(6666004)(66946007)(186003)(36756003)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: agyMNar/C7jHCML8Ny4wKWi6ockkiuHHWgj/nY8I0FgVcQKCUZ6Lc/HSRbu3iSBhiz9VUgBMQILpvwM2uhTs6JrsOrP3mn4BCtbOaZpKI4L0VBWdTcCPoiahhiknuWesLXmGc9CSh1x/OlvG5B2y0PyxnYZlAE3YC+k5SwEudwZzDlgEwEpIzQF7aCtle1d6SGb5x6mGXcSKtxuIdQg1oPUZBIVgoPFgKgub7JCjlCYoyu528/O1NnU4BbIRm/FMY8urwrnngJEviG4wFjWjbS2jO+5UXzt1FyIpU0ZQ+3YWdGPxzeelpdBMhe6L+ZF1b+ZJ3z+rbNcE8qS8ovOTwSxOYq9RFhgM41Grn3TTYNfmvI3l8HqEGttQlOchKE/9jZCOHAhhWEUJZBTGoOqitexdgLLlpXgCNyiTUdAkG+86uX/ehkHPgM43n+JrHe0MEhtb7jsxsy/xOqPVh5Rj5XbH2M28ioyEWXSY9JVvJDhGoDMlbb37TincKk3I429+QOBgu2RD3qTMLWCqovtSDyoTpfm4jvhA7vvB7cETowcFFrddHB4Qs42AJ3R741Q3G70o9kV0L7vGrqCWTuNYkjF4r0M1N5oUunOj4PbA6ujoOjZxT/lp/nyWRDkDwhTPQCkBqG11x28RRT5iLYbGaEkz7PG9jcodTHv1lpekoKmG8IjNHnAW5gW42I+p3TxzLlKpsAMrf0vC8YdtuHMnnaTU5pRxYfPz7ymley4rvD8TQRqbLqKXI5sPz7x9eEu/fC0PQOQFhrwhmgyaGznFpp/HhftEanW3Ow5YotG+YHsHCh7fLymrRPMpTFoPmsQtF9RRODmG9NQo6a2xXRF3szqGefUcJfjgKBXI1CZiPM+6trBcug3HWdnYc6J3+6W3tujB7KaBgclpyqw5HQGDHhMZ//5maVj+EhI6lyfX64A5Hdg8heIQws04YQfMZ1ZpxCP9omKQSkLV4WOp2kCnRM9cWHKMc2nD33Ao6pOwWBD2fmnuNLGc4uos89XSJ1KfE1Ip5xr58TyrNkqmQZrxnCBEhs/kdfQwX8U3DEu5Wd1Fla8G5luh/BPZCmdtqJscqrJbpmmk5j1MP6tAJ18cQSIzGmj9cH14QKysC2jDI2Lkp6BCL3hNh821IJs2nAmYlOx5nNTnBHeigTBQccEgQ339/cBl0t4K50or2lEgU8yZySZYyfha9VkuKWAZKZdtZprZtMbcj+pacOGy/T3d7Es0B18plKmUMQ+vavD8ysGXCIxyhfiteYEZbXhvyvSEPJH5cmu0d4Kany8jvHYcBPw5Xwub8qed2sbw+/TJ9oX+BOpMSRtN5Vuef2WhpV/yXWiwn8JBat1ivJmw6Xuk5pNA45BApQLRLrdUanu8dm0JsUNjAunbh7k7ssx0weTK X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c8b33f1-444e-4bce-a7e3-08d921e6e53a X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:02.2573 (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: aLx8wpcZ4YzwWdpEzqCoYpcOjIu1kDhDrdcKKxN/7ZYyt0nWIvYPKWeXg/3Xnw5TIJdc7+G/51xHyM9WRAHhysuCZHgjjDbuEIJKKq9AII0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4826 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Fri May 28 14:42:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12287175 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 88AA1C2B9F7 for ; Fri, 28 May 2021 14:43:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62E5C611CD for ; Fri, 28 May 2021 14:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235602AbhE1Oou (ORCPT ); Fri, 28 May 2021 10:44:50 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235271AbhE1Ook (ORCPT ); Fri, 28 May 2021 10:44:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LBAZtYOX9ekrVFPoZ1+ggwjk/bWUo/yBXK6OhI1pm+fLekFHvN64KrAV6wS2jGFlPElvLqQ6/uXLxLj5y4EI4fmGgbOXRMAESARbKOub2Yirop0rZRq/WGFXwwwxytlse+XjNd80eJXAVRnSddelKXBUqDq2zyBThfZXTTCjY6qJUSebecix4cnaHmix67ZTD9EJ6JR4JVyuEpnn7AExbFVOB7sJKCwU52tj/Z+abqX8TOjyjN1ympKE6boinD/QhwhKQ1YDZviwUHpPkEquCSxWyesVUwWCPhc3jgpJBws0O0Zg24Jds1nZZKP+0tdTfNOwO+cVt0DYJ+0fTm6dmg== 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=G7U+tj6IA4BqY5/y6+EKXKY8jhrTTgFTVa96llzdnj+8n1vBFwe137Wrw6OD/kTuWGJCstoWsXwJ1JX2e6wEEGH95hQgmYkmGi/3L99QMBgASKAfrMdoIMaV0iC12aS6E3nP7A9GXf6K1tpy5EKVi5F3ovOUVDTKpNUovMPnqPYkZ6NAqNToaXmtI49xE5RbpBFz+TUqTQs2qrXR9+scc6M/EJywSXaWNj20VySbb8NoCEg5ylKoHesVVxZCl8ooBm80OBbcS839TFCPxrnizd60PYksTIhlPO4qs6B0DB2q5dQVl4/195un573rd7jPfZRiu8gfGUZu/7mupe6THw== 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=JZYMQGogHBklmsYuBzGAY1ASPNFoE2YR4TJKzm7++ZiC+SYExFUI76S8EVEYlBV0Uj/hJ+r+grfAMehFtkirhcXGhY8IT5PFpnIv3MUvMxvlN7aVJiZIZXwxoNqyeFdt8bppTanOcHYeCtHzcpSDLCaRqJVN0d5AgOuurvo6goU= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43:04 +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.4173.020; Fri, 28 May 2021 14:43:04 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 2/8] nfp: flower-ct: add pre and post ct checks Date: Fri, 28 May 2021 16:42:40 +0200 Message-Id: <20210528144246.11669-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54eb6f0a-f0af-464a-de87-08d921e6e634 X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: byq5SHiIuoWRKVDk3IEo1PDn0+frFBL0xH78B8jp2JkG4dYBHwmCfOI01pKp4fk51/B8kMfVdbf/bNs6JvI4Zrm1HUVdppnyxAkaFSmWgVOxeOwwbbDEBMcszQWrEEtRr1DT7gEmNqD9fk2EU6z2L5Pp6DE0d7MJP+jEjCvv5BlxEAlfYiuSHzytBRIV+tqlXF34YMrehIOCzVdaZBDHbWwG+Apl3KvLSchqt+3GgEDa3uaADlMGWB8RpfwrB71OnaVLdqzo1CLQrprSNfcFN8g0gpxRJYWrRBoBSC3BxF+MGqDfYwOq2whrm4Knrmpej3B5H7+Io8PVLwY7TPgZ0lhJTXQCJuLjOWHKoN2DlBd9gdnpUPjLU/1ZmphM3agQdSf56nJrsF0oJKj4ccKMtI53DpVnhqAjDImbeREJBOBZYIU7A7+h+0GqsGEtjUSo/4MYPWCfNn4+MKGQ7An0ptIQyZ0zcKP1ZtXwr1xLqXbQOfCSaSeF2zKraZb+s62yK5IuvG3Sc9cEIgFy2aQYRiSBm2noJ9WqBifjHIfVz2rEvRk2LWNMKDHQCJGNpyPvMh+4nDwdU/+1uTdFrJQI6jfvyAgDf8x41MzuvrTdo9A= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(83380400001)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: AK0hFTODbX30gxtszMkaNC7HYsVoJsxr+3kcrB7+XvyAT/ZzLqPa7DbsmToOd7iJXisdWdO4XEc5ZikHyJjOiWtWSoU69CYhPshKZsx4hpf2bup94AWxuBK6OWdlTVQBvLx6hk/xNZEexqxfwDcieAcCgU0b0JPU8ssa3Q+NkovBSbXjsGFXOfjzJvRmTIYGnlwZoy6Neo9lVesOG+Ay4l6kgI1l56zewHxIGaZ6jXm9XBClRv6eXiZA7RYokOP9mAgpHNMFjwJGMr/0m2dG+uZ7Slypft5+bK4/4iRBV3KXs1d4y2dlu1bP1W3P027wpOaufQXI9YMRfteIAIXaMYMazuTLuYJY0sR+a1g0J0TxUXmtQRoJXyDtIBAJvByq++z2NSYNJV1QHnNGMV65GZLr5R5m7UlknAUt3n9SycRBU7+2Z4IdAgT8EOZcpffqjVDePhzE8QsAHkyAVnxApSec9226qpzXxPiXookDXvyZAtr3JpNMnhH5E5DvNYWll+h4sygT9jkYjgOmsTdTxne1q2uD3NvDRdvBFjTSUCuBVDBec+0Ena8FcsKdoxskNUji1OG3CyJd/ZgTFDKQsaof6p4LUUjBCo0zEd4b3LclEb/y6VY2pB72vneVfCGiSc0at+4upAEI3SCqu1vHg+Er0KzgesSSYv7cMqB6gg2ks3t1MDuTGL2Knc0leGkqbXyHIlzlv4ZrUfr78Cy0d2Hm4Yw3tHSap4TLS21TD2+Q1VWsQ4/xv4QdnJJOIrnxvNi0VGvgpbFPBypSGILVlSWzgyF7g8GVMhZcPopmQFhESphGvm4z4kCaJA4GFXV+pu1NyE2UMzjiuS9es1jMQRYDnTyaIZd8sOjwGvY5AjDGlRJWRcj8aEBCvBXdQQqEl5EbBKxpmY2MCWPjDBQgARTnidPi+E3CewDyc6X3OpNB2jnar7l+xrlFui1VyDBQNk5aT/v7kq54hsuBy5Un5IX2gruIY9BnMs+GlBmAThGjRN2Jo/AoN+9UN+2rM/Y9b4SYxn6mqDZnD7YHPxeTnRtmf+Ye2yjIsYVpgHztiiuDRUdHbgYEpDLbqLol8BWI7RrtwaZOIFLciDnM16HiVAp4aVvz5J8cyu3yiMH1S6h8aIiSnyYed/RcHCMmPkEjB7kQV+FSo1ze5nbYZnJcXQNOSFyd8Y4MTCt7EWb/SkZIQiyHnaN/w3FjgnbfujgKAMwlDusKr0MUNz5DN/NnGQa64ElstrpjwI6WEAA6Sd3nIKGdHMQnYRtsYXIKse8uGLnPEGdgmIY5gexj6+sSIi+9f/E+nThVFen8JV2sStdUjSuU6hcKPLl+jHTQR3vBWzd6S2cA1TQ94ALtNoHRqz7Pff0Fdtq2UweG+H3m7Zf10T/s96X4abfhiRDavwGL X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54eb6f0a-f0af-464a-de87-08d921e6e634 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:03.9249 (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: BnUcwLMtSSVfy6/a9bLmjPrXo60N/MPOMqBcMMFy87T/8pB1GJ1s+lEFrpyvfoqq7k2i0KZLrCQsN4BOHfhZ6kVwdKXBdUY6LnHG61stVcU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Fri May 28 14:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12287177 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 F186EC47087 for ; Fri, 28 May 2021 14:43:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB50861402 for ; Fri, 28 May 2021 14:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236404AbhE1Ooy (ORCPT ); Fri, 28 May 2021 10:44:54 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235340AbhE1Ool (ORCPT ); Fri, 28 May 2021 10:44:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZxXgJsus9DOV9+sVBtp+1EFGGZhWQor33i62zxFhmqvIaZcVsK33wAlwudGBQdVhRClWpO4t7iJDPcKym7Ci2rTngAAF5Ewra3Ih4rsi2kN2O5WTeLT84U0qyPmo/ZDl3IZ/2dV/VQmL2WJ9JbeSZa/APkJCzyiPp1Slr+cWw9/hphtazII/5pYijRSXhCy0eqGJygWCgZ7QWgg5y1UmAeBruFdqgr/PYmkLV/UW+iXB4MNjHtAgp9FvzDRw5fHLtFNeIWzXGzKbCCG0KC2HoJD0rTh89sQ4ZM31LDUH5lFIo/VL+7+X0EMvjKuOVgBVQLoph1CFLRQi1f5VXXiHQ== 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=fUdTq9FBXKwTS7l3d4sPKuYg+RYOV36KsxCj/4g/hWQ=; b=mlKgTjkfoXSI45pFWZQgLt7bH3+1mrHE/cscXlqv4E7teZSB7xm3S6Cn32rQk097wYR3pYzircCcTEG7hDjqtj2+6vUN0zBKIFyxZSujiqWjajybUNVCWZMqzTcM4MojIoircn25etf4qQVyI52QWZh8lVOeziDTOwz6WtHBNseSu8KekTJ6pMLd51+jS9GAT9Ma0eeX3TF7V211rzW6kA8AG7HDsM5U7UtUCEOlRzwoe4eqxBS8u0+jz1lALQAGGZNnc0nzFiy6SybI9aZyLQexrJDxaI1TjECgHlvg0Fi1jDy4l/kdRI9I38RF2JzaNoNrANC/P2XPcOJ8tB7AyA== 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=fUdTq9FBXKwTS7l3d4sPKuYg+RYOV36KsxCj/4g/hWQ=; b=kzt7cK2q+MIAjIEUHt+6v48BF2Pucrb1yjfq/E8yaIRoJOdS4m8jGfYKh4vyej4+UOjw5VB5D9CPKC0UYMal5Mxze5Brw77PMWQ7wCNOusYSZFzYF02TIidMMEjq421dcOc3qfnxp/pZK3YHTKeh9sqyKFaGBzJ8DN3XKPMNux4= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43:05 +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.4173.020; Fri, 28 May 2021 14:43:05 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 3/8] nfp: flower-ct: add ct zone table Date: Fri, 28 May 2021 16:42:41 +0200 Message-Id: <20210528144246.11669-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 712bdb4e-a706-452e-3f6b-08d921e6e734 X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: JiBcG8g1zAqIfzvFpBn+lDBhMDF/B/iH7bI6lgWGjC9NW1lfgpvyn6vm53avEIUzwHv/fsR0TGIor3havA+PrFr91tJQecu+PSriL5La0ULILAvYUqY7aBt7Ac2Ogv3FLRo8gI7AbeUlZqmMDaIItoEn+wuOf/iQnJipAVQwFCmBGpAqSN9TztIyYA/gqI5qSuQWyFr4HbqlkNPYIhwvuPLqmWp1imlnWje6wtVX8roIje5EZ3XszlcC4BWQF69H7RzfQESGT3FkLIrClWepha6isz6uU502SuspUHaD2puPbjZe3YwDPFsyA7vkaQFIENtPt1OqD+/RQefThSqYUcGTaHscRvjPqY4ak5K281ue15B2u2tjROLc6y3yKclSCzW8ieW4nslQejDaMb3HWbZtth5/iQCSmlJ8wCxROE+H6cXyQX2UhKcdLz0mzzHOwteJGTmlmqV1nliY3UdITNz/d9Kdu42WUF9XQCtdoCh2OX4JtAlD9B9dZcmknejG1kDOKTdXszVPP6uURY+hocmP5deqZ9ppzi0NM9ykVAW3vTSGJaUblUsQS2S8Og9m8xbc/GZyeXhImr9s6XwJ7FbURYtCzL1ACBkHVdem40c= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(83380400001)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: H6edoq04xtPkMbiZPHABINvsapX43q411/xE7SRZjBdFBqk3k0hp2hmBkp+I3SZjIzic3SQotSEGb29OSWeu1o5/zrrttw+wmfnMBK/DBO7AmtOB2m5xIMAYO56h4/AVlO/Wq1DVmIb5D87kpxQurdS+t79BcWb/o8oAdS5qF+6+jBuPsnkaGUlFxPaZaBdz87UKRS3hHjKZzkCe2l4UeLD6aB0xcLezJV3hDaOYniKWqh2DoE0C+EQWi+Ap5XFVEET6Nk6e4GZ47o86geCzbfBnbMB7ObOS7NYWKLs4rpCgK8fMRvetTk3eapD3QLDQIECS/wHYX4Yp5UVkT4nLQ34FuyIURy3MA5d5JrAqgid47EmstiLKPYDBdkoHUhmERUT92PEA+EG6QKCtt349HRyxT4l8NsGadBRytbxkVzR/uKInYmEW7atgqwYNKKyBT2KDAzTdQbtS9Z6usUoA+6neF0yzxaNu5djNrEON3sbxA/gW9A5fk62CRiELB2tCQoEXmKr5h7bb8579/dssJOL9Rmnc+xBfVF28n2Eq6pxyMbOELoXCVSS2rxY1vPOv0mjuttZWs3JZps2i73yjl++iRGeedjJAlfhKVVkAIx2AjWytdyZAEGc1l/YBxDEgif8z92CP+01jIG84NFBG/Mex2qwD85PUczdnDNHjC3PJ2v2P8Z0yrSsd0B3XwaXgeEL2HXVavV8utq4xnGNrZQWyIiLQqlU0EEVzqXa28GS4EDuv//RtGCjzv/vypHPjD2frLDxLk+VhQYeOHUOecCJHOzUPho5i3Eus0JDVuWPA4xjXzGbXD9tlEiGDkD+SBaOImSTJO4kEFamuwMZWkDH/Rf5wrmSWU+3/vvHS6Nr19AgtVCHrCbZn16XjraJ9w/KGry+lfB0XOb6BsOFYJHjHzfjtfexVW7sh7crJwHbgH0kPqUE4LTdmu53+KJuACAe58tKkixmONj4VSNqjej8V05gRWDPSkeq6m6lXmzko9CQoz8IMcFszVc6t5j3oMGPhWj49Nhc8GV+SvDkzvkb+rO/PolAq8XSU8Owq27e9nIizrPBmbzD7VT/at8nybf/d5g1RIyvIYCrZyUxr3rLr6XzN9R7iCFIs2aBpJa/ua83t++bJFfU2ttGT7k3HS/SqeKnrEf5J5zMhHw5UV7PqP4HT+I6On1OY9p3OZqQ242tGbwDizKPs4pMIDF0jw+4yBR8J3nPXspcEMzAEJD8Y/BovFrhMX8fI/h1iKKxOmQ2m4k66IzHUodBDx7V71yd1qnEEO3jg1N2/bun7nhbRllTz5NWCl3pfgJW2jONf/c8lSX/vYACdhj1WsIZhUCKGwjx3XCGeWgDcmFz8pZSTOYdzP+OXgGshU447A8uGOV49l+6eiSf9jyHU55G1 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 712bdb4e-a706-452e-3f6b-08d921e6e734 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:05.6115 (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: hRbZDq6ijA4d+FA4tlrkofA78BZLPlo7ypzvNSczqOjs/Nj6H9fyMvWTXMKSozfm20iP1p/2+lu1x3MS5Hwq1DArug5IfXVO0Jy3T3Eu0SM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 | 23 ++++++++++++++++++- 3 files changed, 41 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..b9de3d70f958 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..74c0dd508f55 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,11 @@ 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) +{ + struct nfp_fl_ct_zone_entry *zt = ptr; +} + void nfp_flower_metadata_cleanup(struct nfp_app *app) { struct nfp_flower_priv *priv = app->priv; @@ -582,6 +601,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 Fri May 28 14:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12287179 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 A7725C4708C for ; Fri, 28 May 2021 14:43:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80E65613C9 for ; Fri, 28 May 2021 14:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236474AbhE1Oo6 (ORCPT ); Fri, 28 May 2021 10:44:58 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235925AbhE1Ooq (ORCPT ); Fri, 28 May 2021 10:44:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g07y3fMUYxxxrTJTlMUYOs/5rMlkSiX9Aa0wEBlwD+EHqX3T4uNEddSG3tK4G1thW9DdTdnOSpMZ1TZi2dv60GPFnP0ksvDYdcK2EcOTAR6PULyym4wARn6rO8CrEVsDPc0SJ4AiF3IZJEuRazqRjGk66M9t5sGKxsG9XM8oguj0F+2MqbDYUDI/wIYcvwohIPAnrYDBcmmg/hsMqbk53rlkq8+epfcVFIBR7VsopY0PK1ljYp0O0sQSTzbAwFHZud83FgGBqvl3gtzTWQoinqn99yf2zSHnL7IlUyCMwNbIMpRgZl1yBAMZVEarHVIwRbvyhCKrkQWtWnyIXDllyg== 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=r8Rt2q+Urw05+JDe8Ym76MFlczzYMVQ/EMXSWXt+gIw=; b=OFY2ojRXR2pjcsyM7vsWaUXTWOVyZDTLWtQqZ2oCukV/1m1y4a6IQhhwI3H0gecRJj+FfysWu9SGRtPw+WkDCN1AM7lxfHWvFvNxM1s/3xwbsJSg+I5TXryXJ3fs11Pe1kKc85ae+tU5rLu9onApgykbTL4pus2COGIQTrsSHXvQy05GjwyIUN/8zmVZllYJkGrrDUz8T0P6GzvFCfKEj/zbUpgWh+PYVcM9rpVVaUA29+Fek0oEDhlLDn408A6Xgd9CbgbrEhmNMTgA64GdvZtYQdxu7DwnCjXcsIOr+QV+FVN+tEfADa2I7tyFZkqRUSLNwIJFS0wlNgknLCFLwg== 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=r8Rt2q+Urw05+JDe8Ym76MFlczzYMVQ/EMXSWXt+gIw=; b=jvBTGnra9TNz9OjS5vhdfHmKd7xdg+9gxYp6o65RCT9SkJjTUG0ueFZaD0bWRwPvtmJtFrDCB2lUJRcjhnjEOMz1yycg22L2vm0PMHqJvgEQH/ZTVnLH1+i+kuOp+7cbPsVyBzCcRb9i5bv0klH7goIqkdGBhZmW4VLREpXMlpo= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43:07 +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.4173.020; Fri, 28 May 2021 14:43:07 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 4/8] nfp: flower-ct: add zone table entry when handling pre/post_ct flows Date: Fri, 28 May 2021 16:42:42 +0200 Message-Id: <20210528144246.11669-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73503760-bae5-4aae-3f54-08d921e6e839 X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: bLVnDb961bjamhrtymL/RvJIlYQS543PmZompZVfpUZp1xd+JXe+2eGwk6ZLVbcxmw2zOUVyhKcr9ojCXUmten4NHQyqXCRP2nsEn2mimi1RBP6lg0rKUnRvpsQ/J4NSlViJE/3mlq+8ZOK73kPVl9MgPWLSZ65sM7PZxka3BLrYWrC0Fu3p4FZs2O1ThXLs9TyuOBzCVdsE/DwIRlosfOQkT6JX9zLuKFwpENpo9sVW17wP76fJRcfbWT5JqMVGWJSoCtzt0Yj3jfvjI2UU+hZnaJ5d2fFaQHt8pkL/iBOWybQypzvDoLOK5Dn68LoRHid9BdDKthzKqbf0oHnsNN0VZfGwrpYcSNVWNFdYo15f/UiRiVJxH5GZxQfFuuW1ldqtO9E0/o7KHSdPL/IFNKV191HwHFEsXQTNhVA05kJ1OpYuQNFD1Tli1YF+7+KyLFyF02paHOWs6zE37IKcXoZhnsAGLdQPVwAhDmzq1fUxCzHSUP00nQH9ahNr2VLMYoNa7ydEXlDSmbbHDN0nf14ZBbSXVOwoCMnkEVH16Vvbm8oZQMKOjng+vKDfh6mP8mt/c+ZEwjr1oxVUhVmr7JYb8WUUBBGgmAYd2jbeyuI= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(83380400001)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: M2sTUQZCwX9UNmJy36EyH7LcLQiAXiiM+1yE61GtqdkiCUtH5FSShEMl+HpApEm+g7iieZf4QjUnYH0gLyV+S96bLQ05+S1qz+TAnlY8QwmPB34LgjzwCp3nDlQbQjXiuhfk5sbvrO0PZ7bm+DV7aoDueojg+/KSY4ni4qOgw9KCynPHkXnhKN/Ro6aH6//TrYjTOuNtdr9yEgN9O2Smcz5dKy3RoXtUyDHahhukd649fPCSAjD3GmpeQF6NWwRPe/BGOzqMQTCOleBlMX8sF5s9huBR9RzTkwM13d+sgNw4DM28w+6Od0STTCNuCeJUC1I8EjT9nRfS9+7FDvKzKZ0jw1CPRr9BDBkwAVeE/uu76Dp4zxgGXR4JzbEu+B0MJSXXsAGEFZ+fn47bOMIXYVZOtHPHxty62pp7QVOV/XJ0J5NWfF0a8qchZYThX26HX8IOYPXtJgKQMMle3MhNCscHB2+7vb2nE/pEJXICveXY9QxtBaOQXsJ8BS6bkftSg3ndNUu4ni4M2KvZqsSYt15pqImejQa+gg/rQrqt0JmsJzTVVhdfSzmvfXiO6jvplJouy3+PTiA4vZ1WVuh/OFCx7fRxdiMcYWwv5PW7GGz4reEZMFtCS11tfXZGcZowvFBOC0ORudkbGBBDwohHG6VZo0pVgwvGq+NDS5x5TBlSrVRw/nX+7DUNQFbPbw2JwmG8RqNJ2eqdTs7G+54n/7EwLZ7hcKqR/HQhrGIku26M5hmQwevdZmrzknfF75NrvgMlx2eRlTXgc/cW1pdetAvswAdSvAI+s7wjkB3X4qw5kmtOo+HoQ5p7Ewm/lypLMRq66tz2Br/E5M6m1+xtbk2y9wlobLOHdsA80sKLTb0XXon9wGf1/OAQ7KVDEjSD0W/MRyvIT+10TJ76P5utk3S2qei0lCitkXnyCbiq0R8U8IlhMQqlj/F1lYo7Ky1rFBKQ3mH5omgTVMebUU3a462h5NXm6StaP7A2CXFS1qggmMTrft3Kg0pLJX62326wUnQZF5n8JPyKL+Nr13nqSPGMU/Ydh2rGZhJwP9LGkNSplMzjowpFZGax/F5rHNazF1Sr5HXTCYa2ip7450iidwI6jaBee4L5iQEDTFIL9YaB7hNdrTyueUtIdZ2ipWGkAjZAVl0lk2PPlr7j/kXfKDistY+VXvETxEJGk+tC0FuNxK3kPjS5BkkHBovu9B1TvmNARr9TvseT8jm4AcmkBfB96gc7ALKE/FbTpoU1lHhzAYJ8H9zB+yeQTkDzSXCRB5k+90iEQLSjxbYjkNwJ5uJNiIQQsZ3PtXZ2ROiVCZu9jR2WB0rF6y+Gba7z8VlgQwbB7+gsXUtrd6n5EQYPPDoYXhkIo1snXaVzgXVE8Kql/4stvNHytSvZK891SjSc X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73503760-bae5-4aae-3f54-08d921e6e839 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:07.2782 (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: Vtc9G9OsjyXbL8FzDMtQ+4NacjtYPnV0RASOjtJSpEJQrvfQULZ5Zr2/FvtSHttb2gKfS7VhGsx+mlcY3Bhy4uFFtoGnFs/8SP3olvaE8Rs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 | 124 ++++++++++++++++++ .../net/ethernet/netronome/nfp/flower/main.h | 4 +- .../ethernet/netronome/nfp/flower/metadata.c | 3 + 3 files changed, 130 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index aeea37a0135e..3a07196a8fe2 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -3,6 +3,32 @@ #include "conntrack.h" +/** + * get_hashentry() - Wrapper around hashtable lookup. + * @ht: hashtable where entry could be found + * @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 +55,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 +146,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 b9de3d70f958..060c6de36c02 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -193,7 +193,8 @@ 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 + * @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 74c0dd508f55..10d84ebf77bf 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -586,6 +586,8 @@ 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) @@ -603,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 Fri May 28 14:42:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12287181 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 450C7C2B9F7 for ; Fri, 28 May 2021 14:43:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 180B8613C9 for ; Fri, 28 May 2021 14:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235232AbhE1OpM (ORCPT ); Fri, 28 May 2021 10:45:12 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235340AbhE1Ooz (ORCPT ); Fri, 28 May 2021 10:44:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n237CC3jM5rlnTgVydDEfMbjKAuGXJAcAtuxJSDqmKxn/cuTnvUoUPTXL0MTdMW6RuTIdmd+5vw6Rrs0Tlp1l0DYiv7ynifgZC6ZxwoWlw1vmI9C0SWYAqUVrvQg+dqKWH6Kg7s61eLp4srN/prRgU4F1r70lyQrMVWAC/4oMmUQahONEWQJVGdCkSH+Y7dIR6V8/9TiOfD1yxN8YdLlKGrx9asFGT7gl55Rt26qwzvPCDDbcuWnyjW/EFhu0miDBi2JjMfxTvJSgyW3PUizA6hqNhAhg55r0sCukkJI8RwtHz/DVso3orPUkyB2ZOnPJsv5RIXDuui9Glpo6+SV2Q== 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=DUuknGWQJCVQ0e2NA7ihTzscE5vzco4QsSVsbJYTu1U=; b=S7rbezNHM+AxBUHb/ajiZ/qN35LPqS44ksqOheQfqzsSXLS9uLS7oKbFi2frU1SN8L5UfUNC3BJCCUgYGcAFCwVe+yslgWyInLdZfy2wd4VKh9LqfSUNQLhTlSsTLZBheN7YYqksKrL2Xr4b7qy/HiZXirsHmU8Z8s+R7A5GqOEhC5KZXAPfUsbncmBNQ86fSUmooXNyLDznwtPknNPhX1HMlTBCV1edoJ7OJiiSl0FWp4SXfR0540FmP01iFyeB/HbnFF6lcdXiGTYG9iY1xk1HcV0rZngGUWZkuHt2XzGJZjqBXNU44qdyDh8jmEqicvWVC3UTSi/Zn1/JjJxEdA== 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=DUuknGWQJCVQ0e2NA7ihTzscE5vzco4QsSVsbJYTu1U=; b=tKNSpIO4ZnlL8rGhpmoZuGvyQq+nOvOWEyI/hD38gxa6q17Lp27ajAavshDo1kxO5cMiKJHnzjQaeGzM940aw06vTnKIxmpcmyGD39uZyABwLzlpXD/TozZrmimiv1OEyk4FC9e9vz2zbx1lxBq/1drahaqVqHXzx6CNEwotKp8= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43:09 +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.4173.020; Fri, 28 May 2021 14:43:09 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 5/8] nfp: flower-ct: add nfp_fl_ct_flow_entries Date: Fri, 28 May 2021 16:42:43 +0200 Message-Id: <20210528144246.11669-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68523ae0-df3f-411f-a049-08d921e6e938 X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: r9QgO7oz92xZ+8rdTVQ0Sv+JIf41y2UTCI04Pn0tTBEvO6Pw+9cLcmRx2HYJqZ2tGBCPj8ZPNktwpVYdNVZVWQAmdasgQW/DVpOOhxCld87XWBWC/UVcX0H/k5+b6ciFVMoVF+zSVEXb83xdIYP3UF6nRUwSUO2rjQdYkUXDpKAKN6eIzPlKtttsMvbw8WclbSBt/4oQi8GYIDIsxZHwd/cxidFbuoY8Y//ga3OywG0esYDvPEw/2nurM+2f65we6RgyOz/lmSKnXrkt3gWmEkqBSQ4SFIUqhfNRksBiImWTArpWNte8l0LRCUzcLBP/BM/tmZQKBW1ajEHDLbT5bnSCr7T26qw0NadEqcmDCn8OKq2iCm7gnpPLGebz416SiXtUU5PZyaZpihoIkOHrP9hO5vUZa9PbZwICSSjApWeyIHKUZLksRpBIZULdqxAUe7pSLaVLjdfZT+wCxCbpgCs6Z7AIrc6SGcGUHSf03mfUT8P1zX0iVkW7vaXAftjfccWON6sAQh/papEa7wylPXsnat0K4QjNNduMeNJI+zSrqf+++CjhBcvVIyHqq1XYuSTF4pMdWlLx9oAScYUaW5iQ8uytF2I2vsSqZJmpvuw= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(30864003)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(83380400001)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: aLk4usgwb3UCDqiABJ3QuLs9ZLjB2BlX19wWpeRmR5zLpuFsaFV/kvRMYi1AsOCiciZz7MuvnQmYNHN4jKccb+Qnxdz1n2YaWAnua2fU2EEfcReTkETk8qZvp69SDK1lLXwN9/brtFFCt7p/ms69QpbWTLW7dwDBT3lBGT1fUMqdsYroFmuxI8PchOQktLv8J28CpaD1ZGJDc98LegoZiXOUTF2PqlxyUxeGRnTh6FztYgkKiPLXVM87TbXTRmpe514p3I0vk2XyBa01x/eVJoxxb+sf2GRXY991cGGvrsMYpJQrh7JZpLAMLWEFZ37aKEHt1Jzj0I8r/smlNli7hfk3H7q+vx8S9asCYND1+41LNpr6A0lrUzfX74i700pW4dY3dGOyGlyf86Zf04vkFZKje+GHTflNRqByWnSdr8SYDxmTt3yvzQ3EAOa5R++Z7AuaaQDP5bwUJQTcJ3xxOMWa6wtxc4qinqB67TNGPN8iFeypMrhzwSRsB/mkCypx8TmNMVaudV1ZOOq98JNSlTZQi6H6ICXrNvQVk9+O6RWqq1FNg6HD5bGe9yID42fbds15qzQzv4rO0hMqJlEA92C7xGsovUXB6x/mWEJmOzag73mSytGR7Mw/pxCE0i/a9LAN3Bb395rD97nAZB1i8aDq537XFgJD01yZCgMnbRNhmjQ4x/Qqcosek8G0waTPOMO8W761xqZKBv9tx9GHT8M88299NHlvVm9KUW4veWLizFL8DW4OTdBPoWZXdlN/DyLE6W7w4ogVoXBhYoLz7vUAsVYbBUdEkIBd4xKG7Bsq8kMaJ9j5u/xJuv8WhvW46Jpk6f2pq5eOi2GaiXCMC0ZxxfXPwPiK1E0SGRKOJFXnOVNW/IaHu00pO9INy4Df1qKPizuTQ85UWf/Jo/8ouFy0jgcC5wRKptv/x7Ciozeig60f/lLi5jDAx40/zQrKcYCCCHPBPgtw+XY5LSeC6W98vDG8sEdwN02U+KZ4kqvs8MWPsfBxBU6/r18R3Pfr/2I19oWlHkQpbGfYSkOdpw9mKia4CPF6YgOCgE60QMA+AyDNZZJoOTsMb066ngIEjUXLbKXklCJTG3By2ZgopVVyYIbPcxw3/h/rXq0LpLilK1j9kPB+p8YYDRhQs05Ns/kcy9udQw2wci1DkHNaihCuZQH2c6BPGwd6S/tCHnhNsq8osOU7QIT3OsOy5aF1RxY8mWbEg+IVy9XOU+YLgURrep3H3Jc77Sm6hZ1mnKTB02gIC5SA2DJxYP0Z+VBDGU3ru0eKx1YEDFpPAblFJhkHqnYUI1mH6WtErPmOjYl6+Ht2n9oBt8wW7xwaSTTMHGjwew5PPP+N8q8LCNhn8ZYLtqzLwIAmQCeIKLnDVL0HnmC7gpjM4VR4bQH/KKGX X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68523ae0-df3f-411f-a049-08d921e6e938 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:09.0723 (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: Yt+RKLokYtLVLZpbvoK+9TBralDcDuRKsHx4TyQMcothiFuv/Ko1ekX+q0LcFh5OM6Gv7R+/VscPMYSCBMt86mv10Jityh0P8aON46x3TbY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 | 50 +++++++ .../ethernet/netronome/nfp/flower/metadata.c | 31 ++++- 3 files changed, 208 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 3a07196a8fe2..186f821c8e49 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -82,6 +82,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 { @@ -99,6 +103,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) { @@ -117,7 +215,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); @@ -127,6 +226,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, @@ -137,7 +243,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; } @@ -147,6 +263,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; @@ -167,6 +284,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..6a876ae89d9a 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,43 @@ 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 + * @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 +104,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 Fri May 28 14:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12287183 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 547CEC2B9F7 for ; Fri, 28 May 2021 14:43:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 357A5613D1 for ; Fri, 28 May 2021 14:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236445AbhE1OpY (ORCPT ); Fri, 28 May 2021 10:45:24 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235788AbhE1OpF (ORCPT ); Fri, 28 May 2021 10:45:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhCk8HTDkuG7zZ44L4DMO5XHsm7AFgRoirDb/GlI+9QI6ByYhc56IpJduPDs8AW02Ju4dtjPR/kNeFbhzPlYsmrggVnWoxAjrgAvaTzGYvoiYhxLMm/Cxro9kvvAkqqJJZcth3Fq5pASNNE8x0Fm1fs4zR3ZeOnemq2Jl7Sd2KIRAXxUmcGa9q5XcfdnfRg1g4biAqvDLwIg/NvpiDr98XX+AH+j3noMH6/f1isNcOfstmnwM+FqaSsOCbrMXBFUDc3NqANDQSwFufoOGXB2Mb2tXGYDBfZI3zY7k4G+KgVnjdinyJJq2elXjhcp3mCZ/A/JasnnJApg9kqpG2UGvg== 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=kaA+Iww87PhTdlRJY6iK4kwLX55b9baqg0g6cVvsxcs=; b=kc6BfRF7iNvVyym+Pusp1cCtl987KsV4rKgp3xQ0lrxkjZfkOVwu6IdLrajW8vrvfh2imyWv+zcTlmrgkpjWbiuQy7+uEkUXkv7iHPQ58YJuIeAODz6U66g7kAXz9uguv96s4XBRSb4SB8sVeZ6kOB2uDpfVT3SzlU6nhsFtMN+QbsN+KQWZAMOsztt8d0XWAtjLk/3S5iUo8Sznl75RjBJlYWMVMsEnA3YdDIW0Wez2UnUsh3AC3FkJ/4SxCDZZYEaXZNi67OntAre91tnQQwRZyDH/T0nO+uiEJeaxJbUyN9/2HDlF3pCaUC50iDXNq1PRv+hAvxI+DExIFrB8eQ== 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=kaA+Iww87PhTdlRJY6iK4kwLX55b9baqg0g6cVvsxcs=; b=d0AMFVun49MUwfqLQwB3YwF78pcnttRi4Breob9CQH1qzG4GBckCrTMAWb8aHTYbJokExEEj4jMDJ4cNVX1PAtup0/RsWNPjzQsozJyJbghS5nuviZNTDpW4vjllXDsCHJsRpneARsQAcFKMVRE8oW/C18JiRjzh7YVmYElJTHc= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43:10 +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.4173.020; Fri, 28 May 2021 14:43:10 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 6/8] nfp: flower-ct: add a table to map flow cookies to ct flows Date: Fri, 28 May 2021 16:42:44 +0200 Message-Id: <20210528144246.11669-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8164a26-b493-4191-735b-08d921e6ea4b X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: fV+ZogiQ55kkNJWBRsvgt86mNHVwbzG7YWr6FwqfYTL3oGWX2dn2P1whmpA/rr2sINfONZd2v4IEIxHbUAVaKzj6r+PrxvurZg0i+QcIXkSntinfo/3CQJbCPtO+eo1miC3xOwkqOYHyLjSEthGCqS5V6LJmdOPlSF48WZzbCygLOIhzca8jdxkrKzyztweHUgEbsUZEBUdYTkXckgwxIaXTcbt5m7MxEceg7tpKLkzZl6d+xIlY3W+0FHywhMm02ADrPkLp6zQuTF7DSas48PsP/ZV3SVo47KVmPPhP5SCaBviP2tlON7bxLwMzUR81LJP8kbTEq5U+HLA1M4+QVrMZzSAnZSTSh8OzWaDTC6D5VE1XeRVfIIFD4adrirHs3cJjfIojdovJbX9Cc3hN32I7cJu9we3FihJYFt6CTesNZEJ//L455yfYSk8w7UjaN5YEfwEBI2CrkeB7z8iwHWvZ/fYVvOPPNUgbpMwuPeogWQoxP2ghU2D6tK2pj97xAsXwE1Gk0buBZuedJCY4gKwtojuOGPYZESQjOeKitNvjVO7z++BT2spQ6h8febQz1eBapbCkupUMSlMjQD/wiXnB+cxFX6YyG2igMCwzj88= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(83380400001)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1BbmT6Qf921JmMRuebYaaz6PGRZ86w7DiK1favoANFW9RFc3SrCsVz0Ox8DWcQnDGPos9KpxqaYI+hybAlFh5YHH6x5cU+CWBUTpvoGiQwfiAGoAQsolIQyMhR6zRa5hZLvZK1/xF35ZOzrCbW2pSebuptjnN23DCD5mpzxbAotSu9meYkpVTjNCFwa3+tih3LXvzkpIvl+26ZlpRpGTQC6zaQUKJCMgD43nCF4H/L2M0S2XTEHQjl/KMH8rPZE0ettYm0NBCZ4KtQJadDtdJ3IdQpzYtqcIRxAEkg2ZpDNBswJlSyaVdjAcA611ruMqIQgugbQqF2+VD/EFGir7TD1Z++X0uhBy5FBG1tqTKY3nZPbJqBAa2q06ujgQmYr5LwF66md/PdLKl4Tqj61JuC00YItBtjBjkjLhcpgMv6r8zIOqT0zAOkq/loSOfzu5bN3wd+TG2acV1b3NTWr4Kzn9H8GwCqifEbgl2tWB8shmNQL7M0ZRhI5J6BxIRteYUoYZxRmxAZG6IhMJ5SHGJ+7GRHjWA8TaEqTOS0AqEOp6zJ5X/6pGK8g6Dwe0zYMgmAkcIKOgCcWA8VQ3NAcujlRgVAUPmBHi3F8FqFmvks3Q41+zHfiu9zpORK7oJtdWV5gRtjJVyErP9nDGB9utqXiZT1K4ZXHMjKVx/kgjtvTthIBSJEDFo1n65icB0dGjeqo8uAjLAqzI0/Pi7gMjAi23ea3j9nUqoRb8Cv7dOrBPdud2rHJh6kfE/iIFXWr72CIDBmKLguHeUqqO0P01OHcfIW1vwQV7AMLjKJd/sltfTbfw8oYpqA6PHfVbwWYI/8Nj3lbjngl4ujBQR1Sj4uql0XkxmRv9Etv5lIcW31jihZ5tYzkzuBT4qek7AJljf/32/1U3WZS6ERsu4xY2eoCLwHHEqunoir10FqQdfoSaUdTGIEThGCuuV/5mcWddf4OxtbG1ZkLbPBu4ol1lLioe2YfmlF9aM8EoSKfUtPA043FbkN42u3cA77XkxDEoL9SbL+XxmcyV9sfymzKqueN1du5EuxeNHZXGuuTGUIgnG08kgeyzkwCfcGyYFjSu+fF2kIO9Ju8q73qUNa9Bg2nrfPoxIwkwEMu4RFYRV6TNLFowaKJ3oJipRAf6N3RwwHAeeeSiiGFdFG8neNU0SbVbag7eC1DD5qGUiZHDDGnSYBrFgTPabxfuXXh9dyriP9t93d+g25tAD3Tsd/GXv9+HuZDTQKEbZmYtz0qflZd4/z05pFF/nv2Mi4sfh6ULEgAYuY3yVheoILaLRFLxi/otBTmKCIzq+z2+UiMjTHcP5Vm1OkbI8Ffga5o+mCgpS5HTnO58UB7nLh8GjJ4lUQ4s3OcqmdvASwtU9SDp2m0Mu5jUnavDKYmRTJC/J7u3 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8164a26-b493-4191-735b-08d921e6ea4b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:10.7788 (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: iHwgBxVv/oBJ+lYYlhq+jaDgPeh373PGiHziYz0eOLeoWBfut3O3pJLOR+LwRWIV1iXCbk9T9O2livroU6LIHoXyvwTOmjPmttnqN+9YuPE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 186f821c8e49..0ac6e92853fa 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -106,9 +106,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; @@ -159,12 +161,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: @@ -244,7 +267,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; @@ -285,7 +308,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 6a876ae89d9a..faf42a967ab9 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 @@ -68,6 +69,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 Fri May 28 14:42: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: 12287185 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 EB4FAC47087 for ; Fri, 28 May 2021 14:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C152E613D4 for ; Fri, 28 May 2021 14:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236374AbhE1Opa (ORCPT ); Fri, 28 May 2021 10:45:30 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236278AbhE1OpR (ORCPT ); Fri, 28 May 2021 10:45:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdZ8SmCrQWE/NiwsAJRtCI2qTeiDdHvgLEAnyJ7524w8sCH21sqAjwQx/4Q7RWe2SIjGqLjkst0Nf7ww+KLM8elxybKRIgoglA0ZIbNRvz5lBEu7a3oucEi2ueDkvjKd3e/ZJcjz51MEkSr26sDnovvOuRZXMfDuxa3GCCRUa7pNPqGUa0eFPL+cwl2udUpLh5Y9SaSEmPgSPXq9/LJq3tXSWp1sKx/QfobC/Y0EoIj3/HxhnJCuRPWror0z0LZiT57/9e7gRSaWbrOhJjbv7Ja6h+jA+jgYIJb0Y1CTxnQDzQmMOq0UxOkjSyylX4gRsmKtTx9G6Tfu/S+kiAzAcQ== 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=Xlg3Qzqd/yJma1ma0ubnw9hxsuVYqp9u6YY6a4zffkg=; b=iEUheRauid98zjqrOa8kvvt6pLj9q8eJy9DEzLTIbPG0RX/WgWr+dqgrN6kCFGti35oLPLDPAnPYCkqQEMWGT+J+S2DBhLFncyTkEmIzdcX9yRfUEHQkYP8oP30CalYZCh+0KIl5S9PgcAJB4CJLRv3Idc+NmAyVIpwyAgovnoQ4eOrMpVgU7XbouE3fqpXX0YmBEJIb7REZpBf61ZhKd8H2CcNadjeUB+EZWwvWIiBGJubiR6WtRxsqwn3HNV+wI84e05TihdXXJXn4ESV8UNjx1xSLai5eZvL3CZJlCyUfg9fsMlnGeUDs94em8e9sOk4NhxdMbISnvcI2O8rYog== 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=Xlg3Qzqd/yJma1ma0ubnw9hxsuVYqp9u6YY6a4zffkg=; b=quaVZnWrB/iTbKClUdpLDoUrdZAHVgeUahsi8/W4OHPabno/Z1afUEQkKEIwXgLsRTN9rrKIJCQ+A65UhHN5NFEaHnt97ElOp9FPtM/Kl5+zbrxd37bGm/Ap0ojEDfhF3wdPofgUr0aDcbAEHOufcKOh/st79vf4XWyFHho1PkM= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43:12 +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.4173.020; Fri, 28 May 2021 14:43:12 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next 7/8] nfp: flower-ct: add tc_merge_tb Date: Fri, 28 May 2021 16:42:45 +0200 Message-Id: <20210528144246.11669-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43c23eff-ab4f-4452-0864-08d921e6eb53 X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: Xq4k/oY6hWhybX0QQ+swqRNWDyGLb/nJO9SFVBcFg71ozBfXSvMKTCUcNwOyzGgUqLF92UzMt4JYal29lc4JMRom61eLxNeZ6s9r7iBz80nH0IpLw5EtJZfTP4KDDl9q8bG/xs8mYOA3kaSqFKTQhf+0DVkOxysfK4vcuyUmuCtLH6LqeDM83RYHnLiJjh0/JCFHdbqkP4k6ghaMw342VDki6Bjo9+kxbwj/7c+UcnJ7NOZOp5bo7RFxALcdMtsC6XoOR9SdZIksfy64QmY2Ch3ExhShgFIU+RSrvp8DAzhiMVsxs9FGqjO/TME2G9gVq2YxbUJ5zpHDyT1HKNcxV2gd9vCx4sLAos/nsaW4kDD9H6lMgDXEZnbNR8Oiq+STHeOxyEgoLAhU2kL4BFTzi95mFr7XNl7mB7OqSeij5tV/GMhdpLcSfYaW5ALg6GPz05QmHBCIVVBU1KyNPZ3kIw2C+ccjqnjT4sDMg2W9/yiYxIiKQyEY1Sl6YSmi9Bh4mqSGQbb9MUikXM5r4k3YsDxmvvK8QvNdDu9NQXNOY3zuALaluMYKyNEpI/5KzqOqVRibFRpFQTLbhIFs/jxLS6+c86agc8kSKEoLwJmGjO0= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: e9deWwniENp/SVGsNVB8N7bjQzeMfOo6vqKqh9FsXo8e52gFHyBOgMDczxdvzSABo/QTNIeRh7bxsnYB7N1tMeso0YH0fMkI7Giobw8qegESHjE2BW0wLBPEY5X2PCMUS/AomXFKdXMyuYsMG2yJcRmOjZLp2561ZbHVR4tHPXccXwZ48Mc+z45ufSRZ89kKWHKNgvTbjZUooG71H68P4mkn/qgcInl7lF01lER8Tq07/bftLRpOYhNgObGc2Q4d9q/vIYzCDMUETE9POqgveAAWoedN3kM22vnv3q6cxngEwt0cp2ThX8S8svBEpoooLIFNX616c2WpAHMYdfBBE+YzjYS+BMTcDsMBx5sG8JBOI8KeAhULqFpiMVv+2BeVXNU+ValLVHJUHREQcq+FwhPRLwPdyXBRqyGamXxFpPjriNoipAM/usLToIg06nys2hz0ZVsbANzvMmXTTQj0dbQOVIGc5jOW4nWZ7dfLWQdILxOkd3YYrrRYrq5H9/q36n8jrbPO8YBKiYE3NYGRtnlPpYA5NMXeWQOhdSw+j6X8KPa3/yrCR5QEgNGMuUD2KRjz46pZqSEg8oi+qYcq1VKrzmbEyEUw9WyjNDefTYRw1y2Ng90jtsoSTj85KHgx4yKlZ5qn+63tcrTDl/D7YUJoFkeJhj365d8cuIl8mve4/ayKhv5VsyA1poPIWVX7+q4xtmJ7MlMqrnl6of/oIU1zzXTZgfoPQ3gU9yW6iBKJhrB7e0+cQDtSU06XdxcxOL+efMAJGVUwfLSHMIe7M9qVAY+RTOCyG/517+BaNc238bVedHWbd+wiN6WN3DtMqa8x+37lt3gu+qTQbBO4yURXdffOrgmaflQlQ0wXAKIomhGgqfJF7SQDOgRCakCZpQouZjaOSk4Yg2KPXf1okLSl+0mI+/W0JGq1TcAwl4fV6UddjjlKy6b4clA1ILUlFn1eGDc5fKhex/zdvRY/x63FUBuu95zqQLWBVhho8XDHG2hMzpTdg39ZBNcpxNl+oCF+X2H6qnUyOj3v/cy+eh7AXI0J+Gj2B1Bc/w2aRhy70YwBCdtq34AHq8spk6HBBYYl91B2KS4+BXc/IZGoMly4OybOLD5T3NnoMJEgUNNn+UgI65narNihmw2pNm0gjer0xjnUqlVAnMazsI3lC8zZw35TTYynnkc+SsDhpSCqyPb8MplUSZX/dvUQ4h8jeodnDwvvZMnfrhIMPdTjt4d9KPBtAbymTX+Nm0Ku+Cx0R2ygUXknALDphcK2oWj8fVvPwdlqyWc9znUaVBtB0DYwPAZvXQyHd0tPlbRkF/pzRXcIYZK0xuDspQwCuVKG4BzZSgvyyGCvHM4tBXIUOaXg+fXPBCQF78N5xdv6ScJOdfXN04ZgX7Dtr314T4ZD X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43c23eff-ab4f-4452-0864-08d921e6eb53 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:12.4764 (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: vM0Og2vQ4r50wx0VsTTx4uz305DPYukrDGz6OX1asISanu9ofrkTNxXDvM1hPOis14fsnY0972A7Ue5ugTmARvPxgRfLd/OitqxeCgTo6tA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 0ac6e92853fa..cf17c9510fbb 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 @@ -86,6 +94,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 { @@ -99,6 +111,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 faf42a967ab9..a5b36560fce1 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 { @@ -69,6 +76,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 Fri May 28 14:42: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: 12287187 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 50ABAC4708C for ; Fri, 28 May 2021 14:44:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B306613D1 for ; Fri, 28 May 2021 14:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236525AbhE1Opi (ORCPT ); Fri, 28 May 2021 10:45:38 -0400 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97]:62452 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235898AbhE1Opa (ORCPT ); Fri, 28 May 2021 10:45:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GE6Hj0DEGQ6x/DAFNpOMEfb8DXX9ajsUno2fBy4MFUBKw0qwoBC31Qy5TN6UXMZE3CvR+Kbyi1vwEbHSgOzORD6nQo/brr7TEYjf/9vCHoJs/zmO90VNKJFqME54FwIfWX/mcCZGkXqzeCGsLU0jkD66Mkyw4UhpFrMAtmjrP6u2ToGDmTk6c8m/E99w8i+hKq6oYEw6Nb5bZmPL7bi0BzsyXx7iXkhLoJWbSQ15HY6p7CkoCAFJi4tqWXa+brHGg4zn1dUfJY46U9vLicwux0sC9Xdr9sXZPzbDsTgZyrbaW0S7U6jQ8N7CLg7W3sVeG9ZhHkk8SD2GvEDML5xGeg== 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=zupaaJDl4+d6DZYkhCtCttDwXjiA3gL1vXzZ2Sz7EWM=; b=Wv6G+FcP83GE4cl/meaMl4FAABCbaETU8DUMncrUXjDejfvv+2bl3Ua1P+4PWmcocZmUNaTBef3fzVLGyzhlcKAMefvVB/YnqBHPMeE4OuAfjTdz0M4djpkoI90fzne+bNVucjCD4lpswqkmyY1bUriUzqdA6RMee0uLPCT8BvgS5Jz02ZLMiguMg+vX5jjTXEYA5iSlJ0Ttaf+zEPZ6hwZfSh6ejjcL1ZPKEFsThZ9Y0yNlUCzhhnLnFDW4ncKhrku9qA6AWjhCi7SP925YMltVaxY2srm7OOakP+sTYH8temhmU4+lSSTiNjD9SwV4nOD5PmkvPzA8sAzdkizbnw== 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=zupaaJDl4+d6DZYkhCtCttDwXjiA3gL1vXzZ2Sz7EWM=; b=Y9lvG7dvaqMJcWNev4RR+1WUNjCX1wk2SbPjhWQ8E0bPMXjSHcSO1kklZLPCMGdB1EL36/fQMETpZWgSxJuPSW0ce1/iucnjTmvSWN1LqwkTQpTwhRX5VSZfLjkxvSufpkvkfuP1PuZUpqJgy/AOppBwgk4I/D2gjShXxet8XGg= 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 PH0PR13MB5033.namprd13.prod.outlook.com (2603:10b6:510:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.11; Fri, 28 May 2021 14:43: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.4173.020; Fri, 28 May 2021 14:43: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 8/8] nfp: flower-ct: add tc merge functionality Date: Fri, 28 May 2021 16:42:46 +0200 Message-Id: <20210528144246.11669-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528144246.11669-1-simon.horman@corigine.com> References: <20210528144246.11669-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) 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 AM0PR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Fri, 28 May 2021 14:43:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 663bd3c7-a014-4ba9-0e51-08d921e6ec4a X-MS-TrafficTypeDiagnostic: PH0PR13MB5033: 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: rb72OoL5rMLT9UXn690tlA4XnHDj8S9/Op34XCed3eTy/muncs22UHt9eKgbNi7e8NgfU7oESN3yDrtOEcBUt4BiQSXdPH/ZSJdtYhDfRT7uN7KzS5Qt+5pbidHiRj94P365bBAAvRS0DE6hfJTXyI0Gh47b957DHMN0bHeFg4Z0q5qnKmP4Ju6d52hKsUOIOfWW1aLFgdQTaqdi5wEI7KgZ8hUbf1DUlxFcpOJ8iiz6LtA6wSy5jYiAaZSGlDUq7oQKXF/35N7s0WfGioAi/js8/jujbD0bFOfsVddDHXob8k0NFucqwj0Xmklmp/7LXh1qxNG84RFSKAxoppVNyq7/+qLcUsvek98wnKJdhlN4/VLRAUnwunnXdQmWfHjwaUNNhIzDY3Hs5BVuxq1T3M1xoKrQ8UkwnseUdnAtX+hgu4ZE+dTJhIvRNnK5A2BdBuoiT7RrKWLIFHLisxwVxfpCkd8uZAHW4eKi+VXXHcP2JgpCvPLFVHMab0sGJlUSXIZnYuefcjKU1+g+C0kLyuSX3mCoIgtKfxg27AD6vxMcijzhof6U83XPfZgBHSKh6D+aOdsy33Ueor384mxqVjE0zwZ5I0C99LaUb+STv4E= 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)(396003)(366004)(376002)(136003)(39830400003)(16526019)(44832011)(186003)(5660300002)(6666004)(8936002)(6506007)(86362001)(36756003)(4326008)(107886003)(6512007)(8676002)(66476007)(83380400001)(66556008)(2616005)(316002)(54906003)(110136005)(52116002)(478600001)(6486002)(2906002)(66946007)(38100700002)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 3Z/id2UI3TvdsWE1+xF6estuUmvdCLXM8fB8+c0S8badYtbnt/R7AocrNnOpSEobnYYtgCsZ4klph4zZCXrPVsbeT47vL5O+R7Qy3FaxRX+KhCcI5gA/FsgSxuvgVnxdUuwCGBTYh96g+36C5DTI+NH53PeB7wsIgbkIZq0VdAlbHtM4MLbzlcv3DCfuMHivn0QaBxAmlmL2YQISkDC1wHDTOS+E1Evs4oJJ6k1e61KO1Z+vxHm2ZCa5soqPAcGibxW6iuI4SPH8rCYxaCMrFQcDsTiirY0YRSOpkOx1iJ629eErvmwWoi6xmW611EAzn73KugMLFPvCoIW9Z6xkefWqKIEPTCZQe68XWjCL3yF2uFeK6cWgtBNlgLibDbgZxOz1TyrpCJUY6ObyBYLF3Hdm2OmZVJeFkv4h6r3RmkbEUgeRdcdCWr3mr+EDdD9jsAPxEIDnj2LUSC9eaMx5eFzP9rtdfWcQGovAERKY2GdMPxdjrLTpzr0cU8PPHSxkJMcesxjXwi60equSBe8//PCGs6SsbO3V01o/lD/JCyASO4yim9xxBl8TRxpQuswaYKuWe+Qagf2e6SWV9ft4Qx4gI/707UWNRAsim2GbU0LVhxaGssrlshZp4r4xfCBhvBm0cY+dqQ5nMZBHCpzU8ewjBGmDC2xlegl+AZbrSplwr+wBMfoY0Jf0PnqS97kfmz4MtfAqorDhRaJJ8zSa8UibqkWRRlTN/CtoWRIddvqTKj3QtYY1dHbHjcguMmIQz29YtkRp6ibmQv1cOAZGRDmH3YccNMyfMfek3FOiggGgo+cbOjDzLlovJpbcJEsbp9yNoxRl9txHynWw+ySBaJvoYTEApGMo/nFXdGn152G/WxYSGx1RHAle2AiVC6iyJE1+vINZDWWbru3pDR4RR5qkDwj2K7/tku3FTqVv3ZIo5pKqKq4UyQBRPA7aKYtrq2yAOASPcIkrsY5zNKMg6xZHubrj5vu95WGux9ErvZB8PMB3WlQVmyvsfDsnV+RDe1pGpw5+g7PIWVnL8h1UHHq1tYyTxqXo2DsTGLmvHI8Qm+fFoBNTORPJ8G1qUduTYtrmwMVkh0SRkHJmMSrdjN9L1pSUF2F5XkdRq+v25VxlDUkL+IMIhWqrKj3eDvxxp+Pi9NBvJd0fhNtOctUmqgwyefOQaGtyuLuYvWG6Vu9XlIdPEjxM8Ykyq/VN161aGlLuQz/g19l5RwLS4LW+Xl0zTKsjAfMZUYBy/+Pwh0Z1sjKSATt4/Ie0Z+qe3BH5GERLZWV/1yC8E6o5ioHAgh1E6GJXFUFZItIqQ7omkOxBGcrbGgzaj48WeXazL2ZGfjZyZziwkYbDJSHLHCgWCFnAy+sgzEHDECyRBx81f5ydn80DMKdkQwfxIbDXUCKd X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 663bd3c7-a014-4ba9-0e51-08d921e6ec4a X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 14:43:14.1331 (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: TZb3GbH3X3uH7veb8gWDhvOcDSsjTEoXpyNXDTApqIKWqx5t3wgsITL14LVj5h/eAYfYqUDtYGbrm7HrXsM0Yl95aYE2trKUipPwBSlEzjs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5033 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Reported-by: kernel test robot --- .../ethernet/netronome/nfp/flower/conntrack.c | 157 +++++++++++++++++- 1 file changed, 153 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index cf17c9510fbb..ff262d04a73b 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -63,6 +63,74 @@ 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; + 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) @@ -209,12 +277,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) @@ -247,6 +351,25 @@ 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; + + 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, @@ -289,8 +412,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; } @@ -331,7 +459,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; }