net/mlx5: optimize header modify action memory
authorMatan Azrad <matan@nvidia.com>
Tue, 13 Jul 2021 08:44:40 +0000 (11:44 +0300)
committerRaslan Darawsheh <rasland@nvidia.com>
Thu, 15 Jul 2021 13:19:09 +0000 (15:19 +0200)
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 <matan@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
drivers/common/mlx5/linux/mlx5_glue.h
drivers/net/mlx5/linux/mlx5_flow_os.h
drivers/net/mlx5/mlx5_flow.h
drivers/net/mlx5/mlx5_flow_dv.c

index 61f40d5..f39ef2d 100644 (file)
@@ -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
index cee6850..1926d26 100644 (file)
@@ -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;
 }
index 745a1fb..488955a 100644 (file)
@@ -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 {
index 0b48024..b24f48b 100644 (file)
@@ -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");