0001
0002
0003
0004 #ifndef _MLX5DR_H_
0005 #define _MLX5DR_H_
0006
0007 struct mlx5dr_domain;
0008 struct mlx5dr_table;
0009 struct mlx5dr_matcher;
0010 struct mlx5dr_rule;
0011 struct mlx5dr_action;
0012
0013 enum mlx5dr_domain_type {
0014 MLX5DR_DOMAIN_TYPE_NIC_RX,
0015 MLX5DR_DOMAIN_TYPE_NIC_TX,
0016 MLX5DR_DOMAIN_TYPE_FDB,
0017 };
0018
0019 enum mlx5dr_domain_sync_flags {
0020 MLX5DR_DOMAIN_SYNC_FLAGS_SW = 1 << 0,
0021 MLX5DR_DOMAIN_SYNC_FLAGS_HW = 1 << 1,
0022 };
0023
0024 enum mlx5dr_action_reformat_type {
0025 DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2,
0026 DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L2,
0027 DR_ACTION_REFORMAT_TYP_TNL_L3_TO_L2,
0028 DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L3,
0029 DR_ACTION_REFORMAT_TYP_INSERT_HDR,
0030 DR_ACTION_REFORMAT_TYP_REMOVE_HDR,
0031 };
0032
0033 struct mlx5dr_match_parameters {
0034 size_t match_sz;
0035 u64 *match_buf;
0036 };
0037
0038 struct mlx5dr_action_dest {
0039 struct mlx5dr_action *dest;
0040 struct mlx5dr_action *reformat;
0041 };
0042
0043 struct mlx5dr_domain *
0044 mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type);
0045
0046 int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);
0047
0048 int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);
0049
0050 void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
0051 struct mlx5dr_domain *peer_dmn);
0052
0053 struct mlx5dr_table *
0054 mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags,
0055 u16 uid);
0056
0057 struct mlx5dr_table *
0058 mlx5dr_table_get_from_fs_ft(struct mlx5_flow_table *ft);
0059
0060 int mlx5dr_table_destroy(struct mlx5dr_table *table);
0061
0062 u32 mlx5dr_table_get_id(struct mlx5dr_table *table);
0063
0064 struct mlx5dr_matcher *
0065 mlx5dr_matcher_create(struct mlx5dr_table *table,
0066 u32 priority,
0067 u8 match_criteria_enable,
0068 struct mlx5dr_match_parameters *mask);
0069
0070 int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);
0071
0072 struct mlx5dr_rule *
0073 mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
0074 struct mlx5dr_match_parameters *value,
0075 size_t num_actions,
0076 struct mlx5dr_action *actions[],
0077 u32 flow_source);
0078
0079 int mlx5dr_rule_destroy(struct mlx5dr_rule *rule);
0080
0081 int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
0082 struct mlx5dr_action *action);
0083
0084 struct mlx5dr_action *
0085 mlx5dr_action_create_dest_table_num(struct mlx5dr_domain *dmn, u32 table_num);
0086
0087 struct mlx5dr_action *
0088 mlx5dr_action_create_dest_table(struct mlx5dr_table *table);
0089
0090 struct mlx5dr_action *
0091 mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain,
0092 struct mlx5_flow_table *ft);
0093
0094 struct mlx5dr_action *
0095 mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
0096 u16 vport, u8 vhca_id_valid,
0097 u16 vhca_id);
0098
0099 struct mlx5dr_action *
0100 mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn,
0101 struct mlx5dr_action_dest *dests,
0102 u32 num_of_dests,
0103 bool ignore_flow_level,
0104 u32 flow_source);
0105
0106 struct mlx5dr_action *mlx5dr_action_create_drop(void);
0107
0108 struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);
0109
0110 struct mlx5dr_action *
0111 mlx5dr_action_create_flow_sampler(struct mlx5dr_domain *dmn, u32 sampler_id);
0112
0113 struct mlx5dr_action *
0114 mlx5dr_action_create_flow_counter(u32 counter_id);
0115
0116 struct mlx5dr_action *
0117 mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
0118 enum mlx5dr_action_reformat_type reformat_type,
0119 u8 reformat_param_0,
0120 u8 reformat_param_1,
0121 size_t data_sz,
0122 void *data);
0123
0124 struct mlx5dr_action *
0125 mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
0126 u32 flags,
0127 size_t actions_sz,
0128 __be64 actions[]);
0129
0130 struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void);
0131
0132 struct mlx5dr_action *
0133 mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr);
0134
0135 struct mlx5dr_action *
0136 mlx5dr_action_create_aso(struct mlx5dr_domain *dmn,
0137 u32 obj_id,
0138 u8 return_reg_id,
0139 u8 aso_type,
0140 u8 init_color,
0141 u8 meter_id);
0142
0143 int mlx5dr_action_destroy(struct mlx5dr_action *action);
0144
0145 static inline bool
0146 mlx5dr_is_supported(struct mlx5_core_dev *dev)
0147 {
0148 return MLX5_CAP_GEN(dev, roce) &&
0149 (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner) ||
0150 (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner_v2) &&
0151 (MLX5_CAP_GEN(dev, steering_format_version) <=
0152 MLX5_STEERING_FORMAT_CONNECTX_7)));
0153 }
0154
0155
0156
0157 struct mlx5dr_icm_mr;
0158
0159 struct mlx5dr_icm_buddy_mem {
0160 unsigned long **bitmap;
0161 unsigned int *num_free;
0162 u32 max_order;
0163 struct list_head list_node;
0164 struct mlx5dr_icm_mr *icm_mr;
0165 struct mlx5dr_icm_pool *pool;
0166
0167
0168 struct list_head used_list;
0169 u64 used_memory;
0170
0171
0172
0173
0174
0175 struct list_head hot_list;
0176
0177
0178 struct mlx5dr_ste *ste_arr;
0179 struct list_head *miss_list;
0180 u8 *hw_ste_arr;
0181 };
0182
0183 int mlx5dr_buddy_init(struct mlx5dr_icm_buddy_mem *buddy,
0184 unsigned int max_order);
0185 void mlx5dr_buddy_cleanup(struct mlx5dr_icm_buddy_mem *buddy);
0186 int mlx5dr_buddy_alloc_mem(struct mlx5dr_icm_buddy_mem *buddy,
0187 unsigned int order,
0188 unsigned int *segment);
0189 void mlx5dr_buddy_free_mem(struct mlx5dr_icm_buddy_mem *buddy,
0190 unsigned int seg, unsigned int order);
0191
0192 #endif