10
10
#include "ice_tc_lib.h"
11
11
12
12
/**
13
- * ice_eswitch_add_vf_mac_rule - add adv rule with VF's MAC
13
+ * ice_eswitch_add_vf_sp_rule - add adv rule with VF's VSI index
14
14
* @pf: pointer to PF struct
15
15
* @vf: pointer to VF struct
16
- * @mac: VF's MAC address
17
16
*
18
17
* This function adds advanced rule that forwards packets with
19
- * VF's MAC address (src MAC) to the corresponding switchdev ctrl VSI queue.
18
+ * VF's VSI index to the corresponding switchdev ctrl VSI queue.
20
19
*/
21
- int
22
- ice_eswitch_add_vf_mac_rule (struct ice_pf * pf , struct ice_vf * vf , const u8 * mac )
20
+ static int
21
+ ice_eswitch_add_vf_sp_rule (struct ice_pf * pf , struct ice_vf * vf )
23
22
{
24
23
struct ice_vsi * ctrl_vsi = pf -> switchdev .control_vsi ;
25
24
struct ice_adv_rule_info rule_info = { 0 };
@@ -32,76 +31,41 @@ ice_eswitch_add_vf_mac_rule(struct ice_pf *pf, struct ice_vf *vf, const u8 *mac)
32
31
if (!list )
33
32
return - ENOMEM ;
34
33
35
- list [0 ].type = ICE_MAC_OFOS ;
36
- ether_addr_copy (list [0 ].h_u .eth_hdr .src_addr , mac );
37
- eth_broadcast_addr (list [0 ].m_u .eth_hdr .src_addr );
34
+ ice_rule_add_src_vsi_metadata (list );
38
35
39
- rule_info .sw_act .flag | = ICE_FLTR_TX ;
36
+ rule_info .sw_act .flag = ICE_FLTR_TX ;
40
37
rule_info .sw_act .vsi_handle = ctrl_vsi -> idx ;
41
38
rule_info .sw_act .fltr_act = ICE_FWD_TO_Q ;
42
- rule_info .rx = false;
43
39
rule_info .sw_act .fwd_id .q_id = hw -> func_caps .common_cap .rxq_first_id +
44
40
ctrl_vsi -> rxq_map [vf -> vf_id ];
45
41
rule_info .flags_info .act |= ICE_SINGLE_ACT_LB_ENABLE ;
46
42
rule_info .flags_info .act_valid = true;
47
43
rule_info .tun_type = ICE_SW_TUN_AND_NON_TUN ;
44
+ rule_info .src_vsi = vf -> lan_vsi_idx ;
48
45
49
46
err = ice_add_adv_rule (hw , list , lkups_cnt , & rule_info ,
50
- vf -> repr -> mac_rule );
47
+ & vf -> repr -> sp_rule );
51
48
if (err )
52
- dev_err (ice_pf_to_dev (pf ), "Unable to add VF mac rule in switchdev mode for VF %d" ,
49
+ dev_err (ice_pf_to_dev (pf ), "Unable to add VF slow-path rule in switchdev mode for VF %d" ,
53
50
vf -> vf_id );
54
- else
55
- vf -> repr -> rule_added = true;
56
51
57
52
kfree (list );
58
53
return err ;
59
54
}
60
55
61
56
/**
62
- * ice_eswitch_replay_vf_mac_rule - replay adv rule with VF's MAC
63
- * @vf: pointer to vF struct
64
- *
65
- * This function replays VF's MAC rule after reset.
66
- */
67
- void ice_eswitch_replay_vf_mac_rule (struct ice_vf * vf )
68
- {
69
- int err ;
70
-
71
- if (!ice_is_switchdev_running (vf -> pf ))
72
- return ;
73
-
74
- if (is_valid_ether_addr (vf -> hw_lan_addr )) {
75
- err = ice_eswitch_add_vf_mac_rule (vf -> pf , vf ,
76
- vf -> hw_lan_addr );
77
- if (err ) {
78
- dev_err (ice_pf_to_dev (vf -> pf ), "Failed to add MAC %pM for VF %d\n, error %d\n" ,
79
- vf -> hw_lan_addr , vf -> vf_id , err );
80
- return ;
81
- }
82
- vf -> num_mac ++ ;
83
-
84
- ether_addr_copy (vf -> dev_lan_addr , vf -> hw_lan_addr );
85
- }
86
- }
87
-
88
- /**
89
- * ice_eswitch_del_vf_mac_rule - delete adv rule with VF's MAC
57
+ * ice_eswitch_del_vf_sp_rule - delete adv rule with VF's VSI index
90
58
* @vf: pointer to the VF struct
91
59
*
92
- * Delete the advanced rule that was used to forward packets with the VF's MAC
93
- * address (src MAC) to the corresponding switchdev ctrl VSI queue.
60
+ * Delete the advanced rule that was used to forward packets with the VF's VSI
61
+ * index to the corresponding switchdev ctrl VSI queue.
94
62
*/
95
- void ice_eswitch_del_vf_mac_rule (struct ice_vf * vf )
63
+ static void ice_eswitch_del_vf_sp_rule (struct ice_vf * vf )
96
64
{
97
- if (!ice_is_switchdev_running (vf -> pf ))
98
- return ;
99
-
100
- if (!vf -> repr -> rule_added )
65
+ if (!vf -> repr )
101
66
return ;
102
67
103
- ice_rem_adv_rule_by_id (& vf -> pf -> hw , vf -> repr -> mac_rule );
104
- vf -> repr -> rule_added = false;
68
+ ice_rem_adv_rule_by_id (& vf -> pf -> hw , & vf -> repr -> sp_rule );
105
69
}
106
70
107
71
/**
@@ -237,6 +201,7 @@ ice_eswitch_release_reprs(struct ice_pf *pf, struct ice_vsi *ctrl_vsi)
237
201
ice_vsi_update_security (vsi , ice_vsi_ctx_set_antispoof );
238
202
metadata_dst_free (vf -> repr -> dst );
239
203
vf -> repr -> dst = NULL ;
204
+ ice_eswitch_del_vf_sp_rule (vf );
240
205
ice_fltr_add_mac_and_broadcast (vsi , vf -> hw_lan_addr ,
241
206
ICE_FWD_TO_VSI );
242
207
@@ -264,25 +229,30 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)
264
229
vf -> repr -> dst = metadata_dst_alloc (0 , METADATA_HW_PORT_MUX ,
265
230
GFP_KERNEL );
266
231
if (!vf -> repr -> dst ) {
267
- ice_fltr_add_mac_and_broadcast (vsi ,
268
- vf -> hw_lan_addr ,
232
+ ice_fltr_add_mac_and_broadcast (vsi , vf -> hw_lan_addr ,
233
+ ICE_FWD_TO_VSI );
234
+ goto err ;
235
+ }
236
+
237
+ if (ice_eswitch_add_vf_sp_rule (pf , vf )) {
238
+ ice_fltr_add_mac_and_broadcast (vsi , vf -> hw_lan_addr ,
269
239
ICE_FWD_TO_VSI );
270
240
goto err ;
271
241
}
272
242
273
243
if (ice_vsi_update_security (vsi , ice_vsi_ctx_clear_antispoof )) {
274
- ice_fltr_add_mac_and_broadcast (vsi ,
275
- vf -> hw_lan_addr ,
244
+ ice_fltr_add_mac_and_broadcast (vsi , vf -> hw_lan_addr ,
276
245
ICE_FWD_TO_VSI );
246
+ ice_eswitch_del_vf_sp_rule (vf );
277
247
metadata_dst_free (vf -> repr -> dst );
278
248
vf -> repr -> dst = NULL ;
279
249
goto err ;
280
250
}
281
251
282
252
if (ice_vsi_add_vlan_zero (vsi )) {
283
- ice_fltr_add_mac_and_broadcast (vsi ,
284
- vf -> hw_lan_addr ,
253
+ ice_fltr_add_mac_and_broadcast (vsi , vf -> hw_lan_addr ,
285
254
ICE_FWD_TO_VSI );
255
+ ice_eswitch_del_vf_sp_rule (vf );
286
256
metadata_dst_free (vf -> repr -> dst );
287
257
vf -> repr -> dst = NULL ;
288
258
ice_vsi_update_security (vsi , ice_vsi_ctx_set_antispoof );
0 commit comments