> -----Original Message-----
> From: Kitszel, Przemyslaw <[email protected]>
> Sent: Friday, May 8, 2026 2:42 PM
> To: [email protected]; Schmidt, Michal
> <[email protected]>; Jakub Kicinski <[email protected]>; Jiri Pirko
> <[email protected]>
> Cc: [email protected]; Simon Horman <[email protected]>; Nguyen,
> Anthony L <[email protected]>; Michal Swiatkowski
> <[email protected]>; Richardson, Bruce
> <[email protected]>; Medvedkin, Vladimir
> <[email protected]>; Connolly, Padraig J
> <[email protected]>; S, Ananth <[email protected]>;
> Miskell, Timothy <[email protected]>; Keller, Jacob E
> <[email protected]>; Czapnik, Lukasz
> <[email protected]>; Loktionov, Aleksandr
> <[email protected]>; Andrew Lunn <[email protected]>;
> David S. Miller <[email protected]>; Eric Dumazet
> <[email protected]>; Paolo Abeni <[email protected]>; Saeed Mahameed
> <[email protected]>; Leon Romanovsky <[email protected]>; Tariq Toukan
> <[email protected]>; Mark Bloch <[email protected]>; Kitszel,
> Przemyslaw <[email protected]>
> Subject: [PATCH iwl-next v1 05/15] ice: add helpers for Global RSS LUT
> alloc, free, vsi_update
> 
> Add AQ commands for RSS Global LUT allocation and free operations.
> Functions will be called since subsequent commit.
> 
> Add programming code for GLOBAL LUT ID of UPDATE VSI AQ, do the same
> for RSS LUT "type", also for PF LUT in case of VF VSI.
> 
> Co-developed-by: Brett Creeley <[email protected]>
> Signed-off-by: Brett Creeley <[email protected]>
> Signed-off-by: Przemek Kitszel <[email protected]>
> ---
>  drivers/net/ethernet/intel/ice/ice.h          |  1 +
>  .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  1 +
>  drivers/net/ethernet/intel/ice/ice_switch.h   |  2 +
>  drivers/net/ethernet/intel/ice/ice_lib.c      | 28 +++++++++++--
>  drivers/net/ethernet/intel/ice/ice_switch.c   | 41
> +++++++++++++++++++
>  5 files changed, 69 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice.h
> b/drivers/net/ethernet/intel/ice/ice.h
> index f9a43daf04fe..7f4f299c4d37 100644
> --- a/drivers/net/ethernet/intel/ice/ice.h
> +++ b/drivers/net/ethernet/intel/ice/ice.h
> @@ -369,6 +369,7 @@ struct ice_vsi {
>       u8 *rss_hkey_user;      /* User configured hash keys */
>       u8 *rss_lut_user;       /* User configured lookup table entries */
>       u8 rss_lut_type;        /* used to configure Get/Set RSS LUT AQ
> call */
> +     u8 global_lut_id;       /* valid when lut_type == GLOBAL_LUT */
> 
>       /* aRFS members only allocated for the PF VSI */
>  #define ICE_MAX_ARFS_LIST    1024
> diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
> b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
> index d41b2427482d..c49896db51c6 100644
> --- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
> +++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
> @@ -169,6 +169,7 @@ struct ice_aqc_set_port_params {
>  #define ICE_AQC_RES_TYPE_VSI_LIST_PRUNE                      0x04
>  #define ICE_AQC_RES_TYPE_RECIPE                              0x05
>  #define ICE_AQC_RES_TYPE_SWID                                0x07
> +#define ICE_AQC_RES_TYPE_GLOBAL_RSS_HASH             0x20
>  #define ICE_AQC_RES_TYPE_FDIR_COUNTER_BLOCK          0x21
>  #define ICE_AQC_RES_TYPE_FDIR_GUARANTEED_ENTRIES     0x22
>  #define ICE_AQC_RES_TYPE_FDIR_SHARED_ENTRIES         0x23
> diff --git a/drivers/net/ethernet/intel/ice/ice_switch.h
> b/drivers/net/ethernet/intel/ice/ice_switch.h
> index b442db4a2ce5..ab6a8c78d14a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_switch.h
> +++ b/drivers/net/ethernet/intel/ice/ice_switch.h
> @@ -401,6 +401,8 @@ ice_rem_adv_rule_by_id(struct ice_hw *hw,
>                      struct ice_rule_query_data *remove_entry);
> 
>  int ice_init_def_sw_recp(struct ice_hw *hw);
> +int ice_alloc_rss_global_lut(struct ice_hw *hw, u16 *global_lut_id);
> +int ice_free_rss_global_lut(struct ice_hw *hw, u16 global_lut_id);
>  u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
> 
>  int ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle); diff
> --git a/drivers/net/ethernet/intel/ice/ice_lib.c
> b/drivers/net/ethernet/intel/ice/ice_lib.c
> index ac6698a01d2f..2de62cde14ab 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -1154,30 +1154,46 @@ static void ice_set_fd_vsi_ctx(struct
> ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
>       ctxt->info.acl_def_act = cpu_to_le16(val);  }
> 
> +/* Translate @lut_type used in most of the places to the Admin Queue
> + * Q_OPT value for RSS.
> + * Used with VSI ADD and VSI UPDATE AQs (opcodes 0x0210, 0x0211).
> + */
> +static u8 ice_lut_type_to_aq_qopt_rss_val(enum ice_lut_type lut_type)
> {
> +     switch (lut_type) {
> +     case ICE_LUT_PF:
> +             return ICE_AQ_VSI_Q_OPT_RSS_LUT_PF;
> +     case ICE_LUT_GLOBAL:
> +             return ICE_AQ_VSI_Q_OPT_RSS_LUT_GBL;
> +     case ICE_LUT_VSI:
> +     default:
> +             return ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI;
> +     }
> +}
> +
>  /**
>   * ice_set_rss_vsi_ctx - Set RSS VSI context before adding a VSI
>   * @ctxt: the VSI context being set
>   * @vsi: the VSI being configured
>   */
>  void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi
> *vsi)  {
>       u8 lut_type, hash_type;
> +     u8 global_lut_id = 0;
>       struct device *dev;
>       struct ice_pf *pf;
> 
>       pf = vsi->back;
>       dev = ice_pf_to_dev(pf);
> 
>       switch (vsi->type) {
>       case ICE_VSI_CHNL:
> -     case ICE_VSI_PF:
> -             /* PF VSI will inherit RSS instance of PF */
>               lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_PF;
>               break;
> +     case ICE_VSI_PF:
>       case ICE_VSI_VF:
>       case ICE_VSI_SF:
> -             /* VF VSI will gets a small RSS table which is a VSI LUT
> type */
> -             lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI;
> +             lut_type = ice_lut_type_to_aq_qopt_rss_val(vsi-
> >rss_lut_type);
>               break;
>       default:
>               dev_dbg(dev, "Unsupported VSI type %s\n", @@ -1189,8
> +1205,12 @@ void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct
> ice_vsi *vsi)
>               vsi->rss_hfunc = ICE_AQ_VSI_Q_OPT_RSS_HASH_TPLZ;
>       hash_type = vsi->rss_hfunc;
> 
> +     if (vsi->rss_lut_type == ICE_LUT_GLOBAL)
> +              global_lut_id = vsi->global_lut_id;
> +
>       ctxt->info.q_opt_rss =
>               FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_LUT_M, lut_type) |
> +             FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M,
> global_lut_id) |
>               FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_HASH_M, hash_type);  }
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c
> b/drivers/net/ethernet/intel/ice/ice_switch.c
> index 88f1aefc24b3..b783c97f6cfe 100644
> --- a/drivers/net/ethernet/intel/ice/ice_switch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_switch.c
> @@ -1527,6 +1527,47 @@ ice_aq_get_sw_cfg(struct ice_hw *hw, struct
> ice_aqc_get_sw_cfg_resp_elem *buf,
>       return status;
>  }
> 
> +/* Allocate a new Global LUT for the caller.
> + * LUT ID is returned via @global_lut_id.
> + */
> +int ice_alloc_rss_global_lut(struct ice_hw *hw, u16 *global_lut_id) {
> +     DEFINE_RAW_FLEX(struct ice_aqc_alloc_free_res_elem, buf, elem,
> 1);
> +     u16 buf_len = __struct_size(buf);
> +     int err;
> +
> +     buf->num_elems = cpu_to_le16(1);
> +     buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_GLOBAL_RSS_HASH);
> +
> +     err = ice_aq_alloc_free_res(hw, buf, buf_len,
> ice_aqc_opc_alloc_res);
> +     if (err)
> +             ice_debug(hw, ICE_DBG_RES, "Failed to allocate RSS
> global LUT, err %d\n",
> +                       err);
> +     else
> +             *global_lut_id = le16_to_cpu(buf->elem[0].e.sw_resp);
> +
> +     return err;
> +}
> +
> +/* Free Global LUT at @global_lut_id. */ int
> +ice_free_rss_global_lut(struct ice_hw *hw, u16 global_lut_id) {
> +     DEFINE_RAW_FLEX(struct ice_aqc_alloc_free_res_elem, buf, elem,
> 1);
> +     u16 buf_len = __struct_size(buf);
> +     int err;
> +
> +     buf->num_elems = cpu_to_le16(1);
> +     buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_GLOBAL_RSS_HASH);
> +     buf->elem[0].e.sw_resp = cpu_to_le16(global_lut_id);
> +
> +     err = ice_aq_alloc_free_res(hw, buf, buf_len,
> ice_aqc_opc_free_res);
> +     if (err)
> +             ice_debug(hw, ICE_DBG_RES, "Failed to free RSS global
> LUT %d, err %d\n",
> +                       global_lut_id, err);
> +
> +     return err;
> +}
> +
>  /**
>   * ice_aq_add_vsi
>   * @hw: pointer to the HW struct
> --
> 2.39.3

Reviewed-by: Aleksandr Loktionov <[email protected]>

Reply via email to