From e681eb0515ffa3f7ebfdc67d854f9e93c8d91f51 Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Tue, 13 Jul 2021 11:44:40 +0300 Subject: [PATCH] net/mlx5: optimize header modify action memory Define the types of the modify header action fields to be with the minimum size needed for the optional values range. Signed-off-by: Matan Azrad Acked-by: Suanming Mou --- drivers/common/mlx5/linux/mlx5_glue.h | 1 + drivers/net/mlx5/linux/mlx5_flow_os.h | 3 ++- drivers/net/mlx5/mlx5_flow.h | 6 +++--- drivers/net/mlx5/mlx5_flow_dv.c | 13 ++++++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h index 61f40d5478..f39ef2dac7 100644 --- a/drivers/common/mlx5/linux/mlx5_glue.h +++ b/drivers/common/mlx5/linux/mlx5_glue.h @@ -78,6 +78,7 @@ struct mlx5dv_devx_async_cmd_hdr; enum mlx5dv_dr_domain_type { unused, }; struct mlx5dv_dr_domain; struct mlx5dv_dr_action; +#define MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL 1 #endif #ifndef HAVE_MLX5DV_DR_DEVX_PORT diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h index cee685015b..1926d26410 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.h +++ b/drivers/net/mlx5/linux/mlx5_flow_os.h @@ -225,7 +225,8 @@ mlx5_flow_os_create_flow_action_modify_header(void *ctx, void *domain, (struct mlx5_flow_dv_modify_hdr_resource *)resource; *action = mlx5_glue->dv_create_flow_action_modify_header - (ctx, res->ft_type, domain, res->flags, + (ctx, res->ft_type, domain, res->root ? + MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL : 0, actions_len, (uint64_t *)res->actions); return (*action) ? 0 : -1; } diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 745a1fb2d4..488955a00d 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -524,11 +524,11 @@ struct mlx5_flow_dv_modify_hdr_resource { void *action; /**< Modify header action object. */ /* Key area for hash list matching: */ 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. */ + uint8_t actions_num; /**< Number of modification actions. */ + bool root; /**< Whether action is in root table. */ struct mlx5_modification_cmd actions[]; /**< Modification actions. */ -}; +} __rte_packed; /* Modify resource key of the hash organization. */ union mlx5_flow_modify_hdr_key { diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 0b48024392..b24f48b729 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -5006,21 +5006,21 @@ flow_dv_validate_action_port_id(struct rte_eth_dev *dev, * * @param dev * Pointer to rte_eth_dev structure. - * @param flags - * Flags bits to check if root level. + * @param root + * Whether action is on root table. * * @return * Max number of modify header actions device can support. */ static inline unsigned int flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev __rte_unused, - uint64_t flags) + bool root) { /* * There's no way to directly query the max capacity from FW. * The maximal value on root table should be assumed to be supported. */ - if (!(flags & MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL)) + if (!root) return MLX5_MAX_MODIFY_NUM; else return MLX5_ROOT_TBL_MODIFY_NUM; @@ -5622,10 +5622,9 @@ flow_dv_modify_hdr_resource_register }; uint64_t key64; - resource->flags = dev_flow->dv.group ? 0 : - MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL; + resource->root = !dev_flow->dv.group; if (resource->actions_num > flow_dv_modify_hdr_action_max(dev, - resource->flags)) + resource->root)) return rte_flow_error_set(error, EOVERFLOW, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "too many modify header items"); -- 2.20.1