Lines Matching refs:fs

74 static int mlx5e_add_l2_flow_rule(struct mlx5e_flow_steering *fs,
76 static void mlx5e_del_l2_flow_rule(struct mlx5e_flow_steering *fs,
109 struct dentry *mlx5e_fs_get_debugfs_root(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_debugfs_root() argument
111 return fs->dfs_root; in mlx5e_fs_get_debugfs_root()
170 static int mlx5e_vport_context_update_vlans(struct mlx5e_flow_steering *fs) in mlx5e_vport_context_update_vlans() argument
180 for_each_set_bit(vlan, fs->vlan->active_cvlans, VLAN_N_VID) in mlx5e_vport_context_update_vlans()
183 max_list_size = 1 << MLX5_CAP_GEN(fs->mdev, log_max_vlan_list); in mlx5e_vport_context_update_vlans()
186 …fs_warn(fs, "netdev vlans list size (%d) > (%d) max vport list size, some vlans will be dropped\n", in mlx5e_vport_context_update_vlans()
196 for_each_set_bit(vlan, fs->vlan->active_cvlans, VLAN_N_VID) { in mlx5e_vport_context_update_vlans()
202 err = mlx5_modify_nic_vport_vlans(fs->mdev, vlans, list_size); in mlx5e_vport_context_update_vlans()
204 fs_err(fs, "Failed to modify vport vlans list err(%d)\n", in mlx5e_vport_context_update_vlans()
219 static int __mlx5e_add_vlan_rule(struct mlx5e_flow_steering *fs, in __mlx5e_add_vlan_rule() argument
223 struct mlx5_flow_table *ft = fs->vlan->ft.t; in __mlx5e_add_vlan_rule()
230 dest.ft = fs->l2.ft.t; in __mlx5e_add_vlan_rule()
240 rule_p = &fs->vlan->untagged_rule; in __mlx5e_add_vlan_rule()
245 rule_p = &fs->vlan->any_cvlan_rule; in __mlx5e_add_vlan_rule()
251 rule_p = &fs->vlan->any_svlan_rule; in __mlx5e_add_vlan_rule()
257 rule_p = &fs->vlan->active_svlans_rule[vid]; in __mlx5e_add_vlan_rule()
267 rule_p = &fs->vlan->active_cvlans_rule[vid]; in __mlx5e_add_vlan_rule()
286 fs_err(fs, "add rule failed\n"); in __mlx5e_add_vlan_rule()
292 static int mlx5e_add_vlan_rule(struct mlx5e_flow_steering *fs, in mlx5e_add_vlan_rule() argument
303 mlx5e_vport_context_update_vlans(fs); in mlx5e_add_vlan_rule()
305 err = __mlx5e_add_vlan_rule(fs, rule_type, vid, spec); in mlx5e_add_vlan_rule()
312 static void mlx5e_fs_del_vlan_rule(struct mlx5e_flow_steering *fs, in mlx5e_fs_del_vlan_rule() argument
317 if (fs->vlan->untagged_rule) { in mlx5e_fs_del_vlan_rule()
318 mlx5_del_flow_rules(fs->vlan->untagged_rule); in mlx5e_fs_del_vlan_rule()
319 fs->vlan->untagged_rule = NULL; in mlx5e_fs_del_vlan_rule()
323 if (fs->vlan->any_cvlan_rule) { in mlx5e_fs_del_vlan_rule()
324 mlx5_del_flow_rules(fs->vlan->any_cvlan_rule); in mlx5e_fs_del_vlan_rule()
325 fs->vlan->any_cvlan_rule = NULL; in mlx5e_fs_del_vlan_rule()
329 if (fs->vlan->any_svlan_rule) { in mlx5e_fs_del_vlan_rule()
330 mlx5_del_flow_rules(fs->vlan->any_svlan_rule); in mlx5e_fs_del_vlan_rule()
331 fs->vlan->any_svlan_rule = NULL; in mlx5e_fs_del_vlan_rule()
335 if (fs->vlan->active_svlans_rule[vid]) { in mlx5e_fs_del_vlan_rule()
336 mlx5_del_flow_rules(fs->vlan->active_svlans_rule[vid]); in mlx5e_fs_del_vlan_rule()
337 fs->vlan->active_svlans_rule[vid] = NULL; in mlx5e_fs_del_vlan_rule()
341 if (fs->vlan->active_cvlans_rule[vid]) { in mlx5e_fs_del_vlan_rule()
342 mlx5_del_flow_rules(fs->vlan->active_cvlans_rule[vid]); in mlx5e_fs_del_vlan_rule()
343 fs->vlan->active_cvlans_rule[vid] = NULL; in mlx5e_fs_del_vlan_rule()
345 mlx5e_vport_context_update_vlans(fs); in mlx5e_fs_del_vlan_rule()
350 static void mlx5e_fs_del_any_vid_rules(struct mlx5e_flow_steering *fs) in mlx5e_fs_del_any_vid_rules() argument
352 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_ANY_CTAG_VID, 0); in mlx5e_fs_del_any_vid_rules()
353 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_ANY_STAG_VID, 0); in mlx5e_fs_del_any_vid_rules()
356 static int mlx5e_fs_add_any_vid_rules(struct mlx5e_flow_steering *fs) in mlx5e_fs_add_any_vid_rules() argument
360 err = mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_ANY_CTAG_VID, 0); in mlx5e_fs_add_any_vid_rules()
364 return mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_ANY_STAG_VID, 0); in mlx5e_fs_add_any_vid_rules()
388 int mlx5e_add_vlan_trap(struct mlx5e_flow_steering *fs, int trap_id, int tir_num) in mlx5e_add_vlan_trap() argument
390 struct mlx5_flow_table *ft = fs->vlan->ft.t; in mlx5e_add_vlan_trap()
397 fs->vlan->trap_rule = NULL; in mlx5e_add_vlan_trap()
398 fs_err(fs, "add VLAN trap rule failed, err %d\n", err); in mlx5e_add_vlan_trap()
401 fs->vlan->trap_rule = rule; in mlx5e_add_vlan_trap()
405 void mlx5e_remove_vlan_trap(struct mlx5e_flow_steering *fs) in mlx5e_remove_vlan_trap() argument
407 if (fs->vlan->trap_rule) { in mlx5e_remove_vlan_trap()
408 mlx5_del_flow_rules(fs->vlan->trap_rule); in mlx5e_remove_vlan_trap()
409 fs->vlan->trap_rule = NULL; in mlx5e_remove_vlan_trap()
413 int mlx5e_add_mac_trap(struct mlx5e_flow_steering *fs, int trap_id, int tir_num) in mlx5e_add_mac_trap() argument
415 struct mlx5_flow_table *ft = fs->l2.ft.t; in mlx5e_add_mac_trap()
422 fs->l2.trap_rule = NULL; in mlx5e_add_mac_trap()
423 fs_err(fs, "add MAC trap rule failed, err %d\n", err); in mlx5e_add_mac_trap()
426 fs->l2.trap_rule = rule; in mlx5e_add_mac_trap()
430 void mlx5e_remove_mac_trap(struct mlx5e_flow_steering *fs) in mlx5e_remove_mac_trap() argument
432 if (fs->l2.trap_rule) { in mlx5e_remove_mac_trap()
433 mlx5_del_flow_rules(fs->l2.trap_rule); in mlx5e_remove_mac_trap()
434 fs->l2.trap_rule = NULL; in mlx5e_remove_mac_trap()
438 void mlx5e_enable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc) in mlx5e_enable_cvlan_filter() argument
440 if (!fs->vlan->cvlan_filter_disabled) in mlx5e_enable_cvlan_filter()
443 fs->vlan->cvlan_filter_disabled = false; in mlx5e_enable_cvlan_filter()
446 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_ANY_CTAG_VID, 0); in mlx5e_enable_cvlan_filter()
449 void mlx5e_disable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc) in mlx5e_disable_cvlan_filter() argument
451 if (!fs->vlan || fs->vlan->cvlan_filter_disabled) in mlx5e_disable_cvlan_filter()
454 fs->vlan->cvlan_filter_disabled = true; in mlx5e_disable_cvlan_filter()
457 mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_ANY_CTAG_VID, 0); in mlx5e_disable_cvlan_filter()
460 static int mlx5e_vlan_rx_add_cvid(struct mlx5e_flow_steering *fs, u16 vid) in mlx5e_vlan_rx_add_cvid() argument
464 set_bit(vid, fs->vlan->active_cvlans); in mlx5e_vlan_rx_add_cvid()
466 err = mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_CTAG_VID, vid); in mlx5e_vlan_rx_add_cvid()
468 clear_bit(vid, fs->vlan->active_cvlans); in mlx5e_vlan_rx_add_cvid()
473 static int mlx5e_vlan_rx_add_svid(struct mlx5e_flow_steering *fs, in mlx5e_vlan_rx_add_svid() argument
478 set_bit(vid, fs->vlan->active_svlans); in mlx5e_vlan_rx_add_svid()
480 err = mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_STAG_VID, vid); in mlx5e_vlan_rx_add_svid()
482 clear_bit(vid, fs->vlan->active_svlans); in mlx5e_vlan_rx_add_svid()
491 int mlx5e_fs_vlan_rx_add_vid(struct mlx5e_flow_steering *fs, in mlx5e_fs_vlan_rx_add_vid() argument
496 if (!fs->vlan) { in mlx5e_fs_vlan_rx_add_vid()
497 fs_err(fs, "Vlan doesn't exist\n"); in mlx5e_fs_vlan_rx_add_vid()
502 return mlx5e_vlan_rx_add_cvid(fs, vid); in mlx5e_fs_vlan_rx_add_vid()
504 return mlx5e_vlan_rx_add_svid(fs, netdev, vid); in mlx5e_fs_vlan_rx_add_vid()
509 int mlx5e_fs_vlan_rx_kill_vid(struct mlx5e_flow_steering *fs, in mlx5e_fs_vlan_rx_kill_vid() argument
513 if (!fs->vlan) { in mlx5e_fs_vlan_rx_kill_vid()
514 fs_err(fs, "Vlan doesn't exist\n"); in mlx5e_fs_vlan_rx_kill_vid()
519 clear_bit(vid, fs->vlan->active_cvlans); in mlx5e_fs_vlan_rx_kill_vid()
520 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_CTAG_VID, vid); in mlx5e_fs_vlan_rx_kill_vid()
522 clear_bit(vid, fs->vlan->active_svlans); in mlx5e_fs_vlan_rx_kill_vid()
523 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_STAG_VID, vid); in mlx5e_fs_vlan_rx_kill_vid()
530 static void mlx5e_fs_add_vlan_rules(struct mlx5e_flow_steering *fs) in mlx5e_fs_add_vlan_rules() argument
534 mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_UNTAGGED, 0); in mlx5e_fs_add_vlan_rules()
536 for_each_set_bit(i, fs->vlan->active_cvlans, VLAN_N_VID) { in mlx5e_fs_add_vlan_rules()
537 mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_CTAG_VID, i); in mlx5e_fs_add_vlan_rules()
540 for_each_set_bit(i, fs->vlan->active_svlans, VLAN_N_VID) in mlx5e_fs_add_vlan_rules()
541 mlx5e_add_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_STAG_VID, i); in mlx5e_fs_add_vlan_rules()
543 if (fs->vlan->cvlan_filter_disabled) in mlx5e_fs_add_vlan_rules()
544 mlx5e_fs_add_any_vid_rules(fs); in mlx5e_fs_add_vlan_rules()
547 static void mlx5e_del_vlan_rules(struct mlx5e_flow_steering *fs) in mlx5e_del_vlan_rules() argument
551 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_UNTAGGED, 0); in mlx5e_del_vlan_rules()
553 for_each_set_bit(i, fs->vlan->active_cvlans, VLAN_N_VID) { in mlx5e_del_vlan_rules()
554 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_CTAG_VID, i); in mlx5e_del_vlan_rules()
557 for_each_set_bit(i, fs->vlan->active_svlans, VLAN_N_VID) in mlx5e_del_vlan_rules()
558 mlx5e_fs_del_vlan_rule(fs, MLX5E_VLAN_RULE_TYPE_MATCH_STAG_VID, i); in mlx5e_del_vlan_rules()
560 WARN_ON_ONCE(fs->state_destroy); in mlx5e_del_vlan_rules()
562 mlx5e_remove_vlan_trap(fs); in mlx5e_del_vlan_rules()
567 if (fs->vlan->cvlan_filter_disabled) in mlx5e_del_vlan_rules()
568 mlx5e_fs_del_any_vid_rules(fs); in mlx5e_del_vlan_rules()
575 static void mlx5e_execute_l2_action(struct mlx5e_flow_steering *fs, in mlx5e_execute_l2_action() argument
586 mlx5e_add_l2_flow_rule(fs, &hn->ai, MLX5E_FULLMATCH); in mlx5e_execute_l2_action()
588 l2_err = mlx5_mpfs_add_mac(fs->mdev, mac_addr); in mlx5e_execute_l2_action()
596 l2_err = mlx5_mpfs_del_mac(fs->mdev, mac_addr); in mlx5e_execute_l2_action()
597 mlx5e_del_l2_flow_rule(fs, &hn->ai); in mlx5e_execute_l2_action()
603 fs_warn(fs, "MPFS, failed to %s mac %pM, err(%d)\n", in mlx5e_execute_l2_action()
608 static void mlx5e_sync_netdev_addr(struct mlx5e_flow_steering *fs, in mlx5e_sync_netdev_addr() argument
615 mlx5e_add_l2_to_hash(fs->l2.netdev_uc, netdev->dev_addr); in mlx5e_sync_netdev_addr()
617 mlx5e_add_l2_to_hash(fs->l2.netdev_uc, ha->addr); in mlx5e_sync_netdev_addr()
620 mlx5e_add_l2_to_hash(fs->l2.netdev_mc, ha->addr); in mlx5e_sync_netdev_addr()
625 static void mlx5e_fill_addr_array(struct mlx5e_flow_steering *fs, int list_type, in mlx5e_fill_addr_array() argument
636 addr_list = is_uc ? fs->l2.netdev_uc : fs->l2.netdev_mc; in mlx5e_fill_addr_array()
640 else if (fs->l2.broadcast_enabled) in mlx5e_fill_addr_array()
652 static void mlx5e_vport_context_update_addr_list(struct mlx5e_flow_steering *fs, in mlx5e_vport_context_update_addr_list() argument
666 size = is_uc ? 0 : (fs->l2.broadcast_enabled ? 1 : 0); in mlx5e_vport_context_update_addr_list()
668 1 << MLX5_CAP_GEN(fs->mdev, log_max_current_uc_list) : in mlx5e_vport_context_update_addr_list()
669 1 << MLX5_CAP_GEN(fs->mdev, log_max_current_mc_list); in mlx5e_vport_context_update_addr_list()
671 addr_list = is_uc ? fs->l2.netdev_uc : fs->l2.netdev_mc; in mlx5e_vport_context_update_addr_list()
676 fs_warn(fs, "mdev %s list size (%d) > (%d) max vport list size, some addresses will be dropped\n", in mlx5e_vport_context_update_addr_list()
687 mlx5e_fill_addr_array(fs, list_type, netdev, addr_array, size); in mlx5e_vport_context_update_addr_list()
690 err = mlx5_modify_nic_vport_mac_list(fs->mdev, list_type, addr_array, size); in mlx5e_vport_context_update_addr_list()
693 fs_err(fs, "Failed to modify vport %s list err(%d)\n", in mlx5e_vport_context_update_addr_list()
698 static void mlx5e_vport_context_update(struct mlx5e_flow_steering *fs, in mlx5e_vport_context_update() argument
701 struct mlx5e_l2_table *ea = &fs->l2; in mlx5e_vport_context_update()
703 mlx5e_vport_context_update_addr_list(fs, netdev, MLX5_NVPRT_LIST_TYPE_UC); in mlx5e_vport_context_update()
704 mlx5e_vport_context_update_addr_list(fs, netdev, MLX5_NVPRT_LIST_TYPE_MC); in mlx5e_vport_context_update()
705 mlx5_modify_nic_vport_promisc(fs->mdev, 0, in mlx5e_vport_context_update()
710 static void mlx5e_apply_netdev_addr(struct mlx5e_flow_steering *fs) in mlx5e_apply_netdev_addr() argument
716 mlx5e_for_each_hash_node(hn, tmp, fs->l2.netdev_uc, i) in mlx5e_apply_netdev_addr()
717 mlx5e_execute_l2_action(fs, hn); in mlx5e_apply_netdev_addr()
719 mlx5e_for_each_hash_node(hn, tmp, fs->l2.netdev_mc, i) in mlx5e_apply_netdev_addr()
720 mlx5e_execute_l2_action(fs, hn); in mlx5e_apply_netdev_addr()
723 static void mlx5e_handle_netdev_addr(struct mlx5e_flow_steering *fs, in mlx5e_handle_netdev_addr() argument
730 mlx5e_for_each_hash_node(hn, tmp, fs->l2.netdev_uc, i) in mlx5e_handle_netdev_addr()
732 mlx5e_for_each_hash_node(hn, tmp, fs->l2.netdev_mc, i) in mlx5e_handle_netdev_addr()
735 if (fs->state_destroy) in mlx5e_handle_netdev_addr()
736 mlx5e_sync_netdev_addr(fs, netdev); in mlx5e_handle_netdev_addr()
738 mlx5e_apply_netdev_addr(fs); in mlx5e_handle_netdev_addr()
744 static int mlx5e_add_promisc_rule(struct mlx5e_flow_steering *fs) in mlx5e_add_promisc_rule() argument
746 struct mlx5_flow_table *ft = fs->promisc.ft.t; in mlx5e_add_promisc_rule()
757 dest.ft = mlx5_get_ttc_flow_table(fs->ttc); in mlx5e_add_promisc_rule()
759 rule_p = &fs->promisc.rule; in mlx5e_add_promisc_rule()
764 fs_err(fs, "add promiscuous rule failed\n"); in mlx5e_add_promisc_rule()
770 static int mlx5e_create_promisc_table(struct mlx5e_flow_steering *fs) in mlx5e_create_promisc_table() argument
772 struct mlx5e_flow_table *ft = &fs->promisc.ft; in mlx5e_create_promisc_table()
781 ft->t = mlx5_create_auto_grouped_flow_table(fs->ns, &ft_attr); in mlx5e_create_promisc_table()
785 fs_err(fs, "fail to create promisc table err=%d\n", err); in mlx5e_create_promisc_table()
789 err = mlx5e_add_promisc_rule(fs); in mlx5e_create_promisc_table()
802 static void mlx5e_del_promisc_rule(struct mlx5e_flow_steering *fs) in mlx5e_del_promisc_rule() argument
804 if (WARN(!fs->promisc.rule, "Trying to remove non-existing promiscuous rule")) in mlx5e_del_promisc_rule()
806 mlx5_del_flow_rules(fs->promisc.rule); in mlx5e_del_promisc_rule()
807 fs->promisc.rule = NULL; in mlx5e_del_promisc_rule()
810 static void mlx5e_destroy_promisc_table(struct mlx5e_flow_steering *fs) in mlx5e_destroy_promisc_table() argument
812 if (!fs->promisc.ft.t) in mlx5e_destroy_promisc_table()
814 mlx5e_del_promisc_rule(fs); in mlx5e_destroy_promisc_table()
815 mlx5_destroy_flow_table(fs->promisc.ft.t); in mlx5e_destroy_promisc_table()
816 fs->promisc.ft.t = NULL; in mlx5e_destroy_promisc_table()
819 void mlx5e_fs_set_rx_mode_work(struct mlx5e_flow_steering *fs, in mlx5e_fs_set_rx_mode_work() argument
822 struct mlx5e_l2_table *ea = &fs->l2; in mlx5e_fs_set_rx_mode_work()
824 bool rx_mode_enable = fs->state_destroy; in mlx5e_fs_set_rx_mode_work()
838 err = mlx5e_create_promisc_table(fs); in mlx5e_fs_set_rx_mode_work()
841 if (!fs->vlan_strip_disable && !err) in mlx5e_fs_set_rx_mode_work()
842 fs_warn_once(fs, in mlx5e_fs_set_rx_mode_work()
846 mlx5e_add_l2_flow_rule(fs, &ea->allmulti, MLX5E_ALLMULTI); in mlx5e_fs_set_rx_mode_work()
848 mlx5e_add_l2_flow_rule(fs, &ea->broadcast, MLX5E_FULLMATCH); in mlx5e_fs_set_rx_mode_work()
850 mlx5e_handle_netdev_addr(fs, netdev); in mlx5e_fs_set_rx_mode_work()
853 mlx5e_del_l2_flow_rule(fs, &ea->broadcast); in mlx5e_fs_set_rx_mode_work()
855 mlx5e_del_l2_flow_rule(fs, &ea->allmulti); in mlx5e_fs_set_rx_mode_work()
857 mlx5e_destroy_promisc_table(fs); in mlx5e_fs_set_rx_mode_work()
863 mlx5e_vport_context_update(fs, netdev); in mlx5e_fs_set_rx_mode_work()
878 void mlx5e_fs_init_l2_addr(struct mlx5e_flow_steering *fs, struct net_device *netdev) in mlx5e_fs_init_l2_addr() argument
880 ether_addr_copy(fs->l2.broadcast.addr, netdev->broadcast); in mlx5e_fs_init_l2_addr()
891 static void mlx5e_set_inner_ttc_params(struct mlx5e_flow_steering *fs, in mlx5e_set_inner_ttc_params() argument
899 ttc_params->ns = mlx5_get_flow_namespace(fs->mdev, in mlx5e_set_inner_ttc_params()
914 void mlx5e_set_ttc_params(struct mlx5e_flow_steering *fs, in mlx5e_set_ttc_params() argument
923 ttc_params->ns = mlx5_get_flow_namespace(fs->mdev, in mlx5e_set_ttc_params()
937 if (!tunnel || !mlx5_tunnel_inner_ft_supported(fs->mdev)) in mlx5e_set_ttc_params()
944 mlx5_get_ttc_flow_table(fs->inner_ttc); in mlx5e_set_ttc_params()
948 static void mlx5e_del_l2_flow_rule(struct mlx5e_flow_steering *fs, in mlx5e_del_l2_flow_rule() argument
957 static int mlx5e_add_l2_flow_rule(struct mlx5e_flow_steering *fs, in mlx5e_add_l2_flow_rule() argument
960 struct mlx5_flow_table *ft = fs->l2.ft.t; in mlx5e_add_l2_flow_rule()
978 dest.ft = mlx5_get_ttc_flow_table(fs->ttc); in mlx5e_add_l2_flow_rule()
996 fs_err(fs, "add l2 rule(mac:%pM) failed\n", mv_dmac); in mlx5e_add_l2_flow_rule()
1080 static void mlx5e_destroy_l2_table(struct mlx5e_flow_steering *fs) in mlx5e_destroy_l2_table() argument
1082 mlx5e_destroy_flow_table(&fs->l2.ft); in mlx5e_destroy_l2_table()
1085 static int mlx5e_create_l2_table(struct mlx5e_flow_steering *fs) in mlx5e_create_l2_table() argument
1087 struct mlx5e_l2_table *l2_table = &fs->l2; in mlx5e_create_l2_table()
1098 ft->t = mlx5_create_flow_table(fs->ns, &ft_attr); in mlx5e_create_l2_table()
1218 static int mlx5e_fs_create_vlan_table(struct mlx5e_flow_steering *fs) in mlx5e_fs_create_vlan_table() argument
1224 ft = &fs->vlan->ft; in mlx5e_fs_create_vlan_table()
1231 ft->t = mlx5_create_flow_table(fs->ns, &ft_attr); in mlx5e_fs_create_vlan_table()
1245 mlx5e_fs_add_vlan_rules(fs); in mlx5e_fs_create_vlan_table()
1257 static void mlx5e_destroy_vlan_table(struct mlx5e_flow_steering *fs) in mlx5e_destroy_vlan_table() argument
1259 mlx5e_del_vlan_rules(fs); in mlx5e_destroy_vlan_table()
1260 mlx5e_destroy_flow_table(&fs->vlan->ft); in mlx5e_destroy_vlan_table()
1263 static void mlx5e_destroy_inner_ttc_table(struct mlx5e_flow_steering *fs) in mlx5e_destroy_inner_ttc_table() argument
1265 if (!mlx5_tunnel_inner_ft_supported(fs->mdev)) in mlx5e_destroy_inner_ttc_table()
1267 mlx5_destroy_ttc_table(fs->inner_ttc); in mlx5e_destroy_inner_ttc_table()
1270 void mlx5e_destroy_ttc_table(struct mlx5e_flow_steering *fs) in mlx5e_destroy_ttc_table() argument
1272 mlx5_destroy_ttc_table(fs->ttc); in mlx5e_destroy_ttc_table()
1275 static int mlx5e_create_inner_ttc_table(struct mlx5e_flow_steering *fs, in mlx5e_create_inner_ttc_table() argument
1280 if (!mlx5_tunnel_inner_ft_supported(fs->mdev)) in mlx5e_create_inner_ttc_table()
1283 mlx5e_set_inner_ttc_params(fs, rx_res, &ttc_params); in mlx5e_create_inner_ttc_table()
1284 fs->inner_ttc = mlx5_create_inner_ttc_table(fs->mdev, in mlx5e_create_inner_ttc_table()
1286 if (IS_ERR(fs->inner_ttc)) in mlx5e_create_inner_ttc_table()
1287 return PTR_ERR(fs->inner_ttc); in mlx5e_create_inner_ttc_table()
1291 int mlx5e_create_ttc_table(struct mlx5e_flow_steering *fs, in mlx5e_create_ttc_table() argument
1296 mlx5e_set_ttc_params(fs, rx_res, &ttc_params, true); in mlx5e_create_ttc_table()
1297 fs->ttc = mlx5_create_ttc_table(fs->mdev, &ttc_params); in mlx5e_create_ttc_table()
1298 if (IS_ERR(fs->ttc)) in mlx5e_create_ttc_table()
1299 return PTR_ERR(fs->ttc); in mlx5e_create_ttc_table()
1303 int mlx5e_create_flow_steering(struct mlx5e_flow_steering *fs, in mlx5e_create_flow_steering() argument
1308 struct mlx5_flow_namespace *ns = mlx5_get_flow_namespace(fs->mdev, in mlx5e_create_flow_steering()
1315 mlx5e_fs_set_ns(fs, ns, false); in mlx5e_create_flow_steering()
1316 err = mlx5e_arfs_create_tables(fs, rx_res, in mlx5e_create_flow_steering()
1319 fs_err(fs, "Failed to create arfs tables, err=%d\n", err); in mlx5e_create_flow_steering()
1323 err = mlx5e_create_inner_ttc_table(fs, rx_res); in mlx5e_create_flow_steering()
1325 fs_err(fs, "Failed to create inner ttc table, err=%d\n", err); in mlx5e_create_flow_steering()
1329 err = mlx5e_create_ttc_table(fs, rx_res); in mlx5e_create_flow_steering()
1331 fs_err(fs, "Failed to create ttc table, err=%d\n", err); in mlx5e_create_flow_steering()
1335 err = mlx5e_create_l2_table(fs); in mlx5e_create_flow_steering()
1337 fs_err(fs, "Failed to create l2 table, err=%d\n", err); in mlx5e_create_flow_steering()
1341 err = mlx5e_fs_create_vlan_table(fs); in mlx5e_create_flow_steering()
1343 fs_err(fs, "Failed to create vlan table, err=%d\n", err); in mlx5e_create_flow_steering()
1347 err = mlx5e_ptp_alloc_rx_fs(fs, profile); in mlx5e_create_flow_steering()
1351 mlx5e_ethtool_init_steering(fs); in mlx5e_create_flow_steering()
1356 mlx5e_destroy_vlan_table(fs); in mlx5e_create_flow_steering()
1358 mlx5e_destroy_l2_table(fs); in mlx5e_create_flow_steering()
1360 mlx5e_destroy_ttc_table(fs); in mlx5e_create_flow_steering()
1362 mlx5e_destroy_inner_ttc_table(fs); in mlx5e_create_flow_steering()
1364 mlx5e_arfs_destroy_tables(fs, !!(netdev->hw_features & NETIF_F_NTUPLE)); in mlx5e_create_flow_steering()
1369 void mlx5e_destroy_flow_steering(struct mlx5e_flow_steering *fs, bool ntuple, in mlx5e_destroy_flow_steering() argument
1372 mlx5e_ptp_free_rx_fs(fs, profile); in mlx5e_destroy_flow_steering()
1373 mlx5e_destroy_vlan_table(fs); in mlx5e_destroy_flow_steering()
1374 mlx5e_destroy_l2_table(fs); in mlx5e_destroy_flow_steering()
1375 mlx5e_destroy_ttc_table(fs); in mlx5e_destroy_flow_steering()
1376 mlx5e_destroy_inner_ttc_table(fs); in mlx5e_destroy_flow_steering()
1377 mlx5e_arfs_destroy_tables(fs, ntuple); in mlx5e_destroy_flow_steering()
1378 mlx5e_ethtool_cleanup_steering(fs); in mlx5e_destroy_flow_steering()
1381 static int mlx5e_fs_vlan_alloc(struct mlx5e_flow_steering *fs) in mlx5e_fs_vlan_alloc() argument
1383 fs->vlan = kvzalloc(sizeof(*fs->vlan), GFP_KERNEL); in mlx5e_fs_vlan_alloc()
1384 if (!fs->vlan) in mlx5e_fs_vlan_alloc()
1389 static void mlx5e_fs_vlan_free(struct mlx5e_flow_steering *fs) in mlx5e_fs_vlan_free() argument
1391 kvfree(fs->vlan); in mlx5e_fs_vlan_free()
1394 struct mlx5e_vlan_table *mlx5e_fs_get_vlan(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_vlan() argument
1396 return fs->vlan; in mlx5e_fs_get_vlan()
1399 static int mlx5e_fs_tc_alloc(struct mlx5e_flow_steering *fs) in mlx5e_fs_tc_alloc() argument
1401 fs->tc = mlx5e_tc_table_alloc(); in mlx5e_fs_tc_alloc()
1402 if (IS_ERR(fs->tc)) in mlx5e_fs_tc_alloc()
1407 static void mlx5e_fs_tc_free(struct mlx5e_flow_steering *fs) in mlx5e_fs_tc_free() argument
1409 mlx5e_tc_table_free(fs->tc); in mlx5e_fs_tc_free()
1412 struct mlx5e_tc_table *mlx5e_fs_get_tc(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_tc() argument
1414 return fs->tc; in mlx5e_fs_get_tc()
1418 static int mlx5e_fs_ethtool_alloc(struct mlx5e_flow_steering *fs) in mlx5e_fs_ethtool_alloc() argument
1420 return mlx5e_ethtool_alloc(&fs->ethtool); in mlx5e_fs_ethtool_alloc()
1423 static void mlx5e_fs_ethtool_free(struct mlx5e_flow_steering *fs) in mlx5e_fs_ethtool_free() argument
1425 mlx5e_ethtool_free(fs->ethtool); in mlx5e_fs_ethtool_free()
1428 struct mlx5e_ethtool_steering *mlx5e_fs_get_ethtool(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_ethtool() argument
1430 return fs->ethtool; in mlx5e_fs_get_ethtool()
1433 static int mlx5e_fs_ethtool_alloc(struct mlx5e_flow_steering *fs) in mlx5e_fs_ethtool_alloc() argument
1435 static void mlx5e_fs_ethtool_free(struct mlx5e_flow_steering *fs) { } in mlx5e_fs_ethtool_free() argument
1438 static void mlx5e_fs_debugfs_init(struct mlx5e_flow_steering *fs, in mlx5e_fs_debugfs_init() argument
1444 fs->dfs_root = debugfs_create_dir("fs", dfs_root); in mlx5e_fs_debugfs_init()
1452 struct mlx5e_flow_steering *fs; in mlx5e_fs_init() local
1455 fs = kvzalloc(sizeof(*fs), GFP_KERNEL); in mlx5e_fs_init()
1456 if (!fs) in mlx5e_fs_init()
1459 fs->mdev = mdev; in mlx5e_fs_init()
1460 fs->state_destroy = state_destroy; in mlx5e_fs_init()
1462 err = mlx5e_fs_vlan_alloc(fs); in mlx5e_fs_init()
1468 err = mlx5e_fs_tc_alloc(fs); in mlx5e_fs_init()
1473 err = mlx5e_fs_ethtool_alloc(fs); in mlx5e_fs_init()
1477 mlx5e_fs_debugfs_init(fs, dfs_root); in mlx5e_fs_init()
1479 return fs; in mlx5e_fs_init()
1481 mlx5e_fs_tc_free(fs); in mlx5e_fs_init()
1483 mlx5e_fs_vlan_free(fs); in mlx5e_fs_init()
1485 kvfree(fs); in mlx5e_fs_init()
1490 void mlx5e_fs_cleanup(struct mlx5e_flow_steering *fs) in mlx5e_fs_cleanup() argument
1492 if (!fs) in mlx5e_fs_cleanup()
1494 debugfs_remove_recursive(fs->dfs_root); in mlx5e_fs_cleanup()
1495 mlx5e_fs_ethtool_free(fs); in mlx5e_fs_cleanup()
1496 mlx5e_fs_tc_free(fs); in mlx5e_fs_cleanup()
1497 mlx5e_fs_vlan_free(fs); in mlx5e_fs_cleanup()
1498 kvfree(fs); in mlx5e_fs_cleanup()
1501 struct mlx5e_l2_table *mlx5e_fs_get_l2(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_l2() argument
1503 return &fs->l2; in mlx5e_fs_get_l2()
1506 struct mlx5_flow_namespace *mlx5e_fs_get_ns(struct mlx5e_flow_steering *fs, bool egress) in mlx5e_fs_get_ns() argument
1508 return egress ? fs->egress_ns : fs->ns; in mlx5e_fs_get_ns()
1511 void mlx5e_fs_set_ns(struct mlx5e_flow_steering *fs, struct mlx5_flow_namespace *ns, bool egress) in mlx5e_fs_set_ns() argument
1514 fs->ns = ns; in mlx5e_fs_set_ns()
1516 fs->egress_ns = ns; in mlx5e_fs_set_ns()
1519 struct mlx5_ttc_table *mlx5e_fs_get_ttc(struct mlx5e_flow_steering *fs, bool inner) in mlx5e_fs_get_ttc() argument
1521 return inner ? fs->inner_ttc : fs->ttc; in mlx5e_fs_get_ttc()
1524 void mlx5e_fs_set_ttc(struct mlx5e_flow_steering *fs, struct mlx5_ttc_table *ttc, bool inner) in mlx5e_fs_set_ttc() argument
1527 fs->ttc = ttc; in mlx5e_fs_set_ttc()
1529 fs->inner_ttc = ttc; in mlx5e_fs_set_ttc()
1533 struct mlx5e_arfs_tables *mlx5e_fs_get_arfs(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_arfs() argument
1535 return fs->arfs; in mlx5e_fs_get_arfs()
1538 void mlx5e_fs_set_arfs(struct mlx5e_flow_steering *fs, struct mlx5e_arfs_tables *arfs) in mlx5e_fs_set_arfs() argument
1540 fs->arfs = arfs; in mlx5e_fs_set_arfs()
1544 struct mlx5e_ptp_fs *mlx5e_fs_get_ptp(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_ptp() argument
1546 return fs->ptp_fs; in mlx5e_fs_get_ptp()
1549 void mlx5e_fs_set_ptp(struct mlx5e_flow_steering *fs, struct mlx5e_ptp_fs *ptp_fs) in mlx5e_fs_set_ptp() argument
1551 fs->ptp_fs = ptp_fs; in mlx5e_fs_set_ptp()
1554 struct mlx5e_fs_any *mlx5e_fs_get_any(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_any() argument
1556 return fs->any; in mlx5e_fs_get_any()
1559 void mlx5e_fs_set_any(struct mlx5e_flow_steering *fs, struct mlx5e_fs_any *any) in mlx5e_fs_set_any() argument
1561 fs->any = any; in mlx5e_fs_set_any()
1565 struct mlx5e_accel_fs_tcp *mlx5e_fs_get_accel_tcp(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_accel_tcp() argument
1567 return fs->accel_tcp; in mlx5e_fs_get_accel_tcp()
1570 void mlx5e_fs_set_accel_tcp(struct mlx5e_flow_steering *fs, struct mlx5e_accel_fs_tcp *accel_tcp) in mlx5e_fs_set_accel_tcp() argument
1572 fs->accel_tcp = accel_tcp; in mlx5e_fs_set_accel_tcp()
1576 void mlx5e_fs_set_state_destroy(struct mlx5e_flow_steering *fs, bool state_destroy) in mlx5e_fs_set_state_destroy() argument
1578 fs->state_destroy = state_destroy; in mlx5e_fs_set_state_destroy()
1581 void mlx5e_fs_set_vlan_strip_disable(struct mlx5e_flow_steering *fs, in mlx5e_fs_set_vlan_strip_disable() argument
1584 fs->vlan_strip_disable = vlan_strip_disable; in mlx5e_fs_set_vlan_strip_disable()
1587 struct mlx5e_fs_udp *mlx5e_fs_get_udp(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_udp() argument
1589 return fs->udp; in mlx5e_fs_get_udp()
1592 void mlx5e_fs_set_udp(struct mlx5e_flow_steering *fs, struct mlx5e_fs_udp *udp) in mlx5e_fs_set_udp() argument
1594 fs->udp = udp; in mlx5e_fs_set_udp()
1597 struct mlx5_core_dev *mlx5e_fs_get_mdev(struct mlx5e_flow_steering *fs) in mlx5e_fs_get_mdev() argument
1599 return fs->mdev; in mlx5e_fs_get_mdev()