From patchwork Mon May 31 12:46:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 450741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63FFBC47082 for ; Mon, 31 May 2021 12:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47A7A61279 for ; Mon, 31 May 2021 12:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231589AbhEaMsM (ORCPT ); Mon, 31 May 2021 08:48:12 -0400 Received: from mail-bn7nam10on2126.outbound.protection.outlook.com ([40.107.92.126]:16736 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231367AbhEaMsJ (ORCPT ); Mon, 31 May 2021 08:48:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SQYGKGoinhZ0KWzdpu40LDbzHGGUp99tLbiJSyrnam8fsPNiDcbnN6NeHA+Dszv/xtLoWEV7uXjtxj572GVjk4RXd14b1dqSzsBE7T0Y6W6Xoujx2uqATjtZZd1Jljr7G7QSbZ7Js7Jc70sXtYtDBO3ZE/3XqZyKuR+HYxYqQmrqMMfaW3G8TRT96D52w0XfvM4lgMxtBqBw/J4BdshAXsatZH8zQrLfbFwxfKyOUuPmlN9nbGcnnZZA8G8iDSh/Nbcmslny4xe7wz2PC0l+0bUA5/C0E3qiZcgJJklFxF00b6lRHkb3bZL8WKgi4d+FDx597PDWje34p0vsTCdPxg== 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=CkIJsDhSvKrUZ3eOz+D1aKh9FzLmoY2lQEKPf7VU2yVfusRmwlOq2XxtgtOOkaMPcwil2bSDHrUrvrnLyjv9AVBcVs1QTLMIb+eY4uwVClOe08vMGr/tgAd3Bts1EeMo4AkO4PiTtv8U/3IFOokoaA3b3RNjRpbXO4v0x4KO4zyqG2QRn+9+c2JwO5AFS4lmOEHHwaaevPILsOrsn0LS8OkjotmnFnX5m7fSZGukAUq4KxbGLsI8HOMCqevq6XVlq/QTa8H56tdUL4/zOejAoX0GgYpHZ0trCQFirWpi+nFpIwvoZLrEPD72T74tVomY80dVNj1DOQLXZEw3QulUKg== 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=eWM85JSlQz3hoqdF55QaYXo30jAjg8fPnAJO3Nc0YO5fgVvYbWZUMSWJBANlH/C3/eUy03rHqL18kk3AjDvPk31MV9k2Domnu8WXg5TugEyg1cv1wXFIlKd7hw/9/cfWaMTcunmZdLkAaAT7UEbcNjt0NDMNpx+ZF0JjqzdC5cQ= 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 PH0PR13MB4876.namprd13.prod.outlook.com (2603:10b6:510:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.17; Mon, 31 May 2021 12:46:27 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:27 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next v2 1/8] nfp: flower: move non-zero chain check Date: Mon, 31 May 2021 14:46:00 +0200 Message-Id: <20210531124607.29602-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 922a788b-379d-40c0-4b1e-08d924321b76 X-MS-TrafficTypeDiagnostic: PH0PR13MB4876: 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: 9rFPnc1Z8ooHrnXtGb/AZfCE12ga/JMyTIW1uZBWhV/NR/pqZsrEQ4zAjCmwBWgJZb7DeHhbLcXeRhvxRpkT31Wq+koMzMGIgboNk4ZPwzDp2wlkUwRXkIeXCsSSfuTF7nqEoWZOHIv2ugOArh3gDz40BtR/ERUmCc8ok+X5eTds4ylr4qyA0DD9+j+zMB5eh/GyXR6FJNRqupaWTBM9oDIwXm2RvZAUfBv/n3AmGwNR5WuKlMDjcehAJmC1352U/mEjJrMwHGU5X+oieWDbZLmNZp6lXBc5/BFPkwWtGrbCfrzZCERAWebB7EzsduFWNxlUQGl29ZeFHhr49zAssqAb6AzaE2qccyyxYdGK2sS9909YpacJG1KNH4FUXtamN9x5MJz+0mo4DPqjLc5qs2iVawKDRZz/CBp5bC4CL7vBE58K3nzLFSOE3T921m8f1fllafuoCe+PqMZIK8e0Fvg0InJ3cBcwLESn+huDKGKxfyI89L2yb+tbU6jdPGTbdRqVOrq7I1s24j0H336rb/vWQk9JAZhd65QXLSSoI2YTEEcEbTdZm7v7280NFsLV7Aa2XhiKiXy4FTziZ7Q0o9/ZLjU9ImqCJ5JwAdu6bi4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(346002)(39830400003)(136003)(396003)(366004)(2616005)(6512007)(5660300002)(6486002)(1076003)(186003)(86362001)(36756003)(8936002)(4326008)(478600001)(6666004)(16526019)(8676002)(2906002)(66476007)(66556008)(44832011)(107886003)(54906003)(83380400001)(316002)(110136005)(52116002)(38100700002)(66946007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 33iT1s0yqi/+LjIsOCr6Xu98NmrPtviJTMP1fPzaFcvkovUelDvv4eGr2vgTdo6Mn8ognuDXJRrviQS/KcbUJkdmKSMrYtHR2tKrXr3rGgr5luUqVR8gkhgNFRb+dSyFepIOVZpl/EK/+XGGCKtQ2DZDpNTJVSvCM0takP65srwe+/bGvkfCMnteYH2aBKGxFjUVTISIYM7rzX+tU14Kl0Yg/p4lkkpWVx5eWAKHWirgN58R7aQ+eboDQpbOmm7XE03dPJTWMYt/ycHqENJ+bwfUe9eYpF5qBHcHzdT1fKIxO8przNWzQJTlspldKfDzs88cCSGNWgwth4p2jom5+DjKJFVT5ltGAVWFcpxhXQu90H39Vd1Ntk66CXiPQrpw5ZWd0C+cBs6UYkiaozNAIqveSza8aP7oTvgPHT7FEDwaQThh43Jg8T3wexdzFsNlo+kkFenEEMylfHS4CALfaMXVsOalPosrWQkGhHrx2R/tXikbQZkxFgbHZr27UJRlAD6tlLaO27yFxymJokLGleakP8et8nFDVxe+qr0Sdg7mxkrLZodj6+/IhlC9/oaMXo/7S4Gcvs++ToSddA4QTlX8U/HaiByvaZHZI8OrOuHuW583JeKd1UGCfCE42zNJ+LQw1werouV9RhTaa+66fKGjTJQ/SX3Fr1+eoFCenj94KcL6r14Jw2xZe/nqNuHeIufzoTMZ4VVXBz4oOyIhB4Kgi9xPWhvEb3mGAFIhMM+wYejgR/FWq/3Rt5jylEVgObOAMsz4U+qiG0FyQAQK7QQ6CWITjbWgn6BEbBGg6gjfjmHR8G/DBnswKFwtuAO7SbKCe4hd0f4MTM0MHEW7NdGXcSvf/4jzrk6Ber+YR7/caAzi0UTypSYTM4VAdIUMqeLxRd+36ciXpzeu94dfDsDxbeaD/1vYTdxqyegHCyBaaHufp+y9yGHyGgKWwMSAI2A4EhmYJr++TXVX/JjNJxIUC60p0uJVRDpV0EQzFAxRj8aDsU+CknrPdP/PCt+uF5isZMm2Ci5VkU4FjdgLPxQYAjnXwPLLc9S2YtUhVX8oZLOaXb+j35vMOIXT2YzlyeAt05DNlFrhHE2A8T1M6L2dFy7UVSqUwPt7179MUj+XJahPzROcnmKVXOJdVACEeIU07a5fzOkuaiU9QUAu7qJkkXE0lsCaylwK8QJSAb9g9LfmjV1jLS0E5FnuTcrmdAJXjb++UV4JYcvwNxdRIz+DqukZ2RZnhExBh8t0azOz0hv/2qS8/m8ydxspKvEjirMCG2ZMGLqXOwygeArYjHSM+FVQQG4cEjPlMuBDtf4ZBoxomWt6DCqFPkC3dFw+n/QRM6RFqTECfJxbIHE+lh9cdy+NzLuhGeDesgdvclaa7mTZ3/XGwQbfA8Db0NGZ X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 922a788b-379d-40c0-4b1e-08d924321b76 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:27.8472 (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: FOhZAJmmOw8Qu/USUU206U43QuyZRAVtUME5oTUFD9HS/A9Y4Ul52EEh0TcjQrz+LRCNFXhstoZ8HbJP4Mz2GNJBy0gaLmHr4olRe1q1mZA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4876 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens This is in preparation for conntrack offload support which makes used of different chains. Add explicit checks for conntrack and non-zero chains in the add_offload path. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/offload.c | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index e95969c462e4..16ef960a150d 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1276,6 +1276,20 @@ nfp_flower_validate_pre_tun_rule(struct nfp_app *app, return 0; } +static bool offload_pre_check(struct flow_cls_offload *flow) +{ + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); + struct flow_dissector *dissector = rule->match.dissector; + + if (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CT)) + return false; + + if (flow->common.chain_index) + return false; + + return true; +} + /** * nfp_flower_add_offload() - Adds a new flow to hardware. * @app: Pointer to the APP handle @@ -1302,6 +1316,9 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (nfp_netdev_is_nfp_repr(netdev)) port = nfp_port_from_netdev(netdev); + if (!offload_pre_check(flow)) + return -EOPNOTSUPP; + key_layer = kmalloc(sizeof(*key_layer), GFP_KERNEL); if (!key_layer) return -ENOMEM; @@ -1646,9 +1663,10 @@ nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev, static int nfp_flower_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) { + struct flow_cls_common_offload *common = type_data; struct nfp_repr *repr = cb_priv; - if (!tc_cls_can_offload_and_chain0(repr->netdev, type_data)) + if (!tc_can_offload_extack(repr->netdev, common->extack)) return -EOPNOTSUPP; switch (type) { @@ -1746,10 +1764,6 @@ static int nfp_flower_setup_indr_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) { struct nfp_flower_indr_block_cb_priv *priv = cb_priv; - struct flow_cls_offload *flower = type_data; - - if (flower->common.chain_index) - return -EOPNOTSUPP; switch (type) { case TC_SETUP_CLSFLOWER: From patchwork Mon May 31 12:46:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 450740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 993F5C47080 for ; Mon, 31 May 2021 12:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E829610C8 for ; Mon, 31 May 2021 12:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbhEaMsU (ORCPT ); Mon, 31 May 2021 08:48:20 -0400 Received: from mail-bn7nam10on2126.outbound.protection.outlook.com ([40.107.92.126]:16736 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231582AbhEaMsL (ORCPT ); Mon, 31 May 2021 08:48:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFHgax293c1z6FQ5HzuNsiZt3QoXySgbKWZ4z9Fd9p46iI5e02MzhxwRfU4ZsAv1Tk8CDfXy8NcDoSjUPqOuMER4wS0QmBaaByM13zwMAy9/51ghn2Ze9CmY3qM/9pFh+oH+EP61JbksinZPhiA4VDpU8jIlPKvGpBHtRbKf3UKghGG1LtYlcuExcEVIY4VgOlk71kCSMeKrr/5reOFrWUObNc3B9VWexINdiyASJJ7h5SpR/2OdhnhfbZAQN0rdFLHS0+NyFlWPzpqOMp/VacROrrxW/vv4lH5dMntkK9wKEJ23bmCHfaj7cHsXGWwOpkxqdgBH+8sN2Bp5fpu0qA== 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=af2rQzdoe4lv+JnJXYdoLgNj/h12E9UWooi8U2lsgzE27khQrOCfD2XRuAg27Fej9SaCpixQUfe1cYAv4rUm5mhwYNa2ag3nrJqbonWcdQtnJnlY3tNeZ9gqgNHkGCtzjj80qOVGws4Vtpb16M9UILw0QH7UtsRHI+gQp1XAKSzUhGeku09H3+B6OHkHypSPQw+YC9aVgGH2rnUk1mdKNhOgSQz6JMokICCMwpk/uebPScpdLHT/t+ZEuFJtqweKlxyk95Z+CqhM+UfRoJjM21nRkSslecTFWT/Ju6DGHxwRy/eah8S+qfQRZ0/Jma9ljRkSfE3eZIn6dOdGvPTdUg== 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=PsVauvgCTo5N+VwiYzgPHirDDV2l86OsV4IMeg2q1Q4ovvhUaWupc06eB1+hRRkvybTZGsO28XccbHNLrw1caw9Z/H7BdkVh1wvdL8UJtIFodduS0R+sWFOXoznCDZqXCGDqSsyVjoV5k7v8K7GIEljIYeLfBMLRIRI4YQ2m/uw= 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 PH0PR13MB4876.namprd13.prod.outlook.com (2603:10b6:510:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.17; Mon, 31 May 2021 12:46:29 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:29 +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 v2 2/8] nfp: flower-ct: add pre and post ct checks Date: Mon, 31 May 2021 14:46:01 +0200 Message-Id: <20210531124607.29602-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dee05a29-0d79-4a62-4bde-08d924321c93 X-MS-TrafficTypeDiagnostic: PH0PR13MB4876: 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: XpeC3cVQ+SMyo/ljpeVjgwJ0u7Mx6tJ8QtAE/H+llH0PFY+jnsiCVUyYCoWp7MMfG6X+0Tck/VHHzIn8T2JDHsRGSxo7C1tLUARMaE/cAdJzMafi5hj3J8DusJ5VPn4b/j/rtN/2Mcv3UM+XeT/mz/hgRR3USrJZjJk0ntRKhw7JXdecdL6E83V89MUrkuNbSWv35uCh3JxkzSwCIlhoJoinmCED22Il5loen7qWKKvrcK+6UxeLgzOTPllFmwI/uFIZtus2N3jU2KOIQAFYCUUZ2sa5bV57rnRi4KuVDLnT5PEvRmo6j0VFWoSzld24ASbckFJeP3ZWJy9QF+H3LqZib6yJx+X4AsX6qbJSvdXlrZYpadolkYzJPdE3u7FArsfcw6AOXKdWecE/6CEoZT+P56HMatwBjUQhwMoGa4naqu6WwwVpAp8dZ7LHPRsOv5f8iT5dh6ktwNpgzj2B0lrJVZs6FtZ5hYjfPrxjwt6rKd59IMUfO2+9xa4Md8Lwvz5BgN9B1GuuS/TOa5LMSw6Ewb34mlUxijCSHkf/CX1r3ov7i2omNcIOOd9GHvaHrglyiW+vh1sCCocASS3S1I1+cijRE3pzSrGUmva66g4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(346002)(39830400003)(136003)(396003)(366004)(2616005)(6512007)(5660300002)(6486002)(1076003)(186003)(86362001)(36756003)(8936002)(4326008)(478600001)(6666004)(16526019)(8676002)(2906002)(66476007)(66556008)(44832011)(107886003)(54906003)(83380400001)(316002)(110136005)(52116002)(38100700002)(66946007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: sjjdXKuUxaVEoCXRoqKuVsuOh5A+JHP+ShMeyLP00otLrQ5z8BmfkTxyL77jjmJNarRn+G1S7l7MJTk2B1x8pTxK73MkYZDODxcChQXTC7CuL4QT8S76o3cYsrWlpAcHKIHPfBY+9WLranHIi8lasK5pLv+tvwd+bLuIFtMzvod2GMmP+ECH9Xnkhb3uwd4ceTfC/YV/AnrZBl/1Q+zRBSQ4RLPtnmaCSefPfX2dYU/3rznTx0E5jWXBgFat6qeddSf0ZIcWFSNnD7yIRRpIncVPts5gAUIzkfS9fPO/OrQuEqT9J96DV54jlg8qEixbESlk29IVaYLWS44A12frn8SVsVG30KLLAjnJ+5kRRoWK49ba7eC7I231HLrLs3LRcFCUnB7XmwG5gMS6E2V6g2kD8CFyuxXcfxISc6fzf2k04gbMxQKHq+ns7BEElohpT1VhghtWJimYAOBCT+cFi+xC+aDZ03xb+J3mSq/fXBTiNuU8bp6wbCKqJdXzOG1NPXtDprpqjEcGCWUu/zBiN8fpHXWhJe6Fb9lS8b2yiEmEgGc7KGwiicq4viak9uyiZ+6ZsGF/DptaRhE4slbzFS8tz9VZOEpNOefmykDYOUeDFtjVcsaBq9QMIOD5FcnuE0cQF0iBy5a4l6/YaaNz7JpbrwoPtb6IFmem7qYIe5UNVBhHlxrimUELfzW82bF2rNKNg0SA8dGZhpuaJFF4Xce5qpa1qycwRVNzFsBEiS2QbrnVBPK60f019ZZO4xwAxuGTbQwzGy7BuD5HbCbsW17JmW3yiwVAxuYF/I2OlrJ4t5RDoA9byr5MQP/+sZB/LZXYB1Ubxm1hXB/KRxzLQ5P73Q43dBKHadeZuFvQPyb7A6I9FITeAIDJqsbxG8oQHv7TYUEe/pYjTofwQCWwRcV7zz/MHFBvJfq+Yfgs5YK2wbw/Ue5Sb6IDRRcWmcXVbHkyarYKj6BtIEXh4nd0cQ/d0QHbFV3DO+V7kXmqKPjLtNcPEmK+3opVH3nUZeYCv2jDeIyNypgbi4FmnIJbTc9CtOuZzBAdMzqKNIEfG/tjNG82nG2LSjfee9Rfil2RRyKwGCezYJadr6j/KA7lVP/kDRSTN2kJLXTeCZFYuREdp9LxlRm1lgQoRjTATOITanDrzcP/i1rMFSlnWuJJMqQzfLP+XlEZq+txn/IDbwg1oINKEgmw4+Bh88BbwE+ew1F3ibXsY0KMJY3XsguOCI0AHpA+//casVmy6ka8D/QlhvaTUUzgq8ubpTJV9a5JA2vD0qbpLbM9Kw8heeVNww1VzzCkDUPgfasCpjCqHVyDAaKwMPdnX7aAPuyyQ59IyQYskMbdiF529rtLxkJRJNhZ3H/dUJYhXDVXUScgWblG3P6MrfN6r+/IfNcNyJc0 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: dee05a29-0d79-4a62-4bde-08d924321c93 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:29.8425 (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: ieI/ZZaQMqVXRELzfc3KDBlmGpYPk9g4XpsL5LeaN56c8o3dxPkiAilcTnyIqDQtAMacd2beelK4Hx7A3q3SGm8Pp5y0/nDY6NT9kY4acgs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4876 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add checks to see if a flow is a conntrack flow we can potentially handle. Just stub out the handling the different conntrack flows. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- drivers/net/ethernet/netronome/nfp/Makefile | 3 +- .../ethernet/netronome/nfp/flower/conntrack.c | 48 +++++++++++++++++++ .../ethernet/netronome/nfp/flower/conntrack.h | 45 +++++++++++++++++ .../ethernet/netronome/nfp/flower/offload.c | 7 +++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/netronome/nfp/flower/conntrack.c create mode 100644 drivers/net/ethernet/netronome/nfp/flower/conntrack.h diff --git a/drivers/net/ethernet/netronome/nfp/Makefile b/drivers/net/ethernet/netronome/nfp/Makefile index d31772ae511d..9cff3d48acbc 100644 --- a/drivers/net/ethernet/netronome/nfp/Makefile +++ b/drivers/net/ethernet/netronome/nfp/Makefile @@ -51,7 +51,8 @@ nfp-objs += \ flower/metadata.o \ flower/offload.o \ flower/tunnel_conf.o \ - flower/qos_conf.o + flower/qos_conf.o \ + flower/conntrack.o endif ifeq ($(CONFIG_BPF_SYSCALL),y) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c new file mode 100644 index 000000000000..aeea37a0135e --- /dev/null +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +/* Copyright (C) 2021 Corigine, Inc. */ + +#include "conntrack.h" + +bool is_pre_ct_flow(struct flow_cls_offload *flow) +{ + struct flow_action_entry *act; + int i; + + flow_action_for_each(i, act, &flow->rule->action) { + if (act->id == FLOW_ACTION_CT && !act->ct.action) + return true; + } + return false; +} + +bool is_post_ct_flow(struct flow_cls_offload *flow) +{ + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); + struct flow_dissector *dissector = rule->match.dissector; + struct flow_match_ct ct; + + if (dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CT)) { + flow_rule_match_ct(rule, &ct); + if (ct.key->ct_state & TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED) + return true; + } + return false; +} + +int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack) +{ + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack action not supported"); + return -EOPNOTSUPP; +} + +int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack) +{ + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: Conntrack match not supported"); + return -EOPNOTSUPP; +} diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h new file mode 100644 index 000000000000..e8d034bb9807 --- /dev/null +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* Copyright (C) 2021 Corigine, Inc. */ + +#ifndef __NFP_FLOWER_CONNTRACK_H__ +#define __NFP_FLOWER_CONNTRACK_H__ 1 + +#include "main.h" + +bool is_pre_ct_flow(struct flow_cls_offload *flow); +bool is_post_ct_flow(struct flow_cls_offload *flow); + +/** + * nfp_fl_ct_handle_pre_ct() - Handles -trk conntrack rules + * @priv: Pointer to app priv + * @netdev: netdev structure. + * @flow: TC flower classifier offload structure. + * @extack: Extack pointer for errors + * + * Adds a new entry to the relevant zone table and tries to + * merge with other +trk+est entries and offload if possible. + * + * Return: negative value on error, 0 if configured successfully. + */ +int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack); +/** + * nfp_fl_ct_handle_post_ct() - Handles +trk+est conntrack rules + * @priv: Pointer to app priv + * @netdev: netdev structure. + * @flow: TC flower classifier offload structure. + * @extack: Extack pointer for errors + * + * Adds a new entry to the relevant zone table and tries to + * merge with other -trk entries and offload if possible. + * + * Return: negative value on error, 0 if configured successfully. + */ +int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, + struct net_device *netdev, + struct flow_cls_offload *flow, + struct netlink_ext_ack *extack); + +#endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 16ef960a150d..7e4ad5d58859 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -7,6 +7,7 @@ #include "cmsg.h" #include "main.h" +#include "conntrack.h" #include "../nfpcore/nfp_cpp.h" #include "../nfpcore/nfp_nsp.h" #include "../nfp_app.h" @@ -1316,6 +1317,12 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (nfp_netdev_is_nfp_repr(netdev)) port = nfp_port_from_netdev(netdev); + if (is_pre_ct_flow(flow)) + return nfp_fl_ct_handle_pre_ct(priv, netdev, flow, extack); + + if (is_post_ct_flow(flow)) + return nfp_fl_ct_handle_post_ct(priv, netdev, flow, extack); + if (!offload_pre_check(flow)) return -EOPNOTSUPP; From patchwork Mon May 31 12:46:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 450739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E6FDC47082 for ; Mon, 31 May 2021 12:47:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61A4261279 for ; Mon, 31 May 2021 12:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbhEaMsl (ORCPT ); Mon, 31 May 2021 08:48:41 -0400 Received: from mail-bn7nam10on2126.outbound.protection.outlook.com ([40.107.92.126]:16736 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231416AbhEaMsT (ORCPT ); Mon, 31 May 2021 08:48:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g+LbptpY7hluQHFTiYPdPfxtAxSeqa6K8QQk7fy/JYAKazXxi8gChXALvgobg25XP7HyfQp6tkaQtOAq6MD9jxedhasFW6tXR9BzdFkU7ACQfu0wHRf0SHRR6DKLMV+Pyt4AK5Q0v6hwZSRXU+po8WsXt6TFPNP47vt75V9Iu4oYh67JefHrWJab2eTRdjNVQfqUTvcmEnACrJ19R5K6vaWcHhR9DccT88Xbvy1fKUrcac4mjT9y94GpFjiidc0S+xhdB3shUrVhS44ZtlbQBVkQnIFT6D0AYAzQyHKdwR3dwOgac1lIf2qUEuP8mU6rmyzCQN5eVBymCeG8Ah8YUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rcPkcOJ7LLyIpdJhlg7GOENpE4afUtzxsvURmMpaiDM=; b=eLNNvvlblseNqQrpsOODEaC2I5/pOvyvLgYlI3/JIMIFt/IPAqsXbtbHtw2Lraa795JGYN7jHKx19QrkQWOgkjHFe/j/RnuHYPZeCR7fDjvU7ftS21l6M16dur5S4geyTNLdFZluPHxBddVKtzLFhKQ2c+e4/CpVbJvr8ngTY73o7U1X5iAy0U3GdHL9N1soBdzGsNZsDZ2tjHBafJLh6mGErJ4ZDyW2lwLL4KBkQqq6ERzd5RLb/JbfCvZ0+JcN02pzVV4OICRmL8mvuiwfIVtnlSaL6yk65dONT8Ocr/lX0DI04rnbBOut2Y0dNd8GQIZr/QC98FS7Q2xslE0rMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rcPkcOJ7LLyIpdJhlg7GOENpE4afUtzxsvURmMpaiDM=; b=a1en3yqnm3Gd8wVr6W1ujMOtIs6YdmbWMnEICHnKh0IZrIaLPMr+eMxbLUMW5yWAfkx5WvvHXFM7ym+qpp1NCuscnH6q8nbk9HRDvhNJt59AFfV9CBKMm2UlGRk813RBazW3mtWAaHeS7uGDNUuqq5WPNB8j63sCcLkUXvmMXNk= 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 PH0PR13MB4876.namprd13.prod.outlook.com (2603:10b6:510:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.17; Mon, 31 May 2021 12:46:31 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:31 +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 v2 3/8] nfp: flower-ct: add ct zone table Date: Mon, 31 May 2021 14:46:02 +0200 Message-Id: <20210531124607.29602-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2a4d611-ba9e-4407-4f35-08d924321d9d X-MS-TrafficTypeDiagnostic: PH0PR13MB4876: 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: ZD0NQDrIYb4N6ibx9Tt/x8zhiPWNNr1mayhYpuw2eap/dz3hJxWCYK64sWxm5+uzwH7ej6V9GdTQJHANjEgzb9s1UJemLGqRiFbDEiawhXMU7buASnMDryN1xZqNwkxuhf2IHqFNdSH3+ws41cAc30qmqRl+wh632M8mdp8X0+j3/fQfbkrATK5w1N/Rn2Vqq9p93m/7EU3LkrDlPX3mTD/3IrvSS0kITUTb+chv52OK+5agBHZyZim+6WnNToISSQyOr9sWXydHvsUU1jk48iNf2iD+56ATMglYQl7M9iTnlln6c4bDphNfH6hZKWQwC9OvCQD3wgvBrQFWgpV9v4wIc9h3KkB7vaC2G5Cf43JOxWXa7FTJ2bSOnlrkR2YHoZWUFZzxeOFhTgo5CeRzA1JfATpxSjyfM2rMeGORIYma9w8b5KXZ+FlBQwJJrHJTBm8FkIimIlSdLZipPn83+7m/uqfcTuT9WchAqhHWqEp23i5wj53bW89RSLyV1wpOf3s3iFH6V/cx0v8a5BsppsAWmWzQ9bHTUBDu4aMe90E58H46N4CAgS+hwJVIm/y+xPn6civ/yIyRzIn/75J11WcXO+3YOzCZFMG6UMtLHDY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(346002)(39830400003)(136003)(396003)(366004)(2616005)(6512007)(5660300002)(6486002)(1076003)(186003)(86362001)(36756003)(8936002)(4326008)(478600001)(6666004)(16526019)(8676002)(2906002)(66476007)(66556008)(44832011)(107886003)(54906003)(83380400001)(316002)(110136005)(52116002)(38100700002)(66946007)(6506007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 5fuPbLJGGPDIc/Tu7t5P3Pn3nTmg7E62cwJmajnUe4L/nvqrevJVY5pGEIs09xON9RAF5QH9hsy3BHyNmAtmrT/Ab++fLHGxAhAURN7a7fk6gA29sbAxwhS9aGkks1KIBwbKX5rfJW/G09BEQxXxS5wxj2eJ9Y21xkLdQ8r4LgMFqPUu7RjlH0eJKBuGDrbKca278LE9PS+gtc55o8LCnuJcmfO3DdhGX9L1uI+pUt5tDCSckg+1rqlk06N3pICLzthlTlxoKi9jvxIJmqKeuMjHl0oRyVg7JYYsDDSv+DTz0D4oJTZZDDiJdoKDlvjP49XVdOyUdWpj6USiq2lYERohZqKjyajKwH5ylRdzndbimvPAe762agh/jI/HzcDCbZ+U9crVnb7nz0UDzy8PGx140IGXMs3wrgZ4vF2p39ciaFxRBwj64uqKTmuaRTnZaeHLTeFZNiSH5y0/ghb1n1BdY7qbYWporfMlq6QfPEkUVwuf8Vhsu1bFzb8YRNJBCmw5hkzOEEs6nIWfzaji32CGzGENwbb/7+082CA64BxxoIP/ksepIaPf8p9Ytbdwd+Oi0Ak27BRli2uvWv2hj0tiCrxZvUNGiOWkxxDW+/wb245I6LatrK9A+YPOyAj7YFqAEJ5065W0mrC/0/LxCOmYnBtkF5ePCp/FQ4PFhs7XACSPqKgnCwQgyzGy/BmqNZREH5EPLNBwZoZe0Bxpmpup2/iUaHz7FmpyxjyvAvYP9NYZGR3eVZImLFq2nOOdHxNR9JekBUlCvWYvdMPSJyjaWvbG0Uyi/EuPbgvp01i+Y86TxebmbdYVeB5PUcXrxU4VA411zgnKkHJiwU0YUUFNVEvPS/7FfXwV14pCXS6gC2AH5paky2v3ttg+bDqBwoSt1J1iAUH5UIcQTmt5s6/d+6ks2+B+L9LNQDsl3m+64ewGGcsRePNZ3/OL9Up+50MIdWAqD/lbMU1ICTv/1Ht6+nq8WWjzuYEbpnOrEh/S2J/OkiPxELKMdn88XIehuvfIuvymCdYwR2I86cd5RBY9NdpgKpm4zen1ezZSc3XzyQPEY2EfFu869nvZicAWNojKl6Epue9KmejaGq4JSDwp+ho7GFtWDwqTSXtVyT+Mj45ivb1Ew149NdtMEbcjmA+N9hz0nU6LFL+5HNxhvZeTZYSR9uH7ZS/Tfim7kpa3Ql8n310saiIVlG6QiNiGTnaAT7scVjsS89N59pgE0FIGOwbMC7ikMQ+dIUWQPAudqxhjlyjw+eri+RWOnFYb9poiIisgVuLA+Wihc3+JbqlYhO0vlY7LHdD4x77G+liyv03S8td3T0yYFudcD/8Yxe7toiimEYGvVoAuzhbcljQHhgABVe0NkpZ2EMkrLSYf7BCt6wDrQYLSj7BVUFn/ X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2a4d611-ba9e-4407-4f35-08d924321d9d X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:31.4743 (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: GhtYj2O7voV5W3qAqV1WAzlWDDDshj0x41L33gfwLPkE5Wwyw0f/Y9dbgQuK8fzqnuQVw4aOabmRCEucFZUALUefgrhSkbPSRCk/xlP/dqg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4876 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add initial zone table to nfp_flower_priv. This table will be used to store all the information required to offload conntrack. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.h | 17 ++++++++++++++ .../net/ethernet/netronome/nfp/flower/main.h | 2 ++ .../ethernet/netronome/nfp/flower/metadata.c | 22 ++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index e8d034bb9807..5f1f54ccc5a1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -6,6 +6,23 @@ #include "main.h" +extern const struct rhashtable_params nfp_zone_table_params; + +/** + * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information + * @zone: The zone number, used as lookup key in hashtable + * @hash_node: Used by the hashtable + * @priv: Pointer to nfp_flower_priv data + * @nft: Pointer to nf_flowtable for this zone + */ +struct nfp_fl_ct_zone_entry { + u16 zone; + struct rhash_head hash_node; + + struct nfp_flower_priv *priv; + struct nf_flowtable *nft; +}; + bool is_pre_ct_flow(struct flow_cls_offload *flow); bool is_post_ct_flow(struct flow_cls_offload *flow); diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 31377923ea3d..0073851f31d7 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -193,6 +193,7 @@ struct nfp_fl_internal_ports { * @qos_stats_lock: Lock on qos stats updates * @pre_tun_rule_cnt: Number of pre-tunnel rules offloaded * @merge_table: Hash table to store merged flows + * @ct_zone_table: Hash table used to store the different zones */ struct nfp_flower_priv { struct nfp_app *app; @@ -227,6 +228,7 @@ struct nfp_flower_priv { spinlock_t qos_stats_lock; /* Protect the qos stats */ int pre_tun_rule_cnt; struct rhashtable merge_table; + struct rhashtable ct_zone_table; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 327bb56b3ef5..4a00ce803df1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -9,6 +9,7 @@ #include #include "cmsg.h" +#include "conntrack.h" #include "main.h" #include "../nfp_app.h" @@ -496,6 +497,13 @@ const struct rhashtable_params merge_table_params = { .key_len = sizeof(u64), }; +const struct rhashtable_params nfp_zone_table_params = { + .head_offset = offsetof(struct nfp_fl_ct_zone_entry, hash_node), + .key_len = sizeof(u16), + .key_offset = offsetof(struct nfp_fl_ct_zone_entry, zone), + .automatic_shrinking = false, +}; + int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, unsigned int host_num_mems) { @@ -516,6 +524,10 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, if (err) goto err_free_stats_ctx_table; + err = rhashtable_init(&priv->ct_zone_table, &nfp_zone_table_params); + if (err) + goto err_free_merge_table; + get_random_bytes(&priv->mask_id_seed, sizeof(priv->mask_id_seed)); /* Init ring buffer and unallocated mask_ids. */ @@ -523,7 +535,7 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kmalloc_array(NFP_FLOWER_MASK_ENTRY_RS, NFP_FLOWER_MASK_ELEMENT_RS, GFP_KERNEL); if (!priv->mask_ids.mask_id_free_list.buf) - goto err_free_merge_table; + goto err_free_ct_zone_table; priv->mask_ids.init_unallocated = NFP_FLOWER_MASK_ENTRY_RS - 1; @@ -560,6 +572,8 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kfree(priv->mask_ids.last_used); err_free_mask_id: kfree(priv->mask_ids.mask_id_free_list.buf); +err_free_ct_zone_table: + rhashtable_destroy(&priv->ct_zone_table); err_free_merge_table: rhashtable_destroy(&priv->merge_table); err_free_stats_ctx_table: @@ -569,6 +583,10 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, return -ENOMEM; } +static void nfp_free_zone_table_entry(void *ptr, void *arg) +{ +} + void nfp_flower_metadata_cleanup(struct nfp_app *app) { struct nfp_flower_priv *priv = app->priv; @@ -582,6 +600,8 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) nfp_check_rhashtable_empty, NULL); rhashtable_free_and_destroy(&priv->merge_table, nfp_check_rhashtable_empty, NULL); + rhashtable_free_and_destroy(&priv->ct_zone_table, + nfp_free_zone_table_entry, NULL); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Mon May 31 12:46:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 451873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF2B8C47082 for ; Mon, 31 May 2021 12:47:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B336610C8 for ; Mon, 31 May 2021 12:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231668AbhEaMsg (ORCPT ); Mon, 31 May 2021 08:48:36 -0400 Received: from mail-mw2nam12on2114.outbound.protection.outlook.com ([40.107.244.114]:7041 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231611AbhEaMsP (ORCPT ); Mon, 31 May 2021 08:48:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OX98FVYYv4qkiCgqqNEDFy6UHl468CWDpWyM6Al6c5BnfWEndskDsv+YJ60kqehhneRQ47jsYr0SSkRJloRB90/k589Bs5Aupxg+Mjob3JwXjRf9K9WsKE5kde08v/251Hpnj1EY9/0i18c9m7h3SIynQ0mw3Bpa6t1UXksw/P2P2BVUUHqUzPwnBLhbVioXnuA6aFZRfe9/HlG6gy83w0u+/Z+zm4gjkC5p+tuPdqzARQamSvl37hb4EamE6e9E6hx5HZEIk72mCeFY0C0vCi0HEIkDK2aBvrPu7RNoXEQcH3YVXHLqtqt43bWeND1vpMb5sg0Gc61Ad1oAiNXETg== 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=tXGpXXL+YDJDOJH2gnMglEcURAVS7ACDx5Pj0ZB4OVo=; b=fuctGXZfkU4sQ6TmVsSstOs9n9Mqk25wy2Cz46afQezRJOhY4QYepPJLO9NHtIPBlSa7v8vCj37oldYNgIZ3ZNkR29wdstNpn7D/7Kk3WMotiCvWptASZVyu23Ju7rrATXqL8wu6X7RHhpQ9XvtwU5QpbUYL8jW6cHcBvV4oDFaBzWUVToZeC7jJdHhwdFo1KMy2diMcmztyfBZSyI0++ioVqzo1Xz+kwnhaExY4IN9eT/cgZuN4EaNjm2YJwiIci9cJjiQYSKmqxGAkgNaJve1p4VdGm9YGv29QpP5yqq4EMXOmREuE9tVlFx0YWVBueSDm6EdJPep+9oFlfkGNFw== 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=tXGpXXL+YDJDOJH2gnMglEcURAVS7ACDx5Pj0ZB4OVo=; b=XanyEarzMeHd4QG74tEia+lWutyYhTflgDRpeeO9Gre9lgN2ak14zpj8cIESrFc+IeUo9TG/brqn6oMRrXKn88qe94BbdSvHl05SR9sRm2wLFSDmuO1cfvUgGSAPlWJn97c7cMiQvemqXDs9j32pkcEwaSKsU+bSC4L0mUVa548= 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 PH0PR13MB4891.namprd13.prod.outlook.com (2603:10b6:510:96::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.12; Mon, 31 May 2021 12:46:33 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:33 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next v2 4/8] nfp: flower-ct: add zone table entry when handling pre/post_ct flows Date: Mon, 31 May 2021 14:46:03 +0200 Message-Id: <20210531124607.29602-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 460d0b1b-87ff-4bcc-8874-08d924321edf X-MS-TrafficTypeDiagnostic: PH0PR13MB4891: 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: x27MFk5Jjayh/LHY1oii17JQXvbNpJ+5xa4bn9Qf7dJ1V+gmQBH98i7C3HLbdvwpAABBxLYCPaAL183xJdmM7JeVbUKOI01pko+jzzjsQqdPKzd2CXsvXOvt31bgi5y4PxkMh3TUnrGw8Ku+LsCJBtoMDxLUuKF3ckS7TEiVvFVWSbS7HUEaa/MY2UQQyUJSjIFkyD3Cn7up5l4jx87eG1mOSLLsCFdixMn0fpccTBYkyyYvxifP9vs0sn3bBhUbD/SmXwkhjpIdvDrQQpdh+XPWlxALg8mNvbABPZ1Bu0P3B3GbZ2KAVip9PC9pnCA/9vS6tPqMRpWA7Vnd9gFhaQ7PAnFwhPgX6Kmm2lvPeYmwrrDzMYO2pNrkqI0iIotloHYuMlWFCSYevwBcbMxm6FTt995BYh55zK1Mj3JcTsi6wUjABmo5bidBOt4fP9WaYreWwaVirpR/gy1db0wURA2u9PQMCtfis14apfqpAB6fl0SxmWBxCAPJmcpgwA//YQ+p8aRSv0ivAJML/jBony7Q+vs/0MezgjbsVBShbXH1ouKc3A9lU2OE0x3svrj1CjGPuRmHohj2rhkuUPvQ78Swsd47bwOTxldJdLYZ4us= 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:(396003)(136003)(346002)(366004)(39830400003)(376002)(107886003)(2906002)(66946007)(66476007)(66556008)(36756003)(38100700002)(6512007)(186003)(16526019)(4326008)(86362001)(8936002)(8676002)(6666004)(44832011)(1076003)(6506007)(54906003)(110136005)(6486002)(478600001)(2616005)(316002)(52116002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4AcPQ5NwTKWugVXNSX1WVM40sWPbiMUHR94jSUwxgiRbQnQoDfkclfhnCvzWbFsvOwrGlRUJiyMWYwiztEr0a2g9aPI7n+FbdXsTAjtv/X5jJSozjO9QOm2nejNUzqYtISgDSbKq2IsQbwBT1ZvJNbtujcfOye+BgRuUBkJtzxxAZ4n4oeZpCKry2hyC08FX1sUUJrGd54KEEalKLH/iOlwpyovc+QNAwLkwo09+nvtQfWd9ekLT+k6ZWvDLCd5mr8XTpK9/lpyNc5a+mrpSv6ZTSJglsErB3JN2aO2b7S4GEoLFYjo2wJxdsOQHranjeVmvlQVYIrkiIIlK6pJkh8kVr+2XULul2b4KF+9iMJwvke6CA2hmXLEuGoEHKyOdHMnj1hAnYQDs+oxn5cCFIrr6y9/+sA5bmortzXz2iYrgeGWpreatoJwl8EfFLSRjRmr9vVhu7MxRh6EJfwR7Ui05AFM5SHUIZNGLkKEddiejzE7A65XReFCEDcUFBZQlOxA5Ax/a9B9R4e2MI+kS37GGh5E/bOtYvdu2qxm9NknYXXdzA0wRGJBjPwzBc9b6zjmxLkkfPM2aEp1ZmT6Dp5zcr8rkoPweGBiCgLW1dA8UvnrBs0PHP6MaIy523TouZkcXp3nzHk2FKbWQwDHT2hsHLZwRoPcyCZdo/k8OKGFK/50UwYDAM8SbSZUUOr9B/ngyFePG7oG3FodoqkjcWYZSJ7Tk5QoZR13nZWogFdInXGE2s7RZK1lNACCneKuGBS8sk9i/q6+RJS/dtelZGqftlGQnQJdB07yyAuCS8N4OopHMXah4kv6GXH9TgiKvCfeQObFBeBz1JhN+rQ6kkD11+8suwKMt+B5zRp+lnGswc4lTazGlgjSyS9o6zoCPMfQ+tYOsT2z/FQLDAkcSGimfYK5eQTyw4M9QQbVzaUpzXnJmS2/jUZ6U4F0iK8osM0sccjiXa9YwnuZzL574Bi1f3QdO7VHCJSNWUWS5fCFwZy8cPNNWqG9VqN7jgJsFgna31fuO8KnFSWWJKAWKCAwysOETCyJX8jdAu9IjMJVap/K8ktK4dfXMA7OL24/UcmSMxond2/joCIDagfHjwxpcnP2ami6Y3lPpckcvYeMFUcinGAB+DH9WTHI5thNzDrcNDuZTQJGMbr9mhhq5s4PqQ/Zk/adPw4AdPGkgKI/2N+RKJtLizYczw0p/DsTI12zREKHX2hZ+Ocf3KCYsQHfNOPFrAa3Qss3vGu1LUtZxd0LAOAe5+2j0Uy6kQ1fTnZVB7IQYA7rJcPQjdvOHLOn1OATWv5FV7jQSeNXf41vpFkjIJrX9LzpkpIOM4daSNThNcMRA1GMUKj2VgOMhgm1paWjjnBppht7PSgVvWoGodNGQP/hEBfRUNrkuPKeV X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 460d0b1b-87ff-4bcc-8874-08d924321edf X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:33.5801 (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: niMqJfyAonVm+w4+zonMGc3lgsAqU3YFXE8DqyqSwxRb6uxOIdH/+I7VnZwfwmDhcLPrCOLWuQT11vwYwm4/yoFZaQGelpqwClf5048a3DQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4891 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Start populating the pre/post_ct handler functions. Add a zone entry to the zone table, based on the zone information from the flow. In the case of a post_ct flow which has a wildcarded match on the zone create a special entry. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 124 ++++++++++++++++++ .../net/ethernet/netronome/nfp/flower/main.h | 2 + .../ethernet/netronome/nfp/flower/metadata.c | 4 + 3 files changed, 130 insertions(+) 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 0073851f31d7..060c6de36c02 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -194,6 +194,7 @@ struct nfp_fl_internal_ports { * @pre_tun_rule_cnt: Number of pre-tunnel rules offloaded * @merge_table: Hash table to store merged flows * @ct_zone_table: Hash table used to store the different zones + * @ct_zone_wc: Special zone entry for wildcarded zone matches */ struct nfp_flower_priv { struct nfp_app *app; @@ -229,6 +230,7 @@ struct nfp_flower_priv { int pre_tun_rule_cnt; struct rhashtable merge_table; struct rhashtable ct_zone_table; + struct nfp_fl_ct_zone_entry *ct_zone_wc; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 4a00ce803df1..10d84ebf77bf 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -585,6 +585,9 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, static void nfp_free_zone_table_entry(void *ptr, void *arg) { + struct nfp_fl_ct_zone_entry *zt = ptr; + + kfree(zt); } void nfp_flower_metadata_cleanup(struct nfp_app *app) @@ -602,6 +605,7 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) nfp_check_rhashtable_empty, NULL); rhashtable_free_and_destroy(&priv->ct_zone_table, nfp_free_zone_table_entry, NULL); + kfree(priv->ct_zone_wc); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Mon May 31 12:46:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 451872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 079C1C47082 for ; Mon, 31 May 2021 12:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDBEB61287 for ; Mon, 31 May 2021 12:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231473AbhEaMsw (ORCPT ); Mon, 31 May 2021 08:48:52 -0400 Received: from mail-mw2nam12on2114.outbound.protection.outlook.com ([40.107.244.114]:7041 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231589AbhEaMsb (ORCPT ); Mon, 31 May 2021 08:48:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VwPAGDGhY1Xw5SN1i65jSm9ALwObJHgMuGPsVH9aSNYrGQj+jmpXM5yGykdi/xeicAU7SrVPnXxcZZr4exyJy1z7T0zrlZTdWOIl24W07fe1bAzgnrgtm6kOaAhJZdJlu2TtTMkw6c447xihu96CqpHSJO7uZbj9xi2eudm2LaZZMuqaTPhnfqi7wFxLn6ElK/8FsHMjSbX/8np9WGAEISsPr9Ufm2BAhnI0WpoBt4gAliHaO4aDRp56W/3hxwkg0qabTc8WZ20HK8wBvF/nAFpaTJDzDFLtTnzWNz9GYKnDFzQX3+A7HsAuXlP7vuvd8gOi89lJd0Mj6KEoGc+u7A== 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=P9k+GZgNG6ZbpnRK9NxAX8z/uUTsAWKae9DLHUtVWfY=; b=igQb5QcR4xZc+YYpSx06dFsKt/+MqND4x7uVehh3FnwNXqq41r7WEzIpyivnO/bhE9fEAXRHz5GHnz60pWNQIvWhyfF87Z05gIH7ybKxmpiW75thL7QqP2BwEwaakh3le1mWwalJ5zel5BlSJZpdV4NL+/iEGdwEcLsqsytAsSSvLuSB5c4o+ue0KF0DTEnWe2hTBs50pkhPCuUMc3Zem3N5poyZpzU99Lo3O725lRfJapUXhQH+RrDXZ8cY+UiR67v99HxlPpOfJpkVeXn9ofLJtUngJMMOlA3uFXmUFoC5ctdp4RAM7Jiwh8uP6WagAQ6Ze6otMfQt8qKh6YO3SA== 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=P9k+GZgNG6ZbpnRK9NxAX8z/uUTsAWKae9DLHUtVWfY=; b=H1EEv50ujCKiqVO0VXWoAWpA1J7kPmNx1WBIfTvLvhPeap4DiHJRc+TPzKkjh6G6oBKE0NjRK92cCV6lcda7VLTdLYYEY44gLFO3WgvW8rcO5nlvag8z8cxX+bXLMjNVwR1WZpv4j2EXS0DVnEYB3GFF/HZYDq3+CpRZu9muABo= 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 PH0PR13MB4891.namprd13.prod.outlook.com (2603:10b6:510:96::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.12; Mon, 31 May 2021 12:46:36 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:35 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next v2 5/8] nfp: flower-ct: add nfp_fl_ct_flow_entries Date: Mon, 31 May 2021 14:46:04 +0200 Message-Id: <20210531124607.29602-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f237c61-13b1-470d-4328-08d92432201e X-MS-TrafficTypeDiagnostic: PH0PR13MB4891: 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: mSFmT8FGMxnwbtIiXU5p9bU3gKG0SS/OlsboBiL5+wO5JqEVvSZzlS4qofItl2BR7RCmNW0KZtexYNSXeGudWs9n+Qf2r6Xm4/1i42BbSe36/wHFIyXauFykstH/DCg/r1I8YLWddb9Qf7521/3a+PmNgXCqiiUB1oBOR2Tg7cUGJcJkkukIRsyLWTH7FbBWTzpohWOqC39wyywcLD4w5Qw20Wdffuk9zxU6aU70w4MNTpxCubR0rMwy0RDfUb6QtYiBKrW2gkRXl3R0M/S15xrlES4PFjkEiAyWoNAKcFQo+I0mv9N1MXYsR9s4yPufNmmlFSHj9xpaGefAIKci66YOm4gv3J4F+yE2eHTJHpa7VAxFSNEODlKQlbcHUzlT4qu4HtAoMF9xoBlV8UdyfSXoOzZvowsbtO9Iq+BgK9Nyng8dpj8dNv/sMwzu41AVCBumdZOAiMtG1WNkz2zDZCNXqMnCjPZ9I/ir1cAa3No57xQqjD+sKa6zpdg8ORnStaw4IgeDmI1dIXYV0Sp9W9zqtVqxFk8ii4S8iDrkNEhvBtHqlb6C7j+lvZ1nymg2ihAmEVqtlcnZbNINdrFda4GqtyU8vCzky+HJB5VS70o= 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:(396003)(136003)(346002)(366004)(39830400003)(376002)(107886003)(2906002)(66946007)(66476007)(66556008)(36756003)(38100700002)(6512007)(186003)(16526019)(4326008)(86362001)(8936002)(8676002)(83380400001)(6666004)(44832011)(30864003)(1076003)(6506007)(54906003)(110136005)(6486002)(478600001)(2616005)(316002)(52116002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Ju2irf8AFRb2uhK0mk3jKxCZSVp3BZryypo+c9tNvmnw0FF9Zn1CsTQi1FoJpeEKuDoQ8yGc6B7V+8zdua2LR33kxwi/ERFY8Lidva2XNw/tQxQpDIvwxl7IDRHvoAoewBgEz3NHQjzy+6G0OppVWOvbWwYx3LYWo6du8jp9cYGSP5g3QYDUZEs8HxmiavcrAfceEN4pDESHJb3fuHIgVp5QtcqC5IQ8rtYKxicJNhe3RxokbimwPfskmak919POY7V+vbmeahi7TirToYPVtpT27UP5veTmRnLR5qZeMKgRK7zY8jQWEWM++IHEjQffy4TJaXHQqcbNzK39f+McJqvt7tCeheyfnR8DjTe8J/yP3R+lAn296fnPZ1ncctEjEMcO8/J+q79omTK1anm5gr3O+lA5jKT41HaLC4ecI0mR3VMTZFulHxiuamHpbe9QiFnc8gJD/oTAwJvx72Uuidw7S8R7tb9jELaoc9RRUrFaNUBqw5JVgoni/s+S9igmhqPECPhuZBoPeN04kTdBvqtVrzHHmUQ+4+7vGcmS9f8xAMXUJ6JZqNiF7KkLfenavOABbgY1j5OI7A/DpAv4Phmd0tOTYXVCwv0NiqblpVdhvLosH809d7g6sClP74iwGJxl/h71MRS4xciXsxjaUqwXoo2gCjBhIS+FoD4DPkLP+fIMk1YWg2yimNBaCvD1OxtP5k35taPWALM4h1XRm/9IpUo/35Oarngr1zhV+K84FJ83ET9dG64Z7lkd9xCjuOq9ssD0S+XacXQNU6+rUcM8Q0DibJJ0QVwzEwjYf8O4ZcHENwZbIoCsKdZs8i3WADkcCOdPslxOcgWeoYCVwIVQUNyzetD2xGe0nodxaF74QPpJFxloTBQqdbcfdDgDFr0eSIE0g+mShHpXcHFckvJfVAHF1t7JMX/B6yEW61Kt9gIMANZj+YztdPpe7dv3ZiMJ5JqOKpU8YkK8ghX/LkGrzG2pEMklIWDTLhMz18nlYNqa+I00A7GWTRX6e5MHrWAB6yR9O79SAGAqQnIEmh1S7hzo65sDMAsfoTZ+KWvWRsBI/xq3IErSm8a5W4plII2kU6LiZGTVF0R5aPE6h27JY44etgxDB7WK/35Z+MyKQnxHugFEyF72KUfWF28hipf4a11ghLq99HEBOm+LQs/5cokEt9LHrBm+k/I9VaX6YcovUbjsAs7Zc9/L7fhCz+w9b01FZNzrOjKHa/aKUXx9McEsCupGsqGg/dxjhaItHXdybn0OrWHOYnLvU6yckGvDt+v/X+cDa01g8BU8bkLYzHvhUCPYr/Bxnkuhq/fUDmUozUtEexhn8eOVDQ2Cs0uuUGfA0N/NE2PWhlGqLjOmvxhwtsXkHYwd/U34HZQHJO3iH7jmUJuQPojgfC9j X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f237c61-13b1-470d-4328-08d92432201e X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:35.8123 (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: ytyTlT0ePy5dgUIYS4c6WdjZL5s198OAGIwTxWKVaCLJaGNAu2UAUhfOCa3ld+52tKktKT2dkE4Ft/T5+RQSGFQ2eFtgxM+zhAEMOSonEyc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4891 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens This commit starts adding the structures and lists that will be used in follow up commits to enable offloading of conntrack. Some stub functions are also introduced as placeholders by this commit. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 130 +++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 51 +++++++ .../ethernet/netronome/nfp/flower/metadata.c | 31 ++++- 3 files changed, 209 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 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..46437de4d75f 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -6,6 +6,8 @@ #include "main.h" +#define NFP_FL_CT_NO_TUN 0xff + extern const struct rhashtable_params nfp_zone_table_params; /** @@ -14,6 +16,12 @@ extern const struct rhashtable_params nfp_zone_table_params; * @hash_node: Used by the hashtable * @priv: Pointer to nfp_flower_priv data * @nft: Pointer to nf_flowtable for this zone + * + * @pre_ct_list: The pre_ct_list of nfp_fl_ct_flow_entry entries + * @pre_ct_count: Keep count of the number of pre_ct entries + * + * @post_ct_list: The post_ct_list of nfp_fl_ct_flow_entry entries + * @post_ct_count: Keep count of the number of post_ct entries */ struct nfp_fl_ct_zone_entry { u16 zone; @@ -21,6 +29,44 @@ struct nfp_fl_ct_zone_entry { struct nfp_flower_priv *priv; struct nf_flowtable *nft; + + struct list_head pre_ct_list; + unsigned int pre_ct_count; + + struct list_head post_ct_list; + unsigned int post_ct_count; +}; + +enum ct_entry_type { + CT_TYPE_PRE_CT, + CT_TYPE_NFT, + CT_TYPE_POST_CT, +}; + +/** + * struct nfp_fl_ct_flow_entry - Flow entry containing conntrack flow information + * @cookie: Flow cookie, same as original TC flow, used as key + * @list_node: Used by the list + * @chain_index: Chain index of the original flow + * @netdev: netdev structure. + * @type: Type of pre-entry from enum ct_entry_type + * @zt: Reference to the zone table this belongs to + * @children: List of tc_merge flows this flow forms part of + * @rule: Reference to the original TC flow rule + * @stats: Used to cache stats for updating + * @tun_offset: Used to indicate tunnel action offset in action list + */ +struct nfp_fl_ct_flow_entry { + unsigned long cookie; + struct list_head list_node; + u32 chain_index; + enum ct_entry_type type; + struct net_device *netdev; + struct nfp_fl_ct_zone_entry *zt; + struct list_head children; + struct flow_rule *rule; + struct flow_stats stats; + u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun }; bool is_pre_ct_flow(struct flow_cls_offload *flow); @@ -59,4 +105,9 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, struct flow_cls_offload *flow, struct netlink_ext_ack *extack); +/** + * nfp_fl_ct_clean_flow_entry() - Free a nfp_fl_ct_flow_entry + * @entry: Flow entry to cleanup + */ +void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 10d84ebf77bf..062e963a8838 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -583,11 +583,38 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, return -ENOMEM; } +static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) +{ + if (!zt) + return; + + if (!list_empty(&zt->pre_ct_list)) { + struct nfp_fl_ct_flow_entry *entry, *tmp; + + WARN_ONCE(1, "pre_ct_list not empty as expected, cleaning up\n"); + list_for_each_entry_safe(entry, tmp, &zt->pre_ct_list, + list_node) { + nfp_fl_ct_clean_flow_entry(entry); + } + } + + if (!list_empty(&zt->post_ct_list)) { + struct nfp_fl_ct_flow_entry *entry, *tmp; + + WARN_ONCE(1, "post_ct_list not empty as expected, cleaning up\n"); + list_for_each_entry_safe(entry, tmp, &zt->post_ct_list, + list_node) { + nfp_fl_ct_clean_flow_entry(entry); + } + } + kfree(zt); +} + static void nfp_free_zone_table_entry(void *ptr, void *arg) { struct nfp_fl_ct_zone_entry *zt = ptr; - kfree(zt); + nfp_zone_table_entry_destroy(zt); } void nfp_flower_metadata_cleanup(struct nfp_app *app) @@ -605,7 +632,7 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) nfp_check_rhashtable_empty, NULL); rhashtable_free_and_destroy(&priv->ct_zone_table, nfp_free_zone_table_entry, NULL); - kfree(priv->ct_zone_wc); + nfp_zone_table_entry_destroy(priv->ct_zone_wc); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Mon May 31 12:46:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 450738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4090C47082 for ; Mon, 31 May 2021 12:47:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6B3661279 for ; Mon, 31 May 2021 12:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231611AbhEaMtC (ORCPT ); Mon, 31 May 2021 08:49:02 -0400 Received: from mail-mw2nam12on2114.outbound.protection.outlook.com ([40.107.244.114]:7041 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231553AbhEaMsr (ORCPT ); Mon, 31 May 2021 08:48:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GNIZ7cpIfeUJbUug+9HlGdtDyhaIA7naDsbxBKXlWfk7wRmoiOMWLb4rS58zJP2Pyki9jOJIdEf10UhfV0u8CFqAfbgcnnee71ALWcjqVEJLQNlGN42NVWqOubdD5DbHfiQkLlYWgPQ3ySerOJ0W+6F+McPpCsAqha+tpGHRsChisAeB5FYqNhKtztJot7asmIQI5JuI/Ng+j5aTRtxUojpsnrQBO/ZxJzFoGJR07gSC3+kzNALoGsLDeJnqEWSBW6gdWZ9grzM3I6C1j/85dN6hkcu6VnTuBU+GZrrR6WFLodt4tvo70/+rbA3fftuVotz0KBKDr78ZuR4pqLOSdA== 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=h3KCxgKFRoH2eyZiK4IZLpnHxAxPfmhQVdPviTG3mrQ=; b=U6Tfk8Ql8Sfmdh6lZ9BbPCI76hEYUlalqQydriRDwTBlAqFWzfZPBTxkDefBifzJA7LO8Rp1Sb3gZXkG228DmRBsPPGR01LqUfSdfQXfu2QNI1ZAMgttmyxtWJrv4OviTw/FIR62LXcYQ16Cv8E1qg0MkMv3VtmOW8QX8HTYPFa4WPJRlIdp8nP/VNK6cG5+02NwTHPPpJQmK4UlkfmSeWi8VoFy5SqYLW9U/8p8FGwKsQg+da5EUIQ+D8nR+sNeHjHLLODAKHxCCm5F1eWI4uKgCHRI3aFL73tJ7Z5ZhnPw7ZKknIh07GKGRcU1diKGsWXvDpK6uegJ0NoFz9OFwA== 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=h3KCxgKFRoH2eyZiK4IZLpnHxAxPfmhQVdPviTG3mrQ=; b=ewPOX8yU8YSb2LfjKsSuHuu1mcCtSh8idlOjajzvS/yNtx1sD8fmcXZRADgZ445oLR2kKVvNguFtIYCK/qUZfFCTgF4yM3sIwwXkWh2B8Xoxm3ONSXTt08VWK76RduDUze1LW5hH+F3m+L7ghmVDBJeHXJTGvrDQqCedREWehrg= 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 PH0PR13MB4891.namprd13.prod.outlook.com (2603:10b6:510:96::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.12; Mon, 31 May 2021 12:46:37 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:37 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next v2 6/8] nfp: flower-ct: add a table to map flow cookies to ct flows Date: Mon, 31 May 2021 14:46:05 +0200 Message-Id: <20210531124607.29602-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2e15b93d-beb5-4163-12c5-08d92432212c X-MS-TrafficTypeDiagnostic: PH0PR13MB4891: 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: MGZAcWtZuOt4qWUI8Gt5CptfV8LO+fr49Wbvu9axxq03WxBHg79ah8pPRS3prpaMVlNn0T2jkiF8hLuxyQpR6DJv+DSY5jF2ijN78r6ajEvGPB6VhBI1DPBkBMLrOwssyfW4a/WPuBN2qMs3uup5PWbIRVojoMfTXjXfZJ/sQ/TDOBhz9Wu0cLueK3cMUgkgZRR30+Y0bQV+DuK1xQl5fTWKUoXN3/i7BjAI21Sx/wWs30UMDg/2GATiC+XyeVosieJ9FgolVFRIfsrdj43a8S+6nGoM9Iq345UANm5qIh/ZXVbpi8VBRv0kivcQBV21zJ+A+m9xm5Ny5X/KXa5m+NEMBwcCID5exG6MISe2ICpyg0vtYgpVBv+uvrj+U2aTtzxGyeX3lWRVUyH6qXJ74wwO60CcZRxHbiHodi3MVP1iwYmDcmj2o3T/B8WDK+kJ99NRdD+f+kO+ItmOyQ6OZHoOzGC4/0Ij6A5y/6KFJqr1paD4jhYX0h+/Hd92sJpKLVqEhTznKTf1xmPgwUWPvQvGKtvLlSdw8AxnxbBL+fBu2T0oitOZk2qHRmJiaZQeXu2/eLzIJc7i0+AgjZFqmQ7wAK6xmExyhCWdVmw0axk= 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:(396003)(136003)(346002)(366004)(39830400003)(376002)(107886003)(2906002)(66946007)(66476007)(66556008)(36756003)(38100700002)(6512007)(186003)(16526019)(4326008)(86362001)(8936002)(8676002)(83380400001)(6666004)(44832011)(1076003)(6506007)(54906003)(110136005)(6486002)(478600001)(2616005)(316002)(52116002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KLcnk3iVzIgbZFZwXkJT8Rl/R4eH5J0uChkKwHyFGnBCuJXxiUkFh3YJYWLXj83IYNi95KP2BDHox8L3ydorRezl8Duqmjjneq85XmK4hxwvTwIERxZKJsU5FxifRnu5J1pdFC1E58HEJ6KyCDcUPEi/xnnr8uQKd77S23sUWeRde8i/iZ0YVT+SXwORdm6NtRr1ei7bVJu+tN7TpBvmwgszGrcdd0oMY8/w6TdoeKNPRl4qdL/QIrRz3BS0hcLCqx2KPw0bnEQUbfuf6zD5pSjjS/4i3+OMzh8R7GtVyX7xn7TrfdxKZTy6hrK22QZJsvquS4BbUhcbFm1AoCbIvoNegM1UxcB0RwCUlMpupKlp7Y6FW/vz9s6NOCQbUwTTYAVKOe6yTgTbUYL45q3JZfzJF4RzAtW/h3ylHwCz7OU0pd0s24IlwfUG0HSNamo26TSVTwpw4SDWiQeLhxVlV6iax0DjZB8CXVoCTMjFzvddKuaFfL/Vi40IYKFKsznEA1GGhMqoVJcC9X3Svp6mAxKledWgQZ0XQsiCsUd0rEZjJCQOrYZmkTg7ag7VzoowplRAWUe56ixkqrpIUmH8ECvjdbPlmQVP2amxGQ445nxxA+0y/XxIM85eAijdzOdDL6quCO9oGJQgsXKSH0F3NDhv4U85IKWsErfR7MQZFyJGWmZNc/EjDENmItIy1fTc5cHgeURRkbhrHzfWYWI5ixX1NaTKTUK32UtRILyTV9KH6DrKR4bvIt52yx7ZUtuhKeaa8wQloFElGLsfXzp4pteLrcFYSAMRUHz+QO4c4p1UkkyVpfAyd91xCdwvO2dNLKnCshEHJy4Xk/073f75bAPQwHDVJgz5sBIl30T88TmzS/b3SBJj2bySDe7qIpghX6YztrLvsRiaLtQuAjvnvkG+1is2Qf4REgFWSo/5fqQ2aqlOUoOiAQ57r/XrXxODVNolRpIgkliUyX7JHw5iiNAtbrx2m8dSARyat8TrXxiwhCnYmmbkPfrbu9nmxjY7QtcNgB9mKR5qu2LvabrlRYWmnbbzmx8280fshimPk4EfK2oKa/ZN9k4rvB28wkTlqeS+N7sTRFQdlMB8P2lC+bWWQ0Dcx/fPo0tr/wxbXbA+9byGbjSmiqROoqJFxf8NK+cM25LFhGuLUZQHjJh3KpAu/0pnKY0ysgT04SPleywXsUzUiLUSwfvUO9ApEv0RfyNGGNmucQv49cjcRuoIvzO7J7dDFtH2/qrYWzBOJRrFJxwQqCtXjnNKRtzzPvqroS9Gg7J0zz+SErFfVF+8uhEUyyZm/55AzFuclWPD2maz2KV5gCh/o1/FzppWUiKVdKyXBFYZq8utRiqP4sVspBp1nZC6vB4khQgN2+hI++2ZCvxfWwodtSf93DjBB1N+ X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e15b93d-beb5-4163-12c5-08d92432212c X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:37.4481 (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: MHYottiAXX3/536EvFiAnk1PXGZQZC246rrvILsMP1UzZLuGlpnmZIbUKnSNTnc+c61LCOfMwuPAXjUKPEKksNv8ib94yZccOFLHk0GxteE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4891 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add a hashtable which contains entries to map flow cookies to ct flow entries. Currently the entries are added and not used, but follow-up patches will use this for stats updates and flow deletes. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 35 +++++++++++--- .../ethernet/netronome/nfp/flower/conntrack.h | 13 ++++++ .../net/ethernet/netronome/nfp/flower/main.h | 2 + .../ethernet/netronome/nfp/flower/metadata.c | 46 ++++++++++++++++++- 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 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 46437de4d75f..a7f0d7c76b72 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -9,6 +9,7 @@ #define NFP_FL_CT_NO_TUN 0xff extern const struct rhashtable_params nfp_zone_table_params; +extern const struct rhashtable_params nfp_ct_map_params; /** * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information @@ -69,6 +70,18 @@ struct nfp_fl_ct_flow_entry { u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun }; +/** + * struct nfp_fl_ct_map_entry - Map between flow cookie and specific ct_flow + * @cookie: Flow cookie, same as original TC flow, used as key + * @hash_node: Used by the hashtable + * @ct_entry: Pointer to corresponding ct_entry + */ +struct nfp_fl_ct_map_entry { + unsigned long cookie; + struct rhash_head hash_node; + struct nfp_fl_ct_flow_entry *ct_entry; +}; + bool is_pre_ct_flow(struct flow_cls_offload *flow); bool is_post_ct_flow(struct flow_cls_offload *flow); diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 060c6de36c02..0fbd682ccf72 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -195,6 +195,7 @@ struct nfp_fl_internal_ports { * @merge_table: Hash table to store merged flows * @ct_zone_table: Hash table used to store the different zones * @ct_zone_wc: Special zone entry for wildcarded zone matches + * @ct_map_table: Hash table used to referennce ct flows */ struct nfp_flower_priv { struct nfp_app *app; @@ -231,6 +232,7 @@ struct nfp_flower_priv { struct rhashtable merge_table; struct rhashtable ct_zone_table; struct nfp_fl_ct_zone_entry *ct_zone_wc; + struct rhashtable ct_map_table; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 062e963a8838..7654cf6a3222 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -504,6 +504,13 @@ const struct rhashtable_params nfp_zone_table_params = { .automatic_shrinking = false, }; +const struct rhashtable_params nfp_ct_map_params = { + .head_offset = offsetof(struct nfp_fl_ct_map_entry, hash_node), + .key_len = sizeof(unsigned long), + .key_offset = offsetof(struct nfp_fl_ct_map_entry, cookie), + .automatic_shrinking = true, +}; + int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, unsigned int host_num_mems) { @@ -528,6 +535,10 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, if (err) goto err_free_merge_table; + err = rhashtable_init(&priv->ct_map_table, &nfp_ct_map_params); + if (err) + goto err_free_ct_zone_table; + get_random_bytes(&priv->mask_id_seed, sizeof(priv->mask_id_seed)); /* Init ring buffer and unallocated mask_ids. */ @@ -535,7 +546,7 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kmalloc_array(NFP_FLOWER_MASK_ENTRY_RS, NFP_FLOWER_MASK_ELEMENT_RS, GFP_KERNEL); if (!priv->mask_ids.mask_id_free_list.buf) - goto err_free_ct_zone_table; + goto err_free_ct_map_table; priv->mask_ids.init_unallocated = NFP_FLOWER_MASK_ENTRY_RS - 1; @@ -572,6 +583,8 @@ int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count, kfree(priv->mask_ids.last_used); err_free_mask_id: kfree(priv->mask_ids.mask_id_free_list.buf); +err_free_ct_map_table: + rhashtable_destroy(&priv->ct_map_table); err_free_ct_zone_table: rhashtable_destroy(&priv->ct_zone_table); err_free_merge_table: @@ -589,22 +602,40 @@ static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) return; if (!list_empty(&zt->pre_ct_list)) { + struct rhashtable *m_table = &zt->priv->ct_map_table; struct nfp_fl_ct_flow_entry *entry, *tmp; + struct nfp_fl_ct_map_entry *map; WARN_ONCE(1, "pre_ct_list not empty as expected, cleaning up\n"); list_for_each_entry_safe(entry, tmp, &zt->pre_ct_list, list_node) { + map = rhashtable_lookup_fast(m_table, + &entry->cookie, + nfp_ct_map_params); + WARN_ON_ONCE(rhashtable_remove_fast(m_table, + &map->hash_node, + nfp_ct_map_params)); nfp_fl_ct_clean_flow_entry(entry); + kfree(map); } } if (!list_empty(&zt->post_ct_list)) { + struct rhashtable *m_table = &zt->priv->ct_map_table; struct nfp_fl_ct_flow_entry *entry, *tmp; + struct nfp_fl_ct_map_entry *map; WARN_ONCE(1, "post_ct_list not empty as expected, cleaning up\n"); list_for_each_entry_safe(entry, tmp, &zt->post_ct_list, list_node) { + map = rhashtable_lookup_fast(m_table, + &entry->cookie, + nfp_ct_map_params); + WARN_ON_ONCE(rhashtable_remove_fast(m_table, + &map->hash_node, + nfp_ct_map_params)); nfp_fl_ct_clean_flow_entry(entry); + kfree(map); } } kfree(zt); @@ -617,6 +648,16 @@ static void nfp_free_zone_table_entry(void *ptr, void *arg) nfp_zone_table_entry_destroy(zt); } +static void nfp_free_map_table_entry(void *ptr, void *arg) +{ + struct nfp_fl_ct_map_entry *map = ptr; + + if (!map) + return; + + kfree(map); +} + void nfp_flower_metadata_cleanup(struct nfp_app *app) { struct nfp_flower_priv *priv = app->priv; @@ -633,6 +674,9 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app) rhashtable_free_and_destroy(&priv->ct_zone_table, nfp_free_zone_table_entry, NULL); nfp_zone_table_entry_destroy(priv->ct_zone_wc); + + rhashtable_free_and_destroy(&priv->ct_map_table, + nfp_free_map_table_entry, NULL); kvfree(priv->stats); kfree(priv->mask_ids.mask_id_free_list.buf); kfree(priv->mask_ids.last_used); From patchwork Mon May 31 12:46:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 451871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FDD8C47082 for ; Mon, 31 May 2021 12:47:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34DAD61279 for ; Mon, 31 May 2021 12:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbhEaMtX (ORCPT ); Mon, 31 May 2021 08:49:23 -0400 Received: from mail-mw2nam12on2114.outbound.protection.outlook.com ([40.107.244.114]:7041 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231330AbhEaMs7 (ORCPT ); Mon, 31 May 2021 08:48:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VG+M4IoDO8U/UjGYUtwBHASO79yuxNIKfc8N/bFjkOtyEZIjrjKON6gMBGYD+/JTOZLMM4a6Un2QcYiasakTsFQJwooUzMNYN+QMDYCoPkfhOf70zaKcjmN5M/yLsKb5CFEHYQ9+xb4i5goBQe7+r8NjwOltXx2v1+dcgzhbKcHsG2wh4NbHu2SYc9ek0IuX1/awLJrUA7gEIfKnEycIokPtfvO2S7sNMc47V9F/hJA0bWooZmMnqi6+V6tm1RMB7WfHaHWzOBtduO2ySHZGE3Y3uo0hWNZ3rT4A3KqwJR1hYW4ef8COyMHWs5UPSQBfCkQbQPRE0D7JOy5y0aOf+w== 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=C/OWCfzrp9WqyFMaOsMALjX2xrvoFzr3Izx3R3szes8=; b=HI+a3B996WTqdGT1K9olv1izyJWTsp/Dc4ntrVV/zzHrx7PQKc6NZGd9gg58XIk+7mcx0/C+xOWBrIe1nJu3412GAxNBwnxixzEbtlfl/fYqtNr4ysNw+K+XFUv0kZWpvT9rPKFBQ3OsAaUNGh9XUEeH1Kb0uJgyBGOM1+AeyqksksSnJw7KdkD082Zo7Uv3gy9AHBlk0XXNQGRntZuptNL8VRbfZIpqJkOzk0NgRYoJARfGVAv9SngoTJPgdT9Zvdq6/8VyphsJbDfSwUIicLes+7xB3P5EKZROJJIJRriP2Bua/NlzkDoXKECoq/D9FDZ0J76pN1QblJq9YxESIw== 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=C/OWCfzrp9WqyFMaOsMALjX2xrvoFzr3Izx3R3szes8=; b=uYX18+cWrny64BVA2JQdY/ffbgCVwq0LLOKKMrtAlDJybtNy1roNo8azJ6ZTME6sB1rHewVhlYYm0Mqs1fArjuFP8XD3+RRuWezoMIKIWK1ThrVs4j6aspK/bnMWeCG4CrTtD2heZRC+HY4veP/kKF4Y/0Q3yCVj7H+HC0O14vc= 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 PH0PR13MB4891.namprd13.prod.outlook.com (2603:10b6:510:96::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.12; Mon, 31 May 2021 12:46:39 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:39 +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 v2 7/8] nfp: flower-ct: add tc_merge_tb Date: Mon, 31 May 2021 14:46:06 +0200 Message-Id: <20210531124607.29602-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81a8454a-3e3c-4aee-9716-08d924322226 X-MS-TrafficTypeDiagnostic: PH0PR13MB4891: 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: 6y4TD1FFy9lkl904V7lFNZSQyKXLhnq9nvwH97ml6VvO6zCtBpUjZF4LPNfGO39SIuVwP5jw1BCDlM17TCCmNSXh+cLKJjQjBRqLDhD+YAyLpP2FrzlQQA2cbdzLPczhJmtn/IFK9SCJR62MIFHlyXPq3e9kSkdS01gjVFnf5ec/tWah7Z8seNu/cO6hd7rvx3Z4id97RkXdNO8oMlqpDYfJjgr69zifstw8QH8VgTBhy9WQEcu94z0qPueadANQJlemGBEsVaX4p0TfvSMe+vUZS8HxGuMZaGAejresKaSobZYBFRkbLgEJ5rMLLlpl1GPPIpOcRkmolkGA638xLKac553JD5BHLOkx100dXyO+p7pSUZlpkFuCloVZJ01k2Ecf5uYZHmvj0vghlE7ihJtVrpkucyxRCeyUn4Ia2u9GdMDj0iCqSWH0j/pTee+7rSO0+VtIHPrH74QGvPXMgPnbxqjl1Pcu2Bqk7IMzK0Hyragq9dqC/tLUsCl1OY7IK5Y2ozSiIZA3lWO8HO8fTcdVb46p2w0BPJZFU+1ZM+YAcDUbH6cWM8qYwL+QxvLJfsAYpVzw8FUy5BjMDy8Y9XlQgNkl5AutmRxkbT/+tZk= 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:(396003)(136003)(346002)(366004)(39830400003)(376002)(107886003)(2906002)(66946007)(66476007)(66556008)(36756003)(38100700002)(6512007)(186003)(16526019)(4326008)(86362001)(8936002)(8676002)(6666004)(44832011)(1076003)(6506007)(54906003)(110136005)(6486002)(478600001)(2616005)(316002)(52116002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +Jm4VXuGySmpWxm42b/2jW/M0peiX5mEUxvxFD2JBP53h0utJUCMO44CDx2QwkPdC9tpGiiAJgRispO/vJPV6r14oBQFhPnCC7zy1u8cJ/5TfcXYblnSZ+syxh8RRutlV8SiD1vW1UxCeCgtvjozs5Chz6yui2hGm4dc1ZWx+w3/pA79dMMKdMolNir+4PFfZNpy8iqMZUUP+IwmJzinQc7m/QISGzDBx+ZBDcHwbbFtQxa+77uw1Z+HvX8RU2mu/JYQLzG36oatFW5AfXJ8PcgAP0e0r72bjGGZ8DYerh89+MqW5PjK8eIjlaTEc+m3miy1zBmsSm8/9g3SSZG8pdG4GLxa/MUgIphPr1AEwL14Fyorfoj329FP/8gskW3xpdZGhvRksquXEeGaHvEXVWxXnvPvtQTPABAh1uVHvDz7gblrT4DjKzh3BCCrnVdDiyrtBi1vHzNQ0tHjpRAbHfLJp+SHc7jYvP/2wVmu1VT/VFCTtpwPe5RSrzNcbmxeJ2tlYdLCL6MGj+QjWVtmH0DEwApKBFoa35hDVySl5/mCdbBNKnVX7pCIwEXXztRwZbfikFchqjvsQR07RiepsUjt841fVIfZsMXH8J6esTV2Haelb6A3KQMXXxLbvJIZYZtiTMXSl50S/uoczXQbBNXv5COV9vR5JZw8B1F+E7wRJx8tIZK5zdApCd/lYj+XSpSW1US+phevU8wIHI8dTepGaAM4cSe9fMUuN4Rtl5VpP0MISjOWkGdNqxH5yf5Q2EV00Cu3iT3E1e62oCSJBLXC/ZWx5fkrU2CJXE1xtUeyZTJwXicFERc680PX+j4Tu/9/FCMSBXZB0w1V2CdNGYOAGqdMETo/DJqDfsoxG/jV0lIDDj+9o5bJf7vTXQyiUP1CGHkNiGHa9PvoRNicOc6BIoYFUS1Zrv7yLrWHq5RZA0x9kYaZimVmkAn/1AKPe859hciR6X0Eo0LD86mksP8qgsXTYT+Au5NGJDv8AT9yrAfqHEOB2ZmbnRYuG+oxVgRb45JLF/s5/5fnOnbathXbQcXb8vSBEoFCRia1WVZC+tmR9a8mtoka2fRRraExFMnjTPO53ypszxo+vwPXhGnzZ/6QQQ4XfOAnUNqdG/4PbfIFyRqt4mmO6uaSf7hwT7LUv9CoyfqHRvTbqW564OZparICk8pxZWw7lDWFb2MJ0s2MVJ1fwy2jd2OjR4wQ5qK86yXePpRNwKzAaZhpeWM6VIbBFS/mlLKqEf9qkFklAHJmvj685zirmDUSz8dkY92a0vaFgvxv97ASWTeusnob1/PwHyBJOQ1Ak6U8GZb1CFUU3bTtw1oFJenNrE2bDnmZzG8FZYsmZK4+Pa8NiA5lZJSjRgJDMqqmht+DZSXI3GEuY44bbn+0IOFnOPIC X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81a8454a-3e3c-4aee-9716-08d924322226 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:39.0620 (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: dvUHsU1Gz8V0iA/G5sfq8gEu5GmQ7r40gybWw4oY2A5Rgoe3+0rS6nnh2CRiAXEqvxUYiFfeWIOgnYnyFGyAYp4pd82GF8yNiodBVeUyeJA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4891 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add the table required to store the merge result of pre_ct and post_ct flows. This is just the initial setup and teardown of the table, the implementation will be in follow-up patches. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 14 +++++++++ .../ethernet/netronome/nfp/flower/conntrack.h | 29 +++++++++++++++++++ .../ethernet/netronome/nfp/flower/metadata.c | 4 +++ 3 files changed, 47 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 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 a7f0d7c76b72..3d7d260c6e5c 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -10,6 +10,7 @@ extern const struct rhashtable_params nfp_zone_table_params; extern const struct rhashtable_params nfp_ct_map_params; +extern const struct rhashtable_params nfp_tc_ct_merge_params; /** * struct nfp_fl_ct_zone_entry - Zone entry containing conntrack flow information @@ -23,6 +24,9 @@ extern const struct rhashtable_params nfp_ct_map_params; * * @post_ct_list: The post_ct_list of nfp_fl_ct_flow_entry entries * @post_ct_count: Keep count of the number of post_ct entries + * + * @tc_merge_tb: The table of merged tc flows + * @tc_merge_count: Keep count of the number of merged tc entries */ struct nfp_fl_ct_zone_entry { u16 zone; @@ -36,6 +40,9 @@ struct nfp_fl_ct_zone_entry { struct list_head post_ct_list; unsigned int post_ct_count; + + struct rhashtable tc_merge_tb; + unsigned int tc_merge_count; }; enum ct_entry_type { @@ -70,6 +77,28 @@ struct nfp_fl_ct_flow_entry { u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun }; +/** + * struct nfp_fl_ct_tc_merge - Merge of two flows from tc + * @cookie: Flow cookie, combination of pre and post ct cookies + * @hash_node: Used by the hashtable + * @pre_ct_list: This entry is part of a pre_ct_list + * @post_ct_list: This entry is part of a post_ct_list + * @zt: Reference to the zone table this belongs to + * @pre_ct_parent: The pre_ct_parent + * @post_ct_parent: The post_ct_parent + * @children: List of nft merged entries + */ +struct nfp_fl_ct_tc_merge { + unsigned long cookie[2]; + struct rhash_head hash_node; + struct list_head pre_ct_list; + struct list_head post_ct_list; + struct nfp_fl_ct_zone_entry *zt; + struct nfp_fl_ct_flow_entry *pre_ct_parent; + struct nfp_fl_ct_flow_entry *post_ct_parent; + struct list_head children; +}; + /** * struct nfp_fl_ct_map_entry - Map between flow cookie and specific ct_flow * @cookie: Flow cookie, same as original TC flow, used as key diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 7654cf6a3222..8658c5cedf91 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -638,6 +638,10 @@ static void nfp_zone_table_entry_destroy(struct nfp_fl_ct_zone_entry *zt) kfree(map); } } + + rhashtable_free_and_destroy(&zt->tc_merge_tb, + nfp_check_rhashtable_empty, NULL); + kfree(zt); } From patchwork Mon May 31 12:46:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 450737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5199C47082 for ; Mon, 31 May 2021 12:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C0086128A for ; Mon, 31 May 2021 12:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231633AbhEaMt1 (ORCPT ); Mon, 31 May 2021 08:49:27 -0400 Received: from mail-mw2nam12on2114.outbound.protection.outlook.com ([40.107.244.114]:7041 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231643AbhEaMtH (ORCPT ); Mon, 31 May 2021 08:49:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BA1y3+x2LpPXT/ecYoqQn2z0FMPQa8OTe3CFmREXg1Db7/WyHUmOmgn2bhPR7xNuVvulVihUAZ7UKCOKvkhG7Xhd5zIFpdUrh3T+urMXHGWmNkDzbhdh2Afka78dlZMSKE+C8Bb1rClIN5+tHrszyJoJt/5ouzDu6cpTCRCRV68jjNcBpnxMVif+DT+ebr1PyJC04YYU2wT68rCx15qt76Z+hjfZO7mnOp0B/eu4oSjcx1J2vwxhgzceKDrqcDw28bgHCgKmp8F50WvKz0zPB7ZHTZXe7ayHKeN+sZgUGfilVFqDorlA+Fw1qqc0cf5Qle+8etbsN6MaZQOsoKJJpg== 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=EqcKeD/lEfO1KBSWVtcVdcl+oJg82OAiE7luNIOR5zY57OJVQSD1jJafZD01Jn6UDU2kkb7ib7nZb9K9/okf6AnYUxw3xIMHIqQQHF3omG5FPZ9R2+ZHXzIIT4v2nOG1/1Mb0lsiMmL+6IBmi/sjqkJkylNDUxZxsftEtPqVWKbO3bdo3m9FkOxRaotFjGXf/XTDvrzFx1aAkO9Gbx3Tl7XIpfVnpHUmboFy/CppeKGeCZmCjPUWBhfnuuxapndn0dfu7wEhaH3uOVpxGQuFxgHEYdZMTdEgUPXdZIX+MLBoBwbElwuFdF8jDOtHztA7ahOkYceGQFpMFiM8A9srFg== 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=YH0RS7ejesMXAYGZ58m8N+90nawJFRNRuUtCMi4lxnXfR6GvdK+itLbhj0zZUR8/HXES/pdFI+MM8KWJr5sMu2mLGBH9iCguLZzeZlhXIx0SubQFSWNzg9WTjN/wzG+aspcW8cyqVbtdQUZrxZjfEyeS/0lNNudMojADnxDWLZM= 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 PH0PR13MB4891.namprd13.prod.outlook.com (2603:10b6:510:96::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.12; Mon, 31 May 2021 12:46:40 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::4596:4181:eeee:7a8a%9]) with mapi id 15.20.4195.016; Mon, 31 May 2021 12:46:40 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Louis Peens , Yinjun Zhang , Simon Horman Subject: [PATCH net-next v2 8/8] nfp: flower-ct: add tc merge functionality Date: Mon, 31 May 2021 14:46:07 +0200 Message-Id: <20210531124607.29602-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210531124607.29602-1-simon.horman@corigine.com> References: <20210531124607.29602-1-simon.horman@corigine.com> X-Originating-IP: [2001:982:7ed1:403:9eeb:e8ff:fe0d:5b6a] X-ClientProxiedBy: AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) 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 AM4PR05CA0029.eurprd05.prod.outlook.com (2603:10a6:205::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 12:46:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fde533a8-bf69-4d33-a6c2-08d924322320 X-MS-TrafficTypeDiagnostic: PH0PR13MB4891: 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: kBtUszoqQXxJFgXhjQQ7g7mwD7bNXz5gp8PgH0zd6Hz/rcQtn7n1maO7ytQfOIRs9fPrle+PHHlSmq0gvye2BHbwPAZfmqWfurOrXB7bfopXKZm2ndyKAz0bAKUZC+zierYWe3NrwYPpO2iBM19H+NZIGGkFFmiYdJv5CFWSsX5LpuT+M+QwWByQvLXKNLXA2aHzfBKDYwZKqaSmh6UIvcRoTtomdMAhVWXb2v7SEBXQjhi5Uk7fx+UUxWmzlRae7ZNGtvqTEeTLXNfn6zxgIL/TLj7lNU3KUVZRMsW7lEzSg7LUNNnZ1jahUqDDQ5jhxaU1z6x/8gzOL/92MqoyT2kAkrRLbiZfFxrBxfkfBLSUoj6NneISncRM1ue8QAtwq1iZqXydKpp0uc/rUqLw2ZQP/vQi8dhlx6J9VP4+arc1juF2KqvFHXdXOh/w25bCDQCEmvE1uAwAuTvy8z3OAvpObTNFa0Dsvp7K+nkNTko0D4wjYqQSyBwTbXwOJ60zeSb6Ll6QIioXZoox6cPTNRXjT5JRl9NXnsfyP0mUh4cx4VdB3Ow47Dzi98EddNSaKlngH9Ksrk9jypJuvTs4MDjS+KqbvCibYsuKA49yQRE= 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:(396003)(136003)(346002)(366004)(39830400003)(376002)(107886003)(2906002)(66946007)(66476007)(66556008)(36756003)(38100700002)(6512007)(186003)(16526019)(4326008)(86362001)(8936002)(8676002)(83380400001)(6666004)(44832011)(1076003)(6506007)(54906003)(110136005)(6486002)(478600001)(2616005)(316002)(52116002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: sAPlhHS1NykJbBRh0WaCBsx7e1MXU7/RGtScH4rx16s/irzBn5wCV7sD7pTe9bxCVqx7HfpvavgZw/AutdeUqq2j+1VbKXGAF3qyyyQO/FAELY9WjEr3iguHtnMuQOYPAEm/zgH0XtfZhtIrMsuzaw3LyS4C/p1TboC4tX8Zg2v6BMYuyxaFKJfyRM73Pz0WhRiYRlrj+UunphJzVZHwjuW/HKp+GHQdZYbPsKH/1F+iwUMYxkL0Hu6lm2ubCPZKLZf3WrJTHaJK1vnLejZvkTlNSPNlO7NNd4HtCz9aaImM8RWlKBdlK7K1mVELEyJbpoOh5pBsGSfx+KdOaa3HxrHmSS0MgclDSt2hvLAJVYjjjwLsjBil4SNCXo2ERinhHZGoS8PU0/AqM3m+wampRhP52RJYndP8Iq1qMXQMFo0WBfg2jU5mbN2HCX9oJqVNxT6Fl3B80g0fPsnZ9Pb2qplMpAI+/pIbrlVWLQYuDSczfYPb6KIz2W9AM0MZNzmfEjwdTV/M3KeIzda1yBWGclIXmHY+t/V4eOURxQy5gpzlZQW02RPjhze+1W7NyF/6KHLnH9t2qZL91uzEAPz3G5NCIVi3iTyOC0n7AMDZeFXQIKyNY5xO7CrMHj8nCxmNM7sM3RPBMbr2YruaPJaY4eDqCp+AMYWMaV0gu5mA2/54FU1b3MwGFlBpzA0CjJJQN2bd3VSfU6N9Z7cyXwS8ckVCQDskiZfUVxr0DiVs6HjnxbulfFyTG1Cp00+i70kGwr6Fou0ozB/gPjtMUt7EV5k4R0u+YbKZXHL7CzG2fgj59uNhsnAC9GuBQbyGwwGR6VxTDlyeQyj+l0MbBZ6rbRIs4LiEZRlXfvvdyPC84auflEFHqGTRlg0lBoN1oPn3X/CAcnHiDGBljsxQmxt7tIDVA1YBsEhQ/yhbZuO9men1nY1NrDdZfJ6PDAmjlMuZQjypqeFzv7HmrOqrKn8An4JA55ae8/wNFSPSxK4yIG0wniBsdTvvz9HO68l9Eci9TlbPiulXRXnFXkgFzC+BydiXrR1Wpb8VJM5gbNHKYmMeBPgmwOoUFys4HyluDTSN352lREVFfEjhpUP/mdxmP+Zs0BjcLEsIp4fxCtl0OXmajw/vET76K9Estf09p7tHu9I2FrhttnXEoQODCA7+Oi5rVxj8EBc0HJWuGtFFhNEQvymkl8T1mhqufkjvk6eGfLiWc0myu45ipXsgUFQe/+Uy6BBgzxhea0x/mtClVw7vUeYE+rswDjJojV0q0c+QWDBNnBwMvYvaoRVj58JtkLqMxcOe1ulOfAd1Mzf6YZfLR+7ML6p+7ZC8n46wP4c1Bx7m9OO969ai4Jf4gghfF+06gy+jttw44u+N9XI+3Y6aS+FNBwJg7XrcXS9JHAWP X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: fde533a8-bf69-4d33-a6c2-08d924322320 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 12:46:40.7167 (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: tuotwyXYWCaOs54n4RKOHO9Z+QH+/lsIeaAi3q9uLdZyIK4aU/k5Ytz7rFGMJ8v84i0awvq1MEyOtoqRLgzY4ScKV6Y88KuOP07qyeSu7nc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4891 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add merging of pre/post_ct flow rules into the tc_merge table. Pre_ct flows needs to be merge with post_ct flows and vice versa. This needs to be done for all flows in the same zone table, as well as with the wc_zone_table, which is for flows masking out ct_zone info. Cleanup is happening when all the tables are cleared up and prints a warning traceback as this is not expected in the final version. At this point we are not actually returning success for the offload, so we do not get any delete requests for flows, so we can't delete them that way yet. This means that cleanup happens in what would usually be an exception path. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 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; }