From patchwork Wed Sep 14 16:06:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12976337 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B95ECAAD3 for ; Wed, 14 Sep 2022 16:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbiINQJH (ORCPT ); Wed, 14 Sep 2022 12:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbiINQJG (ORCPT ); Wed, 14 Sep 2022 12:09:06 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2127.outbound.protection.outlook.com [40.107.94.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3A8173309 for ; Wed, 14 Sep 2022 09:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SZW9T+bIh1Sn0RdtnVeQHQg5rK9KIhuRWGeGo8DANsm+dGOSrCaKZC0vN2jUF2Spsm2+G7yrau4bE2QhZZ60VlSRBRw5eAAjq3Cu95iI/nSnirT7s7I7i95q/GoxX+PtTaiZ85o6WQZHl6J1jEmi1kcXqJf3teLs3u0k9ZgFIiX53TdaAMvTwGmRK2jCLnKUWVKd7aXTjBk/F50R18goyhNlkFGLycwWO/JwiRvp7VGepNF7ukbDClX95adQ5PVyGa3p/1iyu52V5J3WUhgENE9KRWC4WUw7U/K7IexzlOGMeLBS738JqyUSb1rGJYZQsR6UZ0/varoLEoKylPi+Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uhAhpQubq5qNBrVm4I0jAcrGfDPmHtuGUD2lNxE5KTE=; b=XNkBnrI/eQ8lGIpmnEvVNZygkl3g8e0YZo1ZV7KAGGhu0IQdksMtlGBmrbBHvaka9TjFn12Egl0wzm23xL5S8FZH2haTKS0GHmdWBK3W2ahXILYpgdUpaphflxrljxgBFeGmh6NxtFQQEGHDS2euyqUpgv9JfWVReqr32Y+fmqtnS5ut96I6P68T3IL2dnXjaDuHvZMU3AY4hsN1R6mSxkLqyMsOxC6BoiWp/g94Yh15O73GfMMdhMymiK1uRwGXwaG3zANDMPX/Y5QP/pHjH417VpWggO2ccmvSafXu/J9XfuJvmnJ1Y+vsxR0pcxV8rloZeWny0bj9u51kk9987g== 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=uhAhpQubq5qNBrVm4I0jAcrGfDPmHtuGUD2lNxE5KTE=; b=lX5r87Pda8g0X2WWmk5GrTBsPFhyWRrnL6cRweP+AYAb/qSkr8DOLrKdDIhATMqv0T7gPjxbdNds7e2U+qMfIJZmv/JOxRsbkBG64WVwYhZgy/MKiDGsZHo/tRqKelUEPZSRtXnkY4HKXRzbuhzlMLCelwottxQgJn5Pomp5uTw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by MW5PR13MB5462.namprd13.prod.outlook.com (2603:10b6:303:195::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12; Wed, 14 Sep 2022 16:09:02 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54%4]) with mapi id 15.20.5632.012; Wed, 14 Sep 2022 16:09:01 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Hui Zhou , Ziyang Chen Subject: [PATCH net-next 1/3] nfp: flower: add validation of for police actions which are independent of flows Date: Wed, 14 Sep 2022 17:06:02 +0100 Message-Id: <20220914160604.1740282-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220914160604.1740282-1-simon.horman@corigine.com> References: <20220914160604.1740282-1-simon.horman@corigine.com> X-ClientProxiedBy: LO4P123CA0368.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|MW5PR13MB5462:EE_ X-MS-Office365-Filtering-Correlation-Id: e47006aa-fae2-4d9c-12e8-08da966b7057 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FaLOQ271YSkayFjRxsciDWoV0KosoVNkPw7cU7Amdyerx1Ex6t2iEoPu7luASg0rTQlSqkbx1uhWHQ80jbJfjpU03oTyNpoJBm4t5CAzv/RsHGAsaNzRfELhCG+voR8sqPCLGsz/DjtEsNZWiDg4T2tGRqt+8s6r7I7+epUG6XPPzmdyQzK0s3wzUNW1Oz8t7DRDbUulN+bneCGbFqNd4qa/O7m43dnhiVsqzF0WTtN9n5U9GJC5ULZ4VepKsoVUZ4tmScwYmHi31WfM+1e9EpTkBL1q6H54LAfG7lTn84whEAVSlI5EEiwEJBg527nv4ghlDSJgYtrUNSuG6RhyKXm5MVHu3qhqvElf4WBl7KZcykxHEJU/Duj9IaonuhSjYba3TryZwLLQzYvRcBLv8axUPSN1Sb68rkNyNggESGDdBwyxv8tBgsbz2hQCQHrq1DkCAwH61M5N5tlrs6jkueE/fniNzdTBh1CaJco6zJ0A+YFufbpWBQsfUt/46Zqshv6Gs+QNkCqzYiLxGBxv2wzhCf/ABD0ZaOPyR9uny/FSz8tk+pvccPh1NU68TbVcCjc0FUpkPwiNQlIm9f7VEl4LmTvvxyllMqRzHWnxBSbtROOT6ytogh1S4bl8gpZi46driRw+jh6wFjs+mr6GFZNxKGA9rzvR55ZKvaezzN+9VrJPOvzDQ3pIGKKfWrTL75R0GYGqrOFt935ds41jiX3QOSGJV9MPCqG/4saTgXo3yqZkhyQ3oYqr9SVjwBWuYPVVYes74f29+TjD2SQsoQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(39840400004)(366004)(396003)(346002)(451199015)(6512007)(41300700001)(478600001)(83380400001)(38350700002)(316002)(6486002)(54906003)(36756003)(110136005)(2906002)(38100700002)(107886003)(52116002)(26005)(6506007)(86362001)(2616005)(1076003)(186003)(44832011)(8676002)(4326008)(8936002)(66556008)(66476007)(66946007)(5660300002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: krZbfmkRFeaEjcJKy2lGFv0fpw7JCdKnCsPbAZmWbav0nQQ3Ss5PTVYo3AJvCfGfGXXk0BqLkxnsEw5JOEDl8Hn7Vkwb1RfXSaWnj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RAeSzkPPzsjS8hmpRvU+ll8ktvQZEoHjxHHx0NSu+3NOHa8EKkfRvgaVYv+qoP/Y+iPZO12EqjQRSBAGbT3rvztIvCdKC2CKFaC89PgBbeNnzT5mW0qubmm7yEYxcchddRVqwr7iH4wk1OA9o0xqwb0s8NLXJDuikz+3DDW0vyj8v6OSXmHR852tThlwHlVj4NqfSALM8Z6mZR2AJB5QAjftuU9RTp5SF8Ypl6B6HwUhLX0xSX+CCWoWq5EVAbA4TmhSTI7Bv5sYsQYwugJzncOLESMjvAHJb6L8GzFXOA5jr4oveWoGRyNhRE0hhsIV6YglvFMg/Gc/MMcvhaa3ygEwu4fP0pkPrR8wxVf+DJi1n/PZrDtza81edTysRu+D28UYU67dx+js3cQJZDPW7Q8qgK+wpr+FvBGHw9T40rA+3EK/3ESLaI/zmE2UkeS0I3A== X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ziyang Chen Validation of police actions was added to offload drivers in commit d97b4b105ce7 ("flow_offload: reject offload for all drivers with invalid police parameters") This patch extends that validation in the nfp driver to include police actions which are created independently of flows. Signed-off-by: Ziyang Chen Reviewed-by: Baowen Zheng Reviewed-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/qos_conf.c | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c index 7b92026e1a6f..99052a925d9e 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c @@ -119,7 +119,8 @@ int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, static int nfp_policer_validate(const struct flow_action *action, const struct flow_action_entry *act, - struct netlink_ext_ack *extack) + struct netlink_ext_ack *extack, + bool ingress) { if (act->police.exceed.act_id != FLOW_ACTION_DROP) { NL_SET_ERR_MSG_MOD(extack, @@ -127,12 +128,20 @@ static int nfp_policer_validate(const struct flow_action *action, return -EOPNOTSUPP; } - if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE && - act->police.notexceed.act_id != FLOW_ACTION_PIPE && - act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { - NL_SET_ERR_MSG_MOD(extack, - "Offload not supported when conform action is not continue, pipe or ok"); - return -EOPNOTSUPP; + if (ingress) { + if (act->police.notexceed.act_id != FLOW_ACTION_CONTINUE && + act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { + NL_SET_ERR_MSG_MOD(extack, + "Offload not supported when conform action is not continue or ok"); + return -EOPNOTSUPP; + } + } else { + if (act->police.notexceed.act_id != FLOW_ACTION_PIPE && + act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { + NL_SET_ERR_MSG_MOD(extack, + "Offload not supported when conform action is not pipe or ok"); + return -EOPNOTSUPP; + } } if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT && @@ -218,7 +227,7 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev, return -EOPNOTSUPP; } - err = nfp_policer_validate(&flow->rule->action, action, extack); + err = nfp_policer_validate(&flow->rule->action, action, extack, true); if (err) return err; @@ -687,6 +696,7 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, bool pps_support, pps; bool add = false; u64 rate; + int err; pps_support = !!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_PPS); @@ -698,6 +708,11 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, "unsupported offload: qos rate limit offload requires police action"); continue; } + + err = nfp_policer_validate(&fl_act->action, action, extack, false); + if (err) + return err; + if (action->police.rate_bytes_ps > 0) { rate = action->police.rate_bytes_ps; burst = action->police.burst; From patchwork Wed Sep 14 16:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12976338 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51E33ECAAD3 for ; Wed, 14 Sep 2022 16:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbiINQJJ (ORCPT ); Wed, 14 Sep 2022 12:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiINQJH (ORCPT ); Wed, 14 Sep 2022 12:09:07 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2103.outbound.protection.outlook.com [40.107.94.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554C2606B5 for ; Wed, 14 Sep 2022 09:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mSCDHsfpzb6rEMva+oQJ0F9zMmkH9+mRo0yh0NgQ5GnSnezk9fyss3LLBoES5cjpZrIAd02MJDV/gRNajuWpQJUH7R/BdS1q7KIbtjFHrriKBku3YoryhEWcmi+hDFzTR8/HickC5woqRbhdfSL9AkopnddCIfxpzUwA1pCyOZE6i3g9f5LICQu5jVMLTCs78eJ05lqBzYZhY/PzJGgcOEl0zN6ctH6a25dkmKKNST1BrBFEOepLo1cMvQ9+cQUUq4l4Cmklb6idbLVKAK4f2ca9PITEs0nfkCG6HPx6cEa98ae7hodrR3omhtXY8Dfo6D5e3Ku0rwM+kVLqkCcYQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AeEtkosdSH5Lk021RNG34qZbv2k4mDua3V0B893iEjo=; b=VF5LjrCM17tIhfY4YgcFM/jHwjZS//FqQjy/mnE1y0P06/EjzkdiP6cATenIU1NalBBNGSWfVlvTGKqBtLmh+6I2klA6a4UZKjR9Fy4uPA7BAEqsFAZwADFXNhB8zP1HvQ4ygMeaID2Hk0ggaoCgC63TsQHF+zpkaDD/zTaaoJYXTHcXHw96LQ5/8WykWxN1Ma4eojdXnzZNYhDZa7bo0jThu191q8IMzuKa+AcXJnxEwORys9+3kvH1TdWFDZ//pMuVeHP14zzBdXHEfclhU7Gf5OyxWwNlS8hJorGrYyPP2kOsW4Q245ceXTdKIkJ08mi2DHQWQ6nRA5cFKkmK4A== 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=AeEtkosdSH5Lk021RNG34qZbv2k4mDua3V0B893iEjo=; b=g11wRziRoNG8d/TZzO+ALZSkstlyao/ckTPTfbxZ+gdBeDxJsCU2ZjvTjsl43/5sxD0FDFkW6yBefSlLDj2gV/rU0k5gsAXKcywWqjDnCsoIZfQCEa0uhk9SYrBRlNnXXjcZsQ0dgeVdcPpGMH5AttliXOjfBhylfklmpz0OO/o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4796.namprd13.prod.outlook.com (2603:10b6:510:99::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12; Wed, 14 Sep 2022 16:09:04 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54%4]) with mapi id 15.20.5632.012; Wed, 14 Sep 2022 16:09:04 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Hui Zhou , Ziyang Chen Subject: [PATCH net-next 2/3] nfp: flower: support hw offload for ct nat action Date: Wed, 14 Sep 2022 17:06:03 +0100 Message-Id: <20220914160604.1740282-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220914160604.1740282-1-simon.horman@corigine.com> References: <20220914160604.1740282-1-simon.horman@corigine.com> X-ClientProxiedBy: LO4P123CA0368.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|PH0PR13MB4796:EE_ X-MS-Office365-Filtering-Correlation-Id: 3653d310-8bf3-45dd-523a-08da966b7194 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vzYU0069fCdiy3acjKOpwYqcxfO8KRV1je3XFcjzzN9LiIoMRBMJDJgGY+PzrBVEjrZT+QH9NVN64QRLPYh0s2vDWgxW0NsBIQYwluLq2+i3Lo5zZqh/kxWlt9mMp1VaYGgAOrK5lAho9U48+9+oYyAgp+Y3gnNe8869WDZLOFCKlIfy94RE5f7zPfTRifACem5GjMzwlvq7ueZCPOaWtfOlj/h9d8jtcODLkDWEr4kZqjS+UCmhBm5rBOOFScNS0ub94suZwk6F0bru9q+ecmzR6WG7hyT/8yZXYXobb3zz+SWlGT8iJuWgIQm6DQiaWeYGsCLs6uLm8XcQbSAvKhaoVT5dx81eb9IjOTmhUMe7vV4fH8rujhNLeFg1aPOftzSBqrbuKSvF8tpPrS9c7fZAPFIaB1AM9kuhHAXMXvdm/D2mBI7Xg97KQNkunSnu1o9mcuzLC7Pv/bFw864ZBI09o0egNo6tB9pH0hxcNfiANSnyz1NGSlAKVxvX5K7Ywn4iAPPzhDKfA1H1ayTcX7HN6N+4LQc/d0rWF1V0oXy7SSdLSw3JcCkr//oSRrYwQ9R2WyasZNzOz1CxSgwojbYE5GOLdU6Stx6n4Ucj2xlFqJ0RUa1RqDdxDH3xh8bkApF74/dyoJMrv+vAUYzRlyO0NjD/9Wb5CLrH/RzO+MKPYKYK80vDV5XPiuRWa3K0wCSbJHbF1D8NZXUJAYf4Kn05kOnNSUgQrkujrF9LG15I6t1lwVlH7LYnbrpchMwrN4RyaykTsYHm1+ICU3xOlEyEk6FftdHuD8QjDeBJic9uKfWPVH2wYBjFrNi4f4Vw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(136003)(396003)(366004)(39830400003)(451199015)(30864003)(83380400001)(36756003)(66476007)(316002)(86362001)(8676002)(66946007)(8936002)(4326008)(38100700002)(5660300002)(52116002)(44832011)(38350700002)(478600001)(26005)(107886003)(6512007)(66556008)(6506007)(2616005)(186003)(54906003)(1076003)(110136005)(41300700001)(6486002)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CVzn1KmKVH8MvGqrsIzV0QEvOBTwskkw1BHLgJuSSL8d8gcVkJZ/kDsGjD3GC4qeO4GhxJJmqPGQ9px5eBCbXDtzk7tb3Oo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5X9o31Pm6JV2UrCLUzsqBlgM/LsrSTFYqRylAwlxkqWi846aQdgDtH+8ZaWkj8ckUXxsWQQ+BeFBWZ896W4Cpu+1vQmbduKkq5AvJ8kFfb292q+DEF8Lw+IyOxYq0yZGVCX4Pidkap999hWcMq+DjnJAUlTIyPE83QMHgxXlmvsKbrWBhoi5NORf9xzrSvU6fbWHQwDA1AiIPzFbu56x9Hi5CPc0/bhBLai82TjOor2R5RMikAuzJx4j0AWQxVR8UwRHsMGDbtvb5mnaVryHLEzGdXTa7ZLR70oPZZkzyGQ+XCrvQHnEGucFsNhSHWwBN1vUNd5IfxnlcX8ooDToSaZhqnGY+lAdkvrntoHzkNZ5ziRqCoa0ldt/wweERF0EUH3gjGvLvBWo6nhWRW/TK12o+qBgs2cHCIcMzp+V90skVBUTvqLpv1gv71MN+VDZ08dIq7giwE9w== X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4796 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Hui Zhou support ct nat action when pre_ct merge with post_ct and nft. at the same time, add the extra checksum action and hardware stats for nft to meet the action check when do nat. Signed-off-by: Hui Zhou Reviewed-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 193 +++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 6 + 2 files changed, 192 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index b3b2a23b8d89..235f02327f42 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) /* Copyright (C) 2021 Corigine, Inc. */ +#include +#include + #include "conntrack.h" #include "../nfp_port.h" @@ -56,9 +59,17 @@ bool is_pre_ct_flow(struct flow_cls_offload *flow) int i; flow_action_for_each(i, act, &flow->rule->action) { - if (act->id == FLOW_ACTION_CT && !act->ct.action) - return true; + if (act->id == FLOW_ACTION_CT) { + /* The pre_ct rule only have the ct or ct nat action, cannot + * contains other ct action e.g ct commit and so on. + */ + if ((!act->ct.action || act->ct.action == TCA_CT_ACT_NAT)) + return true; + else + return false; + } } + return false; } @@ -66,13 +77,37 @@ 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_action_entry *act; + bool exist_ct_clear = false; struct flow_match_ct ct; + int i; + + /* post ct entry cannot contains any ct action except ct_clear. */ + flow_action_for_each(i, act, &flow->rule->action) { + if (act->id == FLOW_ACTION_CT) { + /* ignore ct clear action. */ + if (act->ct.action == TCA_CT_ACT_CLEAR) { + exist_ct_clear = true; + continue; + } + + return false; + } + } 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; + } else { + /* when do nat with ct, the post ct entry ignore the ct status, + * will match the nat field(sip/dip) instead. In this situation, + * the flow chain index is not zero and contains ct clear action. + */ + if (flow->common.chain_index && exist_ct_clear) + return true; } + return false; } @@ -168,6 +203,20 @@ static void *get_mangled_tos_ttl(struct flow_rule *rule, void *buf, return buf; } +/* Note entry1 and entry2 are not swappable. only skip ip and + * tport merge check for pre_ct and post_ct when pre_ct do nat. + */ +static bool nfp_ct_merge_check_cannot_skip(struct nfp_fl_ct_flow_entry *entry1, + struct nfp_fl_ct_flow_entry *entry2) +{ + /* only pre_ct have NFP_FL_ACTION_DO_NAT flag. */ + if ((entry1->flags & NFP_FL_ACTION_DO_NAT) && + entry2->type == CT_TYPE_POST_CT) + return false; + + return true; +} + /* Note entry1 and entry2 are not swappable, entry1 should be * the former flow whose mangle action need be taken into account * if existed, and entry2 should be the latter flow whose action @@ -225,7 +274,12 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, goto check_failed; } - if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { + /* if pre ct entry do nat, the nat ip exists in nft entry, + * will be do merge check when do nft and post ct merge, + * so skip this ip merge check here. + */ + if ((ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS)) && + nfp_ct_merge_check_cannot_skip(entry1, entry2)) { struct flow_match_ipv4_addrs match1, match2; flow_rule_match_ipv4_addrs(entry1->rule, &match1); @@ -242,7 +296,12 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, goto check_failed; } - if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { + /* if pre ct entry do nat, the nat ip exists in nft entry, + * will be do merge check when do nft and post ct merge, + * so skip this ip merge check here. + */ + if ((ovlp_keys & BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS)) && + nfp_ct_merge_check_cannot_skip(entry1, entry2)) { struct flow_match_ipv6_addrs match1, match2; flow_rule_match_ipv6_addrs(entry1->rule, &match1); @@ -259,7 +318,12 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, goto check_failed; } - if (ovlp_keys & BIT(FLOW_DISSECTOR_KEY_PORTS)) { + /* if pre ct entry do nat, the nat tport exists in nft entry, + * will be do merge check when do nft and post ct merge, + * so skip this tport merge check here. + */ + if ((ovlp_keys & BIT(FLOW_DISSECTOR_KEY_PORTS)) && + nfp_ct_merge_check_cannot_skip(entry1, entry2)) { enum flow_action_mangle_base htype = FLOW_ACT_MANGLE_UNSPEC; struct flow_match_ports match1, match2; @@ -468,6 +532,12 @@ static int nfp_ct_check_meta(struct nfp_fl_ct_flow_entry *post_ct_entry, return -EINVAL; return 0; + } else { + /* post_ct with ct clear action will not match the + * ct status when nft is nat entry. + */ + if (nft_entry->flags & NFP_FL_ACTION_DO_MANGLE) + return 0; } return -EINVAL; @@ -537,11 +607,37 @@ nfp_fl_calc_key_layers_sz(struct nfp_fl_key_ls in_key_ls, uint16_t *map) return key_size; } +/* get the csum flag according the ip proto and mangle action. */ +static void nfp_fl_get_csum_flag(struct flow_action_entry *a_in, u8 ip_proto, u32 *csum) +{ + if (a_in->id != FLOW_ACTION_MANGLE) + return; + + switch (a_in->mangle.htype) { + case FLOW_ACT_MANGLE_HDR_TYPE_IP4: + *csum |= TCA_CSUM_UPDATE_FLAG_IPV4HDR; + if (ip_proto == IPPROTO_TCP) + *csum |= TCA_CSUM_UPDATE_FLAG_TCP; + else if (ip_proto == IPPROTO_UDP) + *csum |= TCA_CSUM_UPDATE_FLAG_UDP; + break; + case FLOW_ACT_MANGLE_HDR_TYPE_TCP: + *csum |= TCA_CSUM_UPDATE_FLAG_TCP; + break; + case FLOW_ACT_MANGLE_HDR_TYPE_UDP: + *csum |= TCA_CSUM_UPDATE_FLAG_UDP; + break; + default: + break; + } +} + static int nfp_fl_merge_actions_offload(struct flow_rule **rules, struct nfp_flower_priv *priv, struct net_device *netdev, struct nfp_fl_payload *flow_pay) { + enum flow_action_hw_stats tmp_stats = FLOW_ACTION_HW_STATS_DONT_CARE; struct flow_action_entry *a_in; int i, j, num_actions, id; struct flow_rule *a_rule; @@ -551,15 +647,25 @@ static int nfp_fl_merge_actions_offload(struct flow_rule **rules, rules[CT_TYPE_NFT]->action.num_entries + rules[CT_TYPE_POST_CT]->action.num_entries; - a_rule = flow_rule_alloc(num_actions); + /* Add one action to make sure there is enough room to add an checksum action + * when do nat. + */ + a_rule = flow_rule_alloc(num_actions + 1); if (!a_rule) return -ENOMEM; /* Actions need a BASIC dissector. */ a_rule->match = rules[CT_TYPE_PRE_CT]->match; + /* post_ct entry have one action at least. */ + if (rules[CT_TYPE_POST_CT]->action.num_entries != 0) { + tmp_stats = rules[CT_TYPE_POST_CT]->action.entries[0].hw_stats; + } /* Copy actions */ for (j = 0; j < _CT_TYPE_MAX; j++) { + u32 csum_updated = 0; + u8 ip_proto = 0; + if (flow_rule_match_key(rules[j], FLOW_DISSECTOR_KEY_BASIC)) { struct flow_match_basic match; @@ -571,8 +677,10 @@ static int nfp_fl_merge_actions_offload(struct flow_rule **rules, * through the subflows and assign the proper subflow to a_rule */ flow_rule_match_basic(rules[j], &match); - if (match.mask->ip_proto) + if (match.mask->ip_proto) { a_rule->match = rules[j]->match; + ip_proto = match.key->ip_proto; + } } for (i = 0; i < rules[j]->action.num_entries; i++) { @@ -589,11 +697,32 @@ static int nfp_fl_merge_actions_offload(struct flow_rule **rules, case FLOW_ACTION_CT_METADATA: continue; default: + /* nft entry is generated by tc ct, which mangle action do not care + * the stats, inherit the post entry stats to meet the + * flow_action_hw_stats_check. + */ + if (j == CT_TYPE_NFT) { + if (a_in->hw_stats == FLOW_ACTION_HW_STATS_DONT_CARE) + a_in->hw_stats = tmp_stats; + nfp_fl_get_csum_flag(a_in, ip_proto, &csum_updated); + } memcpy(&a_rule->action.entries[offset++], a_in, sizeof(struct flow_action_entry)); break; } } + /* nft entry have mangle action, but do not have checksum action when do NAT, + * hardware will automatically fix IPv4 and TCP/UDP checksum. so add an csum action + * to meet csum action check. + */ + if (csum_updated) { + struct flow_action_entry *csum_action; + + csum_action = &a_rule->action.entries[offset++]; + csum_action->id = FLOW_ACTION_CSUM; + csum_action->csum_flags = csum_updated; + csum_action->hw_stats = tmp_stats; + } } /* Some actions would have been ignored, so update the num_entries field */ @@ -1191,6 +1320,49 @@ static struct net_device *get_netdev_from_rule(struct flow_rule *rule) return NULL; } +static void nfp_nft_ct_translate_mangle_action(struct flow_action_entry *mangle_action) +{ + if (mangle_action->id != FLOW_ACTION_MANGLE) + return; + + switch (mangle_action->mangle.htype) { + case FLOW_ACT_MANGLE_HDR_TYPE_IP4: + case FLOW_ACT_MANGLE_HDR_TYPE_IP6: + mangle_action->mangle.val = (__force u32)cpu_to_be32(mangle_action->mangle.val); + mangle_action->mangle.mask = (__force u32)cpu_to_be32(mangle_action->mangle.mask); + return; + + case FLOW_ACT_MANGLE_HDR_TYPE_TCP: + case FLOW_ACT_MANGLE_HDR_TYPE_UDP: + mangle_action->mangle.val = (__force u16)cpu_to_be16(mangle_action->mangle.val); + mangle_action->mangle.mask = (__force u16)cpu_to_be16(mangle_action->mangle.mask); + return; + + default: + return; + } +} + +static int nfp_nft_ct_set_flow_flag(struct flow_action_entry *act, + struct nfp_fl_ct_flow_entry *entry) +{ + switch (act->id) { + case FLOW_ACTION_CT: + if (act->ct.action == TCA_CT_ACT_NAT) + entry->flags |= NFP_FL_ACTION_DO_NAT; + break; + + case FLOW_ACTION_MANGLE: + entry->flags |= NFP_FL_ACTION_DO_MANGLE; + break; + + default: + break; + } + + return 0; +} + static struct nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, struct net_device *netdev, @@ -1257,6 +1429,13 @@ nfp_fl_ct_flow_entry *nfp_fl_ct_add_flow(struct nfp_fl_ct_zone_entry *zt, new_act = &entry->rule->action.entries[i]; memcpy(new_act, act, sizeof(struct flow_action_entry)); + /* nft entry mangle field is host byte order, need translate to + * network byte order. + */ + if (is_nft) + nfp_nft_ct_translate_mangle_action(new_act); + + nfp_nft_ct_set_flow_flag(new_act, entry); /* Entunnel is a special case, need to allocate and copy * tunnel info. */ diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index beb6cceff9d8..762c0b36e269 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -103,6 +103,10 @@ enum nfp_nfp_layer_name { _FLOW_PAY_LAYERS_MAX }; +/* NFP flow entry flags. */ +#define NFP_FL_ACTION_DO_NAT BIT(0) +#define NFP_FL_ACTION_DO_MANGLE BIT(1) + /** * struct nfp_fl_ct_flow_entry - Flow entry containing conntrack flow information * @cookie: Flow cookie, same as original TC flow, used as key @@ -115,6 +119,7 @@ enum nfp_nfp_layer_name { * @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 + * @flags: Used to indicate flow flag like NAT which used by merge. */ struct nfp_fl_ct_flow_entry { unsigned long cookie; @@ -127,6 +132,7 @@ struct nfp_fl_ct_flow_entry { struct flow_rule *rule; struct flow_stats stats; u8 tun_offset; // Set to NFP_FL_CT_NO_TUN if no tun + u8 flags; }; /** From patchwork Wed Sep 14 16:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12976339 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9B71C6FA82 for ; Wed, 14 Sep 2022 16:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiINQJS (ORCPT ); Wed, 14 Sep 2022 12:09:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiINQJK (ORCPT ); Wed, 14 Sep 2022 12:09:10 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A931E606B5 for ; Wed, 14 Sep 2022 09:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n6kSOHx1j6bRfzRyCjENnTVk34J3Wx3zCXgCsYlwYtWovrM4iLsLlKxf+4M/tbyP0sPceNYjYewIXkHrDXlaMDWh9wwgdAiK0PJtfLALE73vcMZyHSin8gFyAF5LaD8TEfnFQxjhbrb/hbssvt24xwqU0OFdHadW2zMiZFHOkFRqi6Z8TC1A/GUIsiViGIrwNArpQ0ezivNhDLm7R8DefgLvFmMruV4VvFk49sBi8lq4f8jVMBtRB5Z/ZBEpA5/Bbd0hq/B1UAOZeRQqGyvtoq6vrSmKpcrQo31lQ/DkwCD2A0aS9SUEntAI1EKFJUfpr7S+HfyO3knQIHgMHfXSSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=egimI0HY1WfJbytE1qaR71LpswfYK+jUjvhjEfcMeUo=; b=VTyRyM/A4V6vg7fXXvJ6ty63UpLG2RYfBZyu/kgCwlfUk1k4i/oEdovVjATLN+9bfw3uIuczumPMAW5xaivxySClgD91Rqg3DQSLWdJqDNIu8GZbvP3gV/fPQtNWj9wAaStQGSPdomLt+w2ycCS5jiWnmnBT356kpJkQoppTNL9PfXoJMbRi3ackSDWwta4d/R24wyrSB21hNUTotga0M55PsNh47aYLiZplIp8bGm4NucHLopDTDwnQ/X8Bi1+KVcDOiMmYNUKJd4i3czvpjnkvWCzEZV8I5zicQr9Mqzrk4jCkULdskqe7SjGqbIZXjDmayZwodnaQT6kO9D9ayg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=egimI0HY1WfJbytE1qaR71LpswfYK+jUjvhjEfcMeUo=; b=UU6s+DLzXhCD1OXiVlqpCQT0jG6wfhi2gJ6SRiY9k82g9k7Cmua7OPao5sOv1qgygyYiKtPNa+aeQ7r8MUbWT4vi4p90JjjbyiZqbPM6Wf0EPVTQ+IdxFjZfkwzSPonsxc3ItSYLUhCdjlwINvAbfYWeSRaHOcJLPRNkCY76J4A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by MN2PR13MB4070.namprd13.prod.outlook.com (2603:10b6:208:263::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12; Wed, 14 Sep 2022 16:09:06 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::2cbf:e4b1:5bbf:3e54%4]) with mapi id 15.20.5632.012; Wed, 14 Sep 2022 16:09:06 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Hui Zhou , Ziyang Chen Subject: [PATCH net-next 3/3] nfp: flower: support vlan action in pre_ct Date: Wed, 14 Sep 2022 17:06:04 +0100 Message-Id: <20220914160604.1740282-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220914160604.1740282-1-simon.horman@corigine.com> References: <20220914160604.1740282-1-simon.horman@corigine.com> X-ClientProxiedBy: LO4P123CA0368.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::13) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|MN2PR13MB4070:EE_ X-MS-Office365-Filtering-Correlation-Id: 84cada54-daf2-40a8-2599-08da966b72bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VuQN4BxelE0C/siNNJYremJ9sqNzI6hANYtvgEIf3ftemov1Ql7zZURH2LAjY6/aY6Qwc9vmqDkPiIKzC5hzX4I2YEfD18QCyhexJ/yPbK8b7JVwWfATncvcRk11G3zctAKFwwgILAf8cq9gSLzDGe5Th3Hvjc3rDP0ZMHkUF4KC/+/VmjoNQ5cZBvc2jNtDs6BIiYTSXIn402cG7tpRKBg2TgO/xBam49ZaE71Mkt2E4qj2L9K29ivF4yeOJAbIXg/rxJA5FL9o5shOFpcK9b4+OtoA9mdnFO0NBkgcxSH+PVU0L1aNrCIIKe5JO+KiuNYKr9svhgEZOQleJdNIUoBJvdzfQipcbWva+b5PROdpcjjFCqX0YyAFdHOtZrQPIpGKvSOsRc+6I9xZxbnoav0g++DeWvWyg1xnkmbs5HwUUuUkLDkg/70MKKgvR8Yn4cTjLrdaiWjMorXwUweH2D8D87zaLhiD+kJut/jvboxhsox2kIjub0gxawak9qIg5h3YTcJyub8oZPo+pLzdz+4y91iBImZm36ToNlNVx8YzwMLlUK6mBxuTp22DyDg9svA1OoEQoNMx8DC2jrw1MBLIOdHe1lH/eZWva2XlubyLjtnzaqFM9IcmResOgLLfd8oaRFJpo/1XfYn8KfFD3pflw32xQrskvPcIeNL77TP5WOF7YZyI7UqVj8tjM98TfvvlVSCheWE3v1zhUQt4HKe0VgufvO0PFLENL5ajngRh+KnIBHGNsaSBMH+csrXz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39840400004)(396003)(366004)(136003)(346002)(376002)(451199015)(83380400001)(52116002)(8936002)(1076003)(107886003)(8676002)(86362001)(2906002)(4326008)(6506007)(66556008)(186003)(41300700001)(38100700002)(26005)(44832011)(6512007)(6486002)(110136005)(478600001)(66946007)(2616005)(38350700002)(5660300002)(316002)(66476007)(54906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KYVSrdDzqFvgrZ2X1PFM0co2ASP7y/MTEqj+LwMVgGRY26dN+wSn6iX9azMOjD07WeHcRblW2G5rrpr3b6HGmJhKR1XvKru3VABZUc/FgZdFqfFCtb1Rzo8TNaHehT0Q4PILbmbkYDJd6FcMFlIOuMpBw0BxYi1U3NqP8CZBHpvbJEopYLdoRUFHcdkl14A/minwy5JJGdXJkhoEs7YgvzFYdbu8fEJYz9QvYHb+2ASVXiyyisdSPz5w4ZBcdPKK1tpKmp14I0DNADHChOR/djFRJvGjiVizbBFYTuVdJ2650dZuU/W9VUN8vkbcd0+Nmhm0ARs0Aa68HDNXuLx9dnUHlH/qV7Qlk035zAiqeMDQuGBwwLdxOWWrXbHe4EWDdtd+D25RgZKeIqN9trkyrpVtwYlkCW9OSzX8tQKJzlyNi8uiK716zxOVUh8ejDJnJ4PYwxElUPNT3x7LWfFz4MBFHRaVVcva85368qEfBWCzdwFPdPxUNw7k3ZIbPBWx+4k/hCKkkGRa4iR9Y46RriXymzVfOVi4Qi6nR9leuk1092ElJu3nxRXAkEHFMY226evkIucPx206WFuX0P2PMfWy1EUP7dizhFIUNQ1EoIw/28Q== X-OriginatorOrg: corigine.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB4070 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Hui Zhou Support hardware offload of rule which has both vlan push/pop/mangle and ct action. Signed-off-by: Hui Zhou Reviewed-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 235f02327f42..f693119541d5 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -468,12 +468,55 @@ static int nfp_ct_merge_check(struct nfp_fl_ct_flow_entry *entry1, return -EINVAL; } +static int nfp_ct_check_vlan_merge(struct flow_action_entry *a_in, + struct flow_rule *rule) +{ + struct flow_match_vlan match; + + if (unlikely(flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN))) + return -EOPNOTSUPP; + + /* post_ct does not match VLAN KEY, can be merged. */ + if (likely(!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN))) + return 0; + + switch (a_in->id) { + /* pre_ct has pop vlan, post_ct cannot match VLAN KEY, cannot be merged. */ + case FLOW_ACTION_VLAN_POP: + return -EOPNOTSUPP; + + case FLOW_ACTION_VLAN_PUSH: + case FLOW_ACTION_VLAN_MANGLE: + flow_rule_match_vlan(rule, &match); + /* different vlan id, cannot be merged. */ + if ((match.key->vlan_id & match.mask->vlan_id) ^ + (a_in->vlan.vid & match.mask->vlan_id)) + return -EOPNOTSUPP; + + /* different tpid, cannot be merged. */ + if ((match.key->vlan_tpid & match.mask->vlan_tpid) ^ + (a_in->vlan.proto & match.mask->vlan_tpid)) + return -EOPNOTSUPP; + + /* different priority, cannot be merged. */ + if ((match.key->vlan_priority & match.mask->vlan_priority) ^ + (a_in->vlan.prio & match.mask->vlan_priority)) + return -EOPNOTSUPP; + + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, struct nfp_fl_ct_flow_entry *post_ct_entry, struct nfp_fl_ct_flow_entry *nft_entry) { struct flow_action_entry *act; - int i; + int i, err; /* Check for pre_ct->action conflicts */ flow_action_for_each(i, act, &pre_ct_entry->rule->action) { @@ -481,6 +524,10 @@ static int nfp_ct_merge_act_check(struct nfp_fl_ct_flow_entry *pre_ct_entry, case FLOW_ACTION_VLAN_PUSH: case FLOW_ACTION_VLAN_POP: case FLOW_ACTION_VLAN_MANGLE: + err = nfp_ct_check_vlan_merge(act, post_ct_entry->rule); + if (err) + return err; + break; case FLOW_ACTION_MPLS_PUSH: case FLOW_ACTION_MPLS_POP: case FLOW_ACTION_MPLS_MANGLE: