Skip to content

Commit 77499fb

Browse files
mwilczySasha Levin
authored andcommitted
ice: Introduce new parameters in ice_sched_node
[ Upstream commit 16dfa49 ] To support new devlink-rate API ice_sched_node struct needs to store a number of additional parameters. This includes tx_max, tx_share, tx_weight, and tx_priority. Add new fields to ice_sched_node struct. Add new functions to configure the hardware with new parameters. Introduce new xarray to identify nodes uniquely. Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: adbf5a4 ("ice: remove af_xdp_zc_qps bitmap") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 631ad94 commit 77499fb

File tree

5 files changed

+116
-7
lines changed

5 files changed

+116
-7
lines changed

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,9 @@ struct ice_aqc_txsched_elem {
848848
u8 generic;
849849
#define ICE_AQC_ELEM_GENERIC_MODE_M 0x1
850850
#define ICE_AQC_ELEM_GENERIC_PRIO_S 0x1
851-
#define ICE_AQC_ELEM_GENERIC_PRIO_M (0x7 << ICE_AQC_ELEM_GENERIC_PRIO_S)
851+
#define ICE_AQC_ELEM_GENERIC_PRIO_M GENMASK(3, 1)
852852
#define ICE_AQC_ELEM_GENERIC_SP_S 0x4
853-
#define ICE_AQC_ELEM_GENERIC_SP_M (0x1 << ICE_AQC_ELEM_GENERIC_SP_S)
853+
#define ICE_AQC_ELEM_GENERIC_SP_M GENMASK(4, 4)
854854
#define ICE_AQC_ELEM_GENERIC_ADJUST_VAL_S 0x5
855855
#define ICE_AQC_ELEM_GENERIC_ADJUST_VAL_M \
856856
(0x3 << ICE_AQC_ELEM_GENERIC_ADJUST_VAL_S)

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,9 @@ int ice_init_hw(struct ice_hw *hw)
11051105

11061106
hw->evb_veb = true;
11071107

1108+
/* init xarray for identifying scheduling nodes uniquely */
1109+
xa_init_flags(&hw->port_info->sched_node_ids, XA_FLAGS_ALLOC);
1110+
11081111
/* Query the allocated resources for Tx scheduler */
11091112
status = ice_sched_query_res_alloc(hw);
11101113
if (status) {

drivers/net/ethernet/intel/ice/ice_sched.c

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/* Copyright (c) 2018, Intel Corporation. */
33

4+
#include <net/devlink.h>
45
#include "ice_sched.h"
56

67
/**
@@ -355,6 +356,9 @@ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node)
355356
/* leaf nodes have no children */
356357
if (node->children)
357358
devm_kfree(ice_hw_to_dev(hw), node->children);
359+
360+
kfree(node->name);
361+
xa_erase(&pi->sched_node_ids, node->id);
358362
devm_kfree(ice_hw_to_dev(hw), node);
359363
}
360364

@@ -875,7 +879,7 @@ void ice_sched_cleanup_all(struct ice_hw *hw)
875879
*
876880
* This function add nodes to HW as well as to SW DB for a given layer
877881
*/
878-
static int
882+
int
879883
ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
880884
struct ice_sched_node *parent, u8 layer, u16 num_nodes,
881885
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,
940944

941945
new_node->sibling = NULL;
942946
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);
943963

944964
/* add it to previous node sibling pointer */
945965
/* 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,
21542174
* This function removes the child from the old parent and adds it to a new
21552175
* parent
21562176
*/
2157-
static void
2177+
void
21582178
ice_sched_update_parent(struct ice_sched_node *new_parent,
21592179
struct ice_sched_node *node)
21602180
{
@@ -2188,7 +2208,7 @@ ice_sched_update_parent(struct ice_sched_node *new_parent,
21882208
*
21892209
* This function move the child nodes to a given parent.
21902210
*/
2191-
static int
2211+
int
21922212
ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
21932213
u16 num_items, u32 *list)
21942214
{
@@ -3562,7 +3582,7 @@ ice_sched_set_eir_srl_excl(struct ice_port_info *pi,
35623582
* node's RL profile ID of type CIR, EIR, or SRL, and removes old profile
35633583
* ID from local database. The caller needs to hold scheduler lock.
35643584
*/
3565-
static int
3585+
int
35663586
ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
35673587
enum ice_rl_type rl_type, u32 bw, u8 layer_num)
35683588
{
@@ -3598,6 +3618,57 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
35983618
ICE_AQC_RL_PROFILE_TYPE_M, old_id);
35993619
}
36003620

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+
36013672
/**
36023673
* ice_sched_set_node_bw_lmt - set node's BW limit
36033674
* @pi: port information structure
@@ -3608,7 +3679,7 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
36083679
* It updates node's BW limit parameters like BW RL profile ID of type CIR,
36093680
* EIR, or SRL. The caller needs to hold scheduler lock.
36103681
*/
3611-
static int
3682+
int
36123683
ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node,
36133684
enum ice_rl_type rl_type, u32 bw)
36143685
{

drivers/net/ethernet/intel/ice/ice_sched.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "ice_common.h"
88

9+
#define SCHED_NODE_NAME_MAX_LEN 32
10+
911
#define ICE_QGRP_LAYER_OFFSET 2
1012
#define ICE_VSI_LAYER_OFFSET 4
1113
#define ICE_AGG_LAYER_OFFSET 6
@@ -69,6 +71,28 @@ int
6971
ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
7072
struct ice_aqc_txsched_elem_data *buf, u16 buf_size,
7173
u16 *elems_ret, struct ice_sq_cd *cd);
74+
75+
int
76+
ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node,
77+
enum ice_rl_type rl_type, u32 bw);
78+
79+
int
80+
ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
81+
enum ice_rl_type rl_type, u32 bw, u8 layer_num);
82+
83+
int
84+
ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
85+
struct ice_sched_node *parent, u8 layer, u16 num_nodes,
86+
u16 *num_nodes_added, u32 *first_node_teid);
87+
88+
int
89+
ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
90+
u16 num_items, u32 *list);
91+
92+
int ice_sched_set_node_priority(struct ice_port_info *pi, struct ice_sched_node *node,
93+
u16 priority);
94+
int ice_sched_set_node_weight(struct ice_port_info *pi, struct ice_sched_node *node, u16 weight);
95+
7296
int ice_sched_init_port(struct ice_port_info *pi);
7397
int ice_sched_query_res_alloc(struct ice_hw *hw);
7498
void ice_sched_get_psm_clk_freq(struct ice_hw *hw);
@@ -82,6 +106,9 @@ ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid);
82106
int
83107
ice_sched_add_node(struct ice_port_info *pi, u8 layer,
84108
struct ice_aqc_txsched_elem_data *info);
109+
void
110+
ice_sched_update_parent(struct ice_sched_node *new_parent,
111+
struct ice_sched_node *node);
85112
void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node);
86113
struct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc);
87114
struct ice_sched_node *

drivers/net/ethernet/intel/ice/ice_type.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,14 @@ struct ice_sched_node {
524524
struct ice_sched_node *sibling; /* next sibling in the same layer */
525525
struct ice_sched_node **children;
526526
struct ice_aqc_txsched_elem_data info;
527+
char *name;
528+
struct devlink_rate *rate_node;
529+
u64 tx_max;
530+
u64 tx_share;
527531
u32 agg_id; /* aggregator group ID */
532+
u32 id;
533+
u32 tx_priority;
534+
u32 tx_weight;
528535
u16 vsi_handle;
529536
u8 in_use; /* suspended or in use */
530537
u8 tx_sched_layer; /* Logical Layer (1-9) */
@@ -706,6 +713,7 @@ struct ice_port_info {
706713
/* List contain profile ID(s) and other params per layer */
707714
struct list_head rl_prof_list[ICE_AQC_TOPO_MAX_LEVEL_NUM];
708715
struct ice_qos_cfg qos_cfg;
716+
struct xarray sched_node_ids;
709717
u8 is_vf:1;
710718
};
711719

0 commit comments

Comments
 (0)