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 BA572A0554; Fri, 26 Aug 2022 12:36:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C31C84281B; Fri, 26 Aug 2022 12:36:16 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id B3D9540146 for ; Fri, 26 Aug 2022 12:36:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661510171; x=1693046171; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=BsP9tFH10us3y0x4ESy4voEddYGI/h2vii2wf5Qjvfg=; b=jbKGU1/b9K7dVn7FSEl+QIBvRSWu9TTkcdfebXtBb4ZkHmc6CT/i1MPJ LiEq1wZ3t5Rn5AgXyp+gklc/7GgudE3uYu2wsTy4ms/837wOkMSnwmxEL YLxCFGwmnxEj0188YTSyQYL4l8TW6Fng77sQFfA2vhgYXP8X+5FlpShlb 8ZWX71jg8rlncHvywLoVhygesBxwNT08A/3voH5ljbcDV5PEAW0q2IHwh 8cF7m950TL1spHNHRMOL6uOgA25pgJds92J79rwwDTAGjWKcjio7DmloY WbjAlR7ILdZNDXg6KcnSrzvnftADeBOI0Qt+9dDdO/Kh4C9tGXoHM5lg7 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10450"; a="356194329" X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="356194329" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 03:36:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,265,1654585200"; d="scan'208";a="671414290" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com.) ([10.237.223.157]) by fmsmga008.fm.intel.com with ESMTP; 26 Aug 2022 03:36:10 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Subject: [PATCH 5/7] pipeline: support direct meters on the control path Date: Fri, 26 Aug 2022 10:36:03 +0000 Message-Id: <20220826103605.1579589-6-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220826103605.1579589-1-cristian.dumitrescu@intel.com> References: <20220826103605.1579589-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