ice: Introduce switch recipe reusing
Subsystems (3)
cover ice: Introduce switch recipe reusing
This patch series firstly fix the bitmap casting issue in getting/mapping recipe to profile association that is used in both legacy and recipe reusing mode, then introduce switch recipe reusing feature as new E810 firmware supports the corresponding functionality.
Steven Zou (2):
ice: Refactor FW data type and fix bitmap casting issue
ice: Add switch recipe reusing feature
.../net/ethernet/intel/ice/ice_adminq_cmd.h | 5 +- drivers/net/ethernet/intel/ice/ice_common.c | 2 + drivers/net/ethernet/intel/ice/ice_lag.c | 4 +- drivers/net/ethernet/intel/ice/ice_switch.c | 211 +++++++++++++++--- drivers/net/ethernet/intel/ice/ice_switch.h | 5 +- drivers/net/ethernet/intel/ice/ice_type.h | 2 + 6 files changed, 197 insertions(+), 32 deletions(-)
base-commit: f2aae2089368d8e5abb4ec01542c31bc4d011a74
Signature · 1 line
2.31.1
PATCH RESEND 1/2 ice: Refactor FW data type and fix bitmap casting issue
According to the datasheet, the recipe association data is an 8-byte little-endian value. It is described as 'Bitmap of the recipe indexes associated with this profile', it is from 24 to 31 byte area in FW. Therefore, it is defined to '__le64 recipe_assoc' in struct ice_aqc_recipe_to_profile. And then fix the bitmap casting issue, as we must never ever use castings for bitmap type.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 3 ++- drivers/net/ethernet/intel/ice/ice_lag.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_switch.c | 24 +++++++++++-------- drivers/net/ethernet/intel/ice/ice_switch.h | 4 ++-- 4 files changed, 20 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2 -1
@@ -602,8 +602,9 @@ struct ice_aqc_recipe_data_elem {struct ice_aqc_recipe_to_profile {__le16 profile_id;u8 rsvd[6 ]; - DECLARE_BITMAP(recipe_assoc, ICE_MAX_NUM_RECIPES); +__le64 recipe_assoc; }; +static_assert (sizeof (struct ice_aqc_recipe_to_profile ) ==16 );/* Add/Update/Remove/Get switch rules (indirect 0x02A0, 0x02A1, 0x02A2, 0x02A3) */
drivers/net/ethernet/intel/ice/ice_lag.c +2 -2
@@ -2041,7 +2041,7 @@ int ice_init_lag(struct ice_pf *pf)/* associate recipes to profiles */ for (n =0 ; n <ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER ; n++) { err =ice_aq_get_recipe_to_profile (&pf->hw, n, - (u8 *)&recipe_bits,NULL ); + &recipe_bits,NULL );if (err)continue ;
@@ -2049,7 +2049,7 @@ int ice_init_lag(struct ice_pf *pf) recipe_bits |=BIT (lag->pf_recipe) |BIT (lag->lport_recipe);ice_aq_map_recipe_to_profile (&pf->hw, n, - (u8 *)&recipe_bits,NULL ); + recipe_bits,NULL ); } }
drivers/net/ethernet/intel/ice/ice_switch.c +14 -10
@@ -2025,12 +2025,12 @@ ice_update_recipe_lkup_idx(struct ice_hw *hw,* ice_aq_map_recipe_to_profile - Map recipe to packet profile * @hw: pointer to the HW struct * @profile_id: package profile ID to associate the recipe with -* @r_bitmap: Recipe bitmap filled in and need to be returned as response +* @r_assoc: Recipe bitmap filled in and need to be returned as response * @cd: pointer to command details structure or NULL * Recipe to profile association (0x0291) */ int -ice_aq_map_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u8 *r_bitmap, +ice_aq_map_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u64 r_assoc,struct ice_sq_cd *cd) {struct ice_aqc_recipe_to_profile *cmd;
@@ -2042,7 +2042,7 @@ ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,/* Set the recipe ID bit in the bitmask to let the device know which * profile we are associating the recipe to */ -memcpy (cmd->recipe_assoc, r_bitmap,sizeof (cmd->recipe_assoc)); + cmd->recipe_assoc =cpu_to_le64 (r_assoc);return ice_aq_send_cmd (hw, &desc,NULL ,0 , cd); }
@@ -2051,12 +2051,12 @@ ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,* ice_aq_get_recipe_to_profile - Map recipe to packet profile * @hw: pointer to the HW struct * @profile_id: package profile ID to associate the recipe with -* @r_bitmap: Recipe bitmap filled in and need to be returned as response +* @r_assoc: Recipe bitmap filled in and need to be returned as response * @cd: pointer to command details structure or NULL * Associate profile ID with given recipe (0x0293) */ int -ice_aq_get_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u8 *r_bitmap, +ice_aq_get_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u64 *r_assoc,struct ice_sq_cd *cd) {struct ice_aqc_recipe_to_profile *cmd;
@@ -2069,7 +2069,7 @@ ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap, status =ice_aq_send_cmd (hw, &desc,NULL ,0 , cd);if (!status) -memcpy (r_bitmap, cmd->recipe_assoc,sizeof (cmd->recipe_assoc)); + *r_assoc =le64_to_cpu (cmd->recipe_assoc);return status; }
@@ -2108,6 +2108,7 @@ int ice_alloc_recipe(struct ice_hw *hw, u16 *rid)static void ice_get_recp_to_prof_map (struct ice_hw *hw) {DECLARE_BITMAP (r_bitmap,ICE_MAX_NUM_RECIPES ); +u64 recp_assoc;u16 i;for (i =0 ; i < hw->switch_info->max_used_prof_index +1 ; i++) {
@@ -2115,8 +2116,9 @@ static void ice_get_recp_to_prof_map(struct ice_hw *hw)bitmap_zero (profile_to_recipe[i],ICE_MAX_NUM_RECIPES );bitmap_zero (r_bitmap,ICE_MAX_NUM_RECIPES ); -if (ice_aq_get_recipe_to_profile (hw, i, (u8 *)r_bitmap,NULL )) +if (ice_aq_get_recipe_to_profile (hw, i, &recp_assoc,NULL ))continue ; +bitmap_from_arr64 (r_bitmap, &recp_assoc,ICE_MAX_NUM_RECIPES );bitmap_copy (profile_to_recipe[i], r_bitmap,ICE_MAX_NUM_RECIPES );for_each_set_bit (j, r_bitmap,ICE_MAX_NUM_RECIPES )
@@ -5390,22 +5392,24 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,*/ list_for_each_entry (fvit, &rm->fv_list, list_entry) {DECLARE_BITMAP (r_bitmap,ICE_MAX_NUM_RECIPES ); +u64 recp_assoc;u16 j; status =ice_aq_get_recipe_to_profile (hw, fvit->profile_id, - (u8 *)r_bitmap,NULL ); + &recp_assoc,NULL );if (status) goto err_unroll; +bitmap_from_arr64 (r_bitmap, &recp_assoc,ICE_MAX_NUM_RECIPES );bitmap_or (r_bitmap, r_bitmap, rm->r_bitmap,ICE_MAX_NUM_RECIPES ); status =ice_acquire_change_lock (hw,ICE_RES_WRITE );if (status) goto err_unroll; +bitmap_to_arr64 (&recp_assoc, r_bitmap,ICE_MAX_NUM_RECIPES ); status =ice_aq_map_recipe_to_profile (hw, fvit->profile_id, - (u8 *)r_bitmap, -NULL ); + recp_assoc,NULL );ice_release_change_lock (hw);if (status)
drivers/net/ethernet/intel/ice/ice_switch.h +2 -2
@@ -424,10 +424,10 @@ int ice_aq_add_recipe(struct ice_hw *hw,struct ice_aqc_recipe_data_elem *s_recipe_list, u16 num_recipes, struct ice_sq_cd *cd);int -ice_aq_get_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u8 *r_bitmap, +ice_aq_get_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u64 *r_assoc,struct ice_sq_cd *cd);int -ice_aq_map_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u8 *r_bitmap, +ice_aq_map_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u64 r_assoc,struct ice_sq_cd *cd);#endif /* _ICE_SWITCH_H_ */
Signature · 1 line
2.31.1
PATCH RESEND 2/2 ice: Add switch recipe reusing feature
In reply to Steven ZouNew E810 firmware supports the corresponding functionality, so the driver allows PFs to subscribe the same switch recipes. Then when the PF is done with a switch recipes, the PF can ask firmware to free that switch recipe.
When users configure a rule to PFn into E810 switch component, if there is no existing recipe matching this rule's pattern, the driver will request firmware to allocate and return a new recipe resource for the rule by calling ice_add_sw_recipe() and ice_alloc_recipe(). If there is an existing recipe matching this rule's pattern with different key value, or this is a same second rule to PFm into switch component, the driver checks out this recipe by calling ice_find_recp(), the driver will tell firmware to share using this same recipe resource by calling ice_subscribable_recp_shared() and ice_subscribe_recipe().
When firmware detects that all subscribing PFs have freed the switch recipe, firmware will free the switch recipe so that it can be reused.
This feature also fixes a problem where all switch recipes would eventually be exhausted because switch recipes could not be freed, as freeing a shared recipe could potentially break other PFs that were using it.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_common.c | 2 + drivers/net/ethernet/intel/ice/ice_switch.c | 187 ++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_switch.h | 1 + drivers/net/ethernet/intel/ice/ice_type.h | 2 + 5 files changed, 177 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2 -0
@@ -273,6 +273,8 @@ struct ice_aqc_set_port_params {#define ICE_AQC_RES_TYPE_FLAG_SHARED BIT(7)#define ICE_AQC_RES_TYPE_FLAG_SCAN_BOTTOM BIT(12)#define ICE_AQC_RES_TYPE_FLAG_IGNORE_INDEX BIT(13) +#define ICE_AQC_RES_TYPE_FLAG_SUBSCRIBE_SHARED BIT(14) +#define ICE_AQC_RES_TYPE_FLAG_SUBSCRIBE_CTL BIT(15)#define ICE_AQC_RES_TYPE_FLAG_DEDICATED 0x00
drivers/net/ethernet/intel/ice/ice_common.c +2 -0
@@ -1146,6 +1146,8 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_fltr_mgmt_struct;mutex_init (&hw->tnl_lock); +ice_init_chk_recipe_reuse_support (hw); +return 0 ; err_unroll_fltr_mgmt_struct:
drivers/net/ethernet/intel/ice/ice_switch.c +170 -17
315 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_switch.h +1 -0
@@ -429,5 +429,6 @@ ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 *r_assoc,int ice_aq_map_recipe_to_profile (struct ice_hw *hw,u32 profile_id,u64 r_assoc,struct ice_sq_cd *cd); +void ice_init_chk_recipe_reuse_support (struct ice_hw *hw);#endif /* _ICE_SWITCH_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +2 -0
@@ -850,6 +850,8 @@ struct ice_hw {u16 max_burst_size;/* driver sets this value */ + u8 recp_reuse:1; /* indicates whether FW supports recipe reuse */ +/* Tx Scheduler values */ u8 num_tx_sched_layers;u8 num_tx_sched_phys_layers;
Signature · 1 line
2.31.1
Re: [PATCH RESEND iwl-next 2/2] ice: Add switch recipe reusing feature
Quoted 17 lines · Steven Zou
New E810 firmware supports the corresponding functionality, so the driver allows PFs to subscribe the same switch recipes. Then when the PF is done with a switch recipes, the PF can ask firmware to free that switch recipe.
When users configure a rule to PFn into E810 switch component, if there is no existing recipe matching this rule's pattern, the driver will request firmware to allocate and return a new recipe resource for the rule by calling
ice_add_sw_recipe()andice_alloc_recipe(). If there is an existing recipe matching this rule's pattern with different key value, or this is a same second rule to PFm into switch component, the driver checks out this recipe by callingice_find_recp(), the driver will tell firmware to share using this same recipe resource by callingice_subscribable_recp_shared()andice_subscribe_recipe().When firmware detects that all subscribing PFs have freed the switch recipe, firmware will free the switch recipe so that it can be reused.
Quoted 7 lines
This feature also fixes a problem where all switch recipes would eventually be exhausted because switch recipes could not be freed, as freeing a shared recipe could potentially break other PFs that were using it.
Reviewed-by Przemek Kitszel <[email protected]>Reviewed-by Andrii Staikov <[email protected]>Signed-off-by Steven Zou <[email protected]>