1 /* 2 * Copyright (c) 2015, Mellanox Technologies. All rights reserved. 3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or 11 * without modification, are permitted provided that the following 12 * conditions are met: 13 * 14 * - Redistributions of source code must retain the above 15 * copyright notice, this list of conditions and the following 16 * disclaimer. 17 * 18 * - Redistributions in binary form must reproduce the above 19 * copyright notice, this list of conditions and the following 20 * disclaimer in the documentation and/or other materials 21 * provided with the distribution. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * SOFTWARE. 31 */ 32 33 #include <linux/mlx5/driver.h> 34 #include <linux/mlx5/device.h> 35 #include <linux/mlx5/mlx5_ifc.h> 36 37 #include "fs_core.h" 38 #include "fs_cmd.h" 39 #include "fs_ft_pool.h" 40 #include "mlx5_core.h" 41 #include "eswitch.h" 42 43 static int mlx5_cmd_stub_update_root_ft(struct mlx5_flow_root_namespace *ns, 44 struct mlx5_flow_table *ft, 45 u32 underlay_qpn, 46 bool disconnect) 47 { 48 return 0; 49 } 50 51 static int mlx5_cmd_stub_create_flow_table(struct mlx5_flow_root_namespace *ns, 52 struct mlx5_flow_table *ft, 53 struct mlx5_flow_table_attr *ft_attr, 54 struct mlx5_flow_table *next_ft) 55 { 56 int max_fte = ft_attr->max_fte; 57 58 ft->max_fte = max_fte ? roundup_pow_of_two(max_fte) : 1; 59 60 return 0; 61 } 62 63 static int mlx5_cmd_stub_destroy_flow_table(struct mlx5_flow_root_namespace *ns, 64 struct mlx5_flow_table *ft) 65 { 66 return 0; 67 } 68 69 static int mlx5_cmd_stub_modify_flow_table(struct mlx5_flow_root_namespace *ns, 70 struct mlx5_flow_table *ft, 71 struct mlx5_flow_table *next_ft) 72 { 73 return 0; 74 } 75 76 static int mlx5_cmd_stub_create_flow_group(struct mlx5_flow_root_namespace *ns, 77 struct mlx5_flow_table *ft, 78 u32 *in, 79 struct mlx5_flow_group *fg) 80 { 81 return 0; 82 } 83 84 static int mlx5_cmd_stub_destroy_flow_group(struct mlx5_flow_root_namespace *ns, 85 struct mlx5_flow_table *ft, 86 struct mlx5_flow_group *fg) 87 { 88 return 0; 89 } 90 91 static int mlx5_cmd_stub_create_fte(struct mlx5_flow_root_namespace *ns, 92 struct mlx5_flow_table *ft, 93 struct mlx5_flow_group *group, 94 struct fs_fte *fte) 95 { 96 return 0; 97 } 98 99 static int mlx5_cmd_stub_update_fte(struct mlx5_flow_root_namespace *ns, 100 struct mlx5_flow_table *ft, 101 struct mlx5_flow_group *group, 102 int modify_mask, 103 struct fs_fte *fte) 104 { 105 return -EOPNOTSUPP; 106 } 107 108 static int mlx5_cmd_stub_delete_fte(struct mlx5_flow_root_namespace *ns, 109 struct mlx5_flow_table *ft, 110 struct fs_fte *fte) 111 { 112 return 0; 113 } 114 115 static int mlx5_cmd_stub_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, 116 struct mlx5_pkt_reformat_params *params, 117 enum mlx5_flow_namespace_type namespace, 118 struct mlx5_pkt_reformat *pkt_reformat) 119 { 120 return 0; 121 } 122 123 static void mlx5_cmd_stub_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns, 124 struct mlx5_pkt_reformat *pkt_reformat) 125 { 126 } 127 128 static int mlx5_cmd_stub_modify_header_alloc(struct mlx5_flow_root_namespace *ns, 129 u8 namespace, u8 num_actions, 130 void *modify_actions, 131 struct mlx5_modify_hdr *modify_hdr) 132 { 133 return 0; 134 } 135 136 static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace *ns, 137 struct mlx5_modify_hdr *modify_hdr) 138 { 139 } 140 141 static int mlx5_cmd_stub_set_peer(struct mlx5_flow_root_namespace *ns, 142 struct mlx5_flow_root_namespace *peer_ns) 143 { 144 return 0; 145 } 146 147 static int mlx5_cmd_stub_create_ns(struct mlx5_flow_root_namespace *ns) 148 { 149 return 0; 150 } 151 152 static int mlx5_cmd_stub_destroy_ns(struct mlx5_flow_root_namespace *ns) 153 { 154 return 0; 155 } 156 157 static u32 mlx5_cmd_stub_get_capabilities(struct mlx5_flow_root_namespace *ns, 158 enum fs_flow_table_type ft_type) 159 { 160 return 0; 161 } 162 163 static int mlx5_cmd_set_slave_root_fdb(struct mlx5_core_dev *master, 164 struct mlx5_core_dev *slave, 165 bool ft_id_valid, 166 u32 ft_id) 167 { 168 u32 out[MLX5_ST_SZ_DW(set_flow_table_root_out)] = {}; 169 u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)] = {}; 170 struct mlx5_flow_root_namespace *root; 171 struct mlx5_flow_namespace *ns; 172 173 MLX5_SET(set_flow_table_root_in, in, opcode, 174 MLX5_CMD_OP_SET_FLOW_TABLE_ROOT); 175 MLX5_SET(set_flow_table_root_in, in, table_type, 176 FS_FT_FDB); 177 if (ft_id_valid) { 178 MLX5_SET(set_flow_table_root_in, in, 179 table_eswitch_owner_vhca_id_valid, 1); 180 MLX5_SET(set_flow_table_root_in, in, 181 table_eswitch_owner_vhca_id, 182 MLX5_CAP_GEN(master, vhca_id)); 183 MLX5_SET(set_flow_table_root_in, in, table_id, 184 ft_id); 185 } else { 186 ns = mlx5_get_flow_namespace(slave, 187 MLX5_FLOW_NAMESPACE_FDB); 188 root = find_root(&ns->node); 189 MLX5_SET(set_flow_table_root_in, in, table_id, 190 root->root_ft->id); 191 } 192 193 return mlx5_cmd_exec(slave, in, sizeof(in), out, sizeof(out)); 194 } 195 196 static int 197 mlx5_cmd_stub_destroy_match_definer(struct mlx5_flow_root_namespace *ns, 198 int definer_id) 199 { 200 return 0; 201 } 202 203 static int 204 mlx5_cmd_stub_create_match_definer(struct mlx5_flow_root_namespace *ns, 205 u16 format_id, u32 *match_mask) 206 { 207 return 0; 208 } 209 210 static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns, 211 struct mlx5_flow_table *ft, u32 underlay_qpn, 212 bool disconnect) 213 { 214 u32 in[MLX5_ST_SZ_DW(set_flow_table_root_in)] = {}; 215 struct mlx5_core_dev *dev = ns->dev; 216 int err; 217 218 if ((MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) && 219 underlay_qpn == 0) 220 return 0; 221 222 if (ft->type == FS_FT_FDB && 223 mlx5_lag_is_shared_fdb(dev) && 224 !mlx5_lag_is_master(dev)) 225 return 0; 226 227 MLX5_SET(set_flow_table_root_in, in, opcode, 228 MLX5_CMD_OP_SET_FLOW_TABLE_ROOT); 229 MLX5_SET(set_flow_table_root_in, in, table_type, ft->type); 230 231 if (disconnect) 232 MLX5_SET(set_flow_table_root_in, in, op_mod, 1); 233 else 234 MLX5_SET(set_flow_table_root_in, in, table_id, ft->id); 235 236 MLX5_SET(set_flow_table_root_in, in, underlay_qpn, underlay_qpn); 237 MLX5_SET(set_flow_table_root_in, in, vport_number, ft->vport); 238 MLX5_SET(set_flow_table_root_in, in, other_vport, 239 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 240 241 err = mlx5_cmd_exec_in(dev, set_flow_table_root, in); 242 if (!err && 243 ft->type == FS_FT_FDB && 244 mlx5_lag_is_shared_fdb(dev) && 245 mlx5_lag_is_master(dev)) { 246 err = mlx5_cmd_set_slave_root_fdb(dev, 247 mlx5_lag_get_peer_mdev(dev), 248 !disconnect, (!disconnect) ? 249 ft->id : 0); 250 if (err && !disconnect) { 251 MLX5_SET(set_flow_table_root_in, in, op_mod, 0); 252 MLX5_SET(set_flow_table_root_in, in, table_id, 253 ns->root_ft->id); 254 mlx5_cmd_exec_in(dev, set_flow_table_root, in); 255 } 256 } 257 258 return err; 259 } 260 261 static int mlx5_cmd_create_flow_table(struct mlx5_flow_root_namespace *ns, 262 struct mlx5_flow_table *ft, 263 struct mlx5_flow_table_attr *ft_attr, 264 struct mlx5_flow_table *next_ft) 265 { 266 int en_encap = !!(ft->flags & MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT); 267 int en_decap = !!(ft->flags & MLX5_FLOW_TABLE_TUNNEL_EN_DECAP); 268 int term = !!(ft->flags & MLX5_FLOW_TABLE_TERMINATION); 269 u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {}; 270 u32 in[MLX5_ST_SZ_DW(create_flow_table_in)] = {}; 271 struct mlx5_core_dev *dev = ns->dev; 272 unsigned int size; 273 int err; 274 275 if (ft_attr->max_fte != POOL_NEXT_SIZE) 276 size = roundup_pow_of_two(ft_attr->max_fte); 277 size = mlx5_ft_pool_get_avail_sz(dev, ft->type, ft_attr->max_fte); 278 if (!size) 279 return -ENOSPC; 280 281 MLX5_SET(create_flow_table_in, in, opcode, 282 MLX5_CMD_OP_CREATE_FLOW_TABLE); 283 284 MLX5_SET(create_flow_table_in, in, uid, ft_attr->uid); 285 MLX5_SET(create_flow_table_in, in, table_type, ft->type); 286 MLX5_SET(create_flow_table_in, in, flow_table_context.level, ft->level); 287 MLX5_SET(create_flow_table_in, in, flow_table_context.log_size, size ? ilog2(size) : 0); 288 MLX5_SET(create_flow_table_in, in, vport_number, ft->vport); 289 MLX5_SET(create_flow_table_in, in, other_vport, 290 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 291 292 MLX5_SET(create_flow_table_in, in, flow_table_context.decap_en, 293 en_decap); 294 MLX5_SET(create_flow_table_in, in, flow_table_context.reformat_en, 295 en_encap); 296 MLX5_SET(create_flow_table_in, in, flow_table_context.termination_table, 297 term); 298 299 switch (ft->op_mod) { 300 case FS_FT_OP_MOD_NORMAL: 301 if (next_ft) { 302 MLX5_SET(create_flow_table_in, in, 303 flow_table_context.table_miss_action, 304 MLX5_FLOW_TABLE_MISS_ACTION_FWD); 305 MLX5_SET(create_flow_table_in, in, 306 flow_table_context.table_miss_id, next_ft->id); 307 } else { 308 MLX5_SET(create_flow_table_in, in, 309 flow_table_context.table_miss_action, 310 ft->def_miss_action); 311 } 312 break; 313 314 case FS_FT_OP_MOD_LAG_DEMUX: 315 MLX5_SET(create_flow_table_in, in, op_mod, 0x1); 316 if (next_ft) 317 MLX5_SET(create_flow_table_in, in, 318 flow_table_context.lag_master_next_table_id, 319 next_ft->id); 320 break; 321 } 322 323 err = mlx5_cmd_exec_inout(dev, create_flow_table, in, out); 324 if (!err) { 325 ft->id = MLX5_GET(create_flow_table_out, out, 326 table_id); 327 ft->max_fte = size; 328 } else { 329 mlx5_ft_pool_put_sz(ns->dev, size); 330 } 331 332 return err; 333 } 334 335 static int mlx5_cmd_destroy_flow_table(struct mlx5_flow_root_namespace *ns, 336 struct mlx5_flow_table *ft) 337 { 338 u32 in[MLX5_ST_SZ_DW(destroy_flow_table_in)] = {}; 339 struct mlx5_core_dev *dev = ns->dev; 340 int err; 341 342 MLX5_SET(destroy_flow_table_in, in, opcode, 343 MLX5_CMD_OP_DESTROY_FLOW_TABLE); 344 MLX5_SET(destroy_flow_table_in, in, table_type, ft->type); 345 MLX5_SET(destroy_flow_table_in, in, table_id, ft->id); 346 MLX5_SET(destroy_flow_table_in, in, vport_number, ft->vport); 347 MLX5_SET(destroy_flow_table_in, in, other_vport, 348 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 349 350 err = mlx5_cmd_exec_in(dev, destroy_flow_table, in); 351 if (!err) 352 mlx5_ft_pool_put_sz(ns->dev, ft->max_fte); 353 354 return err; 355 } 356 357 static int mlx5_cmd_modify_flow_table(struct mlx5_flow_root_namespace *ns, 358 struct mlx5_flow_table *ft, 359 struct mlx5_flow_table *next_ft) 360 { 361 u32 in[MLX5_ST_SZ_DW(modify_flow_table_in)] = {}; 362 struct mlx5_core_dev *dev = ns->dev; 363 364 MLX5_SET(modify_flow_table_in, in, opcode, 365 MLX5_CMD_OP_MODIFY_FLOW_TABLE); 366 MLX5_SET(modify_flow_table_in, in, table_type, ft->type); 367 MLX5_SET(modify_flow_table_in, in, table_id, ft->id); 368 369 if (ft->op_mod == FS_FT_OP_MOD_LAG_DEMUX) { 370 MLX5_SET(modify_flow_table_in, in, modify_field_select, 371 MLX5_MODIFY_FLOW_TABLE_LAG_NEXT_TABLE_ID); 372 if (next_ft) { 373 MLX5_SET(modify_flow_table_in, in, 374 flow_table_context.lag_master_next_table_id, next_ft->id); 375 } else { 376 MLX5_SET(modify_flow_table_in, in, 377 flow_table_context.lag_master_next_table_id, 0); 378 } 379 } else { 380 MLX5_SET(modify_flow_table_in, in, vport_number, ft->vport); 381 MLX5_SET(modify_flow_table_in, in, other_vport, 382 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 383 MLX5_SET(modify_flow_table_in, in, modify_field_select, 384 MLX5_MODIFY_FLOW_TABLE_MISS_TABLE_ID); 385 if (next_ft) { 386 MLX5_SET(modify_flow_table_in, in, 387 flow_table_context.table_miss_action, 388 MLX5_FLOW_TABLE_MISS_ACTION_FWD); 389 MLX5_SET(modify_flow_table_in, in, 390 flow_table_context.table_miss_id, 391 next_ft->id); 392 } else { 393 MLX5_SET(modify_flow_table_in, in, 394 flow_table_context.table_miss_action, 395 ft->def_miss_action); 396 } 397 } 398 399 return mlx5_cmd_exec_in(dev, modify_flow_table, in); 400 } 401 402 static int mlx5_cmd_create_flow_group(struct mlx5_flow_root_namespace *ns, 403 struct mlx5_flow_table *ft, 404 u32 *in, 405 struct mlx5_flow_group *fg) 406 { 407 u32 out[MLX5_ST_SZ_DW(create_flow_group_out)] = {}; 408 struct mlx5_core_dev *dev = ns->dev; 409 int err; 410 411 MLX5_SET(create_flow_group_in, in, opcode, 412 MLX5_CMD_OP_CREATE_FLOW_GROUP); 413 MLX5_SET(create_flow_group_in, in, table_type, ft->type); 414 MLX5_SET(create_flow_group_in, in, table_id, ft->id); 415 if (ft->vport) { 416 MLX5_SET(create_flow_group_in, in, vport_number, ft->vport); 417 MLX5_SET(create_flow_group_in, in, other_vport, 1); 418 } 419 420 MLX5_SET(create_flow_group_in, in, vport_number, ft->vport); 421 MLX5_SET(create_flow_group_in, in, other_vport, 422 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 423 err = mlx5_cmd_exec_inout(dev, create_flow_group, in, out); 424 if (!err) 425 fg->id = MLX5_GET(create_flow_group_out, out, 426 group_id); 427 return err; 428 } 429 430 static int mlx5_cmd_destroy_flow_group(struct mlx5_flow_root_namespace *ns, 431 struct mlx5_flow_table *ft, 432 struct mlx5_flow_group *fg) 433 { 434 u32 in[MLX5_ST_SZ_DW(destroy_flow_group_in)] = {}; 435 struct mlx5_core_dev *dev = ns->dev; 436 437 MLX5_SET(destroy_flow_group_in, in, opcode, 438 MLX5_CMD_OP_DESTROY_FLOW_GROUP); 439 MLX5_SET(destroy_flow_group_in, in, table_type, ft->type); 440 MLX5_SET(destroy_flow_group_in, in, table_id, ft->id); 441 MLX5_SET(destroy_flow_group_in, in, group_id, fg->id); 442 MLX5_SET(destroy_flow_group_in, in, vport_number, ft->vport); 443 MLX5_SET(destroy_flow_group_in, in, other_vport, 444 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 445 return mlx5_cmd_exec_in(dev, destroy_flow_group, in); 446 } 447 448 static int mlx5_set_extended_dest(struct mlx5_core_dev *dev, 449 struct fs_fte *fte, bool *extended_dest) 450 { 451 int fw_log_max_fdb_encap_uplink = 452 MLX5_CAP_ESW(dev, log_max_fdb_encap_uplink); 453 int num_fwd_destinations = 0; 454 struct mlx5_flow_rule *dst; 455 int num_encap = 0; 456 457 *extended_dest = false; 458 if (!(fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST)) 459 return 0; 460 461 list_for_each_entry(dst, &fte->node.children, node.list) { 462 if (dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_COUNTER || 463 dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_NONE) 464 continue; 465 if ((dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_VPORT || 466 dst->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) && 467 dst->dest_attr.vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) 468 num_encap++; 469 num_fwd_destinations++; 470 } 471 if (num_fwd_destinations > 1 && num_encap > 0) 472 *extended_dest = true; 473 474 if (*extended_dest && !fw_log_max_fdb_encap_uplink) { 475 mlx5_core_warn(dev, "FW does not support extended destination"); 476 return -EOPNOTSUPP; 477 } 478 if (num_encap > (1 << fw_log_max_fdb_encap_uplink)) { 479 mlx5_core_warn(dev, "FW does not support more than %d encaps", 480 1 << fw_log_max_fdb_encap_uplink); 481 return -EOPNOTSUPP; 482 } 483 484 return 0; 485 } 486 487 static void 488 mlx5_cmd_set_fte_flow_meter(struct fs_fte *fte, void *in_flow_context) 489 { 490 void *exe_aso_ctrl; 491 void *execute_aso; 492 493 execute_aso = MLX5_ADDR_OF(flow_context, in_flow_context, 494 execute_aso[0]); 495 MLX5_SET(execute_aso, execute_aso, valid, 1); 496 MLX5_SET(execute_aso, execute_aso, aso_object_id, 497 fte->action.exe_aso.object_id); 498 499 exe_aso_ctrl = MLX5_ADDR_OF(execute_aso, execute_aso, exe_aso_ctrl); 500 MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, return_reg_id, 501 fte->action.exe_aso.return_reg_id); 502 MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, aso_type, 503 fte->action.exe_aso.type); 504 MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, init_color, 505 fte->action.exe_aso.flow_meter.init_color); 506 MLX5_SET(exe_aso_ctrl_flow_meter, exe_aso_ctrl, meter_id, 507 fte->action.exe_aso.flow_meter.meter_idx); 508 } 509 510 static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, 511 int opmod, int modify_mask, 512 struct mlx5_flow_table *ft, 513 unsigned group_id, 514 struct fs_fte *fte) 515 { 516 u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0}; 517 bool extended_dest = false; 518 struct mlx5_flow_rule *dst; 519 void *in_flow_context, *vlan; 520 void *in_match_value; 521 unsigned int inlen; 522 int dst_cnt_size; 523 void *in_dests; 524 u32 *in; 525 int err; 526 527 if (mlx5_set_extended_dest(dev, fte, &extended_dest)) 528 return -EOPNOTSUPP; 529 530 if (!extended_dest) 531 dst_cnt_size = MLX5_ST_SZ_BYTES(dest_format_struct); 532 else 533 dst_cnt_size = MLX5_ST_SZ_BYTES(extended_dest_format); 534 535 inlen = MLX5_ST_SZ_BYTES(set_fte_in) + fte->dests_size * dst_cnt_size; 536 in = kvzalloc(inlen, GFP_KERNEL); 537 if (!in) 538 return -ENOMEM; 539 540 MLX5_SET(set_fte_in, in, opcode, MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY); 541 MLX5_SET(set_fte_in, in, op_mod, opmod); 542 MLX5_SET(set_fte_in, in, modify_enable_mask, modify_mask); 543 MLX5_SET(set_fte_in, in, table_type, ft->type); 544 MLX5_SET(set_fte_in, in, table_id, ft->id); 545 MLX5_SET(set_fte_in, in, flow_index, fte->index); 546 MLX5_SET(set_fte_in, in, ignore_flow_level, 547 !!(fte->action.flags & FLOW_ACT_IGNORE_FLOW_LEVEL)); 548 549 MLX5_SET(set_fte_in, in, vport_number, ft->vport); 550 MLX5_SET(set_fte_in, in, other_vport, 551 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 552 553 in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); 554 MLX5_SET(flow_context, in_flow_context, group_id, group_id); 555 556 MLX5_SET(flow_context, in_flow_context, flow_tag, 557 fte->flow_context.flow_tag); 558 MLX5_SET(flow_context, in_flow_context, flow_source, 559 fte->flow_context.flow_source); 560 561 MLX5_SET(flow_context, in_flow_context, extended_destination, 562 extended_dest); 563 if (extended_dest) { 564 u32 action; 565 566 action = fte->action.action & 567 ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; 568 MLX5_SET(flow_context, in_flow_context, action, action); 569 } else { 570 MLX5_SET(flow_context, in_flow_context, action, 571 fte->action.action); 572 if (fte->action.pkt_reformat) 573 MLX5_SET(flow_context, in_flow_context, packet_reformat_id, 574 fte->action.pkt_reformat->id); 575 } 576 if (fte->action.modify_hdr) 577 MLX5_SET(flow_context, in_flow_context, modify_header_id, 578 fte->action.modify_hdr->id); 579 580 MLX5_SET(flow_context, in_flow_context, ipsec_obj_id, fte->action.ipsec_obj_id); 581 582 vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan); 583 584 MLX5_SET(vlan, vlan, ethtype, fte->action.vlan[0].ethtype); 585 MLX5_SET(vlan, vlan, vid, fte->action.vlan[0].vid); 586 MLX5_SET(vlan, vlan, prio, fte->action.vlan[0].prio); 587 588 vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan_2); 589 590 MLX5_SET(vlan, vlan, ethtype, fte->action.vlan[1].ethtype); 591 MLX5_SET(vlan, vlan, vid, fte->action.vlan[1].vid); 592 MLX5_SET(vlan, vlan, prio, fte->action.vlan[1].prio); 593 594 in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, 595 match_value); 596 memcpy(in_match_value, &fte->val, sizeof(fte->val)); 597 598 in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); 599 if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) { 600 int list_size = 0; 601 602 list_for_each_entry(dst, &fte->node.children, node.list) { 603 enum mlx5_flow_destination_type type = dst->dest_attr.type; 604 enum mlx5_ifc_flow_destination_type ifc_type; 605 unsigned int id; 606 607 if (type == MLX5_FLOW_DESTINATION_TYPE_COUNTER) 608 continue; 609 610 switch (type) { 611 case MLX5_FLOW_DESTINATION_TYPE_NONE: 612 continue; 613 case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE_NUM: 614 id = dst->dest_attr.ft_num; 615 ifc_type = MLX5_IFC_FLOW_DESTINATION_TYPE_FLOW_TABLE; 616 break; 617 case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE: 618 id = dst->dest_attr.ft->id; 619 ifc_type = MLX5_IFC_FLOW_DESTINATION_TYPE_FLOW_TABLE; 620 break; 621 case MLX5_FLOW_DESTINATION_TYPE_UPLINK: 622 case MLX5_FLOW_DESTINATION_TYPE_VPORT: 623 MLX5_SET(dest_format_struct, in_dests, 624 destination_eswitch_owner_vhca_id_valid, 625 !!(dst->dest_attr.vport.flags & 626 MLX5_FLOW_DEST_VPORT_VHCA_ID)); 627 MLX5_SET(dest_format_struct, in_dests, 628 destination_eswitch_owner_vhca_id, 629 dst->dest_attr.vport.vhca_id); 630 if (type == MLX5_FLOW_DESTINATION_TYPE_UPLINK) { 631 /* destination_id is reserved */ 632 id = 0; 633 ifc_type = MLX5_IFC_FLOW_DESTINATION_TYPE_UPLINK; 634 break; 635 } 636 ifc_type = MLX5_IFC_FLOW_DESTINATION_TYPE_VPORT; 637 id = dst->dest_attr.vport.num; 638 if (extended_dest && 639 dst->dest_attr.vport.pkt_reformat) { 640 MLX5_SET(dest_format_struct, in_dests, 641 packet_reformat, 642 !!(dst->dest_attr.vport.flags & 643 MLX5_FLOW_DEST_VPORT_REFORMAT_ID)); 644 MLX5_SET(extended_dest_format, in_dests, 645 packet_reformat_id, 646 dst->dest_attr.vport.pkt_reformat->id); 647 } 648 break; 649 case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER: 650 id = dst->dest_attr.sampler_id; 651 ifc_type = MLX5_IFC_FLOW_DESTINATION_TYPE_FLOW_SAMPLER; 652 break; 653 default: 654 id = dst->dest_attr.tir_num; 655 ifc_type = MLX5_IFC_FLOW_DESTINATION_TYPE_TIR; 656 } 657 658 MLX5_SET(dest_format_struct, in_dests, destination_type, 659 ifc_type); 660 MLX5_SET(dest_format_struct, in_dests, destination_id, id); 661 in_dests += dst_cnt_size; 662 list_size++; 663 } 664 665 MLX5_SET(flow_context, in_flow_context, destination_list_size, 666 list_size); 667 } 668 669 if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_COUNT) { 670 int max_list_size = BIT(MLX5_CAP_FLOWTABLE_TYPE(dev, 671 log_max_flow_counter, 672 ft->type)); 673 int list_size = 0; 674 675 list_for_each_entry(dst, &fte->node.children, node.list) { 676 if (dst->dest_attr.type != 677 MLX5_FLOW_DESTINATION_TYPE_COUNTER) 678 continue; 679 680 MLX5_SET(flow_counter_list, in_dests, flow_counter_id, 681 dst->dest_attr.counter_id); 682 in_dests += dst_cnt_size; 683 list_size++; 684 } 685 if (list_size > max_list_size) { 686 err = -EINVAL; 687 goto err_out; 688 } 689 690 MLX5_SET(flow_context, in_flow_context, flow_counter_list_size, 691 list_size); 692 } 693 694 if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO) { 695 if (fte->action.exe_aso.type == MLX5_EXE_ASO_FLOW_METER) { 696 mlx5_cmd_set_fte_flow_meter(fte, in_flow_context); 697 } else { 698 err = -EOPNOTSUPP; 699 goto err_out; 700 } 701 } 702 703 err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); 704 err_out: 705 kvfree(in); 706 return err; 707 } 708 709 static int mlx5_cmd_create_fte(struct mlx5_flow_root_namespace *ns, 710 struct mlx5_flow_table *ft, 711 struct mlx5_flow_group *group, 712 struct fs_fte *fte) 713 { 714 struct mlx5_core_dev *dev = ns->dev; 715 unsigned int group_id = group->id; 716 717 return mlx5_cmd_set_fte(dev, 0, 0, ft, group_id, fte); 718 } 719 720 static int mlx5_cmd_update_fte(struct mlx5_flow_root_namespace *ns, 721 struct mlx5_flow_table *ft, 722 struct mlx5_flow_group *fg, 723 int modify_mask, 724 struct fs_fte *fte) 725 { 726 int opmod; 727 struct mlx5_core_dev *dev = ns->dev; 728 int atomic_mod_cap = MLX5_CAP_FLOWTABLE(dev, 729 flow_table_properties_nic_receive. 730 flow_modify_en); 731 if (!atomic_mod_cap) 732 return -EOPNOTSUPP; 733 opmod = 1; 734 735 return mlx5_cmd_set_fte(dev, opmod, modify_mask, ft, fg->id, fte); 736 } 737 738 static int mlx5_cmd_delete_fte(struct mlx5_flow_root_namespace *ns, 739 struct mlx5_flow_table *ft, 740 struct fs_fte *fte) 741 { 742 u32 in[MLX5_ST_SZ_DW(delete_fte_in)] = {}; 743 struct mlx5_core_dev *dev = ns->dev; 744 745 MLX5_SET(delete_fte_in, in, opcode, MLX5_CMD_OP_DELETE_FLOW_TABLE_ENTRY); 746 MLX5_SET(delete_fte_in, in, table_type, ft->type); 747 MLX5_SET(delete_fte_in, in, table_id, ft->id); 748 MLX5_SET(delete_fte_in, in, flow_index, fte->index); 749 MLX5_SET(delete_fte_in, in, vport_number, ft->vport); 750 MLX5_SET(delete_fte_in, in, other_vport, 751 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT)); 752 753 return mlx5_cmd_exec_in(dev, delete_fte, in); 754 } 755 756 int mlx5_cmd_fc_bulk_alloc(struct mlx5_core_dev *dev, 757 enum mlx5_fc_bulk_alloc_bitmask alloc_bitmask, 758 u32 *id) 759 { 760 u32 out[MLX5_ST_SZ_DW(alloc_flow_counter_out)] = {}; 761 u32 in[MLX5_ST_SZ_DW(alloc_flow_counter_in)] = {}; 762 int err; 763 764 MLX5_SET(alloc_flow_counter_in, in, opcode, 765 MLX5_CMD_OP_ALLOC_FLOW_COUNTER); 766 MLX5_SET(alloc_flow_counter_in, in, flow_counter_bulk, alloc_bitmask); 767 768 err = mlx5_cmd_exec_inout(dev, alloc_flow_counter, in, out); 769 if (!err) 770 *id = MLX5_GET(alloc_flow_counter_out, out, flow_counter_id); 771 return err; 772 } 773 774 int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id) 775 { 776 return mlx5_cmd_fc_bulk_alloc(dev, 0, id); 777 } 778 779 int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id) 780 { 781 u32 in[MLX5_ST_SZ_DW(dealloc_flow_counter_in)] = {}; 782 783 MLX5_SET(dealloc_flow_counter_in, in, opcode, 784 MLX5_CMD_OP_DEALLOC_FLOW_COUNTER); 785 MLX5_SET(dealloc_flow_counter_in, in, flow_counter_id, id); 786 return mlx5_cmd_exec_in(dev, dealloc_flow_counter, in); 787 } 788 789 int mlx5_cmd_fc_query(struct mlx5_core_dev *dev, u32 id, 790 u64 *packets, u64 *bytes) 791 { 792 u32 out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + 793 MLX5_ST_SZ_BYTES(traffic_counter)] = {}; 794 u32 in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {}; 795 void *stats; 796 int err = 0; 797 798 MLX5_SET(query_flow_counter_in, in, opcode, 799 MLX5_CMD_OP_QUERY_FLOW_COUNTER); 800 MLX5_SET(query_flow_counter_in, in, op_mod, 0); 801 MLX5_SET(query_flow_counter_in, in, flow_counter_id, id); 802 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); 803 if (err) 804 return err; 805 806 stats = MLX5_ADDR_OF(query_flow_counter_out, out, flow_statistics); 807 *packets = MLX5_GET64(traffic_counter, stats, packets); 808 *bytes = MLX5_GET64(traffic_counter, stats, octets); 809 return 0; 810 } 811 812 int mlx5_cmd_fc_get_bulk_query_out_len(int bulk_len) 813 { 814 return MLX5_ST_SZ_BYTES(query_flow_counter_out) + 815 MLX5_ST_SZ_BYTES(traffic_counter) * bulk_len; 816 } 817 818 int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len, 819 u32 *out) 820 { 821 int outlen = mlx5_cmd_fc_get_bulk_query_out_len(bulk_len); 822 u32 in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {}; 823 824 MLX5_SET(query_flow_counter_in, in, opcode, 825 MLX5_CMD_OP_QUERY_FLOW_COUNTER); 826 MLX5_SET(query_flow_counter_in, in, flow_counter_id, base_id); 827 MLX5_SET(query_flow_counter_in, in, num_of_counters, bulk_len); 828 return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen); 829 } 830 831 static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, 832 struct mlx5_pkt_reformat_params *params, 833 enum mlx5_flow_namespace_type namespace, 834 struct mlx5_pkt_reformat *pkt_reformat) 835 { 836 u32 out[MLX5_ST_SZ_DW(alloc_packet_reformat_context_out)] = {}; 837 struct mlx5_core_dev *dev = ns->dev; 838 void *packet_reformat_context_in; 839 int max_encap_size; 840 void *reformat; 841 int inlen; 842 int err; 843 u32 *in; 844 845 if (namespace == MLX5_FLOW_NAMESPACE_FDB || 846 namespace == MLX5_FLOW_NAMESPACE_FDB_BYPASS) 847 max_encap_size = MLX5_CAP_ESW(dev, max_encap_header_size); 848 else 849 max_encap_size = MLX5_CAP_FLOWTABLE(dev, max_encap_header_size); 850 851 if (params->size > max_encap_size) { 852 mlx5_core_warn(dev, "encap size %zd too big, max supported is %d\n", 853 params->size, max_encap_size); 854 return -EINVAL; 855 } 856 857 in = kzalloc(MLX5_ST_SZ_BYTES(alloc_packet_reformat_context_in) + 858 params->size, GFP_KERNEL); 859 if (!in) 860 return -ENOMEM; 861 862 packet_reformat_context_in = MLX5_ADDR_OF(alloc_packet_reformat_context_in, 863 in, packet_reformat_context); 864 reformat = MLX5_ADDR_OF(packet_reformat_context_in, 865 packet_reformat_context_in, 866 reformat_data); 867 inlen = reformat - (void *)in + params->size; 868 869 MLX5_SET(alloc_packet_reformat_context_in, in, opcode, 870 MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT); 871 MLX5_SET(packet_reformat_context_in, packet_reformat_context_in, 872 reformat_data_size, params->size); 873 MLX5_SET(packet_reformat_context_in, packet_reformat_context_in, 874 reformat_type, params->type); 875 MLX5_SET(packet_reformat_context_in, packet_reformat_context_in, 876 reformat_param_0, params->param_0); 877 MLX5_SET(packet_reformat_context_in, packet_reformat_context_in, 878 reformat_param_1, params->param_1); 879 if (params->data && params->size) 880 memcpy(reformat, params->data, params->size); 881 882 err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); 883 884 pkt_reformat->id = MLX5_GET(alloc_packet_reformat_context_out, 885 out, packet_reformat_id); 886 kfree(in); 887 return err; 888 } 889 890 static void mlx5_cmd_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns, 891 struct mlx5_pkt_reformat *pkt_reformat) 892 { 893 u32 in[MLX5_ST_SZ_DW(dealloc_packet_reformat_context_in)] = {}; 894 struct mlx5_core_dev *dev = ns->dev; 895 896 MLX5_SET(dealloc_packet_reformat_context_in, in, opcode, 897 MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT); 898 MLX5_SET(dealloc_packet_reformat_context_in, in, packet_reformat_id, 899 pkt_reformat->id); 900 901 mlx5_cmd_exec_in(dev, dealloc_packet_reformat_context, in); 902 } 903 904 static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns, 905 u8 namespace, u8 num_actions, 906 void *modify_actions, 907 struct mlx5_modify_hdr *modify_hdr) 908 { 909 u32 out[MLX5_ST_SZ_DW(alloc_modify_header_context_out)] = {}; 910 int max_actions, actions_size, inlen, err; 911 struct mlx5_core_dev *dev = ns->dev; 912 void *actions_in; 913 u8 table_type; 914 u32 *in; 915 916 switch (namespace) { 917 case MLX5_FLOW_NAMESPACE_FDB: 918 case MLX5_FLOW_NAMESPACE_FDB_BYPASS: 919 max_actions = MLX5_CAP_ESW_FLOWTABLE_FDB(dev, max_modify_header_actions); 920 table_type = FS_FT_FDB; 921 break; 922 case MLX5_FLOW_NAMESPACE_KERNEL: 923 case MLX5_FLOW_NAMESPACE_BYPASS: 924 max_actions = MLX5_CAP_FLOWTABLE_NIC_RX(dev, max_modify_header_actions); 925 table_type = FS_FT_NIC_RX; 926 break; 927 case MLX5_FLOW_NAMESPACE_EGRESS: 928 case MLX5_FLOW_NAMESPACE_EGRESS_KERNEL: 929 max_actions = MLX5_CAP_FLOWTABLE_NIC_TX(dev, max_modify_header_actions); 930 table_type = FS_FT_NIC_TX; 931 break; 932 case MLX5_FLOW_NAMESPACE_ESW_INGRESS: 933 max_actions = MLX5_CAP_ESW_INGRESS_ACL(dev, max_modify_header_actions); 934 table_type = FS_FT_ESW_INGRESS_ACL; 935 break; 936 case MLX5_FLOW_NAMESPACE_RDMA_TX: 937 max_actions = MLX5_CAP_FLOWTABLE_RDMA_TX(dev, max_modify_header_actions); 938 table_type = FS_FT_RDMA_TX; 939 break; 940 default: 941 return -EOPNOTSUPP; 942 } 943 944 if (num_actions > max_actions) { 945 mlx5_core_warn(dev, "too many modify header actions %d, max supported %d\n", 946 num_actions, max_actions); 947 return -EOPNOTSUPP; 948 } 949 950 actions_size = MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto) * num_actions; 951 inlen = MLX5_ST_SZ_BYTES(alloc_modify_header_context_in) + actions_size; 952 953 in = kzalloc(inlen, GFP_KERNEL); 954 if (!in) 955 return -ENOMEM; 956 957 MLX5_SET(alloc_modify_header_context_in, in, opcode, 958 MLX5_CMD_OP_ALLOC_MODIFY_HEADER_CONTEXT); 959 MLX5_SET(alloc_modify_header_context_in, in, table_type, table_type); 960 MLX5_SET(alloc_modify_header_context_in, in, num_of_actions, num_actions); 961 962 actions_in = MLX5_ADDR_OF(alloc_modify_header_context_in, in, actions); 963 memcpy(actions_in, modify_actions, actions_size); 964 965 err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); 966 967 modify_hdr->id = MLX5_GET(alloc_modify_header_context_out, out, modify_header_id); 968 kfree(in); 969 return err; 970 } 971 972 static void mlx5_cmd_modify_header_dealloc(struct mlx5_flow_root_namespace *ns, 973 struct mlx5_modify_hdr *modify_hdr) 974 { 975 u32 in[MLX5_ST_SZ_DW(dealloc_modify_header_context_in)] = {}; 976 struct mlx5_core_dev *dev = ns->dev; 977 978 MLX5_SET(dealloc_modify_header_context_in, in, opcode, 979 MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT); 980 MLX5_SET(dealloc_modify_header_context_in, in, modify_header_id, 981 modify_hdr->id); 982 983 mlx5_cmd_exec_in(dev, dealloc_modify_header_context, in); 984 } 985 986 static int mlx5_cmd_destroy_match_definer(struct mlx5_flow_root_namespace *ns, 987 int definer_id) 988 { 989 u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {}; 990 u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; 991 992 MLX5_SET(general_obj_in_cmd_hdr, in, opcode, 993 MLX5_CMD_OP_DESTROY_GENERAL_OBJECT); 994 MLX5_SET(general_obj_in_cmd_hdr, in, obj_type, 995 MLX5_OBJ_TYPE_MATCH_DEFINER); 996 MLX5_SET(general_obj_in_cmd_hdr, in, obj_id, definer_id); 997 998 return mlx5_cmd_exec(ns->dev, in, sizeof(in), out, sizeof(out)); 999 } 1000 1001 static int mlx5_cmd_create_match_definer(struct mlx5_flow_root_namespace *ns, 1002 u16 format_id, u32 *match_mask) 1003 { 1004 u32 out[MLX5_ST_SZ_DW(create_match_definer_out)] = {}; 1005 u32 in[MLX5_ST_SZ_DW(create_match_definer_in)] = {}; 1006 struct mlx5_core_dev *dev = ns->dev; 1007 void *ptr; 1008 int err; 1009 1010 MLX5_SET(create_match_definer_in, in, general_obj_in_cmd_hdr.opcode, 1011 MLX5_CMD_OP_CREATE_GENERAL_OBJECT); 1012 MLX5_SET(create_match_definer_in, in, general_obj_in_cmd_hdr.obj_type, 1013 MLX5_OBJ_TYPE_MATCH_DEFINER); 1014 1015 ptr = MLX5_ADDR_OF(create_match_definer_in, in, obj_context); 1016 MLX5_SET(match_definer, ptr, format_id, format_id); 1017 1018 ptr = MLX5_ADDR_OF(match_definer, ptr, match_mask); 1019 memcpy(ptr, match_mask, MLX5_FLD_SZ_BYTES(match_definer, match_mask)); 1020 1021 err = mlx5_cmd_exec_inout(dev, create_match_definer, in, out); 1022 return err ? err : MLX5_GET(general_obj_out_cmd_hdr, out, obj_id); 1023 } 1024 1025 static u32 mlx5_cmd_get_capabilities(struct mlx5_flow_root_namespace *ns, 1026 enum fs_flow_table_type ft_type) 1027 { 1028 return 0; 1029 } 1030 1031 static const struct mlx5_flow_cmds mlx5_flow_cmds = { 1032 .create_flow_table = mlx5_cmd_create_flow_table, 1033 .destroy_flow_table = mlx5_cmd_destroy_flow_table, 1034 .modify_flow_table = mlx5_cmd_modify_flow_table, 1035 .create_flow_group = mlx5_cmd_create_flow_group, 1036 .destroy_flow_group = mlx5_cmd_destroy_flow_group, 1037 .create_fte = mlx5_cmd_create_fte, 1038 .update_fte = mlx5_cmd_update_fte, 1039 .delete_fte = mlx5_cmd_delete_fte, 1040 .update_root_ft = mlx5_cmd_update_root_ft, 1041 .packet_reformat_alloc = mlx5_cmd_packet_reformat_alloc, 1042 .packet_reformat_dealloc = mlx5_cmd_packet_reformat_dealloc, 1043 .modify_header_alloc = mlx5_cmd_modify_header_alloc, 1044 .modify_header_dealloc = mlx5_cmd_modify_header_dealloc, 1045 .create_match_definer = mlx5_cmd_create_match_definer, 1046 .destroy_match_definer = mlx5_cmd_destroy_match_definer, 1047 .set_peer = mlx5_cmd_stub_set_peer, 1048 .create_ns = mlx5_cmd_stub_create_ns, 1049 .destroy_ns = mlx5_cmd_stub_destroy_ns, 1050 .get_capabilities = mlx5_cmd_get_capabilities, 1051 }; 1052 1053 static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { 1054 .create_flow_table = mlx5_cmd_stub_create_flow_table, 1055 .destroy_flow_table = mlx5_cmd_stub_destroy_flow_table, 1056 .modify_flow_table = mlx5_cmd_stub_modify_flow_table, 1057 .create_flow_group = mlx5_cmd_stub_create_flow_group, 1058 .destroy_flow_group = mlx5_cmd_stub_destroy_flow_group, 1059 .create_fte = mlx5_cmd_stub_create_fte, 1060 .update_fte = mlx5_cmd_stub_update_fte, 1061 .delete_fte = mlx5_cmd_stub_delete_fte, 1062 .update_root_ft = mlx5_cmd_stub_update_root_ft, 1063 .packet_reformat_alloc = mlx5_cmd_stub_packet_reformat_alloc, 1064 .packet_reformat_dealloc = mlx5_cmd_stub_packet_reformat_dealloc, 1065 .modify_header_alloc = mlx5_cmd_stub_modify_header_alloc, 1066 .modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc, 1067 .create_match_definer = mlx5_cmd_stub_create_match_definer, 1068 .destroy_match_definer = mlx5_cmd_stub_destroy_match_definer, 1069 .set_peer = mlx5_cmd_stub_set_peer, 1070 .create_ns = mlx5_cmd_stub_create_ns, 1071 .destroy_ns = mlx5_cmd_stub_destroy_ns, 1072 .get_capabilities = mlx5_cmd_stub_get_capabilities, 1073 }; 1074 1075 const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) 1076 { 1077 return &mlx5_flow_cmds; 1078 } 1079 1080 static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_stub_cmds(void) 1081 { 1082 return &mlx5_flow_cmd_stubs; 1083 } 1084 1085 const struct mlx5_flow_cmds *mlx5_fs_cmd_get_default(enum fs_flow_table_type type) 1086 { 1087 switch (type) { 1088 case FS_FT_NIC_RX: 1089 case FS_FT_ESW_EGRESS_ACL: 1090 case FS_FT_ESW_INGRESS_ACL: 1091 case FS_FT_FDB: 1092 case FS_FT_SNIFFER_RX: 1093 case FS_FT_SNIFFER_TX: 1094 case FS_FT_NIC_TX: 1095 case FS_FT_RDMA_RX: 1096 case FS_FT_RDMA_TX: 1097 case FS_FT_PORT_SEL: 1098 return mlx5_fs_cmd_get_fw_cmds(); 1099 default: 1100 return mlx5_fs_cmd_get_stub_cmds(); 1101 } 1102 } 1103