Commit ece285af authored by Przemek Kitszel's avatar Przemek Kitszel Committed by Jakub Kicinski

ice: ice_sched_remove_elems: replace 1 elem array param by u32

Replace array+size params of ice_sched_remove_elems:() by just single u32,
as all callers are using it with "1".

This enables moving from heap-based, to stack-based allocation, what is also
more elegant thanks to DEFINE_FLEX() macro.
Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/20230912115937.1645707-3-przemyslaw.kitszel@intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 26dd68d2
...@@ -229,29 +229,22 @@ ice_aq_delete_sched_elems(struct ice_hw *hw, u16 grps_req, ...@@ -229,29 +229,22 @@ ice_aq_delete_sched_elems(struct ice_hw *hw, u16 grps_req,
* ice_sched_remove_elems - remove nodes from HW * ice_sched_remove_elems - remove nodes from HW
* @hw: pointer to the HW struct * @hw: pointer to the HW struct
* @parent: pointer to the parent node * @parent: pointer to the parent node
* @num_nodes: number of nodes * @node_teid: node teid to be deleted
* @node_teids: array of node teids to be deleted
* *
* This function remove nodes from HW * This function remove nodes from HW
*/ */
static int static int
ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent, ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent,
u16 num_nodes, u32 *node_teids) u32 node_teid)
{ {
struct ice_aqc_delete_elem *buf; DEFINE_FLEX(struct ice_aqc_delete_elem, buf, teid, 1);
u16 i, num_groups_removed = 0; u16 buf_size = __struct_size(buf);
u16 buf_size; u16 num_groups_removed = 0;
int status; int status;
buf_size = struct_size(buf, teid, num_nodes);
buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
buf->hdr.parent_teid = parent->info.node_teid; buf->hdr.parent_teid = parent->info.node_teid;
buf->hdr.num_elems = cpu_to_le16(num_nodes); buf->hdr.num_elems = cpu_to_le16(1);
for (i = 0; i < num_nodes; i++) buf->teid[0] = cpu_to_le32(node_teid);
buf->teid[i] = cpu_to_le32(node_teids[i]);
status = ice_aq_delete_sched_elems(hw, 1, buf, buf_size, status = ice_aq_delete_sched_elems(hw, 1, buf, buf_size,
&num_groups_removed, NULL); &num_groups_removed, NULL);
...@@ -259,7 +252,6 @@ ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent, ...@@ -259,7 +252,6 @@ ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent,
ice_debug(hw, ICE_DBG_SCHED, "remove node failed FW error %d\n", ice_debug(hw, ICE_DBG_SCHED, "remove node failed FW error %d\n",
hw->adminq.sq_last_status); hw->adminq.sq_last_status);
devm_kfree(ice_hw_to_dev(hw), buf);
return status; return status;
} }
...@@ -326,7 +318,7 @@ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node) ...@@ -326,7 +318,7 @@ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node)
node->info.data.elem_type != ICE_AQC_ELEM_TYPE_LEAF) { node->info.data.elem_type != ICE_AQC_ELEM_TYPE_LEAF) {
u32 teid = le32_to_cpu(node->info.node_teid); u32 teid = le32_to_cpu(node->info.node_teid);
ice_sched_remove_elems(hw, node->parent, 1, &teid); ice_sched_remove_elems(hw, node->parent, teid);
} }
parent = node->parent; parent = node->parent;
/* root has no parent */ /* root has no parent */
...@@ -1193,7 +1185,7 @@ static void ice_rm_dflt_leaf_node(struct ice_port_info *pi) ...@@ -1193,7 +1185,7 @@ static void ice_rm_dflt_leaf_node(struct ice_port_info *pi)
int status; int status;
/* remove the default leaf node */ /* remove the default leaf node */
status = ice_sched_remove_elems(pi->hw, node->parent, 1, &teid); status = ice_sched_remove_elems(pi->hw, node->parent, teid);
if (!status) if (!status)
ice_free_sched_node(pi, node); ice_free_sched_node(pi, node);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment