1
1
// SPDX-License-Identifier: GPL-2.0
2
2
/* Copyright (c) 2018, Intel Corporation. */
3
3
4
+ #include <net/devlink.h>
4
5
#include "ice_sched.h"
5
6
6
7
/**
@@ -355,6 +356,9 @@ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node)
355
356
/* leaf nodes have no children */
356
357
if (node -> children )
357
358
devm_kfree (ice_hw_to_dev (hw ), node -> children );
359
+
360
+ kfree (node -> name );
361
+ xa_erase (& pi -> sched_node_ids , node -> id );
358
362
devm_kfree (ice_hw_to_dev (hw ), node );
359
363
}
360
364
@@ -875,7 +879,7 @@ void ice_sched_cleanup_all(struct ice_hw *hw)
875
879
*
876
880
* This function add nodes to HW as well as to SW DB for a given layer
877
881
*/
878
- static int
882
+ int
879
883
ice_sched_add_elems (struct ice_port_info * pi , struct ice_sched_node * tc_node ,
880
884
struct ice_sched_node * parent , u8 layer , u16 num_nodes ,
881
885
u16 * num_nodes_added , u32 * first_node_teid )
@@ -940,6 +944,22 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
940
944
941
945
new_node -> sibling = NULL ;
942
946
new_node -> tc_num = tc_node -> tc_num ;
947
+ new_node -> tx_weight = ICE_SCHED_DFLT_BW_WT ;
948
+ new_node -> tx_share = ICE_SCHED_DFLT_BW ;
949
+ new_node -> tx_max = ICE_SCHED_DFLT_BW ;
950
+ new_node -> name = kzalloc (SCHED_NODE_NAME_MAX_LEN , GFP_KERNEL );
951
+ if (!new_node -> name )
952
+ return - ENOMEM ;
953
+
954
+ status = xa_alloc (& pi -> sched_node_ids , & new_node -> id , NULL , XA_LIMIT (0 , UINT_MAX ),
955
+ GFP_KERNEL );
956
+ if (status ) {
957
+ ice_debug (hw , ICE_DBG_SCHED , "xa_alloc failed for sched node status =%d\n" ,
958
+ status );
959
+ break ;
960
+ }
961
+
962
+ snprintf (new_node -> name , SCHED_NODE_NAME_MAX_LEN , "node_%u" , new_node -> id );
943
963
944
964
/* add it to previous node sibling pointer */
945
965
/* Note: siblings are not linked across branches */
@@ -2154,7 +2174,7 @@ ice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node,
2154
2174
* This function removes the child from the old parent and adds it to a new
2155
2175
* parent
2156
2176
*/
2157
- static void
2177
+ void
2158
2178
ice_sched_update_parent (struct ice_sched_node * new_parent ,
2159
2179
struct ice_sched_node * node )
2160
2180
{
@@ -2188,7 +2208,7 @@ ice_sched_update_parent(struct ice_sched_node *new_parent,
2188
2208
*
2189
2209
* This function move the child nodes to a given parent.
2190
2210
*/
2191
- static int
2211
+ int
2192
2212
ice_sched_move_nodes (struct ice_port_info * pi , struct ice_sched_node * parent ,
2193
2213
u16 num_items , u32 * list )
2194
2214
{
@@ -3562,7 +3582,7 @@ ice_sched_set_eir_srl_excl(struct ice_port_info *pi,
3562
3582
* node's RL profile ID of type CIR, EIR, or SRL, and removes old profile
3563
3583
* ID from local database. The caller needs to hold scheduler lock.
3564
3584
*/
3565
- static int
3585
+ int
3566
3586
ice_sched_set_node_bw (struct ice_port_info * pi , struct ice_sched_node * node ,
3567
3587
enum ice_rl_type rl_type , u32 bw , u8 layer_num )
3568
3588
{
@@ -3598,6 +3618,57 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
3598
3618
ICE_AQC_RL_PROFILE_TYPE_M , old_id );
3599
3619
}
3600
3620
3621
+ /**
3622
+ * ice_sched_set_node_priority - set node's priority
3623
+ * @pi: port information structure
3624
+ * @node: tree node
3625
+ * @priority: number 0-7 representing priority among siblings
3626
+ *
3627
+ * This function sets priority of a node among it's siblings.
3628
+ */
3629
+ int
3630
+ ice_sched_set_node_priority (struct ice_port_info * pi , struct ice_sched_node * node ,
3631
+ u16 priority )
3632
+ {
3633
+ struct ice_aqc_txsched_elem_data buf ;
3634
+ struct ice_aqc_txsched_elem * data ;
3635
+
3636
+ buf = node -> info ;
3637
+ data = & buf .data ;
3638
+
3639
+ data -> valid_sections |= ICE_AQC_ELEM_VALID_GENERIC ;
3640
+ data -> generic |= FIELD_PREP (ICE_AQC_ELEM_GENERIC_PRIO_M , priority );
3641
+
3642
+ return ice_sched_update_elem (pi -> hw , node , & buf );
3643
+ }
3644
+
3645
+ /**
3646
+ * ice_sched_set_node_weight - set node's weight
3647
+ * @pi: port information structure
3648
+ * @node: tree node
3649
+ * @weight: number 1-200 representing weight for WFQ
3650
+ *
3651
+ * This function sets weight of the node for WFQ algorithm.
3652
+ */
3653
+ int
3654
+ ice_sched_set_node_weight (struct ice_port_info * pi , struct ice_sched_node * node , u16 weight )
3655
+ {
3656
+ struct ice_aqc_txsched_elem_data buf ;
3657
+ struct ice_aqc_txsched_elem * data ;
3658
+
3659
+ buf = node -> info ;
3660
+ data = & buf .data ;
3661
+
3662
+ data -> valid_sections = ICE_AQC_ELEM_VALID_CIR | ICE_AQC_ELEM_VALID_EIR |
3663
+ ICE_AQC_ELEM_VALID_GENERIC ;
3664
+ data -> cir_bw .bw_alloc = cpu_to_le16 (weight );
3665
+ data -> eir_bw .bw_alloc = cpu_to_le16 (weight );
3666
+
3667
+ data -> generic |= FIELD_PREP (ICE_AQC_ELEM_GENERIC_SP_M , 0x0 );
3668
+
3669
+ return ice_sched_update_elem (pi -> hw , node , & buf );
3670
+ }
3671
+
3601
3672
/**
3602
3673
* ice_sched_set_node_bw_lmt - set node's BW limit
3603
3674
* @pi: port information structure
@@ -3608,7 +3679,7 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
3608
3679
* It updates node's BW limit parameters like BW RL profile ID of type CIR,
3609
3680
* EIR, or SRL. The caller needs to hold scheduler lock.
3610
3681
*/
3611
- static int
3682
+ int
3612
3683
ice_sched_set_node_bw_lmt (struct ice_port_info * pi , struct ice_sched_node * node ,
3613
3684
enum ice_rl_type rl_type , u32 bw )
3614
3685
{
0 commit comments