net/mlx5: refactor flow infrastructure
cover net/mlx5: refactor flow infrastructure
As part of the effort to support DPDK on different OS, this series adds OS abstraction for flow infrastructures. The changes include renaming using generic terms, as well as OS specific functions for flow related operations and utilities.
Dekel Peled (6):
net/mlx5: rename IB flow to generic name DRV flow net/mlx5: rename Verbs action to generic name net/mlx5: add OS specific flow related utilities net/mlx5: add OS specific flow type selection net/mlx5: add OS specific flow create and destroy net/mlx5: add OS specific flow actions operations
drivers/net/mlx5/linux/mlx5_flow_os.h | 368 ++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.c | 10 +- drivers/net/mlx5/mlx5_flow.h | 18 +- drivers/net/mlx5/mlx5_flow_dv.c | 250 ++++++++++++----------- drivers/net/mlx5/mlx5_flow_verbs.c | 12 +- 5 files changed, 520 insertions(+), 138 deletions(-) create mode 100644 drivers/net/mlx5/linux/mlx5_flow_os.h
Signature · 1 line
1.8.3.1
PATCH 1/6 net/mlx5: rename IB flow to generic name DRV flow
As part of the effort to support DPDK on Windows and other OS, rename from IB related name to generic name.
--- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 11 +++++------ drivers/net/mlx5/mlx5_flow_verbs.c | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -538,7 +538,7 @@ struct mlx5_flow_handle {/**< Index to next device flow handle. */ uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ -void *ib_flow;/**< Verbs flow pointer. */ +void *drv_flow;/**< pointer to driver flow object. */ uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */
drivers/net/mlx5/mlx5_flow_dv.c +5 -6
@@ -8673,12 +8673,11 @@ struct field_modify_info modify_tcp[] = { dh->rix_default_fate =MLX5_FLOW_FATE_DEFAULT_MISS ; dv->actions[n++] = priv->sh->default_miss.action; } - - dh->ib_flow = + dh->drv_flow = mlx5_glue->dv_create_flow (dv_h->matcher->matcher_object, (void *)&dv->value, n, dv->actions); -if (!dh->ib_flow) { +if (!dh->drv_flow) { rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -9041,9 +9040,9 @@ struct field_modify_info modify_tcp[] = { handle_idx);if (!dh)return ; -if (dh->ib_flow) { -claim_zero (mlx5_glue->dv_destroy_flow (dh->ib_flow)); - dh->ib_flow =NULL ; +if (dh->drv_flow) { +claim_zero (mlx5_glue->dv_destroy_flow (dh->drv_flow)); + dh->drv_flow =NULL ; } if (dh->fate_action == MLX5_FLOW_FATE_DROP || dh->fate_action == MLX5_FLOW_FATE_QUEUE ||
drivers/net/mlx5/mlx5_flow_verbs.c +6 -6
@@ -1778,9 +1778,9 @@return ;SILIST_FOREACH (priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW ], flow->dev_handles, handle_idx, handle, next) { -if (handle->ib_flow) { -claim_zero (mlx5_glue->destroy_flow (handle->ib_flow)); - handle->ib_flow =NULL ; +if (handle->drv_flow) { +claim_zero (mlx5_glue->destroy_flow (handle->drv_flow)); + handle->drv_flow =NULL ; }/* hrxq is union, don't touch it only the flag is set. */ if (handle->rix_hrxq) {
@@ -1901,9 +1901,9 @@ handle->rix_hrxq = hrxq_idx; }MLX5_ASSERT (hrxq); - handle->ib_flow = mlx5_glue->create_flow (hrxq->qp, - &dev_flow->verbs.attr); -if (!handle->ib_flow) { + handle->drv_flow = mlx5_glue->create_flow + (hrxq->qp, &dev_flow->verbs.attr); +if (!handle->drv_flow) { rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
Signature · 1 line
1.8.3.1
PATCH 2/6 net/mlx5: rename Verbs action to generic name
In reply to Dekel PeledAs part of the effort to support DPDK on Windows and other OS, rename 'verbs_action' to the generic name 'action'.
--- drivers/net/mlx5/mlx5_flow.h | 16 ++++++++-------- drivers/net/mlx5/mlx5_flow_dv.c | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-)
drivers/net/mlx5/mlx5_flow.h +8 -8
@@ -399,8 +399,8 @@ struct mlx5_flow_dv_encap_decap_resource {ILIST_ENTRY (uint32_t )next;/* Pointer to next element. */ rte_atomic32_t refcnt;/**< Reference counter. */ -void *verbs_action; -/**< Verbs encap/decap action object. */ +void *action; +/**< Encap/decap action object. */ uint8_t buf[MLX5_ENCAP_MAX_LEN ];size_t size;uint8_t reformat_type;
@@ -413,7 +413,7 @@ struct mlx5_flow_dv_tag_resource {struct mlx5_hlist_entry entry;/**< hash list entry for tag resource, tag value as the key. */ void *action; -/**< Verbs tag action object. */ +/**< Tag action object. */ rte_atomic32_t refcnt;/**< Reference counter. */ uint32_t idx;/**< Index for the index memory pool. */ };
@@ -436,8 +436,8 @@ struct mlx5_flow_dv_modify_hdr_resource {LIST_ENTRY (mlx5_flow_dv_modify_hdr_resource) next;/* Pointer to next element. */ rte_atomic32_t refcnt;/**< Reference counter. */ -struct ibv_flow_action *verbs_action; -/**< Verbs modify header action object. */ +struct ibv_flow_action *action; +/**< Modify header action object. */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint32_t actions_num;/**< Number of modification actions. */ uint64_t flags;/**< Flags for RDMA API. */
@@ -458,7 +458,7 @@ struct mlx5_flow_dv_port_id_action_resource {/* Pointer to next element. */ rte_atomic32_t refcnt;/**< Reference counter. */ void *action; -/**< Verbs tag action object. */ +/**< Action object. */ uint32_t port_id;/**< Port ID value. */ };
@@ -467,7 +467,7 @@ struct mlx5_flow_dv_push_vlan_action_resource {ILIST_ENTRY (uint32_t )next;/* Pointer to next element. */ rte_atomic32_t refcnt;/**< Reference counter. */ -void *action;/**< Direct verbs action object. */ +void *action;/**< Action object. */ uint8_t ft_type;/**< Flow table type, Rx, Tx or FDB. */ rte_be32_t vlan_tag;/**< VLAN tag value. */ };
@@ -660,7 +660,7 @@ struct mlx5_flow_verbs_workspace {struct mlx5_flow {struct rte_flow *flow;/**< Pointer to the main flow. */ uint32_t flow_idx;/**< The memory pool index to the main flow. */ -uint64_t hash_fields;/**< Verbs hash Rx queue hash fields. */ +uint64_t hash_fields;/**< Hash Rx queue hash fields. */ uint64_t act_flags;/**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */ bool external;/**< true if the flow is created external to PMD. */
drivers/net/mlx5/mlx5_flow_dv.c +14 -14
@@ -2603,13 +2603,13 @@ struct field_modify_info modify_tcp[] = {RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , "cannot allocate resource memory"); *cache_resource = *resource; - cache_resource->verbs_action = + cache_resource->action = mlx5_glue->dv_create_flow_action_packet_reformat (sh->ctx, cache_resource->reformat_type, cache_resource->ft_type, domain, cache_resource->flags, cache_resource->size, (cache_resource->size ? cache_resource->buf :NULL )); -if (!cache_resource->verbs_action) { +if (!cache_resource->action) {rte_free (cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -4030,12 +4030,12 @@ struct field_modify_info modify_tcp[] = { "cannot allocate resource memory"); *cache_resource = *resource;rte_memcpy (cache_resource->actions, resource->actions, actions_len); - cache_resource->verbs_action = + cache_resource->action = mlx5_glue->dv_create_flow_action_modify_header (sh->ctx, cache_resource->ft_type, ns, cache_resource->flags, actions_len, (uint64_t *)cache_resource->actions); -if (!cache_resource->verbs_action) { +if (!cache_resource->action) {rte_free (cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -8093,7 +8093,7 @@ struct field_modify_info modify_tcp[] = { error))return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; action_flags |=MLX5_FLOW_ACTION_ENCAP ;break ;case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP :
@@ -8103,7 +8103,7 @@ struct field_modify_info modify_tcp[] = { error))return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; action_flags |=MLX5_FLOW_ACTION_DECAP ;break ;case RTE_FLOW_ACTION_TYPE_RAW_ENCAP :
@@ -8113,7 +8113,7 @@ struct field_modify_info modify_tcp[] = { (dev, actions, dev_flow, attr, error))return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; }else {/* Handle encap without preceding decap. */ if (flow_dv_create_action_l2_encap
@@ -8121,7 +8121,7 @@ struct field_modify_info modify_tcp[] = { error))return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; } action_flags |=MLX5_FLOW_ACTION_ENCAP ;break ;
@@ -8133,7 +8133,7 @@ struct field_modify_info modify_tcp[] = { (dev, dev_flow, attr->transfer, error))return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; }/* If decap is followed by encap, handle it at encap. */ action_flags |=MLX5_FLOW_ACTION_DECAP ;
@@ -8315,7 +8315,7 @@ struct field_modify_info modify_tcp[] = { (dev, mhdr_res, dev_flow, error))return -rte_errno; dev_flow->dv.actions[modify_action_position] = - handle->dvh.modify_hdr->verbs_action; + handle->dvh.modify_hdr->action; }if (action_flags &MLX5_FLOW_ACTION_COUNT ) { flow->counter =
@@ -8778,13 +8778,13 @@ struct field_modify_info modify_tcp[] = { idx);if (!cache_resource)return 0 ; -MLX5_ASSERT (cache_resource->verbs_action); +MLX5_ASSERT (cache_resource->action);DRV_LOG (DEBUG ,"encap/decap resource %p: refcnt %d--" , (void *)cache_resource,rte_atomic32_read (&cache_resource->refcnt));if (rte_atomic32_dec_and_test (&cache_resource->refcnt)) {claim_zero (mlx5_glue->destroy_flow_action - (cache_resource->verbs_action)); + (cache_resource->action));ILIST_REMOVE (priv->sh->ipool[MLX5_IPOOL_DECAP_ENCAP ], &priv->sh->encaps_decaps, idx, cache_resource, next);
@@ -8881,13 +8881,13 @@ struct field_modify_info modify_tcp[] = {struct mlx5_flow_dv_modify_hdr_resource *cache_resource = handle->dvh.modify_hdr; -MLX5_ASSERT (cache_resource->verbs_action); +MLX5_ASSERT (cache_resource->action);DRV_LOG (DEBUG ,"modify-header resource %p: refcnt %d--" , (void *)cache_resource,rte_atomic32_read (&cache_resource->refcnt));if (rte_atomic32_dec_and_test (&cache_resource->refcnt)) {claim_zero (mlx5_glue->destroy_flow_action - (cache_resource->verbs_action)); + (cache_resource->action));LIST_REMOVE (cache_resource, next);rte_free (cache_resource); DRV_LOG(DEBUG, "modify-header resource %p: removed",
Signature · 1 line
1.8.3.1
PATCH 3/6 net/mlx5: add OS specific flow related utilities
In reply to Dekel PeledThis patch introduces the first OS specific utility functions, for use by flow engine in different OS implementation.
The first utility functions are:
bool mlx5_flow_os_item_supported(item)
bool mlx5_flow_os_action_supported(action)
They are implemented to check OS specific support for different item types and action types.
New header file is added:drivers/net/mlx5/linux/mlx5_flow_os.h
This file contains the utility functions mentioned above for Linux OS. At this stage they are implemented as static inline, for efficiency, and always return true.
--- drivers/net/mlx5/linux/mlx5_flow_os.h | 38 +++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 20 ++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 drivers/net/mlx5/linux/mlx5_flow_os.h
drivers/net/mlx5/linux/mlx5_flow_os.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2020 Mellanox Technologies, Ltd +*/ + +#ifndef RTE_PMD_MLX5_FLOW_OS_H_ +#define RTE_PMD_MLX5_FLOW_OS_H_ + +/** +* Check if item type is supported. +* +* @param item +* Item type to check. +* +* @return +* True is this item type is supported, false if not supported. +*/ +static inline bool +mlx5_flow_os_item_supported(int item __rte_unused) +{ +return true; +} + +/** +* Check if action type is supported. +* +* @param action +* Action type to check. +* +* @return +* True is this action type is supported, false if not supported. +*/ +static inline bool +mlx5_flow_os_action_supported(int action __rte_unused) +{ +return true; +} + +#endif /* RTE_PMD_MLX5_FLOW_OS_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +20 -0
@@ -38,6 +38,7 @@#include "mlx5.h" #include "mlx5_common_os.h" #include "mlx5_flow.h" +#include "mlx5_flow_os.h" #include "mlx5_rxtx.h" #ifdef HAVE_IBV_FLOW_DV_SUPPORT
@@ -4939,6 +4940,10 @@ struct field_modify_info modify_tcp[] = {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );int type = items->type; +if (!mlx5_flow_os_item_supported (type)) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"item not supported" );switch (type) {case RTE_FLOW_ITEM_TYPE_VOID :break ;
@@ -5177,6 +5182,12 @@ struct field_modify_info modify_tcp[] = { }for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) {int type = actions->type; + +if (!mlx5_flow_os_action_supported (type)) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , + actions, +"action not supported" );if (actions_n ==MLX5_DV_MAX_NUMBER_OF_ACTIONS ) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
@@ -7907,6 +7918,11 @@ struct field_modify_info modify_tcp[] = {const struct rte_flow_action *found_action =NULL ;struct mlx5_flow_meter *fm =NULL ; +if (!mlx5_flow_os_action_supported (action_type)) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , + actions, +"action not supported" );switch (action_type) {case RTE_FLOW_ACTION_TYPE_VOID :break ;
@@ -8347,6 +8363,10 @@ struct field_modify_info modify_tcp[] = {int tunnel = !!(item_flags &MLX5_FLOW_LAYER_TUNNEL );int item_type = items->type; +if (!mlx5_flow_os_item_supported (item_type)) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ITEM , +NULL ,"item not supported" );switch (item_type) {case RTE_FLOW_ITEM_TYPE_PORT_ID : flow_dv_translate_item_port_id(dev, match_mask,
Signature · 1 line
1.8.3.1
PATCH 4/6 net/mlx5: add OS specific flow type selection
In reply to Dekel PeledIn current implementation the flow type (DV/Verbs) is selected using dedicated function flow_get_drv_type().
This patch adds OS specific function mlx5_flow_os_get_type(), to allow OS specific flow type selection.
The new function is called by flow_get_drv_type(), and if it returns a valid value (DV/Verbs) no more logic is required.
Otherwise the existing logic is executed.
--- drivers/net/mlx5/linux/mlx5_flow_os.h | 18 ++++++++++++++++++ drivers/net/mlx5/mlx5_flow.c | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/mlx5/linux/mlx5_flow_os.h +18 -0
@@ -5,6 +5,24 @@#ifndef RTE_PMD_MLX5_FLOW_OS_H_ #define RTE_PMD_MLX5_FLOW_OS_H_ +#include "mlx5_flow.h" + +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops; +#endif + +/** +* Get OS enforced flow type. MLX5_FLOW_TYPE_MAX means "non enforced type". +* +* @return +* Flow type (MLX5_FLOW_TYPE_MAX) +*/ +static inline enum mlx5_flow_drv_type +mlx5_flow_os_get_type (void ) +{ +return MLX5_FLOW_TYPE_MAX ; +} +/** * Check if item type is supported. *
drivers/net/mlx5/mlx5_flow.c +6 -4
@@ -36,12 +36,10 @@#include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_flow.h" +#include "mlx5_flow_os.h" #include "mlx5_rxtx.h" /** Device flow drivers. */ -#ifdef HAVE_IBV_FLOW_DV_SUPPORT -extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops; -#endif extern const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops;const struct mlx5_flow_driver_ops mlx5_flow_null_drv_ops;
@@ -2501,8 +2499,12 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr) { struct mlx5_priv *priv = dev->data->dev_private; -enum mlx5_flow_drv_type type =MLX5_FLOW_TYPE_MAX ; +/* The OS can determine first a specific flow type (DV, VERBS) */ +enum mlx5_flow_drv_type type =mlx5_flow_os_get_type (); +if (type !=MLX5_FLOW_TYPE_MAX ) +return type; +/* If no OS specific type - continue with DV/VERBS selection */ if (attr->transfer && priv->config.dv_esw_en) type =MLX5_FLOW_TYPE_DV ;if (!attr->transfer)
Signature · 1 line
1.8.3.1
PATCH 5/6 net/mlx5: add OS specific flow create and destroy
In reply to Dekel PeledThis patch introduces the OS specific functions, for flow create and flow destroy operations.
In existing implementation, the functions to create objects (flow/table/matcher) return a pointer to the created object. The functions to destroy objects return 0 on success and errno on failure.
The new OS specific functions to create objects return 0 on success, and (-1) on failure.
On success, a pointer to the created object is returned using an additional parameter.
--- drivers/net/mlx5/linux/mlx5_flow_os.h | 114 ++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 101 +++++++++++++++--------------- 2 files changed, 164 insertions(+), 51 deletions(-)
drivers/net/mlx5/linux/mlx5_flow_os.h +114 -0
@@ -53,4 +53,118 @@ return true; } +/** +* Create flow rule. +* +* @param[in] matcher +* Pointer to match mask structure. +* @param[in] match_value +* Pointer to match value structure. +* @param[in] num_actions +* Number of actions in flow rule. +* @param[in] actions +* Pointer to array of flow rule actions. +* @param[out] flow +* Pointer to a valid flow rule object on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow (void *matcher,void *match_value, +size_t num_actions,void *actions[],void **flow) +{ + *flow = mlx5_glue->dv_create_flow (matcher, match_value, + num_actions, actions); +return (*flow) ?0 :-1 ; +} + +/** +* Destroy flow rule. +* +* @param[in] drv_flow_ptr +* Pointer to flow rule object. +* +* @return +* 0 on success, or the value of errno on failure. +*/ +static inline int +mlx5_flow_os_destroy_flow (void *drv_flow_ptr) +{ +return mlx5_glue->dv_destroy_flow (drv_flow_ptr); +} + +/** +* Create flow table. +* +* @param[in] domain +* Pointer to relevant domain. +* @param[in] table_id +* Table ID. +* @param[out] table +* Pointer to a valid flow table object on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_tbl (void *domain,uint32_t table_id,void **table) +{ + *table = mlx5_glue->dr_create_flow_tbl (domain, table_id); +return (*table) ?0 :-1 ; +} + +/** +* Destroy flow table. +* +* @param[in] table +* Pointer to table object to destroy. +* +* @return +* 0 on success, or the value of errno on failure. +*/ +static inline int +mlx5_flow_os_destroy_flow_tbl (void *table) +{ +return mlx5_glue->dr_destroy_flow_tbl (table); +} + +/** +* Create flow matcher in a flow table. +* +* @param[in] ctx +* Pointer to relevant device context. +* @param[in] attr +* Pointer to relevant attributes. +* @param[in] table +* Pointer to table object. +* @param[out] matcher +* Pointer to a valid flow matcher object on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_matcher (void *ctx,void *attr,void *table, +void **matcher) +{ + *matcher = mlx5_glue->dv_create_flow_matcher (ctx, attr, table); +return (*matcher) ?0 :-1 ; +} + +/** +* Destroy flow matcher. +* +* @param[in] matcher +* Pointer to matcher object to destroy. +* +* @return +* 0 on success, or the value of errno on failure. +*/ +static inline int +mlx5_flow_os_destroy_flow_matcher (void *matcher) +{ +return mlx5_glue->dv_destroy_flow_matcher (matcher); +} +#endif /* RTE_PMD_MLX5_FLOW_OS_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +50 -51
213 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 6/6 net/mlx5: add OS specific flow actions operations
In reply to Dekel PeledThis patch introduces the OS specific functions, for flow actions create and destroy operations.
In existing implementation, the functions to create flow actions return a pointer to the created action object.
The new OS specific functions to create flow actions return 0 on success, and (-1) on failure.
On success, a pointer to the created action object is returned using an additional parameter.
On failure errno is set.
--- drivers/net/mlx5/linux/mlx5_flow_os.h | 198 ++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 110 +++++++++---------- 3 files changed, 251 insertions(+), 59 deletions(-)
drivers/net/mlx5/linux/mlx5_flow_os.h +198 -0
@@ -167,4 +167,202 @@ return mlx5_glue->dv_destroy_flow_matcher(matcher); } +/** +* Create flow action: packet reformat. +* +* @param[in] ctx +* Pointer to relevant device context. +* @param[in] domain +* Pointer to domain handler. +* @param[in] resource +* Pointer to action data resource. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_packet_reformat (void *ctx,void *domain, +void *resource,void **action) +{ +struct mlx5_flow_dv_encap_decap_resource *res = + (struct mlx5_flow_dv_encap_decap_resource *)resource; + + *action = mlx5_glue->dv_create_flow_action_packet_reformat + (ctx, res->reformat_type, res->ft_type, + domain, res->flags, res->size, + (res->size ? res->buf :NULL )); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: modify header. +* +* @param[in] ctx +* Pointer to relevant device context. +* @param[in] domain +* Pointer to domain handler. +* @param[in] resource +* Pointer to action data resource. +* @param[in] actions_len +* Total length of actions data in resource. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_modify_header (void *ctx,void *domain, +void *resource, +uint32_t actions_len, +void **action) +{ +struct mlx5_flow_dv_modify_hdr_resource *res = + (struct mlx5_flow_dv_modify_hdr_resource *)resource; + + *action = mlx5_glue->dv_create_flow_action_modify_header + (ctx, res->ft_type, domain, res->flags, + actions_len, (uint64_t *)res->actions); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: destination flow table. +* +* @param[in] tbl_obj +* Pointer to destination table object. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_dest_flow_tbl (void *tbl_obj,void **action) +{ + *action = mlx5_glue->dr_create_flow_action_dest_flow_tbl (tbl_obj); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: destination port. +* +* @param[in] domain +* Pointer to domain handler. +* @param[in] port_id +* Destination port ID. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_dest_port (void *domain,uint32_t port_id, +void **action) +{ +/* +* Depending on rdma_core version the glue routine calls +* either mlx5dv_dr_action_create_dest_ib_port(domain, dev_port) +* or mlx5dv_dr_action_create_dest_vport(domain, vport_id). +*/ + *action = mlx5_glue->dr_create_flow_action_dest_port (domain, port_id); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: push vlan. +* +* @param[in] domain +* Pointer to domain handler. +* @param[in] vlan_tag +* VLAN tag value. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_push_vlan (void *domain,rte_be32_t vlan_tag, +void **action) +{ + *action = mlx5_glue->dr_create_flow_action_push_vlan (domain, vlan_tag); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: count. +* +* @param[in] cnt_obj +* Pointer to DevX counter object. +* @param[in] offset +* Offset of counter in array. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_count (void *cnt_obj,uint16_t offset, +void **action) +{ + *action = mlx5_glue->dv_create_flow_action_counter (cnt_obj, offset); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: tag. +* +* @param[in] tag +* Tag value. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_tag (uint32_t tag,void **action) +{ + *action = mlx5_glue->dv_create_flow_action_tag (tag); +return (*action) ?0 :-1 ; +} + +/** +* Create flow action: drop. +* +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_drop (void **action) +{ + *action = mlx5_glue->dr_create_flow_action_drop (); +return (*action) ?0 :-1 ; +} + +/** +* Destroy flow action. +* +* @param[in] action +* Pointer to action object to destroy. +* +* @return +* 0 on success, or the value of errno on failure. +*/ +static inline int +mlx5_flow_os_destroy_flow_action (void *action) +{ +return mlx5_glue->destroy_flow_action (action); +} +#endif /* RTE_PMD_MLX5_FLOW_OS_H_ */
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -436,7 +436,7 @@ struct mlx5_flow_dv_modify_hdr_resource {LIST_ENTRY (mlx5_flow_dv_modify_hdr_resource) next;/* Pointer to next element. */ rte_atomic32_t refcnt;/**< Reference counter. */ -struct ibv_flow_action *action; +void *action;/**< Modify header action object. */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint32_t actions_num;/**< Number of modification actions. */
drivers/net/mlx5/mlx5_flow_dv.c +52 -58
267 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Hi,
Quoted 32 lines
-----Original Message-----
From: Dekel Peled <[email protected]>
Sent: Sunday, June 28, 2020 5:07 PM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Raslan Darawsheh <[email protected]>
Cc: [email protected]
Subject: [PATCH 0/6] net/mlx5: refactor flow infrastructureAs part of the effort to support DPDK on different OS, this series adds OS abstraction for flow infrastructures. The changes include renaming using generic terms, as well as OS specific functions for flow related operations and utilities.
Series-acked-by Matan Azrad <[email protected]>Dekel Peled (6):
net/mlx5: rename IB flow to generic name DRV flow net/mlx5: rename Verbs action to generic name net/mlx5: add OS specific flow related utilities net/mlx5: add OS specific flow type selection net/mlx5: add OS specific flow create and destroy net/mlx5: add OS specific flow actions operationsdrivers/net/mlx5/linux/mlx5_flow_os.h | 368 ++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.c | 10 +- drivers/net/mlx5/mlx5_flow.h | 18 +- drivers/net/mlx5/mlx5_flow_dv.c | 250 ++++++++++++----------- drivers/net/mlx5/mlx5_flow_verbs.c | 12 +- 5 files changed, 520 insertions(+), 138 deletions(-) create mode 100644 drivers/net/mlx5/linux/mlx5_flow_os.h
Quoted 2 lines
--
1.8.3.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh