Skip to content

Commit 148beb6

Browse files
Henry TiemanJeff Kirsher
authored andcommitted
ice: Initialize Flow Director resources
Flow Director allows for redirection based on ntuple rules. Rules are programmed using the ethtool set-ntuple interface. Supported actions are redirect to queue and drop. Setup the initial framework to process Flow Director filters. Create and allocate resources to manage and program filters to the hardware. Filters are processed via a sideband interface; a control VSI is created to manage communication and process requests through the sideband. Upon allocation of resources, update the hardware tables to accept perfect filters. 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 65ece6d commit 148beb6

22 files changed

+1553
-38
lines changed

drivers/net/ethernet/intel/ice/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ ice-y := ice_main.o \
1818
ice_txrx_lib.o \
1919
ice_txrx.o \
2020
ice_fltr.o \
21+
ice_fdir.o \
22+
ice_ethtool_fdir.o \
2123
ice_flex_pipe.o \
2224
ice_flow.o \
2325
ice_devlink.o \

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "ice_sched.h"
5151
#include "ice_virtchnl_pf.h"
5252
#include "ice_sriov.h"
53+
#include "ice_fdir.h"
5354
#include "ice_xsk.h"
5455

5556
extern const char ice_drv_ver[];
@@ -66,6 +67,7 @@ extern const char ice_drv_ver[];
6667
#define ICE_AQ_LEN 64
6768
#define ICE_MBXSQ_LEN 64
6869
#define ICE_MIN_MSIX 2
70+
#define ICE_FDIR_MSIX 1
6971
#define ICE_NO_VSI 0xffff
7072
#define ICE_VSI_MAP_CONTIG 0
7173
#define ICE_VSI_MAP_SCATTER 1
@@ -257,6 +259,8 @@ struct ice_vsi {
257259
s16 vf_id; /* VF ID for SR-IOV VSIs */
258260

259261
u16 ethtype; /* Ethernet protocol for pause frame */
262+
u16 num_gfltr;
263+
u16 num_bfltr;
260264

261265
/* RSS config */
262266
u16 rss_table_size; /* HW RSS table size */
@@ -339,6 +343,7 @@ enum ice_pf_flags {
339343
ICE_FLAG_SRIOV_CAPABLE,
340344
ICE_FLAG_DCB_CAPABLE,
341345
ICE_FLAG_DCB_ENA,
346+
ICE_FLAG_FD_ENA,
342347
ICE_FLAG_ADV_FEATURES,
343348
ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA,
344349
ICE_FLAG_NO_MEDIA,
@@ -367,6 +372,8 @@ struct ice_pf {
367372
*/
368373
u16 sriov_base_vector;
369374

375+
u16 ctrl_vsi_idx; /* control VSI index in pf->vsi array */
376+
370377
struct ice_vsi **vsi; /* VSIs created by the driver */
371378
struct ice_sw *first_sw; /* first switch created by firmware */
372379
/* Virtchnl/SR-IOV config info */
@@ -505,8 +512,22 @@ static inline struct ice_vsi *ice_get_main_vsi(struct ice_pf *pf)
505512
return NULL;
506513
}
507514

515+
/**
516+
* ice_get_ctrl_vsi - Get the control VSI
517+
* @pf: PF instance
518+
*/
519+
static inline struct ice_vsi *ice_get_ctrl_vsi(struct ice_pf *pf)
520+
{
521+
/* if pf->ctrl_vsi_idx is ICE_NO_VSI, control VSI was not set up */
522+
if (!pf->vsi || pf->ctrl_vsi_idx == ICE_NO_VSI)
523+
return NULL;
524+
525+
return pf->vsi[pf->ctrl_vsi_idx];
526+
}
527+
508528
int ice_vsi_setup_tx_rings(struct ice_vsi *vsi);
509529
int ice_vsi_setup_rx_rings(struct ice_vsi *vsi);
530+
int ice_vsi_open_ctrl(struct ice_vsi *vsi);
510531
void ice_set_ethtool_ops(struct net_device *netdev);
511532
void ice_set_ethtool_safe_mode_ops(struct net_device *netdev);
512533
u16 ice_get_avail_txq_count(struct ice_pf *pf);
@@ -530,6 +551,9 @@ int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset);
530551
void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
531552
const char *ice_stat_str(enum ice_status stat_err);
532553
const char *ice_aq_str(enum ice_aq_err aq_err);
554+
void ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena);
555+
void ice_fdir_release_flows(struct ice_hw *hw);
556+
int ice_fdir_create_dflt_rules(struct ice_pf *pf);
533557
int ice_open(struct net_device *netdev);
534558
int ice_stop(struct net_device *netdev);
535559

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ struct ice_aqc_list_caps_elem {
107107
#define ICE_AQC_CAPS_RXQS 0x0041
108108
#define ICE_AQC_CAPS_TXQS 0x0042
109109
#define ICE_AQC_CAPS_MSIX 0x0043
110+
#define ICE_AQC_CAPS_FD 0x0045
110111
#define ICE_AQC_CAPS_MAX_MTU 0x0047
111112

112113
u8 major_ver;
@@ -232,6 +233,11 @@ struct ice_aqc_get_sw_cfg_resp {
232233
*/
233234
#define ICE_AQC_RES_TYPE_VSI_LIST_REP 0x03
234235
#define ICE_AQC_RES_TYPE_VSI_LIST_PRUNE 0x04
236+
#define ICE_AQC_RES_TYPE_FDIR_COUNTER_BLOCK 0x21
237+
#define ICE_AQC_RES_TYPE_FDIR_GUARANTEED_ENTRIES 0x22
238+
#define ICE_AQC_RES_TYPE_FDIR_SHARED_ENTRIES 0x23
239+
#define ICE_AQC_RES_TYPE_FD_PROF_BLDR_PROFID 0x58
240+
#define ICE_AQC_RES_TYPE_FD_PROF_BLDR_TCAM 0x59
235241
#define ICE_AQC_RES_TYPE_HASH_PROF_BLDR_PROFID 0x60
236242
#define ICE_AQC_RES_TYPE_HASH_PROF_BLDR_TCAM 0x61
237243

@@ -240,6 +246,9 @@ struct ice_aqc_get_sw_cfg_resp {
240246

241247
#define ICE_AQC_RES_TYPE_FLAG_DEDICATED 0x00
242248

249+
#define ICE_AQC_RES_TYPE_S 0
250+
#define ICE_AQC_RES_TYPE_M (0x07F << ICE_AQC_RES_TYPE_S)
251+
243252
/* Allocate Resources command (indirect 0x0208)
244253
* Free Resources command (indirect 0x0209)
245254
*/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ ice_setup_tx_ctx(struct ice_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf_q)
246246
*/
247247
switch (vsi->type) {
248248
case ICE_VSI_LB:
249+
case ICE_VSI_CTRL:
249250
case ICE_VSI_PF:
250251
tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
251252
break;

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,10 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
653653
if (status)
654654
goto err_unroll_cqinit;
655655

656+
/* Set bit to enable Flow Director filters */
657+
wr32(hw, PFQF_FD_ENA, PFQF_FD_ENA_FD_ENA_M);
658+
INIT_LIST_HEAD(&hw->fdir_list_head);
659+
656660
ice_clear_pxe_mode(hw);
657661

658662
status = ice_init_nvm(hw);
@@ -741,6 +745,10 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
741745
status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL);
742746
devm_kfree(ice_hw_to_dev(hw), mac_buf);
743747

748+
if (status)
749+
goto err_unroll_fltr_mgmt_struct;
750+
/* Obtain counter base index which would be used by flow director */
751+
status = ice_alloc_fd_res_cntr(hw, &hw->fd_ctr_base);
744752
if (status)
745753
goto err_unroll_fltr_mgmt_struct;
746754
status = ice_init_hw_tbls(hw);
@@ -770,6 +778,7 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
770778
*/
771779
void ice_deinit_hw(struct ice_hw *hw)
772780
{
781+
ice_free_fd_res_cntr(hw, hw->fd_ctr_base);
773782
ice_cleanup_fltr_mgmt_struct(hw);
774783

775784
ice_sched_cleanup_all(hw);
@@ -1680,6 +1689,33 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
16801689
"%s: msix_vector_first_id = %d\n", prefix,
16811690
caps->msix_vector_first_id);
16821691
break;
1692+
case ICE_AQC_CAPS_FD:
1693+
if (dev_p) {
1694+
dev_p->num_flow_director_fltr = number;
1695+
ice_debug(hw, ICE_DBG_INIT,
1696+
"%s: num_flow_director_fltr = %d\n",
1697+
prefix,
1698+
dev_p->num_flow_director_fltr);
1699+
}
1700+
if (func_p) {
1701+
u32 reg_val, val;
1702+
1703+
reg_val = rd32(hw, GLQF_FD_SIZE);
1704+
val = (reg_val & GLQF_FD_SIZE_FD_GSIZE_M) >>
1705+
GLQF_FD_SIZE_FD_GSIZE_S;
1706+
func_p->fd_fltr_guar =
1707+
ice_get_num_per_func(hw, val);
1708+
val = (reg_val & GLQF_FD_SIZE_FD_BSIZE_M) >>
1709+
GLQF_FD_SIZE_FD_BSIZE_S;
1710+
func_p->fd_fltr_best_effort = val;
1711+
ice_debug(hw, ICE_DBG_INIT,
1712+
"%s: fd_fltr_guar = %d\n",
1713+
prefix, func_p->fd_fltr_guar);
1714+
ice_debug(hw, ICE_DBG_INIT,
1715+
"%s: fd_fltr_best_effort = %d\n",
1716+
prefix, func_p->fd_fltr_best_effort);
1717+
}
1718+
break;
16831719
case ICE_AQC_CAPS_MAX_MTU:
16841720
caps->max_mtu = number;
16851721
ice_debug(hw, ICE_DBG_INIT, "%s: max_mtu = %d\n",

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3184,6 +3184,10 @@ ice_get_channels(struct net_device *dev, struct ethtool_channels *ch)
31843184
ch->combined_count = ice_get_combined_cnt(vsi);
31853185
ch->rx_count = vsi->num_rxq - ch->combined_count;
31863186
ch->tx_count = vsi->num_txq - ch->combined_count;
3187+
3188+
/* report other queues */
3189+
ch->other_count = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0;
3190+
ch->max_other = ch->other_count;
31873191
}
31883192

31893193
/**
@@ -3256,9 +3260,14 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
32563260
return -EOPNOTSUPP;
32573261
}
32583262
/* do not support changing other_count */
3259-
if (ch->other_count)
3263+
if (ch->other_count != (test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1U : 0U))
32603264
return -EINVAL;
32613265

3266+
if (test_bit(ICE_FLAG_FD_ENA, pf->flags) && pf->hw.fdir_active_fltr) {
3267+
netdev_err(dev, "Cannot set channels when Flow Director filters are active\n");
3268+
return -EOPNOTSUPP;
3269+
}
3270+
32623271
curr_combined = ice_get_combined_cnt(vsi);
32633272

32643273
/* these checks are for cases where user didn't specify a particular

0 commit comments

Comments
 (0)