0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #ifndef _MLX5_FS_
0034 #define _MLX5_FS_
0035
0036 #include <linux/mlx5/driver.h>
0037 #include <linux/mlx5/mlx5_ifc.h>
0038
0039 #define MLX5_FS_DEFAULT_FLOW_TAG 0x0
0040
0041 #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
0042
0043 enum mlx5_flow_destination_type {
0044 MLX5_FLOW_DESTINATION_TYPE_NONE,
0045 MLX5_FLOW_DESTINATION_TYPE_VPORT,
0046 MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE,
0047 MLX5_FLOW_DESTINATION_TYPE_TIR,
0048 MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER,
0049 MLX5_FLOW_DESTINATION_TYPE_UPLINK,
0050 MLX5_FLOW_DESTINATION_TYPE_PORT,
0051 MLX5_FLOW_DESTINATION_TYPE_COUNTER,
0052 MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM,
0053 };
0054
0055 enum {
0056 MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO = 1 << 16,
0057 MLX5_FLOW_CONTEXT_ACTION_ENCRYPT = 1 << 17,
0058 MLX5_FLOW_CONTEXT_ACTION_DECRYPT = 1 << 18,
0059 MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS = 1 << 19,
0060 };
0061
0062 enum {
0063 MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT = BIT(0),
0064 MLX5_FLOW_TABLE_TUNNEL_EN_DECAP = BIT(1),
0065 MLX5_FLOW_TABLE_TERMINATION = BIT(2),
0066 MLX5_FLOW_TABLE_UNMANAGED = BIT(3),
0067 MLX5_FLOW_TABLE_OTHER_VPORT = BIT(4),
0068 };
0069
0070 #define LEFTOVERS_RULE_NUM 2
0071 static inline void build_leftovers_ft_param(int *priority,
0072 int *n_ent,
0073 int *n_grp)
0074 {
0075 *priority = 0;
0076 *n_ent = LEFTOVERS_RULE_NUM;
0077 *n_grp = LEFTOVERS_RULE_NUM;
0078 }
0079
0080 enum mlx5_flow_namespace_type {
0081 MLX5_FLOW_NAMESPACE_BYPASS,
0082 MLX5_FLOW_NAMESPACE_LAG,
0083 MLX5_FLOW_NAMESPACE_OFFLOADS,
0084 MLX5_FLOW_NAMESPACE_ETHTOOL,
0085 MLX5_FLOW_NAMESPACE_KERNEL,
0086 MLX5_FLOW_NAMESPACE_LEFTOVERS,
0087 MLX5_FLOW_NAMESPACE_ANCHOR,
0088 MLX5_FLOW_NAMESPACE_FDB_BYPASS,
0089 MLX5_FLOW_NAMESPACE_FDB,
0090 MLX5_FLOW_NAMESPACE_ESW_EGRESS,
0091 MLX5_FLOW_NAMESPACE_ESW_INGRESS,
0092 MLX5_FLOW_NAMESPACE_SNIFFER_RX,
0093 MLX5_FLOW_NAMESPACE_SNIFFER_TX,
0094 MLX5_FLOW_NAMESPACE_EGRESS,
0095 MLX5_FLOW_NAMESPACE_EGRESS_KERNEL,
0096 MLX5_FLOW_NAMESPACE_RDMA_RX,
0097 MLX5_FLOW_NAMESPACE_RDMA_RX_KERNEL,
0098 MLX5_FLOW_NAMESPACE_RDMA_TX,
0099 MLX5_FLOW_NAMESPACE_PORT_SEL,
0100 MLX5_FLOW_NAMESPACE_RDMA_RX_COUNTERS,
0101 MLX5_FLOW_NAMESPACE_RDMA_TX_COUNTERS,
0102 };
0103
0104 enum {
0105 FDB_BYPASS_PATH,
0106 FDB_TC_OFFLOAD,
0107 FDB_FT_OFFLOAD,
0108 FDB_TC_MISS,
0109 FDB_BR_OFFLOAD,
0110 FDB_SLOW_PATH,
0111 FDB_PER_VPORT,
0112 };
0113
0114 struct mlx5_pkt_reformat;
0115 struct mlx5_modify_hdr;
0116 struct mlx5_flow_definer;
0117 struct mlx5_flow_table;
0118 struct mlx5_flow_group;
0119 struct mlx5_flow_namespace;
0120 struct mlx5_flow_handle;
0121
0122 enum {
0123 FLOW_CONTEXT_HAS_TAG = BIT(0),
0124 };
0125
0126 struct mlx5_flow_context {
0127 u32 flags;
0128 u32 flow_tag;
0129 u32 flow_source;
0130 };
0131
0132 struct mlx5_flow_spec {
0133 u8 match_criteria_enable;
0134 u32 match_criteria[MLX5_ST_SZ_DW(fte_match_param)];
0135 u32 match_value[MLX5_ST_SZ_DW(fte_match_param)];
0136 struct mlx5_flow_context flow_context;
0137 };
0138
0139 enum {
0140 MLX5_FLOW_DEST_VPORT_VHCA_ID = BIT(0),
0141 MLX5_FLOW_DEST_VPORT_REFORMAT_ID = BIT(1),
0142 };
0143
0144 struct mlx5_flow_destination {
0145 enum mlx5_flow_destination_type type;
0146 union {
0147 u32 tir_num;
0148 u32 ft_num;
0149 struct mlx5_flow_table *ft;
0150 u32 counter_id;
0151 struct {
0152 u16 num;
0153 u16 vhca_id;
0154 struct mlx5_pkt_reformat *pkt_reformat;
0155 u8 flags;
0156 } vport;
0157 u32 sampler_id;
0158 };
0159 };
0160
0161 struct mod_hdr_tbl {
0162 struct mutex lock;
0163 DECLARE_HASHTABLE(hlist, 8);
0164 };
0165
0166 struct mlx5_flow_namespace *
0167 mlx5_get_fdb_sub_ns(struct mlx5_core_dev *dev, int n);
0168 struct mlx5_flow_namespace *
0169 mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
0170 enum mlx5_flow_namespace_type type);
0171 struct mlx5_flow_namespace *
0172 mlx5_get_flow_vport_acl_namespace(struct mlx5_core_dev *dev,
0173 enum mlx5_flow_namespace_type type,
0174 int vport);
0175
0176 struct mlx5_flow_table_attr {
0177 int prio;
0178 int max_fte;
0179 u32 level;
0180 u32 flags;
0181 u16 uid;
0182 struct mlx5_flow_table *next_ft;
0183
0184 struct {
0185 int max_num_groups;
0186 int num_reserved_entries;
0187 } autogroup;
0188 };
0189
0190 struct mlx5_flow_table *
0191 mlx5_create_flow_table(struct mlx5_flow_namespace *ns,
0192 struct mlx5_flow_table_attr *ft_attr);
0193
0194 struct mlx5_flow_table *
0195 mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
0196 struct mlx5_flow_table_attr *ft_attr);
0197
0198 struct mlx5_flow_table *
0199 mlx5_create_vport_flow_table(struct mlx5_flow_namespace *ns,
0200 struct mlx5_flow_table_attr *ft_attr, u16 vport);
0201 struct mlx5_flow_table *mlx5_create_lag_demux_flow_table(
0202 struct mlx5_flow_namespace *ns,
0203 int prio, u32 level);
0204 int mlx5_destroy_flow_table(struct mlx5_flow_table *ft);
0205
0206
0207
0208
0209
0210
0211
0212 struct mlx5_flow_group *
0213 mlx5_create_flow_group(struct mlx5_flow_table *ft, u32 *in);
0214 void mlx5_destroy_flow_group(struct mlx5_flow_group *fg);
0215
0216 struct mlx5_exe_aso {
0217 u32 object_id;
0218 u8 type;
0219 u8 return_reg_id;
0220 union {
0221 u32 ctrl_data;
0222 struct {
0223 u8 meter_idx;
0224 u8 init_color;
0225 } flow_meter;
0226 };
0227 };
0228
0229 struct mlx5_fs_vlan {
0230 u16 ethtype;
0231 u16 vid;
0232 u8 prio;
0233 };
0234
0235 #define MLX5_FS_VLAN_DEPTH 2
0236
0237 enum {
0238 FLOW_ACT_NO_APPEND = BIT(0),
0239 FLOW_ACT_IGNORE_FLOW_LEVEL = BIT(1),
0240 };
0241
0242 struct mlx5_flow_act {
0243 u32 action;
0244 struct mlx5_modify_hdr *modify_hdr;
0245 struct mlx5_pkt_reformat *pkt_reformat;
0246 union {
0247 u32 ipsec_obj_id;
0248 uintptr_t esp_id;
0249 };
0250 u32 flags;
0251 struct mlx5_fs_vlan vlan[MLX5_FS_VLAN_DEPTH];
0252 struct ib_counters *counters;
0253 struct mlx5_flow_group *fg;
0254 struct mlx5_exe_aso exe_aso;
0255 };
0256
0257 #define MLX5_DECLARE_FLOW_ACT(name) \
0258 struct mlx5_flow_act name = { .action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\
0259 .flags = 0, }
0260
0261
0262
0263
0264 struct mlx5_flow_handle *
0265 mlx5_add_flow_rules(struct mlx5_flow_table *ft,
0266 const struct mlx5_flow_spec *spec,
0267 struct mlx5_flow_act *flow_act,
0268 struct mlx5_flow_destination *dest,
0269 int num_dest);
0270 void mlx5_del_flow_rules(struct mlx5_flow_handle *fr);
0271
0272 int mlx5_modify_rule_destination(struct mlx5_flow_handle *handler,
0273 struct mlx5_flow_destination *new_dest,
0274 struct mlx5_flow_destination *old_dest);
0275
0276 struct mlx5_fc *mlx5_fc_create(struct mlx5_core_dev *dev, bool aging);
0277
0278
0279 struct mlx5_fc *mlx5_fc_create_ex(struct mlx5_core_dev *dev, bool aging);
0280
0281 void mlx5_fc_destroy(struct mlx5_core_dev *dev, struct mlx5_fc *counter);
0282 u64 mlx5_fc_query_lastuse(struct mlx5_fc *counter);
0283 void mlx5_fc_query_cached(struct mlx5_fc *counter,
0284 u64 *bytes, u64 *packets, u64 *lastuse);
0285 int mlx5_fc_query(struct mlx5_core_dev *dev, struct mlx5_fc *counter,
0286 u64 *packets, u64 *bytes);
0287 u32 mlx5_fc_id(struct mlx5_fc *counter);
0288
0289 int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn);
0290 int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn);
0291
0292 struct mlx5_modify_hdr *mlx5_modify_header_alloc(struct mlx5_core_dev *dev,
0293 u8 ns_type, u8 num_actions,
0294 void *modify_actions);
0295 void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev,
0296 struct mlx5_modify_hdr *modify_hdr);
0297 struct mlx5_flow_definer *
0298 mlx5_create_match_definer(struct mlx5_core_dev *dev,
0299 enum mlx5_flow_namespace_type ns_type, u16 format_id,
0300 u32 *match_mask);
0301 void mlx5_destroy_match_definer(struct mlx5_core_dev *dev,
0302 struct mlx5_flow_definer *definer);
0303 int mlx5_get_match_definer_id(struct mlx5_flow_definer *definer);
0304
0305 struct mlx5_pkt_reformat_params {
0306 int type;
0307 u8 param_0;
0308 u8 param_1;
0309 size_t size;
0310 void *data;
0311 };
0312
0313 struct mlx5_pkt_reformat *mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev,
0314 struct mlx5_pkt_reformat_params *params,
0315 enum mlx5_flow_namespace_type ns_type);
0316 void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev,
0317 struct mlx5_pkt_reformat *reformat);
0318
0319 u32 mlx5_flow_table_id(struct mlx5_flow_table *ft);
0320 #endif