OSDN Git Service

ice: Refactor get/set RSS LUT to use struct parameter
authorBrett Creeley <brett.creeley@intel.com>
Tue, 2 Mar 2021 18:15:35 +0000 (10:15 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Wed, 31 Mar 2021 21:21:28 +0000 (14:21 -0700)
Update ice_aq_get_rss_lut() and ice_aq_set_rss_lut() to take a new
structure ice_aq_get_set_rss_params instead of passing individual
parameters. This is done for 2 reasons:

1. Reduce the number of parameters passed to the functions.
2. Reduce the amount of change required if the arguments ever need to be
   updated in the future.

Also, reduce duplicate code that was checking for an invalid vsi_handle
and lut parameter by moving the checks to the lower level
__ice_aq_get_set_rss_lut().

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_common.c
drivers/net/ethernet/intel/ice/ice_common.h
drivers/net/ethernet/intel/ice/ice_ethtool.c
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_type.h

index b906ca4..54df00e 100644 (file)
@@ -3206,23 +3206,33 @@ ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr,
 /**
  * __ice_aq_get_set_rss_lut
  * @hw: pointer to the hardware structure
- * @vsi_id: VSI FW index
- * @lut_type: LUT table type
- * @lut: pointer to the LUT buffer provided by the caller
- * @lut_size: size of the LUT buffer
- * @glob_lut_idx: global LUT index
+ * @params: RSS LUT parameters
  * @set: set true to set the table, false to get the table
  *
  * Internal function to get (0x0B05) or set (0x0B03) RSS look up table
  */
 static enum ice_status
-__ice_aq_get_set_rss_lut(struct ice_hw *hw, u16 vsi_id, u8 lut_type, u8 *lut,
-                        u16 lut_size, u8 glob_lut_idx, bool set)
+__ice_aq_get_set_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *params, bool set)
 {
+       u16 flags = 0, vsi_id, lut_type, lut_size, glob_lut_idx, vsi_handle;
        struct ice_aqc_get_set_rss_lut *cmd_resp;
        struct ice_aq_desc desc;
        enum ice_status status;
-       u16 flags = 0;
+       u8 *lut;
+
+       if (!params)
+               return ICE_ERR_PARAM;
+
+       vsi_handle = params->vsi_handle;
+       lut = params->lut;
+
+       if (!ice_is_vsi_valid(hw, vsi_handle) || !lut)
+               return ICE_ERR_PARAM;
+
+       lut_size = params->lut_size;
+       lut_type = params->lut_type;
+       glob_lut_idx = params->global_lut_id;
+       vsi_id = ice_get_hw_vsi_num(hw, vsi_handle);
 
        cmd_resp = &desc.params.get_set_rss_lut;
 
@@ -3296,43 +3306,27 @@ ice_aq_get_set_rss_lut_exit:
 /**
  * ice_aq_get_rss_lut
  * @hw: pointer to the hardware structure
- * @vsi_handle: software VSI handle
- * @lut_type: LUT table type
- * @lut: pointer to the LUT buffer provided by the caller
- * @lut_size: size of the LUT buffer
+ * @get_params: RSS LUT parameters used to specify which RSS LUT to get
  *
  * get the RSS lookup table, PF or VSI type
  */
 enum ice_status
-ice_aq_get_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type,
-                  u8 *lut, u16 lut_size)
+ice_aq_get_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *get_params)
 {
-       if (!ice_is_vsi_valid(hw, vsi_handle) || !lut)
-               return ICE_ERR_PARAM;
-
-       return __ice_aq_get_set_rss_lut(hw, ice_get_hw_vsi_num(hw, vsi_handle),
-                                       lut_type, lut, lut_size, 0, false);
+       return __ice_aq_get_set_rss_lut(hw, get_params, false);
 }
 
 /**
  * ice_aq_set_rss_lut
  * @hw: pointer to the hardware structure
- * @vsi_handle: software VSI handle
- * @lut_type: LUT table type
- * @lut: pointer to the LUT buffer provided by the caller
- * @lut_size: size of the LUT buffer
+ * @set_params: RSS LUT parameters used to specify how to set the RSS LUT
  *
  * set the RSS lookup table, PF or VSI type
  */
 enum ice_status
-ice_aq_set_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type,
-                  u8 *lut, u16 lut_size)
+ice_aq_set_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *set_params)
 {
-       if (!ice_is_vsi_valid(hw, vsi_handle) || !lut)
-               return ICE_ERR_PARAM;
-
-       return __ice_aq_get_set_rss_lut(hw, ice_get_hw_vsi_num(hw, vsi_handle),
-                                       lut_type, lut, lut_size, 0, true);
+       return __ice_aq_get_set_rss_lut(hw, set_params, true);
 }
 
 /**
index baf4064..81fd69c 100644 (file)
@@ -51,11 +51,9 @@ ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,
                  u32 rxq_index);
 
 enum ice_status
-ice_aq_get_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type, u8 *lut,
-                  u16 lut_size);
+ice_aq_get_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *get_params);
 enum ice_status
-ice_aq_set_rss_lut(struct ice_hw *hw, u16 vsi_handle, u8 lut_type, u8 *lut,
-                  u16 lut_size);
+ice_aq_set_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *set_params);
 enum ice_status
 ice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
                   struct ice_aqc_get_set_rss_keys *keys);
index 109dd69..0840fcf 100644 (file)
@@ -3328,6 +3328,7 @@ static int ice_get_valid_rss_size(struct ice_hw *hw, int new_size)
  */
 static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
 {
+       struct ice_aq_get_set_rss_lut_params set_params = {};
        struct ice_pf *pf = vsi->back;
        enum ice_status status;
        struct device *dev;
@@ -3353,8 +3354,12 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
 
        /* create/set RSS LUT */
        ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
-       status = ice_aq_set_rss_lut(hw, vsi->idx, vsi->rss_lut_type, lut,
-                                   vsi->rss_table_size);
+       set_params.vsi_handle = vsi->idx;
+       set_params.lut_size = vsi->rss_table_size;
+       set_params.lut_type = vsi->rss_lut_type;
+       set_params.lut = lut;
+       set_params.global_lut_id = 0;
+       status = ice_aq_set_rss_lut(hw, &set_params);
        if (status) {
                dev_err(dev, "Cannot set RSS lut, err %s aq_err %s\n",
                        ice_stat_str(status),
index f2cf914..22bcccd 100644 (file)
@@ -1337,6 +1337,7 @@ int ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena)
  */
 static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)
 {
+       struct ice_aq_get_set_rss_lut_params set_params = {};
        struct ice_aqc_get_set_rss_keys *key;
        struct ice_pf *pf = vsi->back;
        enum ice_status status;
@@ -1356,8 +1357,12 @@ static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)
        else
                ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
 
-       status = ice_aq_set_rss_lut(&pf->hw, vsi->idx, vsi->rss_lut_type, lut,
-                                   vsi->rss_table_size);
+       set_params.vsi_handle = vsi->idx;
+       set_params.lut_size = vsi->rss_table_size;
+       set_params.lut_type = vsi->rss_lut_type;
+       set_params.lut = lut;
+       set_params.global_lut_id = 0;
+       status = ice_aq_set_rss_lut(&pf->hw, &set_params);
 
        if (status) {
                dev_err(dev, "set_rss_lut failed, error %s\n",
index 336db16..8085f0a 100644 (file)
@@ -6348,8 +6348,13 @@ int ice_set_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size)
        }
 
        if (lut) {
-               status = ice_aq_set_rss_lut(hw, vsi->idx, vsi->rss_lut_type,
-                                           lut, lut_size);
+               struct ice_aq_get_set_rss_lut_params set_params = {
+                       .vsi_handle = vsi->idx, .lut_size = lut_size,
+                       .lut_type = vsi->rss_lut_type, .lut = lut,
+                       .global_lut_id = 0
+               };
+
+               status = ice_aq_set_rss_lut(hw, &set_params);
                if (status) {
                        dev_err(dev, "Cannot set RSS lut, err %s aq_err %s\n",
                                ice_stat_str(status),
@@ -6392,8 +6397,13 @@ int ice_get_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size)
        }
 
        if (lut) {
-               status = ice_aq_get_rss_lut(hw, vsi->idx, vsi->rss_lut_type,
-                                           lut, lut_size);
+               struct ice_aq_get_set_rss_lut_params get_params = {
+                       .vsi_handle = vsi->idx, .lut_size = lut_size,
+                       .lut_type = vsi->rss_lut_type, .lut = lut,
+                       .global_lut_id = 0
+               };
+
+               status = ice_aq_get_rss_lut(hw, &get_params);
                if (status) {
                        dev_err(dev, "Cannot get RSS lut, err %s aq_err %s\n",
                                ice_stat_str(status),
index ba157b3..276ebcc 100644 (file)
@@ -827,6 +827,14 @@ struct ice_hw_port_stats {
        u64 fd_sb_match;
 };
 
+struct ice_aq_get_set_rss_lut_params {
+       u16 vsi_handle;         /* software VSI handle */
+       u16 lut_size;           /* size of the LUT buffer */
+       u8 lut_type;            /* type of the LUT (i.e. VSI, PF, Global) */
+       u8 *lut;                /* input RSS LUT for set and output RSS LUT for get */
+       u8 global_lut_id;       /* only valid when lut_type is global */
+};
+
 /* Checksum and Shadow RAM pointers */
 #define ICE_SR_NVM_CTRL_WORD           0x00
 #define ICE_SR_BOOT_CFG_PTR            0x132