Skip to content

Commit 9dffb97

Browse files
Michal Swiatkowskidavem330
authored andcommitted
ice: add drop rule matching on not active lport
Inactive LAG port should not receive any packets, as it can cause adding invalid FDBs (bridge offload). Add a drop rule matching on inactive lport in LAG. Reviewed-by: Simon Horman <[email protected]> Co-developed-by: Marcin Szycik <[email protected]> Signed-off-by: Marcin Szycik <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4cd7bc7 commit 9dffb97

File tree

3 files changed

+75
-20
lines changed

3 files changed

+75
-20
lines changed

drivers/net/ethernet/intel/ice/ice_eswitch_br.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ice_eswitch_br_ingress_rule_setup(struct ice_adv_rule_info *rule_info,
7373
rule_info->sw_act.vsi_handle = vf_vsi_idx;
7474
rule_info->sw_act.flag |= ICE_FLTR_RX;
7575
rule_info->sw_act.src = pf_id;
76-
rule_info->priority = 5;
76+
rule_info->priority = 2;
7777
}
7878

7979
static void
@@ -84,7 +84,7 @@ ice_eswitch_br_egress_rule_setup(struct ice_adv_rule_info *rule_info,
8484
rule_info->sw_act.flag |= ICE_FLTR_TX;
8585
rule_info->flags_info.act = ICE_SINGLE_ACT_LAN_ENABLE;
8686
rule_info->flags_info.act_valid = true;
87-
rule_info->priority = 5;
87+
rule_info->priority = 2;
8888
}
8989

9090
static int
@@ -207,7 +207,7 @@ ice_eswitch_br_guard_rule_create(struct ice_hw *hw, u16 vsi_idx,
207207
rule_info.allow_pass_l2 = true;
208208
rule_info.sw_act.vsi_handle = vsi_idx;
209209
rule_info.sw_act.fltr_act = ICE_NOP;
210-
rule_info.priority = 5;
210+
rule_info.priority = 2;
211211

212212
err = ice_add_adv_rule(hw, list, lkups_cnt, &rule_info, rule);
213213
if (err)

drivers/net/ethernet/intel/ice/ice_lag.c

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ static const u8 lacp_train_pkt[LACP_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
1919
static const u8 ice_dflt_vsi_rcp[ICE_RECIPE_LEN] = {
2020
0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2121
0x85, 0, 0x01, 0, 0, 0, 0xff, 0xff, 0x08, 0, 0, 0, 0, 0, 0, 0,
22-
0, 0, 0, 0, 0, 0, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
22+
0, 0, 0, 0, 0, 0, 0x30 };
23+
static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
24+
0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25+
0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
26+
0, 0, 0, 0, 0, 0, 0x30 };
2427

2528
/**
2629
* ice_lag_set_primary - set PF LAG state as Primary
@@ -173,18 +176,22 @@ static struct ice_lag *ice_lag_find_primary(struct ice_lag *lag)
173176
}
174177

175178
/**
176-
* ice_lag_cfg_dflt_fltr - Add/Remove default VSI rule for LAG
179+
* ice_lag_cfg_fltr - Add/Remove rule for LAG
177180
* @lag: lag struct for local interface
181+
* @act: rule action
182+
* @recipe_id: recipe id for the new rule
183+
* @rule_idx: pointer to rule index
178184
* @add: boolean on whether we are adding filters
179185
*/
180186
static int
181-
ice_lag_cfg_dflt_fltr(struct ice_lag *lag, bool add)
187+
ice_lag_cfg_fltr(struct ice_lag *lag, u32 act, u16 recipe_id, u16 *rule_idx,
188+
bool add)
182189
{
183190
struct ice_sw_rule_lkup_rx_tx *s_rule;
184191
u16 s_rule_sz, vsi_num;
185192
struct ice_hw *hw;
186-
u32 act, opc;
187193
u8 *eth_hdr;
194+
u32 opc;
188195
int err;
189196

190197
hw = &lag->pf->hw;
@@ -193,27 +200,25 @@ ice_lag_cfg_dflt_fltr(struct ice_lag *lag, bool add)
193200
s_rule_sz = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE(s_rule);
194201
s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
195202
if (!s_rule) {
196-
dev_err(ice_pf_to_dev(lag->pf), "error allocating rule for LAG default VSI\n");
203+
dev_err(ice_pf_to_dev(lag->pf), "error allocating rule for LAG\n");
197204
return -ENOMEM;
198205
}
199206

200207
if (add) {
201208
eth_hdr = s_rule->hdr_data;
202209
ice_fill_eth_hdr(eth_hdr);
203210

204-
act = (vsi_num << ICE_SINGLE_ACT_VSI_ID_S) &
211+
act |= (vsi_num << ICE_SINGLE_ACT_VSI_ID_S) &
205212
ICE_SINGLE_ACT_VSI_ID_M;
206-
act |= ICE_SINGLE_ACT_VSI_FORWARDING |
207-
ICE_SINGLE_ACT_VALID_BIT | ICE_SINGLE_ACT_LAN_ENABLE;
208213

209214
s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
210-
s_rule->recipe_id = cpu_to_le16(lag->pf_recipe);
215+
s_rule->recipe_id = cpu_to_le16(recipe_id);
211216
s_rule->src = cpu_to_le16(hw->port_info->lport);
212217
s_rule->act = cpu_to_le32(act);
213218
s_rule->hdr_len = cpu_to_le16(DUMMY_ETH_HDR_LEN);
214219
opc = ice_aqc_opc_add_sw_rules;
215220
} else {
216-
s_rule->index = cpu_to_le16(lag->pf_rule_id);
221+
s_rule->index = cpu_to_le16(*rule_idx);
217222
opc = ice_aqc_opc_remove_sw_rules;
218223
}
219224

@@ -222,15 +227,46 @@ ice_lag_cfg_dflt_fltr(struct ice_lag *lag, bool add)
222227
goto dflt_fltr_free;
223228

224229
if (add)
225-
lag->pf_rule_id = le16_to_cpu(s_rule->index);
230+
*rule_idx = le16_to_cpu(s_rule->index);
226231
else
227-
lag->pf_rule_id = 0;
232+
*rule_idx = 0;
228233

229234
dflt_fltr_free:
230235
kfree(s_rule);
231236
return err;
232237
}
233238

239+
/**
240+
* ice_lag_cfg_dflt_fltr - Add/Remove default VSI rule for LAG
241+
* @lag: lag struct for local interface
242+
* @add: boolean on whether to add filter
243+
*/
244+
static int
245+
ice_lag_cfg_dflt_fltr(struct ice_lag *lag, bool add)
246+
{
247+
u32 act = ICE_SINGLE_ACT_VSI_FORWARDING |
248+
ICE_SINGLE_ACT_VALID_BIT | ICE_SINGLE_ACT_LAN_ENABLE;
249+
250+
return ice_lag_cfg_fltr(lag, act, lag->pf_recipe,
251+
&lag->pf_rule_id, add);
252+
}
253+
254+
/**
255+
* ice_lag_cfg_drop_fltr - Add/Remove lport drop rule
256+
* @lag: lag struct for local interface
257+
* @add: boolean on whether to add filter
258+
*/
259+
static int
260+
ice_lag_cfg_drop_fltr(struct ice_lag *lag, bool add)
261+
{
262+
u32 act = ICE_SINGLE_ACT_VSI_FORWARDING |
263+
ICE_SINGLE_ACT_VALID_BIT |
264+
ICE_SINGLE_ACT_DROP;
265+
266+
return ice_lag_cfg_fltr(lag, act, lag->lport_recipe,
267+
&lag->lport_rule_idx, add);
268+
}
269+
234270
/**
235271
* ice_lag_cfg_pf_fltrs - set filters up for new active port
236272
* @lag: local interfaces lag struct
@@ -257,13 +293,18 @@ ice_lag_cfg_pf_fltrs(struct ice_lag *lag, void *ptr)
257293
if (bonding_info->slave.state && lag->pf_rule_id) {
258294
if (ice_lag_cfg_dflt_fltr(lag, false))
259295
dev_err(dev, "Error removing old default VSI filter\n");
296+
if (ice_lag_cfg_drop_fltr(lag, true))
297+
dev_err(dev, "Error adding new drop filter\n");
260298
return;
261299
}
262300

263301
/* interface becoming active - add new default VSI rule */
264-
if (!bonding_info->slave.state && !lag->pf_rule_id)
302+
if (!bonding_info->slave.state && !lag->pf_rule_id) {
265303
if (ice_lag_cfg_dflt_fltr(lag, true))
266304
dev_err(dev, "Error adding new default VSI filter\n");
305+
if (lag->lport_rule_idx && ice_lag_cfg_drop_fltr(lag, false))
306+
dev_err(dev, "Error removing old drop filter\n");
307+
}
267308
}
268309

269310
/**
@@ -1179,6 +1220,7 @@ static void ice_lag_changeupper_event(struct ice_lag *lag, void *ptr)
11791220
swid = primary_lag->pf->hw.port_info->sw_id;
11801221
ice_lag_set_swid(swid, lag, true);
11811222
ice_lag_add_prune_list(primary_lag, lag->pf);
1223+
ice_lag_cfg_drop_fltr(lag, true);
11821224
}
11831225
/* add filter for primary control packets */
11841226
ice_lag_cfg_cp_fltr(lag, true);
@@ -1929,11 +1971,16 @@ int ice_init_lag(struct ice_pf *pf)
19291971
goto lag_error;
19301972
}
19311973

1932-
err = ice_create_lag_recipe(&pf->hw, &lag->pf_recipe, ice_dflt_vsi_rcp,
1933-
1);
1974+
err = ice_create_lag_recipe(&pf->hw, &lag->pf_recipe,
1975+
ice_dflt_vsi_rcp, 1);
19341976
if (err)
19351977
goto lag_error;
19361978

1979+
err = ice_create_lag_recipe(&pf->hw, &lag->lport_recipe,
1980+
ice_lport_rcp, 3);
1981+
if (err)
1982+
goto free_rcp_res;
1983+
19371984
/* associate recipes to profiles */
19381985
for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) {
19391986
err = ice_aq_get_recipe_to_profile(&pf->hw, n,
@@ -1942,7 +1989,8 @@ int ice_init_lag(struct ice_pf *pf)
19421989
continue;
19431990

19441991
if (recipe_bits & BIT(ICE_SW_LKUP_DFLT)) {
1945-
recipe_bits |= BIT(lag->pf_recipe);
1992+
recipe_bits |= BIT(lag->pf_recipe) |
1993+
BIT(lag->lport_recipe);
19461994
ice_aq_map_recipe_to_profile(&pf->hw, n,
19471995
(u8 *)&recipe_bits, NULL);
19481996
}
@@ -1953,6 +2001,9 @@ int ice_init_lag(struct ice_pf *pf)
19532001
dev_dbg(dev, "INIT LAG complete\n");
19542002
return 0;
19552003

2004+
free_rcp_res:
2005+
ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
2006+
&pf->lag->pf_recipe);
19562007
lag_error:
19572008
kfree(lag);
19582009
pf->lag = NULL;
@@ -1982,6 +2033,8 @@ void ice_deinit_lag(struct ice_pf *pf)
19822033

19832034
ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
19842035
&pf->lag->pf_recipe);
2036+
ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
2037+
&pf->lag->lport_recipe);
19852038

19862039
kfree(lag);
19872040

drivers/net/ethernet/intel/ice/ice_lag.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ struct ice_lag {
3939
u8 bonded:1; /* currently bonded */
4040
u8 primary:1; /* this is primary */
4141
u16 pf_recipe;
42+
u16 lport_recipe;
4243
u16 pf_rule_id;
4344
u16 cp_rule_idx;
45+
u16 lport_rule_idx;
4446
u8 role;
4547
};
4648

0 commit comments

Comments
 (0)