From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3D120A00C3; Wed, 7 Dec 2022 03:18:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9432E42D39; Wed, 7 Dec 2022 03:18:35 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2111.outbound.protection.outlook.com [40.107.92.111]) by mails.dpdk.org (Postfix) with ESMTP id BE1A0410D7 for ; Wed, 7 Dec 2022 03:18:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BkiFRRdGRu4aiHUTEcl275QGNOmqy/XE9nR+Xg7ipEEUz82VohogXcTJTSx4p1GhWKUuv2GpAlIQDMO86xWXoEqgGHGM4GNHkP7ZZtXB43Q3bcBKL6me3TFCQl+QzE0/JzfdhJdILxDDQ+stM/1h2Rrx/Wrvww0ZLIOuAuYCopbohTD9cNayRIQOLCRgMmqvt64942kUc8zcXHsrdaM1S/qph9cafgt3tnPhAG8Af3MuB3p37Csz2Ksi/4ZjlHZz5h3ux3CIRl8bbe66nYvuN6VbyJWrDb7kxmSIuz/uP02+SXZ9hdd8bksWfGYPLUtToVBqyxnUvMuPu3fHofVkig== 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=honnHYp+4dI6I5V+S6Hum5l3l+nMSXZuAfPUiATLH4o=; b=b52x6N0QUMICATx5HbsvYvu9rwC/gUUQ7ZTKJmxYs4DZ0PhZY0fdgTbkV3/B64W1OzrMbAiVCCSFXFCal4VOGSXNPxJrlpuQMq+Zzm8iSShMOr5WdBy9B6o8uEzxHK6Ckj6cNJ2ayDz+M8ISzMCNfGf/7OBQBapmy5S2zIRyjAdkKbhxwuctSsNdJw7bQK1t4F2bzQE+k+n7CCBT6OKqjm3RTcKBdtFdoEt2plsJz42UQ0d08793gNHRZO7h8+Illf6KKFB7XKocqymucScKGddqyO8Z/qIQwKF4C4vpxtft1vqXBvRs02tleNoayaib1aadEFE0BdxoYnJqxNYh1A== 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=honnHYp+4dI6I5V+S6Hum5l3l+nMSXZuAfPUiATLH4o=; b=i3As5eDC9vROxI84iwWvXIMTROtygVsbrJmsvq6YvljuPo7zwp8BnQK4z2MOKfMwOoaDh9gVp30uyXHpfanr0ZxZYnWVxujUsMvOO+KCvDHpKQSTe5k9PP0Z5vntzYpXcqUpk8CwUL5mCLrbdilkG16mAoL+B0EqaHLlYye5uaU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by DM6PR13MB3785.namprd13.prod.outlook.com (2603:10b6:5:244::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 02:18:32 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5122:8c31:51f3:4ee7]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::5122:8c31:51f3:4ee7%4]) with mapi id 15.20.5880.014; Wed, 7 Dec 2022 02:18:32 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Jin Liu , Peng Zhang , Chaoyong He Subject: [PATCH 6/6] net/nfp: add meter action logic Date: Wed, 7 Dec 2022 10:17:48 +0800 Message-Id: <20221207021748.40143-7-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20221207021748.40143-1-chaoyong.he@corigine.com> References: <20221207021748.40143-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO6P265CA0021.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ff::14) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DM6PR13MB3785:EE_ X-MS-Office365-Filtering-Correlation-Id: 293af0c9-b792-4d91-8357-08dad7f9561d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dElhtmLh/Cc/HHakypmVFSIy9bsccGuRnrC55LLN47Ai9cKqWNdtFuuwXFXBxTGtlc2Q3MokCtI5vKtj80imQM/2bym3tdAf8mBHCtWbv2KbmWd2A1qZqRsiaoxrzkJ52T2KQIS0ueSXh4447v3+SmXMVFIZuzYr+3ypVR2rxUuEw7nlm8+uiYCpm/AeSW1tmS4CcsnZoie6Fc6joaO2NeKCT8qd1yrNfPhZ2JIrDfPtX2c9AlVJPdoRqBkpRQ2nhIIzgLLbCMd5Oj/fjUCIsI28isc0BAKyKZRL9YEoRt0useQRg9nrD00Kvg35LxGSYyS/Pg3fF8vSOhcQ5QgObpaUaQYsmw57grYu35HhB/0ljGmKgdXecMskXoWUuB5IOXVIP4ejs4cY4kb1avcBVTmTPjI63Np+IWXQnc/CzL7dCxv320QakE6PeQ+GA6qeCaTF9elKUPL4iShA+BvcqUzDoN5DVABwFmgLfk9/I46wtS+7J+pxaN30RvHjO1vRAM8ZUFSAvzNKLzH5NB3NoZb+IGJMPq9pKB8QP5frayiyXMx/9OGZIMTWZZxQnzuDmTEsOE+mooJJx1wMXA+0t2D/NvcyOZFTEukwu2QwU1h/NdUCWKZWUGPP+a/w9Fn4v9S+h2Bs7DxEiDm1wOjz5058e1YPxSenAMaF1b9/0YiqCEBfGyL66mFlS8JXMiPF X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39830400003)(396003)(376002)(136003)(366004)(346002)(451199015)(66574015)(6486002)(478600001)(52116002)(6506007)(36756003)(86362001)(2616005)(26005)(83380400001)(186003)(1076003)(38100700002)(5660300002)(41300700001)(8676002)(38350700002)(6512007)(107886003)(8936002)(6666004)(44832011)(66946007)(66556008)(4326008)(316002)(54906003)(66476007)(6916009)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L1JnSThDR04xYm1pdGdNMTAxWHY5VlpPNzV6ckZjTTd6T2ZKRThwWFNNbnYz?= =?utf-8?B?WTY5QUNrUDJUdHI5dG1tYWd3NFVHZk5TK0lLQWp0Wk5DRTg1TDd4d2JkbGZi?= =?utf-8?B?OWJxZVE0b3NIVkxHZkdxbk9VMFRvMEVNRHViUW9BSyt2NktNYjJMSS95OGIr?= =?utf-8?B?ZnJ5M2F6UnU3eXQwaXF1N21tY1R6Mk5mZjJVdkdwbVA2dmkzbTh4MVZ6b1ly?= =?utf-8?B?V2c1NmhlVUc4aXlRZEJzbThJRlk0SU1CcmJ1cG9wQTVwMlBwNm1neTg0RFNG?= =?utf-8?B?dldnS1RJV1RKTTJWZTJFSnpCYWdQMi9nQ1Z4N3RYZGx3S0M1UFVlWmxrZUhl?= =?utf-8?B?Z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JMSDRBVUVXL1ZM?= =?utf-8?B?MWc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 293af0c9-b792-4d91-8357-08dad7f9561d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 02:18:32.2011 (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: PJoQdnuo6ODC3qubtCw0BFLH4fTU01zJaPtrKCNHj1QGSAi96IXUEjeUO8K6F2mtSRWs7vf+KbL+QeJoWirrnocwh7Sv2J5d4NIndlGVdaE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3785 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jin Liu Add the rte_flow meter action logic, flow with meter action can offload and work well. Signed-off-by: Jin Liu Signed-off-by: Peng Zhang Reviewed-by: Chaoyong He Reviewed-by: Niklas Söderlund --- doc/guides/nics/features/nfp.ini | 1 + doc/guides/rel_notes/release_23_03.rst | 1 + drivers/net/nfp/flower/nfp_flower_cmsg.h | 16 +++++ drivers/net/nfp/nfp_flow.c | 86 +++++++++++++++++++++++- drivers/net/nfp/nfp_flow.h | 1 + drivers/net/nfp/nfp_mtr.c | 16 +++++ drivers/net/nfp/nfp_mtr.h | 2 + 7 files changed, 122 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 9e075a680b..a4eb760675 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -44,6 +44,7 @@ vxlan = Y count = Y drop = Y jump = Y +meter = Y of_pop_vlan = Y of_push_vlan = Y of_set_vlan_pcp = Y diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 0ce6fbf8ee..2c45e1f09f 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -58,6 +58,7 @@ New Features * **Updated Corigine nfp driver.** * Added support for meter options. + * Added support for rte_flow meter action. Removed Items ------------- diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 2f4cd68730..96e080a8e9 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -901,6 +901,22 @@ struct nfp_fl_act_set_tun { rte_be16_t tun_proto; /* Only valid for NFP_FL_TUNNEL_GENEVE */ } __rte_packed; +/* + * Meter + * 3 2 1 + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | res | opcode | res | len_lw| reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Profile ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_fl_act_meter { + struct nfp_fl_act_head head; + rte_be16_t reserved; + rte_be32_t profile_id; +}; + int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower); int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower, struct nfp_flower_representor *repr); diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 6f79d950db..ab9a9c23f5 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -356,7 +356,7 @@ nfp_flow_alloc(struct nfp_fl_key_ls *key_layer) goto free_flow; nfp_flow->length = len; - + nfp_flow->mtr_id = NFP_MAX_MTR_CNT; payload = &nfp_flow->payload; payload->meta = (struct nfp_fl_rule_metadata *)tmp; payload->unmasked_data = tmp + sizeof(struct nfp_fl_rule_metadata); @@ -866,6 +866,7 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], struct nfp_fl_key_ls *key_ls) { int ret = 0; + bool meter_flag = false; bool tc_hl_flag = false; bool mac_set_flag = false; bool ip_set_flag = false; @@ -1012,6 +1013,16 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], case RTE_FLOW_ACTION_TYPE_RAW_DECAP: PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RAW_DECAP detected"); break; + case RTE_FLOW_ACTION_TYPE_METER: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_METER detected"); + if (!meter_flag) { + key_ls->act_size += sizeof(struct nfp_fl_act_meter); + meter_flag = true; + } else { + PMD_DRV_LOG(ERR, "Only support one meter action."); + return -ENOTSUP; + } + break; default: PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); return -ENOTSUP; @@ -3232,6 +3243,48 @@ nfp_flow_action_raw_encap(struct nfp_app_fw_flower *app_fw_flower, return ret; } +static int +nfp_flow_action_meter(struct nfp_flower_representor *representor, + const struct rte_flow_action *action, + char *act_data, + uint32_t *mtr_id) +{ + struct nfp_mtr *mtr; + struct nfp_fl_act_meter *fl_meter; + struct nfp_app_fw_flower *app_fw_flower; + const struct rte_flow_action_meter *meter; + size_t act_size = sizeof(struct nfp_fl_act_meter); + + meter = action->conf; + fl_meter = (struct nfp_fl_act_meter *)act_data; + app_fw_flower = representor->app_fw_flower; + + mtr = nfp_mtr_find_by_mtr_id(app_fw_flower->mtr_priv, meter->mtr_id); + if (mtr == NULL) { + PMD_DRV_LOG(ERR, "Meter id not exist"); + return -EINVAL; + } + + if (!mtr->enable) { + PMD_DRV_LOG(ERR, "Requested meter disable"); + return -EINVAL; + } + + if (!mtr->shared && mtr->ref_cnt > 0) { + PMD_DRV_LOG(ERR, "Can't use a used unshared meter"); + return -EINVAL; + } + + *mtr_id = meter->mtr_id; + + fl_meter->head.jump_id = NFP_FL_ACTION_OPCODE_METER; + fl_meter->head.len_lw = act_size >> NFP_FL_LW_SIZ; + fl_meter->reserved = 0; + fl_meter->profile_id = rte_cpu_to_be_32(mtr->mtr_profile->profile_id); + + return 0; +} + static int nfp_flow_compile_action(struct nfp_flower_representor *representor, const struct rte_flow_action actions[], @@ -3435,6 +3488,14 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor, if (action->conf != NULL) nfp_flow->tun.payload.v6_flag = 1; break; + case RTE_FLOW_ACTION_TYPE_METER: + PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_METER"); + ret = nfp_flow_action_meter(representor, action, + position, &nfp_flow->mtr_id); + if (ret != 0) + return -EINVAL; + position += sizeof(struct nfp_fl_act_meter); + break; default: PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type); return -ENOTSUP; @@ -3685,6 +3746,18 @@ nfp_flow_create(struct rte_eth_dev *dev, goto flow_teardown; } + /* Update meter object ref count */ + if (nfp_flow->mtr_id != NFP_MAX_MTR_CNT) { + ret = nfp_mtr_update_ref_cnt(app_fw_flower->mtr_priv, + nfp_flow->mtr_id, true); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Update meter ref_cnt failed."); + goto flow_teardown; + } + } + return nfp_flow; flow_teardown: @@ -3777,6 +3850,17 @@ nfp_flow_destroy(struct rte_eth_dev *dev, goto exit; } + /* Update meter object ref count */ + if (nfp_flow->mtr_id != NFP_MAX_MTR_CNT) { + ret = nfp_mtr_update_ref_cnt(app_fw_flower->mtr_priv, + nfp_flow->mtr_id, false); + if (ret != 0) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Update meter ref_cnt failed."); + } + } + exit: nfp_flow_free(nfp_flow); diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h index b0c2aaf6d8..b8da752a9d 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -222,6 +222,7 @@ struct rte_flow { struct nfp_fl_tun tun; size_t length; uint32_t hash_key; + uint32_t mtr_id; bool install_flag; enum nfp_flow_type type; }; diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c index f77381dcb3..356bcdb370 100644 --- a/drivers/net/nfp/nfp_mtr.c +++ b/drivers/net/nfp/nfp_mtr.c @@ -1125,3 +1125,19 @@ nfp_mtr_priv_uninit(struct nfp_pf_dev *pf_dev) rte_free(priv); } + +int +nfp_mtr_update_ref_cnt(struct nfp_mtr_priv *priv, + uint32_t mtr_id, + bool add) +{ + struct nfp_mtr *mtr; + + mtr = nfp_mtr_find_by_mtr_id(priv, mtr_id); + if (mtr == NULL) + return -EINVAL; + + mtr->ref_cnt += add ? 1 : -1; + + return 0; +} diff --git a/drivers/net/nfp/nfp_mtr.h b/drivers/net/nfp/nfp_mtr.h index 7bfc935e7d..41c472f139 100644 --- a/drivers/net/nfp/nfp_mtr.h +++ b/drivers/net/nfp/nfp_mtr.h @@ -176,5 +176,7 @@ struct nfp_mtr *nfp_mtr_find_by_mtr_id(struct nfp_mtr_priv *priv, uint32_t mtr_id); struct nfp_mtr *nfp_mtr_find_by_profile_id(struct nfp_mtr_priv *priv, uint32_t profile_id); +int nfp_mtr_update_ref_cnt(struct nfp_mtr_priv *priv, + uint32_t mtr_id, bool add); #endif /* __NFP_MTR_H__ */ -- 2.29.3