static struct mlx5_flow_table *ipsec_ft_create(struct mlx5_flow_namespace *ns,
                                               int level, int prio,
-                                              int max_num_groups)
+                                              int max_num_groups, u32 flags)
 {
        struct mlx5_flow_table_attr ft_attr = {};
 
        ft_attr.max_fte = NUM_IPSEC_FTE;
        ft_attr.level = level;
        ft_attr.prio = prio;
+       ft_attr.flags = flags;
 
        return mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
 }
        struct mlx5_flow_destination default_dest;
        struct mlx5_flow_destination dest[2];
        struct mlx5_flow_table *ft;
+       u32 flags = 0;
        int err;
 
        default_dest = mlx5_ttc_get_default_dest(ttc, family2tt(family));
                return err;
 
        ft = ipsec_ft_create(ns, MLX5E_ACCEL_FS_ESP_FT_ERR_LEVEL,
-                            MLX5E_NIC_PRIO, 1);
+                            MLX5E_NIC_PRIO, 1, 0);
        if (IS_ERR(ft)) {
                err = PTR_ERR(ft);
                goto err_fs_ft_status;
                goto err_add;
 
        /* Create FT */
-       ft = ipsec_ft_create(ns, MLX5E_ACCEL_FS_ESP_FT_LEVEL, MLX5E_NIC_PRIO,
-                            2);
+       if (mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_TUNNEL)
+               flags = MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
+       ft = ipsec_ft_create(ns, MLX5E_ACCEL_FS_ESP_FT_LEVEL, MLX5E_NIC_PRIO, 2,
+                            flags);
        if (IS_ERR(ft)) {
                err = PTR_ERR(ft);
                goto err_fs_ft;
        }
 
        ft = ipsec_ft_create(ns, MLX5E_ACCEL_FS_POL_FT_LEVEL, MLX5E_NIC_PRIO,
-                            2);
+                            2, 0);
        if (IS_ERR(ft)) {
                err = PTR_ERR(ft);
                goto err_pol_ft;
 {
        struct mlx5_flow_destination dest = {};
        struct mlx5_flow_table *ft;
+       u32 flags = 0;
        int err;
 
-       ft = ipsec_ft_create(tx->ns, 2, 0, 1);
+       ft = ipsec_ft_create(tx->ns, 2, 0, 1, 0);
        if (IS_ERR(ft))
                return PTR_ERR(ft);
        tx->ft.status = ft;
        if (err)
                goto err_status_rule;
 
-       ft = ipsec_ft_create(tx->ns, 1, 0, 4);
+       if (mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_TUNNEL)
+               flags = MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
+       ft = ipsec_ft_create(tx->ns, 1, 0, 4, flags);
        if (IS_ERR(ft)) {
                err = PTR_ERR(ft);
                goto err_sa_ft;
                goto connect_roce;
        }
 
-       ft = ipsec_ft_create(tx->ns, 0, 0, 2);
+       ft = ipsec_ft_create(tx->ns, 0, 0, 2, 0);
        if (IS_ERR(ft)) {
                err = PTR_ERR(ft);
                goto err_pol_ft;