root/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_fw.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mlx5dr_fw_create_recalc_cs_ft
  2. mlx5dr_fw_destroy_recalc_cs_ft

   1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
   2 /* Copyright (c) 2019 Mellanox Technologies. */
   3 
   4 #include <linux/types.h>
   5 #include "dr_types.h"
   6 
   7 struct mlx5dr_fw_recalc_cs_ft *
   8 mlx5dr_fw_create_recalc_cs_ft(struct mlx5dr_domain *dmn, u32 vport_num)
   9 {
  10         struct mlx5dr_fw_recalc_cs_ft *recalc_cs_ft;
  11         u32 table_id, group_id, modify_hdr_id;
  12         u64 rx_icm_addr, modify_ttl_action;
  13         int ret;
  14 
  15         recalc_cs_ft = kzalloc(sizeof(*recalc_cs_ft), GFP_KERNEL);
  16         if (!recalc_cs_ft)
  17                 return NULL;
  18 
  19         ret = mlx5dr_cmd_create_flow_table(dmn->mdev, MLX5_FLOW_TABLE_TYPE_FDB,
  20                                            0, 0, dmn->info.caps.max_ft_level - 1,
  21                                            false, true, &rx_icm_addr, &table_id);
  22         if (ret) {
  23                 mlx5dr_err(dmn, "Failed creating TTL W/A FW flow table %d\n", ret);
  24                 goto free_ttl_tbl;
  25         }
  26 
  27         ret = mlx5dr_cmd_create_empty_flow_group(dmn->mdev,
  28                                                  MLX5_FLOW_TABLE_TYPE_FDB,
  29                                                  table_id, &group_id);
  30         if (ret) {
  31                 mlx5dr_err(dmn, "Failed creating TTL W/A FW flow group %d\n", ret);
  32                 goto destroy_flow_table;
  33         }
  34 
  35         /* Modify TTL action by adding zero to trigger CS recalculation */
  36         modify_ttl_action = 0;
  37         MLX5_SET(set_action_in, &modify_ttl_action, action_type, MLX5_ACTION_TYPE_ADD);
  38         MLX5_SET(set_action_in, &modify_ttl_action, field, MLX5_ACTION_IN_FIELD_OUT_IP_TTL);
  39 
  40         ret = mlx5dr_cmd_alloc_modify_header(dmn->mdev, MLX5_FLOW_TABLE_TYPE_FDB, 1,
  41                                              &modify_ttl_action,
  42                                              &modify_hdr_id);
  43         if (ret) {
  44                 mlx5dr_err(dmn, "Failed modify header TTL %d\n", ret);
  45                 goto destroy_flow_group;
  46         }
  47 
  48         ret = mlx5dr_cmd_set_fte_modify_and_vport(dmn->mdev,
  49                                                   MLX5_FLOW_TABLE_TYPE_FDB,
  50                                                   table_id, group_id, modify_hdr_id,
  51                                                   vport_num);
  52         if (ret) {
  53                 mlx5dr_err(dmn, "Failed setting TTL W/A flow table entry %d\n", ret);
  54                 goto dealloc_modify_header;
  55         }
  56 
  57         recalc_cs_ft->modify_hdr_id = modify_hdr_id;
  58         recalc_cs_ft->rx_icm_addr = rx_icm_addr;
  59         recalc_cs_ft->table_id = table_id;
  60         recalc_cs_ft->group_id = group_id;
  61 
  62         return recalc_cs_ft;
  63 
  64 dealloc_modify_header:
  65         mlx5dr_cmd_dealloc_modify_header(dmn->mdev, modify_hdr_id);
  66 destroy_flow_group:
  67         mlx5dr_cmd_destroy_flow_group(dmn->mdev,
  68                                       MLX5_FLOW_TABLE_TYPE_FDB,
  69                                       table_id, group_id);
  70 destroy_flow_table:
  71         mlx5dr_cmd_destroy_flow_table(dmn->mdev, table_id, MLX5_FLOW_TABLE_TYPE_FDB);
  72 free_ttl_tbl:
  73         kfree(recalc_cs_ft);
  74         return NULL;
  75 }
  76 
  77 void mlx5dr_fw_destroy_recalc_cs_ft(struct mlx5dr_domain *dmn,
  78                                     struct mlx5dr_fw_recalc_cs_ft *recalc_cs_ft)
  79 {
  80         mlx5dr_cmd_del_flow_table_entry(dmn->mdev,
  81                                         MLX5_FLOW_TABLE_TYPE_FDB,
  82                                         recalc_cs_ft->table_id);
  83         mlx5dr_cmd_dealloc_modify_header(dmn->mdev, recalc_cs_ft->modify_hdr_id);
  84         mlx5dr_cmd_destroy_flow_group(dmn->mdev,
  85                                       MLX5_FLOW_TABLE_TYPE_FDB,
  86                                       recalc_cs_ft->table_id,
  87                                       recalc_cs_ft->group_id);
  88         mlx5dr_cmd_destroy_flow_table(dmn->mdev,
  89                                       recalc_cs_ft->table_id,
  90                                       MLX5_FLOW_TABLE_TYPE_FDB);
  91 
  92         kfree(recalc_cs_ft);
  93 }

/* [<][>][^][v][top][bottom][index][help] */