Skip to content

Commit 50d6202

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: default Tx rule instead of to queue
Steer all packets that miss other rules to PF VSI. Previously in switchdev mode, PF VSI received missed packets, but only ones marked as Rx. Now it is receiving all missed packets. To queue rule per PR isn't needed, because we use PF VSI instead of control VSI now, and it's already correctly configured. Add flag to correctly set LAN_EN bit in default Tx rule. It shouldn't allow packet to go outside when there is a match. Reviewed-by: Marcin Szycik <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent defd524 commit 50d6202

File tree

4 files changed

+23
-97
lines changed

4 files changed

+23
-97
lines changed

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

Lines changed: 16 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,6 @@
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);
14264
err_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);
14772
err_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

586513
static 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

600525
static void

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ struct ice_repr {
1616
int q_id;
1717
u32 id;
1818
u8 parent_mac[ETH_ALEN];
19-
#ifdef CONFIG_ICE_SWITCHDEV
20-
/* info about slow path rule */
21-
struct ice_rule_query_data sp_rule;
22-
#endif
2319
};
2420

2521
struct ice_repr *ice_repr_add_vf(struct ice_vf *vf);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,9 @@ static void ice_fill_sw_info(struct ice_hw *hw, struct ice_fltr_info *fi)
24442444
fi->lan_en = true;
24452445
}
24462446
}
2447+
2448+
if (fi->flag & ICE_FLTR_TX_ONLY)
2449+
fi->lan_en = false;
24472450
}
24482451

24492452
/**
@@ -3819,6 +3822,7 @@ ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,
38193822
} else if (f_info.flag & ICE_FLTR_TX) {
38203823
f_info.src_id = ICE_SRC_ID_VSI;
38213824
f_info.src = hw_vsi_id;
3825+
f_info.flag |= ICE_FLTR_TX_ONLY;
38223826
}
38233827
f_list_entry.fltr_info = f_info;
38243828

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
#define ICE_SW_CFG_MAX_BUF_LEN 2048
1010
#define ICE_DFLT_VSI_INVAL 0xff
11-
#define ICE_FLTR_RX BIT(0)
12-
#define ICE_FLTR_TX BIT(1)
11+
#define ICE_FLTR_RX BIT(0)
12+
#define ICE_FLTR_TX BIT(1)
13+
#define ICE_FLTR_TX_ONLY BIT(2)
1314
#define ICE_VSI_INVAL_ID 0xffff
1415
#define ICE_INVAL_Q_HANDLE 0xFFFF
1516

0 commit comments

Comments
 (0)