From mboxrd@z Thu Jan 1 00:00:00 1970 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 mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2681BC25B4E for ; Fri, 20 Jan 2023 08:52:23 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B47A40150; Fri, 20 Jan 2023 09:52:22 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 3870B400D5 for ; Fri, 20 Jan 2023 09:52:21 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 9B51650; Fri, 20 Jan 2023 11:52:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 9B51650 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1674204740; bh=h6zYCyTMNJipWIFDcjTPpvxMdP++QR1UDIe9dv3mnec=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=OIyRs3ggPjfN6D2ESWjbY68vNyRrL0YrgbvrJh2voX+gsBwYrfxX3B3dq/w+paPXh L0jyGGDTem3OBVW1LUs/rsFZXgZoOQ8yyvGauOGt8LZoOGGKAg0Va10A8IyMfI0DGQ Yg5M87W4SB1dGNFScokj+9WmjzSZTbAzABnJUA9k= Message-ID: <1d7f71d6-874e-6ad6-64f5-ec5500e17736@oktetlabs.ru> Date: Fri, 20 Jan 2023 11:52:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v6 2/2] ethdev: add quota flow action and item Content-Language: en-US To: Gregory Etelson , dev@dpdk.org Cc: matan@nvidia.com, rasland@nvidia.com, Ori Kam , Aman Singh , Yuying Zhang , Ferruh Yigit , Thomas Monjalon References: <20221221073547.988-1-getelson@nvidia.com> <20230119164713.7164-1-getelson@nvidia.com> <20230119164713.7164-2-getelson@nvidia.com> From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20230119164713.7164-2-getelson@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 1/19/23 19:47, Gregory Etelson wrote: > Quota action limits traffic according to pre-defined configuration. > Quota reflects overall traffic usage regardless bandwidth. > Quota flow action initialized with signed tokens number value. > Quota flow action updates tokens number according to > these rules: > 1. if quota was configured to count packet length, for each packet > of size S, tokens number reduced by S. > 2. If quota was configured to count packets, each packet decrements > tokens number. > quota action sets packet metadata according to a number of remaining > tokens number: > PASS - remaining tokens number is non-negative. > BLOCK - remaining tokens number is negative. > > Quota flow item matches on that data > > Application updates tokens number in quota flow action > with SET or ADD calls: > SET(QUOTA, val) - arm quota with new tokens number set to val > ADD(QUOTA, val) - increase existing quota tokens number by val > > Both SET and ADD return to application number of tokens stored in port > before update. > > If quota state was BLOCK (negative action tokens number) > application can change it to PASS after providing enough tokens to > raise action tokens number to 0 or above. > > Application must create a rule with quota action to mark flow and > match on the mark with quota item in following flow rule. > > Signed-off-by: Gregory Etelson > Acked-by: Ori Kam [snip] > diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst > index 6941d20abc..713b58267f 100644 > --- a/doc/guides/rel_notes/release_23_03.rst > +++ b/doc/guides/rel_notes/release_23_03.rst > @@ -77,6 +77,33 @@ New Features > - ``rte_flow_action_handle_query_update`` > - ``rte_flow_async_action_handle_query_update`` > > +* **Added quota flow action and quota flow item.** > + > + Quota action limits traffic according to pre-defined configuration. > + Quota reflects overall traffic usage regardless bandwidth. > + Quota flow action initialized with signed tokens number value. > + Quota flow action updates tokens number according to > + these rules: > + * If quota was configured to count packet length, for each packet > + of size S, tokens number reduced by S. > + * If quota was configured to count packets, each packet decrements > + tokens number. > + Quota action sets packet metadata according to a number of remaining > + tokens number: > + * ``PASS`` - remaining tokens number is non-negative. > + * ``BLOCK`` - remaining tokens number is negative. > + > + Quota flow item matches on that metadata. > + > + - ``RTE_FLOW_ACTION_TYPE_QUOTA`` > + - ``RTE_FLOW_ITEM_TYPE_QUOTA`` Quota description should be a part of action/item documentation, not release notes. > + > +* **Updated testpmd to support quota flow action and item.** > + > + Added tokens to ``token_list[]`` for flow quota action and item support. IMHO 'token_list' is inapropriate in release notes. It is too deep technical detail. > + > + > + > Removed Items > ------------- > > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h > index 280567a3ae..0068fc275b 100644 > --- a/lib/ethdev/rte_flow.h > +++ b/lib/ethdev/rte_flow.h > @@ -624,7 +624,45 @@ enum rte_flow_item_type { > * See struct rte_flow_item_meter_color. > */ > RTE_FLOW_ITEM_TYPE_METER_COLOR, > + > + /** > + * Match Quota state > + * > + * @see struct rte_flow_item_quota > + */ > + RTE_FLOW_ITEM_TYPE_QUOTA, > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * QUOTA state. > + * > + * @see struct rte_flow_item_quota > + */ > +enum rte_flow_quota_state { > + RTE_FLOW_QUOTA_STATE_PASS, /** PASS quota state */ > + RTE_FLOW_QUOTA_STATE_BLOCK /** BLOCK quota state */ Enum memeber comments should start from /**< since it is a documentation after documented code. > +}; > + > +/** > + * RTE_FLOW_ITEM_TYPE_QUOTA > + * > + * Matches QUOTA state > + */ > +struct rte_flow_item_quota { > + enum rte_flow_quota_state state; > +}; > + > +/** > + * Default mask for RTE_FLOW_ITEM_TYPE_QUOTA > + */ > +#ifndef __cplusplus > +static const struct rte_flow_item_quota rte_flow_item_quota_mask = { > + .state = (enum rte_flow_quota_state)0xff I don't understand why it is just 0xff, not 0x1, not 0xf, not 0xffff, not 0xffffffff. Isn't it better to make 'state' -> 'state_mask' and use PASS and BLOCK as corresponding bits in a mask. If so, here should be a value with all known bits set. > }; > +#endif > > /** > * > @@ -2736,6 +2774,81 @@ enum rte_flow_action_type { > * No associated configuration structure. > */ > RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL, > + > + /** > + * Apply the quota verdict (PASS or BLOCK) to a flow. > + * > + * @see struct rte_flow_action_quota > + * @see struct rte_flow_query_quota > + * @see struct rte_flow_update_quota > + */ > + RTE_FLOW_ACTION_TYPE_QUOTA, > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * QUOTA operational mode. > + * > + * @see struct rte_flow_action_quota > + */ > +enum rte_flow_quota_mode { > + RTE_FLOW_QUOTA_MODE_PACKET = 1, /** Count packets */ /**< > + RTE_FLOW_QUOTA_MODE_L2 = 2, /** Count packet bytes starting from L2 */ /**< > + RTE_FLOW_QUOTA_MODE_L3 = 3, /** Count packet bytes starting from L3 */ /**< > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Create QUOTA action. > + * > + * @see RTE_FLOW_ACTION_TYPE_QUOTA > + */ > +struct rte_flow_action_quota { > + enum rte_flow_quota_mode mode; /** quota operational mode */ /**< > + int64_t quota; /** quota value */ /**< > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Query indirect QUOTA action. > + * > + * @see RTE_FLOW_ACTION_TYPE_QUOTA > + * > + */ > +struct rte_flow_query_quota { > + int64_t quota; /** quota value */ /**< > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Indirect QUOTA update operations. > + * > + * @see struct rte_flow_update_quota > + */ > +enum rte_flow_update_quota_op { > + RTE_FLOW_UPDATE_QUOTA_SET, /** set new quota value */ /**< > + RTE_FLOW_UPDATE_QUOTA_ADD, /** increase existing quota with new value */ /**< > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * @see RTE_FLOW_ACTION_TYPE_QUOTA > + * > + * Update indirect QUOTA action. > + */ > +struct rte_flow_update_quota { > + enum rte_flow_update_quota_op op; /** update operation */ /**< > + int64_t quota; /** quota value */ /**< > }; > > /** > @@ -4854,6 +4967,11 @@ struct rte_flow_port_info { > * @see RTE_FLOW_ACTION_TYPE_CONNTRACK > */ > uint32_t max_nb_conn_tracks; > + /** > + * Maximum number of quota actions. > + * @see RTE_FLOW_ACTION_TYPE_QUOTA > + */ > + uint32_t max_nb_quotas; > /** > * Port supported flags (RTE_FLOW_PORT_FLAG_*). > */ > @@ -4932,6 +5050,11 @@ struct rte_flow_port_attr { > * @see RTE_FLOW_ACTION_TYPE_CONNTRACK > */ > uint32_t nb_conn_tracks; > + /** > + * Maximum number of quota actions. > + * @see RTE_FLOW_ACTION_TYPE_QUOTA > + */ > + uint32_t nb_quotas; > /** > * Port flags (RTE_FLOW_PORT_FLAG_*). > */