Commit bdf96d96 authored by Michal Wilczynski's avatar Michal Wilczynski Committed by Jakub Kicinski

ice: Add an option to pre-allocate memory for ice_sched_node

devlink-rate API requires a priv object to be allocated when node still
doesn't have a parent. This is problematic, because ice_sched_node can't
be currently created without a parent.

Add an option to pre-allocate memory for ice_sched_node struct. Add
new arguments to ice_sched_add() and ice_sched_add_elems() that allow
for pre-allocation of memory for ice_sched_node struct.
Signed-off-by: default avatarMichal Wilczynski <michal.wilczynski@intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 16dfa494
...@@ -4603,7 +4603,7 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle, ...@@ -4603,7 +4603,7 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
q_ctx->q_teid = le32_to_cpu(node.node_teid); q_ctx->q_teid = le32_to_cpu(node.node_teid);
/* add a leaf node into scheduler tree queue layer */ /* add a leaf node into scheduler tree queue layer */
status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node); status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node, NULL);
if (!status) if (!status)
status = ice_sched_replay_q_bw(pi, q_ctx); status = ice_sched_replay_q_bw(pi, q_ctx);
...@@ -4838,7 +4838,7 @@ ice_ena_vsi_rdma_qset(struct ice_port_info *pi, u16 vsi_handle, u8 tc, ...@@ -4838,7 +4838,7 @@ ice_ena_vsi_rdma_qset(struct ice_port_info *pi, u16 vsi_handle, u8 tc,
for (i = 0; i < num_qsets; i++) { for (i = 0; i < num_qsets; i++) {
node.node_teid = buf->rdma_qsets[i].qset_teid; node.node_teid = buf->rdma_qsets[i].qset_teid;
ret = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, ret = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1,
&node); &node, NULL);
if (ret) if (ret)
break; break;
qset_teid[i] = le32_to_cpu(node.node_teid); qset_teid[i] = le32_to_cpu(node.node_teid);
......
...@@ -1580,7 +1580,7 @@ ice_update_port_tc_tree_cfg(struct ice_port_info *pi, ...@@ -1580,7 +1580,7 @@ ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
/* new TC */ /* new TC */
status = ice_sched_query_elem(pi->hw, teid2, &elem); status = ice_sched_query_elem(pi->hw, teid2, &elem);
if (!status) if (!status)
status = ice_sched_add_node(pi, 1, &elem); status = ice_sched_add_node(pi, 1, &elem, NULL);
if (status) if (status)
break; break;
/* update the TC number */ /* update the TC number */
......
...@@ -143,12 +143,14 @@ ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, ...@@ -143,12 +143,14 @@ ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
* @pi: port information structure * @pi: port information structure
* @layer: Scheduler layer of the node * @layer: Scheduler layer of the node
* @info: Scheduler element information from firmware * @info: Scheduler element information from firmware
* @prealloc_node: preallocated ice_sched_node struct for SW DB
* *
* This function inserts a scheduler node to the SW DB. * This function inserts a scheduler node to the SW DB.
*/ */
int int
ice_sched_add_node(struct ice_port_info *pi, u8 layer, ice_sched_add_node(struct ice_port_info *pi, u8 layer,
struct ice_aqc_txsched_elem_data *info) struct ice_aqc_txsched_elem_data *info,
struct ice_sched_node *prealloc_node)
{ {
struct ice_aqc_txsched_elem_data elem; struct ice_aqc_txsched_elem_data elem;
struct ice_sched_node *parent; struct ice_sched_node *parent;
...@@ -177,7 +179,10 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, ...@@ -177,7 +179,10 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,
if (status) if (status)
return status; return status;
node = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*node), GFP_KERNEL); if (prealloc_node)
node = prealloc_node;
else
node = devm_kzalloc(ice_hw_to_dev(hw), sizeof(*node), GFP_KERNEL);
if (!node) if (!node)
return -ENOMEM; return -ENOMEM;
if (hw->max_children[layer]) { if (hw->max_children[layer]) {
...@@ -876,13 +881,15 @@ void ice_sched_cleanup_all(struct ice_hw *hw) ...@@ -876,13 +881,15 @@ void ice_sched_cleanup_all(struct ice_hw *hw)
* @num_nodes: number of nodes * @num_nodes: number of nodes
* @num_nodes_added: pointer to num nodes added * @num_nodes_added: pointer to num nodes added
* @first_node_teid: if new nodes are added then return the TEID of first node * @first_node_teid: if new nodes are added then return the TEID of first node
* @prealloc_nodes: preallocated nodes struct for software DB
* *
* This function add nodes to HW as well as to SW DB for a given layer * This function add nodes to HW as well as to SW DB for a given layer
*/ */
int int
ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
struct ice_sched_node *parent, u8 layer, u16 num_nodes, struct ice_sched_node *parent, u8 layer, u16 num_nodes,
u16 *num_nodes_added, u32 *first_node_teid) u16 *num_nodes_added, u32 *first_node_teid,
struct ice_sched_node **prealloc_nodes)
{ {
struct ice_sched_node *prev, *new_node; struct ice_sched_node *prev, *new_node;
struct ice_aqc_add_elem *buf; struct ice_aqc_add_elem *buf;
...@@ -928,7 +935,11 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, ...@@ -928,7 +935,11 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
*num_nodes_added = num_nodes; *num_nodes_added = num_nodes;
/* add nodes to the SW DB */ /* add nodes to the SW DB */
for (i = 0; i < num_nodes; i++) { for (i = 0; i < num_nodes; i++) {
status = ice_sched_add_node(pi, layer, &buf->generic[i]); if (prealloc_nodes)
status = ice_sched_add_node(pi, layer, &buf->generic[i], prealloc_nodes[i]);
else
status = ice_sched_add_node(pi, layer, &buf->generic[i], NULL);
if (status) { if (status) {
ice_debug(hw, ICE_DBG_SCHED, "add nodes in SW DB failed status =%d\n", ice_debug(hw, ICE_DBG_SCHED, "add nodes in SW DB failed status =%d\n",
status); status);
...@@ -1023,7 +1034,7 @@ ice_sched_add_nodes_to_hw_layer(struct ice_port_info *pi, ...@@ -1023,7 +1034,7 @@ ice_sched_add_nodes_to_hw_layer(struct ice_port_info *pi,
} }
return ice_sched_add_elems(pi, tc_node, parent, layer, num_nodes, return ice_sched_add_elems(pi, tc_node, parent, layer, num_nodes,
num_nodes_added, first_node_teid); num_nodes_added, first_node_teid, NULL);
} }
/** /**
...@@ -1288,7 +1299,7 @@ int ice_sched_init_port(struct ice_port_info *pi) ...@@ -1288,7 +1299,7 @@ int ice_sched_init_port(struct ice_port_info *pi)
ICE_AQC_ELEM_TYPE_ENTRY_POINT) ICE_AQC_ELEM_TYPE_ENTRY_POINT)
hw->sw_entry_point_layer = j; hw->sw_entry_point_layer = j;
status = ice_sched_add_node(pi, j, &buf[i].generic[j]); status = ice_sched_add_node(pi, j, &buf[i].generic[j], NULL);
if (status) if (status)
goto err_init_port; goto err_init_port;
} }
......
...@@ -83,7 +83,8 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node, ...@@ -83,7 +83,8 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
int int
ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
struct ice_sched_node *parent, u8 layer, u16 num_nodes, struct ice_sched_node *parent, u8 layer, u16 num_nodes,
u16 *num_nodes_added, u32 *first_node_teid); u16 *num_nodes_added, u32 *first_node_teid,
struct ice_sched_node **prealloc_node);
int int
ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent, ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
...@@ -105,7 +106,8 @@ struct ice_sched_node * ...@@ -105,7 +106,8 @@ struct ice_sched_node *
ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid); ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid);
int int
ice_sched_add_node(struct ice_port_info *pi, u8 layer, ice_sched_add_node(struct ice_port_info *pi, u8 layer,
struct ice_aqc_txsched_elem_data *info); struct ice_aqc_txsched_elem_data *info,
struct ice_sched_node *prealloc_node);
void void
ice_sched_update_parent(struct ice_sched_node *new_parent, ice_sched_update_parent(struct ice_sched_node *new_parent,
struct ice_sched_node *node); struct ice_sched_node *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