Lines Matching refs:pfvf

26 static void otx2_qos_update_tx_netdev_queues(struct otx2_nic *pfvf)  in otx2_qos_update_tx_netdev_queues()  argument
28 struct otx2_hw *hw = &pfvf->hw; in otx2_qos_update_tx_netdev_queues()
31 qos_txqs = bitmap_weight(pfvf->qos.qos_sq_bmap, in otx2_qos_update_tx_netdev_queues()
36 err = netif_set_real_num_tx_queues(pfvf->netdev, tx_queues); in otx2_qos_update_tx_netdev_queues()
38 netdev_err(pfvf->netdev, in otx2_qos_update_tx_netdev_queues()
71 static int otx2_qos_quantum_to_dwrr_weight(struct otx2_nic *pfvf, u32 quantum) in otx2_qos_quantum_to_dwrr_weight() argument
75 weight = quantum / pfvf->hw.dwrr_mtu; in otx2_qos_quantum_to_dwrr_weight()
76 if (quantum % pfvf->hw.dwrr_mtu) in otx2_qos_quantum_to_dwrr_weight()
82 static void otx2_config_sched_shaping(struct otx2_nic *pfvf, in otx2_config_sched_shaping() argument
100 mtu_to_dwrr_weight(pfvf, pfvf->tx_max_pktlen); in otx2_config_sched_shaping()
111 node->quantum : pfvf->tx_max_pktlen; in otx2_config_sched_shaping()
112 rr_weight = otx2_qos_quantum_to_dwrr_weight(pfvf, quantum); in otx2_config_sched_shaping()
122 otx2_get_txschq_rate_regval(pfvf, maxrate, 65536); in otx2_config_sched_shaping()
128 if (!test_bit(QOS_CIR_PIR_SUPPORT, &pfvf->hw.cap_flag)) in otx2_config_sched_shaping()
132 otx2_get_txschq_rate_regval(pfvf, node->rate, 65536); in otx2_config_sched_shaping()
136 static void __otx2_qos_txschq_cfg(struct otx2_nic *pfvf, in __otx2_qos_txschq_cfg() argument
140 struct otx2_hw *hw = &pfvf->hw; in __otx2_qos_txschq_cfg()
149 cfg->regval[num_regs] = ((u64)pfvf->tx_max_pktlen << 8) | in __otx2_qos_txschq_cfg()
155 otx2_config_sched_shaping(pfvf, node, cfg, &num_regs); in __otx2_qos_txschq_cfg()
157 otx2_config_sched_shaping(pfvf, node, cfg, &num_regs); in __otx2_qos_txschq_cfg()
160 if (level == pfvf->qos.link_cfg_lvl) { in __otx2_qos_txschq_cfg()
166 otx2_config_sched_shaping(pfvf, node, cfg, &num_regs); in __otx2_qos_txschq_cfg()
174 if (level == pfvf->qos.link_cfg_lvl) { in __otx2_qos_txschq_cfg()
184 mtu_to_dwrr_weight(pfvf, in __otx2_qos_txschq_cfg()
185 pfvf->tx_max_pktlen); in __otx2_qos_txschq_cfg()
190 otx2_config_sched_shaping(pfvf, node, cfg, &num_regs); in __otx2_qos_txschq_cfg()
197 static int otx2_qos_txschq_set_parent_topology(struct otx2_nic *pfvf, in otx2_qos_txschq_set_parent_topology() argument
200 struct mbox *mbox = &pfvf->mbox; in otx2_qos_txschq_set_parent_topology()
209 cfg = otx2_mbox_alloc_msg_nix_txschq_cfg(&pfvf->mbox); in otx2_qos_txschq_set_parent_topology()
231 rc = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_qos_txschq_set_parent_topology()
238 static void otx2_qos_free_hw_node_schq(struct otx2_nic *pfvf, in otx2_qos_free_hw_node_schq() argument
244 otx2_txschq_free_one(pfvf, node->level, node->schq); in otx2_qos_free_hw_node_schq()
247 static void otx2_qos_free_hw_node(struct otx2_nic *pfvf, in otx2_qos_free_hw_node() argument
253 otx2_qos_free_hw_node(pfvf, node); in otx2_qos_free_hw_node()
254 otx2_qos_free_hw_node_schq(pfvf, node); in otx2_qos_free_hw_node()
255 otx2_txschq_free_one(pfvf, node->level, node->schq); in otx2_qos_free_hw_node()
259 static void otx2_qos_free_hw_cfg(struct otx2_nic *pfvf, in otx2_qos_free_hw_cfg() argument
262 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_free_hw_cfg()
265 otx2_qos_free_hw_node(pfvf, node); in otx2_qos_free_hw_cfg()
266 otx2_qos_free_hw_node_schq(pfvf, node); in otx2_qos_free_hw_cfg()
269 otx2_txschq_free_one(pfvf, node->level, node->schq); in otx2_qos_free_hw_cfg()
271 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_free_hw_cfg()
274 static void otx2_qos_sw_node_delete(struct otx2_nic *pfvf, in otx2_qos_sw_node_delete() argument
280 __clear_bit(node->qid, pfvf->qos.qos_sq_bmap); in otx2_qos_sw_node_delete()
281 otx2_qos_update_tx_netdev_queues(pfvf); in otx2_qos_sw_node_delete()
288 static void otx2_qos_free_sw_node_schq(struct otx2_nic *pfvf, in otx2_qos_free_sw_node_schq() argument
299 static void __otx2_qos_free_sw_node(struct otx2_nic *pfvf, in __otx2_qos_free_sw_node() argument
305 __otx2_qos_free_sw_node(pfvf, node); in __otx2_qos_free_sw_node()
306 otx2_qos_free_sw_node_schq(pfvf, node); in __otx2_qos_free_sw_node()
307 otx2_qos_sw_node_delete(pfvf, node); in __otx2_qos_free_sw_node()
311 static void otx2_qos_free_sw_node(struct otx2_nic *pfvf, in otx2_qos_free_sw_node() argument
314 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_free_sw_node()
316 __otx2_qos_free_sw_node(pfvf, node); in otx2_qos_free_sw_node()
317 otx2_qos_free_sw_node_schq(pfvf, node); in otx2_qos_free_sw_node()
318 otx2_qos_sw_node_delete(pfvf, node); in otx2_qos_free_sw_node()
320 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_free_sw_node()
323 static void otx2_qos_destroy_node(struct otx2_nic *pfvf, in otx2_qos_destroy_node() argument
326 otx2_qos_free_hw_cfg(pfvf, node); in otx2_qos_destroy_node()
327 otx2_qos_free_sw_node(pfvf, node); in otx2_qos_destroy_node()
356 static void otx2_qos_prepare_txschq_cfg(struct otx2_nic *pfvf, in otx2_qos_prepare_txschq_cfg() argument
360 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_prepare_txschq_cfg()
362 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_prepare_txschq_cfg()
396 static void otx2_qos_read_txschq_cfg(struct otx2_nic *pfvf, in otx2_qos_read_txschq_cfg() argument
400 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_read_txschq_cfg()
402 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_read_txschq_cfg()
406 otx2_qos_alloc_root(struct otx2_nic *pfvf) in otx2_qos_alloc_root() argument
415 if (!is_otx2_vf(pfvf->pcifunc)) { in otx2_qos_alloc_root()
425 hash_add_rcu(pfvf->qos.qos_hlist, &node->hlist, node->classid); in otx2_qos_alloc_root()
426 list_add_tail(&node->list, &pfvf->qos.qos_tree); in otx2_qos_alloc_root()
458 static int otx2_qos_alloc_txschq_node(struct otx2_nic *pfvf, in otx2_qos_alloc_txschq_node() argument
482 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_alloc_txschq_node()
484 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_alloc_txschq_node()
503 otx2_qos_sw_create_leaf_node(struct otx2_nic *pfvf, in otx2_qos_sw_create_leaf_node() argument
528 __set_bit(qid, pfvf->qos.qos_sq_bmap); in otx2_qos_sw_create_leaf_node()
530 hash_add_rcu(pfvf->qos.qos_hlist, &node->hlist, classid); in otx2_qos_sw_create_leaf_node()
532 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_sw_create_leaf_node()
535 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_sw_create_leaf_node()
538 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_sw_create_leaf_node()
543 err = otx2_qos_alloc_txschq_node(pfvf, node); in otx2_qos_sw_create_leaf_node()
545 otx2_qos_sw_node_delete(pfvf, node); in otx2_qos_sw_create_leaf_node()
553 *otx2_sw_node_find_by_qid(struct otx2_nic *pfvf, u16 qid) in otx2_sw_node_find_by_qid() argument
558 hash_for_each(pfvf->qos.qos_hlist, bkt, node, hlist) { in otx2_sw_node_find_by_qid()
567 otx2_sw_node_find(struct otx2_nic *pfvf, u32 classid) in otx2_sw_node_find() argument
571 hash_for_each_possible(pfvf->qos.qos_hlist, node, hlist, classid) { in otx2_sw_node_find()
580 otx2_sw_node_find_rcu(struct otx2_nic *pfvf, u32 classid) in otx2_sw_node_find_rcu() argument
584 hash_for_each_possible_rcu(pfvf->qos.qos_hlist, node, hlist, classid) { in otx2_sw_node_find_rcu()
592 int otx2_get_txq_by_classid(struct otx2_nic *pfvf, u16 classid) in otx2_get_txq_by_classid() argument
598 node = otx2_sw_node_find_rcu(pfvf, classid); in otx2_get_txq_by_classid()
608 res = pfvf->hw.tx_queues + qid; in otx2_get_txq_by_classid()
614 otx2_qos_txschq_config(struct otx2_nic *pfvf, struct otx2_qos_node *node) in otx2_qos_txschq_config() argument
616 struct mbox *mbox = &pfvf->mbox; in otx2_qos_txschq_config()
622 req = otx2_mbox_alloc_msg_nix_txschq_cfg(&pfvf->mbox); in otx2_qos_txschq_config()
629 __otx2_qos_txschq_cfg(pfvf, node, req); in otx2_qos_txschq_config()
631 rc = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_qos_txschq_config()
638 static int otx2_qos_txschq_alloc(struct otx2_nic *pfvf, in otx2_qos_txschq_alloc() argument
643 struct mbox *mbox = &pfvf->mbox; in otx2_qos_txschq_alloc()
647 req = otx2_mbox_alloc_msg_nix_txsch_alloc(&pfvf->mbox); in otx2_qos_txschq_alloc()
658 rc = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_qos_txschq_alloc()
665 otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr); in otx2_qos_txschq_alloc()
686 pfvf->qos.link_cfg_lvl = rsp->link_cfg_lvl; in otx2_qos_txschq_alloc()
687 pfvf->hw.txschq_aggr_lvl_rr_prio = rsp->aggr_lvl_rr_prio; in otx2_qos_txschq_alloc()
694 static void otx2_qos_free_unused_txschq(struct otx2_nic *pfvf, in otx2_qos_free_unused_txschq() argument
703 otx2_txschq_free_one(pfvf, lvl, schq); in otx2_qos_free_unused_txschq()
709 static void otx2_qos_txschq_fill_cfg_schq(struct otx2_nic *pfvf, in otx2_qos_txschq_fill_cfg_schq() argument
723 static void otx2_qos_txschq_fill_cfg_tl(struct otx2_nic *pfvf, in otx2_qos_txschq_fill_cfg_tl() argument
731 otx2_qos_txschq_fill_cfg_tl(pfvf, tmp, cfg); in otx2_qos_txschq_fill_cfg_tl()
739 otx2_qos_txschq_fill_cfg_schq(pfvf, tmp, cfg); in otx2_qos_txschq_fill_cfg_tl()
743 static void otx2_qos_txschq_fill_cfg(struct otx2_nic *pfvf, in otx2_qos_txschq_fill_cfg() argument
747 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_txschq_fill_cfg()
748 otx2_qos_txschq_fill_cfg_tl(pfvf, node, cfg); in otx2_qos_txschq_fill_cfg()
749 otx2_qos_txschq_fill_cfg_schq(pfvf, node, cfg); in otx2_qos_txschq_fill_cfg()
750 otx2_qos_free_unused_txschq(pfvf, cfg); in otx2_qos_txschq_fill_cfg()
751 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_txschq_fill_cfg()
754 static void __otx2_qos_assign_base_idx_tl(struct otx2_nic *pfvf, in __otx2_qos_assign_base_idx_tl() argument
780 static int otx2_qos_assign_base_idx_tl(struct otx2_nic *pfvf, in otx2_qos_assign_base_idx_tl() argument
799 otx2_qos_assign_base_idx_tl(pfvf, tmp); in otx2_qos_assign_base_idx_tl()
805 __otx2_qos_assign_base_idx_tl(pfvf, tmp, child_idx_bmap, in otx2_qos_assign_base_idx_tl()
811 __otx2_qos_assign_base_idx_tl(pfvf, tmp, child_idx_bmap, in otx2_qos_assign_base_idx_tl()
819 static int otx2_qos_assign_base_idx(struct otx2_nic *pfvf, in otx2_qos_assign_base_idx() argument
824 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_assign_base_idx()
825 ret = otx2_qos_assign_base_idx_tl(pfvf, node); in otx2_qos_assign_base_idx()
826 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_assign_base_idx()
831 static int otx2_qos_txschq_push_cfg_schq(struct otx2_nic *pfvf, in otx2_qos_txschq_push_cfg_schq() argument
839 ret = otx2_qos_txschq_config(pfvf, tmp); in otx2_qos_txschq_push_cfg_schq()
842 ret = otx2_qos_txschq_set_parent_topology(pfvf, tmp->parent); in otx2_qos_txschq_push_cfg_schq()
850 static int otx2_qos_txschq_push_cfg_tl(struct otx2_nic *pfvf, in otx2_qos_txschq_push_cfg_tl() argument
858 ret = otx2_qos_txschq_push_cfg_tl(pfvf, tmp, cfg); in otx2_qos_txschq_push_cfg_tl()
861 ret = otx2_qos_txschq_config(pfvf, tmp); in otx2_qos_txschq_push_cfg_tl()
864 ret = otx2_qos_txschq_push_cfg_schq(pfvf, tmp, cfg); in otx2_qos_txschq_push_cfg_tl()
869 ret = otx2_qos_txschq_set_parent_topology(pfvf, node); in otx2_qos_txschq_push_cfg_tl()
876 static int otx2_qos_txschq_push_cfg(struct otx2_nic *pfvf, in otx2_qos_txschq_push_cfg() argument
882 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_txschq_push_cfg()
883 ret = otx2_qos_txschq_push_cfg_tl(pfvf, node, cfg); in otx2_qos_txschq_push_cfg()
886 ret = otx2_qos_txschq_push_cfg_schq(pfvf, node, cfg); in otx2_qos_txschq_push_cfg()
888 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_txschq_push_cfg()
892 static int otx2_qos_txschq_update_config(struct otx2_nic *pfvf, in otx2_qos_txschq_update_config() argument
896 otx2_qos_txschq_fill_cfg(pfvf, node, cfg); in otx2_qos_txschq_update_config()
898 return otx2_qos_txschq_push_cfg(pfvf, node, cfg); in otx2_qos_txschq_update_config()
901 static int otx2_qos_txschq_update_root_cfg(struct otx2_nic *pfvf, in otx2_qos_txschq_update_root_cfg() argument
906 return otx2_qos_txschq_config(pfvf, root); in otx2_qos_txschq_update_root_cfg()
909 static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg) in otx2_qos_free_cfg() argument
916 otx2_txschq_free_one(pfvf, lvl, schq); in otx2_qos_free_cfg()
924 otx2_txschq_free_one(pfvf, lvl, schq); in otx2_qos_free_cfg()
930 static void otx2_qos_enadis_sq(struct otx2_nic *pfvf, in otx2_qos_enadis_sq() argument
934 if (pfvf->qos.qid_to_sqmap[qid] != OTX2_QOS_INVALID_SQ) in otx2_qos_enadis_sq()
935 otx2_qos_disable_sq(pfvf, qid); in otx2_qos_enadis_sq()
937 pfvf->qos.qid_to_sqmap[qid] = node->schq; in otx2_qos_enadis_sq()
938 otx2_qos_txschq_config(pfvf, node); in otx2_qos_enadis_sq()
939 otx2_qos_enable_sq(pfvf, qid); in otx2_qos_enadis_sq()
942 static void otx2_qos_update_smq_schq(struct otx2_nic *pfvf, in otx2_qos_update_smq_schq() argument
954 otx2_smq_flush(pfvf, tmp->schq); in otx2_qos_update_smq_schq()
956 otx2_qos_enadis_sq(pfvf, tmp, node->qid); in otx2_qos_update_smq_schq()
961 static void __otx2_qos_update_smq(struct otx2_nic *pfvf, in __otx2_qos_update_smq() argument
968 __otx2_qos_update_smq(pfvf, tmp, action); in __otx2_qos_update_smq()
973 otx2_smq_flush(pfvf, tmp->schq); in __otx2_qos_update_smq()
975 otx2_qos_enadis_sq(pfvf, tmp, tmp->qid); in __otx2_qos_update_smq()
977 otx2_qos_update_smq_schq(pfvf, tmp, action); in __otx2_qos_update_smq()
982 static void otx2_qos_update_smq(struct otx2_nic *pfvf, in otx2_qos_update_smq() argument
986 mutex_lock(&pfvf->qos.qos_lock); in otx2_qos_update_smq()
987 __otx2_qos_update_smq(pfvf, node, action); in otx2_qos_update_smq()
988 otx2_qos_update_smq_schq(pfvf, node, action); in otx2_qos_update_smq()
989 mutex_unlock(&pfvf->qos.qos_lock); in otx2_qos_update_smq()
992 static int otx2_qos_push_txschq_cfg(struct otx2_nic *pfvf, in otx2_qos_push_txschq_cfg() argument
998 ret = otx2_qos_txschq_alloc(pfvf, cfg); in otx2_qos_push_txschq_cfg()
1002 ret = otx2_qos_assign_base_idx(pfvf, node); in otx2_qos_push_txschq_cfg()
1006 if (!(pfvf->netdev->flags & IFF_UP)) { in otx2_qos_push_txschq_cfg()
1007 otx2_qos_txschq_fill_cfg(pfvf, node, cfg); in otx2_qos_push_txschq_cfg()
1011 ret = otx2_qos_txschq_update_config(pfvf, node, cfg); in otx2_qos_push_txschq_cfg()
1013 otx2_qos_free_cfg(pfvf, cfg); in otx2_qos_push_txschq_cfg()
1017 otx2_qos_update_smq(pfvf, node, QOS_CFG_SQ); in otx2_qos_push_txschq_cfg()
1022 static int otx2_qos_update_tree(struct otx2_nic *pfvf, in otx2_qos_update_tree() argument
1026 otx2_qos_prepare_txschq_cfg(pfvf, node->parent, cfg); in otx2_qos_update_tree()
1027 return otx2_qos_push_txschq_cfg(pfvf, node->parent, cfg); in otx2_qos_update_tree()
1030 static int otx2_qos_root_add(struct otx2_nic *pfvf, u16 htb_maj_id, u16 htb_defcls, in otx2_qos_root_add() argument
1037 netdev_dbg(pfvf->netdev, in otx2_qos_root_add()
1041 root = otx2_qos_alloc_root(pfvf); in otx2_qos_root_add()
1056 err = otx2_qos_txschq_alloc(pfvf, new_cfg); in otx2_qos_root_add()
1064 root->child_dwrr_prio = pfvf->hw.txschq_aggr_lvl_rr_prio; in otx2_qos_root_add()
1065 netdev_dbg(pfvf->netdev, in otx2_qos_root_add()
1069 if (!(pfvf->netdev->flags & IFF_UP) || in otx2_qos_root_add()
1076 err = otx2_qos_txschq_update_root_cfg(pfvf, root, new_cfg); in otx2_qos_root_add()
1084 WRITE_ONCE(pfvf->qos.defcls, htb_defcls); in otx2_qos_root_add()
1086 smp_store_release(&pfvf->qos.maj_id, htb_maj_id); in otx2_qos_root_add()
1091 otx2_qos_free_cfg(pfvf, new_cfg); in otx2_qos_root_add()
1094 otx2_qos_sw_node_delete(pfvf, root); in otx2_qos_root_add()
1098 static int otx2_qos_root_destroy(struct otx2_nic *pfvf) in otx2_qos_root_destroy() argument
1102 netdev_dbg(pfvf->netdev, "TC_HTB_DESTROY\n"); in otx2_qos_root_destroy()
1105 root = otx2_sw_node_find(pfvf, OTX2_QOS_ROOT_CLASSID); in otx2_qos_root_destroy()
1110 otx2_qos_destroy_node(pfvf, root); in otx2_qos_root_destroy()
1115 static int otx2_qos_validate_quantum(struct otx2_nic *pfvf, u32 quantum) in otx2_qos_validate_quantum() argument
1117 u32 rr_weight = otx2_qos_quantum_to_dwrr_weight(pfvf, quantum); in otx2_qos_validate_quantum()
1123 if (is_dev_otx2(pfvf->pdev)) in otx2_qos_validate_quantum()
1133 struct otx2_nic *pfvf, in otx2_qos_validate_dwrr_cfg() argument
1138 err = otx2_qos_validate_quantum(pfvf, quantum); in otx2_qos_validate_dwrr_cfg()
1156 struct otx2_nic *pfvf, in otx2_qos_validate_configuration() argument
1186 struct otx2_nic *pfvf, in is_qos_node_dwrr() argument
1195 mutex_lock(&pfvf->qos.qos_lock); in is_qos_node_dwrr()
1202 if (otx2_qos_validate_quantum(pfvf, node->quantum)) { in is_qos_node_dwrr()
1203 netdev_err(pfvf->netdev, in is_qos_node_dwrr()
1217 mutex_unlock(&pfvf->qos.qos_lock); in is_qos_node_dwrr()
1222 static int otx2_qos_leaf_alloc_queue(struct otx2_nic *pfvf, u16 classid, in otx2_qos_leaf_alloc_queue() argument
1232 netdev_dbg(pfvf->netdev, in otx2_qos_leaf_alloc_queue()
1249 parent = otx2_sw_node_find(pfvf, parent_classid); in otx2_qos_leaf_alloc_queue()
1261 static_cfg = !is_qos_node_dwrr(parent, pfvf, prio); in otx2_qos_leaf_alloc_queue()
1262 ret = otx2_qos_validate_configuration(parent, extack, pfvf, prio, in otx2_qos_leaf_alloc_queue()
1268 ret = otx2_qos_validate_dwrr_cfg(parent, extack, pfvf, prio, in otx2_qos_leaf_alloc_queue()
1288 otx2_qos_read_txschq_cfg(pfvf, parent, old_cfg); in otx2_qos_leaf_alloc_queue()
1291 qid = otx2_qos_get_qid(pfvf); in otx2_qos_leaf_alloc_queue()
1299 pfvf->qos.qid_to_sqmap[qid] = OTX2_QOS_INVALID_SQ; in otx2_qos_leaf_alloc_queue()
1302 node = otx2_qos_sw_create_leaf_node(pfvf, parent, classid, prio, rate, in otx2_qos_leaf_alloc_queue()
1317 ret = otx2_qos_update_tree(pfvf, node, new_cfg); in otx2_qos_leaf_alloc_queue()
1321 otx2_qos_sw_node_delete(pfvf, node); in otx2_qos_leaf_alloc_queue()
1323 err = otx2_qos_txschq_update_config(pfvf, parent, old_cfg); in otx2_qos_leaf_alloc_queue()
1325 netdev_err(pfvf->netdev, in otx2_qos_leaf_alloc_queue()
1330 otx2_qos_update_smq(pfvf, parent, QOS_CFG_SQ); in otx2_qos_leaf_alloc_queue()
1335 otx2_qos_update_tx_netdev_queues(pfvf); in otx2_qos_leaf_alloc_queue()
1341 otx2_qos_free_cfg(pfvf, old_cfg); in otx2_qos_leaf_alloc_queue()
1344 return pfvf->hw.tx_queues + qid; in otx2_qos_leaf_alloc_queue()
1347 otx2_qos_sw_node_delete(pfvf, node); in otx2_qos_leaf_alloc_queue()
1361 static int otx2_qos_leaf_to_inner(struct otx2_nic *pfvf, u16 classid, in otx2_qos_leaf_to_inner() argument
1371 netdev_dbg(pfvf->netdev, in otx2_qos_leaf_to_inner()
1388 node = otx2_sw_node_find(pfvf, classid); in otx2_qos_leaf_to_inner()
1401 static_cfg = !is_qos_node_dwrr(node, pfvf, prio); in otx2_qos_leaf_to_inner()
1403 ret = otx2_qos_validate_dwrr_cfg(node, extack, pfvf, prio, in otx2_qos_leaf_to_inner()
1426 otx2_qos_read_txschq_cfg(pfvf, node, old_cfg); in otx2_qos_leaf_to_inner()
1429 otx2_qos_disable_sq(pfvf, qid); in otx2_qos_leaf_to_inner()
1430 otx2_qos_free_hw_node_schq(pfvf, node); in otx2_qos_leaf_to_inner()
1431 otx2_qos_free_sw_node_schq(pfvf, node); in otx2_qos_leaf_to_inner()
1432 pfvf->qos.qid_to_sqmap[qid] = OTX2_QOS_INVALID_SQ; in otx2_qos_leaf_to_inner()
1438 child = otx2_qos_sw_create_leaf_node(pfvf, node, child_classid, in otx2_qos_leaf_to_inner()
1454 ret = otx2_qos_update_tree(pfvf, child, new_cfg); in otx2_qos_leaf_to_inner()
1458 otx2_qos_sw_node_delete(pfvf, child); in otx2_qos_leaf_to_inner()
1461 err = otx2_qos_alloc_txschq_node(pfvf, node); in otx2_qos_leaf_to_inner()
1463 netdev_err(pfvf->netdev, in otx2_qos_leaf_to_inner()
1467 err = otx2_qos_txschq_update_config(pfvf, node, old_cfg); in otx2_qos_leaf_to_inner()
1469 netdev_err(pfvf->netdev, in otx2_qos_leaf_to_inner()
1473 otx2_qos_update_smq(pfvf, node, QOS_CFG_SQ); in otx2_qos_leaf_to_inner()
1481 otx2_qos_free_cfg(pfvf, old_cfg); in otx2_qos_leaf_to_inner()
1487 otx2_qos_sw_node_delete(pfvf, child); in otx2_qos_leaf_to_inner()
1500 static int otx2_qos_cur_leaf_nodes(struct otx2_nic *pfvf) in otx2_qos_cur_leaf_nodes() argument
1502 int last = find_last_bit(pfvf->qos.qos_sq_bmap, pfvf->hw.tc_tx_queues); in otx2_qos_cur_leaf_nodes()
1504 return last == pfvf->hw.tc_tx_queues ? 0 : last + 1; in otx2_qos_cur_leaf_nodes()
1520 static void otx2_cfg_smq(struct otx2_nic *pfvf, struct otx2_qos_node *node, in otx2_cfg_smq() argument
1527 otx2_qos_txschq_config(pfvf, tmp); in otx2_cfg_smq()
1528 pfvf->qos.qid_to_sqmap[qid] = tmp->schq; in otx2_cfg_smq()
1532 static int otx2_qos_leaf_del(struct otx2_nic *pfvf, u16 *classid, in otx2_qos_leaf_del() argument
1540 netdev_dbg(pfvf->netdev, "TC_HTB_LEAF_DEL classid %04x\n", *classid); in otx2_qos_leaf_del()
1543 node = otx2_sw_node_find(pfvf, *classid); in otx2_qos_leaf_del()
1555 otx2_qos_disable_sq(pfvf, node->qid); in otx2_qos_leaf_del()
1557 otx2_qos_destroy_node(pfvf, node); in otx2_qos_leaf_del()
1558 pfvf->qos.qid_to_sqmap[qid] = OTX2_QOS_INVALID_SQ; in otx2_qos_leaf_del()
1574 moved_qid = otx2_qos_cur_leaf_nodes(pfvf); in otx2_qos_leaf_del()
1582 node = otx2_sw_node_find_by_qid(pfvf, moved_qid); in otx2_qos_leaf_del()
1590 __clear_bit(moved_qid, pfvf->qos.qos_sq_bmap); in otx2_qos_leaf_del()
1591 otx2_qos_disable_sq(pfvf, moved_qid); in otx2_qos_leaf_del()
1593 otx2_reset_qdisc(pfvf->netdev, pfvf->hw.tx_queues + moved_qid); in otx2_qos_leaf_del()
1598 otx2_cfg_smq(pfvf, node, qid); in otx2_qos_leaf_del()
1600 otx2_qos_enable_sq(pfvf, qid); in otx2_qos_leaf_del()
1601 __set_bit(qid, pfvf->qos.qos_sq_bmap); in otx2_qos_leaf_del()
1608 static int otx2_qos_leaf_del_last(struct otx2_nic *pfvf, u16 classid, bool force, in otx2_qos_leaf_del_last() argument
1618 netdev_dbg(pfvf->netdev, in otx2_qos_leaf_del_last()
1622 node = otx2_sw_node_find(pfvf, classid); in otx2_qos_leaf_del_last()
1632 parent = otx2_sw_node_find(pfvf, node->parent->classid); in otx2_qos_leaf_del_last()
1642 otx2_qos_disable_sq(pfvf, qid); in otx2_qos_leaf_del_last()
1643 otx2_qos_destroy_node(pfvf, node); in otx2_qos_leaf_del_last()
1644 pfvf->qos.qid_to_sqmap[qid] = OTX2_QOS_INVALID_SQ; in otx2_qos_leaf_del_last()
1661 err = otx2_qos_alloc_txschq_node(pfvf, parent); in otx2_qos_leaf_del_last()
1667 __set_bit(qid, pfvf->qos.qos_sq_bmap); in otx2_qos_leaf_del_last()
1677 err = otx2_qos_push_txschq_cfg(pfvf, parent, new_cfg); in otx2_qos_leaf_del_last()
1686 otx2_qos_update_tx_netdev_queues(pfvf); in otx2_qos_leaf_del_last()
1691 void otx2_clean_qos_queues(struct otx2_nic *pfvf) in otx2_clean_qos_queues() argument
1695 root = otx2_sw_node_find(pfvf, OTX2_QOS_ROOT_CLASSID); in otx2_clean_qos_queues()
1699 otx2_qos_update_smq(pfvf, root, QOS_SMQ_FLUSH); in otx2_clean_qos_queues()
1702 void otx2_qos_config_txschq(struct otx2_nic *pfvf) in otx2_qos_config_txschq() argument
1707 root = otx2_sw_node_find(pfvf, OTX2_QOS_ROOT_CLASSID); in otx2_qos_config_txschq()
1712 err = otx2_qos_txschq_config(pfvf, root); in otx2_qos_config_txschq()
1714 netdev_err(pfvf->netdev, "Error update txschq configuration\n"); in otx2_qos_config_txschq()
1719 err = otx2_qos_txschq_push_cfg_tl(pfvf, root, NULL); in otx2_qos_config_txschq()
1721 netdev_err(pfvf->netdev, "Error update txschq configuration\n"); in otx2_qos_config_txschq()
1725 otx2_qos_update_smq(pfvf, root, QOS_CFG_SQ); in otx2_qos_config_txschq()
1729 netdev_err(pfvf->netdev, "Failed to update Scheduler/Shaping config in Hardware\n"); in otx2_qos_config_txschq()
1731 otx2_qos_root_destroy(pfvf); in otx2_qos_config_txschq()
1736 struct otx2_nic *pfvf = netdev_priv(ndev); in otx2_setup_tc_htb() local
1741 return otx2_qos_root_add(pfvf, htb->parent_classid, in otx2_setup_tc_htb()
1744 return otx2_qos_root_destroy(pfvf); in otx2_setup_tc_htb()
1746 res = otx2_qos_leaf_alloc_queue(pfvf, htb->classid, in otx2_setup_tc_htb()
1756 return otx2_qos_leaf_to_inner(pfvf, htb->parent_classid, in otx2_setup_tc_htb()
1761 return otx2_qos_leaf_del(pfvf, &htb->classid, htb->extack); in otx2_setup_tc_htb()
1764 return otx2_qos_leaf_del_last(pfvf, htb->classid, in otx2_setup_tc_htb()
1768 res = otx2_get_txq_by_classid(pfvf, htb->classid); in otx2_setup_tc_htb()