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
  36#ifdef CONFIG_MLX5_SW_STEERING
  37
  38struct mlx5dr_domain *
  39mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type);
  40
  41int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);
  42
  43int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);
  44
  45void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
  46                            struct mlx5dr_domain *peer_dmn);
  47
  48struct mlx5dr_table *
  49mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level);
  50
  51int mlx5dr_table_destroy(struct mlx5dr_table *table);
  52
  53u32 mlx5dr_table_get_id(struct mlx5dr_table *table);
  54
  55struct mlx5dr_matcher *
  56mlx5dr_matcher_create(struct mlx5dr_table *table,
  57                      u16 priority,
  58                      u8 match_criteria_enable,
  59                      struct mlx5dr_match_parameters *mask);
  60
  61int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
  62
  63struct mlx5dr_rule *
  64mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
  65                   struct mlx5dr_match_parameters *value,
  66                   size_t num_actions,
  67                   struct mlx5dr_action *actions[]);
  68
  69int mlx5dr_rule_destroy(struct mlx5dr_rule *rule);
  70
  71int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
  72                                 struct mlx5dr_action *action);
  73
  74struct mlx5dr_action *
  75mlx5dr_action_create_dest_table(struct mlx5dr_table *table);
  76
  77struct mlx5dr_action *
  78mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft,
  79                                        struct mlx5_core_dev *mdev);
  80
  81struct mlx5dr_action *
  82mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
  83                                u32 vport, u8 vhca_id_valid,
  84                                u16 vhca_id);
  85
  86struct mlx5dr_action *mlx5dr_action_create_drop(void);
  87
  88struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);
  89
  90struct mlx5dr_action *
  91mlx5dr_action_create_flow_counter(u32 counter_id);
  92
  93struct mlx5dr_action *
  94mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
  95                                     enum mlx5dr_action_reformat_type reformat_type,
  96                                     size_t data_sz,
  97                                     void *data);
  98
  99struct mlx5dr_action *
 100mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
 101                                   u32 flags,
 102                                   size_t actions_sz,
 103                                   __be64 actions[]);
 104
 105struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void);
 106
 107struct mlx5dr_action *
 108mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr);
 109
 110int mlx5dr_action_destroy(struct mlx5dr_action *action);
 111
 112static inline bool
 113mlx5dr_is_supported(struct mlx5_core_dev *dev)
 114{
 115        return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner);
 116}
 117
 118#else /* CONFIG_MLX5_SW_STEERING */
 119
 120static inline struct mlx5dr_domain *
 121mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type) { return NULL; }
 122
 123static inline int
 124mlx5dr_domain_destroy(struct mlx5dr_domain *domain) { return 0; }
 125
 126static inline int
 127mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags) { return 0; }
 128
 129static inline void
 130mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
 131                       struct mlx5dr_domain *peer_dmn) { }
 132
 133static inline struct mlx5dr_table *
 134mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level) { return NULL; }
 135
 136static inline int
 137mlx5dr_table_destroy(struct mlx5dr_table *table) { return 0; }
 138
 139static inline u32
 140mlx5dr_table_get_id(struct mlx5dr_table *table) { return 0; }
 141
 142static inline struct mlx5dr_matcher *
 143mlx5dr_matcher_create(struct mlx5dr_table *table,
 144                      u16 priority,
 145                      u8 match_criteria_enable,
 146                      struct mlx5dr_match_parameters *mask) { return NULL; }
 147
 148static inline int
 149mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher) { return 0; }
 150
 151static inline struct mlx5dr_rule *
 152mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
 153                   struct mlx5dr_match_parameters *value,
 154                   size_t num_actions,
 155                   struct mlx5dr_action *actions[]) { return NULL; }
 156
 157static inline int
 158mlx5dr_rule_destroy(struct mlx5dr_rule *rule) { return 0; }
 159
 160static inline int
 161mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
 162                             struct mlx5dr_action *action) { return 0; }
 163
 164static inline struct mlx5dr_action *
 165mlx5dr_action_create_dest_table(struct mlx5dr_table *table) { return NULL; }
 166
 167static inline struct mlx5dr_action *
 168mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft,
 169                                        struct mlx5_core_dev *mdev) { return NULL; }
 170
 171static inline struct mlx5dr_action *
 172mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
 173                                u32 vport, u8 vhca_id_valid,
 174                                u16 vhca_id) { return NULL; }
 175
 176static inline struct mlx5dr_action *
 177mlx5dr_action_create_drop(void) { return NULL; }
 178
 179static inline struct mlx5dr_action *
 180mlx5dr_action_create_tag(u32 tag_value) { return NULL; }
 181
 182static inline struct mlx5dr_action *
 183mlx5dr_action_create_flow_counter(u32 counter_id) { return NULL; }
 184
 185static inline struct mlx5dr_action *
 186mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
 187                                     enum mlx5dr_action_reformat_type reformat_type,
 188                                     size_t data_sz,
 189                                     void *data) { return NULL; }
 190
 191static inline struct mlx5dr_action *
 192mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
 193                                   u32 flags,
 194                                   size_t actions_sz,
 195                                   __be64 actions[]) { return NULL; }
 196
 197static inline struct mlx5dr_action *
 198mlx5dr_action_create_pop_vlan(void) { return NULL; }
 199
 200static inline struct mlx5dr_action *
 201mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain,
 202                               __be32 vlan_hdr) { return NULL; }
 203
 204static inline int
 205mlx5dr_action_destroy(struct mlx5dr_action *action) { return 0; }
 206
 207static inline bool
 208mlx5dr_is_supported(struct mlx5_core_dev *dev) { return false; }
 209
 210#endif /* CONFIG_MLX5_SW_STEERING */
 211
 212#endif /* _MLX5DR_H_ */
 213