linux/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
   2/* Copyright (c) 2019, Mellanox Technologies */
   3
   4#ifndef _MLX5DR_H_
   5#define _MLX5DR_H_
   6
   7struct mlx5dr_domain;
   8struct mlx5dr_table;
   9struct mlx5dr_matcher;
  10struct mlx5dr_rule;
  11struct mlx5dr_action;
  12
  13enum mlx5dr_domain_type {
  14        MLX5DR_DOMAIN_TYPE_NIC_RX,
  15        MLX5DR_DOMAIN_TYPE_NIC_TX,
  16        MLX5DR_DOMAIN_TYPE_FDB,
  17};
  18
  19enum mlx5dr_domain_sync_flags {
  20        MLX5DR_DOMAIN_SYNC_FLAGS_SW = 1 << 0,
  21        MLX5DR_DOMAIN_SYNC_FLAGS_HW = 1 << 1,
  22};
  23
  24enum mlx5dr_action_reformat_type {
  25        DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2,
  26        DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L2,
  27        DR_ACTION_REFORMAT_TYP_TNL_L3_TO_L2,
  28        DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L3,
  29};
  30
  31struct mlx5dr_match_parameters {
  32        size_t match_sz;
  33        u64 *match_buf; /* Device spec format */
  34};
  35
  36struct mlx5dr_action_dest {
  37        struct mlx5dr_action *dest;
  38        struct mlx5dr_action *reformat;
  39};
  40
  41struct mlx5dr_domain *
  42mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type);
  43
  44int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);
  45
  46int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);
  47
  48void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
  49                            struct mlx5dr_domain *peer_dmn);
  50
  51struct mlx5dr_table *
  52mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags);
  53
  54int mlx5dr_table_destroy(struct mlx5dr_table *table);
  55
  56u32 mlx5dr_table_get_id(struct mlx5dr_table *table);
  57
  58struct mlx5dr_matcher *
  59mlx5dr_matcher_create(struct mlx5dr_table *table,
  60                      u32 priority,
  61                      u8 match_criteria_enable,
  62                      struct mlx5dr_match_parameters *mask);
  63
  64int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
  65
  66struct mlx5dr_rule *
  67mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
  68                   struct mlx5dr_match_parameters *value,
  69                   size_t num_actions,
  70                   struct mlx5dr_action *actions[]);
  71
  72int mlx5dr_rule_destroy(struct mlx5dr_rule *rule);
  73
  74int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
  75                                 struct mlx5dr_action *action);
  76
  77struct mlx5dr_action *
  78mlx5dr_action_create_dest_table_num(struct mlx5dr_domain *dmn, u32 table_num);
  79
  80struct mlx5dr_action *
  81mlx5dr_action_create_dest_table(struct mlx5dr_table *table);
  82
  83struct mlx5dr_action *
  84mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain,
  85                                        struct mlx5_flow_table *ft);
  86
  87struct mlx5dr_action *
  88mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
  89                                u32 vport, u8 vhca_id_valid,
  90                                u16 vhca_id);
  91
  92struct mlx5dr_action *
  93mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
  94                                   struct mlx5dr_action_dest *dests,
  95                                   u32 num_of_dests);
  96
  97struct mlx5dr_action *mlx5dr_action_create_drop(void);
  98
  99struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);
 100
 101struct mlx5dr_action *
 102mlx5dr_action_create_flow_counter(u32 counter_id);
 103
 104struct mlx5dr_action *
 105mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
 106                                     enum mlx5dr_action_reformat_type reformat_type,
 107                                     size_t data_sz,
 108                                     void *data);
 109
 110struct mlx5dr_action *
 111mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
 112                                   u32 flags,
 113                                   size_t actions_sz,
 114                                   __be64 actions[]);
 115
 116struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void);
 117
 118struct mlx5dr_action *
 119mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr);
 120
 121int mlx5dr_action_destroy(struct mlx5dr_action *action);
 122
 123static inline bool
 124mlx5dr_is_supported(struct mlx5_core_dev *dev)
 125{
 126        return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner);
 127}
 128
 129#endif /* _MLX5DR_H_ */
 130