Hello Andrew, []
> On 1/24/23 12:37, 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 <getel...@nvidia.com> > > Acked-by: Ori Kam <or...@nvidia.com> > > [snip] > > > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > > index 3e6242803d..7a3868638c 100644 > > --- a/doc/guides/prog_guide/rte_flow.rst > > +++ b/doc/guides/prog_guide/rte_flow.rst > > @@ -1544,6 +1544,13 @@ Matches Color Marker set by a Meter. > > > > - ``color``: Metering color marker. > > > > +Item: ``QUOTA`` > > +^^^^^^^^^^^^^^^ > > + > > +Matches flow quota state set by quota action. > > + > > +- ``state``: Flow quota state > > + > > Actions > > ~~~~~~~ > > > > @@ -3227,6 +3234,40 @@ and rte_mtr_policy_get() API respectively. > > | ``policy`` | Meter policy object | > > +------------------+----------------------+ > > > > +Action: ``QUOTA`` > > +^^^^^^^^^^^^^^^^^ > > + > > +Update ``quota`` value and set packet quota state. > > +If the ``quota`` value after update is non-negative packet quota state set > to > > +``RTE_FLOW_QUOTA_STATE_PASS``. Otherwise, packet quota state set to > ``RTE_FLOW_QUOTA_STATE_BLOCK``. > > +The ``quota`` value is reduced according to ``mode`` setting. > > + > > +.. _table_rte_flow_action_quota: > > + > > +.. table:: QUOTA > > + > > + +------------------+------------------------+ > > + | Field | Value | > > + +==================+========================+ > > + | ``mode`` | Quota operational mode | > > + +------------------+------------------------+ > > + | ``quota`` | Quota value | > > + +------------------+------------------------+ > > + > > +.. _rte_flow_quota_mode: > > + > > +.. table:: Quota update modes > > + > > + > > +---------------------------------+-------------------------------------+ > > + | Value | Description > > | > > + > +=================================+============================ > =========+ > > + | ``RTE_FLOW_QUOTA_MODE_PACKET`` | Count packets > | > > + > > +---------------------------------+-------------------------------------+ > > + | ``RTE_FLOW_QUOTA_MODE_L2`` | Count packet bytes starting > from L2 | > > + > > +------------------+----------------------------------------------------+ > > + | ``RTE_FLOW_QUOTA_MODE_L3`` | Count packet bytes starting > from L3 | > > + > > +------------------+----------------------------------------------------+ > > + > > Negative types > > ~~~~~~~~~~~~~~ > > > > diff --git a/doc/guides/rel_notes/release_23_03.rst > b/doc/guides/rel_notes/release_23_03.rst > > index 5b98e18032..0756cca241 100644 > > --- a/doc/guides/rel_notes/release_23_03.rst > > +++ b/doc/guides/rel_notes/release_23_03.rst > > @@ -77,6 +77,18 @@ New Features > > - ``rte_flow_async_action_handle_query_update`` > > > > > > Just one empty line between section items > Will fix in v8. > > +* **Added quota flow action and quota flow item.** > > + > > + - ``RTE_FLOW_ACTION_TYPE_QUOTA`` > > + - ``RTE_FLOW_ITEM_TYPE_QUOTA`` > > + > > + > Just one empty line between section items > Will fix in v8. > > +* **Updated testpmd to support quota flow action and item.** > > + > > + Added support for flow quota action and item. > > + > > + > > + > > It should be 2 empty lines, not 3, > Will fix in v8. > > Removed Items > > ------------- > > > > [snip] > > > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h > > index 6705cb32af..46409ed607 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 */ > > +}; > > + > > +/** > > + * 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 > > }; > > +#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 */ > > /**< since you put documentation after documented member > > > + RTE_FLOW_QUOTA_MODE_L2 = 2, /** Count packet bytes starting > from L2 */ > > /**< > Will fix in v8. > also, why do you initialize every member? are you going to rely > on these values? > I selected these values to avoid confusion. L2 mode corresponds to numerical value 2 and L3 mode corresponds to numerical value 3. > > + 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 */ > > /**< since you put documentation after documented member > > > + int64_t quota; /** quota value */ > > /**< > Will fix in v8. > > +}; > > + > > +/** > > + * @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 */ > > /**< since you put documentation after documented member > Will fix in v8. > > +}; > > + > > +/** > > + * @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 */ > > /**< since you put documentation after documented member > > > + RTE_FLOW_UPDATE_QUOTA_ADD, /** increase existing quota with > new value */ > > /**< > Will fix in v8. > > +}; > > + > > +/** > > + * @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 */ > > /**< since you put documentation after documented member > > > + int64_t quota; /** quota value */ > > /**< > Will fix in v8. > > }; > > > > /** > > @@ -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_*). > > */