Skip to content

Commit 83af003

Browse files
Henry TiemanJeff Kirsher
authored andcommitted
ice: Restore filters following reset
Following a reset, Flow Director filters are cleared from the hardware. Rebuild the filters using the software structures containing the filter rules. Signed-off-by: Henry Tieman <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 2c57ffc commit 83af003

File tree

4 files changed

+109
-6
lines changed

4 files changed

+109
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ int
566566
ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd,
567567
u32 *rule_locs);
568568
void ice_fdir_release_flows(struct ice_hw *hw);
569+
void ice_fdir_replay_flows(struct ice_hw *hw);
570+
void ice_fdir_replay_fltrs(struct ice_pf *pf);
569571
int ice_fdir_create_dflt_rules(struct ice_pf *pf);
570572
int ice_open(struct net_device *netdev);
571573
int ice_stop(struct net_device *netdev);

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,53 @@ void ice_fdir_release_flows(struct ice_hw *hw)
348348
ice_fdir_erase_flow_from_hw(hw, ICE_BLK_FD, flow);
349349
}
350350

351+
/**
352+
* ice_fdir_replay_flows - replay HW Flow Director filter info
353+
* @hw: pointer to HW instance
354+
*/
355+
void ice_fdir_replay_flows(struct ice_hw *hw)
356+
{
357+
int flow;
358+
359+
for (flow = 0; flow < ICE_FLTR_PTYPE_MAX; flow++) {
360+
int tun;
361+
362+
if (!hw->fdir_prof[flow] || !hw->fdir_prof[flow]->cnt)
363+
continue;
364+
for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
365+
struct ice_flow_prof *hw_prof;
366+
struct ice_fd_hw_prof *prof;
367+
u64 prof_id;
368+
int j;
369+
370+
prof = hw->fdir_prof[flow];
371+
prof_id = flow + tun * ICE_FLTR_PTYPE_MAX;
372+
ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX, prof_id,
373+
prof->fdir_seg[tun], TNL_SEG_CNT(tun),
374+
&hw_prof);
375+
for (j = 0; j < prof->cnt; j++) {
376+
enum ice_flow_priority prio;
377+
u64 entry_h = 0;
378+
int err;
379+
380+
prio = ICE_FLOW_PRIO_NORMAL;
381+
err = ice_flow_add_entry(hw, ICE_BLK_FD,
382+
prof_id,
383+
prof->vsi_h[0],
384+
prof->vsi_h[j],
385+
prio, prof->fdir_seg,
386+
&entry_h);
387+
if (err) {
388+
dev_err(ice_hw_to_dev(hw), "Could not replay Flow Director, flow type %d\n",
389+
flow);
390+
continue;
391+
}
392+
prof->entry_h[j][tun] = entry_h;
393+
}
394+
}
395+
}
396+
}
397+
351398
/**
352399
* ice_parse_rx_flow_user_data - deconstruct user-defined data
353400
* @fsp: pointer to ethtool Rx flow specification
@@ -1225,6 +1272,24 @@ ice_fdir_write_all_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input,
12251272
return 0;
12261273
}
12271274

1275+
/**
1276+
* ice_fdir_replay_fltrs - replay filters from the HW filter list
1277+
* @pf: board private structure
1278+
*/
1279+
void ice_fdir_replay_fltrs(struct ice_pf *pf)
1280+
{
1281+
struct ice_fdir_fltr *f_rule;
1282+
struct ice_hw *hw = &pf->hw;
1283+
1284+
list_for_each_entry(f_rule, &hw->fdir_list_head, fltr_node) {
1285+
int err = ice_fdir_write_all_fltr(pf, f_rule, true);
1286+
1287+
if (err)
1288+
dev_dbg(ice_pf_to_dev(pf), "Flow Director error %d, could not reprogram filter %d\n",
1289+
err, f_rule->fltr_id);
1290+
}
1291+
}
1292+
12281293
/**
12291294
* ice_fdir_create_dflt_rules - create default perfect filters
12301295
* @pf: PF data structure

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,8 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
27482748
goto err_vsi;
27492749

27502750
ice_vsi_get_qs(vsi);
2751+
2752+
ice_alloc_fd_res(vsi);
27512753
ice_vsi_set_tc_cfg(vsi);
27522754

27532755
/* Initialize VSI struct elements and create VSI in FW */
@@ -2756,6 +2758,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
27562758
goto err_vsi;
27572759

27582760
switch (vsi->type) {
2761+
case ICE_VSI_CTRL:
27592762
case ICE_VSI_PF:
27602763
ret = ice_vsi_alloc_q_vectors(vsi);
27612764
if (ret)
@@ -2780,12 +2783,14 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
27802783
if (ret)
27812784
goto err_vectors;
27822785
}
2783-
/* Do not exit if configuring RSS had an issue, at least
2784-
* receive traffic on first queue. Hence no need to capture
2785-
* return value
2786-
*/
2787-
if (test_bit(ICE_FLAG_RSS_ENA, pf->flags))
2788-
ice_vsi_cfg_rss_lut_key(vsi);
2786+
/* ICE_VSI_CTRL does not need RSS so skip RSS processing */
2787+
if (vsi->type != ICE_VSI_CTRL)
2788+
/* Do not exit if configuring RSS had an issue, at
2789+
* least receive traffic on first queue. Hence no
2790+
* need to capture return value
2791+
*/
2792+
if (test_bit(ICE_FLAG_RSS_ENA, pf->flags))
2793+
ice_vsi_cfg_rss_lut_key(vsi);
27892794
break;
27902795
case ICE_VSI_VF:
27912796
ret = ice_vsi_alloc_q_vectors(vsi);

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4895,6 +4895,21 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
48954895
goto err_sched_init_port;
48964896
}
48974897

4898+
if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) {
4899+
wr32(hw, PFQF_FD_ENA, PFQF_FD_ENA_FD_ENA_M);
4900+
if (!rd32(hw, PFQF_FD_SIZE)) {
4901+
u16 unused, guar, b_effort;
4902+
4903+
guar = hw->func_caps.fd_fltr_guar;
4904+
b_effort = hw->func_caps.fd_fltr_best_effort;
4905+
4906+
/* force guaranteed filter pool for PF */
4907+
ice_alloc_fd_guar_item(hw, &unused, guar);
4908+
/* force shared filter pool for PF */
4909+
ice_alloc_fd_shrd_item(hw, &unused, b_effort);
4910+
}
4911+
}
4912+
48984913
if (test_bit(ICE_FLAG_DCB_ENA, pf->flags))
48994914
ice_dcb_rebuild(pf);
49004915

@@ -4913,6 +4928,22 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
49134928
}
49144929
}
49154930

4931+
/* If Flow Director is active */
4932+
if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) {
4933+
err = ice_vsi_rebuild_by_type(pf, ICE_VSI_CTRL);
4934+
if (err) {
4935+
dev_err(dev, "control VSI rebuild failed: %d\n", err);
4936+
goto err_vsi_rebuild;
4937+
}
4938+
4939+
/* replay HW Flow Director recipes */
4940+
if (hw->fdir_prof)
4941+
ice_fdir_replay_flows(hw);
4942+
4943+
/* replay Flow Director filters */
4944+
ice_fdir_replay_fltrs(pf);
4945+
}
4946+
49164947
ice_update_pf_netdev_link(pf);
49174948

49184949
/* tell the firmware we are up */

0 commit comments

Comments
 (0)