| .. | .. |
|---|
| 39 | 39 | #include "mlx5_core.h" |
|---|
| 40 | 40 | #include "eswitch.h" |
|---|
| 41 | 41 | |
|---|
| 42 | | -static int mlx5_cmd_stub_update_root_ft(struct mlx5_core_dev *dev, |
|---|
| 42 | +static int mlx5_cmd_stub_update_root_ft(struct mlx5_flow_root_namespace *ns, |
|---|
| 43 | 43 | struct mlx5_flow_table *ft, |
|---|
| 44 | 44 | u32 underlay_qpn, |
|---|
| 45 | 45 | bool disconnect) |
|---|
| .. | .. |
|---|
| 47 | 47 | return 0; |
|---|
| 48 | 48 | } |
|---|
| 49 | 49 | |
|---|
| 50 | | -static int mlx5_cmd_stub_create_flow_table(struct mlx5_core_dev *dev, |
|---|
| 51 | | - u16 vport, |
|---|
| 52 | | - enum fs_flow_table_op_mod op_mod, |
|---|
| 53 | | - enum fs_flow_table_type type, |
|---|
| 54 | | - unsigned int level, |
|---|
| 50 | +static int mlx5_cmd_stub_create_flow_table(struct mlx5_flow_root_namespace *ns, |
|---|
| 51 | + struct mlx5_flow_table *ft, |
|---|
| 55 | 52 | unsigned int log_size, |
|---|
| 56 | | - struct mlx5_flow_table *next_ft, |
|---|
| 57 | | - unsigned int *table_id, u32 flags) |
|---|
| 53 | + struct mlx5_flow_table *next_ft) |
|---|
| 58 | 54 | { |
|---|
| 59 | 55 | return 0; |
|---|
| 60 | 56 | } |
|---|
| 61 | 57 | |
|---|
| 62 | | -static int mlx5_cmd_stub_destroy_flow_table(struct mlx5_core_dev *dev, |
|---|
| 58 | +static int mlx5_cmd_stub_destroy_flow_table(struct mlx5_flow_root_namespace *ns, |
|---|
| 63 | 59 | struct mlx5_flow_table *ft) |
|---|
| 64 | 60 | { |
|---|
| 65 | 61 | return 0; |
|---|
| 66 | 62 | } |
|---|
| 67 | 63 | |
|---|
| 68 | | -static int mlx5_cmd_stub_modify_flow_table(struct mlx5_core_dev *dev, |
|---|
| 64 | +static int mlx5_cmd_stub_modify_flow_table(struct mlx5_flow_root_namespace *ns, |
|---|
| 69 | 65 | struct mlx5_flow_table *ft, |
|---|
| 70 | 66 | struct mlx5_flow_table *next_ft) |
|---|
| 71 | 67 | { |
|---|
| 72 | 68 | return 0; |
|---|
| 73 | 69 | } |
|---|
| 74 | 70 | |
|---|
| 75 | | -static int mlx5_cmd_stub_create_flow_group(struct mlx5_core_dev *dev, |
|---|
| 71 | +static int mlx5_cmd_stub_create_flow_group(struct mlx5_flow_root_namespace *ns, |
|---|
| 76 | 72 | struct mlx5_flow_table *ft, |
|---|
| 77 | 73 | u32 *in, |
|---|
| 78 | | - unsigned int *group_id) |
|---|
| 74 | + struct mlx5_flow_group *fg) |
|---|
| 79 | 75 | { |
|---|
| 80 | 76 | return 0; |
|---|
| 81 | 77 | } |
|---|
| 82 | 78 | |
|---|
| 83 | | -static int mlx5_cmd_stub_destroy_flow_group(struct mlx5_core_dev *dev, |
|---|
| 79 | +static int mlx5_cmd_stub_destroy_flow_group(struct mlx5_flow_root_namespace *ns, |
|---|
| 84 | 80 | struct mlx5_flow_table *ft, |
|---|
| 85 | | - unsigned int group_id) |
|---|
| 81 | + struct mlx5_flow_group *fg) |
|---|
| 86 | 82 | { |
|---|
| 87 | 83 | return 0; |
|---|
| 88 | 84 | } |
|---|
| 89 | 85 | |
|---|
| 90 | | -static int mlx5_cmd_stub_create_fte(struct mlx5_core_dev *dev, |
|---|
| 86 | +static int mlx5_cmd_stub_create_fte(struct mlx5_flow_root_namespace *ns, |
|---|
| 91 | 87 | struct mlx5_flow_table *ft, |
|---|
| 92 | 88 | struct mlx5_flow_group *group, |
|---|
| 93 | 89 | struct fs_fte *fte) |
|---|
| .. | .. |
|---|
| 95 | 91 | return 0; |
|---|
| 96 | 92 | } |
|---|
| 97 | 93 | |
|---|
| 98 | | -static int mlx5_cmd_stub_update_fte(struct mlx5_core_dev *dev, |
|---|
| 94 | +static int mlx5_cmd_stub_update_fte(struct mlx5_flow_root_namespace *ns, |
|---|
| 99 | 95 | struct mlx5_flow_table *ft, |
|---|
| 100 | | - unsigned int group_id, |
|---|
| 96 | + struct mlx5_flow_group *group, |
|---|
| 101 | 97 | int modify_mask, |
|---|
| 102 | 98 | struct fs_fte *fte) |
|---|
| 103 | 99 | { |
|---|
| 104 | 100 | return -EOPNOTSUPP; |
|---|
| 105 | 101 | } |
|---|
| 106 | 102 | |
|---|
| 107 | | -static int mlx5_cmd_stub_delete_fte(struct mlx5_core_dev *dev, |
|---|
| 103 | +static int mlx5_cmd_stub_delete_fte(struct mlx5_flow_root_namespace *ns, |
|---|
| 108 | 104 | struct mlx5_flow_table *ft, |
|---|
| 109 | 105 | struct fs_fte *fte) |
|---|
| 110 | 106 | { |
|---|
| 111 | 107 | return 0; |
|---|
| 112 | 108 | } |
|---|
| 113 | 109 | |
|---|
| 114 | | -static int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev, |
|---|
| 110 | +static int mlx5_cmd_stub_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 111 | + int reformat_type, |
|---|
| 112 | + size_t size, |
|---|
| 113 | + void *reformat_data, |
|---|
| 114 | + enum mlx5_flow_namespace_type namespace, |
|---|
| 115 | + struct mlx5_pkt_reformat *pkt_reformat) |
|---|
| 116 | +{ |
|---|
| 117 | + return 0; |
|---|
| 118 | +} |
|---|
| 119 | + |
|---|
| 120 | +static void mlx5_cmd_stub_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 121 | + struct mlx5_pkt_reformat *pkt_reformat) |
|---|
| 122 | +{ |
|---|
| 123 | +} |
|---|
| 124 | + |
|---|
| 125 | +static int mlx5_cmd_stub_modify_header_alloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 126 | + u8 namespace, u8 num_actions, |
|---|
| 127 | + void *modify_actions, |
|---|
| 128 | + struct mlx5_modify_hdr *modify_hdr) |
|---|
| 129 | +{ |
|---|
| 130 | + return 0; |
|---|
| 131 | +} |
|---|
| 132 | + |
|---|
| 133 | +static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 134 | + struct mlx5_modify_hdr *modify_hdr) |
|---|
| 135 | +{ |
|---|
| 136 | +} |
|---|
| 137 | + |
|---|
| 138 | +static int mlx5_cmd_stub_set_peer(struct mlx5_flow_root_namespace *ns, |
|---|
| 139 | + struct mlx5_flow_root_namespace *peer_ns) |
|---|
| 140 | +{ |
|---|
| 141 | + return 0; |
|---|
| 142 | +} |
|---|
| 143 | + |
|---|
| 144 | +static int mlx5_cmd_stub_create_ns(struct mlx5_flow_root_namespace *ns) |
|---|
| 145 | +{ |
|---|
| 146 | + return 0; |
|---|
| 147 | +} |
|---|
| 148 | + |
|---|
| 149 | +static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns) |
|---|
| 150 | +{ |
|---|
| 151 | + return 0; |
|---|
| 152 | +} |
|---|
| 153 | + |
|---|
| 154 | +static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns, |
|---|
| 115 | 155 | struct mlx5_flow_table *ft, u32 underlay_qpn, |
|---|
| 116 | 156 | bool disconnect) |
|---|
| 117 | 157 | { |
|---|
| 118 | | - u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)] = {0}; |
|---|
| 119 | | - u32 out[MLX5_ST_SZ_DW(set_flow_table_root_out)] = {0}; |
|---|
| 158 | + u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)] = {}; |
|---|
| 159 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 120 | 160 | |
|---|
| 121 | 161 | if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) && |
|---|
| 122 | 162 | underlay_qpn == 0) |
|---|
| .. | .. |
|---|
| 126 | 166 | MLX5_CMD_OP_SET_FLOW_TABLE_ROOT); |
|---|
| 127 | 167 | MLX5_SET(set_flow_table_root_in, in, table_type, ft->type); |
|---|
| 128 | 168 | |
|---|
| 129 | | - if (disconnect) { |
|---|
| 169 | + if (disconnect) |
|---|
| 130 | 170 | MLX5_SET(set_flow_table_root_in, in, op_mod, 1); |
|---|
| 131 | | - MLX5_SET(set_flow_table_root_in, in, table_id, 0); |
|---|
| 132 | | - } else { |
|---|
| 133 | | - MLX5_SET(set_flow_table_root_in, in, op_mod, 0); |
|---|
| 171 | + else |
|---|
| 134 | 172 | MLX5_SET(set_flow_table_root_in, in, table_id, ft->id); |
|---|
| 135 | | - } |
|---|
| 136 | 173 | |
|---|
| 137 | 174 | MLX5_SET(set_flow_table_root_in, in, underlay_qpn, underlay_qpn); |
|---|
| 138 | 175 | if (ft->vport) { |
|---|
| .. | .. |
|---|
| 140 | 177 | MLX5_SET(set_flow_table_root_in, in, other_vport, 1); |
|---|
| 141 | 178 | } |
|---|
| 142 | 179 | |
|---|
| 143 | | - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 180 | + return mlx5_cmd_exec_in(dev, set_flow_table_root, in); |
|---|
| 144 | 181 | } |
|---|
| 145 | 182 | |
|---|
| 146 | | -static int mlx5_cmd_create_flow_table(struct mlx5_core_dev *dev, |
|---|
| 147 | | - u16 vport, |
|---|
| 148 | | - enum fs_flow_table_op_mod op_mod, |
|---|
| 149 | | - enum fs_flow_table_type type, |
|---|
| 150 | | - unsigned int level, |
|---|
| 183 | +static int mlx5_cmd_create_flow_table(struct mlx5_flow_root_namespace *ns, |
|---|
| 184 | + struct mlx5_flow_table *ft, |
|---|
| 151 | 185 | unsigned int log_size, |
|---|
| 152 | | - struct mlx5_flow_table *next_ft, |
|---|
| 153 | | - unsigned int *table_id, u32 flags) |
|---|
| 186 | + struct mlx5_flow_table *next_ft) |
|---|
| 154 | 187 | { |
|---|
| 155 | | - int en_encap_decap = !!(flags & MLX5_FLOW_TABLE_TUNNEL_EN); |
|---|
| 156 | | - u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {0}; |
|---|
| 157 | | - u32 in[MLX5_ST_SZ_DW(create_flow_table_in)] = {0}; |
|---|
| 188 | + int en_encap = !!(ft->flags & MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT); |
|---|
| 189 | + int en_decap = !!(ft->flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP); |
|---|
| 190 | + int term = !!(ft->flags & MLX5_FLOW_TABLE_TERMINATION); |
|---|
| 191 | + u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {}; |
|---|
| 192 | + u32 in[MLX5_ST_SZ_DW(create_flow_table_in)] = {}; |
|---|
| 193 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 158 | 194 | int err; |
|---|
| 159 | 195 | |
|---|
| 160 | 196 | MLX5_SET(create_flow_table_in, in, opcode, |
|---|
| 161 | 197 | MLX5_CMD_OP_CREATE_FLOW_TABLE); |
|---|
| 162 | 198 | |
|---|
| 163 | | - MLX5_SET(create_flow_table_in, in, table_type, type); |
|---|
| 164 | | - MLX5_SET(create_flow_table_in, in, flow_table_context.level, level); |
|---|
| 199 | + MLX5_SET(create_flow_table_in, in, table_type, ft->type); |
|---|
| 200 | + MLX5_SET(create_flow_table_in, in, flow_table_context.level, ft->level); |
|---|
| 165 | 201 | MLX5_SET(create_flow_table_in, in, flow_table_context.log_size, log_size); |
|---|
| 166 | | - if (vport) { |
|---|
| 167 | | - MLX5_SET(create_flow_table_in, in, vport_number, vport); |
|---|
| 202 | + if (ft->vport) { |
|---|
| 203 | + MLX5_SET(create_flow_table_in, in, vport_number, ft->vport); |
|---|
| 168 | 204 | MLX5_SET(create_flow_table_in, in, other_vport, 1); |
|---|
| 169 | 205 | } |
|---|
| 170 | 206 | |
|---|
| 171 | 207 | MLX5_SET(create_flow_table_in, in, flow_table_context.decap_en, |
|---|
| 172 | | - en_encap_decap); |
|---|
| 173 | | - MLX5_SET(create_flow_table_in, in, flow_table_context.encap_en, |
|---|
| 174 | | - en_encap_decap); |
|---|
| 208 | + en_decap); |
|---|
| 209 | + MLX5_SET(create_flow_table_in, in, flow_table_context.reformat_en, |
|---|
| 210 | + en_encap); |
|---|
| 211 | + MLX5_SET(create_flow_table_in, in, flow_table_context.termination_table, |
|---|
| 212 | + term); |
|---|
| 175 | 213 | |
|---|
| 176 | | - switch (op_mod) { |
|---|
| 214 | + switch (ft->op_mod) { |
|---|
| 177 | 215 | case FS_FT_OP_MOD_NORMAL: |
|---|
| 178 | 216 | if (next_ft) { |
|---|
| 179 | 217 | MLX5_SET(create_flow_table_in, in, |
|---|
| 180 | | - flow_table_context.table_miss_action, 1); |
|---|
| 218 | + flow_table_context.table_miss_action, |
|---|
| 219 | + MLX5_FLOW_TABLE_MISS_ACTION_FWD); |
|---|
| 181 | 220 | MLX5_SET(create_flow_table_in, in, |
|---|
| 182 | 221 | flow_table_context.table_miss_id, next_ft->id); |
|---|
| 222 | + } else { |
|---|
| 223 | + MLX5_SET(create_flow_table_in, in, |
|---|
| 224 | + flow_table_context.table_miss_action, |
|---|
| 225 | + ft->def_miss_action); |
|---|
| 183 | 226 | } |
|---|
| 184 | 227 | break; |
|---|
| 185 | 228 | |
|---|
| .. | .. |
|---|
| 192 | 235 | break; |
|---|
| 193 | 236 | } |
|---|
| 194 | 237 | |
|---|
| 195 | | - err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 238 | + err = mlx5_cmd_exec_inout(dev, create_flow_table, in, out); |
|---|
| 196 | 239 | if (!err) |
|---|
| 197 | | - *table_id = MLX5_GET(create_flow_table_out, out, |
|---|
| 198 | | - table_id); |
|---|
| 240 | + ft->id = MLX5_GET(create_flow_table_out, out, |
|---|
| 241 | + table_id); |
|---|
| 199 | 242 | return err; |
|---|
| 200 | 243 | } |
|---|
| 201 | 244 | |
|---|
| 202 | | -static int mlx5_cmd_destroy_flow_table(struct mlx5_core_dev *dev, |
|---|
| 245 | +static int mlx5_cmd_destroy_flow_table(struct mlx5_flow_root_namespace *ns, |
|---|
| 203 | 246 | struct mlx5_flow_table *ft) |
|---|
| 204 | 247 | { |
|---|
| 205 | | - u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)] = {0}; |
|---|
| 206 | | - u32 out[MLX5_ST_SZ_DW(destroy_flow_table_out)] = {0}; |
|---|
| 248 | + u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)] = {}; |
|---|
| 249 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 207 | 250 | |
|---|
| 208 | 251 | MLX5_SET(destroy_flow_table_in, in, opcode, |
|---|
| 209 | 252 | MLX5_CMD_OP_DESTROY_FLOW_TABLE); |
|---|
| .. | .. |
|---|
| 214 | 257 | MLX5_SET(destroy_flow_table_in, in, other_vport, 1); |
|---|
| 215 | 258 | } |
|---|
| 216 | 259 | |
|---|
| 217 | | - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 260 | + return mlx5_cmd_exec_in(dev, destroy_flow_table, in); |
|---|
| 218 | 261 | } |
|---|
| 219 | 262 | |
|---|
| 220 | | -static int mlx5_cmd_modify_flow_table(struct mlx5_core_dev *dev, |
|---|
| 263 | +static int mlx5_cmd_modify_flow_table(struct mlx5_flow_root_namespace *ns, |
|---|
| 221 | 264 | struct mlx5_flow_table *ft, |
|---|
| 222 | 265 | struct mlx5_flow_table *next_ft) |
|---|
| 223 | 266 | { |
|---|
| 224 | | - u32 in[MLX5_ST_SZ_DW(modify_flow_table_in)] = {0}; |
|---|
| 225 | | - u32 out[MLX5_ST_SZ_DW(modify_flow_table_out)] = {0}; |
|---|
| 267 | + u32 in[MLX5_ST_SZ_DW(modify_flow_table_in)] = {}; |
|---|
| 268 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 226 | 269 | |
|---|
| 227 | 270 | MLX5_SET(modify_flow_table_in, in, opcode, |
|---|
| 228 | 271 | MLX5_CMD_OP_MODIFY_FLOW_TABLE); |
|---|
| .. | .. |
|---|
| 249 | 292 | MLX5_MODIFY_FLOW_TABLE_MISS_TABLE_ID); |
|---|
| 250 | 293 | if (next_ft) { |
|---|
| 251 | 294 | MLX5_SET(modify_flow_table_in, in, |
|---|
| 252 | | - flow_table_context.table_miss_action, 1); |
|---|
| 295 | + flow_table_context.table_miss_action, |
|---|
| 296 | + MLX5_FLOW_TABLE_MISS_ACTION_FWD); |
|---|
| 253 | 297 | MLX5_SET(modify_flow_table_in, in, |
|---|
| 254 | 298 | flow_table_context.table_miss_id, |
|---|
| 255 | 299 | next_ft->id); |
|---|
| 256 | 300 | } else { |
|---|
| 257 | 301 | MLX5_SET(modify_flow_table_in, in, |
|---|
| 258 | | - flow_table_context.table_miss_action, 0); |
|---|
| 302 | + flow_table_context.table_miss_action, |
|---|
| 303 | + ft->def_miss_action); |
|---|
| 259 | 304 | } |
|---|
| 260 | 305 | } |
|---|
| 261 | 306 | |
|---|
| 262 | | - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 307 | + return mlx5_cmd_exec_in(dev, modify_flow_table, in); |
|---|
| 263 | 308 | } |
|---|
| 264 | 309 | |
|---|
| 265 | | -static int mlx5_cmd_create_flow_group(struct mlx5_core_dev *dev, |
|---|
| 310 | +static int mlx5_cmd_create_flow_group(struct mlx5_flow_root_namespace *ns, |
|---|
| 266 | 311 | struct mlx5_flow_table *ft, |
|---|
| 267 | 312 | u32 *in, |
|---|
| 268 | | - unsigned int *group_id) |
|---|
| 313 | + struct mlx5_flow_group *fg) |
|---|
| 269 | 314 | { |
|---|
| 270 | | - u32 out[MLX5_ST_SZ_DW(create_flow_group_out)] = {0}; |
|---|
| 271 | | - int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); |
|---|
| 315 | + u32 out[MLX5_ST_SZ_DW(create_flow_group_out)] = {}; |
|---|
| 316 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 272 | 317 | int err; |
|---|
| 273 | 318 | |
|---|
| 274 | 319 | MLX5_SET(create_flow_group_in, in, opcode, |
|---|
| .. | .. |
|---|
| 280 | 325 | MLX5_SET(create_flow_group_in, in, other_vport, 1); |
|---|
| 281 | 326 | } |
|---|
| 282 | 327 | |
|---|
| 283 | | - err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
|---|
| 328 | + err = mlx5_cmd_exec_inout(dev, create_flow_group, in, out); |
|---|
| 284 | 329 | if (!err) |
|---|
| 285 | | - *group_id = MLX5_GET(create_flow_group_out, out, |
|---|
| 286 | | - group_id); |
|---|
| 330 | + fg->id = MLX5_GET(create_flow_group_out, out, |
|---|
| 331 | + group_id); |
|---|
| 287 | 332 | return err; |
|---|
| 288 | 333 | } |
|---|
| 289 | 334 | |
|---|
| 290 | | -static int mlx5_cmd_destroy_flow_group(struct mlx5_core_dev *dev, |
|---|
| 335 | +static int mlx5_cmd_destroy_flow_group(struct mlx5_flow_root_namespace *ns, |
|---|
| 291 | 336 | struct mlx5_flow_table *ft, |
|---|
| 292 | | - unsigned int group_id) |
|---|
| 337 | + struct mlx5_flow_group *fg) |
|---|
| 293 | 338 | { |
|---|
| 294 | | - u32 out[MLX5_ST_SZ_DW(destroy_flow_group_out)] = {0}; |
|---|
| 295 | | - u32 in[MLX5_ST_SZ_DW(destroy_flow_group_in)] = {0}; |
|---|
| 339 | + u32 in[MLX5_ST_SZ_DW(destroy_flow_group_in)] = {}; |
|---|
| 340 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 296 | 341 | |
|---|
| 297 | 342 | MLX5_SET(destroy_flow_group_in, in, opcode, |
|---|
| 298 | 343 | MLX5_CMD_OP_DESTROY_FLOW_GROUP); |
|---|
| 299 | 344 | MLX5_SET(destroy_flow_group_in, in, table_type, ft->type); |
|---|
| 300 | 345 | MLX5_SET(destroy_flow_group_in, in, table_id, ft->id); |
|---|
| 301 | | - MLX5_SET(destroy_flow_group_in, in, group_id, group_id); |
|---|
| 346 | + MLX5_SET(destroy_flow_group_in, in, group_id, fg->id); |
|---|
| 302 | 347 | if (ft->vport) { |
|---|
| 303 | 348 | MLX5_SET(destroy_flow_group_in, in, vport_number, ft->vport); |
|---|
| 304 | 349 | MLX5_SET(destroy_flow_group_in, in, other_vport, 1); |
|---|
| 305 | 350 | } |
|---|
| 306 | 351 | |
|---|
| 307 | | - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 352 | + return mlx5_cmd_exec_in(dev, destroy_flow_group, in); |
|---|
| 308 | 353 | } |
|---|
| 309 | 354 | |
|---|
| 355 | +static int mlx5_set_extended_dest(struct mlx5_core_dev *dev, |
|---|
| 356 | + struct fs_fte *fte, bool *extended_dest) |
|---|
| 357 | +{ |
|---|
| 358 | + int fw_log_max_fdb_encap_uplink = |
|---|
| 359 | + MLX5_CAP_ESW(dev, log_max_fdb_encap_uplink); |
|---|
| 360 | + int num_fwd_destinations = 0; |
|---|
| 361 | + struct mlx5_flow_rule *dst; |
|---|
| 362 | + int num_encap = 0; |
|---|
| 363 | + |
|---|
| 364 | + *extended_dest = false; |
|---|
| 365 | + if (!(fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST)) |
|---|
| 366 | + return 0; |
|---|
| 367 | + |
|---|
| 368 | + list_for_each_entry(dst, &fte->node.children, node.list) { |
|---|
| 369 | + if (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_COUNTER) |
|---|
| 370 | + continue; |
|---|
| 371 | + if (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT && |
|---|
| 372 | + dst->dest_attr.vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) |
|---|
| 373 | + num_encap++; |
|---|
| 374 | + num_fwd_destinations++; |
|---|
| 375 | + } |
|---|
| 376 | + if (num_fwd_destinations > 1 && num_encap > 0) |
|---|
| 377 | + *extended_dest = true; |
|---|
| 378 | + |
|---|
| 379 | + if (*extended_dest && !fw_log_max_fdb_encap_uplink) { |
|---|
| 380 | + mlx5_core_warn(dev, "FW does not support extended destination"); |
|---|
| 381 | + return -EOPNOTSUPP; |
|---|
| 382 | + } |
|---|
| 383 | + if (num_encap > (1 << fw_log_max_fdb_encap_uplink)) { |
|---|
| 384 | + mlx5_core_warn(dev, "FW does not support more than %d encaps", |
|---|
| 385 | + 1 << fw_log_max_fdb_encap_uplink); |
|---|
| 386 | + return -EOPNOTSUPP; |
|---|
| 387 | + } |
|---|
| 388 | + |
|---|
| 389 | + return 0; |
|---|
| 390 | +} |
|---|
| 310 | 391 | static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, |
|---|
| 311 | 392 | int opmod, int modify_mask, |
|---|
| 312 | 393 | struct mlx5_flow_table *ft, |
|---|
| 313 | 394 | unsigned group_id, |
|---|
| 314 | 395 | struct fs_fte *fte) |
|---|
| 315 | 396 | { |
|---|
| 316 | | - unsigned int inlen = MLX5_ST_SZ_BYTES(set_fte_in) + |
|---|
| 317 | | - fte->dests_size * MLX5_ST_SZ_BYTES(dest_format_struct); |
|---|
| 318 | 397 | u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0}; |
|---|
| 398 | + bool extended_dest = false; |
|---|
| 319 | 399 | struct mlx5_flow_rule *dst; |
|---|
| 320 | 400 | void *in_flow_context, *vlan; |
|---|
| 321 | 401 | void *in_match_value; |
|---|
| 402 | + unsigned int inlen; |
|---|
| 403 | + int dst_cnt_size; |
|---|
| 322 | 404 | void *in_dests; |
|---|
| 323 | 405 | u32 *in; |
|---|
| 324 | 406 | int err; |
|---|
| 325 | 407 | |
|---|
| 408 | + if (mlx5_set_extended_dest(dev, fte, &extended_dest)) |
|---|
| 409 | + return -EOPNOTSUPP; |
|---|
| 410 | + |
|---|
| 411 | + if (!extended_dest) |
|---|
| 412 | + dst_cnt_size = MLX5_ST_SZ_BYTES(dest_format_struct); |
|---|
| 413 | + else |
|---|
| 414 | + dst_cnt_size = MLX5_ST_SZ_BYTES(extended_dest_format); |
|---|
| 415 | + |
|---|
| 416 | + inlen = MLX5_ST_SZ_BYTES(set_fte_in) + fte->dests_size * dst_cnt_size; |
|---|
| 326 | 417 | in = kvzalloc(inlen, GFP_KERNEL); |
|---|
| 327 | 418 | if (!in) |
|---|
| 328 | 419 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 333 | 424 | MLX5_SET(set_fte_in, in, table_type, ft->type); |
|---|
| 334 | 425 | MLX5_SET(set_fte_in, in, table_id, ft->id); |
|---|
| 335 | 426 | MLX5_SET(set_fte_in, in, flow_index, fte->index); |
|---|
| 427 | + MLX5_SET(set_fte_in, in, ignore_flow_level, |
|---|
| 428 | + !!(fte->action.flags & FLOW_ACT_IGNORE_FLOW_LEVEL)); |
|---|
| 429 | + |
|---|
| 336 | 430 | if (ft->vport) { |
|---|
| 337 | 431 | MLX5_SET(set_fte_in, in, vport_number, ft->vport); |
|---|
| 338 | 432 | MLX5_SET(set_fte_in, in, other_vport, 1); |
|---|
| .. | .. |
|---|
| 341 | 435 | in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); |
|---|
| 342 | 436 | MLX5_SET(flow_context, in_flow_context, group_id, group_id); |
|---|
| 343 | 437 | |
|---|
| 344 | | - MLX5_SET(flow_context, in_flow_context, flow_tag, fte->action.flow_tag); |
|---|
| 345 | | - MLX5_SET(flow_context, in_flow_context, action, fte->action.action); |
|---|
| 346 | | - MLX5_SET(flow_context, in_flow_context, encap_id, fte->action.encap_id); |
|---|
| 347 | | - MLX5_SET(flow_context, in_flow_context, modify_header_id, |
|---|
| 348 | | - fte->action.modify_id); |
|---|
| 438 | + MLX5_SET(flow_context, in_flow_context, flow_tag, |
|---|
| 439 | + fte->flow_context.flow_tag); |
|---|
| 440 | + MLX5_SET(flow_context, in_flow_context, flow_source, |
|---|
| 441 | + fte->flow_context.flow_source); |
|---|
| 442 | + |
|---|
| 443 | + MLX5_SET(flow_context, in_flow_context, extended_destination, |
|---|
| 444 | + extended_dest); |
|---|
| 445 | + if (extended_dest) { |
|---|
| 446 | + u32 action; |
|---|
| 447 | + |
|---|
| 448 | + action = fte->action.action & |
|---|
| 449 | + ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; |
|---|
| 450 | + MLX5_SET(flow_context, in_flow_context, action, action); |
|---|
| 451 | + } else { |
|---|
| 452 | + MLX5_SET(flow_context, in_flow_context, action, |
|---|
| 453 | + fte->action.action); |
|---|
| 454 | + if (fte->action.pkt_reformat) |
|---|
| 455 | + MLX5_SET(flow_context, in_flow_context, packet_reformat_id, |
|---|
| 456 | + fte->action.pkt_reformat->id); |
|---|
| 457 | + } |
|---|
| 458 | + if (fte->action.modify_hdr) |
|---|
| 459 | + MLX5_SET(flow_context, in_flow_context, modify_header_id, |
|---|
| 460 | + fte->action.modify_hdr->id); |
|---|
| 461 | + |
|---|
| 462 | + MLX5_SET(flow_context, in_flow_context, ipsec_obj_id, fte->action.ipsec_obj_id); |
|---|
| 349 | 463 | |
|---|
| 350 | 464 | vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan); |
|---|
| 351 | 465 | |
|---|
| .. | .. |
|---|
| 385 | 499 | id = dst->dest_attr.vport.num; |
|---|
| 386 | 500 | MLX5_SET(dest_format_struct, in_dests, |
|---|
| 387 | 501 | destination_eswitch_owner_vhca_id_valid, |
|---|
| 388 | | - dst->dest_attr.vport.vhca_id_valid); |
|---|
| 502 | + !!(dst->dest_attr.vport.flags & |
|---|
| 503 | + MLX5_FLOW_DEST_VPORT_VHCA_ID)); |
|---|
| 389 | 504 | MLX5_SET(dest_format_struct, in_dests, |
|---|
| 390 | 505 | destination_eswitch_owner_vhca_id, |
|---|
| 391 | 506 | dst->dest_attr.vport.vhca_id); |
|---|
| 507 | + if (extended_dest && |
|---|
| 508 | + dst->dest_attr.vport.pkt_reformat) { |
|---|
| 509 | + MLX5_SET(dest_format_struct, in_dests, |
|---|
| 510 | + packet_reformat, |
|---|
| 511 | + !!(dst->dest_attr.vport.flags & |
|---|
| 512 | + MLX5_FLOW_DEST_VPORT_REFORMAT_ID)); |
|---|
| 513 | + MLX5_SET(extended_dest_format, in_dests, |
|---|
| 514 | + packet_reformat_id, |
|---|
| 515 | + dst->dest_attr.vport.pkt_reformat->id); |
|---|
| 516 | + } |
|---|
| 392 | 517 | break; |
|---|
| 393 | 518 | default: |
|---|
| 394 | 519 | id = dst->dest_attr.tir_num; |
|---|
| .. | .. |
|---|
| 397 | 522 | MLX5_SET(dest_format_struct, in_dests, destination_type, |
|---|
| 398 | 523 | type); |
|---|
| 399 | 524 | MLX5_SET(dest_format_struct, in_dests, destination_id, id); |
|---|
| 400 | | - in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); |
|---|
| 525 | + in_dests += dst_cnt_size; |
|---|
| 401 | 526 | list_size++; |
|---|
| 402 | 527 | } |
|---|
| 403 | 528 | |
|---|
| .. | .. |
|---|
| 417 | 542 | continue; |
|---|
| 418 | 543 | |
|---|
| 419 | 544 | MLX5_SET(flow_counter_list, in_dests, flow_counter_id, |
|---|
| 420 | | - dst->dest_attr.counter->id); |
|---|
| 421 | | - in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); |
|---|
| 545 | + dst->dest_attr.counter_id); |
|---|
| 546 | + in_dests += dst_cnt_size; |
|---|
| 422 | 547 | list_size++; |
|---|
| 423 | 548 | } |
|---|
| 424 | 549 | if (list_size > max_list_size) { |
|---|
| .. | .. |
|---|
| 436 | 561 | return err; |
|---|
| 437 | 562 | } |
|---|
| 438 | 563 | |
|---|
| 439 | | -static int mlx5_cmd_create_fte(struct mlx5_core_dev *dev, |
|---|
| 564 | +static int mlx5_cmd_create_fte(struct mlx5_flow_root_namespace *ns, |
|---|
| 440 | 565 | struct mlx5_flow_table *ft, |
|---|
| 441 | 566 | struct mlx5_flow_group *group, |
|---|
| 442 | 567 | struct fs_fte *fte) |
|---|
| 443 | 568 | { |
|---|
| 569 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 444 | 570 | unsigned int group_id = group->id; |
|---|
| 445 | 571 | |
|---|
| 446 | 572 | return mlx5_cmd_set_fte(dev, 0, 0, ft, group_id, fte); |
|---|
| 447 | 573 | } |
|---|
| 448 | 574 | |
|---|
| 449 | | -static int mlx5_cmd_update_fte(struct mlx5_core_dev *dev, |
|---|
| 575 | +static int mlx5_cmd_update_fte(struct mlx5_flow_root_namespace *ns, |
|---|
| 450 | 576 | struct mlx5_flow_table *ft, |
|---|
| 451 | | - unsigned int group_id, |
|---|
| 577 | + struct mlx5_flow_group *fg, |
|---|
| 452 | 578 | int modify_mask, |
|---|
| 453 | 579 | struct fs_fte *fte) |
|---|
| 454 | 580 | { |
|---|
| 455 | 581 | int opmod; |
|---|
| 582 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 456 | 583 | int atomic_mod_cap = MLX5_CAP_FLOWTABLE(dev, |
|---|
| 457 | 584 | flow_table_properties_nic_receive. |
|---|
| 458 | 585 | flow_modify_en); |
|---|
| .. | .. |
|---|
| 460 | 587 | return -EOPNOTSUPP; |
|---|
| 461 | 588 | opmod = 1; |
|---|
| 462 | 589 | |
|---|
| 463 | | - return mlx5_cmd_set_fte(dev, opmod, modify_mask, ft, group_id, fte); |
|---|
| 590 | + return mlx5_cmd_set_fte(dev, opmod, modify_mask, ft, fg->id, fte); |
|---|
| 464 | 591 | } |
|---|
| 465 | 592 | |
|---|
| 466 | | -static int mlx5_cmd_delete_fte(struct mlx5_core_dev *dev, |
|---|
| 593 | +static int mlx5_cmd_delete_fte(struct mlx5_flow_root_namespace *ns, |
|---|
| 467 | 594 | struct mlx5_flow_table *ft, |
|---|
| 468 | 595 | struct fs_fte *fte) |
|---|
| 469 | 596 | { |
|---|
| 470 | | - u32 out[MLX5_ST_SZ_DW(delete_fte_out)] = {0}; |
|---|
| 471 | | - u32 in[MLX5_ST_SZ_DW(delete_fte_in)] = {0}; |
|---|
| 597 | + u32 in[MLX5_ST_SZ_DW(delete_fte_in)] = {}; |
|---|
| 598 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 472 | 599 | |
|---|
| 473 | 600 | MLX5_SET(delete_fte_in, in, opcode, MLX5_CMD_OP_DELETE_FLOW_TABLE_ENTRY); |
|---|
| 474 | 601 | MLX5_SET(delete_fte_in, in, table_type, ft->type); |
|---|
| .. | .. |
|---|
| 479 | 606 | MLX5_SET(delete_fte_in, in, other_vport, 1); |
|---|
| 480 | 607 | } |
|---|
| 481 | 608 | |
|---|
| 482 | | - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 609 | + return mlx5_cmd_exec_in(dev, delete_fte, in); |
|---|
| 483 | 610 | } |
|---|
| 484 | 611 | |
|---|
| 485 | | -int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id) |
|---|
| 612 | +int mlx5_cmd_fc_bulk_alloc(struct mlx5_core_dev *dev, |
|---|
| 613 | + enum mlx5_fc_bulk_alloc_bitmask alloc_bitmask, |
|---|
| 614 | + u32 *id) |
|---|
| 486 | 615 | { |
|---|
| 487 | | - u32 in[MLX5_ST_SZ_DW(alloc_flow_counter_in)] = {0}; |
|---|
| 488 | | - u32 out[MLX5_ST_SZ_DW(alloc_flow_counter_out)] = {0}; |
|---|
| 616 | + u32 out[MLX5_ST_SZ_DW(alloc_flow_counter_out)] = {}; |
|---|
| 617 | + u32 in[MLX5_ST_SZ_DW(alloc_flow_counter_in)] = {}; |
|---|
| 489 | 618 | int err; |
|---|
| 490 | 619 | |
|---|
| 491 | 620 | MLX5_SET(alloc_flow_counter_in, in, opcode, |
|---|
| 492 | 621 | MLX5_CMD_OP_ALLOC_FLOW_COUNTER); |
|---|
| 622 | + MLX5_SET(alloc_flow_counter_in, in, flow_counter_bulk, alloc_bitmask); |
|---|
| 493 | 623 | |
|---|
| 494 | | - err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 624 | + err = mlx5_cmd_exec_inout(dev, alloc_flow_counter, in, out); |
|---|
| 495 | 625 | if (!err) |
|---|
| 496 | 626 | *id = MLX5_GET(alloc_flow_counter_out, out, flow_counter_id); |
|---|
| 497 | 627 | return err; |
|---|
| 498 | 628 | } |
|---|
| 499 | 629 | |
|---|
| 630 | +int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id) |
|---|
| 631 | +{ |
|---|
| 632 | + return mlx5_cmd_fc_bulk_alloc(dev, 0, id); |
|---|
| 633 | +} |
|---|
| 634 | + |
|---|
| 500 | 635 | int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id) |
|---|
| 501 | 636 | { |
|---|
| 502 | | - u32 in[MLX5_ST_SZ_DW(dealloc_flow_counter_in)] = {0}; |
|---|
| 503 | | - u32 out[MLX5_ST_SZ_DW(dealloc_flow_counter_out)] = {0}; |
|---|
| 637 | + u32 in[MLX5_ST_SZ_DW(dealloc_flow_counter_in)] = {}; |
|---|
| 504 | 638 | |
|---|
| 505 | 639 | MLX5_SET(dealloc_flow_counter_in, in, opcode, |
|---|
| 506 | 640 | MLX5_CMD_OP_DEALLOC_FLOW_COUNTER); |
|---|
| 507 | 641 | MLX5_SET(dealloc_flow_counter_in, in, flow_counter_id, id); |
|---|
| 508 | | - return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 642 | + return mlx5_cmd_exec_in(dev, dealloc_flow_counter, in); |
|---|
| 509 | 643 | } |
|---|
| 510 | 644 | |
|---|
| 511 | 645 | int mlx5_cmd_fc_query(struct mlx5_core_dev *dev, u32 id, |
|---|
| 512 | 646 | u64 *packets, u64 *bytes) |
|---|
| 513 | 647 | { |
|---|
| 514 | 648 | u32 out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + |
|---|
| 515 | | - MLX5_ST_SZ_BYTES(traffic_counter)] = {0}; |
|---|
| 516 | | - u32 in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; |
|---|
| 649 | + MLX5_ST_SZ_BYTES(traffic_counter)] = {}; |
|---|
| 650 | + u32 in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {}; |
|---|
| 517 | 651 | void *stats; |
|---|
| 518 | 652 | int err = 0; |
|---|
| 519 | 653 | |
|---|
| .. | .. |
|---|
| 531 | 665 | return 0; |
|---|
| 532 | 666 | } |
|---|
| 533 | 667 | |
|---|
| 534 | | -struct mlx5_cmd_fc_bulk { |
|---|
| 535 | | - u32 id; |
|---|
| 536 | | - int num; |
|---|
| 537 | | - int outlen; |
|---|
| 538 | | - u32 out[0]; |
|---|
| 539 | | -}; |
|---|
| 540 | | - |
|---|
| 541 | | -struct mlx5_cmd_fc_bulk * |
|---|
| 542 | | -mlx5_cmd_fc_bulk_alloc(struct mlx5_core_dev *dev, u32 id, int num) |
|---|
| 668 | +int mlx5_cmd_fc_get_bulk_query_out_len(int bulk_len) |
|---|
| 543 | 669 | { |
|---|
| 544 | | - struct mlx5_cmd_fc_bulk *b; |
|---|
| 545 | | - int outlen = |
|---|
| 546 | | - MLX5_ST_SZ_BYTES(query_flow_counter_out) + |
|---|
| 547 | | - MLX5_ST_SZ_BYTES(traffic_counter) * num; |
|---|
| 548 | | - |
|---|
| 549 | | - b = kzalloc(sizeof(*b) + outlen, GFP_KERNEL); |
|---|
| 550 | | - if (!b) |
|---|
| 551 | | - return NULL; |
|---|
| 552 | | - |
|---|
| 553 | | - b->id = id; |
|---|
| 554 | | - b->num = num; |
|---|
| 555 | | - b->outlen = outlen; |
|---|
| 556 | | - |
|---|
| 557 | | - return b; |
|---|
| 670 | + return MLX5_ST_SZ_BYTES(query_flow_counter_out) + |
|---|
| 671 | + MLX5_ST_SZ_BYTES(traffic_counter) * bulk_len; |
|---|
| 558 | 672 | } |
|---|
| 559 | 673 | |
|---|
| 560 | | -void mlx5_cmd_fc_bulk_free(struct mlx5_cmd_fc_bulk *b) |
|---|
| 674 | +int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len, |
|---|
| 675 | + u32 *out) |
|---|
| 561 | 676 | { |
|---|
| 562 | | - kfree(b); |
|---|
| 563 | | -} |
|---|
| 564 | | - |
|---|
| 565 | | -int |
|---|
| 566 | | -mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, struct mlx5_cmd_fc_bulk *b) |
|---|
| 567 | | -{ |
|---|
| 568 | | - u32 in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; |
|---|
| 677 | + int outlen = mlx5_cmd_fc_get_bulk_query_out_len(bulk_len); |
|---|
| 678 | + u32 in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {}; |
|---|
| 569 | 679 | |
|---|
| 570 | 680 | MLX5_SET(query_flow_counter_in, in, opcode, |
|---|
| 571 | 681 | MLX5_CMD_OP_QUERY_FLOW_COUNTER); |
|---|
| 572 | | - MLX5_SET(query_flow_counter_in, in, op_mod, 0); |
|---|
| 573 | | - MLX5_SET(query_flow_counter_in, in, flow_counter_id, b->id); |
|---|
| 574 | | - MLX5_SET(query_flow_counter_in, in, num_of_counters, b->num); |
|---|
| 575 | | - return mlx5_cmd_exec(dev, in, sizeof(in), b->out, b->outlen); |
|---|
| 682 | + MLX5_SET(query_flow_counter_in, in, flow_counter_id, base_id); |
|---|
| 683 | + MLX5_SET(query_flow_counter_in, in, num_of_counters, bulk_len); |
|---|
| 684 | + return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen); |
|---|
| 576 | 685 | } |
|---|
| 577 | 686 | |
|---|
| 578 | | -void mlx5_cmd_fc_bulk_get(struct mlx5_core_dev *dev, |
|---|
| 579 | | - struct mlx5_cmd_fc_bulk *b, u32 id, |
|---|
| 580 | | - u64 *packets, u64 *bytes) |
|---|
| 687 | +static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 688 | + int reformat_type, |
|---|
| 689 | + size_t size, |
|---|
| 690 | + void *reformat_data, |
|---|
| 691 | + enum mlx5_flow_namespace_type namespace, |
|---|
| 692 | + struct mlx5_pkt_reformat *pkt_reformat) |
|---|
| 581 | 693 | { |
|---|
| 582 | | - int index = id - b->id; |
|---|
| 583 | | - void *stats; |
|---|
| 584 | | - |
|---|
| 585 | | - if (index < 0 || index >= b->num) { |
|---|
| 586 | | - mlx5_core_warn(dev, "Flow counter id (0x%x) out of range (0x%x..0x%x). Counter ignored.\n", |
|---|
| 587 | | - id, b->id, b->id + b->num - 1); |
|---|
| 588 | | - return; |
|---|
| 589 | | - } |
|---|
| 590 | | - |
|---|
| 591 | | - stats = MLX5_ADDR_OF(query_flow_counter_out, b->out, |
|---|
| 592 | | - flow_statistics[index]); |
|---|
| 593 | | - *packets = MLX5_GET64(traffic_counter, stats, packets); |
|---|
| 594 | | - *bytes = MLX5_GET64(traffic_counter, stats, octets); |
|---|
| 595 | | -} |
|---|
| 596 | | - |
|---|
| 597 | | -int mlx5_encap_alloc(struct mlx5_core_dev *dev, |
|---|
| 598 | | - int header_type, |
|---|
| 599 | | - size_t size, |
|---|
| 600 | | - void *encap_header, |
|---|
| 601 | | - u32 *encap_id) |
|---|
| 602 | | -{ |
|---|
| 603 | | - int max_encap_size = MLX5_CAP_ESW(dev, max_encap_header_size); |
|---|
| 604 | | - u32 out[MLX5_ST_SZ_DW(alloc_encap_header_out)]; |
|---|
| 605 | | - void *encap_header_in; |
|---|
| 606 | | - void *header; |
|---|
| 694 | + u32 out[MLX5_ST_SZ_DW(alloc_packet_reformat_context_out)] = {}; |
|---|
| 695 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 696 | + void *packet_reformat_context_in; |
|---|
| 697 | + int max_encap_size; |
|---|
| 698 | + void *reformat; |
|---|
| 607 | 699 | int inlen; |
|---|
| 608 | 700 | int err; |
|---|
| 609 | 701 | u32 *in; |
|---|
| 702 | + |
|---|
| 703 | + if (namespace == MLX5_FLOW_NAMESPACE_FDB) |
|---|
| 704 | + max_encap_size = MLX5_CAP_ESW(dev, max_encap_header_size); |
|---|
| 705 | + else |
|---|
| 706 | + max_encap_size = MLX5_CAP_FLOWTABLE(dev, max_encap_header_size); |
|---|
| 610 | 707 | |
|---|
| 611 | 708 | if (size > max_encap_size) { |
|---|
| 612 | 709 | mlx5_core_warn(dev, "encap size %zd too big, max supported is %d\n", |
|---|
| .. | .. |
|---|
| 614 | 711 | return -EINVAL; |
|---|
| 615 | 712 | } |
|---|
| 616 | 713 | |
|---|
| 617 | | - in = kzalloc(MLX5_ST_SZ_BYTES(alloc_encap_header_in) + size, |
|---|
| 714 | + in = kzalloc(MLX5_ST_SZ_BYTES(alloc_packet_reformat_context_in) + size, |
|---|
| 618 | 715 | GFP_KERNEL); |
|---|
| 619 | 716 | if (!in) |
|---|
| 620 | 717 | return -ENOMEM; |
|---|
| 621 | 718 | |
|---|
| 622 | | - encap_header_in = MLX5_ADDR_OF(alloc_encap_header_in, in, encap_header); |
|---|
| 623 | | - header = MLX5_ADDR_OF(encap_header_in, encap_header_in, encap_header); |
|---|
| 624 | | - inlen = header - (void *)in + size; |
|---|
| 719 | + packet_reformat_context_in = MLX5_ADDR_OF(alloc_packet_reformat_context_in, |
|---|
| 720 | + in, packet_reformat_context); |
|---|
| 721 | + reformat = MLX5_ADDR_OF(packet_reformat_context_in, |
|---|
| 722 | + packet_reformat_context_in, |
|---|
| 723 | + reformat_data); |
|---|
| 724 | + inlen = reformat - (void *)in + size; |
|---|
| 625 | 725 | |
|---|
| 626 | | - memset(in, 0, inlen); |
|---|
| 627 | | - MLX5_SET(alloc_encap_header_in, in, opcode, |
|---|
| 628 | | - MLX5_CMD_OP_ALLOC_ENCAP_HEADER); |
|---|
| 629 | | - MLX5_SET(encap_header_in, encap_header_in, encap_header_size, size); |
|---|
| 630 | | - MLX5_SET(encap_header_in, encap_header_in, header_type, header_type); |
|---|
| 631 | | - memcpy(header, encap_header, size); |
|---|
| 726 | + MLX5_SET(alloc_packet_reformat_context_in, in, opcode, |
|---|
| 727 | + MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT); |
|---|
| 728 | + MLX5_SET(packet_reformat_context_in, packet_reformat_context_in, |
|---|
| 729 | + reformat_data_size, size); |
|---|
| 730 | + MLX5_SET(packet_reformat_context_in, packet_reformat_context_in, |
|---|
| 731 | + reformat_type, reformat_type); |
|---|
| 732 | + memcpy(reformat, reformat_data, size); |
|---|
| 632 | 733 | |
|---|
| 633 | | - memset(out, 0, sizeof(out)); |
|---|
| 634 | 734 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
|---|
| 635 | 735 | |
|---|
| 636 | | - *encap_id = MLX5_GET(alloc_encap_header_out, out, encap_id); |
|---|
| 736 | + pkt_reformat->id = MLX5_GET(alloc_packet_reformat_context_out, |
|---|
| 737 | + out, packet_reformat_id); |
|---|
| 637 | 738 | kfree(in); |
|---|
| 638 | 739 | return err; |
|---|
| 639 | 740 | } |
|---|
| 640 | 741 | |
|---|
| 641 | | -void mlx5_encap_dealloc(struct mlx5_core_dev *dev, u32 encap_id) |
|---|
| 742 | +static void mlx5_cmd_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 743 | + struct mlx5_pkt_reformat *pkt_reformat) |
|---|
| 642 | 744 | { |
|---|
| 643 | | - u32 in[MLX5_ST_SZ_DW(dealloc_encap_header_in)]; |
|---|
| 644 | | - u32 out[MLX5_ST_SZ_DW(dealloc_encap_header_out)]; |
|---|
| 745 | + u32 in[MLX5_ST_SZ_DW(dealloc_packet_reformat_context_in)] = {}; |
|---|
| 746 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 645 | 747 | |
|---|
| 646 | | - memset(in, 0, sizeof(in)); |
|---|
| 647 | | - MLX5_SET(dealloc_encap_header_in, in, opcode, |
|---|
| 648 | | - MLX5_CMD_OP_DEALLOC_ENCAP_HEADER); |
|---|
| 649 | | - MLX5_SET(dealloc_encap_header_in, in, encap_id, encap_id); |
|---|
| 748 | + MLX5_SET(dealloc_packet_reformat_context_in, in, opcode, |
|---|
| 749 | + MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT); |
|---|
| 750 | + MLX5_SET(dealloc_packet_reformat_context_in, in, packet_reformat_id, |
|---|
| 751 | + pkt_reformat->id); |
|---|
| 650 | 752 | |
|---|
| 651 | | - mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 753 | + mlx5_cmd_exec_in(dev, dealloc_packet_reformat_context, in); |
|---|
| 652 | 754 | } |
|---|
| 653 | 755 | |
|---|
| 654 | | -int mlx5_modify_header_alloc(struct mlx5_core_dev *dev, |
|---|
| 655 | | - u8 namespace, u8 num_actions, |
|---|
| 656 | | - void *modify_actions, u32 *modify_header_id) |
|---|
| 756 | +static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 757 | + u8 namespace, u8 num_actions, |
|---|
| 758 | + void *modify_actions, |
|---|
| 759 | + struct mlx5_modify_hdr *modify_hdr) |
|---|
| 657 | 760 | { |
|---|
| 658 | | - u32 out[MLX5_ST_SZ_DW(alloc_modify_header_context_out)]; |
|---|
| 761 | + u32 out[MLX5_ST_SZ_DW(alloc_modify_header_context_out)] = {}; |
|---|
| 659 | 762 | int max_actions, actions_size, inlen, err; |
|---|
| 763 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 660 | 764 | void *actions_in; |
|---|
| 661 | 765 | u8 table_type; |
|---|
| 662 | 766 | u32 *in; |
|---|
| .. | .. |
|---|
| 667 | 771 | table_type = FS_FT_FDB; |
|---|
| 668 | 772 | break; |
|---|
| 669 | 773 | case MLX5_FLOW_NAMESPACE_KERNEL: |
|---|
| 774 | + case MLX5_FLOW_NAMESPACE_BYPASS: |
|---|
| 670 | 775 | max_actions = MLX5_CAP_FLOWTABLE_NIC_RX(dev, max_modify_header_actions); |
|---|
| 671 | 776 | table_type = FS_FT_NIC_RX; |
|---|
| 777 | + break; |
|---|
| 778 | + case MLX5_FLOW_NAMESPACE_EGRESS: |
|---|
| 779 | +#ifdef CONFIG_MLX5_IPSEC |
|---|
| 780 | + case MLX5_FLOW_NAMESPACE_EGRESS_KERNEL: |
|---|
| 781 | +#endif |
|---|
| 782 | + max_actions = MLX5_CAP_FLOWTABLE_NIC_TX(dev, max_modify_header_actions); |
|---|
| 783 | + table_type = FS_FT_NIC_TX; |
|---|
| 784 | + break; |
|---|
| 785 | + case MLX5_FLOW_NAMESPACE_ESW_INGRESS: |
|---|
| 786 | + max_actions = MLX5_CAP_ESW_INGRESS_ACL(dev, max_modify_header_actions); |
|---|
| 787 | + table_type = FS_FT_ESW_INGRESS_ACL; |
|---|
| 788 | + break; |
|---|
| 789 | + case MLX5_FLOW_NAMESPACE_RDMA_TX: |
|---|
| 790 | + max_actions = MLX5_CAP_FLOWTABLE_RDMA_TX(dev, max_modify_header_actions); |
|---|
| 791 | + table_type = FS_FT_RDMA_TX; |
|---|
| 672 | 792 | break; |
|---|
| 673 | 793 | default: |
|---|
| 674 | 794 | return -EOPNOTSUPP; |
|---|
| .. | .. |
|---|
| 680 | 800 | return -EOPNOTSUPP; |
|---|
| 681 | 801 | } |
|---|
| 682 | 802 | |
|---|
| 683 | | - actions_size = MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto) * num_actions; |
|---|
| 803 | + actions_size = MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto) * num_actions; |
|---|
| 684 | 804 | inlen = MLX5_ST_SZ_BYTES(alloc_modify_header_context_in) + actions_size; |
|---|
| 685 | 805 | |
|---|
| 686 | 806 | in = kzalloc(inlen, GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 695 | 815 | actions_in = MLX5_ADDR_OF(alloc_modify_header_context_in, in, actions); |
|---|
| 696 | 816 | memcpy(actions_in, modify_actions, actions_size); |
|---|
| 697 | 817 | |
|---|
| 698 | | - memset(out, 0, sizeof(out)); |
|---|
| 699 | 818 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
|---|
| 700 | 819 | |
|---|
| 701 | | - *modify_header_id = MLX5_GET(alloc_modify_header_context_out, out, modify_header_id); |
|---|
| 820 | + modify_hdr->id = MLX5_GET(alloc_modify_header_context_out, out, modify_header_id); |
|---|
| 702 | 821 | kfree(in); |
|---|
| 703 | 822 | return err; |
|---|
| 704 | 823 | } |
|---|
| 705 | 824 | |
|---|
| 706 | | -void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, u32 modify_header_id) |
|---|
| 825 | +static void mlx5_cmd_modify_header_dealloc(struct mlx5_flow_root_namespace *ns, |
|---|
| 826 | + struct mlx5_modify_hdr *modify_hdr) |
|---|
| 707 | 827 | { |
|---|
| 708 | | - u32 in[MLX5_ST_SZ_DW(dealloc_modify_header_context_in)]; |
|---|
| 709 | | - u32 out[MLX5_ST_SZ_DW(dealloc_modify_header_context_out)]; |
|---|
| 828 | + u32 in[MLX5_ST_SZ_DW(dealloc_modify_header_context_in)] = {}; |
|---|
| 829 | + struct mlx5_core_dev *dev = ns->dev; |
|---|
| 710 | 830 | |
|---|
| 711 | | - memset(in, 0, sizeof(in)); |
|---|
| 712 | 831 | MLX5_SET(dealloc_modify_header_context_in, in, opcode, |
|---|
| 713 | 832 | MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT); |
|---|
| 714 | 833 | MLX5_SET(dealloc_modify_header_context_in, in, modify_header_id, |
|---|
| 715 | | - modify_header_id); |
|---|
| 834 | + modify_hdr->id); |
|---|
| 716 | 835 | |
|---|
| 717 | | - mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
|---|
| 836 | + mlx5_cmd_exec_in(dev, dealloc_modify_header_context, in); |
|---|
| 718 | 837 | } |
|---|
| 719 | 838 | |
|---|
| 720 | 839 | static const struct mlx5_flow_cmds mlx5_flow_cmds = { |
|---|
| .. | .. |
|---|
| 727 | 846 | .update_fte = mlx5_cmd_update_fte, |
|---|
| 728 | 847 | .delete_fte = mlx5_cmd_delete_fte, |
|---|
| 729 | 848 | .update_root_ft = mlx5_cmd_update_root_ft, |
|---|
| 849 | + .packet_reformat_alloc = mlx5_cmd_packet_reformat_alloc, |
|---|
| 850 | + .packet_reformat_dealloc = mlx5_cmd_packet_reformat_dealloc, |
|---|
| 851 | + .modify_header_alloc = mlx5_cmd_modify_header_alloc, |
|---|
| 852 | + .modify_header_dealloc = mlx5_cmd_modify_header_dealloc, |
|---|
| 853 | + .set_peer = mlx5_cmd_stub_set_peer, |
|---|
| 854 | + .create_ns = mlx5_cmd_stub_create_ns, |
|---|
| 855 | + .destroy_ns = mlx5_cmd_stub_destroy_ns, |
|---|
| 730 | 856 | }; |
|---|
| 731 | 857 | |
|---|
| 732 | 858 | static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { |
|---|
| .. | .. |
|---|
| 739 | 865 | .update_fte = mlx5_cmd_stub_update_fte, |
|---|
| 740 | 866 | .delete_fte = mlx5_cmd_stub_delete_fte, |
|---|
| 741 | 867 | .update_root_ft = mlx5_cmd_stub_update_root_ft, |
|---|
| 868 | + .packet_reformat_alloc = mlx5_cmd_stub_packet_reformat_alloc, |
|---|
| 869 | + .packet_reformat_dealloc = mlx5_cmd_stub_packet_reformat_dealloc, |
|---|
| 870 | + .modify_header_alloc = mlx5_cmd_stub_modify_header_alloc, |
|---|
| 871 | + .modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc, |
|---|
| 872 | + .set_peer = mlx5_cmd_stub_set_peer, |
|---|
| 873 | + .create_ns = mlx5_cmd_stub_create_ns, |
|---|
| 874 | + .destroy_ns = mlx5_cmd_stub_destroy_ns, |
|---|
| 742 | 875 | }; |
|---|
| 743 | 876 | |
|---|
| 744 | | -static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) |
|---|
| 877 | +const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) |
|---|
| 745 | 878 | { |
|---|
| 746 | 879 | return &mlx5_flow_cmds; |
|---|
| 747 | 880 | } |
|---|
| .. | .. |
|---|
| 760 | 893 | case FS_FT_FDB: |
|---|
| 761 | 894 | case FS_FT_SNIFFER_RX: |
|---|
| 762 | 895 | case FS_FT_SNIFFER_TX: |
|---|
| 763 | | - return mlx5_fs_cmd_get_fw_cmds(); |
|---|
| 764 | 896 | case FS_FT_NIC_TX: |
|---|
| 897 | + case FS_FT_RDMA_RX: |
|---|
| 898 | + case FS_FT_RDMA_TX: |
|---|
| 899 | + return mlx5_fs_cmd_get_fw_cmds(); |
|---|
| 765 | 900 | default: |
|---|
| 766 | 901 | return mlx5_fs_cmd_get_stub_cmds(); |
|---|
| 767 | 902 | } |
|---|