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 8B856A0555; Fri, 26 Aug 2022 13:21:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37A8542826; Fri, 26 Aug 2022 13:21:38 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 7F97940A80 for ; Fri, 26 Aug 2022 13:21:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661512893; x=1693048893; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=BsP9tFH10us3y0x4ESy4voEddYGI/h2vii2wf5Qjvfg=; b=a30LKsCiHlp/JkRNrHJmGu+wDDNev8w5zgxUZ+IEdhQbS31JDVLj85Ax SY3/VcmCUizv24wHipMpVXu+R09p51v0KN2GN8uFD9G4/aRnBJHfxu9JA 9TW19r8FT2mQzZcnqpTKuwEUIlnEZGg0FAhukEb40Xun0vKuhSdst0lKO mIKRZVunDIxzg/sdT4nXqOGtqoZnIqQDHxVBGGPzWOYL1Sx7iWAuvilT2 BGGiXhSHDsMUeFf1NvWyz1f0/qvYkvHTiE2TV2W42kGosJ0ZAj6/Wyf+Z AokphrNf6UhTZuLxbMIiASqSXkp7d7y8XGI30cpoMI9uD+ehPQ0yMW+rO g==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="295264082" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="295264082" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 04:21:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="678834807" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga004.fm.intel.com with ESMTP; 26 Aug 2022 04:21:32 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Subject: [PATCH V2 5/7] pipeline: support direct meters on the control path Date: Fri, 26 Aug 2022 11:21:25 +0000 Message-Id: <20220826112127.1580044-6-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220826112127.1580044-1-cristian.dumitrescu@intel.com> References: <20220826103605.1579589-1-cristian.dumitrescu@intel.com> <20220826112127.1580044-1-cristian.dumitrescu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Add pipeline control path API to manage direct meters. These meters are identified by a table key, whose entry ID is used as the index into the meter array. Signed-off-by: Cristian Dumitrescu --- lib/pipeline/rte_swx_ctl.h | 81 +++++++++++++++++++++++++++++++++ lib/pipeline/rte_swx_pipeline.c | 50 ++++++++++++++++++++ lib/pipeline/version.map | 3 ++ 3 files changed, 134 insertions(+) diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h index 1b47820441..2eb51b2c76 100644 --- a/lib/pipeline/rte_swx_ctl.h +++ b/lib/pipeline/rte_swx_ctl.h @@ -1440,6 +1440,87 @@ rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p, uint32_t metarray_index, struct rte_swx_ctl_meter_stats *stats); +/** + * Meter reset with table key lookup + * + * Reset a meter within a given meter array to use the default profile that + * causes all the input packets to be colored as green. It is the responsibility + * of the control plane to make sure this meter is not used by the data plane + * pipeline before calling this function. + * + * @param[in] p + * Pipeline handle. + * @param[in] metarray_name + * Meter array name. + * @param[in] table_name + * Regular or learner table name. + * @param[in] table_key + * Table key. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument. + */ +__rte_experimental +int +rte_swx_ctl_meter_reset_with_key(struct rte_swx_pipeline *p, + const char *metarray_name, + const char *table_name, + uint8_t *table_key); + +/** + * Meter set with table key lookup + * + * Set a meter within a given meter array to use a specific profile. It is the + * responsibility of the control plane to make sure this meter is not used by + * the data plane pipeline before calling this function. + * + * @param[in] p + * Pipeline handle. + * @param[in] metarray_name + * Meter array name. + * @param[in] table_name + * Regular or learner table name. + * @param[in] table_key + * Table key. + * @param[in] profile_name + * Existing meter profile name. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument. + */ +__rte_experimental +int +rte_swx_ctl_meter_set_with_key(struct rte_swx_pipeline *p, + const char *metarray_name, + const char *table_name, + uint8_t *table_key, + const char *profile_name); + +/** + * Meter statistics counters read with table key lookup + * + * @param[in] p + * Pipeline handle. + * @param[in] metarray_name + * Meter array name. + * @param[in] table_name + * Regular or learner table name. + * @param[in] table_key + * Table key. + * @param[out] stats + * Meter statistics counters. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument. + */ +__rte_experimental +int +rte_swx_ctl_meter_stats_read_with_key(struct rte_swx_pipeline *p, + const char *metarray_name, + const char *table_name, + uint8_t *table_key, + struct rte_swx_ctl_meter_stats *stats); + /** * Pipeline control free * diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index e726bf1575..4b1b311093 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -11315,6 +11315,56 @@ rte_swx_ctl_pipeline_regarray_write_with_key(struct rte_swx_pipeline *p, return rte_swx_ctl_pipeline_regarray_write(p, regarray_name, entry_id, value); } +int +rte_swx_ctl_meter_reset_with_key(struct rte_swx_pipeline *p, + const char *metarray_name, + const char *table_name, + uint8_t *table_key) +{ + size_t entry_id = 0; + int status; + + status = rte_swx_ctl_pipeline_table_entry_id_get(p, table_name, table_key, &entry_id); + if (status) + return status; + + return rte_swx_ctl_meter_reset(p, metarray_name, entry_id); +} + +int +rte_swx_ctl_meter_set_with_key(struct rte_swx_pipeline *p, + const char *metarray_name, + const char *table_name, + uint8_t *table_key, + const char *profile_name) +{ + size_t entry_id = 0; + int status; + + status = rte_swx_ctl_pipeline_table_entry_id_get(p, table_name, table_key, &entry_id); + if (status) + return status; + + return rte_swx_ctl_meter_set(p, metarray_name, entry_id, profile_name); +} + +int +rte_swx_ctl_meter_stats_read_with_key(struct rte_swx_pipeline *p, + const char *metarray_name, + const char *table_name, + uint8_t *table_key, + struct rte_swx_ctl_meter_stats *stats) +{ + size_t entry_id = 0; + int status; + + status = rte_swx_ctl_pipeline_table_entry_id_get(p, table_name, table_key, &entry_id); + if (status) + return status; + + return rte_swx_ctl_meter_stats_read(p, metarray_name, entry_id, stats); +} + /* * Pipeline compilation. */ diff --git a/lib/pipeline/version.map b/lib/pipeline/version.map index 8ed92042d6..f53a037edf 100644 --- a/lib/pipeline/version.map +++ b/lib/pipeline/version.map @@ -146,6 +146,9 @@ EXPERIMENTAL { rte_swx_pipeline_hash_func_register; #added in 22.11 + rte_swx_ctl_meter_reset_with_key; + rte_swx_ctl_meter_set_with_key; + rte_swx_ctl_meter_stats_read_with_key; rte_swx_ctl_pipeline_find; rte_swx_ctl_pipeline_regarray_read_with_key; rte_swx_ctl_pipeline_regarray_write_with_key; -- 2.34.1