Skip to contentSkip to conversation

ice: Add support for switch recipe reusing feature

PATCH In review Steven Zou 2 participants 3 messages Sep 26, 2023

Subsystems (2)
lore
Share & tools
lore

Steven Zou

author
#0 lore raw

PATCH v6 1/1 ice: Add support for switch recipe reusing feature

If E810 firmware supports the corresponding functionality, 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.

---
v2:
- fix nvm version detection for the feature (Thanks to Przemek)
- fix more small commit message Reviewed-by Przemek

v3: refactor ice_alloc_recipe to support both legacy and new methods

v4:
- a small change in ice_subscribe_recipe, sw_resp instead of flu_resp
- move ice_subscribe_recipe() and ice_subscribable_recp_shared() definitions down to before ice_add_adv_recipe()
- add commit message for new function of ice_subscribe_recipe()

v5:
- refactor ice_init_chk_subscribable_recipe_support() and replace it to ice_init_chk_recipe_reuse_support()
- add a newline before 'return' in ice_init_hw()
- remove redundant cast of u8
- make u8 and u16 to u32 in the subfunctions

v6:
- fix AdminQ data type from/to FW and casting for bitmap type issue
- fix hole padding with adding new member in ice_hw structure
- fix setting the flag of recp_created issue
- fix redundant lable
- change bit traversal method

---
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   4 +-
 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   | 247 +++++++++++++++---
 drivers/net/ethernet/intel/ice/ice_switch.h   |   5 +-
 drivers/net/ethernet/intel/ice/ice_type.h     |   2 +
 6 files changed, 229 insertions(+), 35 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +3 -1
index eb4c13b754a4..c43688520eca 100644
@@ -263,6 +263,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
 
@@ -592,7 +594,7 @@ 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;
 };
 
 /* Add/Update/Remove/Get switch rules (indirect 0x02A0, 0x02A1, 0x02A2, 0x02A3)
drivers/net/ethernet/intel/ice/ice_common.c +2 -0
index d4e259b816b9..64d79571ebf0 100644
@@ -1075,6 +1075,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_lag.c +2 -2
index 5466fba52f58..85c1ac3272b8 100644
@@ -2008,7 +2008,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;
 
@@ -2016,7 +2016,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 +217 -30

434 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_switch.h +3 -2
index db7e501b7e0a..522ff549392b 100644
@@ -424,10 +424,11 @@ 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);
+void ice_init_chk_recipe_reuse_support(struct ice_hw *hw);
 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_ */
drivers/net/ethernet/intel/ice/ice_type.h +2 -0
index e68425bd0713..8298c8382d87 100644
@@ -837,6 +837,8 @@ struct ice_hw {
 
 	u16 max_burst_size;	/* driver sets this value */
 
+	bool recp_reuse;	/* indicates whether FW supports recipe reuse */
+
 	/* Tx Scheduler values */
 	u8 num_tx_sched_layers;
 	u8 num_tx_sched_phys_layers;

base-commit: c1735368c670faae047e41c815474d5b64837072

Signature · 6 lines
2.31.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#1 lore raw
Quoted 48 lines · Steven Zou

If E810 firmware supports the corresponding functionality, 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.

---
v2:
- fix nvm version detection for the feature (Thanks to Przemek)
- fix more small commit message Reviewed-by Przemek

v3: refactor ice_alloc_recipe to support both legacy and new methods

v4:
- a small change in ice_subscribe_recipe, sw_resp instead of flu_resp
- move ice_subscribe_recipe() and ice_subscribable_recp_shared() definitions down to before ice_add_adv_recipe()
- add commit message for new function of ice_subscribe_recipe()

v5:
- refactor ice_init_chk_subscribable_recipe_support() and replace it to ice_init_chk_recipe_reuse_support()
- add a newline before 'return' in ice_init_hw()
- remove redundant cast of u8
- make u8 and u16 to u32 in the subfunctions

v6:
- fix AdminQ data type from/to FW and casting for bitmap type issue
- fix hole padding with adding new member in ice_hw structure
- fix setting the flag of recp_created issue
- fix redundant lable
- change bit traversal method

Quoted 8 lines
---
  .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   4 +-
  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   | 247 +++++++++++++++---
  drivers/net/ethernet/intel/ice/ice_switch.h   |   5 +-
  drivers/net/ethernet/intel/ice/ice_type.h     |   2 +
  6 files changed, 229 insertions(+), 35 deletions(-)

Hi, we are not yet done with our pre-IWL (e1000) review.

General rule is to have Reviewed-by: tag prior to posting here.
And public submission versioning should start with v1, without the changelog from e1000.

Normally one should also CC netdev, which you have not.

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 59 lines · Przemek Kitszel
Quoted 56 lines · Steven Zou

If E810 firmware supports the corresponding functionality, 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.

---
v2:
- fix nvm version detection for the feature (Thanks to Przemek)
- fix more small commit message Reviewed-by Przemek

v3: refactor ice_alloc_recipe to support both legacy and new methods

v4:
- a small change in ice_subscribe_recipe, sw_resp instead of flu_resp
- move ice_subscribe_recipe() and ice_subscribable_recp_shared() definitions
down to before ice_add_adv_recipe()
- add commit message for new function of ice_subscribe_recipe()

v5:
- refactor ice_init_chk_subscribable_recipe_support() and replace it to ice_init_chk_recipe_reuse_support()
- add a newline before 'return' in ice_init_hw()
- remove redundant cast of u8
- make u8 and u16 to u32 in the subfunctions

v6:
- fix AdminQ data type from/to FW and casting for bitmap type issue
- fix hole padding with adding new member in ice_hw structure
- fix setting the flag of recp_created issue
- fix redundant lable
- change bit traversal method
---
  .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   4 +- 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   | 247 +++++++++++++++--- drivers/net/ethernet/intel/ice/ice_switch.h   |   5 +- drivers/net/ethernet/intel/ice/ice_type.h     |   2 +

Quoted 1 line
  6 files changed, 229 insertions(+), 35 deletions(-)
Quoted 6 lines

Hi, we are not yet done with our pre-IWL (e1000) review.

General rule is to have Reviewed-by: tag prior to posting here.
And public submission versioning should start with v1, without the changelog from e1000.

Normally one should also CC netdev, which you have not.

Thank you very much!
My mistake.
Please ignore my submission this time here.

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan