add flow shared action API
PATCH v2 5/6 net/mlx5: driver support for shared action
In reply to Andrey VesnovatyImplement shared action create/destroy/update/query. Implement RSS shared action and handle shared RSS on flow apply and release.
Note: currently implemented for sharede RSS action only
--- drivers/net/mlx5/mlx5_flow_dv.c | 671 ++++++++++++++++++++++++++++++-- 1 file changed, 647 insertions(+), 24 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +647 -24
@@ -8570,6 +8570,156 @@ __flow_dv_translate(struct rte_eth_dev *dev,return 0 ; } +/** +* Set hash RX queue by hash fields (see enum ibv_rx_hash_fields) +* and tunnel. +* +* @param[in, out] action +* Shred RSS action holding hash RX queue objects. +* @param[in] hash_fields +* Defines combination of packet fields to participate in RX hash. +* @param[in] tunnel +* Tunnel type +* @param[in] hrxq_idx +* Hash RX queue index to set. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +__flow_dv_action_rss_hrxq_set (struct mlx5_shared_action_rss *action, +const uint64_t hash_fields, +const int tunnel, +uint32_t hrxq_idx) +{ +uint32_t *hrxqs = (tunnel) ? action->hrxq : action->hrxq_tunnel; + +switch (hash_fields & ~IBV_RX_HASH_INNER ) { +case MLX5_RSS_HASH_IPV4 : + hrxqs[0 ] = hrxq_idx; +return 0 ; +case MLX5_RSS_HASH_IPV4_TCP : + hrxqs[1 ] = hrxq_idx; +return 0 ; +case MLX5_RSS_HASH_IPV4_UDP : + hrxqs[2 ] = hrxq_idx; +return 0 ; +case MLX5_RSS_HASH_IPV6 : + hrxqs[3 ] = hrxq_idx; +return 0 ; +case MLX5_RSS_HASH_IPV6_TCP : + hrxqs[4 ] = hrxq_idx; +return 0 ; +case MLX5_RSS_HASH_IPV6_UDP : + hrxqs[5 ] = hrxq_idx; +return 0 ; +case MLX5_RSS_HASH_NONE : + hrxqs[6 ] = hrxq_idx; +return 0 ; +default : +return -1 ; + } +} + +/** +* Look up for hash RX queue by hash fields (see enum ibv_rx_hash_fields) +* and tunnel. +* +* @param[in] action +* Shred RSS action holding hash RX queue objects. +* @param[in] hash_fields +* Defines combination of packet fields to participate in RX hash. +* @param[in] tunnel +* Tunnel type +* +* @return +* Valid hash RX queue index, otherwise 0. +*/ +static uint32_t +__flow_dv_action_rss_hrxq_lookup (const struct mlx5_shared_action_rss *action, +const uint64_t hash_fields, +const int tunnel) +{ +const uint32_t *hrxqs = (tunnel) ? action->hrxq : action->hrxq_tunnel; + +switch (hash_fields & ~IBV_RX_HASH_INNER ) { +case MLX5_RSS_HASH_IPV4 : +return hrxqs[0 ]; +case MLX5_RSS_HASH_IPV4_TCP : +return hrxqs[1 ]; +case MLX5_RSS_HASH_IPV4_UDP : +return hrxqs[2 ]; +case MLX5_RSS_HASH_IPV6 : +return hrxqs[3 ]; +case MLX5_RSS_HASH_IPV6_TCP : +return hrxqs[4 ]; +case MLX5_RSS_HASH_IPV6_UDP : +return hrxqs[5 ]; +case MLX5_RSS_HASH_NONE : +return hrxqs[6 ]; +default : +return 0 ; + } +} + +/** +* Retrieves hash RX queue suitable for the *flow*. +* If shared action configured for *flow* suitable hash RX queue will be +* retrieved from attached shared action. +* +* @param[in] flow +* Shred RSS action holding hash RX queue objects. +* @param[in] dev_flow +* Pointer to the sub flow. +* @param[out] hrxq +* Pointer to retrieved hash RX queue object. +* +* @return +* Valid hash RX queue index, otherwise 0 and rte_errno is set. +*/ +static uint32_t +__flow_dv_rss_get_hrxq (struct rte_eth_dev *dev,struct rte_flow *flow, +struct mlx5_flow *dev_flow, +struct mlx5_hrxq **hrxq) +{ +struct mlx5_priv *priv = dev->data->dev_private; +uint32_t hrxq_idx; +struct mlx5_flow_rss_desc *rss_desc =NULL ; + +if (flow->shared_rss) { + hrxq_idx =__flow_dv_action_rss_hrxq_lookup + (flow->shared_rss, dev_flow->hash_fields, + !!(dev_flow->handle->layers & +MLX5_FLOW_LAYER_TUNNEL )); +if (hrxq_idx) { + *hrxq =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_HRXQ ], + hrxq_idx); +rte_atomic32_inc (&(*hrxq)->refcnt); + } + }else { + rss_desc = &((struct mlx5_flow_rss_desc *)priv->rss_desc) + [!!priv->flow_nested_idx]; +MLX5_ASSERT (rss_desc->queue_num); + hrxq_idx =mlx5_hrxq_get (dev, rss_desc->key, +MLX5_RSS_HASH_KEY_LEN , + dev_flow->hash_fields, + rss_desc->queue, rss_desc->queue_num); +if (!hrxq_idx) { + hrxq_idx =mlx5_hrxq_new (dev, + rss_desc->key, +MLX5_RSS_HASH_KEY_LEN , + dev_flow->hash_fields, + rss_desc->queue, + rss_desc->queue_num, + !!(dev_flow->handle->layers & +MLX5_FLOW_LAYER_TUNNEL )); + } + *hrxq =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_HRXQ ], + hrxq_idx); + } +return hrxq_idx; +} +/** * Apply the flow to the NIC, lock free, * (mutex should be acquired by caller).
@@ -8628,30 +8778,10 @@ __flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow, dv->actions[n++] = drop_hrxq->action; } }else if (dh->fate_action ==MLX5_FLOW_FATE_QUEUE ) { -struct mlx5_hrxq *hrxq; -uint32_t hrxq_idx; -struct mlx5_flow_rss_desc *rss_desc = - &((struct mlx5_flow_rss_desc *)priv->rss_desc) - [!!priv->flow_nested_idx]; - -MLX5_ASSERT (rss_desc->queue_num); - hrxq_idx =mlx5_hrxq_get (dev, rss_desc->key, -MLX5_RSS_HASH_KEY_LEN , - dev_flow->hash_fields, - rss_desc->queue, - rss_desc->queue_num); -if (!hrxq_idx) { - hrxq_idx =mlx5_hrxq_new - (dev, rss_desc->key, -MLX5_RSS_HASH_KEY_LEN , - dev_flow->hash_fields, - rss_desc->queue, - rss_desc->queue_num, - !!(dh->layers & -MLX5_FLOW_LAYER_TUNNEL )); - } - hrxq =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_HRXQ ], - hrxq_idx); +struct mlx5_hrxq *hrxq =NULL ; +uint32_t hrxq_idx =__flow_dv_rss_get_hrxq + (dev, flow, dev_flow, + &hrxq);if (!hrxq) { rte_flow_error_set (error, rte_errno,
@@ -9067,12 +9197,16 @@ __flow_dv_remove(struct rte_eth_dev *dev, struct rte_flow *flow)static void __flow_dv_destroy (struct rte_eth_dev *dev,struct rte_flow *flow) { +struct rte_flow_shared_action *shared;struct mlx5_flow_handle *dev_handle;struct mlx5_priv *priv = dev->data->dev_private;if (!flow)return ;__flow_dv_remove (dev, flow); + shared =mlx5_flow_get_shared_rss (flow); +if (shared) +rte_atomic32_dec (&shared->refcnt);if (flow->counter) {flow_dv_counter_release (dev, flow->counter); flow->counter =0 ;
@@ -9112,6 +9246,410 @@ __flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) } } +/** +* Release array of hash RX queue objects. +* Helper function. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in, out] hrxqs +* Array of hash RX queue objects. +* +* @return +* Total number of references to hash RX queue objects in *hrxqs* array +* after this operation. +*/ +static int +__flow_dv_hrxqs_release (struct rte_eth_dev *dev, +uint32_t (*hrxqs)[MLX5_RSS_HASH_FIELDS_LEN ]) +{ +size_t i; +int remaining =0 , ret =0 , ret_tunnel =0 ; + +for (i =0 ; i <RTE_DIM (*hrxqs); i++) { + ret =mlx5_hrxq_release (dev, (*hrxqs)[i]); +if (!ret) + (*hrxqs)[i] =0 ; + remaining += ret + ret_tunnel; + } +return remaining; +} + +/** +* Release all hash RX queue objects representing shared RSS action. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in, out] action +* Shared RSS action to remove hash RX queue objects from. +* +* @return +* Total number of references to hash RX queue objects stored in *action* +* after this operation. +* Expected to be 0 if no external references held. +*/ +static int +__flow_dv_action_rss_hrxqs_release (struct rte_eth_dev *dev, +struct mlx5_shared_action_rss *action) +{ +return __flow_dv_hrxqs_release (dev, &action->hrxq) + +__flow_dv_hrxqs_release (dev, &action->hrxq_tunnel); +} + +/** +* Setup shared RSS action. +* Prepare set of hash RX queue objects sufficient to handle all valid +* hash_fields combinations (see enum ibv_rx_hash_fields). +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in, out] action +* Partially initialized shared RSS action. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +__flow_dv_action_rss_setup (struct rte_eth_dev *dev, +struct mlx5_shared_action_rss *action, +struct rte_flow_error *error) +{ +size_t i; +int err; + +for (i =0 ; i <MLX5_RSS_HASH_FIELDS_LEN ; i++) { +uint32_t hrxq_idx; +uint64_t hash_fields = mlx5_rss_hash_fields[i]; +int tunnel; + +for (tunnel =0 ; tunnel <2 ; tunnel++) { + hrxq_idx =mlx5_hrxq_new (dev, action->origin.key, +MLX5_RSS_HASH_KEY_LEN , + hash_fields, + action->origin.queue, + action->origin.queue_num, + tunnel); +if (!hrxq_idx) { +rte_flow_error_set + (error, rte_errno, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"cannot get hash queue" ); + goto error_hrxq_new; + } + err =__flow_dv_action_rss_hrxq_set + (action, hash_fields, tunnel, hrxq_idx); +MLX5_ASSERT (!err); + } + } +return 0 ; +error_hrxq_new: + err = rte_errno; +__flow_dv_action_rss_hrxqs_release (dev, action); + rte_errno = err; +return -rte_errno; +} + +/** +* Create shared RSS action. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] rss +* RSS action specification used to create shared action. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* A valid shared action handle in case of success, NULL otherwise and +* rte_errno is set. +*/ +static struct rte_flow_shared_action * +__flow_dv_action_rss_create (struct rte_eth_dev *dev, +const struct rte_flow_action_rss *rss, +struct rte_flow_error *error) +{ +struct rte_flow_shared_action *shared_action =NULL ; +void *queue =NULL ; +uint32_t queue_size; +struct mlx5_shared_action_rss *shared_rss; +struct rte_flow_action_rss *origin; +const uint8_t *rss_key; + + queue_size =RTE_ALIGN_CEIL (rss->queue_num *sizeof (uint16_t ), +sizeof (void *)); + queue =rte_calloc (__func__,1 , queue_size,0 ); + shared_action =rte_calloc (__func__,1 ,sizeof (*shared_action),0 ); +if (!shared_action || !queue) { +rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"cannot allocate resource memory" ); + goto error_rss_init; + } + shared_rss = &shared_action->rss; + shared_rss->queue = queue; + origin = &shared_rss->origin; + origin->func = rss->func; + origin->level = rss->level; +/* RSS type 0 indicates default RSS type (ETH_RSS_IP). */ + origin->types = !rss->types ?ETH_RSS_IP : rss->types; +/* NULL RSS key indicates default RSS key. */ + rss_key = !rss->key ? rss_hash_default_key : rss->key; +rte_memcpy (shared_rss->key, rss_key,MLX5_RSS_HASH_KEY_LEN ); + origin->key = &shared_rss->key[0 ]; + origin->key_len =MLX5_RSS_HASH_KEY_LEN ; +rte_memcpy (shared_rss->queue, rss->queue, queue_size); + origin->queue = shared_rss->queue; + origin->queue_num = rss->queue_num; +if (__flow_dv_action_rss_setup (dev, shared_rss, error)) + goto error_rss_init; +return shared_action; +error_rss_init: +rte_free (shared_action); +rte_free (queue); +return NULL ; +} + +/** +* Destroy the shared RSS action. +* Release related hash RX queue objects. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] shared_rss +* The shared RSS action object to be removed. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +__flow_dv_action_rss_release (struct rte_eth_dev *dev, +struct mlx5_shared_action_rss *shared_rss, +struct rte_flow_error *error) +{ +struct rte_flow_shared_action *shared_action =NULL ; +int remaining =__flow_dv_action_rss_hrxqs_release (dev, shared_rss); + +if (remaining) { +return rte_flow_error_set (error,ETOOMANYREFS , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL , +"shared rss hrxq has references" ); + } + shared_action =container_of (shared_rss, + struct rte_flow_shared_action, rss); +if (!rte_atomic32_dec_and_test (&shared_action->refcnt)) { +return rte_flow_error_set (error,ETOOMANYREFS , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL , +"shared rss has references" ); + } +rte_free (shared_rss->queue); +return 0 ; +} + +/** +* Create shared action, lock free, +* (mutex should be acquired by caller). +* Dispatcher for action type specific call. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] action +* Action specification used to create shared action. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* A valid shared action handle in case of success, NULL otherwise and +* rte_errno is set. +*/ +static struct rte_flow_shared_action * +__flow_dv_action_create (struct rte_eth_dev *dev, +const struct rte_flow_action *action, +struct rte_flow_error *error) +{ +struct rte_flow_shared_action *shared_action =NULL ; +struct mlx5_priv *priv = dev->data->dev_private; + +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + shared_action =__flow_dv_action_rss_create (dev, action->conf, + error); +break ; +default : +rte_flow_error_set (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"action type not supported" ); +break ; + } +if (shared_action) { +rte_atomic32_inc (&shared_action->refcnt); +LIST_INSERT_HEAD (&priv->shared_actions, shared_action, next); + } +return shared_action; +} + +/** +* Destroy the shared action. +* Release action related resources on the NIC and the memory. +* Lock free, (mutex should be acquired by caller). +* Dispatcher for action type specific call. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] action +* The shared action object to be removed. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +__flow_dv_action_destroy (struct rte_eth_dev *dev, +struct rte_flow_shared_action *action, +struct rte_flow_error *error) +{ +int ret; + +switch (action->type) { +case MLX5_FLOW_ACTION_SHARED_RSS : + ret =__flow_dv_action_rss_release (dev, &action->rss, error); +break ; +default : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL , +"action type not supported" ); + } +if (ret) +return ret; +LIST_REMOVE (action, next); +rte_free (action); +return 0 ; +} + +/** +* Updates in place shared RSS action configuration. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] shared_rss +* The shared RSS action object to be updated. +* @param[in] action_conf +* RSS action specification used to modify *shared_rss*. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +* @note: currently only support update of RSS queues. +*/ +static int +__flow_dv_action_rss_update (struct rte_eth_dev *dev, +struct mlx5_shared_action_rss *shared_rss, +const struct rte_flow_action_rss *action_conf, +struct rte_flow_error *error) +{ +size_t i; +int ret; +void *queue =NULL ; +uint32_t queue_size; +const uint8_t *rss_key; +uint32_t rss_key_len; + + queue_size =RTE_ALIGN_CEIL (action_conf->queue_num *sizeof (uint16_t ), +sizeof (void *)); + queue =rte_calloc (__func__,1 , queue_size,0 ); +if (!queue) { +return rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"cannot allocate resource memory" ); + } +if (action_conf->key) { + rss_key = action_conf->key; + rss_key_len = action_conf->key_len; + }else { + rss_key = rss_hash_default_key; + rss_key_len =MLX5_RSS_HASH_KEY_LEN ; + } +for (i =0 ; i <MLX5_RSS_HASH_FIELDS_LEN ; i++) { +uint32_t hrxq_idx; +uint64_t hash_fields = mlx5_rss_hash_fields[i]; +int tunnel; + +for (tunnel =0 ; tunnel <2 ; tunnel++) { + hrxq_idx =__flow_dv_action_rss_hrxq_lookup + (shared_rss, hash_fields, tunnel); +MLX5_ASSERT (hrxq_idx); + ret =mlx5_hrxq_modify + (dev, hrxq_idx, + rss_key, rss_key_len, + hash_fields, + action_conf->queue, action_conf->queue_num); +if (ret) { +rte_free (queue); +return rte_flow_error_set + (error, rte_errno, +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"cannot update hash queue" ); + } + } + } +rte_free (shared_rss->queue); + shared_rss->queue = queue; +rte_memcpy (shared_rss->queue, action_conf->queue, queue_size); + shared_rss->origin.queue = shared_rss->queue; + shared_rss->origin.queue_num = action_conf->queue_num; +return 0 ; +} + +/** +* Updates in place shared action configuration, lock free, +* (mutex should be acquired by caller). +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] action +* The shared action object to be updated. +* @param[in] action_conf +* Action specification used to modify *action*. +* *action_conf* should be of type correlating with type of the *action*, +* otherwise considered as invalid. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +__flow_dv_action_update (struct rte_eth_dev *dev, +struct rte_flow_shared_action *action, +const void *action_conf, +struct rte_flow_error *error) +{ +switch (action->type) { +case MLX5_FLOW_ACTION_SHARED_RSS : +return __flow_dv_action_rss_update (dev, &action->rss, + action_conf, error); +default : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL , +"action type not supported" ); + } +}/** * Query a dv flow rule for its statistics via devx. *
@@ -9792,6 +10330,87 @@ flow_dv_counter_free(struct rte_eth_dev *dev, uint32_t cnt)flow_dv_shared_unlock (dev); } +/** +* Validate shared action. +* Dispatcher for action type specific validation. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* @param[in] action +* The shared action object to validate. +* @param[out] error +* Perform verbose error reporting if not NULL. Initialized in case of +* error only. +* +* @return +* 0 on success, otherwise negative errno value. +*/ +static int +flow_dv_action_validate (struct rte_eth_dev *dev, +const struct rte_flow_action *action, +struct rte_flow_error *error) +{ +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RSS : +return mlx5_validate_action_rss (dev, action, error); +default : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL , +"action type not supported" ); + } +} + +/* +* Mutex-protected thunk to lock-free __flow_dv_action_create(). +*/ +static struct rte_flow_shared_action * +flow_dv_action_create (struct rte_eth_dev *dev, +const struct rte_flow_action *action, +struct rte_flow_error *error) +{ +struct rte_flow_shared_action *shared_action =NULL ; + +flow_dv_shared_lock (dev); + shared_action =__flow_dv_action_create (dev, action, error); +flow_dv_shared_unlock (dev); +return shared_action; +} + +/* +* Mutex-protected thunk to lock-free __flow_dv_action_destroy(). +*/ +static int +flow_dv_action_destroy (struct rte_eth_dev *dev, +struct rte_flow_shared_action *action, +struct rte_flow_error *error) +{ +int ret; + +flow_dv_shared_lock (dev); + ret =__flow_dv_action_destroy (dev, action, error); +flow_dv_shared_unlock (dev); +return ret; +} + +/* +* Mutex-protected thunk to lock-free __flow_dv_action_update(). +*/ +static int +flow_dv_action_update (struct rte_eth_dev *dev, +struct rte_flow_shared_action *action, +const void *action_conf, +struct rte_flow_error *error) +{ +int ret; + +flow_dv_shared_lock (dev); + ret =__flow_dv_action_update (dev, action, action_conf, + error); +flow_dv_shared_unlock (dev); +return ret; +} +const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .validate = flow_dv_validate, .prepare = flow_dv_prepare,
@@ -9808,6 +10427,10 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .counter_free = flow_dv_counter_free, .counter_query = flow_dv_counter_query, .get_aged_flows = flow_get_aged_flows, + .action_validate = flow_dv_action_validate, + .action_create = flow_dv_action_create, + .action_destroy = flow_dv_action_destroy, + .action_update = flow_dv_action_update, };#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
Signature · 1 line
2.26.2
PATCH v2 6/6 examples/flow_filtering: utilize shared RSS action
In reply to Andrey VesnovatyThis commit gives very first shared RSS action usage example and demonstrates shared action capability for in-place update.
First application creates shared action during initialization phase. Later on the flow object created by application uses previously created shared RSS action with 1 queue configured instead of queue action in original application.
On each RX queue burst shared RSS action reconfigured via rte_flow_shared_action_update() API to switch queue 0 to 1 & 1 to 0. User supposed to observe consistent queue switches on each packet burst.
--- doc/guides/sample_app_ug/flow_filtering.rst | 62 +++++++++++++++++---- examples/flow_filtering/flow_blocks.c | 30 +++++----- examples/flow_filtering/main.c | 41 +++++++++++++- 3 files changed, 105 insertions(+), 28 deletions(-)
doc/guides/sample_app_ug/flow_filtering.rst +52 -10
@@ -106,7 +106,7 @@ following code: .. code-block:: c /* create flow for send packet with */ - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error); if (!flow) {
@@ -242,7 +242,7 @@ The Ethernet port is configured with default settings using the rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; -For this example we are configuring number of rx and tx queues that are connected +For this example we are configuring 2 rx and 2 tx queues that are connected to a single port. .. code-block:: c
@@ -270,13 +270,22 @@ to a single port. } } +Before we create the flow we create shared action in order to send it as +actions argument when creating a flow. The action is single queue RSS action +similar to action queue with the only difference that shared RSS action +provides update capability after action creation. + +.. code-block:: c + + shared_action = rte_flow_shared_action_create(port_id, &action, &error); + In the next step we create and apply the flow rule. which is to send packets with destination ip equals to 192.168.1.1 to queue number 1. The detail explanation of the ``generate_ipv4_flow()`` appears later in this document: .. code-block:: c - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error);
@@ -339,6 +348,21 @@ looks like the following: printf("\n"); rte_pktmbuf_free(m); } + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }
@@ -348,6 +372,8 @@ looks like the following: rte_eth_dev_close(port_id); } +On each loop eteration Rx queue switched using +``rte_flow_shared_action_update()`` API. The main work of the application is reading the packets from all queues and printing for each packet the destination queue:
@@ -365,6 +391,21 @@ queues and printing for each packet the destination queue: printf(" - queue=0x%x", (unsigned int)i); printf("\n"); rte_pktmbuf_free(m); + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }
@@ -378,13 +419,15 @@ The forwarding loop can be interrupted and the application closed using The generate_ipv4_flow function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The generate_ipv4_flow function is responsible for creating the flow rule. This function is located in the ``flow_blocks.c`` file. .. code-block:: c static struct rte_flow * - generate_ipv4_flow(uint8_t port_id, uint16_t rx_q, + generate_ipv4_flow(uint8_t port_id, + cstructrte_flow_shared_action *shared_action, uint32_t src_ip, uint32_t src_mask, uint32_t dest_ip, uint32_t dest_mask, struct rte_flow_error *error)
@@ -393,7 +436,6 @@ This function is located in the ``flow_blocks.c`` file. struct rte_flow_item pattern[MAX_PATTERN_NUM]; struct rte_flow_action action[MAX_ACTION_NUM]; struct rte_flow *flow = NULL; - struct rte_flow_action_queue queue = { .index = rx_q }; struct rte_flow_item_ipv4 ip_spec; struct rte_flow_item_ipv4 ip_mask;
@@ -411,8 +453,8 @@ This function is located in the ``flow_blocks.c`` file. * create the action sequence. * one action only, move packet to queue */ - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; /*
@@ -468,12 +510,12 @@ The following part create the flow attributes, in our case ingress. attr.ingress = 1; The third part defines the action to be taken when a packet matches -the rule. In this case send the packet to queue. +the rule. In this case send the packet to single RSS queue. .. code-block:: c - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; The fourth part is responsible for creating the pattern and is built from
examples/flow_filtering/flow_blocks.c +15 -15
@@ -6,11 +6,11 @@#define MAX_ACTION_NUM 2struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error); - +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error);/** * create a flow rule that sends packets with matching src and dest ip
@@ -18,8 +18,8 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* * @param port_id * The selected port. -* @param rx_q -* The selected target queue. +* @param shared_action +* The shared RSS action with single queue * @param src_ip * The src ip value to match the input packet. * @param src_mask
@@ -35,16 +35,16 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* A flow if the rule could be created else return NULL. */ struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error) +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error) {struct rte_flow_attr attr;struct rte_flow_item pattern[MAX_PATTERN_NUM ];struct rte_flow_action action[MAX_ACTION_NUM ];struct rte_flow *flow =NULL ; -struct rte_flow_action_queue queue = { .index = rx_q };struct rte_flow_item_ipv4 ip_spec;struct rte_flow_item_ipv4 ip_mask;int res;
@@ -61,10 +61,10 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,/* * create the action sequence. -* one action only, move packet to queue +* one action only, move packet to shared RSS queue */ - action[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; - action[0 ].conf = &queue; + action[0 ].type =RTE_FLOW_ACTION_TYPE_SHARED ; + action[0 ].conf = shared_action; action[1 ].type =RTE_FLOW_ACTION_TYPE_END ;/*
examples/flow_filtering/main.c +38 -3
72 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS action
Quoted 5 lines · Andrey Vesnovaty
This commit gives very first shared RSS action usage example and demonstrates shared action capability for in-place update.
First application creates shared action during initialization phase.
What if PMD does not support a shared context, Then this application fails to run?
if so, have a mode or probe the capability(if capability present then switches to new mode else fall back to old mode) before changing the application behavior.
Quoted 318 lines
Later on the flow object created by application uses previously created shared RSS action with 1 queue configured instead of queue action in original application.
On each RX queue burst shared RSS action reconfigured via
rte_flow_shared_action_update()API to switch queue 0 to 1 & 1 to 0. User supposed to observe consistent queue switches on each packet burst.Signed-off-by Andrey Vesnovaty <[email protected]>--- doc/guides/sample_app_ug/flow_filtering.rst | 62 +++++++++++++++++---- examples/flow_filtering/flow_blocks.c | 30 +++++----- examples/flow_filtering/main.c | 41 +++++++++++++- 3 files changed, 105 insertions(+), 28 deletions(-)doc/guides/sample_app_ug/flow_filtering.rst +52
-10@@ -106,7 +106,7 @@ following code: .. code-block:: c /* create flow for send packet with */ - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error); if (!flow) {@@ -242,7 +242,7 @@ The Ethernet port is configured with default settings using the rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; -For this example we are configuring number of rx and tx queues that are connected +For this example we are configuring 2 rx and 2 tx queues that are connected to a single port. .. code-block:: c@@ -270,13 +270,22 @@ to a single port. } } +Before we create the flow we create shared action in order to send it as +actions argument when creating a flow. The action is single queue RSS action +similar to action queue with the only difference that shared RSS action +provides update capability after action creation. + +.. code-block:: c + + shared_action = rte_flow_shared_action_create(port_id, &action, &error); + In the next step we create and apply the flow rule. which is to send packets with destination ip equals to 192.168.1.1 to queue number 1. The detail explanation of the ``generate_ipv4_flow()`` appears later in this document: .. code-block:: c - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error);@@ -339,6 +348,21 @@ looks like the following: printf("\n"); rte_pktmbuf_free(m); } + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }@@ -348,6 +372,8 @@ looks like the following: rte_eth_dev_close(port_id); } +On each loop eteration Rx queue switched using +``rte_flow_shared_action_update()`` API. The main work of the application is reading the packets from all queues and printing for each packet the destination queue:@@ -365,6 +391,21 @@ queues and printing for each packet the destination queue: printf(" - queue=0x%x", (unsigned int)i); printf("\n"); rte_pktmbuf_free(m); + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }@@ -378,13 +419,15 @@ The forwarding loop can be interrupted and the application closed using The generate_ipv4_flow function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The generate_ipv4_flow function is responsible for creating the flow rule. This function is located in the ``flow_blocks.c`` file. .. code-block:: c static struct rte_flow * - generate_ipv4_flow(uint8_t port_id, uint16_t rx_q, + generate_ipv4_flow(uint8_t port_id, + cstructrte_flow_shared_action *shared_action, uint32_t src_ip, uint32_t src_mask, uint32_t dest_ip, uint32_t dest_mask, struct rte_flow_error *error)@@ -393,7 +436,6 @@ This function is located in the ``flow_blocks.c`` file. struct rte_flow_item pattern[MAX_PATTERN_NUM]; struct rte_flow_action action[MAX_ACTION_NUM]; struct rte_flow *flow = NULL; - struct rte_flow_action_queue queue = { .index = rx_q }; struct rte_flow_item_ipv4 ip_spec; struct rte_flow_item_ipv4 ip_mask;@@ -411,8 +453,8 @@ This function is located in the ``flow_blocks.c`` file. * create the action sequence. * one action only, move packet to queue */ - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; /*@@ -468,12 +510,12 @@ The following part create the flow attributes, in our case ingress. attr.ingress = 1; The third part defines the action to be taken when a packet matches -the rule. In this case send the packet to queue. +the rule. In this case send the packet to single RSS queue. .. code-block:: c - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; The fourth part is responsible for creating the pattern and is built fromexamples/flow_filtering/flow_blocks.c +15
-15@@ -6,11 +6,11 @@#define MAX_ACTION_NUM 2struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error); - +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error);/** * create a flow rule that sends packets with matching src and dest ip @@ -18,8 +18,8 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* * @param port_id * The selected port. -* @param rx_q -* The selected target queue. +* @param shared_action +* The shared RSS action with single queue * @param src_ip * The src ip value to match the input packet. * @param src_mask @@ -35,16 +35,16 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* A flow if the rule could be created else return NULL. */ struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error) +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error) {struct rte_flow_attr attr;struct rte_flow_item pattern[MAX_PATTERN_NUM ];struct rte_flow_action action[MAX_ACTION_NUM ];struct rte_flow *flow =NULL ; -struct rte_flow_action_queue queue = { .index = rx_q };struct rte_flow_item_ipv4 ip_spec;struct rte_flow_item_ipv4 ip_mask;int res;@@ -61,10 +61,10 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,/* * create the action sequence. -* one action only, move packet to queue +* one action only, move packet to shared RSS queue */ - action[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; - action[0 ].conf = &queue; + action[0 ].type =RTE_FLOW_ACTION_TYPE_SHARED ; + action[0 ].conf = shared_action; action[1 ].type =RTE_FLOW_ACTION_TYPE_END ;/* examples/flow_filtering/main.c +38
-4@@ -32,8 +32,7 @@static volatile bool force_quit;static uint16_t port_id; -static uint16_t nr_queues =5 ; -static uint8_t selected_queue =1 ; +static uint16_t nr_queues =2 ;struct rte_mempool *mbuf_pool;struct rte_flow *flow;@@ -42,6 +41,24 @@ struct rte_flow *flow;#define FULL_MASK 0xffffffff/* full mask */ #define EMPTY_MASK 0x0/* empty mask */ +struct rte_flow_shared_action *shared_action; +uint16_t rss_queue[1 ] = {0 }; + +struct rte_flow_action_rss action_rss = { + .func =RTE_ETH_HASH_FUNCTION_DEFAULT , + .level =0 , + .types =0 , + .key_len =0 , + .key =NULL , + .queue = rss_queue, + .queue_num =1 , +}; + +struct rte_flow_action action = { + .type =RTE_FLOW_ACTION_TYPE_RSS , + .conf = &action_rss, +}; +#include "flow_blocks.c" static inline void@@ -61,6 +78,7 @@ main_loop(void)uint16_t nb_rx;uint16_t i;uint16_t j; +int ret;while (!force_quit) {for (i =0 ; i < nr_queues; i++) {@@ -82,6 +100,21 @@ main_loop(void)rte_pktmbuf_free (m); } +if (rss_queue[0 ] ==0 ) { +printf (">>> switching queue 0 -> 1\n" ); + rss_queue[0 ] =1 ; + }else { +printf (">>> switching queue 1 -> 0\n" ); + rss_queue[0 ] =0 ; + } + ret =rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); +if (ret) +rte_exit (EXIT_FAILURE , +":: error: RSS action update " +"failed: %s\n" , +rte_strerror (-ret)); } } }@@ -243,8 +276,10 @@ main(int argc, char **argv)init_port (); + shared_action =rte_flow_shared_action_create (port_id, &action, &error); +/* create flow for send packet with */ - flow =generate_ipv4_flow (port_id, selected_queue, + flow =generate_ipv4_flow (port_id, shared_action,SRC_IP ,EMPTY_MASK ,DEST_IP ,FULL_MASK , &error);if (!flow) { --2.26.2
Re: [dpdk-dev] [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS action
Hi Andrey,
Quoted 22 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, July 9, 2020 7:44 AM
To: Andrey Vesnovaty <[email protected]>
Cc: dpdk-dev <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Stephen Hemminger <[email protected]>; Richardson, Bruce <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Andrey Vesnovaty <[email protected]>; Marko Kovacevic <[email protected]>; Radu Nicolau <[email protected]>; Akhil Goyal <[email protected]>; Tomasz Kantecki <[email protected]>; Sunil Kumar Kori <[email protected]>; Pavan Nikhilesh <[email protected]>; John McNamara <[email protected]>
Subject: Re: [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS actionQuoted 4 lines · Andrey Vesnovaty
This commit gives very first shared RSS action usage example and demonstrates shared action capability for in-place update.
Quoted 8 lines
Quoted 1 line
First application creates shared action during initialization phase.
What if PMD does not support a shared context, Then this application fails to run?
if so, have a mode or probe the capability(if capability present then switches to new mode else fall back to old mode) before changing the application behavior.
+1 the new action should be added as a new case and should run only if it is the shared action is supported.
Quoted 328 lines
Quoted 9 lines
Later on the flow object created by application uses previously created shared RSS action with 1 queue configured instead of queue action in original application.
On each RX queue burst shared RSS action reconfigured via
rte_flow_shared_action_update()API to switch queue 0 to 1 & 1 to 0. User supposed to observe consistent queue switches on each packet burst.Review
Quoted 8 lines
Signed-off-by Andrey Vesnovaty <[email protected]>--- doc/guides/sample_app_ug/flow_filtering.rst | 62 +++++++++++++++++---- examples/flow_filtering/flow_blocks.c | 30 +++++----- examples/flow_filtering/main.c | 41 +++++++++++++- 3 files changed, 105 insertions(+), 28 deletions(-)(quoted diff) +0
-0
b/doc/guides/sample_app_ug/flow_filtering.rstdoc/guides/sample_app_ug/flow_filtering.rst The Ethernet port is configured with default settings
Quoted 13 lines
index
5e5a6cd8a0..cfe9334717100644doc/guides/sample_app_ug/flow_filtering.rst +1
-1@@ -106,7 +106,7 @@ following code: .. code-block:: c /* create flow for send packet with */ - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error); if (!flow) {@@ -242,7 +242,7 @@ The Ethernet port is configured with default settingsusing the
doc/guides/sample_app_ug/flow_filtering.rst The Ethernet port is configured with default settings using the
Quoted 4 lines
doc/guides/sample_app_ug/flow_filtering.rst +0
-1rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; -For this example we are configuring number of rx and tx queues that areconnected
doc/guides/sample_app_ug/flow_filtering.rst to a single port. · line 274
Quoted 10 lines
doc/guides/sample_app_ug/flow_filtering.rst +3
-0+For this example we are configuring 2 rx and 2 tx queues that are connected to a single port. .. code-block:: c@@ -270,13 +270,22 @@ to a single port. } } +Before we create the flow we create shared action in order to send it as +actions argument when creating a flow. The action is single queue RSSaction
doc/guides/sample_app_ug/flow_filtering.rst queues and printing for each packet the destination
Quoted 50 lines
doc/guides/sample_app_ug/flow_filtering.rst +25
-1+similar to action queue with the only difference that shared RSS action +provides update capability after action creation. + +.. code-block:: c + + shared_action = rte_flow_shared_action_create(port_id, &action, &error); + In the next step we create and apply the flow rule. which is to send packets with destination ip equals to 192.168.1.1 to queue number 1. The detail explanation of the ``generate_ipv4_flow()`` appears later in this document: .. code-block:: c - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error);@@ -339,6 +348,21 @@ looks like the following: printf("\n"); rte_pktmbuf_free(m); } + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }@@ -348,6 +372,8 @@ looks like the following: rte_eth_dev_close(port_id); } +On each loop eteration Rx queue switched using +``rte_flow_shared_action_update()`` API. The main work of the application is reading the packets from all queues and printing for each packet the destination queue:@@ -365,6 +391,21 @@ queues and printing for each packet the destinationqueue:
doc/guides/sample_app_ug/flow_filtering.rst The forwarding loop can be interrupted and the
Quoted 22 lines
doc/guides/sample_app_ug/flow_filtering.rst +15
-0printf(" - queue=0x%x", (unsigned int)i); printf("\n"); rte_pktmbuf_free(m); + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }@@ -378,13 +419,15 @@ The forwarding loop can be interrupted and theapplication closed using
doc/guides/sample_app_ug/flow_filtering.rst The following part create the flow attributes, in
Quoted 36 lines
doc/guides/sample_app_ug/flow_filtering.rst +5
-4The generate_ipv4_flow function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The generate_ipv4_flow function is responsible for creating the flow rule. This function is located in the ``flow_blocks.c`` file. .. code-block:: c static struct rte_flow * - generate_ipv4_flow(uint8_t port_id, uint16_t rx_q, + generate_ipv4_flow(uint8_t port_id, + cstructrte_flow_shared_action *shared_action, uint32_t src_ip, uint32_t src_mask, uint32_t dest_ip, uint32_t dest_mask, struct rte_flow_error *error)@@ -393,7 +436,6 @@ This function is located in the ``flow_blocks.c`` file. struct rte_flow_item pattern[MAX_PATTERN_NUM]; struct rte_flow_action action[MAX_ACTION_NUM]; struct rte_flow *flow = NULL; - struct rte_flow_action_queue queue = { .index = rx_q }; struct rte_flow_item_ipv4 ip_spec; struct rte_flow_item_ipv4 ip_mask;@@ -411,8 +453,8 @@ This function is located in the ``flow_blocks.c`` file. * create the action sequence. * one action only, move packet to queue */ - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; /*@@ -468,12 +510,12 @@ The following part create the flow attributes, inour case ingress.
Review
Quoted 16 lines
doc/guides/sample_app_ug/flow_filtering.rst +3
-3attr.ingress = 1; The third part defines the action to be taken when a packet matches -the rule. In this case send the packet to queue. +the rule. In this case send the packet to single RSS queue. .. code-block:: c - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; The fourth part is responsible for creating the pattern and is built from(quoted diff) +0
-0
b/examples/flow_filtering/flow_blocks.cQuoted 137 lines
index
575d792810..99bfed3172100644examples/flow_filtering/flow_blocks.c +15
-15@@ -6,11 +6,11 @@#define MAX_ACTION_NUM 2struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error); - +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error);/** * create a flow rule that sends packets with matching src and dest ip @@ -18,8 +18,8 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* * @param port_id * The selected port. -* @param rx_q -* The selected target queue. +* @param shared_action +* The shared RSS action with single queue * @param src_ip * The src ip value to match the input packet. * @param src_mask @@ -35,16 +35,16 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* A flow if the rule could be created else return NULL. */ struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error) +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error) {struct rte_flow_attr attr;struct rte_flow_item pattern[MAX_PATTERN_NUM ];struct rte_flow_action action[MAX_ACTION_NUM ];struct rte_flow *flow =NULL ; -struct rte_flow_action_queue queue = { .index = rx_q };struct rte_flow_item_ipv4 ip_spec;struct rte_flow_item_ipv4 ip_mask;int res;@@ -61,10 +61,10 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,/* * create the action sequence. -* one action only, move packet to queue +* one action only, move packet to shared RSS queue */ - action[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; - action[0 ].conf = &queue; + action[0 ].type =RTE_FLOW_ACTION_TYPE_SHARED ; + action[0 ].conf = shared_action; action[1 ].type =RTE_FLOW_ACTION_TYPE_END ;/* examples/flow_filtering/main.c +35
-2@@ -32,8 +32,7 @@static volatile bool force_quit;static uint16_t port_id; -static uint16_t nr_queues =5 ; -static uint8_t selected_queue =1 ; +static uint16_t nr_queues =2 ;struct rte_mempool *mbuf_pool;struct rte_flow *flow;@@ -42,6 +41,24 @@ struct rte_flow *flow;#define FULL_MASK 0xffffffff/* full mask */ #define EMPTY_MASK 0x0/* empty mask */ +struct rte_flow_shared_action *shared_action; +uint16_t rss_queue[1 ] = {0 }; + +struct rte_flow_action_rss action_rss = { + .func =RTE_ETH_HASH_FUNCTION_DEFAULT , + .level =0 , + .types =0 , + .key_len =0 , + .key =NULL , + .queue = rss_queue, + .queue_num =1 , +}; + +struct rte_flow_action action = { + .type =RTE_FLOW_ACTION_TYPE_RSS , + .conf = &action_rss, +}; +#include "flow_blocks.c" static inline void@@ -61,6 +78,7 @@ main_loop(void)uint16_t nb_rx;uint16_t i;uint16_t j; +int ret;while (!force_quit) {for (i =0 ; i < nr_queues; i++) {@@ -82,6 +100,21 @@ main_loop(void)rte_pktmbuf_free (m); } +if (rss_queue[0 ] ==0 ) { +printf (">>> switching queue 0 -> 1\n" ); + rss_queue[0 ] =1 ; + }else { +printf (">>> switching queue 1 -> 0\n" ); + rss_queue[0 ] =0 ; + } + ret =rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); +if (ret) +rte_exit (EXIT_FAILURE , +":: error: RSS action update " +"failed: %s\n" , +rte_strerror (-ret)); } } }examples/flow_filtering/main.c main(int argc, char **argv) · line 279
Quoted 4 lines
examples/flow_filtering/main.c +1
-0@@ -243,8 +276,10 @@ main(int argc, char **argv)init_port (); + shared_action = rte_flow_shared_action_create(port_id, &action,&error);
Quoted 10 lines
examples/flow_filtering/main.c +2
-2+/* create flow for send packet with */ - flow =generate_ipv4_flow (port_id, selected_queue, + flow =generate_ipv4_flow (port_id, shared_action,SRC_IP ,EMPTY_MASK ,DEST_IP ,FULL_MASK , &error);if (!flow) { --2.26.2
Re: [dpdk-dev] [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS action
Hi, Jerin and Ferruh
First of all it's decided to postpone this effort to 20.11. @[email protected] I sincerely believe we can work out great API for
- shared action, context
- action update / modification / replacement
after 20.08 without time pressure & stress.
I'm fully committed and will continue to work on this PATCH. I'll resend improved version of this patch once 20.08 is out & we will continue our discussion from here to make it even better.
Many thanks to all participants of this discussion, Andrey
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Thursday, July 9, 2020 9:09 AM
To: Jerin Jacob <[email protected]>; Andrey Vesnovaty <[email protected]>
Cc: dpdk-dev <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Stephen Hemminger <[email protected]>; Richardson, Bruce <[email protected]>; Slava Ovsiienko <[email protected]>; Andrey Vesnovaty <[email protected]>; Marko Kovacevic <[email protected]>; Radu Nicolau <[email protected]>; Akhil Goyal <[email protected]>; Tomasz Kantecki <[email protected]>; Sunil Kumar Kori <[email protected]>; Pavan Nikhilesh <[email protected]>; John McNamara <[email protected]>
Subject: RE: [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS action
Hi Andrey,
Quoted 22 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, July 9, 2020 7:44 AM
To: Andrey Vesnovaty <[email protected]>
Cc: dpdk-dev <[email protected]>; [email protected]; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Stephen Hemminger <[email protected]>; Richardson, Bruce <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Andrey Vesnovaty <[email protected]>; Marko Kovacevic <[email protected]>; Radu Nicolau <[email protected]>; Akhil Goyal <[email protected]>; Tomasz Kantecki <[email protected]>; Sunil Kumar Kori <[email protected]>; Pavan Nikhilesh <[email protected]>; John McNamara <[email protected]>
Subject: Re: [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS actionQuoted 4 lines · Andrey Vesnovaty
This commit gives very first shared RSS action usage example and demonstrates shared action capability for in-place update.
Quoted 8 lines
Quoted 1 line
First application creates shared action during initialization phase.
What if PMD does not support a shared context, Then this application fails to run?
if so, have a mode or probe the capability(if capability present then switches to new mode else fall back to old mode) before changing the application behavior.
+1 the new action should be added as a new case and should run only if it is the shared action is supported.
Quoted 328 lines
Quoted 9 lines
Later on the flow object created by application uses previously created shared RSS action with 1 queue configured instead of queue action in original application.
On each RX queue burst shared RSS action reconfigured via
rte_flow_shared_action_update()API to switch queue 0 to 1 & 1 to 0. User supposed to observe consistent queue switches on each packet burst.Review
Quoted 8 lines
Signed-off-by Andrey Vesnovaty <[email protected]>--- doc/guides/sample_app_ug/flow_filtering.rst | 62 +++++++++++++++++---- examples/flow_filtering/flow_blocks.c | 30 +++++----- examples/flow_filtering/main.c | 41 +++++++++++++- 3 files changed, 105 insertions(+), 28 deletions(-)(quoted diff) +0
-0
b/doc/guides/sample_app_ug/flow_filtering.rstdoc/guides/sample_app_ug/flow_filtering.rst The Ethernet port is configured with default settings
Quoted 13 lines
index
5e5a6cd8a0..cfe9334717100644doc/guides/sample_app_ug/flow_filtering.rst +1
-1@@ -106,7 +106,7 @@ following code: .. code-block:: c /* create flow for send packet with */ - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error); if (!flow) {@@ -242,7 +242,7 @@ The Ethernet port is configured with default settingsusing the
doc/guides/sample_app_ug/flow_filtering.rst The Ethernet port is configured with default settings using the
Quoted 4 lines
doc/guides/sample_app_ug/flow_filtering.rst +0
-1rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; -For this example we are configuring number of rx and tx queues that areconnected
doc/guides/sample_app_ug/flow_filtering.rst to a single port. · line 274
Quoted 10 lines
doc/guides/sample_app_ug/flow_filtering.rst +3
-0+For this example we are configuring 2 rx and 2 tx queues that are connected to a single port. .. code-block:: c@@ -270,13 +270,22 @@ to a single port. } } +Before we create the flow we create shared action in order to send it as +actions argument when creating a flow. The action is single queue RSSaction
doc/guides/sample_app_ug/flow_filtering.rst queues and printing for each packet the destination
Quoted 50 lines
doc/guides/sample_app_ug/flow_filtering.rst +25
-1+similar to action queue with the only difference that shared RSS action +provides update capability after action creation. + +.. code-block:: c + + shared_action = rte_flow_shared_action_create(port_id, &action, &error); + In the next step we create and apply the flow rule. which is to send packets with destination ip equals to 192.168.1.1 to queue number 1. The detail explanation of the ``generate_ipv4_flow()`` appears later in this document: .. code-block:: c - flow = generate_ipv4_flow(port_id, selected_queue, + flow = generate_ipv4_flow(port_id, shared_action, SRC_IP, EMPTY_MASK, DEST_IP, FULL_MASK, &error);@@ -339,6 +348,21 @@ looks like the following: printf("\n"); rte_pktmbuf_free(m); } + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }@@ -348,6 +372,8 @@ looks like the following: rte_eth_dev_close(port_id); } +On each loop eteration Rx queue switched using +``rte_flow_shared_action_update()`` API. The main work of the application is reading the packets from all queues and printing for each packet the destination queue:@@ -365,6 +391,21 @@ queues and printing for each packet the destinationqueue:
doc/guides/sample_app_ug/flow_filtering.rst The forwarding loop can be interrupted and the
Quoted 22 lines
doc/guides/sample_app_ug/flow_filtering.rst +15
-0printf(" - queue=0x%x", (unsigned int)i); printf("\n"); rte_pktmbuf_free(m); + if (rss_queue[0] == 0) { + printf(">>> switching queue 0 -> 1\n"); + rss_queue[0] = 1; + } else { + printf(">>> switching queue 1 -> 0\n"); + rss_queue[0] = 0; + } + ret = rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); + if (ret) + rte_exit(EXIT_FAILURE, + ":: error: RSS action update " + "failed: %s\n", + rte_strerror(-ret)); } } }@@ -378,13 +419,15 @@ The forwarding loop can be interrupted and theapplication closed using
doc/guides/sample_app_ug/flow_filtering.rst The following part create the flow attributes, in
Quoted 36 lines
doc/guides/sample_app_ug/flow_filtering.rst +5
-4The generate_ipv4_flow function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The generate_ipv4_flow function is responsible for creating the flow rule. This function is located in the ``flow_blocks.c`` file. .. code-block:: c static struct rte_flow * - generate_ipv4_flow(uint8_t port_id, uint16_t rx_q, + generate_ipv4_flow(uint8_t port_id, + cstructrte_flow_shared_action *shared_action, uint32_t src_ip, uint32_t src_mask, uint32_t dest_ip, uint32_t dest_mask, struct rte_flow_error *error)@@ -393,7 +436,6 @@ This function is located in the ``flow_blocks.c`` file. struct rte_flow_item pattern[MAX_PATTERN_NUM]; struct rte_flow_action action[MAX_ACTION_NUM]; struct rte_flow *flow = NULL; - struct rte_flow_action_queue queue = { .index = rx_q }; struct rte_flow_item_ipv4 ip_spec; struct rte_flow_item_ipv4 ip_mask;@@ -411,8 +453,8 @@ This function is located in the ``flow_blocks.c`` file. * create the action sequence. * one action only, move packet to queue */ - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; /*@@ -468,12 +510,12 @@ The following part create the flow attributes, inour case ingress.
Review
Quoted 16 lines
doc/guides/sample_app_ug/flow_filtering.rst +3
-3attr.ingress = 1; The third part defines the action to be taken when a packet matches -the rule. In this case send the packet to queue. +the rule. In this case send the packet to single RSS queue. .. code-block:: c - action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; - action[0].conf = &queue; + action[0].type = RTE_FLOW_ACTION_TYPE_SHARED; + action[0].conf = shared_action; action[1].type = RTE_FLOW_ACTION_TYPE_END; The fourth part is responsible for creating the pattern and is built from(quoted diff) +0
-0
b/examples/flow_filtering/flow_blocks.cQuoted 137 lines
index
575d792810..99bfed3172100644examples/flow_filtering/flow_blocks.c +15
-15@@ -6,11 +6,11 @@#define MAX_ACTION_NUM 2struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error); - +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error);/** * create a flow rule that sends packets with matching src and dest ip @@ -18,8 +18,8 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* * @param port_id * The selected port. -* @param rx_q -* The selected target queue. +* @param shared_action +* The shared RSS action with single queue * @param src_ip * The src ip value to match the input packet. * @param src_mask @@ -35,16 +35,16 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,* A flow if the rule could be created else return NULL. */ struct rte_flow * -generate_ipv4_flow (uint16_t port_id,uint16_t rx_q, -uint32_t src_ip,uint32_t src_mask, -uint32_t dest_ip,uint32_t dest_mask, -struct rte_flow_error *error) +generate_ipv4_flow (uint16_t port_id, +struct rte_flow_shared_action *shared_action, +uint32_t src_ip,uint32_t src_mask, +uint32_t dest_ip,uint32_t dest_mask, +struct rte_flow_error *error) {struct rte_flow_attr attr;struct rte_flow_item pattern[MAX_PATTERN_NUM ];struct rte_flow_action action[MAX_ACTION_NUM ];struct rte_flow *flow =NULL ; -struct rte_flow_action_queue queue = { .index = rx_q };struct rte_flow_item_ipv4 ip_spec;struct rte_flow_item_ipv4 ip_mask;int res;@@ -61,10 +61,10 @@ generate_ipv4_flow(uint16_t port_id, uint16_t rx_q,/* * create the action sequence. -* one action only, move packet to queue +* one action only, move packet to shared RSS queue */ - action[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; - action[0 ].conf = &queue; + action[0 ].type =RTE_FLOW_ACTION_TYPE_SHARED ; + action[0 ].conf = shared_action; action[1 ].type =RTE_FLOW_ACTION_TYPE_END ;/* examples/flow_filtering/main.c +35
-2@@ -32,8 +32,7 @@static volatile bool force_quit;static uint16_t port_id; -static uint16_t nr_queues =5 ; -static uint8_t selected_queue =1 ; +static uint16_t nr_queues =2 ;struct rte_mempool *mbuf_pool;struct rte_flow *flow;@@ -42,6 +41,24 @@ struct rte_flow *flow;#define FULL_MASK 0xffffffff/* full mask */ #define EMPTY_MASK 0x0/* empty mask */ +struct rte_flow_shared_action *shared_action; +uint16_t rss_queue[1 ] = {0 }; + +struct rte_flow_action_rss action_rss = { + .func =RTE_ETH_HASH_FUNCTION_DEFAULT , + .level =0 , + .types =0 , + .key_len =0 , + .key =NULL , + .queue = rss_queue, + .queue_num =1 , +}; + +struct rte_flow_action action = { + .type =RTE_FLOW_ACTION_TYPE_RSS , + .conf = &action_rss, +}; +#include "flow_blocks.c" static inline void@@ -61,6 +78,7 @@ main_loop(void)uint16_t nb_rx;uint16_t i;uint16_t j; +int ret;while (!force_quit) {for (i =0 ; i < nr_queues; i++) {@@ -82,6 +100,21 @@ main_loop(void)rte_pktmbuf_free (m); } +if (rss_queue[0 ] ==0 ) { +printf (">>> switching queue 0 -> 1\n" ); + rss_queue[0 ] =1 ; + }else { +printf (">>> switching queue 1 -> 0\n" ); + rss_queue[0 ] =0 ; + } + ret =rte_flow_shared_action_update + (port_id, shared_action, &action, + &error); +if (ret) +rte_exit (EXIT_FAILURE , +":: error: RSS action update " +"failed: %s\n" , +rte_strerror (-ret)); } } }examples/flow_filtering/main.c main(int argc, char **argv) · line 279
Quoted 4 lines
examples/flow_filtering/main.c +1
-0@@ -243,8 +276,10 @@ main(int argc, char **argv)init_port (); + shared_action = rte_flow_shared_action_create(port_id, &action,&error);
Quoted 10 lines
examples/flow_filtering/main.c +2
-2+/* create flow for send packet with */ - flow =generate_ipv4_flow (port_id, selected_queue, + flow =generate_ipv4_flow (port_id, shared_action,SRC_IP ,EMPTY_MASK ,DEST_IP ,FULL_MASK , &error);if (!flow) { --2.26.2
Re: [dpdk-dev] [PATCH v2 6/6] examples/flow_filtering: utilize shared RSS action
09/07/2020 14:25, Andrey Vesnovaty:
Quoted 11 lines
Hi, Jerin and Ferruh
First of all it's decided to postpone this effort to 20.11. @[email protected] I sincerely believe we can work out great API for
- shared action, context
- action update / modification / replacement
after 20.08 without time pressure & stress.I'm fully committed and will continue to work on this PATCH. I'll resend improved version of this patch once 20.08 is out & we will continue our discussion from here to make it even better.
I don't think you should wait 20.08 (one month) to progress. Ideally, it should be ready to be merged in the first day of 20.11 cycle.
Please add the feature in the release notes (even in 20.08 one in the meantime).
Re: [dpdk-dev] [PATCH v2 0/6] add flow shared action API + PMD
In reply to Andrey VesnovatyQuoted 10 lines · Andrey Vesnovaty
Hi Jerin and Ori.
V2 changes:
- First version of PMD implementation for shared action API.
- Simple example application demonstaration shared action update.
- Changes to shred action API according to discussion of V1.@Jerin Jacob: please take a look at provided example, hopefully it will help to converge our API discussion and reach consensus on it.
I am sorry, Based on my understanding it is not addressing API sequence query[1]
[1]
---
http://mails.dpdk.org/archives/dev/2020-July/173997.html
ie.
Otherway to ask is, Could you have share the API call sequence using "rte_flow_shared_action_update(uint16_port port, rte_shared_ctx *ctx, rte_flow_action *action, error)"
to enable support for the following category of HW as I mentioned earlier.
- The HW has "pattern" and "action" mapped to different HW objects and action can be updated any time without destroying and create.(a,k,a Does not have shared HW object)
---
Quoted 36 lines
Thanks,
AndreyAndrey Vesnovaty (6):
ethdev: add flow shared action API common/mlx5: modify advanced Rx object via DevX net/mlx5: modify hash Rx queue objects net/mlx5: shared action PMD
net/mlx5: driver support for shared action examples/flow_filtering: utilize shared RSS actiondoc/guides/sample_app_ug/flow_filtering.rst | 62 +- drivers/common/mlx5/mlx5_devx_cmds.c | 84 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 10 + drivers/common/mlx5/mlx5_prm.h | 29 + .../common/mlx5/rte_common_mlx5_version.map | 1 + drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_defs.h | 3 + drivers/net/mlx5/mlx5_flow.c | 492 ++++++++++++- drivers/net/mlx5/mlx5_flow.h | 83 +++ drivers/net/mlx5/mlx5_flow_dv.c | 671 +++++++++++++++++- drivers/net/mlx5/mlx5_rxq.c | 300 ++++++-- drivers/net/mlx5/mlx5_rxtx.h | 4 + examples/flow_filtering/flow_blocks.c | 30 +- examples/flow_filtering/main.c | 41 +- lib/librte_ethdev/rte_ethdev_version.map | 6 + lib/librte_ethdev/rte_flow.c | 81 +++ lib/librte_ethdev/rte_flow.h | 148 +++- lib/librte_ethdev/rte_flow_driver.h | 22 + 19 files changed, 1924 insertions(+), 146 deletions(-)--
2.26.2
v4 cover RTE flow shared action
In reply to Andrey VesnovatyThis patchset introduces shared action API for RTE flow.
V4 changes:
* patchset split to:
1. shared action API (this patchset)
2. mlx5 PMD implementation for shared action API
* testpmd for shared action CLI documented
* release notes for 20.11 updated with shared action feature
* misc spelling fixes and rephrase in commit messages
* flow_filtering example removed in favor of testpmd
Andrey Vesnovaty (2):
ethdev: add flow shared action API
app/testpmd: support shared action
app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 217 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/rel_notes/release_20_11.rst | 9 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++ lib/librte_ethdev/rte_flow.h | 161 +++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++ 9 files changed, 888 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH v4 1/2 ethdev: add flow shared action API
This commit introduces extension of DPDK flow action API enabling sharing of single rte_flow_action in multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.
Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- call rte_flow_destroy()
- call rte_flow_create() with modified RSS action
API for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flows
Change description
===
Shared action
===
In order to represent flow action shared by multiple flows new action type RTE_FLOW_ACTION_TYPE_SHARED is introduced (see enum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (see rte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (see rte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.
In order to share some flow action reuse the handle of type struct rte_flow_shared_action returned by rte_flow_shared_action_create() as a conf field of struct rte_flow_action (see "example" section).
If some shared action not used by any flow rule all resources allocated by the shared action can be released by rte_flow_shared_action_destroy() (see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.
Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated via rte_flow_shared_action_update() (see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.
Shared action query
===
Provide separate API to query shared action state (see rte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled by rte_flow_shared_action_create() and rte_flow_shared_action_update() APIs and no supposed to change by other means.
PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see struct rte_flow_ops).
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordingly
flow shared_action (port) create {action_id (id)} (action) / end flow shared_action (port) update (id) (action) / end
flow shared_action (port) destroy action_id (id) {action_id (id) [...]} flow shared_action (port) query (id)
testpmd example
===
configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / end
create flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \
actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / end
example
===
struct rte_flow_action actions[2];
struct rte_flow_action action;
/* skipped: initialize action */
struct rte_flow_shared_action *handle = rte_flow_shared_action_create(
port_id, &action, &error);
actions[0].type = RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type = RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
struct rte_flow *flow0 = rte_flow_create(port_id, &attr0, pattern0,
actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);
/* update shared action */
struct rte_flow_action updated_action;
/*
* skipped: initialize updated_action according to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
* updated_action
*/
/* skipped: destroy all flows 1 till N */ rte_flow_shared_action_destroy(port_id, handle, error);
--- doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 ++++++++++++ lib/librte_ethdev/rte_flow.h | 161 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++++ 5 files changed, 280 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_20_11.rst +9 -0
@@ -55,6 +55,15 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Add shared action support for rte flow.** + + Added shared action support to utilize single rte flow action in multiple + rte flow rules. An update of shared action configuration alters the behavior + of all rte flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared action + as rte flow action. + * Added new rte flow APIs to create/update/destroy/query shared action. Removed Items -------------
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -225,6 +225,10 @@ EXPERIMENTAL { rte_tm_shared_wred_context_delete; rte_tm_wred_profile_add; rte_tm_wred_profile_delete; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query; }; INTERNAL {
lib/librte_ethdev/rte_flow.c +84 -0
93 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +160 -1
185 lines not on this page · raw message
lib/librte_ethdev/rte_flow_driver.h +23 -0
@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v4 1/2] ethdev: add flow shared action API
Hi Andrey,
PSB,
Best,
Ori
Quoted 148 lines
-----Original Message-----
From: Andrey Vesnovaty <[email protected]>
Sent: Tuesday, October 6, 2020 11:09 PM
Subject: [PATCH v4 1/2] ethdev: add flow shared action APIThis commit introduces extension of DPDK flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endexample
===struct
rte_flow_actionactions[2];
structrte_flow_actionaction;
/* skipped: initialize action */
structrte_flow_shared_action*handle = rte_flow_shared_action_create(port_id, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);
Quoted 9 lines
Signed-off-by Andrey Vesnovaty <[email protected]>--- doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 ++++++++++++ lib/librte_ethdev/rte_flow.h | 161 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++++ 5 files changed, 280 insertions(+), 1 deletion(-)
Missing rte_flow.rst update.
[snip ...]
PATCH v4 2/2 app/testpmd: support shared action
In reply to Andrey VesnovatyThis patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flow shared_action (port) create {action_id (shared_action_id)} \
(action) / end
Create shared action examples:
flow shared_action 0 create action_id 100 \
rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.
flow shared_action 0 create action_id \
rss queues 0 1 end / end
This creates shared rss action with id assigned by tetspmd on port 0.
Update shared action syntax:
flow shared_action (port) update (shared_action_id) (action) / end
Update shared action example:
flow shared_action 0 update 100 rss queues 0 3 end / end This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).
Destroy shared action syntax:
flow shared_action (port) destroy action_id (shared_action_id) \
{ action_id (shared_action_id) [...]}Update shared action example:
flow shared_action 0 destroy action_id 100 action_id 101 This destroys shared actions having id 100 & 101
Query shared action syntax:
flow shared_action (port) query (shared_action_id)
Query shared action example:
flow shared_action 0 query 100
This queries shared actions having id 100
Use shared action as flow action syntax:
flow create (port) ... / end actions {action / [...]} \
shared (action_id) / {action / [...]} endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \ actions shared 100 / end This creates flow rule where rss action is shared rss action having id 100.
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
--- app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 217 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ 4 files changed, 608 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +261 -1
@@ -49,6 +49,7 @@ enum index {PORT_ID ,GROUP_ID ,PRIORITY_LEVEL , +SHARED_ACTION_ID ,/* Top-level command. */ SET,
@@ -60,6 +61,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +SHARED_ACTION ,VALIDATE ,CREATE , DESTROY,
@@ -89,6 +91,18 @@ enum index {EGRESS ,TRANSFER , +/* Shared action arguments */ +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , + +/* Shared action create arguments */ +SHARED_ACTION_CREATE_ID , + +/* Shared action destroy arguments */ +SHARED_ACTION_DESTROY_ID , +/* Validate/create pattern. */ PATTERN , ITEM_PARAM_IS,
@@ -358,6 +372,8 @@ enum index {ACTION_SET_IPV6_DSCP_VALUE ,ACTION_AGE ,ACTION_AGE_TIMEOUT , +ACTION_SHARED , + SHARED_ACTION_ID2PTR, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -651,6 +667,13 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +uint32_t *action_id; +uint32_t action_id_n; + } sa_destroy;/**< Shared action destroy arguments. */ +struct { +uint32_t action_id; + } sa;/* Shared action query arguments */ struct {struct rte_flow_attr attr;struct rte_flow_item *pattern;
@@ -707,6 +730,19 @@ struct parse_action_priv { .size = s, \ }) +static const enum index next_sa_create_attr[] = { +SHARED_ACTION_CREATE_ID , +ACTION_RSS , +ZERO , +}; + +static const enum index next_sa_subcmd[] = { +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , +}; +static const enum index next_vc_attr[] = {GROUP ,PRIORITY ,
@@ -741,6 +777,12 @@ static const enum index next_aged_attr[] = { ZERO, }; +static const enum index next_sa_destroy_attr[] = { +SHARED_ACTION_DESTROY_ID , +END , +ZERO , +}; +static const enum index item_param[] = {ITEM_PARAM_IS ,ITEM_PARAM_SPEC ,
@@ -1189,6 +1231,7 @@ static const enum index next_action[] = {ACTION_SET_IPV4_DSCP ,ACTION_SET_IPV6_DSCP ,ACTION_AGE , +ACTION_SHARED , ZERO, };
@@ -1546,6 +1589,15 @@ static int parse_ipv6_addr(struct context *, const struct token *,static int parse_port (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_sa (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size); +static int parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int comp_none (struct context *,const struct token *,unsigned int ,char *,unsigned int ); static int comp_boolean(struct context *, const struct token *,
@@ -1684,13 +1736,21 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_none, }, + [SHARED_ACTION_ID] = { + .name = "{shared_action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .call = parse_int, + .comp = comp_none, + },/* Top-level command. */ [FLOW] = { .name = "flow", .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (VALIDATE, + (SHARED_ACTION, + VALIDATE, CREATE, DESTROY, FLUSH,
@@ -1701,7 +1761,45 @@ static const struct token token_list[] = { ISOLATE)), .call = parse_init, }, +/* Top-level command. */ + [SHARED_ACTION] = { + .name = "shared_action", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage shared actions", + .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa, + },/* Sub-level commands. */ + [SHARED_ACTION_CREATE] = { + .name = "create", + .help = "create shared action", + .next = NEXT(next_sa_create_attr), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_UPDATE] = { + .name = "update", + .help = "update shared action", + .next =NEXT (NEXT_ENTRY (ACTION_RSS ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_DESTROY] = { + .name = "destroy", + .help = "destroy shared action", + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa_destroy, + }, + [SHARED_ACTION_QUERY] = { + .name = "query", + .help = "query shared action", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)), + .call = parse_sa, + }, [VALIDATE] = { .name = "validate", .help = "check whether a flow rule can be created",
@@ -3841,6 +3939,40 @@ static const struct token token_list[] = { .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)), .call = parse_vc_conf, }, +/* Shared action destroy arguments. */ + [SHARED_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a shared action id to destroy", + .next =NEXT (next_sa_destroy_attr, + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.sa_destroy.action_id)), + .call = parse_sa_destroy, + }, +/* Shared action create arguments. */ + [SHARED_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a shared action id to create", + .next =NEXT (NEXT_ENTRY (ACTION_RSS ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [ACTION_SHARED] = { + .name = "shared", + .help = "apply shared action by id", + .priv = PRIV_ACTION(SHARED, 0), + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + .call = parse_vc, + }, + [SHARED_ACTION_ID2PTR] = { + .name = "{action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_sa_id2ptr, + .comp = comp_none, + }, };/** Remove and return last entry from argument stack. */
@@ -4025,6 +4157,91 @@ parse_init(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for shared action commands. */ +static int +parse_sa (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=SHARED_ACTION ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case SHARED_ACTION_CREATE : +case SHARED_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; +/* fallthrough */ +case SHARED_ACTION_QUERY : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + + +/** Parse tokens for shared action destroy command. */ +static int +parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==SHARED_ACTION ) { +if (ctx->curr !=SHARED_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.sa_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + action_id = out->args.sa_destroy.action_id + + out->args.sa_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +} +/** Parse tokens for validate/create commands. */ static int parse_vc(struct context *ctx, const struct token *token,
@@ -6092,6 +6309,32 @@ parse_port(struct context *ctx, const struct token *token,return ret; } +static int +parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct rte_flow_action *action = ctx->object; +uint32_t id; +int ret; + + (void )buf; + (void )size; + ctx->objdata =0 ; + ctx->object = &id; + ctx->objmask =NULL ; + ret =parse_int (ctx, token, str, len, ctx->object,sizeof (id)); + ctx->object = action; +if (ret != (int )len) +return ret; +/* set shared action */ +if (action) { + action->conf =port_shared_action_get_by_id (ctx->port, id); + ret = (action->conf) ? ret :-1 ; + } +return ret; +} +/** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
@@ -6541,6 +6784,23 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case SHARED_ACTION_CREATE : +port_shared_action_create (in->port, + in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_DESTROY : +port_shared_action_destroy (in->port, + in->args.sa_destroy.action_id_n, + in->args.sa_destroy.action_id); +break ; +case SHARED_ACTION_UPDATE : +port_shared_action_update (in->port, in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_QUERY : +port_shared_action_query (in->port, in->args.sa.action_id); +break ;case VALIDATE :port_flow_validate (in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions);
app/test-pmd/config.c +217 -0
223 lines not on this page · raw message
app/test-pmd/testpmd.h +19 -0
@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */
@@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */
@@ -746,6 +756,14 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
@@ -754,6 +772,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +111 -0
123 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v4 2/2] app/testpmd: support shared action
Hi Andrey,
Quoted 62 lines
-----Original Message-----
From: Andrey Vesnovaty <[email protected]>
Sent: Tuesday, October 6, 2020 11:09 PM
To: [email protected]Subject: [PATCH v4 2/2] app/testpmd: support shared action
This patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flowshared_action(port) create {action_id(shared_action_id)} \
(action) / endCreate shared action examples:
flowshared_action0 createaction_id100 \
rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.flow
shared_action0 createaction_id\
rss queues 0 1 end / end
This creates shared rss action with id assigned by tetspmd on port 0.Update shared action syntax:
flowshared_action(port) update (shared_action_id) (action) / endUpdate shared action example:
flowshared_action0 update 100 rss queues 0 3 end / end This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).Destroy shared action syntax:
flow shared_action (port) destroy action_id (shared_action_id) \ { action_id (shared_action_id) [...]}Update shared action example:
flowshared_action0 destroyaction_id100action_id101 This destroys shared actions having id 100 & 101Query shared action syntax:
flowshared_action(port) query (shared_action_id)Query shared action example:
flowshared_action0 query 100
This queries shared actions having id 100Use shared action as flow action syntax:
flow create (port) ... / end actions {action / [...]} \ shared (action_id) / {action / [...]} endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \ actions shared 100 / end This creates flow rule where rss action is shared rss action having id 100.
Quoted 5 lines
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
Signed-off-by Andrey Vesnovaty <[email protected]>---
Thanks,
Ori
v5 cover RTE flow shared action
In reply to Andrey VesnovatyThis patchset introduces shared action API for RTE flow.
v5 changes:
* updated RTE flow programmers guide
* misc elaborations in code comments
Andrey Vesnovaty (2):
ethdev: add flow shared action API
app/testpmd: support shared action
app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 217 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/prog_guide/rte_flow.rst | 19 ++ doc/guides/rel_notes/release_20_11.rst | 9 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++ lib/librte_ethdev/rte_flow.h | 163 +++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++ 10 files changed, 909 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH v5 1/2 ethdev: add flow shared action API
This commit introduces extension of DPDK flow action API enabling sharing of single rte_flow_action in multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.
Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- call rte_flow_destroy()
- call rte_flow_create() with modified RSS action
API for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flows
Change description
===
Shared action
===
In order to represent flow action shared by multiple flows new action type RTE_FLOW_ACTION_TYPE_SHARED is introduced (see enum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (see rte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (see rte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.
In order to share some flow action reuse the handle of type struct rte_flow_shared_action returned by rte_flow_shared_action_create() as a conf field of struct rte_flow_action (see "example" section).
If some shared action not used by any flow rule all resources allocated by the shared action can be released by rte_flow_shared_action_destroy() (see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.
Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated via rte_flow_shared_action_update() (see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.
Shared action query
===
Provide separate API to query shared action state (see rte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled by rte_flow_shared_action_create() and rte_flow_shared_action_update() APIs and no supposed to change by other means.
PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see struct rte_flow_ops).
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordingly
flow shared_action (port) create {action_id (id)} (action) / end flow shared_action (port) update (id) (action) / end
flow shared_action (port) destroy action_id (id) {action_id (id) [...]} flow shared_action (port) query (id)
testpmd example
===
configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / end
create flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \
actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / end
example
===
struct rte_flow_action actions[2];
struct rte_flow_action action;
/* skipped: initialize action */
struct rte_flow_shared_action *handle = rte_flow_shared_action_create(
port_id, &action, &error);
actions[0].type = RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type = RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
struct rte_flow *flow0 = rte_flow_create(port_id, &attr0, pattern0,
actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);
/* update shared action */
struct rte_flow_action updated_action;
/*
* skipped: initialize updated_action according to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
* updated_action
*/
/* skipped: destroy all flows 1 till N */ rte_flow_shared_action_destroy(port_id, handle, error);
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 ++++++++++++ lib/librte_ethdev/rte_flow.h | 163 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++++ 6 files changed, 301 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +19 -0
@@ -2666,6 +2666,25 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+ +Action: ``SHARED`` +^^^^^^^^^^^^^^^^^^ + +Flow Utilize shared action by handle as returned from +``rte_flow_shared_action_create()``. + +The behaviour of the shared action defined by ``action`` argument of type +``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``. + +.. _table_rte_flow_shared_action: + +.. table:: SHARED + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_20_11.rst +9 -0
@@ -109,6 +109,15 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Add shared action support for rte flow.** + + Added shared action support to utilize single rte flow action in multiple + rte flow rules. An update of shared action configuration alters the behavior + of all rte flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared action + as rte flow action. + * Added new rte flow APIs to create/update/destroy/query shared action. Removed Items -------------
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query; }; INTERNAL {
lib/librte_ethdev/rte_flow.c +84 -0
93 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +162 -1
187 lines not on this page · raw message
lib/librte_ethdev/rte_flow_driver.h +23 -0
@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: add flow shared action API
Hi Andrey,
Quoted 148 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Andrey Vesnovaty
Sent: Wednesday, October 7, 2020 3:56 PM
Subject: [dpdk-dev] [PATCH v5 1/2] ethdev: add flow shared action APIThis commit introduces extension of DPDK flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endexample
===struct
rte_flow_actionactions[2];
structrte_flow_actionaction;
/* skipped: initialize action */
structrte_flow_shared_action*handle = rte_flow_shared_action_create(port_id, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);
Quoted 3 lines
Signed-off-by Andrey Vesnovaty <[email protected]>---
2.26.2
Thanks,
Ori
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: add flow shared action API
In reply to Andrey VesnovatyPlease see inline..
Quoted 15 lines · Andrey Vesnovaty
This commit introduces extension of DPDK flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS action
[snip]
Quoted 4 lines
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow.
s/reside/resides
[snip]
Quoted 7 lines
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end
Same comment as in testpmd patch. Please add the ability to specify and parse direction.
Quoted 24 lines
flow
shared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endexample
===
Quoted 7 lines
struct
rte_flow_actionactions[2];
structrte_flow_actionaction;
/* skipped: initialize action */
structrte_flow_shared_action*handle = rte_flow_shared_action_create(port_id, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED;
actions[0].conf = handle;
direction?
Quoted 2 lines
actions[1].type =
RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
[snip]
Quoted 15 lines
lib/librte_ethdev/rte_flow.h +2
-1@@ -1714,7 +1714,8 @@ enum rte_flow_action_type {/** * Enables counters for this flow rule. * -* These counters can be retrieved and reset through rte_flow_query(), +* These counters can be retrieved and reset through rte_flow_query() or +* rte_flow_shared_action_query() if the action provided via handle, * see struct rte_flow_query_count. * * See struct rte_flow_action_count.
lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2138
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +3
-0@@ -2132,6 +2133,14 @@ enum rte_flow_action_type {* see enum RTE_ETH_EVENT_FLOW_AGED */ RTE_FLOW_ACTION_TYPE_AGE, + +/** +* Describe action shared a cross multiple flow rules.
s/a cross/across
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +5
-0+* +* Allow multiple rules reference the same action by handle (see +* struct rte_flow_shared_action). +*/ + RTE_FLOW_ACTION_TYPE_SHARED, };/** @@ -2693,6 +2702,20 @@ struct rte_flow_action_set_dscp {uint8_t dscp;
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2712
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +8
-0}; + +/** +* RTE_FLOW_ACTION_TYPE_SHARED +* +* Opaque type returned after successfully creating a shared action. +* +* This handle can be used to manage and query the related action: +* - share it a cross multiple flow rules
s/a cross/across
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +6
-0+* - update action configuration +* - query action data +* - destroy action +*/ +struct rte_flow_shared_action ; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;@@ -3357,6 +3380,144 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
lib/librte_ethdev/rte_flow.h int · line 3390
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +8
-0uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +uint32_t ingress:1 ; +/**< Action valid for rules applied to ingress traffic. */ +uint32_t egress:1 ; +/**< Action valid for rules applied to egress traffic. */
Add a note to indicate only one of these shall be set.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +*
[snip]
Re: [dpdk-dev] [PATCH v5 1/2] ethdev: add flow shared action API
Hi, Ajit.
All spelling & rephrases will be fixed in next couple of hours & v7 will be sent. PSB response on shared action configuration documentation.
Please respond ASAP since RC1 window about to close very soon.
Thanks,
Andrey
Quoted 148 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Thursday, October 8, 2020 12:23 AM
To: Andrey Vesnovaty <[email protected]>
Cc: dpdk-dev <[email protected]>; [email protected]; Jerin Jacob <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Stephen Hemminger <[email protected]>; Bruce Richardson <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>; Samik Gupta <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v5 1/2] ethdev: add flow shared action APIPlease see inline..
Quoted 15 lines · Andrey Vesnovaty
This commit introduces extension of DPDK flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS action[snip]
Quoted 4 lines
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow.s/reside/resides
[snip]
Quoted 7 lines
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / endSame comment as in testpmd patch. Please add the ability to specify and parse direction.
Quoted 24 lines
flow
shared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endexample
===Quoted 7 lines
struct
rte_flow_actionactions[2];
structrte_flow_actionaction;
/* skipped: initialize action */
structrte_flow_shared_action*handle = rte_flow_shared_action_create(port_id, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED;
actions[0].conf = handle;direction?
Quoted 2 lines
actions[1].type =
RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */[snip]
Quoted 15 lines
lib/librte_ethdev/rte_flow.h +2
-1@@ -1714,7 +1714,8 @@ enum rte_flow_action_type {/** * Enables counters for this flow rule. * -* These counters can be retrieved and reset through rte_flow_query(), +* These counters can be retrieved and reset through rte_flow_query() or +* rte_flow_shared_action_query() if the action provided via handle, * see struct rte_flow_query_count. * * See struct rte_flow_action_count. lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2138
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +3
-0@@ -2132,6 +2133,14 @@ enum rte_flow_action_type {* see enum RTE_ETH_EVENT_FLOW_AGED */ RTE_FLOW_ACTION_TYPE_AGE, + +/** +* Describe action shared a cross multiple flow rules. s/a cross/across
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +5
-0+* +* Allow multiple rules reference the same action by handle (see +* struct rte_flow_shared_action). +*/ + RTE_FLOW_ACTION_TYPE_SHARED, };/** @@ -2693,6 +2702,20 @@ struct rte_flow_action_set_dscp {uint8_t dscp;lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2712
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +8
-0}; + +/** +* RTE_FLOW_ACTION_TYPE_SHARED +* +* Opaque type returned after successfully creating a shared action. +* +* This handle can be used to manage and query the related action: +* - share it a cross multiple flow rules s/a cross/across
Quoted 13 lines
lib/librte_ethdev/rte_flow.h +6
-0+* - update action configuration +* - query action data +* - destroy action +*/ +struct rte_flow_shared_action ; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;@@ -3357,6 +3380,144 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error);
Quoted 10 lines
lib/librte_ethdev/rte_flow.h int · line 3390
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +8
-0+/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +uint32_t ingress:1 ; +/**< Action valid for rules applied to ingress traffic. */ +uint32_t egress:1 ; +/**< Action valid for rules applied to egress traffic. */ Add a note to indicate only one of these shall be set.
"only" -> "at least"
Action should be valid for at least one direction but some actions valid for both ingress & egress. For example, shared counter can be incremented on both incoming & outgoing packets.
Quoted 7 lines
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* [snip]
PATCH v5 2/2 app/testpmd: support shared action
In reply to Andrey VesnovatyThis patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flow shared_action (port) create {action_id (shared_action_id)} \
(action) / end
Create shared action examples:
flow shared_action 0 create action_id 100 \
rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.
flow shared_action 0 create action_id \
rss queues 0 1 end / end
This creates shared rss action with id assigned by tetspmd on port 0.
Update shared action syntax:
flow shared_action (port) update (shared_action_id) (action) / end
Update shared action example:
flow shared_action 0 update 100 rss queues 0 3 end / end This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).
Destroy shared action syntax:
flow shared_action (port) destroy action_id (shared_action_id) \
{ action_id (shared_action_id) [...]}Update shared action example:
flow shared_action 0 destroy action_id 100 action_id 101 This destroys shared actions having id 100 & 101
Query shared action syntax:
flow shared_action (port) query (shared_action_id)
Query shared action example:
flow shared_action 0 query 100
This queries shared actions having id 100
Use shared action as flow action syntax:
flow create (port) ... / end actions {action / [...]} \
shared (action_id) / {action / [...]} endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \ actions shared 100 / end This creates flow rule where rss action is shared rss action having id 100.
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
--- app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 217 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ 4 files changed, 608 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +261 -1
@@ -49,6 +49,7 @@ enum index {PORT_ID ,GROUP_ID ,PRIORITY_LEVEL , +SHARED_ACTION_ID ,/* Top-level command. */ SET,
@@ -60,6 +61,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +SHARED_ACTION ,VALIDATE ,CREATE , DESTROY,
@@ -89,6 +91,18 @@ enum index {EGRESS ,TRANSFER , +/* Shared action arguments */ +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , + +/* Shared action create arguments */ +SHARED_ACTION_CREATE_ID , + +/* Shared action destroy arguments */ +SHARED_ACTION_DESTROY_ID , +/* Validate/create pattern. */ PATTERN , ITEM_PARAM_IS,
@@ -360,6 +374,8 @@ enum index {ACTION_SET_IPV6_DSCP_VALUE ,ACTION_AGE ,ACTION_AGE_TIMEOUT , +ACTION_SHARED , + SHARED_ACTION_ID2PTR, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -653,6 +669,13 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +uint32_t *action_id; +uint32_t action_id_n; + } sa_destroy;/**< Shared action destroy arguments. */ +struct { +uint32_t action_id; + } sa;/* Shared action query arguments */ struct {struct rte_flow_attr attr;struct rte_flow_item *pattern;
@@ -709,6 +732,19 @@ struct parse_action_priv { .size = s, \ }) +static const enum index next_sa_create_attr[] = { +SHARED_ACTION_CREATE_ID , +ACTION_RSS , +ZERO , +}; + +static const enum index next_sa_subcmd[] = { +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , +}; +static const enum index next_vc_attr[] = {GROUP ,PRIORITY ,
@@ -743,6 +779,12 @@ static const enum index next_aged_attr[] = { ZERO, }; +static const enum index next_sa_destroy_attr[] = { +SHARED_ACTION_DESTROY_ID , +END , +ZERO , +}; +static const enum index item_param[] = {ITEM_PARAM_IS ,ITEM_PARAM_SPEC ,
@@ -1193,6 +1235,7 @@ static const enum index next_action[] = {ACTION_SET_IPV4_DSCP ,ACTION_SET_IPV6_DSCP ,ACTION_AGE , +ACTION_SHARED , ZERO, };
@@ -1550,6 +1593,15 @@ static int parse_ipv6_addr(struct context *, const struct token *,static int parse_port (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_sa (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size); +static int parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int comp_none (struct context *,const struct token *,unsigned int ,char *,unsigned int ); static int comp_boolean(struct context *, const struct token *,
@@ -1688,13 +1740,21 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_none, }, + [SHARED_ACTION_ID] = { + .name = "{shared_action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .call = parse_int, + .comp = comp_none, + },/* Top-level command. */ [FLOW] = { .name = "flow", .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (VALIDATE, + (SHARED_ACTION, + VALIDATE, CREATE, DESTROY, FLUSH,
@@ -1705,7 +1765,45 @@ static const struct token token_list[] = { ISOLATE)), .call = parse_init, }, +/* Top-level command. */ + [SHARED_ACTION] = { + .name = "shared_action", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage shared actions", + .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa, + },/* Sub-level commands. */ + [SHARED_ACTION_CREATE] = { + .name = "create", + .help = "create shared action", + .next = NEXT(next_sa_create_attr), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_UPDATE] = { + .name = "update", + .help = "update shared action", + .next =NEXT (NEXT_ENTRY (ACTION_RSS ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_DESTROY] = { + .name = "destroy", + .help = "destroy shared action", + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa_destroy, + }, + [SHARED_ACTION_QUERY] = { + .name = "query", + .help = "query shared action", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)), + .call = parse_sa, + }, [VALIDATE] = { .name = "validate", .help = "check whether a flow rule can be created",
@@ -3859,6 +3957,40 @@ static const struct token token_list[] = { .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)), .call = parse_vc_conf, }, +/* Shared action destroy arguments. */ + [SHARED_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a shared action id to destroy", + .next =NEXT (next_sa_destroy_attr, + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.sa_destroy.action_id)), + .call = parse_sa_destroy, + }, +/* Shared action create arguments. */ + [SHARED_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a shared action id to create", + .next =NEXT (NEXT_ENTRY (ACTION_RSS ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [ACTION_SHARED] = { + .name = "shared", + .help = "apply shared action by id", + .priv = PRIV_ACTION(SHARED, 0), + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + .call = parse_vc, + }, + [SHARED_ACTION_ID2PTR] = { + .name = "{action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_sa_id2ptr, + .comp = comp_none, + }, };/** Remove and return last entry from argument stack. */
@@ -4043,6 +4175,91 @@ parse_init(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for shared action commands. */ +static int +parse_sa (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=SHARED_ACTION ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case SHARED_ACTION_CREATE : +case SHARED_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; +/* fallthrough */ +case SHARED_ACTION_QUERY : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + + +/** Parse tokens for shared action destroy command. */ +static int +parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==SHARED_ACTION ) { +if (ctx->curr !=SHARED_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.sa_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + action_id = out->args.sa_destroy.action_id + + out->args.sa_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +} +/** Parse tokens for validate/create commands. */ static int parse_vc(struct context *ctx, const struct token *token,
@@ -6110,6 +6327,32 @@ parse_port(struct context *ctx, const struct token *token,return ret; } +static int +parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct rte_flow_action *action = ctx->object; +uint32_t id; +int ret; + + (void )buf; + (void )size; + ctx->objdata =0 ; + ctx->object = &id; + ctx->objmask =NULL ; + ret =parse_int (ctx, token, str, len, ctx->object,sizeof (id)); + ctx->object = action; +if (ret != (int )len) +return ret; +/* set shared action */ +if (action) { + action->conf =port_shared_action_get_by_id (ctx->port, id); + ret = (action->conf) ? ret :-1 ; + } +return ret; +} +/** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
@@ -6559,6 +6802,23 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case SHARED_ACTION_CREATE : +port_shared_action_create (in->port, + in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_DESTROY : +port_shared_action_destroy (in->port, + in->args.sa_destroy.action_id_n, + in->args.sa_destroy.action_id); +break ; +case SHARED_ACTION_UPDATE : +port_shared_action_update (in->port, in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_QUERY : +port_shared_action_query (in->port, in->args.sa.action_id); +break ;case VALIDATE :port_flow_validate (in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions);
app/test-pmd/config.c +217 -0
223 lines not on this page · raw message
app/test-pmd/testpmd.h +19 -0
@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */
@@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */
@@ -748,6 +758,14 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
@@ -756,6 +774,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +111 -0
123 lines not on this page · raw message
Signature · 1 line
2.26.2
v6 cover RTE flow shared action
In reply to Andrey VesnovatyThis patchset introduces shared action API for RTE flow.
v6 changes:
* fix build warning in testpmd
Andrey Vesnovaty (2):
ethdev: add flow shared action API
app/testpmd: support shared action
app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 215 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/prog_guide/rte_flow.rst | 19 ++ doc/guides/rel_notes/release_20_11.rst | 9 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++ lib/librte_ethdev/rte_flow.h | 163 +++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++ 10 files changed, 907 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH v6 1/2 ethdev: add flow shared action API
This commit introduces extension of DPDK flow action API enabling sharing of single rte_flow_action in multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.
Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- call rte_flow_destroy()
- call rte_flow_create() with modified RSS action
API for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flows
Change description
===
Shared action
===
In order to represent flow action shared by multiple flows new action type RTE_FLOW_ACTION_TYPE_SHARED is introduced (see enum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action reside outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (see rte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (see rte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.
In order to share some flow action reuse the handle of type struct rte_flow_shared_action returned by rte_flow_shared_action_create() as a conf field of struct rte_flow_action (see "example" section).
If some shared action not used by any flow rule all resources allocated by the shared action can be released by rte_flow_shared_action_destroy() (see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.
Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated via rte_flow_shared_action_update() (see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.
Shared action query
===
Provide separate API to query shared action state (see rte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled by rte_flow_shared_action_create() and rte_flow_shared_action_update() APIs and no supposed to change by other means.
PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see struct rte_flow_ops).
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordingly
flow shared_action (port) create {action_id (id)} (action) / end flow shared_action (port) update (id) (action) / end
flow shared_action (port) destroy action_id (id) {action_id (id) [...]} flow shared_action (port) query (id)
testpmd example
===
configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / end
create flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \
actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / end
example
===
struct rte_flow_action actions[2];
struct rte_flow_action action;
/* skipped: initialize action */
struct rte_flow_shared_action *handle = rte_flow_shared_action_create(
port_id, &action, &error);
actions[0].type = RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type = RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
struct rte_flow *flow0 = rte_flow_create(port_id, &attr0, pattern0,
actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);
/* update shared action */
struct rte_flow_action updated_action;
/*
* skipped: initialize updated_action according to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
* updated_action
*/
/* skipped: destroy all flows 1 till N */ rte_flow_shared_action_destroy(port_id, handle, error);
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 ++++++++++++ lib/librte_ethdev/rte_flow.h | 163 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++++ 6 files changed, 301 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +19 -0
@@ -2666,6 +2666,25 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+ +Action: ``SHARED`` +^^^^^^^^^^^^^^^^^^ + +Flow Utilize shared action by handle as returned from +``rte_flow_shared_action_create()``. + +The behaviour of the shared action defined by ``action`` argument of type +``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``. + +.. _table_rte_flow_shared_action: + +.. table:: SHARED + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_20_11.rst +9 -0
@@ -109,6 +109,15 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Add shared action support for rte flow.** + + Added shared action support to utilize single rte flow action in multiple + rte flow rules. An update of shared action configuration alters the behavior + of all rte flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared action + as rte flow action. + * Added new rte flow APIs to create/update/destroy/query shared action. Removed Items -------------
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query; }; INTERNAL {
lib/librte_ethdev/rte_flow.c +84 -0
93 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +162 -1
187 lines not on this page · raw message
lib/librte_ethdev/rte_flow_driver.h +23 -0
@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Signature · 1 line
2.26.2
PATCH v6 2/2 app/testpmd: support shared action
In reply to Andrey VesnovatyThis patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flow shared_action (port) create {action_id (shared_action_id)} \
(action) / end
Create shared action examples:
flow shared_action 0 create action_id 100 \
rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.
flow shared_action 0 create action_id \
rss queues 0 1 end / end
This creates shared rss action with id assigned by tetspmd on port 0.
Update shared action syntax:
flow shared_action (port) update (shared_action_id) (action) / end
Update shared action example:
flow shared_action 0 update 100 rss queues 0 3 end / end This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).
Destroy shared action syntax:
flow shared_action (port) destroy action_id (shared_action_id) \
{ action_id (shared_action_id) [...]}Update shared action example:
flow shared_action 0 destroy action_id 100 action_id 101 This destroys shared actions having id 100 & 101
Query shared action syntax:
flow shared_action (port) query (shared_action_id)
Query shared action example:
flow shared_action 0 query 100
This queries shared actions having id 100
Use shared action as flow action syntax:
flow create (port) ... / end actions {action / [...]} \
shared (action_id) / {action / [...]} endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \ actions shared 100 / end This creates flow rule where rss action is shared rss action having id 100.
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
--- app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 215 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ 4 files changed, 606 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +261 -1
@@ -49,6 +49,7 @@ enum index {PORT_ID ,GROUP_ID ,PRIORITY_LEVEL , +SHARED_ACTION_ID ,/* Top-level command. */ SET,
@@ -60,6 +61,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +SHARED_ACTION ,VALIDATE ,CREATE , DESTROY,
@@ -89,6 +91,18 @@ enum index {EGRESS ,TRANSFER , +/* Shared action arguments */ +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , + +/* Shared action create arguments */ +SHARED_ACTION_CREATE_ID , + +/* Shared action destroy arguments */ +SHARED_ACTION_DESTROY_ID , +/* Validate/create pattern. */ PATTERN , ITEM_PARAM_IS,
@@ -360,6 +374,8 @@ enum index {ACTION_SET_IPV6_DSCP_VALUE ,ACTION_AGE ,ACTION_AGE_TIMEOUT , +ACTION_SHARED , + SHARED_ACTION_ID2PTR, };/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -653,6 +669,13 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +uint32_t *action_id; +uint32_t action_id_n; + } sa_destroy;/**< Shared action destroy arguments. */ +struct { +uint32_t action_id; + } sa;/* Shared action query arguments */ struct {struct rte_flow_attr attr;struct rte_flow_item *pattern;
@@ -709,6 +732,19 @@ struct parse_action_priv { .size = s, \ }) +static const enum index next_sa_create_attr[] = { +SHARED_ACTION_CREATE_ID , +ACTION_RSS , +ZERO , +}; + +static const enum index next_sa_subcmd[] = { +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , +}; +static const enum index next_vc_attr[] = {GROUP ,PRIORITY ,
@@ -743,6 +779,12 @@ static const enum index next_aged_attr[] = { ZERO, }; +static const enum index next_sa_destroy_attr[] = { +SHARED_ACTION_DESTROY_ID , +END , +ZERO , +}; +static const enum index item_param[] = {ITEM_PARAM_IS ,ITEM_PARAM_SPEC ,
@@ -1193,6 +1235,7 @@ static const enum index next_action[] = {ACTION_SET_IPV4_DSCP ,ACTION_SET_IPV6_DSCP ,ACTION_AGE , +ACTION_SHARED , ZERO, };
@@ -1550,6 +1593,15 @@ static int parse_ipv6_addr(struct context *, const struct token *,static int parse_port (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_sa (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size); +static int parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int comp_none (struct context *,const struct token *,unsigned int ,char *,unsigned int ); static int comp_boolean(struct context *, const struct token *,
@@ -1688,13 +1740,21 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_none, }, + [SHARED_ACTION_ID] = { + .name = "{shared_action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .call = parse_int, + .comp = comp_none, + },/* Top-level command. */ [FLOW] = { .name = "flow", .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (VALIDATE, + (SHARED_ACTION, + VALIDATE, CREATE, DESTROY, FLUSH,
@@ -1705,7 +1765,45 @@ static const struct token token_list[] = { ISOLATE)), .call = parse_init, }, +/* Top-level command. */ + [SHARED_ACTION] = { + .name = "shared_action", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage shared actions", + .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa, + },/* Sub-level commands. */ + [SHARED_ACTION_CREATE] = { + .name = "create", + .help = "create shared action", + .next = NEXT(next_sa_create_attr), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_UPDATE] = { + .name = "update", + .help = "update shared action", + .next =NEXT (NEXT_ENTRY (ACTION_RSS ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_DESTROY] = { + .name = "destroy", + .help = "destroy shared action", + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa_destroy, + }, + [SHARED_ACTION_QUERY] = { + .name = "query", + .help = "query shared action", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)), + .call = parse_sa, + }, [VALIDATE] = { .name = "validate", .help = "check whether a flow rule can be created",
@@ -3859,6 +3957,40 @@ static const struct token token_list[] = { .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)), .call = parse_vc_conf, }, +/* Shared action destroy arguments. */ + [SHARED_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a shared action id to destroy", + .next =NEXT (next_sa_destroy_attr, + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.sa_destroy.action_id)), + .call = parse_sa_destroy, + }, +/* Shared action create arguments. */ + [SHARED_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a shared action id to create", + .next =NEXT (NEXT_ENTRY (ACTION_RSS ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [ACTION_SHARED] = { + .name = "shared", + .help = "apply shared action by id", + .priv = PRIV_ACTION(SHARED, 0), + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + .call = parse_vc, + }, + [SHARED_ACTION_ID2PTR] = { + .name = "{action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_sa_id2ptr, + .comp = comp_none, + }, };/** Remove and return last entry from argument stack. */
@@ -4043,6 +4175,91 @@ parse_init(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for shared action commands. */ +static int +parse_sa (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=SHARED_ACTION ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case SHARED_ACTION_CREATE : +case SHARED_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; +/* fallthrough */ +case SHARED_ACTION_QUERY : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + + +/** Parse tokens for shared action destroy command. */ +static int +parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==SHARED_ACTION ) { +if (ctx->curr !=SHARED_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.sa_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + action_id = out->args.sa_destroy.action_id + + out->args.sa_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +} +/** Parse tokens for validate/create commands. */ static int parse_vc(struct context *ctx, const struct token *token,
@@ -6110,6 +6327,32 @@ parse_port(struct context *ctx, const struct token *token,return ret; } +static int +parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct rte_flow_action *action = ctx->object; +uint32_t id; +int ret; + + (void )buf; + (void )size; + ctx->objdata =0 ; + ctx->object = &id; + ctx->objmask =NULL ; + ret =parse_int (ctx, token, str, len, ctx->object,sizeof (id)); + ctx->object = action; +if (ret != (int )len) +return ret; +/* set shared action */ +if (action) { + action->conf =port_shared_action_get_by_id (ctx->port, id); + ret = (action->conf) ? ret :-1 ; + } +return ret; +} +/** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
@@ -6559,6 +6802,23 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case SHARED_ACTION_CREATE : +port_shared_action_create (in->port, + in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_DESTROY : +port_shared_action_destroy (in->port, + in->args.sa_destroy.action_id_n, + in->args.sa_destroy.action_id); +break ; +case SHARED_ACTION_UPDATE : +port_shared_action_update (in->port, in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_QUERY : +port_shared_action_query (in->port, in->args.sa.action_id); +break ;case VALIDATE :port_flow_validate (in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions);
app/test-pmd/config.c +215 -0
221 lines not on this page · raw message
app/test-pmd/testpmd.h +19 -0
@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */
@@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */
@@ -748,6 +758,14 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
@@ -756,6 +774,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +111 -0
123 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v6 2/2] app/testpmd: support shared action
Quoted 8 lines · Andrey Vesnovaty
This patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Quoted 7 lines
Create shared action syntax:
flowshared_action(port) create {action_id(shared_action_id)} \
(action) / endCreate shared action examples:
flowshared_action0 createaction_id100 \
rss queues 1 2 end / end
I don't see the direction being specified.
Quoted 4 lines
This creates shared rss action with id 100 on port 0.
flow
shared_action0 createaction_id\
rss queues 0 1 end / end
Same here.
Quoted 5 lines
This creates shared rss action with id assigned by tetspmd on port 0.
Update shared action syntax:
flowshared_action(port) update (shared_action_id) (action) / end
The syntax will be incomplete without parsing the direction which a part of the shared action configuration.
Quoted 108 lines
Update shared action example:
flowshared_action0 update 100 rss queues 0 3 end / end This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).Destroy shared action syntax:
flow shared_action (port) destroy action_id (shared_action_id) \ { action_id (shared_action_id) [...]}Update shared action example:
flowshared_action0 destroyaction_id100action_id101 This destroys shared actions having id 100 & 101Query shared action syntax:
flowshared_action(port) query (shared_action_id)Query shared action example:
flowshared_action0 query 100
This queries shared actions having id 100Use shared action as flow action syntax:
flow create (port) ... / end actions {action / [...]} \ shared (action_id) / {action / [...]} endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \
actions shared 100 / end
This creates flow rule where rss action is shared rss action having id 100.All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>Signed-off-by Andrey Vesnovaty <[email protected]>--- app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 215 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ 4 files changed, 606 insertions(+), 1 deletion(-)app/test-pmd/cmdline_flow.c +23
-0@@ -49,6 +49,7 @@ enum index {PORT_ID ,GROUP_ID ,PRIORITY_LEVEL , +SHARED_ACTION_ID ,/* Top-level command. */ SET,@@ -60,6 +61,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +SHARED_ACTION ,VALIDATE ,CREATE , DESTROY,@@ -89,6 +91,18 @@ enum index {EGRESS ,TRANSFER , +/* Shared action arguments */ +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , + +/* Shared action create arguments */ +SHARED_ACTION_CREATE_ID , + +/* Shared action destroy arguments */ +SHARED_ACTION_DESTROY_ID , +/* Validate/create pattern. */ PATTERN , ITEM_PARAM_IS,@@ -360,6 +374,8 @@ enum index {ACTION_SET_IPV6_DSCP_VALUE ,ACTION_AGE ,ACTION_AGE_TIMEOUT , +ACTION_SHARED , + SHARED_ACTION_ID2PTR, };/** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -653,6 +669,13 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +uint32_t *action_id; +uint32_t action_id_n; + } sa_destroy;/**< Shared action destroy arguments. */ +struct { +uint32_t action_id; + } sa;/* Shared action query arguments */ struct {struct rte_flow_attr attr;struct rte_flow_item *pattern;
app/test-pmd/cmdline_flow.c struct parse_action_priv { · line 737
Quoted 6 lines
app/test-pmd/cmdline_flow.c +3
-0@@ -709,6 +732,19 @@ struct parse_action_priv { .size = s, \ }) +static const enum index next_sa_create_attr[] = { +SHARED_ACTION_CREATE_ID , +ACTION_RSS ,
This is only for RSS.
What if we want to do it for another resource?
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ ZERO, +}; + +static const enum index next_sa_subcmd[] = { +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , +}; +
[snip]
Quoted 11 lines
app/test-pmd/cmdline_flow.c +10
-0+ /* Top-level command. */ + [SHARED_ACTION] = { + .name = "shared_action", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage shared actions", + .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa, + },/* Sub-level commands. */ + [SHARED_ACTION_CREATE] = {
app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 1788
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ .name = "create", + .help = "create shared action", + .next = NEXT(next_sa_create_attr), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_UPDATE] = { + .name = "update", + .help = "update shared action", + .next = NEXT(NEXT_ENTRY(ACTION_RSS),
Can't we fill this action based on the input of the flow shared_action create command?
Quoted 30 lines
app/test-pmd/cmdline_flow.c +23
-0+ NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_DESTROY] = { + .name = "destroy", + .help = "destroy shared action", + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa_destroy, + }, + [SHARED_ACTION_QUERY] = { + .name = "query", + .help = "query shared action", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)), + .call = parse_sa, + }, [VALIDATE] = { .name = "validate", .help = "check whether a flow rule can be created",@@ -3859,6 +3957,40 @@ static const struct token token_list[] = { .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)), .call = parse_vc_conf, }, +/* Shared action destroy arguments. */ + [SHARED_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a shared action id to destroy", + .next = NEXT(next_sa_destroy_attr,
app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3974
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.sa_destroy.action_id)), + .call = parse_sa_destroy, + }, +/* Shared action create arguments. */ + [SHARED_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a shared action id to create", + .next = NEXT(NEXT_ENTRY(ACTION_RSS),
Same here. This is assuming RSS action only.
Quoted 465 lines
app/test-pmd/cmdline_flow.c +147
-0+ NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [ACTION_SHARED] = { + .name = "shared", + .help = "apply shared action by id", + .priv = PRIV_ACTION(SHARED, 0), + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + .call = parse_vc, + }, + [SHARED_ACTION_ID2PTR] = { + .name = "{action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_sa_id2ptr, + .comp = comp_none, + }, };/** Remove and return last entry from argument stack. */ @@ -4043,6 +4175,91 @@ parse_init(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for shared action commands. */ +static int +parse_sa (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=SHARED_ACTION ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case SHARED_ACTION_CREATE : +case SHARED_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; +/* fallthrough */ +case SHARED_ACTION_QUERY : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + + +/** Parse tokens for shared action destroy command. */ +static int +parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==SHARED_ACTION ) { +if (ctx->curr !=SHARED_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.sa_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + action_id = out->args.sa_destroy.action_id + + out->args.sa_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +} +/** Parse tokens for validate/create commands. */ static int parse_vc(struct context *ctx, const struct token *token,@@ -6110,6 +6327,32 @@ parse_port(struct context *ctx, const struct token *token,return ret; } +static int +parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct rte_flow_action *action = ctx->object; +uint32_t id; +int ret; + + (void )buf; + (void )size; + ctx->objdata =0 ; + ctx->object = &id; + ctx->objmask =NULL ; + ret =parse_int (ctx, token, str, len, ctx->object,sizeof (id)); + ctx->object = action; +if (ret != (int )len) +return ret; +/* set shared action */ +if (action) { + action->conf =port_shared_action_get_by_id (ctx->port, id); + ret = (action->conf) ? ret :-1 ; + } +return ret; +} +/** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token,@@ -6559,6 +6802,23 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case SHARED_ACTION_CREATE : +port_shared_action_create (in->port, + in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_DESTROY : +port_shared_action_destroy (in->port, + in->args.sa_destroy.action_id_n, + in->args.sa_destroy.action_id); +break ; +case SHARED_ACTION_UPDATE : +port_shared_action_update (in->port, in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_QUERY : +port_shared_action_query (in->port, in->args.sa.action_id); +break ;case VALIDATE :port_flow_validate (in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions);app/test-pmd/config.c +215
-0@@ -1580,6 +1580,221 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) } } +static struct port_shared_action * +action_get_by_id (portid_t port_id,uint32_t id) +{ +struct rte_port *port; +struct port_shared_action **ppsa; +struct port_shared_action *psa =NULL ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return NULL ; + port = &ports[port_id]; + ppsa = &port->actions_list; +while (*ppsa) { +if ((*ppsa)->id == id) { + psa = *ppsa; +break ; + } + ppsa = &(*ppsa)->next; + } +if (!psa) +printf ("Failed to find shared action #%u on port %u\n" , + id, port_id); +return psa; +} + +static int +action_alloc (portid_t port_id,uint32_t id, +struct port_shared_action **action) +{ +struct rte_port *port; +struct port_shared_action **ppsa; +struct port_shared_action *psa =NULL ; + + *action =NULL ; +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; +if (id ==UINT32_MAX ) { +/* taking first available ID */ +if (port->actions_list) { +if (port->actions_list->id ==UINT32_MAX -1 ) { +printf ("Highest shared action ID is already" +" assigned, delete it first\n" ); +return -ENOMEM ; + } + id = port->actions_list->id +1 ; + }else { + id =0 ; + } + } + psa =calloc (1 ,sizeof (*psa)); +if (!psa) { +printf ("Allocation of port %u shared action failed\n" , + port_id); +return -ENOMEM ; + } + ppsa = &port->actions_list; +while (*ppsa && (*ppsa)->id > id) + ppsa = &(*ppsa)->next; +if (*ppsa && (*ppsa)->id == id) { +printf ("Shared action #%u is already assigned," +" delete it first\n" , id); +free (psa); +return -EINVAL ; + } + psa->next = *ppsa; + psa->id = id; + *ppsa = psa; + *action = psa; +return 0 ; +} + +/** Create shared action */ +int +port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action) +{ +struct port_shared_action *psa; +int ret; +struct rte_flow_error error; + + ret =action_alloc (port_id, id, &psa); +if (ret) +return ret; +/* Poisoning to make sure PMDs update it in case of error. */ +memset (&error,0x22 ,sizeof (error)); + psa->action =rte_flow_shared_action_create (port_id,NULL , action, + &error); +if (!psa->action) { +uint32_t destroy_id = psa->id; +port_shared_action_destroy (port_id,1 , &destroy_id); +return port_flow_complain (&error); + } + psa->type = action->type; +printf ("Shared action #%u created\n" , psa->id); +return 0 ; +} + +/** Destroy shared action */ +int +port_shared_action_destroy (portid_t port_id, +uint32_t n, +const uint32_t *actions) +{ +struct rte_port *port; +struct port_shared_action **tmp; +uint32_t c =0 ; +int ret =0 ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + tmp = &port->actions_list; +while (*tmp) { +uint32_t i; + +for (i =0 ; i != n; ++i) { +struct rte_flow_error error; +struct port_shared_action *psa = *tmp; + +if (actions[i] != psa->id) +continue ; +/* +* Poisoning to make sure PMDs update it in case +* of error. +*/ +memset (&error,0x33 ,sizeof (error)); + +if (psa->action &&rte_flow_shared_action_destroy ( + port_id, psa->action, &error)) { + ret =port_flow_complain (&error); +continue ; + } + *tmp = psa->next; +free (psa); +printf ("Shared action #%u destroyed\n" , psa->id); +break ; + } +if (i == n) + tmp = &(*tmp)->next; + ++c; + } +return ret; +} + + +/** Get shared action by port + id */ +struct rte_flow_shared_action * +port_shared_action_get_by_id (portid_t port_id,uint32_t id) +{ + +struct port_shared_action *psa =action_get_by_id (port_id, id); + +return (psa) ? psa->action :NULL ; +} + +/** Update shared action */ +int +port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action) +{ +struct rte_flow_error error; +struct rte_flow_shared_action *shared_action; + + shared_action =port_shared_action_get_by_id (port_id, id); +if (!shared_action) +return -EINVAL ; +if (rte_flow_shared_action_update (port_id, shared_action, action, + &error)) { +return port_flow_complain (&error); + } +printf ("Shared action #%u updated\n" , id); +return 0 ; +} + +int +port_shared_action_query (portid_t port_id,uint32_t id) +{ +struct rte_flow_error error; +struct port_shared_action *psa; +uint64_t default_data; +void *data =NULL ; +int ret =0 ; + + psa =action_get_by_id (port_id, id); +if (!psa) +return -EINVAL ; +switch (psa->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + data = &default_data; +break ; +default : +printf ("Shared action %u (type: %d) on port %u doesn't support" +" query\n" , id, psa->type, port_id); +return -1 ; + } +if (rte_flow_shared_action_query (port_id, psa->action, data, &error)) + ret =port_flow_complain (&error); +switch (psa->type) { +case RTE_FLOW_ACTION_TYPE_RSS : +if (!ret) +printf ("Shared RSS action:\n\trefs:%u\n" , + *((uint32_t *)data)); + data =NULL ; +break ; +default : +printf ("Shared action %u (type: %d) on port %u doesn't support" +" query\n" , id, psa->type, port_id); + ret =-1 ; + } +return ret; +} +/** Validate flow rule. */ int port_flow_validate(portid_t port_id,app/test-pmd/testpmd.h +19
-0@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */ @@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */ @@ -748,6 +758,14 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,@@ -756,6 +774,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);doc/guides/testpmd_app_ug/testpmd_funcs.rst +5
-0@@ -4382,6 +4382,11 @@ This section lists supported actions and their attributes, if any. - ``dscp_value {unsigned}``: The new DSCP value to be set +- ``shared``: Use shared action created via + ``flow shared_action {port_id} create`` + + - ``shared_action_id {unsigned}``: Shared action ID to use + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~
doc/guides/testpmd_app_ug/testpmd_funcs.rst If attach ``destroy`` parameter, the command will destroy all the list aged flow · line 4685
Quoted 10 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7
-0@@ -4671,6 +4676,112 @@ If attach ``destroy`` parameter, the command will destroy all the list aged flow testpmd> flow aged 0 Port 0 total aged flows: 0 +Creating shared actions +~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} create`` creates shared action with optional +shared action ID. It is bound to ``rte_flow_shared_action_create()``:: + + flow shared_action {port_id} create [action_id {shared_action_id}] \ + {action} / end
Need to allow passing the direction attribute.
Quoted 105 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +99
-1+ +If successful, it will show:: + + Shared action #[...] created + +Otherwise, it will complain either that shared action already exists or that +some error occurred:: + + Shared action #[...] is already assigned, delete it first + +:: + + Caught error type [...] ([...]): [...] + +Create shared rss action with id 100 to queues 1 and 2 on port 0:: + + testpmd> flow shared_action 0 create action_id 100 \ + rss queues 1 2 end / end + +Create shared rss action with id assigned by testpmd to queues 1 and 2 on +port 0:: + + testpmd> flow shared_action 0 create action_id \ + rss queues 0 1 end / end + +Updating shared actions +~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} update`` updates configuration of the shared +action from its shared action ID (as returned by +``flow shared_action {port_id} create``). It is bound to +``rte_flow_shared_action_update()``:: + + flow shared_action {port_id} update {shared_action_id} {action} / end + +If successful, it will show:: + + Shared action #[...] updated + +Otherwise, it will complain either that shared action not found or that some +error occurred:: + + Failed to find shared action #[...] on port [...] + +:: + + Caught error type [...] ([...]): [...] + +Update shared rss action having id 100 on port 0 with rss to queues 0 and 3 +(in create example above rss queues were 1 and 2):: + + testpmd> flow shared_action 0 update 100 rss queues 0 3 end / end + +Destroying shared actions +~~~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} update`` destroys one or more shared actions +from their shared action IDs (as returned by +``flow shared_action {port_id} create``). It is bound to +``rte_flow_shared_action_destroy()``:: + + flow shared_action {port_id} destroy action_id {shared_action_id} [...] + +If successful, it will show:: + + Shared action #[...] destroyed + +It does not report anything for shared action IDs that do not exist. +The usual error message is shown when a shared action cannot be destroyed:: + + Caught error type [...] ([...]): [...] + +Destroy shared actions having id 100 & 101:: + + testpmd> flow shared_action 0 destroy action_id 100 action_id 101 + +Query shared actions +~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} query`` queries the shared action from its +shared action ID (as returned by ``flow shared_action {port_id} create``). +It is bound to ``rte_flow_shared_action_query()``:: + + flow shared_action {port_id} query {shared_action_id} + +Currently only rss shared action supported. If successful, it will show:: + + Shared RSS action: + refs:[...] + +Otherwise, it will complain either that shared action not found or that some +error occurred:: + + Failed to find shared action #[...] on port [...] + +:: + + Caught error type [...] ([...]): [...] + +Query shared action having id 100:: + + testpmd> flow shared_action 0 query 100 Sample QinQ flow rules ~~~~~~~~~~~~~~~~~~~~~~ --2.26.2
Re: [dpdk-dev] [PATCH v6 2/2] app/testpmd: support shared action
Hi Ajit.
I completely agree that action direction was overlooked by me just because RSS has implicit ingress direction.
v7 patch is about to be sent in an hour with following changes:
* Added handling of direction arguments for create CLI.
* Both create & update CLI can receive all RTE flow action types now.
PSB my suggestion regarding improving update CLI.
Thanks,
Andrey
Quoted 160 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Wednesday, October 7, 2020 11:02 PM
To: Andrey Vesnovaty <[email protected]>
Cc: dpdk-dev <[email protected]>; [email protected]; Jerin Jacob <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Stephen Hemminger <[email protected]>; Bruce Richardson <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>; Samik Gupta <[email protected]>; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>
Subject: Re: [PATCH v6 2/2] app/testpmd: support shared actionQuoted 8 lines · Andrey Vesnovaty
This patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Quoted 7 lines
Create shared action syntax:
flowshared_action(port) create {action_id(shared_action_id)} \
(action) / endCreate shared action examples:
flowshared_action0 createaction_id100 \
rss queues 1 2 end / endI don't see the direction being specified.
Quoted 4 lines
This creates shared rss action with id 100 on port 0.
flow
shared_action0 createaction_id\
rss queues 0 1 end / endSame here.
Quoted 5 lines
This creates shared rss action with id assigned by tetspmd on port 0.
Update shared action syntax:
flowshared_action(port) update (shared_action_id) (action) / endThe syntax will be incomplete without parsing the direction which a part of the shared action configuration.
Quoted 111 lines
Update shared action example:
flowshared_action0 update 100 rss queues 0 3 end / end This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).Destroy shared action syntax:
flow shared_action (port) destroy action_id (shared_action_id) \ { action_id (shared_action_id) [...]}Update shared action example:
flowshared_action0 destroyaction_id100action_id101 This destroys shared actions having id 100 & 101Query shared action syntax:
flowshared_action(port) query (shared_action_id)Query shared action example:
flowshared_action0 query 100
This queries shared actions having id 100Use shared action as flow action syntax:
flow create (port) ... / end actions {action / [...]} \ shared (action_id) / {action / [...]} endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \
actions shared 100 / end
This creates flow rule where rss action is shared rss action having id 100.All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>Signed-off-by Andrey Vesnovaty <[email protected]>--- app/test-pmd/cmdline_flow.c | 262 +++++++++++++++++++- app/test-pmd/config.c | 215 ++++++++++++++++ app/test-pmd/testpmd.h | 19 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 111 +++++++++ 4 files changed, 606 insertions(+), 1 deletion(-)app/test-pmd/cmdline_flow.c +23
-0@@ -49,6 +49,7 @@ enum index {PORT_ID ,GROUP_ID ,PRIORITY_LEVEL , +SHARED_ACTION_ID ,/* Top-level command. */ SET,@@ -60,6 +61,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +SHARED_ACTION ,VALIDATE ,CREATE , DESTROY,@@ -89,6 +91,18 @@ enum index {EGRESS ,TRANSFER , +/* Shared action arguments */ +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , + +/* Shared action create arguments */ +SHARED_ACTION_CREATE_ID , + +/* Shared action destroy arguments */ +SHARED_ACTION_DESTROY_ID , +/* Validate/create pattern. */ PATTERN , ITEM_PARAM_IS,@@ -360,6 +374,8 @@ enum index {ACTION_SET_IPV6_DSCP_VALUE ,ACTION_AGE ,ACTION_AGE_TIMEOUT , +ACTION_SHARED , + SHARED_ACTION_ID2PTR, };/** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -653,6 +669,13 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +uint32_t *action_id; +uint32_t action_id_n; + } sa_destroy;/**< Shared action destroy arguments. */ +struct { +uint32_t action_id; + } sa;/* Shared action query arguments */ struct {struct rte_flow_attr attr;struct rte_flow_item *pattern;@@ -709,6 +732,19 @@ struct parse_action_priv { .size = s, \ })
Quoted 6 lines
app/test-pmd/cmdline_flow.c struct parse_action_priv { · line 737
Quoted 3 lines
app/test-pmd/cmdline_flow.c +3
-0+static const enum index next_sa_create_attr[] = { +SHARED_ACTION_CREATE_ID , +ACTION_RSS ,This is only for RSS.
What if we want to do it for another resource?
Fixed, now it accepts all RTE flow actions. Unimplemented/unsupported actions rejected by RTE flow layer/PMD.
Quoted 34 lines
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ ZERO, +}; + +static const enum index next_sa_subcmd[] = { +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , +}; +[snip]
Quoted 11 lines
app/test-pmd/cmdline_flow.c +10
-0+ /* Top-level command. */ + [SHARED_ACTION] = { + .name = "shared_action", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage shared actions", + .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa, + },/* Sub-level commands. */ + [SHARED_ACTION_CREATE] = {app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 1788
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ .name = "create", + .help = "create shared action", + .next = NEXT(next_sa_create_attr), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_UPDATE] = { + .name = "update", + .help = "update shared action", + .next = NEXT(NEXT_ENTRY(ACTION_RSS),
Quoted 3 lines
Can't we fill this action based on the input of the flow
shared_actioncreate command?
Do you mean tab completion improvement for shared action ID? If yes, please let me to keep this improvement for post RC1 phase. BW, now update receives all RTE flow action types similar to create.
Quoted 35 lines
Quoted 6 lines
app/test-pmd/cmdline_flow.c +5
-0+ NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_DESTROY] = {app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 10 lines
app/test-pmd/cmdline_flow.c +10
-0+ .name = "destroy", + .help = "destroy shared action", + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa_destroy, + }, + [SHARED_ACTION_QUERY] = { + .name = "query", + .help = "query shared action", + .next = NEXT(NEXT_ENTRY(END),
NEXT_ENTRY(SHARED_ACTION_ID)),Quoted 18 lines
app/test-pmd/cmdline_flow.c +11
-0+ .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)), + .call = parse_sa, + }, [VALIDATE] = { .name = "validate", .help = "check whether a flow rule can be created",@@ -3859,6 +3957,40 @@ static const struct token token_list[] = { .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)), .call = parse_vc_conf, }, +/* Shared action destroy arguments. */ + [SHARED_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a shared action id to destroy", + .next =NEXT (next_sa_destroy_attr, + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.sa_destroy.action_id)),
Quoted 9 lines
app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 3974
Quoted 7 lines
app/test-pmd/cmdline_flow.c +7
-0+ .call = parse_sa_destroy, + }, +/* Shared action create arguments. */ + [SHARED_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a shared action id to create", + .next = NEXT(NEXT_ENTRY(ACTION_RSS),Same here. This is assuming RSS action only.
Fixed, all RTE flow action types supported.
Quoted 479 lines
app/test-pmd/cmdline_flow.c parse_init(struct context *ctx, const struct token
Quoted 24 lines
app/test-pmd/cmdline_flow.c +19
-0+ NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [ACTION_SHARED] = { + .name = "shared", + .help = "apply shared action by id", + .priv = PRIV_ACTION(SHARED, 0), + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + .call = parse_vc, + }, + [SHARED_ACTION_ID2PTR] = { + .name = "{action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_sa_id2ptr, + .comp = comp_none, + }, };/** Remove and return last entry from argument stack. */ @@ -4043,6 +4175,91 @@ parse_init(struct context *ctx, const struct token*token,
app/test-pmd/cmdline_flow.c parse_port(struct context *ctx, const struct token
Quoted 92 lines
app/test-pmd/cmdline_flow.c +85
-0return len; } +/** Parse tokens for shared action commands. */ +static int +parse_sa (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=SHARED_ACTION ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case SHARED_ACTION_CREATE : +case SHARED_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; +/* fallthrough */ +case SHARED_ACTION_QUERY : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + + +/** Parse tokens for shared action destroy command. */ +static int +parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==SHARED_ACTION ) { +if (ctx->curr !=SHARED_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.sa_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + action_id = out->args.sa_destroy.action_id + + out->args.sa_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +} +/** Parse tokens for validate/create commands. */ static int parse_vc(struct context *ctx, const struct token *token,@@ -6110,6 +6327,32 @@ parse_port(struct context *ctx, const struct token*token,
app/test-pmd/config.c rss_config_display(struct rte_flow_action_rss
Quoted 61 lines
app/test-pmd/cmdline_flow.c +43
-0return ret; } +static int +parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct rte_flow_action *action = ctx->object; +uint32_t id; +int ret; + + (void )buf; + (void )size; + ctx->objdata =0 ; + ctx->object = &id; + ctx->objmask =NULL ; + ret =parse_int (ctx, token, str, len, ctx->object,sizeof (id)); + ctx->object = action; +if (ret != (int )len) +return ret; +/* set shared action */ +if (action) { + action->conf =port_shared_action_get_by_id (ctx->port, id); + ret = (action->conf) ? ret :-1 ; + } +return ret; +} +/** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token,@@ -6559,6 +6802,23 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case SHARED_ACTION_CREATE : +port_shared_action_create (in->port, + in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_DESTROY : +port_shared_action_destroy (in->port, + in->args.sa_destroy.action_id_n, + in->args.sa_destroy.action_id); +break ; +case SHARED_ACTION_UPDATE : +port_shared_action_update (in->port, in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_QUERY : +port_shared_action_query (in->port, in->args.sa.action_id); +break ;case VALIDATE :port_flow_validate (in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions);app/test-pmd/config.c +0
-0@@ -1580,6 +1580,221 @@ rss_config_display(struct rte_flow_action_rss
*rss_conf)Quoted 241 lines
app/test-pmd/config.c +215
-0} } +static struct port_shared_action * +action_get_by_id (portid_t port_id,uint32_t id) +{ +struct rte_port *port; +struct port_shared_action **ppsa; +struct port_shared_action *psa =NULL ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return NULL ; + port = &ports[port_id]; + ppsa = &port->actions_list; +while (*ppsa) { +if ((*ppsa)->id == id) { + psa = *ppsa; +break ; + } + ppsa = &(*ppsa)->next; + } +if (!psa) +printf ("Failed to find shared action #%u on port %u\n" , + id, port_id); +return psa; +} + +static int +action_alloc (portid_t port_id,uint32_t id, +struct port_shared_action **action) +{ +struct rte_port *port; +struct port_shared_action **ppsa; +struct port_shared_action *psa =NULL ; + + *action =NULL ; +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; +if (id ==UINT32_MAX ) { +/* taking first available ID */ +if (port->actions_list) { +if (port->actions_list->id ==UINT32_MAX -1 ) { +printf ("Highest shared action ID is already" +" assigned, delete it first\n" ); +return -ENOMEM ; + } + id = port->actions_list->id +1 ; + }else { + id =0 ; + } + } + psa =calloc (1 ,sizeof (*psa)); +if (!psa) { +printf ("Allocation of port %u shared action failed\n" , + port_id); +return -ENOMEM ; + } + ppsa = &port->actions_list; +while (*ppsa && (*ppsa)->id > id) + ppsa = &(*ppsa)->next; +if (*ppsa && (*ppsa)->id == id) { +printf ("Shared action #%u is already assigned," +" delete it first\n" , id); +free (psa); +return -EINVAL ; + } + psa->next = *ppsa; + psa->id = id; + *ppsa = psa; + *action = psa; +return 0 ; +} + +/** Create shared action */ +int +port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action) +{ +struct port_shared_action *psa; +int ret; +struct rte_flow_error error; + + ret =action_alloc (port_id, id, &psa); +if (ret) +return ret; +/* Poisoning to make sure PMDs update it in case of error. */ +memset (&error,0x22 ,sizeof (error)); + psa->action =rte_flow_shared_action_create (port_id,NULL , action, + &error); +if (!psa->action) { +uint32_t destroy_id = psa->id; +port_shared_action_destroy (port_id,1 , &destroy_id); +return port_flow_complain (&error); + } + psa->type = action->type; +printf ("Shared action #%u created\n" , psa->id); +return 0 ; +} + +/** Destroy shared action */ +int +port_shared_action_destroy (portid_t port_id, +uint32_t n, +const uint32_t *actions) +{ +struct rte_port *port; +struct port_shared_action **tmp; +uint32_t c =0 ; +int ret =0 ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + tmp = &port->actions_list; +while (*tmp) { +uint32_t i; + +for (i =0 ; i != n; ++i) { +struct rte_flow_error error; +struct port_shared_action *psa = *tmp; + +if (actions[i] != psa->id) +continue ; +/* +* Poisoning to make sure PMDs update it in case +* of error. +*/ +memset (&error,0x33 ,sizeof (error)); + +if (psa->action &&rte_flow_shared_action_destroy ( + port_id, psa->action, &error)) { + ret =port_flow_complain (&error); +continue ; + } + *tmp = psa->next; +free (psa); +printf ("Shared action #%u destroyed\n" , psa->id); +break ; + } +if (i == n) + tmp = &(*tmp)->next; + ++c; + } +return ret; +} + + +/** Get shared action by port + id */ +struct rte_flow_shared_action * +port_shared_action_get_by_id (portid_t port_id,uint32_t id) +{ + +struct port_shared_action *psa =action_get_by_id (port_id, id); + +return (psa) ? psa->action :NULL ; +} + +/** Update shared action */ +int +port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action) +{ +struct rte_flow_error error; +struct rte_flow_shared_action *shared_action; + + shared_action =port_shared_action_get_by_id (port_id, id); +if (!shared_action) +return -EINVAL ; +if (rte_flow_shared_action_update (port_id, shared_action, action, + &error)) { +return port_flow_complain (&error); + } +printf ("Shared action #%u updated\n" , id); +return 0 ; +} + +int +port_shared_action_query (portid_t port_id,uint32_t id) +{ +struct rte_flow_error error; +struct port_shared_action *psa; +uint64_t default_data; +void *data =NULL ; +int ret =0 ; + + psa =action_get_by_id (port_id, id); +if (!psa) +return -EINVAL ; +switch (psa->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + data = &default_data; +break ; +default : +printf ("Shared action %u (type: %d) on port %u doesn't support" +" query\n" , id, psa->type, port_id); +return -1 ; + } +if (rte_flow_shared_action_query (port_id, psa->action, data, &error)) + ret =port_flow_complain (&error); +switch (psa->type) { +case RTE_FLOW_ACTION_TYPE_RSS : +if (!ret) +printf ("Shared RSS action:\n\trefs:%u\n" , + *((uint32_t *)data)); + data =NULL ; +break ; +default : +printf ("Shared action %u (type: %d) on port %u doesn't support" +" query\n" , id, psa->type, port_id); + ret =-1 ; + } +return ret; +} +/** Validate flow rule. */ int port_flow_validate(portid_t port_id,app/test-pmd/testpmd.h +8
-0@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */ app/test-pmd/testpmd.h struct rte_port { · line 185
Quoted 6 lines
app/test-pmd/testpmd.h +2
-0@@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback*rx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
app/test-pmd/testpmd.h struct rte_port { · line 186
Quoted 1 line
app/test-pmd/testpmd.h +0
-0const struct rte_eth_rxtx_callback*tx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
app/test-pmd/testpmd.h void port_reg_bit_field_set(portid_t port_id,
Quoted 2 lines
app/test-pmd/testpmd.h +0
-0/**< metadata value to insert in Tx packets. */ @@ -748,6 +758,14 @@ void port_reg_bit_field_set(portid_t port_id,
uint32_treg_off,app/test-pmd/testpmd.h void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off,
Quoted 8 lines
app/test-pmd/testpmd.h +5
-0uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id(portid_t
port_id,Review
Quoted 15 lines
app/test-pmd/testpmd.h +4
-0+ uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,@@ -756,6 +774,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);(quoted diff) +0
-0
b/doc/guides/testpmd_app_ug/testpmd_funcs.rstdoc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported actions and their
Quoted 4 lines
index
72bdb1be43..f4b26ed307100644doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0@@ -4382,6 +4382,11 @@ This section lists supported actions and theirattributes, if any.
doc/guides/testpmd_app_ug/testpmd_funcs.rst If attach ``destroy`` parameter, the command will
Quoted 12 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +5
-0- ``dscp_value {unsigned}``: The new DSCP value to be set +- ``shared``: Use shared action created via + ``flow shared_action {port_id} create`` + + - ``shared_action_id {unsigned}``: Shared action ID to use + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~@@ -4671,6 +4676,112 @@ If attach ``destroy`` parameter, the command willdestroy all the list aged flow
Quoted 3 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0testpmd> flow aged 0 Port 0 total aged flows: 0
Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst If attach ``destroy`` parameter, the command will destroy all the list aged flow · line 4685
Quoted 7 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7
-0+Creating shared actions +~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} create`` creates shared action with optional +shared action ID. It is bound to ``rte_flow_shared_action_create()``:: + + flow shared_action {port_id} create [action_id {shared_action_id}] \ + {action} / endNeed to allow passing the direction attribute.
Fixed.
Quoted 106 lines
Quoted 57 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +57
-0+ +If successful, it will show:: + + Shared action #[...] created + +Otherwise, it will complain either that shared action already exists or that +some error occurred:: + + Shared action #[...] is already assigned, delete it first + +:: + + Caught error type [...] ([...]): [...] + +Create shared rss action with id 100 to queues 1 and 2 on port 0:: + + testpmd> flow shared_action 0 create action_id 100 \ + rss queues 1 2 end / end + +Create shared rss action with id assigned by testpmd to queues 1 and 2 on +port 0:: + + testpmd> flow shared_action 0 create action_id \ + rss queues 0 1 end / end + +Updating shared actions +~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} update`` updates configuration of the shared +action from its shared action ID (as returned by +``flow shared_action {port_id} create``). It is bound to +``rte_flow_shared_action_update()``:: + + flow shared_action {port_id} update {shared_action_id} {action} / end + +If successful, it will show:: + + Shared action #[...] updated + +Otherwise, it will complain either that shared action not found or that some +error occurred:: + + Failed to find shared action #[...] on port [...] + +:: + + Caught error type [...] ([...]): [...] + +Update shared rss action having id 100 on port 0 with rss to queues 0 and 3 +(in create example above rss queues were 1 and 2):: + + testpmd> flow shared_action 0 update 100 rss queues 0 3 end / end + +Destroying shared actions +~~~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} update`` destroys one or more shared actions +from their shared action IDs (as returned by +``flow shared_action {port_id} create``). It is bound todoc/guides/testpmd_app_ug/testpmd_funcs.rst If attach ``destroy`` parameter, the command will destroy all the list aged flow
Quoted 10 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +10
-0+``rte_flow_shared_action_destroy()``:: + + flow shared_action {port_id} destroy action_id {shared_action_id} [...] + +If successful, it will show:: + + Shared action #[...] destroyed + +It does not report anything for shared action IDs that do not exist. +The usual error message is shown when a shared action cannot bedestroyed::
Quoted 38 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +32
-1+ + Caught error type [...] ([...]): [...] + +Destroy shared actions having id 100 & 101:: + + testpmd> flow shared_action 0 destroy action_id 100 action_id 101 + +Query shared actions +~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} query`` queries the shared action from its +shared action ID (as returned by ``flow shared_action {port_id} create``). +It is bound to ``rte_flow_shared_action_query()``:: + + flow shared_action {port_id} query {shared_action_id} + +Currently only rss shared action supported. If successful, it will show:: + + Shared RSS action: + refs:[...] + +Otherwise, it will complain either that shared action not found or that some +error occurred:: + + Failed to find shared action #[...] on port [...] + +:: + + Caught error type [...] ([...]): [...] + +Query shared action having id 100:: + + testpmd> flow shared_action 0 query 100 Sample QinQ flow rules ~~~~~~~~~~~~~~~~~~~~~~ --2.26.2
v7 cover RTE flow shared action
In reply to Andrey VesnovatyThis patchset introduces shared action API for RTE flow.
v7 changes:
* misc spelling fixes and rephrase in commit messages and documentation
* RTE flow:
* commit message example updated with shared action create configuration argument
* shared action configuration struct cocumetation updated
* tetspmd:
* added handling of direction arguments for shared action create CLI
* shared action create/update CLIs can receive all RTE flow action types
Andrey Vesnovaty (2):
ethdev: add flow shared action API
app/testpmd: support shared action
app/test-pmd/cmdline.c | 18 ++ app/test-pmd/cmdline_flow.c | 294 +++++++++++++++++++- app/test-pmd/config.c | 216 ++++++++++++++ app/test-pmd/testpmd.h | 20 ++ doc/guides/prog_guide/rte_flow.rst | 19 ++ doc/guides/rel_notes/release_20_11.rst | 9 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 112 ++++++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 ++++++ lib/librte_ethdev/rte_flow.h | 169 ++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++ 11 files changed, 966 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH v7 1/2 ethdev: add flow shared action API
This commit introduces extension of DPDK flow action API enabling sharing of single rte_flow_action in multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.
Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- call rte_flow_destroy()
- call rte_flow_create() with modified RSS action
API for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flows
Change description
===
Shared action
===
In order to represent flow action shared by multiple flows new action type RTE_FLOW_ACTION_TYPE_SHARED is introduced (see enum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (see rte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (see rte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.
In order to share some flow action reuse the handle of type struct rte_flow_shared_action returned by rte_flow_shared_action_create() as a conf field of struct rte_flow_action (see "example" section).
If some shared action not used by any flow rule all resources allocated by the shared action can be released by rte_flow_shared_action_destroy() (see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.
Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated via rte_flow_shared_action_update() (see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.
Shared action query
===
Provide separate API to query shared action state (see rte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled by rte_flow_shared_action_create() and rte_flow_shared_action_update() APIs and no supposed to change by other means.
PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see struct rte_flow_ops).
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordingly
flow shared_action (port) create {action_id (id)} (action) / end flow shared_action (port) update (id) (action) / end
flow shared_action (port) destroy action_id (id) {action_id (id) [...]} flow shared_action (port) query (id)
testpmd example
===
configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / end
create flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \
actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / end
example
===
struct rte_flow_action actions[2];
struct rte_flow_shared_action_conf conf;
struct rte_flow_action action;
/* skipped: initialize conf and action */
struct rte_flow_shared_action *handle =
rte_flow_shared_action_create(port_id, &conf, &action, &error);
actions[0].type = RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type = RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
struct rte_flow *flow0 = rte_flow_create(port_id, &attr0, pattern0,
actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);
/* update shared action */
struct rte_flow_action updated_action;
/*
* skipped: initialize updated_action according to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
* updated_action
*/
/* skipped: destroy all flows 1 till N */ rte_flow_shared_action_destroy(port_id, handle, error);
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++++++ lib/librte_ethdev/rte_flow.h | 169 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 +++ 6 files changed, 307 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +19 -0
@@ -2666,6 +2666,25 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+ +Action: ``SHARED`` +^^^^^^^^^^^^^^^^^^ + +Flow Utilize shared action by handle as returned from +``rte_flow_shared_action_create()``. + +The behaviour of the shared action defined by ``action`` argument of type +``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``. + +.. _table_rte_flow_shared_action: + +.. table:: SHARED + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_20_11.rst +9 -0
@@ -109,6 +109,15 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Add shared action support for rte flow.** + + Added shared action support to utilize single rte flow action in multiple + rte flow rules. An update of shared action configuration alters the behavior + of all rte flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared action + as rte flow action. + * Added new rte flow APIs to create/update/destroy/query shared action. Removed Items -------------
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query; }; INTERNAL {
lib/librte_ethdev/rte_flow.c +84 -0
93 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +168 -1
193 lines not on this page · raw message
lib/librte_ethdev/rte_flow_driver.h +23 -0
@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
Quoted 145 lines · Andrey Vesnovaty
This commit introduces extension of DPDK flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endexample
===struct
rte_flow_actionactions[2];
structrte_flow_shared_action_confconf;
structrte_flow_actionaction;
/* skipped: initialize conf and action */
structrte_flow_shared_action*handle =rte_flow_shared_action_create(port_id, &conf, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);
Quoted 2 lines
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>
Since this is an ethdev patch, the testpmd description is really not required. Moreover they are not in sync with the direction and other changes you made in the testpmd patch. Also there is a typo inline. Other than that..
Quoted 9 lines
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++++++ lib/librte_ethdev/rte_flow.h | 169 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 +++ 6 files changed, 307 insertions(+), 1 deletion(-)
[snip]
Quoted 19 lines
lib/librte_ethdev/rte_flow.h +14
-0+ +/** +* RTE_FLOW_ACTION_TYPE_SHARED +* +* Opaque type returned after successfully creating a shared action. +* +* This handle can be used to manage and query the related action: +* - share it across multiple flow rules +* - update action configuration +* - query action data +* - destroy action +*/ +struct rte_flow_shared_action ; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;@@ -3357,6 +3380,150 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
lib/librte_ethdev/rte_flow.h int · line 3390
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +8
-0uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +/** +* Flow direction for shared action configuration. +* +* Shred action should be valid at least for one flow direction,
s/Shred/Shared
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+* otherwise it is invalid for both ingress and egress rules. +*/ + uint32_t ingress:1; +/**< Action valid for rules applied to ingress traffic. */ + uint32_t egress:1; +/**< Action valid for rules applied to egress traffic. */ +};
[snip]
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
Hi Ajit
All your suggestions applied in v8 series.
BW Thomas & Andrew pointed to testpmd example in RTE flow API.
Thanks,
Andrey
Quoted 220 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Friday, October 9, 2020 1:31 AM
To: Andrey Vesnovaty <[email protected]>
Cc: dpdk-dev <[email protected]>; [email protected]; Jerin Jacob <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Stephen Hemminger <[email protected]>; Bruce Richardson <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; Ray Kinsella <[email protected]>; Neil Horman <[email protected]>; Samik Gupta <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v7 1/2] ethdev: add flow shared action APIQuoted 145 lines · Andrey Vesnovaty
This commit introduces extension of DPDK flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endexample
===struct
rte_flow_actionactions[2];
structrte_flow_shared_action_confconf;
structrte_flow_actionaction;
/* skipped: initialize conf and action */
structrte_flow_shared_action*handle =rte_flow_shared_action_create(port_id, &conf, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);Quoted 2 lines
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>Since this is an ethdev patch, the testpmd description is really not required. Moreover they are not in sync with the direction and other changes you made in the testpmd patch. Also there is a typo inline. Other than that..
Acked-by Ajit Khaparde <[email protected]>Quoted 9 lines
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++++++ lib/librte_ethdev/rte_flow.h | 169 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 +++ 6 files changed, 307 insertions(+), 1 deletion(-)[snip]
Quoted 19 lines
lib/librte_ethdev/rte_flow.h +14
-0+ +/** +* RTE_FLOW_ACTION_TYPE_SHARED +* +* Opaque type returned after successfully creating a shared action. +* +* This handle can be used to manage and query the related action: +* - share it across multiple flow rules +* - update action configuration +* - query action data +* - destroy action +*/ +struct rte_flow_shared_action ; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;@@ -3357,6 +3380,150 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts,lib/librte_ethdev/rte_flow.h int · line 3390
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +8
-0uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +/** +* Flow direction for shared action configuration. +* +* Shred action should be valid at least for one flow direction, s/Shred/Shared
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+* otherwise it is invalid for both ingress and egress rules. +*/ + uint32_t ingress:1; +/**< Action valid for rules applied to ingress traffic. */ + uint32_t egress:1; +/**< Action valid for rules applied to egress traffic. */ +};[snip]
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
In reply to Andrey Vesnovaty"add flow shared action API"
Is flow shared? May be "add shared actions to flow API".
Quoted 1 line · Andrey Vesnovaty
This commit introduces extension of DPDK flow action API enabling
"This commit" and "DPDK" are not necessary in description. It is a commit description and the patch is to DPDK tree. Consider just:
"Introduce extension of flow action API enabling..."
Quoted 98 lines
sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / end
Quoted 9 lines
create flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / end
testpmd is out-of-scope of the patch and it is better to remove the description to avoid unsync if testpmd commands are changed.
Quoted 36 lines
example
===struct
rte_flow_actionactions[2];
structrte_flow_shared_action_confconf;
structrte_flow_actionaction;
/* skipped: initialize conf and action */
structrte_flow_shared_action*handle =rte_flow_shared_action_create(port_id, &conf, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);
Quoted 2 lines
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>
LGTM
Quoted 14 lines
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++++++ lib/librte_ethdev/rte_flow.h | 169 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 +++ 6 files changed, 307 insertions(+), 1 deletion(-)doc/guides/prog_guide/rte_flow.rst +0
-0
doc/guides/prog_guide/rte_flow.rst timeout passed without any matching on the flow. · line 2672
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +4
-0@@ -2666,6 +2666,25 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+ +Action: ``SHARED`` +^^^^^^^^^^^^^^^^^^ + +Flow Utilize shared action by handle as returned from
Utilize -> utilize
Quoted 23 lines
doc/guides/prog_guide/rte_flow.rst +15
-0+``rte_flow_shared_action_create()``. + +The behaviour of the shared action defined by ``action`` argument of type +``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``. + +.. _table_rte_flow_shared_action: + +.. table:: SHARED + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~doc/guides/rel_notes/release_20_11.rst +0
-0
doc/guides/rel_notes/release_20_11.rst New Features · line 112
Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +1
-0@@ -109,6 +109,15 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Add shared action support for rte flow.**
I think it required "ethdev: " prefix.
Add -> Added, rte -> RTE, plus API, i.e.:
**ethdev: Added shared action support to RTE flow API."
doc/guides/rel_notes/release_20_11.rst New Features · line 114
Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +2
-0+ + Added shared action support to utilize single rte flow action in multiple
rte -> RTE, but I'd consider to drop RTE in both description, here and below.
doc/guides/rel_notes/release_20_11.rst New Features · line 120
Quoted 6 lines
doc/guides/rel_notes/release_20_11.rst +6
-0+ rte flow rules. An update of shared action configuration alters the behavior + of all rte flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared action + as rte flow action. + * Added new rte flow APIs to create/update/destroy/query shared action.
Missing one more empty line here.
Quoted 8 lines
doc/guides/rel_notes/release_20_11.rst +0
-0Removed Items -------------lib/librte_ethdev/rte_ethdev_version.map +0
-0
lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 235
Quoted 7 lines
lib/librte_ethdev/rte_ethdev_version.map +4
-0@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query;
Shouldn't it be alphabetically sorted?
lib/librte_ethdev/rte_flow.c static const struct rte_flow_desc_data rte_flow_desc_action[] = { · line 177
Quoted 12 lines
lib/librte_ethdev/rte_ethdev_version.map +0
-0}; INTERNAL {lib/librte_ethdev/rte_flow.c +1
-0@@ -174,6 +174,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {MK_FLOW_ACTION (SET_IPV4_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (SET_IPV6_DSCP ,sizeof (struct rte_flow_action_set_dscp )),MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )), + MK_FLOW_ACTION(SHARED, 0),
It looks correct, it deserves a comment which explains why size is 0 here.
Quoted 5 lines
lib/librte_ethdev/rte_flow.c +0
-0};int @@ -1251,3 +1252,86 @@ rte_flow_get_aged_flows(uint16_t port_id, void **contexts, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1262
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +8
-0NULL, rte_strerror(ENOTSUP)); } + +struct rte_flow_shared_action * +rte_flow_shared_action_create (uint16_t port_id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];
Sorry, but it unsafe to initialize it before port_id check. It is too error-prone for the future maintenance of the code. Since, port_id is checked indirection here via rte_flow_ops_get(), please, initialize the variable or even move it completely to be just before usage.
I realize that nearby code does the same, but IMHO it is never later to turn into the right direction.
Quoted 13 lines
lib/librte_ethdev/rte_flow.c +13
-0+struct rte_flow_shared_action *shared_action; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return NULL ; +if (likely (!!ops->shared_action_create)) { + shared_action = ops->shared_action_create (dev, conf, action, + error); +if (shared_action ==NULL ) +flow_err (port_id, -rte_errno, error); +return shared_action; + } + rte_flow_error_set(error, ENOSYS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1285
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +10
-0+ NULL, rte_strerror(ENOSYS)); +return NULL ; +} + +int +rte_flow_shared_action_destroy (uint16_t port_id, +struct rte_flow_shared_action *action, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];
same here
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +10
-0+const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->shared_action_destroy)) +return flow_err (port_id, + ops->shared_action_destroy (dev, action, error), + error); + return rte_flow_error_set(error, ENOSYS, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1305
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +10
-0+ NULL, rte_strerror(ENOSYS)); +} + +int +rte_flow_shared_action_update (uint16_t port_id, +struct rte_flow_shared_action *action, +const struct rte_flow_action *update, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];
same here
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1313
Quoted 8 lines
lib/librte_ethdev/rte_flow.c +8
-0+const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->shared_action_update)) +return flow_err (port_id, ops->shared_action_update (dev, action, + update, error), + error);
Sorry, but above is very hard to follow what is where. May be helper variable sfor op result should be used to make it readable.
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1325
Quoted 12 lines
lib/librte_ethdev/rte_flow.c +12
-0+return rte_flow_error_set (error,ENOSYS , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOSYS )); +} + +int +rte_flow_shared_action_query (uint16_t port_id, +const struct rte_flow_shared_action *action, +void *data, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];
same here
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1333
Quoted 8 lines
lib/librte_ethdev/rte_flow.c +8
-0+const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->shared_action_query)) +return flow_err (port_id, ops->shared_action_query (dev, action, + data, error), + error);
Sorry, but above is very hard to follow what is where. May be helper variable sfor op result should be used to make it readable.
Quoted 88 lines
lib/librte_ethdev/rte_flow.c +4
-0+return rte_flow_error_set (error,ENOSYS , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOSYS )); +}lib/librte_ethdev/rte_flow.h +54
-1@@ -1714,7 +1714,8 @@ enum rte_flow_action_type {/** * Enables counters for this flow rule. * -* These counters can be retrieved and reset through rte_flow_query(), +* These counters can be retrieved and reset through rte_flow_query() or +* rte_flow_shared_action_query() if the action provided via handle, * see struct rte_flow_query_count. * * See struct rte_flow_action_count. @@ -2132,6 +2133,14 @@ enum rte_flow_action_type {* see enum RTE_ETH_EVENT_FLOW_AGED */ RTE_FLOW_ACTION_TYPE_AGE , + +/** +* Describe action shared across multiple flow rules. +* +* Allow multiple rules reference the same action by handle (see +* struct rte_flow_shared_action). +*/ + RTE_FLOW_ACTION_TYPE_SHARED, };/** @@ -2693,6 +2702,20 @@ struct rte_flow_action_set_dscp {uint8_t dscp; }; + +/** +* RTE_FLOW_ACTION_TYPE_SHARED +* +* Opaque type returned after successfully creating a shared action. +* +* This handle can be used to manage and query the related action: +* - share it across multiple flow rules +* - update action configuration +* - query action data +* - destroy action +*/ +struct rte_flow_shared_action ; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;@@ -3357,6 +3380,150 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +/** +* Flow direction for shared action configuration. +* +* Shred action should be valid at least for one flow direction, +* otherwise it is invalid for both ingress and egress rules. +*/ +uint32_t ingress:1 ; +/**< Action valid for rules applied to ingress traffic. */ +uint32_t egress:1 ; +/**< Action valid for rules applied to egress traffic. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create shared action for reuse in multiple flow rules. +* The created shared action has single state and configuration +* across all flow rules using it. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] conf +* Shared action configuration. +* @param[in] action +* Action configuration for shared action creation.
lib/librte_ethdev/rte_flow.h int · line 3422
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return +* A valid handle in case of success, NULL otherwise and rte_errno is set +* to one of the error codes defined: +* - (ENOSYS) if underlying device does not support this functionality. +* - (EIO) if underlying device is removed. +* - (EINVAL) if *action* invalid. +* - (ENOTSUP) if *action* valid but unsupported.
ENODEV ?
Quoted 19 lines
lib/librte_ethdev/rte_flow.h +19
-0+*/ +__rte_experimental +struct rte_flow_shared_action * +rte_flow_shared_action_create (uint16_t port_id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy the shared action by handle. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] action +* Handle for the shared action to be destroyed. +* @param[out] error
lib/librte_ethdev/rte_flow.h int · line 3451
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return +* - (0) if success. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-ETOOMANYREFS) if action pointed by *action* handle still used by one or +* more rules +* rte_errno is also set.
-ENODEV?
Quoted 24 lines
lib/librte_ethdev/rte_flow.h +24
-0+*/ +__rte_experimental +int +rte_flow_shared_action_destroy (uint16_t port_id, +struct rte_flow_shared_action *action, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Update in-place the shared action configuration pointed by *action* handle +* with the configuration provided as *update* argument. +* The update of the shared action configuration effects all flow rules reusing +* the action via handle. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] action +* Handle for the shared action to be updated. +* @param[in] update +* Action specification used to modify the action pointed by handle. +* *update* should be of same type with the action pointed by the *action* +* handle argument, otherwise considered as invalid.
lib/librte_ethdev/rte_flow.h int · line 3485
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return +* - (0) if success. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-EINVAL) if *update* invalid. +* - (-ENOTSUP) if *update* valid but unsupported. +* - (-ENOENT) if action pointed by *ctx* was not found.
-ENODEV ?
Quoted 79 lines
lib/librte_ethdev/rte_flow.h +41
-0+* rte_errno is also set. +*/ +__rte_experimental +int +rte_flow_shared_action_update (uint16_t port_id, +struct rte_flow_shared_action *action, +const struct rte_flow_action *update, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Query the shared action by handle. +* +* Retrieve action-specific data such as counters. +* Data is gathered by special action which may be present/referenced in +* more than one flow rule definition. +* +* \see RTE_FLOW_ACTION_TYPE_COUNT +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] action +* Handle for the shared action to query. +* @param[in, out] data +* Pointer to storage for the associated query data type. +* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_shared_action_query (uint16_t port_id, +const struct rte_flow_shared_action *action, +void *data, +struct rte_flow_error *error); + #ifdef __cplusplus }#endif lib/librte_ethdev/rte_flow_driver.h +23
-0@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
Hi Andrew.
Thanks for the input.
All spelling & rephrases will be applied PSB for the rest. Will publish v8 very soon.
Thanks,
Andrey
Quoted 12 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 5:19 PM
To: Andrey Vesnovaty <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
Quoted 3 lines
"add flow shared action API"
Is flow shared? May be "add shared actions to flow API".
Accepted, will update commit message.
Quoted 8 lines · Andrey Vesnovaty
Quoted 1 line
This commit introduces extension of DPDK flow action API enabling
"This commit" and "DPDK" are not necessary in description. It is a commit description and the patch is to DPDK tree. Consider just:
"Introduce extension of flow action API enabling..."
Accepted, will update commit message.
Quoted 105 lines
Quoted 105 lines
sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
Quoted 7 lines
Quoted 3 lines
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endtestpmd is out-of-scope of the patch and it is better to remove the description to avoid unsync if testpmd commands are changed.
There is still added value is testpmd example demonstrating usage of shared action with rte flows. I will update the example to reflect the current testpmd syntax for shared action.
Quoted 60 lines
Quoted 37 lines
example
===struct
rte_flow_actionactions[2];
structrte_flow_shared_action_confconf;
structrte_flow_actionaction;
/* skipped: initialize conf and action */
structrte_flow_shared_action*handle =rte_flow_shared_action_create(port_id, &conf, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);Quoted 2 lines
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>LGTM
Review
Quoted 10 lines
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 9 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 84 +++++++++++ lib/librte_ethdev/rte_flow.h | 169 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 +++ 6 files changed, 307 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstQuoted 7 lines
index
119b128739..8cff8a0440100644doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2666,6 +2666,25 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst timeout passed without any matching on the flow. · line 2672
Quoted 4 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+Action: ``SHARED`` +^^^^^^^^^^^^^^^^^^ + +Flow Utilize shared action by handle as returned fromUtilize -> utilize
Will fix.
Quoted 28 lines
Review
Quoted 20 lines
doc/guides/prog_guide/rte_flow.rst +15
-0+``rte_flow_shared_action_create()``. + +The behaviour of the shared action defined by ``action`` argument of type +``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``. + +.. _table_rte_flow_shared_action: + +.. table:: SHARED + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~(quoted diff) +0
-0
b/doc/guides/rel_notes/release_20_11.rstQuoted 7 lines
index
0b2a3700c3..87c90909be100644doc/guides/rel_notes/release_20_11.rst +0
-0@@ -109,6 +109,15 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates.
Quoted 6 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 112
Quoted 1 line
doc/guides/rel_notes/release_20_11.rst +1
-0+* **Add shared action support for rte flow.**I think it required "ethdev: " prefix.
Add -> Added, rte -> RTE, plus API, i.e.:
**ethdev: Added shared action support to RTE flow API."
"ethdev:" prefix used in 'API Changes '. I'll change it to:
* **Added ethdev API to support shared action for RTE flow.**
Quoted 10 lines
doc/guides/rel_notes/release_20_11.rst New Features · line 114
Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +2
-0+ + Added shared action support to utilize single rte flow action in multiplerte -> RTE, but I'd consider to drop RTE in both description, here and below.
doc/guides/rel_notes/release_20_11.rst New Features
Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +4
-0+ rte flow rules. An update of shared action configuration alters the behavior + of all rte flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared
Quoted 5 lines
action
doc/guides/rel_notes/release_20_11.rst New Features · line 120
Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +2
-0+ as rte flow action. + * Added new rte flow APIs to create/update/destroy/query shared action.Missing one more empty line here.
Will fix.
Quoted 6 lines
Review
Quoted 5 lines
doc/guides/rel_notes/release_20_11.rst +0
-0Removed Items -------------(quoted diff) +0
-0b/lib/librte_ethdev/rte_ethdev_version.map
Quoted 13 lines
lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 235
Quoted 11 lines
index
c95ef5157a..a8a4821dbb100644lib/librte_ethdev/rte_ethdev_version.map +4
-0@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query;Shouldn't it be alphabetically sorted?
Query before update?
Quoted 11 lines
lib/librte_ethdev/rte_flow.c static const struct rte_flow_desc_data
Quoted 9 lines
lib/librte_ethdev/rte_ethdev_version.map +0
-0}; INTERNAL {lib/librte_ethdev/rte_flow.c +0
-0@@ -174,6 +174,7 @@ static const struct rte_flow_desc_datarte_flow_desc_action[] = {
lib/librte_ethdev/rte_flow.c static const struct rte_flow_desc_data · line 174
Quoted 1 line
lib/librte_ethdev/rte_flow.c +0
-0MK_FLOW_ACTION(SET_IPV4_DSCP, sizeof(struct
Quoted 8 lines
rte_flow_action_set_dscp)),lib/librte_ethdev/rte_flow.c static const struct rte_flow_desc_data · line 175
Quoted 1 line
lib/librte_ethdev/rte_flow.c +0
-0MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct
rte_flow_action_set_dscp)),lib/librte_ethdev/rte_flow.c static const struct rte_flow_desc_data rte_flow_desc_action[] = { · line 177
Quoted 2 lines
lib/librte_ethdev/rte_flow.c +1
-0MK_FLOW_ACTION (AGE ,sizeof (struct rte_flow_action_age )), + MK_FLOW_ACTION(SHARED, 0),It looks correct, it deserves a comment which explains why size is 0 here.
Comment will be added.
Quoted 24 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void
Quoted 5 lines
lib/librte_ethdev/rte_flow.c +0
-0};int @@ -1251,3 +1252,86 @@ rte_flow_get_aged_flows(uint16_t port_id, void**contexts,
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1262
Quoted 11 lines
lib/librte_ethdev/rte_flow.c +8
-0RTE_FLOW_ERROR_TYPE_UNSPECIFIED , NULL, rte_strerror(ENOTSUP)); } + +struct rte_flow_shared_action * +rte_flow_shared_action_create (uint16_t port_id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];Sorry, but it unsafe to initialize it before
port_idcheck. It is too error-prone for the future maintenance of the code. Since,port_idis checked indirection here viarte_flow_ops_get(), please, initialize the variable or even move it completely to be just before usage.
Quoted 2 lines
I realize that nearby code does the same, but IMHO it is never later to turn into the right direction.
Will fix.
Quoted 15 lines
Quoted 4 lines
lib/librte_ethdev/rte_flow.c +3
-0+struct rte_flow_shared_action *shared_action; +const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); +lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +10
-0+if (unlikely (!ops)) +return NULL ; +if (likely (!!ops->shared_action_create)) { + shared_action = ops->shared_action_create (dev, conf, action, + error); +if (shared_action ==NULL ) +flow_err (port_id, -rte_errno, error); +return shared_action; + } + rte_flow_error_set(error, ENOSYS,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
Quoted 12 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1285
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +10
-0+ NULL, rte_strerror(ENOSYS)); +return NULL ; +} + +int +rte_flow_shared_action_destroy (uint16_t port_id, +struct rte_flow_shared_action *action, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];same here
Will fix.
Quoted 9 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
Quoted 8 lines
lib/librte_ethdev/rte_flow.c +7
-0+const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->shared_action_destroy)) + return flow_err(port_id, + ops->shared_action_destroy(dev, action,error),
Quoted 15 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1305
Quoted 13 lines
lib/librte_ethdev/rte_flow.c +13
-0+ error); +return rte_flow_error_set (error,ENOSYS , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOSYS )); +} + +int +rte_flow_shared_action_update (uint16_t port_id, +struct rte_flow_shared_action *action, +const struct rte_flow_action *update, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];same here
Will fix.
Quoted 8 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
Quoted 7 lines
lib/librte_ethdev/rte_flow.c +6
-0+const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->shared_action_update)) + return flow_err(port_id, ops->shared_action_update(dev,action,
Quoted 6 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void · line 1313
Quoted 2 lines
lib/librte_ethdev/rte_flow.c +2
-0+ update, error), + error);Sorry, but above is very hard to follow what is where. May be helper variable sfor op result should be used to make it readable.
Agree, refactoring needed.
Quoted 15 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1325
Quoted 13 lines
lib/librte_ethdev/rte_flow.c +12
-0+return rte_flow_error_set (error,ENOSYS , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOSYS )); +} + +int +rte_flow_shared_action_query (uint16_t port_id, +const struct rte_flow_shared_action *action, +void *data, +struct rte_flow_error *error) +{ +struct rte_eth_dev *dev = &rte_eth_devices[port_id];same here
Will fix.
Quoted 13 lines
lib/librte_ethdev/rte_flow.c rte_flow_get_aged_flows(uint16_t port_id, void **contexts, · line 1333
Quoted 9 lines
lib/librte_ethdev/rte_flow.c +8
-0+const struct rte_flow_ops *ops =rte_flow_ops_get (port_id, error); + +if (unlikely (!ops)) +return -rte_errno; +if (likely (!!ops->shared_action_query)) +return flow_err (port_id, ops->shared_action_query (dev, action, + data, error), + error);Sorry, but above is very hard to follow what is where. May be helper variable sfor op result should be used to make it readable.
Agree, refactoring needed.
Quoted 94 lines
Quoted 10 lines
lib/librte_ethdev/rte_flow.c +4
-0+return rte_flow_error_set (error,ENOSYS , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL ,rte_strerror (ENOSYS )); +}lib/librte_ethdev/rte_flow.h +0
-0lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 1717
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +1
-1@@ -1714,7 +1714,8 @@ enum rte_flow_action_type {/** * Enables counters for this flow rule. * -* These counters can be retrieved and reset through rte_flow_query(), +* These counters can be retrieved and reset through rte_flow_query() or
Quoted 78 lines
lib/librte_ethdev/rte_flow.h +57
-0+* rte_flow_shared_action_query() if the action provided via handle, * see struct rte_flow_query_count. * * See struct rte_flow_action_count. @@ -2132,6 +2133,14 @@ enum rte_flow_action_type {* see enum RTE_ETH_EVENT_FLOW_AGED */ RTE_FLOW_ACTION_TYPE_AGE , + +/** +* Describe action shared across multiple flow rules. +* +* Allow multiple rules reference the same action by handle (see +* struct rte_flow_shared_action). +*/ + RTE_FLOW_ACTION_TYPE_SHARED, };/** @@ -2693,6 +2702,20 @@ struct rte_flow_action_set_dscp {uint8_t dscp; }; + +/** +* RTE_FLOW_ACTION_TYPE_SHARED +* +* Opaque type returned after successfully creating a shared action. +* +* This handle can be used to manage and query the related action: +* - share it across multiple flow rules +* - update action configuration +* - query action data +* - destroy action +*/ +struct rte_flow_shared_action ; +/* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs;@@ -3357,6 +3380,150 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +/** +* Flow direction for shared action configuration. +* +* Shred action should be valid at least for one flow direction, +* otherwise it is invalid for both ingress and egress rules. +*/ +uint32_t ingress:1 ; +/**< Action valid for rules applied to ingress traffic. */ +uint32_t egress:1 ; +/**< Action valid for rules applied to egress traffic. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create shared action for reuse in multiple flow rules. +* The created shared action has single state and configuration +* across all flow rules using it. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] conf +* Shared action configuration. +* @param[in] action +* Action configuration for shared action creation. +* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return
Quoted 8 lines
lib/librte_ethdev/rte_flow.h int · line 3422
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* A valid handle in case of success, NULL otherwise and rte_errno is set +* to one of the error codes defined: +* - (ENOSYS) if underlying device does not support this functionality. +* - (EIO) if underlying device is removed. +* - (EINVAL) if *action* invalid. +* - (ENOTSUP) if *action* valid but unsupported. ENODEV ?
Can you elaborate?
Quoted 29 lines
Quoted 18 lines
lib/librte_ethdev/rte_flow.h +17
-0+*/ +__rte_experimental +struct rte_flow_shared_action * +rte_flow_shared_action_create (uint16_t port_id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Destroy the shared action by handle. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] action lib/librte_ethdev/rte_flow.h int
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* Handle for the shared action to be destroyed. +* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return +* - (0) if success. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-ENOENT) if action pointed by *action* handle was not found. +* - (-ETOOMANYREFS) if action pointed by *action* handle still used by one or
Quoted 4 lines
lib/librte_ethdev/rte_flow.h int · line 3451
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+* more rules +* rte_errno is also set.
-ENODEV?
Same here.
Quoted 37 lines
lib/librte_ethdev/rte_flow.h int
Quoted 13 lines
lib/librte_ethdev/rte_flow.h +12
-0+*/ +__rte_experimental +int +rte_flow_shared_action_destroy (uint16_t port_id, +struct rte_flow_shared_action *action, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Update in-place the shared action configuration pointed by *action* handle
Quoted 12 lines
lib/librte_ethdev/rte_flow.h +12
-0+* with the configuration provided as *update* argument. +* The update of the shared action configuration effects all flow rules reusing +* the action via handle. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] action +* Handle for the shared action to be updated. +* @param[in] update +* Action specification used to modify the action pointed by handle. +* *update* should be of same type with the action pointed by the *action* +* handle argument, otherwise considered as invalid. lib/librte_ethdev/rte_flow.h int · line 3485
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return +* - (0) if success. +* - (-ENOSYS) if underlying device does not support this functionality. +* - (-EIO) if underlying device is removed. +* - (-EINVAL) if *update* invalid. +* - (-ENOTSUP) if *update* valid but unsupported. +* - (-ENOENT) if action pointed by *ctx* was not found.
Quoted 1 line
-ENODEV?
And once more.
Quoted 81 lines
Review
Quoted 46 lines
lib/librte_ethdev/rte_flow.h +41
-0+* rte_errno is also set. +*/ +__rte_experimental +int +rte_flow_shared_action_update (uint16_t port_id, +struct rte_flow_shared_action *action, +const struct rte_flow_action *update, +struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Query the shared action by handle. +* +* Retrieve action-specific data such as counters. +* Data is gathered by special action which may be present/referenced in +* more than one flow rule definition. +* +* \see RTE_FLOW_ACTION_TYPE_COUNT +* +* @param port_id +* Port identifier of Ethernet device. +* @param[in] action +* Handle for the shared action to query. +* @param[in, out] data +* Pointer to storage for the associated query data type. +* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* +* @return +* 0 on success, a negative errno value otherwise and rte_errno is set. +*/ +__rte_experimental +int +rte_flow_shared_action_query (uint16_t port_id, +const struct rte_flow_shared_action *action, +void *data, +struct rte_flow_error *error); + #ifdef __cplusplus }#endif (quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow_driver.hQuoted 34 lines
index
3ee871d3eb..adaace47ea100644lib/librte_ethdev/rte_flow_driver.h +23
-0@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
Hi Andrey,
Quoted 145 lines · Andrey Vesnovaty
Hi Andrew.
Thanks for the input.
All spelling & rephrases will be applied PSB for the rest. Will publish v8 very soon.Thanks,
AndreyQuoted 12 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 5:19 PM
To: Andrey Vesnovaty <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action APIQuoted 3 lines
"add flow shared action API"
Is flow shared? May be "add shared actions to flow API".
Accepted, will update commit message.
Quoted 8 lines · Andrey Vesnovaty
Quoted 1 line
This commit introduces extension of DPDK flow action API enabling
"This commit" and "DPDK" are not necessary in description. It is a commit description and the patch is to DPDK tree. Consider just:
"Introduce extension of flow action API enabling..."Accepted, will update commit message.
Quoted 109 lines
Quoted 108 lines
sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / end
Quoted 7 lines
Quoted 3 lines
testpmd is out-of-scope of the patch and it is better to remove the description to avoid unsync if testpmd commands are changed.
There is still added value is testpmd example demonstrating usage of shared action with rte flows. I will update the example to reflect the current testpmd syntax for shared action.
Yes and no. IMHO It would be OK for series description etc, but not OK for the changeset description which will be kept in the history and will become misleading when commands are changed. I think that no information is better than potentially wrong information.
[snip]
Quoted 16 lines
Quoted 15 lines
Review
Quoted 1 line
(quoted diff) +0
-0b/lib/librte_ethdev/rte_ethdev_version.map
lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 235
Quoted 11 lines
index
c95ef5157a..a8a4821dbb100644lib/librte_ethdev/rte_ethdev_version.map +4
-0@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query;Shouldn't it be alphabetically sorted?
Quoted 1 line
Query before update?
yes
[snip]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +0
-0
[snip]
Quoted 47 lines
Quoted 38 lines
Quoted 38 lines
lib/librte_ethdev/rte_flow.h +34
-0@@ -3357,6 +3380,150 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +/** +* Flow direction for shared action configuration. +* +* Shred action should be valid at least for one flow direction, +* otherwise it is invalid for both ingress and egress rules. +*/ +uint32_t ingress:1 ; +/**< Action valid for rules applied to ingress traffic. */ +uint32_t egress:1 ; +/**< Action valid for rules applied to egress traffic. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create shared action for reuse in multiple flow rules. +* The created shared action has single state and configuration +* across all flow rules using it. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] conf +* Shared action configuration. +* @param[in] action +* Action configuration for shared action creation. +* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return Quoted 8 lines
lib/librte_ethdev/rte_flow.h int · line 3422
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* A valid handle in case of success, NULL otherwise and rte_errno is set +* to one of the error codes defined: +* - (ENOSYS) if underlying device does not support this functionality. +* - (EIO) if underlying device is removed. +* - (EINVAL) if *action* invalid. +* - (ENOTSUP) if *action* valid but unsupported. ENODEV ?
Quoted 1 line
Can you elaborate?
ENODEV is returned if port_id is invalid and it should be documented here if you try to list all return values.
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
14/10/2020 08:49, Andrew Rybchenko:
Quoted 48 lines · Andrey Vesnovaty
Quoted 47 lines
From: Andrew Rybchenko <[email protected]>
Quoted 46 lines
Quoted 46 lines
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).
This sentence is strange.
Of course PMD implementation is a PMD specific design. I think you can remove it.
Quoted 36 lines
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endQuoted 7 lines
Quoted 3 lines
testpmd is out-of-scope of the patch and it is better to remove the description to avoid unsync if testpmd commands are changed.
There is still added value is testpmd example demonstrating usage of shared action with rte flows. I will update the example to reflect the current testpmd syntax for shared action.
Quoted 5 lines
Yes and no. IMHO It would be OK for series description etc, but not OK for the changeset description which will be kept in the history and will become misleading when commands are changed. I think that no information is better than potentially wrong information.
I agree with Andrew, the API explanation should be enough. Talking about testpmd commands in the ethdev patch is not appropriate.
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
Hi Thomas
All your suggestions applied in v8 series.
Thanks,
Andrey
Quoted 118 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 14, 2020 10:23 AM
To: Andrey Vesnovaty <[email protected]>
Cc: [email protected]; Andrew Rybchenko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API14/10/2020 08:49, Andrew Rybchenko:
Quoted 15 lines · Andrey Vesnovaty
Quoted 14 lines
From: Andrew Rybchenko <[email protected]>
Quoted 13 lines
Quoted 13 lines
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required forshared
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
action implementation.
In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by theupdate
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change byother
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
means.
PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).This sentence is strange.
Of course PMD implementation is a PMD specific design. I think you can remove it.Quoted 36 lines
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endQuoted 7 lines
Quoted 3 lines
testpmd is out-of-scope of the patch and it is better to remove the description to avoid unsync if testpmd commands are changed.
There is still added value is testpmd example demonstrating usage of shared action with rte flows. I will update the example to reflect the current testpmd syntax for shared action.
Quoted 5 lines
Yes and no. IMHO It would be OK for series description etc, but not OK for the changeset description which will be kept in the history and will become misleading when commands are changed. I think that no information is better than potentially wrong information.
I agree with Andrew, the API explanation should be enough. Talking about testpmd commands in the ethdev patch is not appropriate.
Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API
In reply to Andrew RybchenkoHi Andrew
All your suggestions applied in v8 series.
Thanks,
Andrey
Quoted 258 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Wednesday, October 14, 2020 9:50 AM
To: Andrey Vesnovaty <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action APIHi Andrey,
Quoted 14 lines · Andrey Vesnovaty
Hi Andrew.
Thanks for the input.
All spelling & rephrases will be applied PSB for the rest. Will publish v8 very soon.Thanks,
AndreyQuoted 5 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 5:19 PM
To: Andrey Vesnovaty <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; NBU-Contact-ThomasMonjalon
Quoted 131 lines
Quoted 10 lines
<[email protected]>; [email protected]; [email protected]; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/2] ethdev: add flow shared action API"add flow shared action API"
Is flow shared? May be "add shared actions to flow API".
Accepted, will update commit message.
Quoted 8 lines · Andrey Vesnovaty
Quoted 1 line
This commit introduces extension of DPDK flow action API enabling
"This commit" and "DPDK" are not necessary in description. It is a commit description and the patch is to DPDK tree. Consider just:
"Introduce extension of flow action API enabling..."Accepted, will update commit message.
Quoted 109 lines
Quoted 108 lines
sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.PMD support
===
The support of introduced API is pure PMD specific design and responsibility for each action type (see structrte_flow_ops).testpmd
===
In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordinglyflow
shared_action(port) create {action_id(id)} (action) / end flowshared_action(port) update (id) (action) / end
flowshared_action(port) destroyaction_id(id) {action_id(id) [...]} flowshared_action(port) query (id)testpmd example
===configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 rss queues 1 2 end / endcreate flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 rss queues 1 2 3 4 end / endQuoted 7 lines
Quoted 3 lines
testpmd is out-of-scope of the patch and it is better to remove the description to avoid unsync if testpmd commands are changed.
There is still added value is testpmd example demonstrating usage of shared action with rte flows. I will update the example to reflect the current testpmd syntax for shared action.
Yes and no. IMHO It would be OK for series description etc, but not OK for the changeset description which will be kept in the history and will become misleading when commands are changed. I think that no information is better than potentially wrong information.
[snip]
Quoted 16 lines
Quoted 15 lines
Review
Quoted 1 line
(quoted diff) +0
-0b/lib/librte_ethdev/rte_ethdev_version.map
lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 235
Quoted 11 lines
index
c95ef5157a..a8a4821dbb100644lib/librte_ethdev/rte_ethdev_version.map +4
-0@@ -229,6 +229,10 @@ EXPERIMENTAL { # added in 20.11 rte_eth_link_speed_to_str; rte_eth_link_to_str; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_update; + rte_flow_shared_action_query;Shouldn't it be alphabetically sorted?
Quoted 1 line
Query before update?
yes
[snip]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +0
-0[snip]
Quoted 47 lines
Quoted 38 lines
Quoted 38 lines
lib/librte_ethdev/rte_flow.h +34
-0@@ -3357,6 +3380,150 @@ int rte_flow_get_aged_flows(uint16_t port_id, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error); +/** +* Specify shared action configuration +*/ +struct rte_flow_shared_action_conf { +/** +* Flow direction for shared action configuration. +* +* Shred action should be valid at least for one flow direction, +* otherwise it is invalid for both ingress and egress rules. +*/ +uint32_t ingress:1 ; +/**< Action valid for rules applied to ingress traffic. */ +uint32_t egress:1 ; +/**< Action valid for rules applied to egress traffic. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Create shared action for reuse in multiple flow rules. +* The created shared action has single state and configuration +* across all flow rules using it. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] conf +* Shared action configuration. +* @param[in] action +* Action configuration for shared action creation. +* @param[out] error +* Perform verbose error reporting if not NULL. PMDs initialize this +* structure in case of error only. +* @return Quoted 8 lines
lib/librte_ethdev/rte_flow.h int · line 3422
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* A valid handle in case of success, NULL otherwise and rte_errno is set +* to one of the error codes defined: +* - (ENOSYS) if underlying device does not support this functionality. +* - (EIO) if underlying device is removed. +* - (EINVAL) if *action* invalid. +* - (ENOTSUP) if *action* valid but unsupported. ENODEV ?
Quoted 1 line
Can you elaborate?
ENODEV is returned if
port_idis invalid and it should be documented here if you try to list all return values.
PATCH v7 2/2 app/testpmd: support shared action
In reply to Andrey VesnovatyThis patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flow shared_action {port_id} create [action_id {shared_action_id}]
[ingress] [egress] action {action} / end
Create shared action examples:
flow shared_action 0 create action_id 100 \
ingress action rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.
flow shared_action 0 create action_id \
ingress action rss queues 0 1 end / end
This creates shared rss action with id assigned by testpmd on port 0.
Update shared action syntax:
flow shared_action {port_id} update {shared_action_id}
action {action} / end
Update shared action example:
flow shared_action 0 update 100 \
action rss queues 0 3 end / end
This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).
Destroy shared action syntax:
flow shared_action {port_id} destroy action_id {shared_action_id} [...]
Destroy shared action example:
flow shared_action 0 destroy action_id 100 action_id 101 This destroys shared actions having id 100 & 101
Query shared action syntax:
flow shared_action {port} query {shared_action_id}
Query shared action example:
flow shared_action 0 query 100
This queries shared actions having id 100
Use shared action as flow action syntax:
flow create {port_id} ... / end actions [action / [...]]
shared {action_id} / [action / [...]] endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \ actions shared 100 / end This creates flow rule where rss action is shared rss action having id 100.
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
--- app/test-pmd/cmdline.c | 18 ++ app/test-pmd/cmdline_flow.c | 294 +++++++++++++++++++- app/test-pmd/config.c | 216 ++++++++++++++ app/test-pmd/testpmd.h | 20 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 112 ++++++++ 5 files changed, 659 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +18 -0
@@ -1143,6 +1143,24 @@ static void cmd_help_long_parsed(void *parsed_result," List and destroy aged flows" " flow rules\n\n" +"flow shared_action {port_id} create" +" [action_id {shared_action_id}]" +" [ingress] [egress]" +" action {action} / end\n" +" Create shared action.\n\n" + +"flow shared_action {port_id} update" +" {shared_action_id} action {action} / end\n" +" Update shared action.\n\n" + +"flow shared_action {port_id} destroy" +" action_id {shared_action_id} [...]\n" +" Destroy specific shared actions.\n\n" + +"flow shared_action {port_id} query" +" {shared_action_id}\n" +" Query an existing shared action.\n\n" +"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
app/test-pmd/cmdline_flow.c +293 -1
391 lines not on this page · raw message
app/test-pmd/config.c +216 -0
222 lines not on this page · raw message
app/test-pmd/testpmd.h +20 -0
@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */
@@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */
@@ -748,6 +758,15 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
@@ -756,6 +775,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +112 -0
124 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v7 2/2] app/testpmd: support shared action
Quoted 57 lines · Andrey Vesnovaty
This patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flowshared_action{port_id} create [action_id{shared_action_id}]
[ingress] [egress] action {action} / endCreate shared action examples:
flowshared_action0 createaction_id100 \
ingress action rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.flow
shared_action0 createaction_id\
ingress action rss queues 0 1 end / end
This creates shared rss action with id assigned by testpmd on port 0.Update shared action syntax:
flowshared_action{port_id} update {shared_action_id}
action {action} / endUpdate shared action example:
flowshared_action0 update 100 \
action rss queues 0 3 end / end
This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).Destroy shared action syntax:
flowshared_action{port_id} destroyaction_id{shared_action_id} [...]Destroy shared action example:
flowshared_action0 destroyaction_id100action_id101 This destroys shared actions having id 100 & 101Query shared action syntax:
flowshared_action{port} query {shared_action_id}Query shared action example:
flowshared_action0 query 100
This queries shared actions having id 100Use shared action as flow action syntax:
flow create {port_id} ... / end actions [action / [...]]shared {action_id} / [action / [...]] endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \
actions shared 100 / end
This creates flow rule where rss action is shared rss action having id 100.
Quoted 5 lines
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>
Quoted 859 lines
--- app/test-pmd/cmdline.c | 18 ++ app/test-pmd/cmdline_flow.c | 294 +++++++++++++++++++- app/test-pmd/config.c | 216 ++++++++++++++ app/test-pmd/testpmd.h | 20 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 112 ++++++++ 5 files changed, 659 insertions(+), 1 deletion(-)app/test-pmd/cmdline.c +18
-0@@ -1143,6 +1143,24 @@ static void cmd_help_long_parsed(void *parsed_result," List and destroy aged flows" " flow rules\n\n" +"flow shared_action {port_id} create" +" [action_id {shared_action_id}]" +" [ingress] [egress]" +" action {action} / end\n" +" Create shared action.\n\n" + +"flow shared_action {port_id} update" +" {shared_action_id} action {action} / end\n" +" Update shared action.\n\n" + +"flow shared_action {port_id} destroy" +" action_id {shared_action_id} [...]\n" +" Destroy specific shared actions.\n\n" + +"flow shared_action {port_id} query" +" {shared_action_id}\n" +" Query an existing shared action.\n\n" +"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" app/test-pmd/cmdline_flow.c +293
-1@@ -49,6 +49,7 @@ enum index {PORT_ID ,GROUP_ID ,PRIORITY_LEVEL , +SHARED_ACTION_ID ,/* Top-level command. */ SET,@@ -60,6 +61,7 @@ enum index {/* Top-level command. */ FLOW ,/* Sub-level commands. */ +SHARED_ACTION ,VALIDATE ,CREATE , DESTROY,@@ -89,6 +91,21 @@ enum index {EGRESS ,TRANSFER , +/* Shared action arguments */ +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , + +/* Shared action create arguments */ +SHARED_ACTION_CREATE_ID , +SHARED_ACTION_INGRESS , +SHARED_ACTION_EGRESS , +SHARED_ACTION_SPEC , + +/* Shared action destroy arguments */ +SHARED_ACTION_DESTROY_ID , +/* Validate/create pattern. */ PATTERN , ITEM_PARAM_IS,@@ -360,6 +377,8 @@ enum index {ACTION_SET_IPV6_DSCP_VALUE ,ACTION_AGE ,ACTION_AGE_TIMEOUT , +ACTION_SHARED , + SHARED_ACTION_ID2PTR, };/** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -653,6 +672,13 @@ struct buffer {enum index command;/**< Flow command. */ portid_t port;/**< Affected port ID. */ union { +struct { +uint32_t *action_id; +uint32_t action_id_n; + } sa_destroy;/**< Shared action destroy arguments. */ +struct { +uint32_t action_id; + } sa;/* Shared action query arguments */ struct {struct rte_flow_attr attr;struct rte_flow_item *pattern;@@ -709,6 +735,22 @@ struct parse_action_priv { .size = s, \ }) +static const enum index next_sa_create_attr[] = { +SHARED_ACTION_CREATE_ID , +SHARED_ACTION_INGRESS , +SHARED_ACTION_EGRESS , +SHARED_ACTION_SPEC , +ZERO , +}; + +static const enum index next_sa_subcmd[] = { +SHARED_ACTION_CREATE , +SHARED_ACTION_UPDATE , +SHARED_ACTION_DESTROY , +SHARED_ACTION_QUERY , +ZERO , +}; +static const enum index next_vc_attr[] = {GROUP ,PRIORITY ,@@ -743,6 +785,12 @@ static const enum index next_aged_attr[] = { ZERO, }; +static const enum index next_sa_destroy_attr[] = { +SHARED_ACTION_DESTROY_ID , +END , +ZERO , +}; +static const enum index item_param[] = {ITEM_PARAM_IS ,ITEM_PARAM_SPEC ,@@ -1193,6 +1241,7 @@ static const enum index next_action[] = {ACTION_SET_IPV4_DSCP ,ACTION_SET_IPV6_DSCP ,ACTION_AGE , +ACTION_SHARED , ZERO, };@@ -1550,6 +1599,15 @@ static int parse_ipv6_addr(struct context *, const struct token *,static int parse_port (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_sa (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size); +static int parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size);static int comp_none (struct context *,const struct token *,unsigned int ,char *,unsigned int ); static int comp_boolean(struct context *, const struct token *,@@ -1688,13 +1746,21 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_none, }, + [SHARED_ACTION_ID] = { + .name = "{shared_action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .call = parse_int, + .comp = comp_none, + },/* Top-level command. */ [FLOW] = { .name = "flow", .type = "{command} {port_id} [{arg} [...]]", .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY - (VALIDATE, + (SHARED_ACTION, + VALIDATE, CREATE, DESTROY, FLUSH,@@ -1705,7 +1771,44 @@ static const struct token token_list[] = { ISOLATE)), .call = parse_init, }, +/* Top-level command. */ + [SHARED_ACTION] = { + .name = "shared_action", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage shared actions", + .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa, + },/* Sub-level commands. */ + [SHARED_ACTION_CREATE] = { + .name = "create", + .help = "create shared action", + .next = NEXT(next_sa_create_attr), + .call = parse_sa, + }, + [SHARED_ACTION_UPDATE] = { + .name = "update", + .help = "update shared action", + .next =NEXT (NEXT_ENTRY (SHARED_ACTION_SPEC ), + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + .call = parse_sa, + }, + [SHARED_ACTION_DESTROY] = { + .name = "destroy", + .help = "destroy shared action", + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_sa_destroy, + }, + [SHARED_ACTION_QUERY] = { + .name = "query", + .help = "query shared action", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)), + .call = parse_sa, + }, [VALIDATE] = { .name = "validate", .help = "check whether a flow rule can be created",@@ -3859,6 +3962,57 @@ static const struct token token_list[] = { .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)), .call = parse_vc_conf, }, +/* Shared action destroy arguments. */ + [SHARED_ACTION_DESTROY_ID] = { + .name = "action_id", + .help = "specify a shared action id to destroy", + .next =NEXT (next_sa_destroy_attr, + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.sa_destroy.action_id)), + .call = parse_sa_destroy, + }, +/* Shared action create arguments. */ + [SHARED_ACTION_CREATE_ID] = { + .name = "action_id", + .help = "specify a shared action id to create", + .next =NEXT (next_sa_create_attr, + NEXT_ENTRY(SHARED_ACTION_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)), + }, + [ACTION_SHARED] = { + .name = "shared", + .help = "apply shared action by id", + .priv = PRIV_ACTION(SHARED, 0), + .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + .call = parse_vc, + }, + [SHARED_ACTION_ID2PTR] = { + .name = "{action_id}", + .type = "SHARED_ACTION_ID", + .help = "shared action id", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_sa_id2ptr, + .comp = comp_none, + }, + [SHARED_ACTION_INGRESS] = { + .name = "ingress", + .help = "affect rule to ingress", + .next = NEXT(next_sa_create_attr), + .call = parse_sa, + }, + [SHARED_ACTION_EGRESS] = { + .name = "egress", + .help = "affect rule to egress", + .next = NEXT(next_sa_create_attr), + .call = parse_sa, + }, + [SHARED_ACTION_SPEC] = { + .name = "action", + .help = "specify action to share", + .next = NEXT(next_action), + }, };/** Remove and return last entry from argument stack. */ @@ -4043,6 +4197,97 @@ parse_init(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for shared action commands. */ +static int +parse_sa (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=SHARED_ACTION ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case SHARED_ACTION_CREATE : +case SHARED_ACTION_UPDATE : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.attr.group =UINT32_MAX ; +/* fallthrough */ +case SHARED_ACTION_QUERY : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case SHARED_ACTION_EGRESS : + out->args.vc.attr.egress =1 ; +return len; +case SHARED_ACTION_INGRESS : + out->args.vc.attr.ingress =1 ; +return len; +default : +return -1 ; + } +} + + +/** Parse tokens for shared action destroy command. */ +static int +parse_sa_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *action_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==SHARED_ACTION ) { +if (ctx->curr !=SHARED_ACTION_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.sa_destroy.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + action_id = out->args.sa_destroy.action_id + + out->args.sa_destroy.action_id_n++; +if ((uint8_t *)action_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = action_id; + ctx->objmask =NULL ; +return len; +} +/** Parse tokens for validate/create commands. */ static int parse_vc(struct context *ctx, const struct token *token,@@ -6110,6 +6355,32 @@ parse_port(struct context *ctx, const struct token *token,return ret; } +static int +parse_sa_id2ptr (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct rte_flow_action *action = ctx->object; +uint32_t id; +int ret; + + (void )buf; + (void )size; + ctx->objdata =0 ; + ctx->object = &id; + ctx->objmask =NULL ; + ret =parse_int (ctx, token, str, len, ctx->object,sizeof (id)); + ctx->object = action; +if (ret != (int )len) +return ret; +/* set shared action */ +if (action) { + action->conf =port_shared_action_get_by_id (ctx->port, id); + ret = (action->conf) ? ret :-1 ; + } +return ret; +} +/** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token,@@ -6559,6 +6830,27 @@ static void cmd_flow_parsed(const struct buffer *in) {switch (in->command) { +case SHARED_ACTION_CREATE : +port_shared_action_create ( + in->port, in->args.vc.attr.group, + &((const struct rte_flow_shared_action_conf ) { + .ingress = in->args.vc.attr.ingress, + .egress = in->args.vc.attr.egress, + }), + in->args.vc.actions); +break ; +case SHARED_ACTION_DESTROY : +port_shared_action_destroy (in->port, + in->args.sa_destroy.action_id_n, + in->args.sa_destroy.action_id); +break ; +case SHARED_ACTION_UPDATE : +port_shared_action_update (in->port, in->args.vc.attr.group, + in->args.vc.actions); +break ; +case SHARED_ACTION_QUERY : +port_shared_action_query (in->port, in->args.sa.action_id); +break ;case VALIDATE :port_flow_validate (in->port, &in->args.vc.attr, in->args.vc.pattern, in->args.vc.actions);app/test-pmd/config.c +216
-0@@ -1580,6 +1580,222 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) } } +static struct port_shared_action * +action_get_by_id (portid_t port_id,uint32_t id) +{ +struct rte_port *port; +struct port_shared_action **ppsa; +struct port_shared_action *psa =NULL ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return NULL ; + port = &ports[port_id]; + ppsa = &port->actions_list; +while (*ppsa) { +if ((*ppsa)->id == id) { + psa = *ppsa; +break ; + } + ppsa = &(*ppsa)->next; + } +if (!psa) +printf ("Failed to find shared action #%u on port %u\n" , + id, port_id); +return psa; +} + +static int +action_alloc (portid_t port_id,uint32_t id, +struct port_shared_action **action) +{ +struct rte_port *port; +struct port_shared_action **ppsa; +struct port_shared_action *psa =NULL ; + + *action =NULL ; +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; +if (id ==UINT32_MAX ) { +/* taking first available ID */ +if (port->actions_list) { +if (port->actions_list->id ==UINT32_MAX -1 ) { +printf ("Highest shared action ID is already" +" assigned, delete it first\n" ); +return -ENOMEM ; + } + id = port->actions_list->id +1 ; + }else { + id =0 ; + } + } + psa =calloc (1 ,sizeof (*psa)); +if (!psa) { +printf ("Allocation of port %u shared action failed\n" , + port_id); +return -ENOMEM ; + } + ppsa = &port->actions_list; +while (*ppsa && (*ppsa)->id > id) + ppsa = &(*ppsa)->next; +if (*ppsa && (*ppsa)->id == id) { +printf ("Shared action #%u is already assigned," +" delete it first\n" , id); +free (psa); +return -EINVAL ; + } + psa->next = *ppsa; + psa->id = id; + *ppsa = psa; + *action = psa; +return 0 ; +} + +/** Create shared action */ +int +port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action) +{ +struct port_shared_action *psa; +int ret; +struct rte_flow_error error; + + ret =action_alloc (port_id, id, &psa); +if (ret) +return ret; +/* Poisoning to make sure PMDs update it in case of error. */ +memset (&error,0x22 ,sizeof (error)); + psa->action =rte_flow_shared_action_create (port_id, conf, action, + &error); +if (!psa->action) { +uint32_t destroy_id = psa->id; +port_shared_action_destroy (port_id,1 , &destroy_id); +return port_flow_complain (&error); + } + psa->type = action->type; +printf ("Shared action #%u created\n" , psa->id); +return 0 ; +} + +/** Destroy shared action */ +int +port_shared_action_destroy (portid_t port_id, +uint32_t n, +const uint32_t *actions) +{ +struct rte_port *port; +struct port_shared_action **tmp; +uint32_t c =0 ; +int ret =0 ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + tmp = &port->actions_list; +while (*tmp) { +uint32_t i; + +for (i =0 ; i != n; ++i) { +struct rte_flow_error error; +struct port_shared_action *psa = *tmp; + +if (actions[i] != psa->id) +continue ; +/* +* Poisoning to make sure PMDs update it in case +* of error. +*/ +memset (&error,0x33 ,sizeof (error)); + +if (psa->action &&rte_flow_shared_action_destroy ( + port_id, psa->action, &error)) { + ret =port_flow_complain (&error); +continue ; + } + *tmp = psa->next; +free (psa); +printf ("Shared action #%u destroyed\n" , psa->id); +break ; + } +if (i == n) + tmp = &(*tmp)->next; + ++c; + } +return ret; +} + + +/** Get shared action by port + id */ +struct rte_flow_shared_action * +port_shared_action_get_by_id (portid_t port_id,uint32_t id) +{ + +struct port_shared_action *psa =action_get_by_id (port_id, id); + +return (psa) ? psa->action :NULL ; +} + +/** Update shared action */ +int +port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action) +{ +struct rte_flow_error error; +struct rte_flow_shared_action *shared_action; + + shared_action =port_shared_action_get_by_id (port_id, id); +if (!shared_action) +return -EINVAL ; +if (rte_flow_shared_action_update (port_id, shared_action, action, + &error)) { +return port_flow_complain (&error); + } +printf ("Shared action #%u updated\n" , id); +return 0 ; +} + +int +port_shared_action_query (portid_t port_id,uint32_t id) +{ +struct rte_flow_error error; +struct port_shared_action *psa; +uint64_t default_data; +void *data =NULL ; +int ret =0 ; + + psa =action_get_by_id (port_id, id); +if (!psa) +return -EINVAL ; +switch (psa->type) { +case RTE_FLOW_ACTION_TYPE_RSS : + data = &default_data; +break ; +default : +printf ("Shared action %u (type: %d) on port %u doesn't support" +" query\n" , id, psa->type, port_id); +return -1 ; + } +if (rte_flow_shared_action_query (port_id, psa->action, data, &error)) + ret =port_flow_complain (&error); +switch (psa->type) { +case RTE_FLOW_ACTION_TYPE_RSS : +if (!ret) +printf ("Shared RSS action:\n\trefs:%u\n" , + *((uint32_t *)data)); + data =NULL ; +break ; +default : +printf ("Shared action %u (type: %d) on port %u doesn't support" +" query\n" , id, psa->type, port_id); + ret =-1 ; + } +return ret; +} +/** Validate flow rule. */ int port_flow_validate(portid_t port_id,app/test-pmd/testpmd.h +20
-0@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */ @@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */ @@ -748,6 +758,15 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,@@ -756,6 +775,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);doc/guides/testpmd_app_ug/testpmd_funcs.rst +112
-1@@ -4382,6 +4382,11 @@ This section lists supported actions and their attributes, if any. - ``dscp_value {unsigned}``: The new DSCP value to be set +- ``shared``: Use shared action created via + ``flow shared_action {port_id} create`` + + - ``shared_action_id {unsigned}``: Shared action ID to use + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~@@ -4671,6 +4676,113 @@ If attach ``destroy`` parameter, the command will destroy all the list aged flow testpmd> flow aged 0 Port 0 total aged flows: 0 +Creating shared actions +~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} create`` creates shared action with optional +shared action ID. It is bound to ``rte_flow_shared_action_create()``:: + + flow shared_action {port_id} create [action_id {shared_action_id}] + [ingress] [egress] action {action} / end + +If successful, it will show:: + + Shared action #[...] created + +Otherwise, it will complain either that shared action already exists or that +some error occurred:: + + Shared action #[...] is already assigned, delete it first + +:: + + Caught error type [...] ([...]): [...] + +Create shared rss action with id 100 to queues 1 and 2 on port 0:: + + testpmd> flow shared_action 0 create action_id 100 \ + ingress action rss queues 1 2 end / end + +Create shared rss action with id assigned by testpmd to queues 1 and 2 on +port 0:: + + testpmd> flow shared_action 0 create action_id \ + ingress action rss queues 0 1 end / end + +Updating shared actions +~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} update`` updates configuration of the shared +action from its shared action ID (as returned by +``flow shared_action {port_id} create``). It is bound to +``rte_flow_shared_action_update()``:: + + flow shared_action {port_id} update {shared_action_id} + action {action} / end + +If successful, it will show:: + + Shared action #[...] updated + +Otherwise, it will complain either that shared action not found or that some +error occurred:: + + Failed to find shared action #[...] on port [...] + +:: + + Caught error type [...] ([...]): [...] + +Update shared rss action having id 100 on port 0 with rss to queues 0 and 3 +(in create example above rss queues were 1 and 2):: + + testpmd> flow shared_action 0 update 100 action rss queues 0 3 end / end + +Destroying shared actions +~~~~~~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} update`` destroys one or more shared actions +from their shared action IDs (as returned by +``flow shared_action {port_id} create``). It is bound to +``rte_flow_shared_action_destroy()``:: + + flow shared_action {port_id} destroy action_id {shared_action_id} [...] + +If successful, it will show:: + + Shared action #[...] destroyed + +It does not report anything for shared action IDs that do not exist. +The usual error message is shown when a shared action cannot be destroyed:: + + Caught error type [...] ([...]): [...] + +Destroy shared actions having id 100 & 101:: + + testpmd> flow shared_action 0 destroy action_id 100 action_id 101 + +Query shared actions +~~~~~~~~~~~~~~~~~~~~ +``flow shared_action {port_id} query`` queries the shared action from its +shared action ID (as returned by ``flow shared_action {port_id} create``). +It is bound to ``rte_flow_shared_action_query()``:: + + flow shared_action {port_id} query {shared_action_id} + +Currently only rss shared action supported. If successful, it will show:: + + Shared RSS action: + refs:[...] + +Otherwise, it will complain either that shared action not found or that some +error occurred:: + + Failed to find shared action #[...] on port [...] + +:: + + Caught error type [...] ([...]): [...] + +Query shared action having id 100:: + + testpmd> flow shared_action 0 query 100 Sample QinQ flow rules ~~~~~~~~~~~~~~~~~~~~~~ --2.26.2
v8 cover RTE flow shared action
In reply to Andrey VesnovatyThis patchset introduces shared action API for RTE flow.
v8 changes:
* misc spelling fixes and rephrase in commit messages and documentation
* RTE flow shared action API:
* invalid port error documented
* invalid port handling
* code readability improvements
* testpmd example moved from commit message to below
testpmd: shared action usage
In this section testpmd command syntax should be treated as pseudo-code, may be out of sync with future testpmd syntax for shared action cli. In order to utilize introduced API testpmd cli may implement following extension
create/update/destroy/query shared action accordingly
flow shared_action {port} create [action_id {id}]
[ingress] [egress] action {action} / end
flow shared_action {port} update {id} action {action} / end flow shared_action {port} destroy action_id {id} [...] flow shared_action {port} query {id}
testpmd example:
configure rss to queues 1 & 2
Quoted 1 line
flow
shared_action0 createaction_id100 \
ingress action rss queues 1 2 end / end
create flow rule utilizing shared action
Quoted 1 line
flow create 0 ingress \
pattern eth dst is 0c:42:a1:15:fd:ac / ipv6 / tcp / end \
actions shared 100 / end
add 2 more queues
Quoted 1 line
flow
shared_action0 modify 100 action rss queues 1 2 3 4 end / end
Andrey Vesnovaty (2):
ethdev: add shared actions to flow API
app/testpmd: support shared action
app/test-pmd/cmdline.c | 18 ++ app/test-pmd/cmdline_flow.c | 294 +++++++++++++++++++- app/test-pmd/config.c | 216 ++++++++++++++ app/test-pmd/testpmd.h | 20 ++ doc/guides/prog_guide/rte_flow.rst | 19 ++ doc/guides/rel_notes/release_20_11.rst | 10 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 112 ++++++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 90 ++++++ lib/librte_ethdev/rte_flow.h | 172 +++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 ++ 11 files changed, 976 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH v8 1/2 ethdev: add shared actions to flow API
Introduce extension of flow action API enabling sharing of single rte_flow_action in multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.
Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- call rte_flow_destroy()
- call rte_flow_create() with modified RSS action
API for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flows
Change description
===
Shared action
===
In order to represent flow action shared by multiple flows new action type RTE_FLOW_ACTION_TYPE_SHARED is introduced (see enum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.
Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (see rte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (see rte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.
In order to share some flow action reuse the handle of type struct rte_flow_shared_action returned by rte_flow_shared_action_create() as a conf field of struct rte_flow_action (see "example" section).
If some shared action not used by any flow rule all resources allocated by the shared action can be released by rte_flow_shared_action_destroy() (see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.
Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated via rte_flow_shared_action_update() (see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.
Shared action query
===
Provide separate API to query shared action state (see rte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled by rte_flow_shared_action_create() and rte_flow_shared_action_update() APIs and no supposed to change by other means.
example
===
struct rte_flow_action actions[2];
struct rte_flow_shared_action_conf conf;
struct rte_flow_action action;
/* skipped: initialize conf and action */
struct rte_flow_shared_action *handle =
rte_flow_shared_action_create(port_id, &conf, &action, &error);
actions[0].type = RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type = RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
struct rte_flow *flow0 = rte_flow_create(port_id, &attr0, pattern0,
actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);
/* update shared action */
struct rte_flow_action updated_action;
/*
* skipped: initialize updated_action according to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
* updated_action
*/
/* skipped: destroy all flows 1 till N */ rte_flow_shared_action_destroy(port_id, handle, error);
--- doc/guides/prog_guide/rte_flow.rst | 19 +++ doc/guides/rel_notes/release_20_11.rst | 10 ++ lib/librte_ethdev/rte_ethdev_version.map | 4 + lib/librte_ethdev/rte_flow.c | 90 ++++++++++++ lib/librte_ethdev/rte_flow.h | 172 ++++++++++++++++++++++- lib/librte_ethdev/rte_flow_driver.h | 23 +++ 6 files changed, 317 insertions(+), 1 deletion(-)
doc/guides/prog_guide/rte_flow.rst +19 -0
@@ -2666,6 +2666,25 @@ timeout passed without any matching on the flow. | ``context`` | user input flow context | +--------------+---------------------------------+ +Action: ``SHARED`` +^^^^^^^^^^^^^^^^^^ + +Flow utilize shared action by handle as returned from +``rte_flow_shared_action_create()``. + +The behaviour of the shared action defined by ``action`` argument of type +``struct rte_flow_action`` passed to ``rte_flow_shared_action_create()``. + +.. _table_rte_flow_shared_action: + +.. table:: SHARED + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_20_11.rst +10 -0
@@ -148,6 +148,16 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Added ethdev API to support shared action for RTE flow.** + + Added shared action support to utilize single flow action in multiple flow + rules. An update of shared action configuration alters the behavior of all + flow rules using it. + + * Added new action: ``RTE_FLOW_ACTION_TYPE_SHARED`` to use shared action + as flow action. + * Added new flow APIs to create/update/destroy/query shared action. + Removed Items -------------
lib/librte_ethdev/rte_ethdev_version.map +4 -0
@@ -232,6 +232,10 @@ EXPERIMENTAL { rte_eth_fec_get_capability; rte_eth_fec_get; rte_eth_fec_set; + rte_flow_shared_action_create; + rte_flow_shared_action_destroy; + rte_flow_shared_action_query; + rte_flow_shared_action_update; }; INTERNAL {
lib/librte_ethdev/rte_flow.c +90 -0
99 lines not on this page · raw message
lib/librte_ethdev/rte_flow.h +171 -1
196 lines not on this page · raw message
lib/librte_ethdev/rte_flow_driver.h +23 -0
@@ -108,6 +108,29 @@ struct rte_flow_ops {void **context, uint32_t nb_contexts, struct rte_flow_error *err); +/** See rte_flow_shared_action_create() */ +struct rte_flow_shared_action *(*shared_action_create) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_destroy() */ +int (*shared_action_destroy) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +struct rte_flow_error *error); +/** See rte_flow_shared_action_update() */ +int (*shared_action_update) + (struct rte_eth_dev *dev, +struct rte_flow_shared_action *shared_action, +const struct rte_flow_action *update, +struct rte_flow_error *error); +/** See rte_flow_shared_action_query() */ +int (*shared_action_query) + (struct rte_eth_dev *dev, +const struct rte_flow_shared_action *shared_action, +void *data, +struct rte_flow_error *error); };/**
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH v8 1/2] ethdev: add shared actions to flow API
Quoted 111 lines · Andrey Vesnovaty
Introduce extension of flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.example
===struct
rte_flow_actionactions[2];
structrte_flow_shared_action_confconf;
structrte_flow_actionaction;
/* skipped: initialize conf and action */
structrte_flow_shared_action*handle =rte_flow_shared_action_create(port_id, &conf, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);
Quoted 3 lines
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Ajit Khaparde <[email protected]>
Re: [dpdk-dev] [PATCH v8 1/2] ethdev: add shared actions to flow API
Quoted 112 lines · Andrew Rybchenko
Quoted 111 lines · Andrey Vesnovaty
Introduce extension of flow action API enabling sharing of single
rte_flow_actionin multiple flows. The API intended for PMDs, where multiple HW offloaded flows can reuse the same HW essence/object representing flow action and modification of such an essence/object affects all the rules using it.Motivation and example
===
Adding or removing one or more queues to RSS used by multiple flow rules imposes per rule toll for current DPDK flow API; the scenario requires for each flow sharing cloned RSS action:
- callrte_flow_destroy()
- callrte_flow_create()with modified RSS actionAPI for sharing action and its in-place update benefits:
- reduce the overhead of multiple RSS flow rules reconfiguration
- optimize resource utilization by sharing action across multiple flowsChange description
===Shared action
===
In order to represent flow action shared by multiple flows new action typeRTE_FLOW_ACTION_TYPE_SHAREDis introduced (seeenum rte_flow_action_type).
Actually the introduced API decouples action from any specific flow and enables sharing of single action by its handle across multiple flows.Shared action create/use/destroy
===
Shared action may be reused by some or none flow rules at any given moment, i.e. shared action resides outside of the context of any flow. Shared action represent HW resources/objects used for action offloading implementation.
API for shared action create (seerte_flow_shared_action_create()):
- should allocate HW resources and make related initializations required for shared action implementation.
- make necessary preparations to maintain shared access to the action resources, configuration and state.
API for shared action destroy (seerte_flow_shared_action_destroy()) should release HW resources and make related cleanups required for shared action implementation.In order to share some flow action reuse the handle of type
struct rte_flow_shared_actionreturned byrte_flow_shared_action_create()as aconffield ofstruct rte_flow_action(see "example" section).If some shared action not used by any flow rule all resources allocated by the shared action can be released by
rte_flow_shared_action_destroy()(see "example" section). The shared action handle passed as argument to destroy API should not be used any further i.e. result of the usage is undefined.Shared action re-configuration
===
Shared action behavior defined by its configuration can be updated viarte_flow_shared_action_update()(see "example" section). The shared action update operation modifies HW related resources/objects allocated on the action creation. The number of operations performed by the update operation should not depend on the number of flows sharing the related action. On return of shared action update API action behavior should be according to updated configuration for all flows sharing the action.Shared action query
===
Provide separate API to query shared action state (seerte_flow_shared_action_update()). Taking a counter as an example: query returns value aggregating all counter increments across all flow rules sharing the counter. This API doesn't query shared action configuration since it is controlled byrte_flow_shared_action_create()andrte_flow_shared_action_update()APIs and no supposed to change by other means.example
===struct
rte_flow_actionactions[2];
structrte_flow_shared_action_confconf;
structrte_flow_actionaction;
/* skipped: initialize conf and action */
structrte_flow_shared_action*handle =rte_flow_shared_action_create(port_id, &conf, &action, &error);actions[0].type =
RTE_FLOW_ACTION_TYPE_SHARED; actions[0].conf = handle;
actions[1].type =RTE_FLOW_ACTION_TYPE_END;
/* skipped: init attr0 & pattern0 args */
structrte_flow*flow0 = rte_flow_create(port_id, &attr0, pattern0,actions, error); /* create more rules reusing shared action */ struct rte_flow *flow1 = rte_flow_create(port_id, &attr1, pattern1, actions, error); /* skipped: for flows 2 till N */ struct rte_flow *flowN = rte_flow_create(port_id, &attrN, patternN, actions, error);/* update shared action */
structrte_flow_actionupdated_action;
/*
* skipped: initializeupdated_actionaccording to desired action
* configuration change
*/rte_flow_shared_action_update(port_id, handle, &updated_action, error); /*
* from now on all flows 1 till N will act according to configuration of
*updated_action
*/
/* skipped: destroy all flows 1 till N */rte_flow_shared_action_destroy(port_id, handle, error);
Quoted 6 lines
Quoted 3 lines
Signed-off-by Andrey Vesnovaty <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Ajit Khaparde <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Series applied to dpdk-next-net/main, thanks.
PATCH v8 2/2 app/testpmd: support shared action
In reply to Andrey VesnovatyThis patch adds shared action support to testpmd CLI.
All shared actions created via testpmd CLI assigned ID for further reference in other CLI commands. Shared action ID supplied as CLI argument or assigned by testpmd is similar to flow ID & limited to scope of testpdm CLI.
Create shared action syntax:
flow shared_action {port_id} create [action_id {shared_action_id}]
[ingress] [egress] action {action} / end
Create shared action examples:
flow shared_action 0 create action_id 100 \
ingress action rss queues 1 2 end / end
This creates shared rss action with id 100 on port 0.
flow shared_action 0 create action_id \
ingress action rss queues 0 1 end / end
This creates shared rss action with id assigned by testpmd on port 0.
Update shared action syntax:
flow shared_action {port_id} update {shared_action_id}
action {action} / end
Update shared action example:
flow shared_action 0 update 100 \
action rss queues 0 3 end / end
This updates shared rss action having id 100 on port 0 with rss to queues 0 3 (in create example rss queues were 1 & 2).
Destroy shared action syntax:
flow shared_action {port_id} destroy action_id {shared_action_id} [...]
Destroy shared action example:
flow shared_action 0 destroy action_id 100 action_id 101 This destroys shared actions having id 100 & 101
Query shared action syntax:
flow shared_action {port} query {shared_action_id}
Query shared action example:
flow shared_action 0 query 100
This queries shared actions having id 100
Use shared action as flow action syntax:
flow create {port_id} ... / end actions [action / [...]]
shared {action_id} / [action / [...]] endUse shared action as flow action example:
flow create 0 ingress pattern ... / end \ actions shared 100 / end This creates flow rule where rss action is shared rss action having id 100.
All shared action CLIs report status of the command. Shared action query CLI output depends on action type.
--- app/test-pmd/cmdline.c | 18 ++ app/test-pmd/cmdline_flow.c | 294 +++++++++++++++++++- app/test-pmd/config.c | 216 ++++++++++++++ app/test-pmd/testpmd.h | 20 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 112 ++++++++ 5 files changed, 659 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +18 -0
@@ -1152,6 +1152,24 @@ static void cmd_help_long_parsed(void *parsed_result," List and destroy aged flows" " flow rules\n\n" +"flow shared_action {port_id} create" +" [action_id {shared_action_id}]" +" [ingress] [egress]" +" action {action} / end\n" +" Create shared action.\n\n" + +"flow shared_action {port_id} update" +" {shared_action_id} action {action} / end\n" +" Update shared action.\n\n" + +"flow shared_action {port_id} destroy" +" action_id {shared_action_id} [...]\n" +" Destroy specific shared actions.\n\n" + +"flow shared_action {port_id} query" +" {shared_action_id}\n" +" Query an existing shared action.\n\n" +"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
app/test-pmd/cmdline_flow.c +293 -1
391 lines not on this page · raw message
app/test-pmd/config.c +216 -0
222 lines not on this page · raw message
app/test-pmd/testpmd.h +20 -0
@@ -142,6 +142,14 @@ struct port_flow {uint8_t data[];/**< Storage for flow rule description */ }; +/* Descriptor for shared action */ +struct port_shared_action { +struct port_shared_action *next;/**< Next flow in list. */ +uint32_t id;/**< Shared action ID. */ +enum rte_flow_action_type type;/**< Action type. */ +struct rte_flow_shared_action *action;/**< Shared action handle. */ +}; +/** * The data structure associated with each port. */
@@ -172,6 +180,8 @@ struct rte_port {uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag;/**< bonding slave port */ struct port_flow *flow_list;/**< Associated flows. */ +struct port_shared_action *actions_list; +/**< Associated shared actions. */ const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT +1 ];/**< metadata value to insert in Tx packets. */
@@ -749,6 +759,15 @@ void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);void port_reg_display (portid_t port_id,uint32_t reg_off);void port_reg_set (portid_t port_id,uint32_t reg_off,uint32_t value); +int port_shared_action_create (portid_t port_id,uint32_t id, +const struct rte_flow_shared_action_conf *conf, +const struct rte_flow_action *action); +int port_shared_action_destroy (portid_t port_id, +uint32_t n,const uint32_t *action); +struct rte_flow_shared_action *port_shared_action_get_by_id (portid_t port_id, +uint32_t id); +int port_shared_action_update (portid_t port_id,uint32_t id, +const struct rte_flow_action *action); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
@@ -757,6 +776,7 @@ int port_flow_create(portid_t port_id,const struct rte_flow_attr *attr, const struct rte_flow_item *pattern, const struct rte_flow_action *actions); +int port_shared_action_query (portid_t port_id,uint32_t id);void update_age_action_context (const struct rte_flow_action *actions,struct port_flow *pf);int port_flow_destroy (portid_t port_id,uint32_t n,const uint32_t *rule);
doc/guides/testpmd_app_ug/testpmd_funcs.rst +112 -0
124 lines not on this page · raw message
Signature · 1 line
2.26.2