Added refresh_required flag to determine if we need to update the
recipe to profile mapping cache. This will reduce the number of
calls made to refresh the profile map.

Signed-off-by: Shivanshu Shukla <shivanshu.shu...@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell...@intel.com>
Signed-off-by: Leyi Rong <leyi.r...@intel.com>
---
 drivers/net/ice/base/ice_switch.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ice/base/ice_switch.c 
b/drivers/net/ice/base/ice_switch.c
index 636b43d69..7f4edd274 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -175,13 +175,15 @@ static void ice_get_recp_to_prof_map(struct ice_hw *hw);
  * @hw: pointer to hardware structure
  * @recps: struct that we need to populate
  * @rid: recipe ID that we are populating
+ * @refresh_required: true if we should get recipe to profile mapping from FW
  *
  * This function is used to populate all the necessary entries into our
  * bookkeeping so that we have a current list of all the recipes that are
  * programmed in the firmware.
  */
 static enum ice_status
-ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid)
+ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid,
+                   bool *refresh_required)
 {
        u16 i, sub_recps, fv_word_idx = 0, result_idx = 0;
        ice_declare_bitmap(r_bitmap, ICE_MAX_NUM_PROFILES);
@@ -191,10 +193,6 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct 
ice_sw_recipe *recps, u8 rid)
        struct ice_prot_lkup_ext *lkup_exts;
        enum ice_status status;
 
-       /* Get recipe to profile map so that we can get the fv from
-        * lkups that we read for a recipe from FW.
-        */
-       ice_get_recp_to_prof_map(hw);
        /* we need a buffer big enough to accommodate all the recipes */
        tmp = (struct ice_aqc_recipe_data_elem *)ice_calloc(hw,
                ICE_MAX_NUM_RECIPES, sizeof(*tmp));
@@ -206,6 +204,19 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct 
ice_sw_recipe *recps, u8 rid)
        /* non-zero status meaning recipe doesn't exist */
        if (status)
                goto err_unroll;
+
+       /* Get recipe to profile map so that we can get the fv from lkups that
+        * we read for a recipe from FW. Since we want to minimize the number of
+        * times we make this FW call, just make one call and cache the copy
+        * until a new recipe is added. This operation is only required the
+        * first time to get the changes from FW. Then to search existing
+        * entries we don't need to update the cache again until another recipe
+        * gets added.
+        */
+       if (*refresh_required) {
+               ice_get_recp_to_prof_map(hw);
+               *refresh_required = false;
+       }
        lkup_exts = &recps[rid].lkup_exts;
        /* start populating all the entries for recps[rid] based on lkups from
         * firmware
@@ -4358,6 +4369,7 @@ static const struct ice_protocol_entry ice_prot_id_tbl[] 
= {
  */
 static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext 
*lkup_exts)
 {
+       bool refresh_required = true;
        struct ice_sw_recipe *recp;
        u16 i;
 
@@ -4376,7 +4388,8 @@ static u16 ice_find_recp(struct ice_hw *hw, struct 
ice_prot_lkup_ext *lkup_exts)
                 */
                if (!recp[i].recp_created)
                        if (ice_get_recp_frm_fw(hw,
-                                               hw->switch_info->recp_list, i))
+                                               hw->switch_info->recp_list, i,
+                                               &refresh_required))
                                continue;
 
                /* if number of words we are looking for match */
-- 
2.17.1

Reply via email to