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 33ADDA0C4D; Mon, 6 Sep 2021 09:56:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D43224112E; Mon, 6 Sep 2021 09:55:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id CDE8B41176 for ; Mon, 6 Sep 2021 09:55:40 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 185MxZEN021315 for ; Mon, 6 Sep 2021 00:55:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=f9wZxwMWz6k9zLaAIKyqKLsK4AKZmEkUEr+xsrCRf1Q=; b=iUoirI2FhtYzNodiTu7bavbqwNTTBHcSf5Pml4GMUmxRsHfN8KaPtPNiuPrONcNXG8YN 5F/6Kuck4QEum3CWTFyc6zF7QazJtpQG1Y7+uZqu3KotGVDqTBcVp9E0FytqO703Lsem 0F/uSm70PhsuVYQ7JiWY2f5NioprTgACJsftRIxQT6QOuJF0XYoUmdoC37nMi264VxXt unjwZUfm2dnzsDBKYNcQTQ5ktP/WxKVutQDwHvK8P0Xgfyyv0gb3oVP/s/JImh06Yk1I i9ynKRTokcCExc/gXIpufUZUVq+ki/SS29Hjb9ZB8747VkSVUqcglanUUK/BnPhuOZI8 bg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3aw2sp1sp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 06 Sep 2021 00:55:40 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 6 Sep 2021 00:55:38 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 6 Sep 2021 00:55:38 -0700 Received: from localhost.localdomain (unknown [10.28.34.25]) by maili.marvell.com (Postfix) with ESMTP id D39173F7089; Mon, 6 Sep 2021 00:55:36 -0700 (PDT) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: Date: Mon, 6 Sep 2021 13:24:42 +0530 Message-ID: <20210906075450.1452123-19-skori@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210906075450.1452123-1-skori@marvell.com> References: <20210906075450.1452123-1-skori@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: XdhTcPVouif6UxRtEq8xMyLZs7RWtGGG X-Proofpoint-ORIG-GUID: XdhTcPVouif6UxRtEq8xMyLZs7RWtGGG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-06_02,2021-09-03_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH 19/27] net/cnxk: support ops to validate meter policy 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 Sender: "dev" From: Sunil Kumar Kori Implement API to validate meter policy for CN10K platform. Signed-off-by: Sunil Kumar Kori --- drivers/net/cnxk/cn10k_ethdev_mtr.c | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/net/cnxk/cn10k_ethdev_mtr.c b/drivers/net/cnxk/cn10k_ethdev_mtr.c index 480ce8fd73..8374f40681 100644 --- a/drivers/net/cnxk/cn10k_ethdev_mtr.c +++ b/drivers/net/cnxk/cn10k_ethdev_mtr.c @@ -184,10 +184,73 @@ cn10k_nix_mtr_profile_delete(struct rte_eth_dev *eth_dev, uint32_t profile_id, return 0; } +static int +cn10k_nix_mtr_policy_validate(struct rte_eth_dev *dev, + struct rte_mtr_meter_policy_params *policy, + struct rte_mtr_error *error) +{ + enum rte_flow_action_type supported_action[] = { + RTE_FLOW_ACTION_TYPE_END, RTE_FLOW_ACTION_TYPE_QUEUE, + RTE_FLOW_ACTION_TYPE_DROP, RTE_FLOW_ACTION_TYPE_RSS, + RTE_FLOW_ACTION_TYPE_METER}; + bool supported[RTE_COLORS] = {false, false, false}; + uint32_t i; + + RTE_SET_USED(dev); + + if (!policy) + return 0; /* Nothing to be validated */ + + for (i = 0; i < RTE_DIM(supported_action); i++) { + if (policy->actions[RTE_COLOR_GREEN]->type == + supported_action[i]) { + supported[RTE_COLOR_GREEN] = true; + break; + } + } + + if (!supported[RTE_COLOR_GREEN]) { + return -rte_mtr_error_set(error, ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, + "Green: action is not supported"); + } + + for (i = 0; i < RTE_DIM(supported_action); i++) { + if (policy->actions[RTE_COLOR_YELLOW]->type == + supported_action[i]) { + supported[RTE_COLOR_YELLOW] = true; + break; + } + } + + if (!supported[RTE_COLOR_YELLOW]) { + return -rte_mtr_error_set(error, ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, + "Yellow: action is not supported"); + } + + for (i = 0; i < RTE_DIM(supported_action); i++) { + if (policy->actions[RTE_COLOR_RED]->type == + supported_action[i]) { + supported[RTE_COLOR_RED] = true; + break; + } + } + + if (!supported[RTE_COLOR_RED]) { + return -rte_mtr_error_set(error, ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, + "Red: action is not supported"); + } + + return 0; +} + const struct rte_mtr_ops nix_mtr_ops = { .capabilities_get = cn10k_nix_mtr_capabilities_get, .meter_profile_add = cn10k_nix_mtr_profile_add, .meter_profile_delete = cn10k_nix_mtr_profile_delete, + .meter_policy_validate = cn10k_nix_mtr_policy_validate, }; int -- 2.25.1