1010#include "ice_devlink.h"
1111#include "ice_tc_lib.h"
1212
13- /**
14- * ice_eswitch_del_sp_rules - delete adv rules added on PRs
15- * @pf: pointer to the PF struct
16- *
17- * Delete all advanced rules that were used to forward packets with the
18- * device's VSI index to the corresponding eswitch ctrl VSI queue.
19- */
20- static void ice_eswitch_del_sp_rules (struct ice_pf * pf )
21- {
22- struct ice_repr * repr ;
23- unsigned long id ;
24-
25- xa_for_each (& pf -> eswitch .reprs , id , repr ) {
26- if (repr -> sp_rule .rid )
27- ice_rem_adv_rule_by_id (& pf -> hw , & repr -> sp_rule );
28- }
29- }
30-
31- /**
32- * ice_eswitch_add_sp_rule - add adv rule with device's VSI index
33- * @pf: pointer to PF struct
34- * @repr: pointer to the repr struct
35- *
36- * This function adds advanced rule that forwards packets with
37- * device's VSI index to the corresponding eswitch ctrl VSI queue.
38- */
39- static int ice_eswitch_add_sp_rule (struct ice_pf * pf , struct ice_repr * repr )
40- {
41- struct ice_vsi * ctrl_vsi = pf -> eswitch .control_vsi ;
42- struct ice_adv_rule_info rule_info = { 0 };
43- struct ice_adv_lkup_elem * list ;
44- struct ice_hw * hw = & pf -> hw ;
45- const u16 lkups_cnt = 1 ;
46- int err ;
47-
48- list = kcalloc (lkups_cnt , sizeof (* list ), GFP_ATOMIC );
49- if (!list )
50- return - ENOMEM ;
51-
52- ice_rule_add_src_vsi_metadata (list );
53-
54- rule_info .sw_act .flag = ICE_FLTR_TX ;
55- rule_info .sw_act .vsi_handle = ctrl_vsi -> idx ;
56- rule_info .sw_act .fltr_act = ICE_FWD_TO_Q ;
57- rule_info .sw_act .fwd_id .q_id = hw -> func_caps .common_cap .rxq_first_id +
58- ctrl_vsi -> rxq_map [repr -> q_id ];
59- rule_info .flags_info .act |= ICE_SINGLE_ACT_LB_ENABLE ;
60- rule_info .flags_info .act_valid = true;
61- rule_info .tun_type = ICE_SW_TUN_AND_NON_TUN ;
62- rule_info .src_vsi = repr -> src_vsi -> idx ;
63-
64- err = ice_add_adv_rule (hw , list , lkups_cnt , & rule_info ,
65- & repr -> sp_rule );
66- if (err )
67- dev_err (ice_pf_to_dev (pf ), "Unable to add slow-path rule for eswitch for PR %d" ,
68- repr -> id );
69-
70- kfree (list );
71- return err ;
72- }
73-
74- static int
75- ice_eswitch_add_sp_rules (struct ice_pf * pf )
76- {
77- struct ice_repr * repr ;
78- unsigned long id ;
79- int err ;
80-
81- xa_for_each (& pf -> eswitch .reprs , id , repr ) {
82- err = ice_eswitch_add_sp_rule (pf , repr );
83- if (err ) {
84- ice_eswitch_del_sp_rules (pf );
85- return err ;
86- }
87- }
88-
89- return 0 ;
90- }
91-
9213/**
9314 * ice_eswitch_setup_env - configure eswitch HW filters
9415 * @pf: pointer to PF struct
@@ -102,7 +23,6 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
10223 struct ice_vsi * ctrl_vsi = pf -> eswitch .control_vsi ;
10324 struct net_device * netdev = uplink_vsi -> netdev ;
10425 struct ice_vsi_vlan_ops * vlan_ops ;
105- bool rule_added = false;
10626
10727 ice_remove_vsi_fltr (& pf -> hw , uplink_vsi -> idx );
10828
@@ -112,17 +32,19 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
11232 netif_addr_unlock_bh (netdev );
11333
11434 if (ice_vsi_add_vlan_zero (uplink_vsi ))
35+ goto err_vlan_zero ;
36+
37+ if (ice_cfg_dflt_vsi (uplink_vsi -> port_info , uplink_vsi -> idx , true,
38+ ICE_FLTR_RX ))
11539 goto err_def_rx ;
11640
117- if (!ice_is_dflt_vsi_in_use (uplink_vsi -> port_info )) {
118- if (ice_set_dflt_vsi (uplink_vsi ))
119- goto err_def_rx ;
120- rule_added = true;
121- }
41+ if (ice_cfg_dflt_vsi (uplink_vsi -> port_info , uplink_vsi -> idx , true,
42+ ICE_FLTR_TX ))
43+ goto err_def_tx ;
12244
12345 vlan_ops = ice_get_compat_vsi_vlan_ops (uplink_vsi );
12446 if (vlan_ops -> dis_rx_filtering (uplink_vsi ))
125- goto err_dis_rx ;
47+ goto err_vlan_filtering ;
12648
12749 if (ice_vsi_update_security (uplink_vsi , ice_vsi_ctx_set_allow_override ))
12850 goto err_override_uplink ;
@@ -141,10 +63,15 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
14163 ice_vsi_update_security (uplink_vsi , ice_vsi_ctx_clear_allow_override );
14264err_override_uplink :
14365 vlan_ops -> ena_rx_filtering (uplink_vsi );
144- err_dis_rx :
145- if (rule_added )
146- ice_clear_dflt_vsi (uplink_vsi );
66+ err_vlan_filtering :
67+ ice_cfg_dflt_vsi (uplink_vsi -> port_info , uplink_vsi -> idx , false,
68+ ICE_FLTR_TX );
69+ err_def_tx :
70+ ice_cfg_dflt_vsi (uplink_vsi -> port_info , uplink_vsi -> idx , false,
71+ ICE_FLTR_RX );
14772err_def_rx :
73+ ice_vsi_del_vlan_zero (uplink_vsi );
74+ err_vlan_zero :
14875 ice_fltr_add_mac_and_broadcast (uplink_vsi ,
14976 uplink_vsi -> port_info -> mac .perm_addr ,
15077 ICE_FWD_TO_VSI );
@@ -585,7 +512,6 @@ void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf)
585512
586513static void ice_eswitch_stop_reprs (struct ice_pf * pf )
587514{
588- ice_eswitch_del_sp_rules (pf );
589515 ice_eswitch_stop_all_tx_queues (pf );
590516 ice_eswitch_napi_disable (& pf -> eswitch .reprs );
591517}
@@ -594,7 +520,6 @@ static void ice_eswitch_start_reprs(struct ice_pf *pf)
594520{
595521 ice_eswitch_napi_enable (& pf -> eswitch .reprs );
596522 ice_eswitch_start_all_tx_queues (pf );
597- ice_eswitch_add_sp_rules (pf );
598523}
599524
600525static void
0 commit comments