diff mbox series

[07/63] net/ice/base: correct argument port info

Message ID 20190826105105.19121-8-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers show
Series net/ice/base: update base code | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Zhang, Qi Z Aug. 26, 2019, 10:50 a.m. UTC
correct argument pi(port_info) passed in function
ice_sched_get_first_node(), otherwise it will return the incorrect
node.

functions ice_sched_get_agg_node and ice_sched_cfg_sibl_node_prio:
change argument from hw to pi for it to align to correct port.

Moved saving tc node bw info from hardware structure(hw) to port info
structure(pi). This change allows multiple ports to save and replay
the information correctly.

Signed-off-by: Tarun Singh <tarun.k.singh@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/base/ice_common.c |  2 +-
 drivers/net/ice/base/ice_common.h |  2 +-
 drivers/net/ice/base/ice_sched.c  | 70 ++++++++++++++++++++-------------------
 drivers/net/ice/base/ice_sched.h  |  4 +--
 drivers/net/ice/base/ice_type.h   |  2 +-
 5 files changed, 41 insertions(+), 39 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c
index 0356537a4..b4f0b964d 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -4158,7 +4158,7 @@  static enum ice_status ice_replay_pre_init(struct ice_hw *hw)
 				  &sw->recp_list[i].filt_replay_rules);
 	ice_sched_replay_agg_vsi_preinit(hw);
 
-	return ice_sched_replay_tc_node_bw(hw);
+	return ice_sched_replay_tc_node_bw(hw->port_info);
 }
 
 /**
diff --git a/drivers/net/ice/base/ice_common.h b/drivers/net/ice/base/ice_common.h
index c5170f705..4ecfa6b9b 100644
--- a/drivers/net/ice/base/ice_common.h
+++ b/drivers/net/ice/base/ice_common.h
@@ -184,7 +184,7 @@  enum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
 void ice_replay_post(struct ice_hw *hw);
 void ice_sched_replay_agg_vsi_preinit(struct ice_hw *hw);
 void ice_sched_replay_agg(struct ice_hw *hw);
-enum ice_status ice_sched_replay_tc_node_bw(struct ice_hw *hw);
+enum ice_status ice_sched_replay_tc_node_bw(struct ice_port_info *pi);
 enum ice_status ice_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle);
 enum ice_status
 ice_sched_replay_q_bw(struct ice_port_info *pi, struct ice_q_ctx *q_ctx);
diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c
index 2d80af731..d16f256c9 100644
--- a/drivers/net/ice/base/ice_sched.c
+++ b/drivers/net/ice/base/ice_sched.c
@@ -1480,7 +1480,7 @@  ice_sched_get_vsi_node(struct ice_port_info *pi, struct ice_sched_node *tc_node,
 
 /**
  * ice_sched_get_agg_node - Get an aggregator node based on aggregator ID
- * @hw: pointer to the HW struct
+ * @pi: pointer to the port information structure
  * @tc_node: pointer to the TC node
  * @agg_id: aggregator ID
  *
@@ -1488,14 +1488,17 @@  ice_sched_get_vsi_node(struct ice_port_info *pi, struct ice_sched_node *tc_node,
  * a given TC branch
  */
 static struct ice_sched_node *
-ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
+ice_sched_get_agg_node(struct ice_port_info *pi, struct ice_sched_node *tc_node,
 		       u32 agg_id)
 {
 	struct ice_sched_node *node;
+	struct ice_hw *hw = pi->hw;
 	u8 agg_layer;
 
+	if (!hw)
+		return NULL;
 	agg_layer = ice_sched_get_agg_layer(hw);
-	node = ice_sched_get_first_node(hw->port_info, tc_node, agg_layer);
+	node = ice_sched_get_first_node(pi, tc_node, agg_layer);
 
 	/* Check whether it already exists */
 	while (node) {
@@ -2251,7 +2254,7 @@  ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
 	if (!tc_node)
 		return ICE_ERR_CFG;
 
-	agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+	agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 	if (!agg_node)
 		return ICE_ERR_DOES_NOT_EXIST;
 
@@ -2388,7 +2391,7 @@  ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
 	if (!tc_node)
 		return ICE_ERR_CFG;
 
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 	if (!agg_node)
 		return ICE_ERR_DOES_NOT_EXIST;
 
@@ -2497,7 +2500,7 @@  ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
 	if (!tc_node)
 		return ICE_ERR_CFG;
 
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 	/* Does Agg node already exist ? */
 	if (agg_node)
 		return status;
@@ -3445,7 +3448,6 @@  ice_cfg_vsi_q_priority(struct ice_port_info *pi, u16 num_qs, u32 *q_ids,
 		       u8 *q_prio)
 {
 	enum ice_status status = ICE_ERR_PARAM;
-	struct ice_hw *hw = pi->hw;
 	u16 i;
 
 	ice_acquire_lock(&pi->sched_lock);
@@ -3460,7 +3462,7 @@  ice_cfg_vsi_q_priority(struct ice_port_info *pi, u16 num_qs, u32 *q_ids,
 			break;
 		}
 		/* Configure Priority */
-		status = ice_sched_cfg_sibl_node_prio(hw, node, q_prio[i]);
+		status = ice_sched_cfg_sibl_node_prio(pi, node, q_prio[i]);
 		if (status)
 			break;
 	}
@@ -3508,7 +3510,7 @@  ice_cfg_agg_vsi_priority_per_tc(struct ice_port_info *pi, u32 agg_id,
 	if (!tc_node)
 		goto exit_agg_priority_per_tc;
 
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 	if (!agg_node)
 		goto exit_agg_priority_per_tc;
 
@@ -3542,7 +3544,7 @@  ice_cfg_agg_vsi_priority_per_tc(struct ice_port_info *pi, u32 agg_id,
 
 		if (ice_sched_find_node_in_subtree(hw, agg_node, vsi_node)) {
 			/* Configure Priority */
-			status = ice_sched_cfg_sibl_node_prio(hw, vsi_node,
+			status = ice_sched_cfg_sibl_node_prio(pi, vsi_node,
 							      node_prio[i]);
 			if (status)
 				break;
@@ -3654,7 +3656,7 @@  ice_cfg_agg_bw_alloc(struct ice_port_info *pi, u32 agg_id, u8 ena_tcmap,
 		if (!tc_node)
 			continue;
 
-		agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+		agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 		if (!agg_node)
 			continue;
 
@@ -4453,19 +4455,17 @@  static enum ice_status
 ice_sched_save_tc_node_bw(struct ice_port_info *pi, u8 tc,
 			  enum ice_rl_type rl_type, u32 bw)
 {
-	struct ice_hw *hw = pi->hw;
-
 	if (tc >= ICE_MAX_TRAFFIC_CLASS)
 		return ICE_ERR_PARAM;
 	switch (rl_type) {
 	case ICE_MIN_BW:
-		ice_set_clear_cir_bw(&hw->tc_node_bw_t_info[tc], bw);
+		ice_set_clear_cir_bw(&pi->tc_node_bw_t_info[tc], bw);
 		break;
 	case ICE_MAX_BW:
-		ice_set_clear_eir_bw(&hw->tc_node_bw_t_info[tc], bw);
+		ice_set_clear_eir_bw(&pi->tc_node_bw_t_info[tc], bw);
 		break;
 	case ICE_SHARED_BW:
-		ice_set_clear_shared_bw(&hw->tc_node_bw_t_info[tc], bw);
+		ice_set_clear_shared_bw(&pi->tc_node_bw_t_info[tc], bw);
 		break;
 	default:
 		return ICE_ERR_PARAM;
@@ -4552,17 +4552,15 @@  static enum ice_status
 ice_sched_save_tc_node_bw_alloc(struct ice_port_info *pi, u8 tc,
 				enum ice_rl_type rl_type, u16 bw_alloc)
 {
-	struct ice_hw *hw = pi->hw;
-
 	if (tc >= ICE_MAX_TRAFFIC_CLASS)
 		return ICE_ERR_PARAM;
 	switch (rl_type) {
 	case ICE_MIN_BW:
-		ice_set_clear_cir_bw_alloc(&hw->tc_node_bw_t_info[tc],
+		ice_set_clear_cir_bw_alloc(&pi->tc_node_bw_t_info[tc],
 					   bw_alloc);
 		break;
 	case ICE_MAX_BW:
-		ice_set_clear_eir_bw_alloc(&hw->tc_node_bw_t_info[tc],
+		ice_set_clear_eir_bw_alloc(&pi->tc_node_bw_t_info[tc],
 					   bw_alloc);
 		break;
 	default:
@@ -4710,7 +4708,7 @@  ice_sched_get_node_by_id_type(struct ice_port_info *pi, u32 id,
 
 		tc_node = ice_sched_get_tc_node(pi, tc);
 		if (tc_node)
-			node = ice_sched_get_agg_node(pi->hw, tc_node, id);
+			node = ice_sched_get_agg_node(pi, tc_node, id);
 		break;
 	}
 
@@ -4921,7 +4919,7 @@  ice_sched_validate_agg_srl_node(struct ice_port_info *pi, u32 agg_id)
 		if (!tc_node)
 			continue;
 
-		agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+		agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 		if (!agg_node)
 			continue;
 		/* SRL bandwidth layer selection */
@@ -4992,7 +4990,7 @@  ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
 		if (!tc_node)
 			continue;
 
-		agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+		agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
 		if (!agg_node)
 			continue;
 
@@ -5017,7 +5015,7 @@  ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
 
 /**
  * ice_sched_cfg_sibl_node_prio - configure node sibling priority
- * @hw: pointer to the HW struct
+ * @pi: port information structure
  * @node: sched node to configure
  * @priority: sibling priority
  *
@@ -5025,13 +5023,16 @@  ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
  * function needs to be called with scheduler lock held.
  */
 enum ice_status
-ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
-			     u8 priority)
+ice_sched_cfg_sibl_node_prio(struct ice_port_info *pi,
+			     struct ice_sched_node *node, u8 priority)
 {
 	struct ice_aqc_txsched_elem_data buf;
 	struct ice_aqc_txsched_elem *data;
+	struct ice_hw *hw = pi->hw;
 	enum ice_status status;
 
+	if (!hw)
+		return ICE_ERR_PARAM;
 	buf = node->info;
 	data = &buf.data;
 	data->valid_sections |= ICE_AQC_ELEM_VALID_GENERIC;
@@ -5198,7 +5199,7 @@  ice_sched_replay_agg_bw(struct ice_hw *hw, struct ice_sched_agg_info *agg_info)
 			status = ICE_ERR_PARAM;
 			break;
 		}
-		agg_node = ice_sched_get_agg_node(hw, tc_node,
+		agg_node = ice_sched_get_agg_node(hw->port_info, tc_node,
 						  agg_info->agg_id);
 		if (!agg_node) {
 			status = ICE_ERR_PARAM;
@@ -5310,26 +5311,27 @@  void ice_sched_replay_agg_vsi_preinit(struct ice_hw *hw)
 
 /**
  * ice_sched_replay_tc_node_bw - replay TC node(s) BW
- * @hw: pointer to the HW struct
+ * @pi: port information structure
  *
- * This function replay TC nodes. The caller needs to hold the scheduler lock.
+ * This function replay TC nodes.
  */
 enum ice_status
-ice_sched_replay_tc_node_bw(struct ice_hw *hw)
+ice_sched_replay_tc_node_bw(struct ice_port_info *pi)
 {
-	struct ice_port_info *pi = hw->port_info;
 	enum ice_status status = ICE_SUCCESS;
 	u8 tc;
 
+	if (!pi->hw)
+		return ICE_ERR_PARAM;
 	ice_acquire_lock(&pi->sched_lock);
 	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node;
 
-		tc_node = ice_sched_get_tc_node(hw->port_info, tc);
+		tc_node = ice_sched_get_tc_node(pi, tc);
 		if (!tc_node)
 			continue; /* TC not present */
-		status = ice_sched_replay_node_bw(hw, tc_node,
-						  &hw->tc_node_bw_t_info[tc]);
+		status = ice_sched_replay_node_bw(pi->hw, tc_node,
+						  &pi->tc_node_bw_t_info[tc]);
 		if (status)
 			break;
 	}
diff --git a/drivers/net/ice/base/ice_sched.h b/drivers/net/ice/base/ice_sched.h
index 38f8f93d2..932ae075f 100644
--- a/drivers/net/ice/base/ice_sched.h
+++ b/drivers/net/ice/base/ice_sched.h
@@ -183,6 +183,6 @@  ice_sched_set_vsi_bw_shared_lmt(struct ice_port_info *pi, u16 vsi_handle,
 enum ice_status
 ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw);
 enum ice_status
-ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
-			     u8 priority);
+ice_sched_cfg_sibl_node_prio(struct ice_port_info *pi,
+			     struct ice_sched_node *node, u8 priority);
 #endif /* _ICE_SCHED_H_ */
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index 88846e042..d8cb8eecd 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -674,6 +674,7 @@  struct ice_port_info {
 		sib_head[ICE_MAX_TRAFFIC_CLASS][ICE_AQC_TOPO_MAX_LEVEL_NUM];
 	/* List contain profile ID(s) and other params per layer */
 	struct LIST_HEAD_TYPE rl_prof_list[ICE_AQC_TOPO_MAX_LEVEL_NUM];
+	struct ice_bw_type_info tc_node_bw_t_info[ICE_MAX_TRAFFIC_CLASS];
 	struct ice_dcbx_cfg local_dcbx_cfg;	/* Oper/Local Cfg */
 	/* DCBX info */
 	struct ice_dcbx_cfg remote_dcbx_cfg;	/* Peer Cfg */
@@ -742,7 +743,6 @@  struct ice_hw {
 	u8 sw_entry_point_layer;
 	u16 max_children[ICE_AQC_TOPO_MAX_LEVEL_NUM];
 	struct LIST_HEAD_TYPE agg_list;	/* lists all aggregator */
-	struct ice_bw_type_info tc_node_bw_t_info[ICE_MAX_TRAFFIC_CLASS];
 	struct ice_vsi_ctx *vsi_ctx[ICE_MAX_VSI];
 	u8 evb_veb;		/* true for VEB, false for VEPA */
 	u8 reset_ongoing;	/* true if HW is in reset, false otherwise */