From patchwork Thu Feb 17 10:56:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12749763 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 A8005C433EF for ; Thu, 17 Feb 2022 10:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232127AbiBQK5c (ORCPT ); Thu, 17 Feb 2022 05:57:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234656AbiBQK5a (ORCPT ); Thu, 17 Feb 2022 05:57:30 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2125.outbound.protection.outlook.com [40.107.100.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437001704C for ; Thu, 17 Feb 2022 02:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=if16SY0eHvHgfpMlXRCVLSLQe2/eHdMDyYhzAvykjmDVoI/gxg6abo6IzlilIwj1HuDrapIYIJeT/1F18ekPy78rC4tcm2Lni1Mb4fpowSNW/DgcNwJxAkT5D6l7Fo834yiLtufukTbY/hLkIURRbHuwLZZKEonwVeMJ6q+qffFidyuZuF4Aqqm77+uugsgXaVALB7K/3epDtVXrPwA/g4Pk0HeDdHccRVZysoxux8cWCNeXRDx717MpF0XFct2MJmjV8D7qlWx3cC5xaw+fyS2gkQ5o/cl5KtQQjIWOmhpHUbqJcVBblTBUnEzl0bYo5TlgP19IFAMIxmEZA04vlw== 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=/ilOGCwqm5mjplkvAtjPdznOr147UBs4avU1R4yuhak=; b=TrebDrvZSJFiXViyU895KNRf6r/ESLEBD6lD50wSIbKTdfHRKt/vsN4ph82eR5H16ZPn2JT+Q8DRcfyRpg620pMSBiUvTNAAylmKipvWyvX5VkLboodtGrmkYuSoATVQCofK9IgEfpz78Wl7b+3LwYstbIOBSdqhl0T1qY4WPL+LKVINgUiKKl4WBIfSf+UXf0So+NS83u52kGLxDNoWTJ2YaoQmj/GpIIJYtoYc4gJF6a2P2/AQTTNHj0roT6PvLK7tIcukMu3fE3V0mMO/UTuKXWlHJYxtdf/rmhV9Sqz2t37QVLJKpP5rrqDeUSGqR2Wq7AVvdbiecKCEtJIwDg== 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=/ilOGCwqm5mjplkvAtjPdznOr147UBs4avU1R4yuhak=; b=ReAUiKRKdHBrs9A7Vz/sbkU8ZTBsmy5k/+8W7pBE5gmOxTBPi1VmjMs+bg9AkzrFPqyPBJJef5i+0ytgzhQfRgR6LHpv6pu9u3pClTMT7Q0wdXHUzElflz5TKNPnYKva5nvTb3dMze4Gy7yAsrghZTSLscbLpK/qN1C1Oy3ndhA= 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 CY4PR13MB1397.namprd13.prod.outlook.com (2603:10b6:903:136::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Thu, 17 Feb 2022 10:57:13 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d%7]) with mapi id 15.20.4995.015; Thu, 17 Feb 2022 10:57:13 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Baowen Zheng , Louis Peens , netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH net-next 1/6] nfp: refactor policer config to support ingress/egress meter Date: Thu, 17 Feb 2022 11:56:47 +0100 Message-Id: <20220217105652.14451-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217105652.14451-1-simon.horman@corigine.com> References: <20220217105652.14451-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6adc0a7-61b3-4ab0-2c3c-08d9f2044101 X-MS-TrafficTypeDiagnostic: CY4PR13MB1397:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lHX+VL/OVwWKWMRz2t38YCVJ+47kv8mdQqZkpM3NqtOC+K2rSDX4DNj4qWjIWXvdBjwANPNi3+3E0aUTyzLbHcfRLmye5ItYpQa8a/f23sh/YdRX13v2WCxDWyFccgsUx95JcvhXm/KdbZvoNgEfDl7BpVSmPHV5NEOyzWPpVINBd38y/pt7h5KINLsz5WgWsfi94oXs67PKxn0g37fwVheSRfcpm5Dl4/Ydm1tycbTuxPJcs2AiHAcPGcIm5zIZp8SdqbR7vMxtJjDy5nh9ghJWC4dNQALvtMTk+3sJznGyRf2rRNDv9eSnMq6NPMNwSHVi4slG65I7bPAYjlxx3ecm4VIULK6Hn+BxJ3x4B3eBdPtv12h/laxdfWgI+yYtRA3jMYR+xFP1Gc3JXiqaXOOOyHfma8KbNU2pn00c256PNCczgQ6kAtzsDxfwnULbxs5fxCT3P5MSxU4aS9DqzfV647I8zVNSig3HOvWzqeODAbYhyJLshX5MFl4ZGUXWMkNRqXBjQgr60B3xRFMHcc9LtctWsL8FrzzVTBLOxEvWvxXYpTTcOcVCGgGtxEmP9hzhvFSrYd+/DspZbCQ1fTDmwv7TkfHl63qMjHiMPSD9kvkmjYLBtzOPf8qpIKTLBqeM/4K5RuKzzOMwnVbbDw== 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:(13230001)(346002)(39840400004)(136003)(396003)(376002)(366004)(8676002)(66476007)(316002)(1076003)(6666004)(6506007)(2616005)(54906003)(186003)(52116002)(38100700002)(6512007)(66946007)(66556008)(4326008)(86362001)(110136005)(6486002)(83380400001)(508600001)(107886003)(44832011)(36756003)(2906002)(5660300002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D4cKWic0NbRtBC8EedZlgMkd4Qy1JE3XnfASNHEQDnzfcV42iCaN87ZzrZG7933rDLJapqn3Bfza5WqIAZlgxrcPBBKbq5VMyZ6aCokuJjqB1pcx2ooeFzPBVdBbiQ4qkVLXrzhUsK6ff/Zsxs+crO0jkJFaSBXSBDXYLZmvsv3Hz/cK35pcS9KqN7vktuLCfA2p/W5OhXZN0ufOG7ZsPhqVrXDNNaeaXWelNVcgGRDYg1acOYMP3GPMR2u6y3wWBBjCkhKG2iTi3VKAmOZEXq03lsYlUGo8l0Q0xiTgxIP1w/dScd6Smnr97ixGjgZJxBH2nySj7a6Wlf9JxMUPN1Ro07l5wi0aHhcGUiSfJYcfDWaMb9Jgez80cv9wWxXj7AdchtrIpUg7kmcotyh45Dn3RgaVuFtitrrGr3CAC5pPOIG/QIHmXVy/BC0SqjfTR/bMQMy7l9gDnxKgbWj7DWiolYxwvdWwi2Tq97MwZYXyLe8FmnWR81C8e44912J3DoLP97deBpCnQ2tr7S4jZ4FG5YHwd4FMpQ+VhpOzQwS3Vfhkhk4jGDW5O0ONd+XFTlvqQ1FbGahqbw+v/t8Gf8Mr/hub51LGqyKl/am/ERX54n/z29zx7lKlfjn57V1oriF5NtOHoohB6H16Qgz0c2qMvcSU1I8iQBn4YzsIbSUMYLZeutX+CowdruW/WtHpw7vm0ymNvsuaR+c16YsUCaSejZXWdYvIwic3yYgCcZ3yW6N8HyM0Y6+FFlxrTPE4k3JUz/cBVoKZgRwhtY4RWUULUbsRPuLurgadRln7EPeOxRnCnYrtSKwg3PnxfNfnz4aj3hlmCcBFfSXTupV/KHy3d7p9SwBEhNPwV9MBUyaSFJZbI4lNldio24gU4648O/r/Tz0kqFSGcSHcf2PXTEgAHWL5DGeLMTL6cs3l3TCW0sDlcnbsYp0TGKg4iYJB329PDkrV/hXu76kiugPniA03gln2NDQeNv1wh4zM2ZSMvOUdedfmzoMpSXdNrICD81MDmhNQ3E6DR6uvlqDKqW6G3FmGPx78DZBJ5e5sKH/OAxeXxFkXI2nbM8EDQUXbWRHM2BE9tOZn6foPaKOuMxWm6VByZ0tohp0jSw+veoOxhNdUxjik5WWZBIwJ3HZFlbsgoKIRnYzDhkvcrWy4h78wYpP4LGwjfDpDIGpxeB4qEBpyGkN2EbPybUntgXAc7Bbhpnzla0/+E5dbOiDomXPNrGilSnJCLl4rhiUjYQCUDEHsyh4O4a2F0CYO06PPxtyN0KIhNtQBdIFqvSofVMO/u4WQTGlWVs004rsjxz5DVx/Cf+HV6FhF/6H0cw/mdNcbZ354R7yHkBr3JfcT18lAOQ6lCa2Zyrkn2fHcKl2rcxJ2C0IeqbEhTs2yFZSCjjNbP3GUsI+rljGMkfUnPRZwfQBtaDT+8qadvPqSSoqbWMvtcA53tV+s198lORPk50lVQnK0Uk2/I2lgTK2lxDVT+Ah8FicBY6VsJsVfItQc+WBA3wchHfb7taclBagkom5rQPkOHFHavI6oenEDLmK73ZfQX0gnEey2GRBAP7uwXuxMQeb/zCLwpf/OSuIiuqxBZqYm8ftNogzY5V+LlxUXNpku+pbk2ZPXoWt+yiSt6pN7XXpxQOT0e1sBKbU4hpfqNk5s/y1SWy6MFRBJXP5U/iJWeiM7+BGzSpNdX+CzU44j01sH89GOdVi6h0YDRFGIzyh/1tilHyk8RaOfRhTn5DVLFYP+mOBIM5LVvhM= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6adc0a7-61b3-4ab0-2c3c-08d9f2044101 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 10:57:13.4960 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c2aX4n44ZnEGfr0qsocB9tnZohEbC2qWxh+SjHIFb+WMastfR2HQUMxPJBuhB84mDr3M0ptvgjrhVQfdVFo7eBye3Bql5yEWNQIIUApEglk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR13MB1397 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add an policer API to support ingress/egress meter. Change ingress police to compatible with the new API. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/main.h | 2 + .../ethernet/netronome/nfp/flower/qos_conf.c | 74 ++++++++++++++----- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 917c450a7aad..7720403e79fb 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -569,4 +569,6 @@ nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow, void nfp_flower_update_merge_stats(struct nfp_app *app, struct nfp_fl_payload *sub_flow); +int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, + bool pps, u32 id, u32 rate, u32 burst); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c index 784c6dbf8bc4..68a92a28d7fa 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c @@ -11,10 +11,14 @@ #define NFP_FL_QOS_UPDATE msecs_to_jiffies(1000) #define NFP_FL_QOS_PPS BIT(15) +#define NFP_FL_QOS_METER BIT(10) struct nfp_police_cfg_head { __be32 flags_opts; - __be32 port; + union { + __be32 meter_id; + __be32 port; + }; }; enum NFP_FL_QOS_TYPES { @@ -46,7 +50,15 @@ enum NFP_FL_QOS_TYPES { * | Committed Information Rate | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * Word[0](FLag options): - * [15] p(pps) 1 for pps ,0 for bps + * [15] p(pps) 1 for pps, 0 for bps + * + * Meter control message + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-------------------------------+-+---+-----+-+---------+-+---+-+ + * | Reserved |p| Y |TYPE |E|TSHFV |P| PC|R| + * +-------------------------------+-+---+-----+-+---------+-+---+-+ + * | meter ID | + * +-------------------------------+-------------------------------+ * */ struct nfp_police_config { @@ -67,6 +79,40 @@ struct nfp_police_stats_reply { __be64 drop_pkts; }; +int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, + bool pps, u32 id, u32 rate, u32 burst) +{ + struct nfp_police_config *config; + struct sk_buff *skb; + + skb = nfp_flower_cmsg_alloc(app, sizeof(struct nfp_police_config), + NFP_FLOWER_CMSG_TYPE_QOS_MOD, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + config = nfp_flower_cmsg_get_data(skb); + memset(config, 0, sizeof(struct nfp_police_config)); + if (pps) + config->head.flags_opts |= cpu_to_be32(NFP_FL_QOS_PPS); + if (!ingress) + config->head.flags_opts |= cpu_to_be32(NFP_FL_QOS_METER); + + if (ingress) + config->head.port = cpu_to_be32(id); + else + config->head.meter_id = cpu_to_be32(id); + + config->bkt_tkn_p = cpu_to_be32(burst); + config->bkt_tkn_c = cpu_to_be32(burst); + config->pbs = cpu_to_be32(burst); + config->cbs = cpu_to_be32(burst); + config->pir = cpu_to_be32(rate); + config->cir = cpu_to_be32(rate); + nfp_ctrl_tx(app->ctrl, skb); + + return 0; +} + static int nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev, struct tc_cls_matchall_offload *flow, @@ -77,14 +123,13 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev, struct nfp_flower_priv *fl_priv = app->priv; struct flow_action_entry *action = NULL; struct nfp_flower_repr_priv *repr_priv; - struct nfp_police_config *config; u32 netdev_port_id, i; struct nfp_repr *repr; - struct sk_buff *skb; bool pps_support; u32 bps_num = 0; u32 pps_num = 0; u32 burst; + bool pps; u64 rate; if (!nfp_netdev_is_nfp_repr(netdev)) { @@ -169,23 +214,12 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev, } if (rate != 0) { - skb = nfp_flower_cmsg_alloc(repr->app, sizeof(struct nfp_police_config), - NFP_FLOWER_CMSG_TYPE_QOS_MOD, GFP_KERNEL); - if (!skb) - return -ENOMEM; - - config = nfp_flower_cmsg_get_data(skb); - memset(config, 0, sizeof(struct nfp_police_config)); + pps = false; if (action->police.rate_pkt_ps > 0) - config->head.flags_opts = cpu_to_be32(NFP_FL_QOS_PPS); - config->head.port = cpu_to_be32(netdev_port_id); - config->bkt_tkn_p = cpu_to_be32(burst); - config->bkt_tkn_c = cpu_to_be32(burst); - config->pbs = cpu_to_be32(burst); - config->cbs = cpu_to_be32(burst); - config->pir = cpu_to_be32(rate); - config->cir = cpu_to_be32(rate); - nfp_ctrl_tx(repr->app->ctrl, skb); + pps = true; + nfp_flower_offload_one_police(repr->app, true, + pps, netdev_port_id, + rate, burst); } } repr_priv->qos_table.netdev_port_id = netdev_port_id; From patchwork Thu Feb 17 10:56:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12749764 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 58FD3C433FE for ; Thu, 17 Feb 2022 10:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234656AbiBQK5d (ORCPT ); Thu, 17 Feb 2022 05:57:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231210AbiBQK5c (ORCPT ); Thu, 17 Feb 2022 05:57:32 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2125.outbound.protection.outlook.com [40.107.100.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC8376589 for ; Thu, 17 Feb 2022 02:57:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k94qZDx2uHjcmT2kEhkR0caoG+X+VyHPbMJFD1sOHsSjvbsirdLnylRz4OwWV8oVI/3EUN0MPqpq4PfRmgq8KMeOQ3//52BnCfSDhg+XdRBqVNH+iZwX/SBuwswYYl8NnaSLczp21aSX7VDj+XXEAJAmZvvpQYvJLaPT2ml3LTSkiDKsYmY5FWbkWDrBm8qTh4mwe76LNpzNzfiQLjQP5NccS7qtd0h6x4zkBDAo/pPbYkNsoQUL0Xkl7AU3xxyJBqAlro7SyJ637mBy1xUr7NSBS+JlGjB2cwH0PIKF5jQrtnOzqnK4c8xmXQ+vix4Twk90qvmm7RH4NF7Ro/a88w== 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=G7SW5RmL+IfhPETXPHEbPaIGnl0N9w87G0kLumAbrnc=; b=X0lCj+Kk2I3o1c+SvOYBeXVCah3OD+HdbDp6kNrvwoJ49Laub9mpQ6bNsad1PrQMNPh5RasWjEH3DhsXdxA+UwKtOXl7uUoRsI8HG1+7hUhxx6doi0sIP0z9zj4e7o5IGWBq9v5zLt0XhBWQBqo6OdDZMFE8Q4ZglrCu7os+pBWs0Tv3Z3O/Qh4vLK3qp007LeAxsgCM+fq6BC2ao68pVT5fuBH5qhIrIVnbMdTuwVq0x3nKUapIvXuNI9MAaneWlbQIO7QHf2Bsgmh2oYUFqlc2HRk72KoIK6H1RFLd+E+vczhYMx13NPA50MRx+PDb8BHJdQwUC3r5V4pW54w+5w== 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=G7SW5RmL+IfhPETXPHEbPaIGnl0N9w87G0kLumAbrnc=; b=BzBNasL3rr4wMZYiwLZrBmawz9JAigw+CUN0ccqtN6X66/0h3AKD8KjwSfxSp+5Kh7usk6JMmaESY5N3dNdrhWckDW2sqvpKGRzLyl3qCu34kZc8Hb8VteJqAyFx/Y3GXP3VfmsxjCYq2dSgz5m9gHsUK8ul/PMSYdf2Dg3CUc4= 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 CY4PR13MB1397.namprd13.prod.outlook.com (2603:10b6:903:136::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Thu, 17 Feb 2022 10:57:15 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d%7]) with mapi id 15.20.4995.015; Thu, 17 Feb 2022 10:57:15 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Baowen Zheng , Louis Peens , netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH net-next 2/6] nfp: add support to offload tc action to hardware Date: Thu, 17 Feb 2022 11:56:48 +0100 Message-Id: <20220217105652.14451-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217105652.14451-1-simon.horman@corigine.com> References: <20220217105652.14451-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bbc62c38-1ce5-415d-89b6-08d9f20441ef X-MS-TrafficTypeDiagnostic: CY4PR13MB1397:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:628; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j0RYQfSY+IazjHAxv/ska14kigmO3lZLwofihH4vQSuGAP566S9nynlGZMeqASXwdJ4bGLeGg7CCRlzMXOD23ZLTFYlLnDMBFZv4X7FB5X1YaiSo76yNhoJPdDDS9QtYNDWsRfZc+kZWF61XPcFXdbQ/q0bpNV4jZJVetPThI6Qehs+3j0FEioPENdgewI3BDEjoXO2Re+2voGAzauy4Q01cidRwLBXGgYZBGyyEsKUZWcJs1QqycL9ct7aWiQUgj7SLJILNhU/t9hBQICM8JyCbQx0bwaKptN1CyhbaP+/lzj5u/l9N4p3WVLOmXk3l/YNUA54Lxq5wULKnk3Qptj5RsibnNNrIRwyQzhNIMMod75O9tJugwRALqNo+aJZuFW3aJtVlyytviiROiQV2oHReMnLZ/SoaVdwELVSwUVF1A7FrR8GdC770LltGspVxb5vgjFuqHFjeb63PanafUtTYFlBQN40unkX7ka/41+8kTS5lw7+gWNH80jwi5S356hdd5lpYyYnNcaaz0l+/9Gv/VVFUbrnCIHDCImHQS3oeumqNadNJA0S/3jmEu6XxAtOKvd8/b4mBalCthHi8bGsT64Qxwec2U0oVM73qQOf3/5WQ/z5T8Ko/M+dHGfRsOBrmr7hS6aDJN+Wb+MwHdQ== 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:(13230001)(346002)(39840400004)(136003)(396003)(376002)(366004)(8676002)(66476007)(316002)(1076003)(6666004)(6506007)(2616005)(54906003)(186003)(52116002)(38100700002)(6512007)(66946007)(66556008)(4326008)(86362001)(110136005)(6486002)(83380400001)(508600001)(107886003)(44832011)(36756003)(2906002)(5660300002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rc/MDKXJPUyFLCVVoagN3A9BKDNm0xQW3JtYbkLlUdba0gI51tAr6TzY5X5k5NRK2H7t717XP3BeP+PyzNanhu9rr1F/o3MWJ6zdeEC/IiKmVfUsulRGyH+WN8uFYTWOB0bZbr60ecrll1kXwg0FRHK2RwPsbXOwxOj9HCCaH3+Ex/ylcW89SnNXGTbCJzgOMrddwevP7X6bN4rejW5EUAIjzy5/ziMOR1WU2RQexeoxLzmX/guH8MjvtzSoC42rGDfyhWUnGtKd+H2oikeG7bbz4enD8K3CPRlsBLcv3+WocIBBNcRHt3+LUDFcemMfYrykIjDt5omPUeKuq/jfyC8/1cl/28RTdK6QAwT1Kea+MOdrEehvpEEkBnvzHXojVvMW1uJ7qWwlW+TLK8TEI6LNoSAe3qoemdc6MQINBPxOAd+GpaQdii5xb8S2uIbGDN9i0D45bKhfnRlZuBpl5pNZY7GkadqnwuxGpVmp11CyHizimCbtEHgQvjM/QSnph8s71iIFvuQFzoAJgQFNnDsdAPfFe7lYMAZhMgKanrgZmv62U75/vZFpG7Om7489TO6FV+7QIcyQjoCgIUiwSvBF29dFP4IXRFgKDysI95r7rnJkTsUTRD1RUR6gF4X8IYDmeF9tTPaB5nXt3hMh9rRTe0ihkvmD2FTcfEJyhaJICnPma0SmLud9bWjJRbQNS5XW/zj85iNIhjzi2yl89NXOlqOgbQY+z3Ao/8tC0fPONMtAmrZcEWin5Ii74eIx8SLZLM6lzzFYV+xW3scOCtugc7NI0AHQWA4lkXEta528QJ5zvngfLLy5YjGU4RtHGj+zXd4CYunJ8Gn78LGOEZj8EG+5RU337h40ZckK/Az8/Zg06ffqzTRhpgVvJRQKZoIzSgPd+8rIqqrXGEWvkfwR38zsVg2dGbA7+m5wXehQP+j/gYqWwO4p6PBrIeJdVBY0CqsE7MKW0E6UpZQtupHBtC/aVEmMNs6Gm2N1TpG/9Nue+tlKwnlh5gZJUsdPyJLDfKDpe5XY3wP3mK786VBZj/pHWn88PkvOE8+ek/M80HhRDwQd1Ssg+QbvNEOa89vUvr9QGrVA5Nh0hwNyZZUkGRsTOcXPCPfaQ/11cPKMjZmdHuQWPZ3mh8N8BebP0WiekpQQn0fzUUgbz13kBLXTewbUx5JdgMIJYVhTC3vQxekOjTC6zGod/GTYLuuKGCFxZW8fBV37K2hxMvSdl5UjkZAwSvlK3+xYYXtUNcy0zx7fzLB3t6oIBou5YeqUNHm2JDdbEC1VHxYiqhkHvTZpEH3gYu5E/qR62dy6bOA9Ke+VOG3aIT4qxTpg9X5hfqXoYQXQkp1kt5LT39zlOtpyhHwithvepBIVq5vBHjQTdePNvEbYxdYK0m+suAaitI8S+wFIr9b7CxG3H0gc26mcWaw2BivbLvBMOCO89wh8LOMXH7YAiCeHZN92RtFGKsO0NZDbyzUgKDY3xJY4Jflm5KydCIKrpHYle27XMkDD2OYyFDeB3lXrUVk6qfnluT0rV3nQeyKSec64FPcU1LqbWL7ZeBMnLDXkaudHfz3B59JaNamAl4sOUVMf/WpzATt/UfEYnd7leQJg7TpXKTR/BqK6crPfBCFilqQpKENXVQrxG4JVFjayV7/xObioRwdx3V8wrEjC1teQYjYgDcstzdascucnzO1Y5K0ixAFawEwLa702X+bvKApO1gRnj7DFohC5VT5/L1vanBVHAV75vt66HbAlaCp3Vv5Wp9s= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbc62c38-1ce5-415d-89b6-08d9f20441ef X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 10:57:15.0581 (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: ngcqILw157SCDfuus4jE87NkMm/lvLKDKPV8IS8snR8ALUWnTNVLRHhiaDgiqEGB7+UxWGi3jMll1ObF4Cz7YHG3lYWk9VAq5CsTB5CQpBs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR13MB1397 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add process to offload tc action to hardware. Currently we only support to offload police action. Add meter capability to check if firmware supports meter offload. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/main.h | 6 + .../ethernet/netronome/nfp/flower/offload.c | 16 ++- .../ethernet/netronome/nfp/flower/qos_conf.c | 103 ++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 7720403e79fb..a880f7684600 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -12,7 +12,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -48,6 +50,7 @@ struct nfp_app; #define NFP_FL_FEATS_IPV6_TUN BIT(7) #define NFP_FL_FEATS_VLAN_QINQ BIT(8) #define NFP_FL_FEATS_QOS_PPS BIT(9) +#define NFP_FL_FEATS_QOS_METER BIT(10) #define NFP_FL_FEATS_HOST_ACK BIT(31) #define NFP_FL_ENABLE_FLOW_MERGE BIT(0) @@ -569,6 +572,9 @@ nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow, void nfp_flower_update_merge_stats(struct nfp_app *app, struct nfp_fl_payload *sub_flow); + +int nfp_setup_tc_act_offload(struct nfp_app *app, + struct flow_offload_action *fl_act); int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, bool pps, u32 id, u32 rate, u32 burst); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index f97eff5afd12..92e8ade4854e 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1861,6 +1861,20 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct Qdisc *sch, str return 0; } +static int +nfp_setup_tc_no_dev(struct nfp_app *app, enum tc_setup_type type, void *data) +{ + if (!data) + return -EOPNOTSUPP; + + switch (type) { + case TC_SETUP_ACT: + return nfp_setup_tc_act_offload(app, data); + default: + return -EOPNOTSUPP; + } +} + int nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void *cb_priv, enum tc_setup_type type, void *type_data, @@ -1868,7 +1882,7 @@ nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void * void (*cleanup)(struct flow_block_cb *block_cb)) { if (!netdev) - return -EOPNOTSUPP; + return nfp_setup_tc_no_dev(cb_priv, type, data); if (!nfp_fl_is_netdev_to_offload(netdev)) return -EOPNOTSUPP; diff --git a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c index 68a92a28d7fa..3ec63217fb19 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c @@ -475,3 +475,106 @@ int nfp_flower_setup_qos_offload(struct nfp_app *app, struct net_device *netdev, return -EOPNOTSUPP; } } + +/* offload tc action, currently only for tc police */ + +static int +nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + struct flow_action_entry *paction = &fl_act->action.entries[0]; + u32 action_num = fl_act->action.num_entries; + struct nfp_flower_priv *fl_priv = app->priv; + struct flow_action_entry *action = NULL; + u32 burst, i, meter_id; + bool pps_support, pps; + bool add = false; + u64 rate; + + pps_support = !!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_PPS); + + for (i = 0 ; i < action_num; i++) { + /*set qos associate data for this interface */ + action = paction + i; + if (action->id != FLOW_ACTION_POLICE) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: qos rate limit offload requires police action"); + continue; + } + if (action->police.rate_bytes_ps > 0) { + rate = action->police.rate_bytes_ps; + burst = action->police.burst; + } else if (action->police.rate_pkt_ps > 0 && pps_support) { + rate = action->police.rate_pkt_ps; + burst = action->police.burst_pkt; + } else { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: unsupported qos rate limit"); + continue; + } + + if (rate != 0) { + pps = false; + if (action->police.rate_pkt_ps > 0) + pps = true; + meter_id = action->hw_index; + nfp_flower_offload_one_police(app, false, pps, meter_id, + rate, burst); + add = true; + } + } + + if (add) + return 0; + else + return -EOPNOTSUPP; +} + +static int +nfp_act_remove_actions(struct nfp_app *app, struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + struct nfp_police_config *config; + struct sk_buff *skb; + u32 meter_id; + + /*delete qos associate data for this interface */ + if (fl_act->id != FLOW_ACTION_POLICE) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: qos rate limit offload requires police action"); + return -EOPNOTSUPP; + } + + meter_id = fl_act->index; + skb = nfp_flower_cmsg_alloc(app, sizeof(struct nfp_police_config), + NFP_FLOWER_CMSG_TYPE_QOS_DEL, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + config = nfp_flower_cmsg_get_data(skb); + memset(config, 0, sizeof(struct nfp_police_config)); + config->head.flags_opts = cpu_to_be32(NFP_FL_QOS_METER); + config->head.meter_id = cpu_to_be32(meter_id); + nfp_ctrl_tx(app->ctrl, skb); + + return 0; +} + +int nfp_setup_tc_act_offload(struct nfp_app *app, + struct flow_offload_action *fl_act) +{ + struct netlink_ext_ack *extack = fl_act->extack; + struct nfp_flower_priv *fl_priv = app->priv; + + if (!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_METER)) + return -EOPNOTSUPP; + + switch (fl_act->command) { + case FLOW_ACT_REPLACE: + return nfp_act_install_actions(app, fl_act, extack); + case FLOW_ACT_DESTROY: + return nfp_act_remove_actions(app, fl_act, extack); + default: + return -EOPNOTSUPP; + } +} From patchwork Thu Feb 17 10:56:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12749765 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 F41D2C433F5 for ; Thu, 17 Feb 2022 10:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236018AbiBQK5e (ORCPT ); Thu, 17 Feb 2022 05:57:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbiBQK5d (ORCPT ); Thu, 17 Feb 2022 05:57:33 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2125.outbound.protection.outlook.com [40.107.100.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 060D4DF4C for ; Thu, 17 Feb 2022 02:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MbpR4FPDH3c2x04hX7ph5zdqxAQLFGuTHCHiRsHlfm5HQCSy0QhNSizQs72L9zHnL8TJ4OVNh/LqkSP+uj6Oeo8zZ6rloj8u02iZeBIR7ZsaxoXmQ5AeWb3N9ehhwqNcXriUEumDvahowsr17EboApcSmWMjbnv1eQBnUMrupxaccg4YsyD/q/9KGHZiA8BO7tL52lfpuUvQugzFbNqJEpwDcKaA+7IIpZWeI72UJ2zKNvw65aXzrb/jkfVbKH7L/6ejBgldrw0MTSRJvTy7gryfeg/Z24gweArYWroqiZpClF6xO0IxBQbyx6mSN9f+nKJcVCJ0vKo8xUzosZQMZQ== 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=6JBNQZOzLcWLwZmzkouhinJ/NCK6APcu19xCH8gqkYE=; b=B1elp0BjFWJs9YhZwZ2ZJgh+1XjrHLjTWxHiwM2CNBbXMXW3Wjpe+jA/v6P39GKBZwlMCRKcaX8SAeV3y15hwGP3x9eEOahpa6MZ+xVbnJqFTd0EA2Fzey+kHJxYmhak2nJu9QDDXMuEMcImExAWNND1mdU+c0zdgN6a+MZuCLjE0F8YZbSL3Bh0Xuw5JUe3GRRum9p66jSIJl2ujyD94Mja4l3BMQfnzweiyEbQRflnoUx79kme62eTrqgeVz/lLVRAMhFJcfApi4i8uQS79rJfLEE6MtBUCugxm82ESWX4kHL06C70XpuASUeYr/QI51uBQznM19f7eEqqppMthg== 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=6JBNQZOzLcWLwZmzkouhinJ/NCK6APcu19xCH8gqkYE=; b=abrHrcTC1kZNy/5IC3/ADKIN4fXXGwVWhAn1cAIzhHZuaD32uvhuLEkzkqfErSZS9VUx5s5FcWA7vvZyt/dqcqcxVHbBrj3HgPy1m+VJkIrkOsRS6Cf45s9WNKE5cB1fra1ZrkzL45FP4rVuHy00t7g8XD2g6ufRPUdwKX2LtGU= 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 CY4PR13MB1397.namprd13.prod.outlook.com (2603:10b6:903:136::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Thu, 17 Feb 2022 10:57:16 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d%7]) with mapi id 15.20.4995.015; Thu, 17 Feb 2022 10:57:16 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Baowen Zheng , Louis Peens , netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH net-next 3/6] nfp: add hash table to store meter table Date: Thu, 17 Feb 2022 11:56:49 +0100 Message-Id: <20220217105652.14451-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217105652.14451-1-simon.horman@corigine.com> References: <20220217105652.14451-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f554b7b-d44d-46fe-dd08-08d9f20442e2 X-MS-TrafficTypeDiagnostic: CY4PR13MB1397:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u//iiBV7krTdcYFOiGx8ag5IpI6pxQCJ7FCQ5z59M+dXLq9vmpg5G62YNvxLuGsXrYshU2h0IHQIkoWmNm6QbwCcckqA4iKQ7PfvqlgvPnfA84K66siYZCh4rrI1HtQCFkx2bO0x97kgjgJGyz0Zu9OBoauYyaPhlgr/M1+2Z3jrPL8i4iAYiOFL0Y/bD0fWIGfklEHTe0mQnNl8GFQzNh3CV7PcOcdvWmPHEYnfcuI+aPD80qUh8apFMvEPSt8JbqMVfo1770q9PBhd3ZzRWCtjdNq+RKKu0FTSm+nN4mYXrmp+y8VurjYjsPKe/Y9clxFFYNZrSEyoGo7n+GYV+i/2ZyWw71ssy7XrQVJ71XRTDKh9ufvNb6qCt+TFBMh/NetngbytgnoVglhHKRyflKJH7U/O16K4uZh+Et2Gf3EfQLVxk3KScb2iAYdHdDiKlBjxUjLDkbf9j8M6aksv+oOHmYNfnNgxfnOOEnnxki97iOewE0aLJT/zf/dmBqRS7k1VHxS/yT1dd1yf5ERbhVWnHqCmh2Y7QCillmwkid3O2alZiqfKQPcHFwApiBSyDbSpRxNVloSPP+Rcm0sE/tpbORKhJbuTcdG578D5fXiRGkgEJGhnZS8q+oKqk283a5EpdxJ0xQtJ12jPxLWcOQ== 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:(13230001)(346002)(39840400004)(136003)(396003)(376002)(366004)(8676002)(66476007)(316002)(1076003)(6666004)(6506007)(2616005)(54906003)(186003)(52116002)(38100700002)(6512007)(66946007)(66556008)(4326008)(86362001)(110136005)(6486002)(83380400001)(508600001)(107886003)(44832011)(36756003)(2906002)(5660300002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jZxclcVY9HqXg7QNf86FBea5eIdZKjyie7a4sgJhmAldT7hNR2R6m4WErIwBH7I5l5iZNnM94CVPhk3VbvUrKvf953t50sBNZVXG/HDtnCU7XpyJUdy/tKqMhj7reaoyh/6vE2OPUNUf+idXliGUZNYDWulp+hPzteezS1p3q7/OtXoJpWRzWh2X19ZyjCJyg3EMpP0DSXz/jjFWga3t5EaIG3yDPmh8RoYW/Nvr9zUX2sa+a5ipjMqXjFDks9vkgStohQP++hiCE/bq4mD6mZY6H09IQfiqfazBZ6CV9hu+2OnZTRd11nqE+ywKJEf5qG0sL9ygWmaLVt21h2tmLG7wV8g3nQ03r9nHRZNcH2zucbMG+gxYeu0j/Q0ziuEOH6mJ0K8TtHk/BHg62bBC2HxAvcuFN8aE8qgrQYDbCehIfKB83cGXBVIrWoSgJznDEdaXYjBK3sVew2VF56LG3Rq0UyHhWERvsLmtfVtrwYyTPxk3zFk3eFEkeBuIODZjgoQhSHw5aoXgvUbsS1UJ62oaS9iioZ6qy5SLBb5t4xGh0LdJ+3t2F+KdGUEdnVXwcyjC0TlUsbP9j2ncuUPJuNIQXtUP1ZSIVy5czBotnJc03joMqlpPfK0uNSGFVi/BFWfyYrf+msnGRYjFjPrMJDryE2p+lr8VX7dXix2CeJ/aw/5pxpmEYOgS51aUZSAdQGwSeDE7BXgc0X0e5mscYuXS+kD0lpyjltWFDpe2Ij6DeB6vedLlfsuXAoxcMuk9PyCTrQHHQgrLXrgXezLGpgOiFnBInv33CZdummFJOtOQNlnyi6EcN2ir8erVRP4OSazVgVXMhoIfIMZjcxC2rlR/Y5SOBUGbt9fQFG6+Vuzehw4CwZdhGuN5zRiNeU/4y055YbLWKdhASt4liIvIb+qkSIKfnEu1Tk/KPe1xfpkGTg2UBTpd9OUSYEybwllwY8cZYTcSz58dxhHCKBx2mtj7FWSgY/5sQhK4yTCk43AFGocPp02bITsKgqzd5GIwz84P7uOwLhwQ/vUwrdhMxrFG8Mf7hDWjK9jW+8sAAwDnc0C67RhellSTbtEfxDmHonD7Gam2DsKqkHW26GC64ickDxMKLhWPhEhCO4RDU6o06ipXhstdW6Y36W7T66pspQ4f3XTwrUqDMEW2apv9YhOaxzYOkaJQGg6UWKYVNmCO2gfXNdI81BSOWAl4fOC/15pabGH5crGNpeFiakzkzdZKpGyv7S/V2PrMvAnMR549IHdUlGaCV47N6xyOgUS0eU5oZkl3QP1HXAGPOlkM2lINZI0Lkc9yzrgT6OaIqJmiNk90Ey5ueoKd/kJqwJdj+jrUBkiook4cmdMDLwWc3F4r+gG+YkGRCghUZ5yLV/NBfdoPRgqQfgN6PzsJLmtP7BilbGa/snqqQHqEVCUayrLT6k+MWWsfGI9oyF90hHKI2TAIv0Q0bPIXK9JuGtMrd8L94jtcEMsOyxwgcnwfo22Hdo3vVEDGX6T9VLLSmzKLpLLz+Wlzd8oajjV4NoLq6AXfHm/8faHksDxonf0Te+CZcgidRsmVRHqPW8mtMlXj9dS2TZkslIty+vHX/OWlN7nLl7vJ/Uv0D0S1o3b6emZ0N5dWNaVMs+kC1YLU2TnIMGxtA9QXqpaA4VGBdl/r39dTOVp1UxkW0nrfR9L1rxb5FOGsbxpiy1XTqwGus80EgSfvwlPEq9iV50FHQAf/O2JLOYO8DgiubcKAnBOQt2g+gDtjmhKqWRdJIMUxh78= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f554b7b-d44d-46fe-dd08-08d9f20442e2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 10:57:16.7621 (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: 82zs47YSmLnd/OFheCHTaTI+P6SpVRoEIJJ+Dpyln1QQHhge8FuAAbTOT5Ymhwy0IZIHB2TfcAbh5QSGTDVFMnNmpAT/YFQZy4d8G2eADIA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR13MB1397 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add a hash table to store meter table. This meter table will also be used by flower action. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/main.h | 36 +++++ .../ethernet/netronome/nfp/flower/qos_conf.c | 148 +++++++++++++++++- 2 files changed, 183 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index a880f7684600..0c28e3414b7f 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -194,6 +194,8 @@ struct nfp_fl_internal_ports { * @qos_stats_work: Workqueue for qos stats processing * @qos_rate_limiters: Current active qos rate limiters * @qos_stats_lock: Lock on qos stats updates + * @meter_stats_lock: Lock on meter stats updates + * @meter_table: Hash table used to store the meter table * @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 @@ -231,6 +233,8 @@ struct nfp_flower_priv { struct delayed_work qos_stats_work; unsigned int qos_rate_limiters; spinlock_t qos_stats_lock; /* Protect the qos stats */ + struct mutex meter_stats_lock; /* Protect the meter stats */ + struct rhashtable meter_table; int pre_tun_rule_cnt; struct rhashtable merge_table; struct rhashtable ct_zone_table; @@ -377,6 +381,32 @@ struct nfp_fl_stats_frame { __be64 stats_cookie; }; +struct nfp_meter_stats_entry { + u64 pkts; + u64 bytes; + u64 drops; +}; + +struct nfp_meter_entry { + struct rhash_head ht_node; + u32 meter_id; + bool bps; + u32 rate; + u32 burst; + u64 used; + struct nfp_meter_stats { + u64 update; + struct nfp_meter_stats_entry curr; + struct nfp_meter_stats_entry prev; + } stats; +}; + +enum nfp_meter_op { + NFP_METER_ADD, + NFP_METER_SET, + NFP_METER_DEL, +}; + static inline bool nfp_flower_internal_port_can_offload(struct nfp_app *app, struct net_device *netdev) @@ -575,6 +605,12 @@ nfp_flower_update_merge_stats(struct nfp_app *app, int nfp_setup_tc_act_offload(struct nfp_app *app, struct flow_offload_action *fl_act); +int nfp_init_meter_table(struct nfp_app *app); + int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, bool pps, u32 id, u32 rate, u32 burst); +int nfp_flower_setup_meter_entry(struct nfp_app *app, + const struct flow_action_entry *action, + enum nfp_meter_op op, + u32 meter_id); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c index 3ec63217fb19..f9f9e506b303 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c @@ -1,7 +1,11 @@ // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) /* Copyright (C) 2019 Netronome Systems, Inc. */ +#include +#include +#include #include +#include #include #include @@ -440,6 +444,9 @@ void nfp_flower_qos_init(struct nfp_app *app) struct nfp_flower_priv *fl_priv = app->priv; spin_lock_init(&fl_priv->qos_stats_lock); + mutex_init(&fl_priv->meter_stats_lock); + nfp_init_meter_table(app); + INIT_DELAYED_WORK(&fl_priv->qos_stats_work, &update_stats_cache); } @@ -478,6 +485,128 @@ int nfp_flower_setup_qos_offload(struct nfp_app *app, struct net_device *netdev, /* offload tc action, currently only for tc police */ +static const struct rhashtable_params stats_meter_table_params = { + .key_offset = offsetof(struct nfp_meter_entry, meter_id), + .head_offset = offsetof(struct nfp_meter_entry, ht_node), + .key_len = sizeof(u32), +}; + +static struct nfp_meter_entry * +nfp_flower_search_meter_entry(struct nfp_app *app, u32 meter_id) +{ + struct nfp_flower_priv *priv = app->priv; + + return rhashtable_lookup_fast(&priv->meter_table, &meter_id, + stats_meter_table_params); +} + +static struct nfp_meter_entry * +nfp_flower_add_meter_entry(struct nfp_app *app, u32 meter_id) +{ + struct nfp_meter_entry *meter_entry = NULL; + struct nfp_flower_priv *priv = app->priv; + + meter_entry = rhashtable_lookup_fast(&priv->meter_table, + &meter_id, + stats_meter_table_params); + + if (meter_entry) + return meter_entry; + + meter_entry = kzalloc(sizeof(*meter_entry), GFP_ATOMIC); + if (!meter_entry) + goto err; + + meter_entry->meter_id = meter_id; + meter_entry->used = jiffies; + if (rhashtable_insert_fast(&priv->meter_table, &meter_entry->ht_node, + stats_meter_table_params)) { + goto err_free_meter_entry; + } + priv->qos_rate_limiters++; + if (priv->qos_rate_limiters == 1) + schedule_delayed_work(&priv->qos_stats_work, + NFP_FL_QOS_UPDATE); + return meter_entry; + +err_free_meter_entry: + kfree(meter_entry); +err: + return NULL; +} + +static void nfp_flower_del_meter_entry(struct nfp_app *app, u32 meter_id) +{ + struct nfp_meter_entry *meter_entry = NULL; + struct nfp_flower_priv *priv = app->priv; + + meter_entry = rhashtable_lookup_fast(&priv->meter_table, &meter_id, + stats_meter_table_params); + + if (meter_entry) { + rhashtable_remove_fast(&priv->meter_table, + &meter_entry->ht_node, + stats_meter_table_params); + kfree(meter_entry); + priv->qos_rate_limiters--; + if (!priv->qos_rate_limiters) + cancel_delayed_work_sync(&priv->qos_stats_work); + } +} + +int nfp_flower_setup_meter_entry(struct nfp_app *app, + const struct flow_action_entry *action, + enum nfp_meter_op op, + u32 meter_id) +{ + struct nfp_flower_priv *fl_priv = app->priv; + struct nfp_meter_entry *meter_entry = NULL; + int err = 0; + + mutex_lock(&fl_priv->meter_stats_lock); + + switch (op) { + case NFP_METER_DEL: + nfp_flower_del_meter_entry(app, meter_id); + goto ret; + case NFP_METER_ADD: + meter_entry = nfp_flower_add_meter_entry(app, meter_id); + break; + default: + meter_entry = nfp_flower_search_meter_entry(app, meter_id); + break; + } + + if (!meter_entry) { + err = -ENOMEM; + goto ret; + } + + if (!action) { + err = -EINVAL; + goto ret; + } + + if (action->police.rate_bytes_ps > 0) { + meter_entry->bps = true; + meter_entry->rate = action->police.rate_bytes_ps; + meter_entry->burst = action->police.burst; + } else { + meter_entry->bps = false; + meter_entry->rate = action->police.rate_pkt_ps; + meter_entry->burst = action->police.burst_pkt; + } +ret: + mutex_unlock(&fl_priv->meter_stats_lock); + return err; +} + +int nfp_init_meter_table(struct nfp_app *app) +{ + struct nfp_flower_priv *priv = app->priv; + + return rhashtable_init(&priv->meter_table, &stats_meter_table_params); +} static int nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, struct netlink_ext_ack *extack) @@ -514,10 +643,13 @@ nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, } if (rate != 0) { + meter_id = action->hw_index; + if (nfp_flower_setup_meter_entry(app, action, NFP_METER_ADD, meter_id)) + continue; + pps = false; if (action->police.rate_pkt_ps > 0) pps = true; - meter_id = action->hw_index; nfp_flower_offload_one_police(app, false, pps, meter_id, rate, burst); add = true; @@ -534,9 +666,11 @@ static int nfp_act_remove_actions(struct nfp_app *app, struct flow_offload_action *fl_act, struct netlink_ext_ack *extack) { + struct nfp_meter_entry *meter_entry = NULL; struct nfp_police_config *config; struct sk_buff *skb; u32 meter_id; + bool pps; /*delete qos associate data for this interface */ if (fl_act->id != FLOW_ACTION_POLICE) { @@ -546,6 +680,14 @@ nfp_act_remove_actions(struct nfp_app *app, struct flow_offload_action *fl_act, } meter_id = fl_act->index; + meter_entry = nfp_flower_search_meter_entry(app, meter_id); + if (!meter_entry) { + NL_SET_ERR_MSG_MOD(extack, + "no meter entry when delete the action index.\n"); + return -ENOENT; + } + pps = !meter_entry->bps; + skb = nfp_flower_cmsg_alloc(app, sizeof(struct nfp_police_config), NFP_FLOWER_CMSG_TYPE_QOS_DEL, GFP_KERNEL); if (!skb) @@ -555,7 +697,11 @@ nfp_act_remove_actions(struct nfp_app *app, struct flow_offload_action *fl_act, memset(config, 0, sizeof(struct nfp_police_config)); config->head.flags_opts = cpu_to_be32(NFP_FL_QOS_METER); config->head.meter_id = cpu_to_be32(meter_id); + if (pps) + config->head.flags_opts |= cpu_to_be32(NFP_FL_QOS_PPS); + nfp_ctrl_tx(app->ctrl, skb); + nfp_flower_setup_meter_entry(app, NULL, NFP_METER_DEL, meter_id); return 0; } From patchwork Thu Feb 17 10:56:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12749766 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 5F518C433EF for ; Thu, 17 Feb 2022 10:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239448AbiBQK5p (ORCPT ); Thu, 17 Feb 2022 05:57:45 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236207AbiBQK5e (ORCPT ); Thu, 17 Feb 2022 05:57:34 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2125.outbound.protection.outlook.com [40.107.100.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53FCB6589 for ; Thu, 17 Feb 2022 02:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSof1ue5jMQe6FfZMxtPzypKRfmQaPbZ+rZ37aoetXhGFcOrQdt0LAhzyb6UfIXnD7Y4+a2Hr18JJeBWGCPZ29oW7PN7OstSjjQLqFwWyuvdRlf3vHgadIE5o3iY+FnnDMJmHfPd71XHRMVYH2IwnK3bJlD2WNDj8CkTHlzNnkx6FQsWuUnvudwfqrNP0WadfldgFjeYCM120fH5bXLkTf3iKClN7TZ5SEuvWaPCVOpJ+288cDTtvXTHdul+HIBm4ujvqepaAv6RoQBqYZZ90G9FGlNDmtp4U0mjAWaEpor5sXhyHmwnlVqBDZxI6RO0PeF0ooX8zIbaW2YeFdaOOg== 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=faMcEoGbYdrAHuaPuJoPeflXsHdX5yHik8mZ577dQqM=; b=DEeL/lrsMPNB7xZg89jXNxTkZUviHSJ3pO1aUcVLSQwKTKEAO6E2cnjxgDJmnEypENOrzCXklEv/Zo0Vw7xEby2Cycwkp80nl9JuPTSsy1at+FTOcF7OigmcSr2zUxQlQ8kyFpyG7vHp8Bmad0mahRmgK0wcjNOO0DqE5fl6/w6aZOAp3FHRrU6jxTxjUWo5ms2A1L17YLSy10yYh9nDCCFYjvudbiT00oqyMz7J++fvx4hQts7fu0zie5d8g+jYzYJGTub49vazvyXkYOjJpe3dkF0305rP6dKbcTC536WLe/5DbVAXufXf9sumcKegd1IJG+bB7VoB33C1OfaJYw== 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=faMcEoGbYdrAHuaPuJoPeflXsHdX5yHik8mZ577dQqM=; b=dgJ2xkVbfIcCHdiSmcRJM6Tmfgmei1XUaNGqGbpVu1RxdZtbPrlOnw/JDqc/GhcKvnRRakanJPjZ2Sm1etMJg5tKzuyR1zjyKNHlJPoG9tSoa/rI5md+Bnyx7dk2Cs4gXky5VHTp/uN/MDIBwunND5MqwaYYO5xifbeW60J0cZk= 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 CY4PR13MB1397.namprd13.prod.outlook.com (2603:10b6:903:136::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Thu, 17 Feb 2022 10:57:18 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d%7]) with mapi id 15.20.4995.015; Thu, 17 Feb 2022 10:57:18 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Baowen Zheng , Louis Peens , netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH net-next 4/6] nfp: add process to get action stats from hardware Date: Thu, 17 Feb 2022 11:56:50 +0100 Message-Id: <20220217105652.14451-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217105652.14451-1-simon.horman@corigine.com> References: <20220217105652.14451-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ace2d49f-0d1e-4af2-e0e7-08d9f20443e6 X-MS-TrafficTypeDiagnostic: CY4PR13MB1397:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:196; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 62/w8u6s6yI5GjhZzqrr6hiRNvuJMoJCpFh0Wc9FBPDmMzY3ogKZxkJG8DbrVcyV53nj7kVzBA9/74Jhgl8sNWl3xbRSO/fJ1g+Xr3vEya+7O63xLPy/tcMHyzeRHiomC4V0wOFNOVqxAcCZGSn4QFfEb6qxpQgkm9s6fXptnf+PxBEk6CfK8e8lIo3H+lwvMFCicF1FhG3OkPoYEQ8IBQ/2WeXWS3wGeh1ia0UHQaBXTwLZpXBRDR0YaFMkiwawWXxp/HzoFgst5XvQrVBnS43p3WqHefkCcgKpqyd5QN4+HZ+Dl8gScIZPRfsHPlq/iXe7H7PSYCpC3F5LSNAxKPA5dbP7wmGgrVbeHvz+QH0q4C05rdidKQBWpv2CrwN8nwjFIPbENvBN6Yz/QeDsn0lF2Cggguzs2m+o/vmlUJugvQpD4lx8bSoJP0I/Q3rpEU4HfGJRedp2rK65140iYAW9In4oDGswaS89VDIgWINNvLSrYD/qz95hQZnAdZ5WbAqh8zP+9T6/9X3Eb+n04HMOYYpRLfxRUmd3lDadEaJt/x+kFCVWd9bpKWjnCK9C1ALg+OnCoMSHTFarTf7lLljJziGnkuKh+9oVDS7r0crSh6MYJoeA+oRbt3u7nWWkM7KFtMmMRW1E3PUfHGoiLQ== 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:(13230001)(346002)(39840400004)(136003)(396003)(376002)(366004)(8676002)(66476007)(316002)(1076003)(6666004)(6506007)(2616005)(54906003)(186003)(52116002)(38100700002)(6512007)(66946007)(66556008)(4326008)(86362001)(110136005)(6486002)(83380400001)(508600001)(107886003)(44832011)(36756003)(2906002)(5660300002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ynacC6AGMgAgw1SbVjQzTn4I9DN/a/PJF9ms1mp6qdVTH9WWI3rf48+lx4HZ2K9o4Jukp5DyM+KpN5ZnxY7SMC9N3+QEFVWgLVWtO0WWbVzbXc3lXs57/QvPinPdB8EACrUlY5f3JmqH9ISdxefEKf/Ae5U2IxxE0kKhXU5QvFMb7JKromcgpr4d0bSc/5rqyy4L1747aC6wX01/sPBzrMF0xRCCG5DH4+hL0oyDvCsPSm1Tf1Ava7BwLCG0IkBHmGD/EoV6EDiIxw0sZy4XoguGzH0Ga5zNOWyxm1Ry7I4Z7dNylDzIEwmxtJlIuSnXbegqUytfqktZZ6xwgncE9ztBggRYHGIKHLXVDjF6YCFbB9aSFG0xVfg7g0U0OKGlB6gBTez1Qy1h8gQ3SZvHvXpnz5xzt+HDz01dZnwfBoUP8r6dcaeBf/S8bxcKLoW/rjVHCc6Y9HREX8YeNohcvo1LQTyzeaCTD5z2mrFIjvvzrTwLR53LzZfJeVyK8a9elSZw0sD0CRBCoCjCdJqa/88aVa3DOJzSEcKz7vlYohvd0TLTk488YuJ0B/RPYfjrKtZbaNeFTHH0g85IxBW2xH7Rpbp0kuyg+t7E+kvTa7MtCgJ9TOuf0BkB5t8+fNNOYY9ekyo0UXv3sD1LTcdc9OCZayJMFXQxcGToBECcvKokzDUaBhyr7w1dVqzyjhwCR3yxP9Few0B16FHlJVTPG/FvSYK3jCx7Ex6iw68fDrYaMjVZG4MNLzl1XSGt+U7LpcGOA/zAokf8TI1W7jkDV0E9vLdK0CVyEsKDla7yYCNbV7v5FTHrSOM5/bvu048FtdoiXZdaj3+KLmN3PUThEkfoeLk6ZXm7n5TRj+eno0xKuHJyZXa2i0rrLCjyNynHnmPkGX8okssczqwfm3z346Syqgzus0VuPDuZHbVvTwbef5z6iS+AjgCbD2gv/ZKEpVWhlsukhckk5zcnuMKPkIt2ktz7FdUFxUiTtYCAOwFQedJB/WR3Q8OFXX+zsl07VoTPyNRVJRmBMrhTR57HKCAbLA15N5A4R+oGZtGQDB2ME2BOQ4PikFGjAIuH845uWMaPhKPGmp+6yWYcoyffY7x+mkI++HvAdX7+x8WRC0a+cnMmukAAPe9qsIocSPpuoBijeJeqNfPZSG7RRDjzehw66NAHz4PzTkVzbbMeWRiaa1rYWL1cupHs5hbSTr81UssIRg6zhxq9kV6VFQyJCVPuHsOjkpk9GXK72arF8D8KRCtlKOFs/iYSk68Hk21pAI5OcYwz5cLco4gy3lw8G5+Yu3kq79o6Aps9zVq34PdKx9dr2QHHjd2SGlX1OayW7DAFMri2MIVvzQ3tU69/gFzznWDi0PIdR3qskkHkxptPXD3ZUnzaTh3R+bLUxE8RvN/lYoo0stfRYrtHP1vzQAs9Eq6W7J7wMIsejMJkDMEy2Vo4J7yiN3NJwGop1C3FE3unHHgupiKd5Ryv+tEAiV6jAK6e/AtDOtxexpXqTfWI7QQ7R9ALkv+i03/Y1usNp/OLI4F6OBl5dPkioRbSiuLFgp+orJ1iTDUU2Qinf3zFZm029O/QpWTJsKB8+sJ4jrs9hToz6EYdgmRkliReVYPqjU6PLr3LtEZxpPYb41hUf28Cyd2NbLKspGdIs7HJUqcgxYdbm5mzS087GNrJBdxU9UtW3EIEkZ+iK2s0YYNtFQS9thd7UiAS2fR8xWBk+O+62xjwH9o6tr9fvS+lfTsj/aUlGY8u5yWV1/JFeCE= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: ace2d49f-0d1e-4af2-e0e7-08d9f20443e6 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 10:57:18.4974 (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: FrfJSEu3lwayBxzsSyAzjpWwOh46Cd4bWTVh1MFvTHk26efk+tESnANhIzJ0ZPM7JrYI1JBppVxLocFAHQJf2yXZ8HVLETda4QsZYH74yII= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR13MB1397 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add a process to update action stats from hardware. This stats data will be updated to tc action when dumping actions or filters. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/main.h | 3 +- .../ethernet/netronome/nfp/flower/qos_conf.c | 117 +++++++++++++++++- 2 files changed, 115 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 0c28e3414b7f..73bb76a938a2 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -606,7 +606,8 @@ nfp_flower_update_merge_stats(struct nfp_app *app, int nfp_setup_tc_act_offload(struct nfp_app *app, struct flow_offload_action *fl_act); int nfp_init_meter_table(struct nfp_app *app); - +void nfp_flower_stats_meter_request_all(struct nfp_flower_priv *fl_priv); +void nfp_act_stats_reply(struct nfp_app *app, void *pmsg); int nfp_flower_offload_one_police(struct nfp_app *app, bool ingress, bool pps, u32 id, u32 rate, u32 burst); int nfp_flower_setup_meter_entry(struct nfp_app *app, diff --git a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c index f9f9e506b303..632513b4f121 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c @@ -304,6 +304,9 @@ void nfp_flower_stats_rlim_reply(struct nfp_app *app, struct sk_buff *skb) u32 netdev_port_id; msg = nfp_flower_cmsg_get_data(skb); + if (be32_to_cpu(msg->head.flags_opts) & NFP_FL_QOS_METER) + return nfp_act_stats_reply(app, msg); + netdev_port_id = be32_to_cpu(msg->head.port); rcu_read_lock(); netdev = nfp_app_dev_get(app, netdev_port_id, NULL); @@ -335,7 +338,7 @@ void nfp_flower_stats_rlim_reply(struct nfp_app *app, struct sk_buff *skb) static void nfp_flower_stats_rlim_request(struct nfp_flower_priv *fl_priv, - u32 netdev_port_id) + u32 id, bool ingress) { struct nfp_police_cfg_head *head; struct sk_buff *skb; @@ -346,10 +349,15 @@ nfp_flower_stats_rlim_request(struct nfp_flower_priv *fl_priv, GFP_ATOMIC); if (!skb) return; - head = nfp_flower_cmsg_get_data(skb); + memset(head, 0, sizeof(struct nfp_police_cfg_head)); - head->port = cpu_to_be32(netdev_port_id); + if (ingress) { + head->port = cpu_to_be32(id); + } else { + head->flags_opts = cpu_to_be32(NFP_FL_QOS_METER); + head->meter_id = cpu_to_be32(id); + } nfp_ctrl_tx(fl_priv->app->ctrl, skb); } @@ -379,7 +387,8 @@ nfp_flower_stats_rlim_request_all(struct nfp_flower_priv *fl_priv) if (!netdev_port_id) continue; - nfp_flower_stats_rlim_request(fl_priv, netdev_port_id); + nfp_flower_stats_rlim_request(fl_priv, + netdev_port_id, true); } } @@ -397,6 +406,8 @@ static void update_stats_cache(struct work_struct *work) qos_stats_work); nfp_flower_stats_rlim_request_all(fl_priv); + nfp_flower_stats_meter_request_all(fl_priv); + schedule_delayed_work(&fl_priv->qos_stats_work, NFP_FL_QOS_UPDATE); } @@ -607,6 +618,29 @@ int nfp_init_meter_table(struct nfp_app *app) return rhashtable_init(&priv->meter_table, &stats_meter_table_params); } + +void +nfp_flower_stats_meter_request_all(struct nfp_flower_priv *fl_priv) +{ + struct nfp_meter_entry *meter_entry = NULL; + struct rhashtable_iter iter; + + mutex_lock(&fl_priv->meter_stats_lock); + rhashtable_walk_enter(&fl_priv->meter_table, &iter); + rhashtable_walk_start(&iter); + + while ((meter_entry = rhashtable_walk_next(&iter)) != NULL) { + if (IS_ERR(meter_entry)) + continue; + nfp_flower_stats_rlim_request(fl_priv, + meter_entry->meter_id, false); + } + + rhashtable_walk_stop(&iter); + rhashtable_walk_exit(&iter); + mutex_unlock(&fl_priv->meter_stats_lock); +} + static int nfp_act_install_actions(struct nfp_app *app, struct flow_offload_action *fl_act, struct netlink_ext_ack *extack) @@ -706,6 +740,79 @@ nfp_act_remove_actions(struct nfp_app *app, struct flow_offload_action *fl_act, return 0; } +void +nfp_act_stats_reply(struct nfp_app *app, void *pmsg) +{ + struct nfp_flower_priv *fl_priv = app->priv; + struct nfp_meter_entry *meter_entry = NULL; + struct nfp_police_stats_reply *msg = pmsg; + u32 meter_id; + + meter_id = be32_to_cpu(msg->head.meter_id); + mutex_lock(&fl_priv->meter_stats_lock); + + meter_entry = nfp_flower_search_meter_entry(app, meter_id); + if (!meter_entry) + goto ret; + + meter_entry->stats.curr.pkts = be64_to_cpu(msg->pass_pkts) + + be64_to_cpu(msg->drop_pkts); + meter_entry->stats.curr.bytes = be64_to_cpu(msg->pass_bytes) + + be64_to_cpu(msg->drop_bytes); + meter_entry->stats.curr.drops = be64_to_cpu(msg->drop_pkts); + if (!meter_entry->stats.update) { + meter_entry->stats.prev.pkts = meter_entry->stats.curr.pkts; + meter_entry->stats.prev.bytes = meter_entry->stats.curr.bytes; + meter_entry->stats.prev.drops = meter_entry->stats.curr.drops; + } + + meter_entry->stats.update = jiffies; + +ret: + mutex_unlock(&fl_priv->meter_stats_lock); +} + +static int +nfp_act_stats_actions(struct nfp_app *app, struct flow_offload_action *fl_act, + struct netlink_ext_ack *extack) +{ + struct nfp_flower_priv *fl_priv = app->priv; + struct nfp_meter_entry *meter_entry = NULL; + u64 diff_bytes, diff_pkts, diff_drops; + int err = 0; + + if (fl_act->id != FLOW_ACTION_POLICE) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: qos rate limit offload requires police action"); + return -EOPNOTSUPP; + } + + mutex_lock(&fl_priv->meter_stats_lock); + meter_entry = nfp_flower_search_meter_entry(app, fl_act->index); + if (!meter_entry) { + err = -ENOENT; + goto ret; + } + diff_pkts = meter_entry->stats.curr.pkts > meter_entry->stats.prev.pkts ? + meter_entry->stats.curr.pkts - meter_entry->stats.prev.pkts : 0; + diff_bytes = meter_entry->stats.curr.bytes > meter_entry->stats.prev.bytes ? + meter_entry->stats.curr.bytes - meter_entry->stats.prev.bytes : 0; + diff_drops = meter_entry->stats.curr.drops > meter_entry->stats.prev.drops ? + meter_entry->stats.curr.drops - meter_entry->stats.prev.drops : 0; + + flow_stats_update(&fl_act->stats, diff_bytes, diff_pkts, diff_drops, + meter_entry->stats.update, + FLOW_ACTION_HW_STATS_DELAYED); + + meter_entry->stats.prev.pkts = meter_entry->stats.curr.pkts; + meter_entry->stats.prev.bytes = meter_entry->stats.curr.bytes; + meter_entry->stats.prev.drops = meter_entry->stats.curr.drops; +ret: + mutex_unlock(&fl_priv->meter_stats_lock); + + return err; +} + int nfp_setup_tc_act_offload(struct nfp_app *app, struct flow_offload_action *fl_act) { @@ -720,6 +827,8 @@ int nfp_setup_tc_act_offload(struct nfp_app *app, return nfp_act_install_actions(app, fl_act, extack); case FLOW_ACT_DESTROY: return nfp_act_remove_actions(app, fl_act, extack); + case FLOW_ACT_STATS: + return nfp_act_stats_actions(app, fl_act, extack); default: return -EOPNOTSUPP; } From patchwork Thu Feb 17 10:56:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12749767 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 E1244C433EF for ; Thu, 17 Feb 2022 10:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238788AbiBQK5r (ORCPT ); Thu, 17 Feb 2022 05:57:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238015AbiBQK5g (ORCPT ); Thu, 17 Feb 2022 05:57:36 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2125.outbound.protection.outlook.com [40.107.100.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8882FD30 for ; Thu, 17 Feb 2022 02:57:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDQfi519jJ9+yj1MkP7Nw0nQ6MLf8Sscw2tsV/NA1DX4EPuwqzNUmyNDoR1D7HIkJI6QSLK6lNlVupO9IPloTmCzH6XwWiR3qxFDYMDApY0+WB4/XdX6hAY1xxCUh/9g7O15BaJZs2RoDrjPd7IKJ/MNfdv/2TC5dF0zPnubc5N2IboLScePLryv8Z6OKcAKO8qUU5FdFCXfaymZQ+HWUlNVPJ2c+RfStJXAzxNb5I4sUdgRHR5pTt5UhMwk8cBOnwFPjWlQxiWYymrBg0DxOCMXEun4tpAi1VBqwPU2PeTyM5r5Ay0Hx9oSIC2Mscd3MjBDsejrmb4KCFc2E0tXmg== 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=lTdIP6ktfTVFkKhf7Q4a4/l4vYKB6cR7W+WleDBvteo=; b=K/nhDiApVHArqK34rv0ll7Kpyv4goDE6KIEgvy6NObREKNdjNmr1RRlBoz/02ljk8W2iQIa/Jw4utBmVAYBP7fRFJJKSBaDcBg1TWXOAODKVXI0VCf7vQGwU8HtYe8CLReu7XNm8DajIe4ovdfinMYW56uvdLY/RhwQph9OkPsU0qBq46DoSYtY+1iRwC4WH0xxVgUyuwPkAnj7JhH+/CIOJ8jhG/cA/osf0iI+eV5TWGWYjwVSWYPJ6bPYIB37cjPzO/8R4fOQLn1ePd3hQHaFlLA2vgV9tRsQqBJJdOf3Ztu0DOgWQBfUjUTmbKeAzclW+JVlNi48agzuEI9PBdQ== 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=lTdIP6ktfTVFkKhf7Q4a4/l4vYKB6cR7W+WleDBvteo=; b=WSQa7EPyx/RzRPshCgT5jjxjqywfaEUoT4h1a24xfk4r/ImaH/t7mduI9UIzPnspaftjIdA6aie3AivuTiM80wjZUUFDq/YuPre5OUjyuaijXMy6ttO+dyB6MEZFksvAjW5oH9zSbVKo5FldHQjtCqQbHLBvNHHnrgt5erhFNFI= 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 CY4PR13MB1397.namprd13.prod.outlook.com (2603:10b6:903:136::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Thu, 17 Feb 2022 10:57:20 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d%7]) with mapi id 15.20.4995.015; Thu, 17 Feb 2022 10:57:20 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Baowen Zheng , Louis Peens , netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH net-next 5/6] nfp: add support to offload police action from flower table Date: Thu, 17 Feb 2022 11:56:51 +0100 Message-Id: <20220217105652.14451-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217105652.14451-1-simon.horman@corigine.com> References: <20220217105652.14451-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12a152ee-521f-4420-16cf-08d9f20444ed X-MS-TrafficTypeDiagnostic: CY4PR13MB1397:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: prwyhn7k2Mv5cq1INwxle6YMQETjWWDKfL/mw8Eq/uaq2PqDXd7fi6h6SLGnP3/zFmh3t++3tH7BzQOqETKKr55982iOmukdwwRnW0cJdAsmgew3rd7+vN6MSvVIeyIswjb9kpQU4EJmSvXypLMdokeFHeFM1C5GyBdCmPsoMS9gPaRrYcdlYRhlmoFpiC4fi2PjbGDUSBwGiu97cra42Gl2GcTyF+EYdbFRWSAg5qxhhnXWuAYE7GEBes9CBOX+z5RrJP2Cse3+T0Np2O2X590TpBVYQ6CDf5L6IAMtHGYcsBefquIhsKoHVPdG19SSjkPK6gILXO/1Op0UY+I4VgsXlF5O+LXeNhoKID3Mx9yBGHitnxn+k8MOe1v1zqcThOmJHqW+vInKe7j1Vjlm0p8Iq+f3ppTMcq0fvp+gwgjLao9mypPoY7lhOmkAP7CItcTqbJpjCByvNYR7YH00CNyciidUM7kWBWIDhol5Mprn5eBFsCdvy1TE8rEy//JtO1okGMn/9hA3qBOcXHTsrZ7T8gGkIrIFsPaL2OT4y2Ozwga6C1z2MBRA9HGb3Q9Xt9WGlomFkowLIcaizwgtakFeAJDJwNOdp6+ejsjGgGYi5Osx9lcX7S7kIYvWDJABnhDspEnSysXN3RO7VzwBhg== 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:(13230001)(346002)(39840400004)(136003)(396003)(376002)(366004)(8676002)(66476007)(316002)(1076003)(6666004)(6506007)(2616005)(54906003)(186003)(52116002)(38100700002)(6512007)(66946007)(66556008)(4326008)(86362001)(110136005)(6486002)(83380400001)(508600001)(107886003)(44832011)(36756003)(2906002)(5660300002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NLITpGWfM7vKooEeb5X4VGZjoFxyvGOvaZhiysVzLxf2XFGRBUutFFJyvBhyxllzsUr9kwqKlDrzujklYOrs0I24KVFiTwA8gtIXj0uX/VUBexQlPzXpqGqVRoucfB8TeIqWXOS3c1ihwYs/kdS+dJ7KYUWoNU75hNqH8iEfUuIg0+pRITzVc0OMKR4dC5SRqAA+cWTyGpL/90naixmNYdR1mT8Gx5AdKOG4vWGI5DpTWnGHHko/t5C+1IvkKAjb9XYMqFTGTis/LniHmsRQect9111gq3AGUfGsflw+dzmDSqssMbGcrN06KvYdGW9igrnV3I4e48OUuDto6MFOaLw3rcpJR3rLSnhPZ2TVB8MutpM7VjakmnuQAkFLPgy1SIv0udtj5e8W8Fjvd1wnz1KmRhot/+5kC53ZFN5Ay3XN3R0oT09nFVEZE7dAfwjtTx6FVnlQsQKQGwTNFlw+JgJ6sqJh288m2XDbMc5IfxLD/O4Ql+Wnr8mXTjG8bhcwJgHk637Pxp1LEMiTuHo1rZPE0qozHJxPHeOTWRvXIK2abdEvENEUB5lH1oKlbY9oxRoqtwJmTdY/lk0jOSRPOc1oKVcqP0xTNOCCUHhQPAOQJ2KFlS840+CtloRxH6R32gm2Qcxgkx9+nB2IyMTN2kNC0e2eI274Ah2EgMXfeVLaUhOQNDq6EmSKy5sRPfN9EeeWPsmvsDR8olCYzBQIno4Vnzg281s57I+ZzESqQ0yn3Il74JPR/MgA7VRvpqBEsdDOp+vwYL/cR2bPvAzRMsbViYXiZqEf8eHHJjmaQvFd5D7dMDl7b4D84RGU3s0XfGzFKfa+E1PhKo4MEMtzErwX7acwsXm3slLOQCT8PyVNQ7vb9BFzfI5d6Te2r6Vg3caEsksUnOS9aoNe/ddZoc6KmaDgDHjSySc1nUgYlLBiIVrS/r6GsqI5ZuzcaZyTaRpbKFsjPYwynt10uIO08oIdg5fpNhl3X0dNGzBFHzm/HTnpUEbdaO4sbhm/nRVxC1p2RtLK6LrAmLTlo4QAtVQvk0YE5Td4GRft+RsZeoxGG5Fjl1+YGWJ3zdZ0SB1qv2L0qyLVgVPzConIuPwbEKIUOu+PxuGyZg5G3jrlE4xT9QXoNv/Aqi1k2Tby5U7qgPfyE+iEx/KLHebshxRK6tycm70rDRkfrCk6p6sG7NQouYv52QJkF8IgXMU0fPzMdVg16WiqoplwrRYTWHLSUy/RDH8CX9+FXo5Qkcq9Pp/Mq7ouqOz9uLRXYUqom0p4Wx1bX78udYjAfw3KlBLS+IyHpfxACE+nnsKTpPzIMWJz7Vekpqmoy+dBvj+6hxcYT7KypXGg0XZitZ9w1kgocE2sAP2AZILM+Gy6JRSvzUpfjHasIRqNUhS1riN5kNJXYESGlBoA+jyS4PHMCShd7kaySxneVzIDEvj8QnzqMvJ8rqysQTOS2gCJTwQD5l6LCZJSmdJCICRlMVcLlno7nxaC0McYws+r56gbeXV82f2Z+CRhiZ4TsUrlBRjLZG+c9lkFdo13fGUO7Wnp7/i9sJvsHhTJy4niqRqIRp+RvjT1D4uhWiEMEOpYaTzUzPo9sPuo2Sh/fg5ypL/G4l+wEbsQBA99hKznEK/LcsrUBhblaaVW/8HrTVyO4DlYN2YkVgJ0HQ+KyFipHo+k2rViOzwCK0RftEAtBUlWSYgLf2nvcPZ5JLOWks+YzCF/5x73uH+8nZ0kha8rHPFYAbBK+s+sPQgTtQ5aTLarwSvxzZI= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12a152ee-521f-4420-16cf-08d9f20444ed X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 10:57:20.0752 (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: lFVPxQ6m5zEVn67gbCu0a19DqnGhGdQA2HwhUYy+BGIZhPRzc6kqjDfjyU/GTKwD+lmVG7lXM9mi0p7EZbsJgyFB+Cgrw/kpdnlDTnMTjEs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR13MB1397 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Offload flow table if the action is already offloaded to hardware when flow table uses this action. Change meter id to type of u32 to support all the action index. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/action.c | 58 +++++++++++++++++++ .../net/ethernet/netronome/nfp/flower/cmsg.h | 7 +++ .../net/ethernet/netronome/nfp/flower/main.h | 2 + .../ethernet/netronome/nfp/flower/qos_conf.c | 2 +- 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index a3242b36e216..2c40a3959f94 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -922,6 +922,51 @@ nfp_fl_pedit(const struct flow_action_entry *act, } } +static struct nfp_fl_meter *nfp_fl_meter(char *act_data) +{ + size_t act_size = sizeof(struct nfp_fl_meter); + struct nfp_fl_meter *meter_act; + + meter_act = (struct nfp_fl_meter *)act_data; + + memset(meter_act, 0, act_size); + + meter_act->head.jump_id = NFP_FL_ACTION_OPCODE_METER; + meter_act->head.len_lw = act_size >> NFP_FL_LW_SIZ; + + return meter_act; +} + +static int +nfp_flower_meter_action(struct nfp_app *app, + const struct flow_action_entry *action, + struct nfp_fl_payload *nfp_fl, int *a_len, + struct net_device *netdev, + struct netlink_ext_ack *extack) +{ + struct nfp_fl_meter *fl_meter; + u32 meter_id; + + if (*a_len + sizeof(struct nfp_fl_meter) > NFP_FL_MAX_A_SIZ) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload:meter action size beyond the allowed maximum"); + return -EOPNOTSUPP; + } + + meter_id = action->hw_index; + if (!nfp_flower_search_meter_entry(app, meter_id)) { + NL_SET_ERR_MSG_MOD(extack, + "can not offload flow table with unsupported police action.\n"); + return -EOPNOTSUPP; + } + + fl_meter = nfp_fl_meter(&nfp_fl->action_data[*a_len]); + *a_len += sizeof(struct nfp_fl_meter); + fl_meter->meter_id = cpu_to_be32(meter_id); + + return 0; +} + static int nfp_flower_output_action(struct nfp_app *app, const struct flow_action_entry *act, @@ -985,6 +1030,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, struct nfp_flower_pedit_acts *set_act, bool *pkt_host, struct netlink_ext_ack *extack, int act_idx) { + struct nfp_flower_priv *fl_priv = app->priv; struct nfp_fl_pre_tunnel *pre_tun; struct nfp_fl_set_tun *set_tun; struct nfp_fl_push_vlan *psh_v; @@ -1149,6 +1195,18 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, *pkt_host = true; break; + case FLOW_ACTION_POLICE: + if (!(fl_priv->flower_ext_feats & NFP_FL_FEATS_QOS_METER)) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: unsupported police action in action list"); + return -EOPNOTSUPP; + } + + err = nfp_flower_meter_action(app, act, nfp_fl, a_len, netdev, + extack); + if (err) + return err; + break; default: /* Currently we do not handle any other actions. */ NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list"); diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h index 784292b16290..4518ee90afef 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h @@ -85,6 +85,7 @@ #define NFP_FL_ACTION_OPCODE_SET_TCP 15 #define NFP_FL_ACTION_OPCODE_PRE_LAG 16 #define NFP_FL_ACTION_OPCODE_PRE_TUNNEL 17 +#define NFP_FL_ACTION_OPCODE_METER 24 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE 26 #define NFP_FL_ACTION_OPCODE_NUM 32 @@ -260,6 +261,12 @@ struct nfp_fl_set_mpls { __be32 lse; }; +struct nfp_fl_meter { + struct nfp_fl_act_head head; + __be16 reserved; + __be32 meter_id; +}; + /* Metadata with L2 (1W/4B) * ---------------------------------------------------------------- * 3 2 1 diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 73bb76a938a2..898abb68b80b 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -614,4 +614,6 @@ int nfp_flower_setup_meter_entry(struct nfp_app *app, const struct flow_action_entry *action, enum nfp_meter_op op, u32 meter_id); +struct nfp_meter_entry * +nfp_flower_search_meter_entry(struct nfp_app *app, u32 meter_id); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c index 632513b4f121..6da24c457ab3 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/qos_conf.c @@ -502,7 +502,7 @@ static const struct rhashtable_params stats_meter_table_params = { .key_len = sizeof(u32), }; -static struct nfp_meter_entry * +struct nfp_meter_entry * nfp_flower_search_meter_entry(struct nfp_app *app, u32 meter_id) { struct nfp_flower_priv *priv = app->priv; From patchwork Thu Feb 17 10:56:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12749768 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 721C1C433EF for ; Thu, 17 Feb 2022 10:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236300AbiBQK5u (ORCPT ); Thu, 17 Feb 2022 05:57:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239446AbiBQK5p (ORCPT ); Thu, 17 Feb 2022 05:57:45 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2137.outbound.protection.outlook.com [40.107.244.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849BD295FC7 for ; Thu, 17 Feb 2022 02:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bTYEdulTOs8scnSHJauNZGfECtgnUn1pROcf74j0MGJO7O+YWYRMpkE/wuzMq/g4vAqUD7YiwKwpsvJc0/zUIIbASD6LzILtHd2TtoG4NK9jhLzLc9ZHXbfJr0twf2IlcKb2lqD+SqEQm+7VxpQJXx1LOCNcQZxdWZwW0Vw+WBSttPQXyyuAPs8+XUpVnV6RWzWUedCyLqppMW+vjAirdiFAakrsQKlea+wFxlC/qBgIf5filnyq+tW/T83DHD+f09811DH4Zidh0i8+Ejg7FYrXtT7x+SpoWwhZx6I0Hh5/ntGBTyXYSmdg3e5aq6XfqzWGWrTAZByU0gdhiOu2uA== 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=I0/JA8BlNkcs2jLZt2RzbRrCognUoYwHT7FGSqVynaY=; b=KbeuFllqeRXoOoYvY6NXKkCQpYuEKj//YrFfz3GLsrJk9/UYEypPCCjoYhH7OHZuYBCQqgx/qSCtSDaVvCriVFgNhtH2jdQECSq4SzlfBZhSR3+bkCeDoKT35eBQa8x72NtVDpq25yKWdU61Su1+7X03QLW5MnebuQqhpJUUUeGa3VkEMqBuGfBrkNaHi2DWDTZ7x9KDGPNvTqrQ+ugChmkDII2Hm0+qPDG/tBNe4xXfEHoti/exSmzz4J/70yrCwXogf4Nor/NZSQqQK7+fD4Zd+U6Vvn2+VR9zD0J+2Ok3FDnpwaVAu+g+3JGF/8ZEwsRGMMABmyIUuFtRbSmTFA== 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=I0/JA8BlNkcs2jLZt2RzbRrCognUoYwHT7FGSqVynaY=; b=Wkbf6kdC4jtBFEqbqxpGVKF8MPdCP9waUf8v1tFVOjb/iFH9xmh7BLZ9ZeGctY+NFTiUazW1U0F9LySbNiLkGmoHtmRDVxo18LBbqhQ731BHIDI+umXMHBpLgoKNPu/aBXBr1aNoY0MCNBcM4WnvCTwDJ6ocZuAoDuysjixZa+8= 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 CY4PR1301MB2040.namprd13.prod.outlook.com (2603:10b6:910:48::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.9; Thu, 17 Feb 2022 10:57:22 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::7037:b9dc:923c:c20d%7]) with mapi id 15.20.4995.015; Thu, 17 Feb 2022 10:57:21 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: Baowen Zheng , Louis Peens , netdev@vger.kernel.org, oss-drivers@corigine.com, Simon Horman Subject: [PATCH net-next 6/6] nfp: add NFP_FL_FEATS_QOS_METER to host features to enable meter offload Date: Thu, 17 Feb 2022 11:56:52 +0100 Message-Id: <20220217105652.14451-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217105652.14451-1-simon.horman@corigine.com> References: <20220217105652.14451-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31508f23-d3ef-45ca-05ce-08d9f20445de X-MS-TrafficTypeDiagnostic: CY4PR1301MB2040:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2nKVrBsGUeKlqwgy09CbM4JCv7P4kFhLmpCCibBA+MpT3edfZh2zkz+dmp6Eg7UpNlLc7dNzgWnqku4tWveJTAZPi+YNS7ntif81Lcz1BDRFzB4Yk9XvrGkAsmypEZT35cgsvhh9QeXC/lAGmBd3W/PgtHZgK3TtcdGQqyod8NO1UfKtuE9uyaOiYujSjOtZXVuk/SM+EuMYNf7rOftAjy0Xy4XIGywzFzDEE/4GbNMMCl6gYNRrn+NdA255mniv5/ph4RW+5Em/UMovcn4ACOoa357Vii+4h8q7kEOBB+Jg+FNCHQ0hDLbKBu8u0hpKRmGABg1f92q53Cxju6LIW0FWceJwGxxYyfgAdVTzEtWBNKmLTYCC3M1vSnW7hksO1SW5/iU3Ni/2V4Cp4wtNhaxRDUAVVSBh/LVc5i7Dy5fStzZRHJ6kUBT6yrtlRN8hlJ4ONoo5wH3f4ZwDfCzrNKxTGxph42WPddvC4fD98OkmsuOT2xY0ATRxiX86erCzrLUFmhd3lgJor9CzuqtHCvYSnyAzI4uYW8GJFIPh1zSp3QqU5k7z2RDDyiLzetga3UCBGtcGJzE3hakfe+uA4aWL3OPfGHzJmjaBuaCPL6w4+g7PFR6jjkGTI4nr5/Tq0VgWL44/Z5V68r3M8Hysk5LBMUDAQ+pPj3wRG1IughVZoAzv7zt0rJsK+s3o0SEF 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:(13230001)(396003)(376002)(346002)(366004)(136003)(39830400003)(8676002)(66476007)(66556008)(4326008)(8936002)(5660300002)(66946007)(54906003)(6512007)(6666004)(6506007)(316002)(52116002)(44832011)(110136005)(36756003)(83380400001)(2906002)(86362001)(38100700002)(508600001)(6486002)(107886003)(1076003)(186003)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1hHSy0tUKQo9jSHXYwFW1ts53wGm2U+twqd9I2cv3JChnyTQZ75/4J1hmXJy9/IKfmreUSzTUuSkw+zW/iYaBIRnsQPmKRaGAy0B6U6xKrVe1yGaugd+HlEDgHYcGtLWoN84gzAf+pW/6sOCQa/UZP3ubNUOl9Wr6Uw30qYDnFzLS+470gATuLzBbmuyxC7eWQmgWwerzHI2YQq6Ol0UtvZRN1m2HyXxr+928sH7UUY7VtbRdnLPgMpnB+yhdhBRthKiwCei/bJ7xWU7kR2xvMRqnQAb+ICjVv5Gienqd7x7URtZIl4xUbBq3AhWZ8hm5Zg+XKr5Mv2N5pdQdk7pYZKVeOmc5cHQrMRKbnee7xQ3i3+kHWvDSUxZGp41tYB1SqPYeltGBuhT8qElCvazW2rnz8HJGnT6YCMMOKEU3l+4BBUo21KNTErbXrtlxUbxrOlDJePCcLbPMA8HocTMaVGD9liTFL4DWf8jd8eNLc0ttfmF/OZqyiApPQoIo9KjGb4vgWlRmh0dYPe3OVGdvUCtKtf2c5w6DEWWl/7aN9QzoEanSwZoFh07apezPnzEU3OqdtfAt5rlPfx9NmuY/A9bMrEws1MwMtlU3JNaEj4XikkaatfmRuSGyF7w55j9G2E+XR5PMYxoCFt/sCNWxPHKIofPA7Zdcre4kWM5vNtjjQ7dbT/wG0B+3aaORUxBheJiR2SHttlNanjD9Rrm0FjaNZrOveBvQGKsVQJMaSnH2zurtCExliPLMK7EYRwhdkYgvBLqKJ4teIHPNPi0xNeD1H46KweKWQV3tvgTkjptvzhaVpuWeLZMNHRLU2RgJshlT/6GpAMX7MqCR7TcLCql/h7fZ9Dxdr0/FjTT4IU5bacH+fOTNJJFwGd2lbRquPlt1ehTqTxTQbU2DoaXbdIXPCVLuuo/ugFQc78Rep9kqyWcbPliK2UmUKm4E9PwWIohNsE9eiQstzbJxsH61f+Zby6LXSoULrO7UABU1CPivLn8xzdWz0SlUAz/NMNLLe5W9MYXBp/4OOU6GuI9Bgt7uHodWNm1FKe0mCT66e/4HGo4RVtXEWiu8kX+v/gLDQpMeFFiQ5YJfOr7mCF4f5IKrpY1CL+96HHWGHBj6XcbpeOP+P92Hku0HyHVQsRaVFUocgLdXcFpZMOn9RknyvQfNNxCuwZOLlP6rLUqahbAbVKxn3lYyYBXGWJpyr0S8ESofx6OYr0lg0bUMyjaCvilYwIPq4S5xxaDDScK/tUCr/TpRj57Ei5QZCl2XZYIv+iFuJZfd9Y3vq+sw3s79sOi3dVEmunp7r/IcaoCGiWK/SX+k/VGqp+ioYJK75x0x+I2gnTLmfIv4blQZ+6OwwyuIQcm2BKYBrSODwKkeFJRFZz6OJR8AuelJcltpWjwsT7rIScZugAjLLfCUgTMpBO3L/D6UZ41oNug55YGTPyWxBQQv7LRbY6A15begPxb1SKwOt4ZbPtrx0YmeHA0tJoEPflBy51CGD1AeNx9fdCd2rHHmEt8Wu8skzEYqzN8+qf/d2Djq5kJdkokYdA9lCpikUEEKkINkKCQPNDtsNrfVK2svjxMZdqcfK4DumTxBHd+nptL4W/mR/jQ+yWAOSDmaQosG+SkuPp6rB9ZuKS1V9lQYasKWQ/tJA+X9gfidBTw/qfZJn7JQIlfcppQAOxSGElPSQa04wFyTQJIksmXtMh3Cv66S/vCiiUFVf+Z5uvt0Dt6/Ban8hMmWXn5UA+bKHR35cOT1A6Nx3oDRV8= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31508f23-d3ef-45ca-05ce-08d9f20445de X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 10:57:21.8417 (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: L/52N7yUo6SsXvXdRALBogwAP9eM+xXY5Ma7anmgRf0tEv7d46qKISAW1R1Oh4QQ9uHHdH4UGG9b3tdL+ZP4FeNdIQ/BeIB2lGlY6cq/ByQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1301MB2040 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Baowen Zheng Add NFP_FL_FEATS_QOS_METER to host features to enable meter offload in driver. Before adding this feature, we will not offload any police action since we will check the host features before offloading any police action. Signed-off-by: Baowen Zheng Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- drivers/net/ethernet/netronome/nfp/flower/main.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 898abb68b80b..627d5155e376 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -66,7 +66,8 @@ struct nfp_app; NFP_FL_FEATS_PRE_TUN_RULES | \ NFP_FL_FEATS_IPV6_TUN | \ NFP_FL_FEATS_VLAN_QINQ | \ - NFP_FL_FEATS_QOS_PPS) + NFP_FL_FEATS_QOS_PPS | \ + NFP_FL_FEATS_QOS_METER) struct nfp_fl_mask_id { struct circ_buf mask_id_free_list;