1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
9 bitmap_ctzll(uint64_t slab)
14 return __builtin_ctzll(slab);
18 nix_tm_clear_shaper_profiles(struct nix *nix)
20 struct nix_tm_shaper_profile *shaper_profile, *tmp;
21 struct nix_tm_shaper_profile_list *list;
23 list = &nix->shaper_profile_list;
24 PLT_TAILQ_FOREACH_SAFE(shaper_profile, list, shaper, tmp) {
25 if (shaper_profile->ref_cnt)
26 plt_warn("Shaper profile %u has non zero references",
28 TAILQ_REMOVE(&nix->shaper_profile_list, shaper_profile, shaper);
29 nix_tm_shaper_profile_free(shaper_profile);
34 nix_tm_node_reg_conf(struct nix *nix, struct nix_tm_node *node)
36 uint64_t regval_mask[MAX_REGS_PER_MBOX_MSG];
37 uint64_t regval[MAX_REGS_PER_MBOX_MSG];
38 struct nix_tm_shaper_profile *profile;
39 uint64_t reg[MAX_REGS_PER_MBOX_MSG];
40 struct mbox *mbox = (&nix->dev)->mbox;
41 struct nix_txschq_config *req;
46 memset(regval, 0, sizeof(regval));
47 memset(regval_mask, 0, sizeof(regval_mask));
49 profile = nix_tm_shaper_profile_search(nix, node->shaper_profile_id);
50 hw_lvl = node->hw_lvl;
52 /* Need this trigger to configure TL1 */
53 if (!nix_tm_have_tl1_access(nix) && hw_lvl == NIX_TXSCH_LVL_TL2) {
54 /* Prepare default conf for TL1 */
55 req = mbox_alloc_msg_nix_txschq_cfg(mbox);
56 req->lvl = NIX_TXSCH_LVL_TL1;
58 k = nix_tm_tl1_default_prep(nix, node->parent_hw_id, req->reg,
61 rc = mbox_process(mbox);
66 /* Prepare topology config */
67 k = nix_tm_topology_reg_prep(nix, node, reg, regval, regval_mask);
69 /* Prepare schedule config */
70 k += nix_tm_sched_reg_prep(nix, node, ®[k], ®val[k]);
72 /* Prepare shaping config */
73 k += nix_tm_shaper_reg_prep(node, profile, ®[k], ®val[k]);
78 /* Copy and send config mbox */
79 req = mbox_alloc_msg_nix_txschq_cfg(mbox);
83 mbox_memcpy(req->reg, reg, sizeof(uint64_t) * k);
84 mbox_memcpy(req->regval, regval, sizeof(uint64_t) * k);
85 mbox_memcpy(req->regval_mask, regval_mask, sizeof(uint64_t) * k);
87 rc = mbox_process(mbox);
93 plt_err("Txschq conf failed for node %p, rc=%d", node, rc);
98 nix_tm_txsch_reg_config(struct nix *nix, enum roc_nix_tm_tree tree)
100 struct nix_tm_node_list *list;
101 bool is_pf_or_lbk = false;
102 struct nix_tm_node *node;
103 bool skip_bp = false;
107 list = nix_tm_node_list(nix, tree);
109 if ((!dev_is_vf(&nix->dev) || nix->lbk_link) && !nix->sdp_link)
112 for (hw_lvl = 0; hw_lvl <= nix->tm_root_lvl; hw_lvl++) {
113 TAILQ_FOREACH(node, list, node) {
114 if (node->hw_lvl != hw_lvl)
117 /* Only one TL3/TL2 Link config should have BP enable
118 * set per channel only for PF or lbk vf.
121 if (is_pf_or_lbk && !skip_bp &&
122 node->hw_lvl == nix->tm_link_cfg_lvl) {
127 rc = nix_tm_node_reg_conf(nix, node);
137 nix_tm_update_parent_info(struct nix *nix, enum roc_nix_tm_tree tree)
139 struct nix_tm_node *child, *parent;
140 struct nix_tm_node_list *list;
141 uint32_t rr_prio, max_prio;
144 list = nix_tm_node_list(nix, tree);
146 /* Release all the node hw resources locally
147 * if parent marked as dirty and resource exists.
149 TAILQ_FOREACH(child, list, node) {
150 /* Release resource only if parent direct hierarchy changed */
151 if (child->flags & NIX_TM_NODE_HWRES && child->parent &&
152 child->parent->child_realloc) {
153 nix_tm_free_node_resource(nix, child);
155 child->max_prio = UINT32_MAX;
158 TAILQ_FOREACH(parent, list, node) {
159 /* Count group of children of same priority i.e are RR */
160 rr_num = nix_tm_check_rr(nix, parent->id, tree, &rr_prio,
163 /* Assuming that multiple RR groups are
164 * not configured based on capability.
166 parent->rr_prio = rr_prio;
167 parent->rr_num = rr_num;
168 parent->max_prio = max_prio;
175 nix_tm_root_node_get(struct nix *nix, int tree)
177 struct nix_tm_node_list *list = nix_tm_node_list(nix, tree);
178 struct nix_tm_node *tm_node;
180 TAILQ_FOREACH(tm_node, list, node) {
181 if (tm_node->hw_lvl == nix->tm_root_lvl)
189 nix_tm_node_add(struct roc_nix *roc_nix, struct nix_tm_node *node)
191 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
192 struct nix_tm_shaper_profile *profile;
193 uint32_t node_id, parent_id, lvl;
194 struct nix_tm_node *parent_node;
195 uint32_t priority, profile_id;
196 uint8_t hw_lvl, exp_next_lvl;
197 enum roc_nix_tm_tree tree;
201 priority = node->priority;
202 parent_id = node->parent_id;
203 profile_id = node->shaper_profile_id;
207 plt_tm_dbg("Add node %s lvl %u id %u, prio 0x%x weight 0x%x "
208 "parent %u profile 0x%x tree %u",
209 nix_tm_hwlvl2str(nix_tm_lvl2nix(nix, lvl)), lvl, node_id,
210 priority, node->weight, parent_id, profile_id, tree);
212 if (tree >= ROC_NIX_TM_TREE_MAX)
213 return NIX_ERR_PARAM;
215 /* Translate sw level id's to nix hw level id's */
216 hw_lvl = nix_tm_lvl2nix(nix, lvl);
217 if (hw_lvl == NIX_TXSCH_LVL_CNT && !nix_tm_is_leaf(nix, lvl))
218 return NIX_ERR_TM_INVALID_LVL;
220 /* Leaf nodes have to be same priority */
221 if (nix_tm_is_leaf(nix, lvl) && priority != 0)
222 return NIX_ERR_TM_INVALID_PRIO;
224 parent_node = nix_tm_node_search(nix, parent_id, tree);
226 if (node_id < nix->nb_tx_queues)
227 exp_next_lvl = NIX_TXSCH_LVL_SMQ;
229 exp_next_lvl = hw_lvl + 1;
231 /* Check if there is no parent node yet */
232 if (hw_lvl != nix->tm_root_lvl &&
233 (!parent_node || parent_node->hw_lvl != exp_next_lvl))
234 return NIX_ERR_TM_INVALID_PARENT;
236 /* Check if a node already exists */
237 if (nix_tm_node_search(nix, node_id, tree))
238 return NIX_ERR_TM_NODE_EXISTS;
240 /* Check if root node exists */
241 if (hw_lvl == nix->tm_root_lvl && nix_tm_root_node_get(nix, tree))
242 return NIX_ERR_TM_NODE_EXISTS;
244 profile = nix_tm_shaper_profile_search(nix, profile_id);
245 if (!nix_tm_is_leaf(nix, lvl)) {
246 /* Check if shaper profile exists for non leaf node */
247 if (!profile && profile_id != ROC_NIX_TM_SHAPER_PROFILE_NONE)
248 return NIX_ERR_TM_INVALID_SHAPER_PROFILE;
250 /* Packet mode in profile should match with that of tm node */
251 if (profile && profile->pkt_mode != node->pkt_mode)
252 return NIX_ERR_TM_PKT_MODE_MISMATCH;
255 /* Check if there is second DWRR already in siblings or holes in prio */
256 rc = nix_tm_validate_prio(nix, lvl, parent_id, priority, tree);
260 if (node->weight > roc_nix_tm_max_sched_wt_get())
261 return NIX_ERR_TM_WEIGHT_EXCEED;
263 /* Maintain minimum weight */
267 node->hw_lvl = nix_tm_lvl2nix(nix, lvl);
269 node->max_prio = UINT32_MAX;
270 node->hw_id = NIX_TM_HW_ID_INVALID;
276 node->parent = parent_node;
278 parent_node->child_realloc = true;
279 node->parent_hw_id = NIX_TM_HW_ID_INVALID;
281 TAILQ_INSERT_TAIL(&nix->trees[tree], node, node);
282 plt_tm_dbg("Added node %s lvl %u id %u (%p)",
283 nix_tm_hwlvl2str(node->hw_lvl), lvl, node_id, node);
288 nix_tm_clear_path_xoff(struct nix *nix, struct nix_tm_node *node)
290 struct mbox *mbox = (&nix->dev)->mbox;
291 struct nix_txschq_config *req;
292 struct nix_tm_node *p;
295 /* Enable nodes in path for flush to succeed */
296 if (!nix_tm_is_leaf(nix, node->lvl))
301 if (!(p->flags & NIX_TM_NODE_ENABLED) &&
302 (p->flags & NIX_TM_NODE_HWRES)) {
303 req = mbox_alloc_msg_nix_txschq_cfg(mbox);
304 req->lvl = p->hw_lvl;
305 req->num_regs = nix_tm_sw_xoff_prep(p, false, req->reg,
307 rc = mbox_process(mbox);
311 p->flags |= NIX_TM_NODE_ENABLED;
320 nix_tm_bp_config_set(struct roc_nix *roc_nix, uint16_t sq, uint16_t tc,
323 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
324 enum roc_nix_tm_tree tree = nix->tm_tree;
325 struct mbox *mbox = (&nix->dev)->mbox;
326 struct nix_txschq_config *req = NULL;
327 struct nix_tm_node_list *list;
328 uint16_t link = nix->tx_link;
329 struct nix_tm_node *sq_node;
330 struct nix_tm_node *parent;
331 struct nix_tm_node *node;
335 sq_node = nix_tm_node_search(nix, sq, nix->tm_tree);
339 parent = sq_node->parent;
341 if (parent->lvl == ROC_TM_LVL_SCH2)
344 parent = parent->parent;
349 list = nix_tm_node_list(nix, tree);
351 if (parent->rel_chan != NIX_TM_CHAN_INVALID && parent->rel_chan != tc) {
356 TAILQ_FOREACH(node, list, node) {
357 if (node->hw_lvl != nix->tm_link_cfg_lvl)
360 if (!(node->flags & NIX_TM_NODE_HWRES) || !node->bp_capa)
363 if (node->hw_id != parent->hw_id)
367 req = mbox_alloc_msg_nix_txschq_cfg(mbox);
368 req->lvl = nix->tm_link_cfg_lvl;
372 req->reg[k] = NIX_AF_TL3_TL2X_LINKX_CFG(node->hw_id, link);
373 req->regval[k] = enable ? tc : 0;
374 req->regval[k] |= enable ? BIT_ULL(13) : 0;
375 req->regval_mask[k] = ~(BIT_ULL(13) | GENMASK_ULL(7, 0));
378 if (k >= MAX_REGS_PER_MBOX_MSG) {
380 rc = mbox_process(mbox);
389 rc = mbox_process(mbox);
394 parent->rel_chan = enable ? tc : NIX_TM_CHAN_INVALID;
397 plt_err("Failed to %s bp on link %u, rc=%d(%s)",
398 enable ? "enable" : "disable", link, rc, roc_error_msg_get(rc));
403 nix_tm_bp_config_get(struct roc_nix *roc_nix, bool *is_enabled)
405 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
406 struct nix_txschq_config *req = NULL, *rsp;
407 enum roc_nix_tm_tree tree = nix->tm_tree;
408 struct mbox *mbox = (&nix->dev)->mbox;
409 struct nix_tm_node_list *list;
410 struct nix_tm_node *node;
417 list = nix_tm_node_list(nix, tree);
420 TAILQ_FOREACH(node, list, node) {
421 if (node->hw_lvl != nix->tm_link_cfg_lvl)
424 if (!(node->flags & NIX_TM_NODE_HWRES) || !node->bp_capa)
429 req = mbox_alloc_msg_nix_txschq_cfg(mbox);
431 req->lvl = nix->tm_link_cfg_lvl;
435 req->reg[k] = NIX_AF_TL3_TL2X_LINKX_CFG(node->hw_id, link);
438 if (k >= MAX_REGS_PER_MBOX_MSG) {
440 rc = mbox_process_msg(mbox, (void **)&rsp);
441 if (rc || rsp->num_regs != k)
445 /* Report it as enabled only if enabled or all */
446 for (i = 0; i < k; i++)
447 enable &= !!(rsp->regval[i] & BIT_ULL(13));
453 rc = mbox_process_msg(mbox, (void **)&rsp);
456 /* Report it as enabled only if enabled or all */
457 for (i = 0; i < k; i++)
458 enable &= !!(rsp->regval[i] & BIT_ULL(13));
461 *is_enabled = found ? !!enable : false;
464 plt_err("Failed to get bp status on link %u, rc=%d(%s)", link, rc,
465 roc_error_msg_get(rc));
470 nix_tm_smq_xoff(struct nix *nix, struct nix_tm_node *node, bool enable)
472 struct mbox *mbox = (&nix->dev)->mbox;
473 struct nix_txschq_config *req;
478 plt_tm_dbg("Setting SMQ %u XOFF/FLUSH to %s", smq,
479 enable ? "enable" : "disable");
481 rc = nix_tm_clear_path_xoff(nix, node);
485 req = mbox_alloc_msg_nix_txschq_cfg(mbox);
486 req->lvl = NIX_TXSCH_LVL_SMQ;
489 req->reg[0] = NIX_AF_SMQX_CFG(smq);
490 req->regval[0] = enable ? (BIT_ULL(50) | BIT_ULL(49)) : 0;
491 req->regval_mask[0] =
492 enable ? ~(BIT_ULL(50) | BIT_ULL(49)) : ~BIT_ULL(50);
494 return mbox_process(mbox);
498 nix_tm_leaf_data_get(struct nix *nix, uint16_t sq, uint32_t *rr_quantum,
501 struct nix_tm_node *node;
504 node = nix_tm_node_search(nix, sq, nix->tm_tree);
506 /* Check if we found a valid leaf node */
507 if (!node || !nix_tm_is_leaf(nix, node->lvl) || !node->parent ||
508 node->parent->hw_id == NIX_TM_HW_ID_INVALID) {
512 /* Get SMQ Id of leaf node's parent */
513 *smq = node->parent->hw_id;
514 *rr_quantum = nix_tm_weight_to_rr_quantum(node->weight);
516 rc = nix_tm_smq_xoff(nix, node->parent, false);
519 node->flags |= NIX_TM_NODE_ENABLED;
524 roc_nix_tm_sq_flush_spin(struct roc_nix_sq *sq)
526 struct nix *nix = roc_nix_to_nix_priv(sq->roc_nix);
527 uint16_t sqb_cnt, head_off, tail_off;
528 uint64_t wdata, val, prev;
529 uint16_t qid = sq->qid;
531 uint64_t timeout; /* 10's of usec */
533 /* Wait for enough time based on shaper min rate */
534 timeout = (sq->nb_desc * roc_nix_max_pkt_len(sq->roc_nix) * 8 * 1E5);
535 /* Wait for worst case scenario of this SQ being last priority
536 * and so have to wait for all other SQ's drain out by their own.
538 timeout = timeout * nix->nb_tx_queues;
539 timeout = timeout / nix->tm_rate_min;
543 wdata = ((uint64_t)qid << 32);
544 regaddr = (int64_t *)(nix->base + NIX_LF_SQ_OP_STATUS);
545 val = roc_atomic64_add_nosync(wdata, regaddr);
547 /* Spin multiple iterations as "sq->fc_cache_pkts" can still
548 * have space to send pkts even though fc_mem is disabled
554 val = roc_atomic64_add_nosync(wdata, regaddr);
555 /* Continue on error */
556 if (val & BIT_ULL(63))
562 sqb_cnt = val & 0xFFFF;
563 head_off = (val >> 20) & 0x3F;
564 tail_off = (val >> 28) & 0x3F;
566 /* SQ reached quiescent state */
567 if (sqb_cnt <= 1 && head_off == tail_off &&
568 (*(volatile uint64_t *)sq->fc == sq->nb_sqb_bufs)) {
580 roc_nix_tm_dump(sq->roc_nix);
581 roc_nix_queues_ctx_dump(sq->roc_nix);
585 /* Flush and disable tx queue and its parent SMQ */
587 nix_tm_sq_flush_pre(struct roc_nix_sq *sq)
589 struct roc_nix *roc_nix = sq->roc_nix;
590 struct nix_tm_node *node, *sibling;
591 struct nix_tm_node_list *list;
592 enum roc_nix_tm_tree tree;
599 nix = roc_nix_to_nix_priv(roc_nix);
601 /* Need not do anything if tree is in disabled state */
602 if (!(nix->tm_flags & NIX_TM_HIERARCHY_ENA))
605 mbox = (&nix->dev)->mbox;
609 list = nix_tm_node_list(nix, tree);
611 /* Find the node for this SQ */
612 node = nix_tm_node_search(nix, qid, tree);
613 if (!node || !(node->flags & NIX_TM_NODE_ENABLED)) {
614 plt_err("Invalid node/state for sq %u", qid);
618 /* Enable CGX RXTX to drain pkts */
619 if (!roc_nix->io_enabled) {
620 /* Though it enables both RX MCAM Entries and CGX Link
621 * we assume all the rx queues are stopped way back.
623 mbox_alloc_msg_nix_lf_start_rx(mbox);
624 rc = mbox_process(mbox);
626 plt_err("cgx start failed, rc=%d", rc);
631 /* Disable backpressure */
632 rc = nix_tm_bp_config_set(roc_nix, sq->qid, 0, false);
634 plt_err("Failed to disable backpressure for flush, rc=%d", rc);
638 /* Disable smq xoff for case it was enabled earlier */
639 rc = nix_tm_smq_xoff(nix, node->parent, false);
641 plt_err("Failed to enable smq %u, rc=%d", node->parent->hw_id,
646 /* As per HRM, to disable an SQ, all other SQ's
647 * that feed to same SMQ must be paused before SMQ flush.
649 TAILQ_FOREACH(sibling, list, node) {
650 if (sibling->parent != node->parent)
652 if (!(sibling->flags & NIX_TM_NODE_ENABLED))
660 rc = roc_nix_tm_sq_aura_fc(sq, false);
662 plt_err("Failed to disable sqb aura fc, rc=%d", rc);
666 /* Wait for sq entries to be flushed */
667 rc = roc_nix_tm_sq_flush_spin(sq);
669 plt_err("Failed to drain sq %u, rc=%d\n", sq->qid, rc);
674 node->flags &= ~NIX_TM_NODE_ENABLED;
676 /* Disable and flush */
677 rc = nix_tm_smq_xoff(nix, node->parent, true);
679 plt_err("Failed to disable smq %u, rc=%d", node->parent->hw_id,
684 req = mbox_alloc_msg_nix_rx_sw_sync(mbox);
688 rc = mbox_process(mbox);
690 /* Restore cgx state */
691 if (!roc_nix->io_enabled) {
692 mbox_alloc_msg_nix_lf_stop_rx(mbox);
693 rc |= mbox_process(mbox);
700 nix_tm_sq_flush_post(struct roc_nix_sq *sq)
702 struct roc_nix *roc_nix = sq->roc_nix;
703 struct nix_tm_node *node, *sibling;
704 struct nix_tm_node_list *list;
705 enum roc_nix_tm_tree tree;
706 struct roc_nix_sq *s_sq;
712 nix = roc_nix_to_nix_priv(roc_nix);
714 /* Need not do anything if tree is in disabled state */
715 if (!(nix->tm_flags & NIX_TM_HIERARCHY_ENA))
720 list = nix_tm_node_list(nix, tree);
722 /* Find the node for this SQ */
723 node = nix_tm_node_search(nix, qid, tree);
725 plt_err("Invalid node for sq %u", qid);
729 /* Enable all the siblings back */
730 TAILQ_FOREACH(sibling, list, node) {
731 if (sibling->parent != node->parent)
734 if (sibling->id == qid)
737 if (!(sibling->flags & NIX_TM_NODE_ENABLED))
741 s_sq = nix->sqs[s_qid];
746 /* Enable back if any SQ is still present */
747 rc = nix_tm_smq_xoff(nix, node->parent, false);
749 plt_err("Failed to enable smq %u, rc=%d",
750 node->parent->hw_id, rc);
756 rc = roc_nix_tm_sq_aura_fc(s_sq, true);
758 plt_err("Failed to enable sqb aura fc, rc=%d", rc);
766 /* Restore backpressure */
767 rc = nix_tm_bp_config_set(roc_nix, sq->qid, 0, true);
769 plt_err("Failed to restore backpressure, rc=%d", rc);
777 nix_tm_sq_sched_conf(struct nix *nix, struct nix_tm_node *node,
778 bool rr_quantum_only)
780 struct mbox *mbox = (&nix->dev)->mbox;
781 uint16_t qid = node->id, smq;
785 smq = node->parent->hw_id;
786 rr_quantum = nix_tm_weight_to_rr_quantum(node->weight);
789 plt_tm_dbg("Update sq(%u) rr_quantum 0x%" PRIx64, qid,
792 plt_tm_dbg("Enabling sq(%u)->smq(%u), rr_quantum 0x%" PRIx64,
793 qid, smq, rr_quantum);
795 if (qid > nix->nb_tx_queues)
798 if (roc_model_is_cn9k()) {
799 struct nix_aq_enq_req *aq;
801 aq = mbox_alloc_msg_nix_aq_enq(mbox);
806 aq->ctype = NIX_AQ_CTYPE_SQ;
807 aq->op = NIX_AQ_INSTOP_WRITE;
809 /* smq update only when needed */
810 if (!rr_quantum_only) {
812 aq->sq_mask.smq = ~aq->sq_mask.smq;
814 aq->sq.smq_rr_quantum = rr_quantum;
815 aq->sq_mask.smq_rr_quantum = ~aq->sq_mask.smq_rr_quantum;
817 struct nix_cn10k_aq_enq_req *aq;
819 aq = mbox_alloc_msg_nix_cn10k_aq_enq(mbox);
824 aq->ctype = NIX_AQ_CTYPE_SQ;
825 aq->op = NIX_AQ_INSTOP_WRITE;
827 /* smq update only when needed */
828 if (!rr_quantum_only) {
830 aq->sq_mask.smq = ~aq->sq_mask.smq;
832 aq->sq.smq_rr_weight = rr_quantum;
833 aq->sq_mask.smq_rr_weight = ~aq->sq_mask.smq_rr_weight;
836 rc = mbox_process(mbox);
838 plt_err("Failed to set smq, rc=%d", rc);
843 nix_tm_release_resources(struct nix *nix, uint8_t hw_lvl, bool contig,
846 uint16_t avail, thresh, to_free = 0, schq;
847 struct mbox *mbox = (&nix->dev)->mbox;
848 struct nix_txsch_free_req *req;
849 struct plt_bitmap *bmp;
854 bmp = contig ? nix->schq_contig_bmp[hw_lvl] : nix->schq_bmp[hw_lvl];
856 contig ? nix->contig_rsvd[hw_lvl] : nix->discontig_rsvd[hw_lvl];
857 plt_bitmap_scan_init(bmp);
859 avail = nix_tm_resource_avail(nix, hw_lvl, contig);
862 /* Release only above threshold */
864 to_free = avail - thresh;
866 /* Release everything */
870 /* Now release resources to AF */
872 if (!slab && !plt_bitmap_scan(bmp, &pos, &slab))
875 schq = bitmap_ctzll(slab);
876 slab &= ~(1ULL << schq);
880 req = mbox_alloc_msg_nix_txsch_free(mbox);
884 req->schq_lvl = hw_lvl;
886 rc = mbox_process(mbox);
888 plt_err("failed to release hwres %s(%u) rc %d",
889 nix_tm_hwlvl2str(hw_lvl), schq, rc);
893 plt_tm_dbg("Released hwres %s(%u)", nix_tm_hwlvl2str(hw_lvl),
895 plt_bitmap_clear(bmp, schq);
900 plt_err("resource inconsistency for %s(%u)",
901 nix_tm_hwlvl2str(hw_lvl), contig);
908 nix_tm_free_node_resource(struct nix *nix, struct nix_tm_node *node)
910 struct mbox *mbox = (&nix->dev)->mbox;
911 struct nix_txsch_free_req *req;
912 struct plt_bitmap *bmp;
913 uint16_t avail, hw_id;
917 hw_lvl = node->hw_lvl;
919 bmp = nix->schq_bmp[hw_lvl];
920 /* Free specific HW resource */
921 plt_tm_dbg("Free hwres %s(%u) lvl %u id %u (%p)",
922 nix_tm_hwlvl2str(node->hw_lvl), hw_id, node->lvl, node->id,
925 avail = nix_tm_resource_avail(nix, hw_lvl, false);
926 /* Always for now free to discontiguous queue when avail
929 if (nix->discontig_rsvd[hw_lvl] &&
930 avail < nix->discontig_rsvd[hw_lvl]) {
931 PLT_ASSERT(hw_id < NIX_TM_MAX_HW_TXSCHQ);
932 PLT_ASSERT(plt_bitmap_get(bmp, hw_id) == 0);
933 plt_bitmap_set(bmp, hw_id);
934 node->hw_id = NIX_TM_HW_ID_INVALID;
935 node->flags &= ~NIX_TM_NODE_HWRES;
940 req = mbox_alloc_msg_nix_txsch_free(mbox);
944 req->schq_lvl = node->hw_lvl;
946 rc = mbox_process(mbox);
948 plt_err("failed to release hwres %s(%u) rc %d",
949 nix_tm_hwlvl2str(node->hw_lvl), hw_id, rc);
953 /* Mark parent as dirty for reallocing it's children */
955 node->parent->child_realloc = true;
957 node->hw_id = NIX_TM_HW_ID_INVALID;
958 node->flags &= ~NIX_TM_NODE_HWRES;
959 plt_tm_dbg("Released hwres %s(%u) to af",
960 nix_tm_hwlvl2str(node->hw_lvl), hw_id);
965 nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id,
966 enum roc_nix_tm_tree tree, bool free)
968 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
969 struct nix_tm_shaper_profile *profile;
970 struct nix_tm_node *node, *child;
971 struct nix_tm_node_list *list;
975 plt_tm_dbg("Delete node id %u tree %u", node_id, tree);
977 node = nix_tm_node_search(nix, node_id, tree);
979 return NIX_ERR_TM_INVALID_NODE;
981 list = nix_tm_node_list(nix, tree);
982 /* Check for any existing children */
983 TAILQ_FOREACH(child, list, node) {
984 if (child->parent == node)
985 return NIX_ERR_TM_CHILD_EXISTS;
988 /* Remove shaper profile reference */
989 profile_id = node->shaper_profile_id;
990 profile = nix_tm_shaper_profile_search(nix, profile_id);
992 /* Free hw resource locally */
993 if (node->flags & NIX_TM_NODE_HWRES) {
994 rc = nix_tm_free_node_resource(nix, node);
1002 TAILQ_REMOVE(list, node, node);
1004 plt_tm_dbg("Deleted node %s lvl %u id %u, prio 0x%x weight 0x%x "
1005 "parent %u profile 0x%x tree %u (%p)",
1006 nix_tm_hwlvl2str(node->hw_lvl), node->lvl, node->id,
1007 node->priority, node->weight,
1008 node->parent ? node->parent->id : UINT32_MAX,
1009 node->shaper_profile_id, tree, node);
1010 /* Free only if requested */
1012 nix_tm_node_free(node);
1017 nix_tm_assign_hw_id(struct nix *nix, struct nix_tm_node *parent,
1018 uint16_t *contig_id, int *contig_cnt,
1019 struct nix_tm_node_list *list)
1021 struct nix_tm_node *child;
1022 struct plt_bitmap *bmp;
1023 uint8_t child_hw_lvl;
1024 int spare_schq = -1;
1029 child_hw_lvl = parent->hw_lvl - 1;
1030 bmp = nix->schq_bmp[child_hw_lvl];
1031 plt_bitmap_scan_init(bmp);
1034 /* Save spare schq if it is case of RR + SP */
1035 if (parent->rr_prio != 0xf && *contig_cnt > 1)
1036 spare_schq = *contig_id + parent->rr_prio;
1038 TAILQ_FOREACH(child, list, node) {
1041 if (child->parent->id != parent->id)
1044 /* Resource never expected to be present */
1045 if (child->flags & NIX_TM_NODE_HWRES) {
1046 plt_err("Resource exists for child (%s)%u, id %u (%p)",
1047 nix_tm_hwlvl2str(child->hw_lvl), child->hw_id,
1053 plt_bitmap_scan(bmp, &pos, &slab);
1055 if (child->priority == parent->rr_prio && spare_schq != -1) {
1056 /* Use spare schq first if present */
1059 *contig_cnt = *contig_cnt - 1;
1061 } else if (child->priority == parent->rr_prio) {
1062 /* Assign a discontiguous queue */
1064 plt_err("Schq not found for Child %u "
1066 child->id, child->lvl, child);
1070 schq = bitmap_ctzll(slab);
1071 slab &= ~(1ULL << schq);
1073 plt_bitmap_clear(bmp, schq);
1075 /* Assign a contiguous queue */
1076 schq = *contig_id + child->priority;
1077 *contig_cnt = *contig_cnt - 1;
1080 plt_tm_dbg("Resource %s(%u), for lvl %u id %u(%p)",
1081 nix_tm_hwlvl2str(child->hw_lvl), schq, child->lvl,
1084 child->hw_id = schq;
1085 child->parent_hw_id = parent->hw_id;
1086 child->flags |= NIX_TM_NODE_HWRES;
1093 nix_tm_assign_resources(struct nix *nix, enum roc_nix_tm_tree tree)
1095 struct nix_tm_node *parent, *root = NULL;
1096 struct plt_bitmap *bmp, *bmp_contig;
1097 struct nix_tm_node_list *list;
1098 uint8_t child_hw_lvl, hw_lvl;
1099 uint16_t contig_id, j;
1104 list = nix_tm_node_list(nix, tree);
1105 /* Walk from TL1 to TL4 parents */
1106 for (hw_lvl = NIX_TXSCH_LVL_TL1; hw_lvl > 0; hw_lvl--) {
1107 TAILQ_FOREACH(parent, list, node) {
1108 child_hw_lvl = parent->hw_lvl - 1;
1109 if (parent->hw_lvl != hw_lvl)
1112 /* Remember root for future */
1113 if (parent->hw_lvl == nix->tm_root_lvl)
1116 if (!parent->child_realloc) {
1117 /* Skip when parent is not dirty */
1118 if (nix_tm_child_res_valid(list, parent))
1120 plt_err("Parent not dirty but invalid "
1121 "child res parent id %u(lvl %u)",
1122 parent->id, parent->lvl);
1126 bmp_contig = nix->schq_contig_bmp[child_hw_lvl];
1128 /* Prealloc contiguous indices for a parent */
1129 contig_id = NIX_TM_MAX_HW_TXSCHQ;
1130 cnt = (int)parent->max_prio + 1;
1132 plt_bitmap_scan_init(bmp_contig);
1133 if (!plt_bitmap_scan(bmp_contig, &pos, &slab)) {
1134 plt_err("Contig schq not found");
1137 contig_id = pos + bitmap_ctzll(slab);
1139 /* Check if we have enough */
1140 for (j = contig_id; j < contig_id + cnt; j++) {
1141 if (!plt_bitmap_get(bmp_contig, j))
1145 if (j != contig_id + cnt) {
1146 plt_err("Contig schq not sufficient");
1150 for (j = contig_id; j < contig_id + cnt; j++)
1151 plt_bitmap_clear(bmp_contig, j);
1154 /* Assign hw id to all children */
1155 rc = nix_tm_assign_hw_id(nix, parent, &contig_id, &cnt,
1158 plt_err("Unexpected err, contig res alloc, "
1159 "parent %u, of %s, rc=%d, cnt=%d",
1160 parent->id, nix_tm_hwlvl2str(hw_lvl),
1165 /* Clear the dirty bit as children's
1166 * resources are reallocated.
1168 parent->child_realloc = false;
1172 /* Root is always expected to be there */
1176 if (root->flags & NIX_TM_NODE_HWRES)
1179 /* Process root node */
1180 bmp = nix->schq_bmp[nix->tm_root_lvl];
1181 plt_bitmap_scan_init(bmp);
1182 if (!plt_bitmap_scan(bmp, &pos, &slab)) {
1183 plt_err("Resource not allocated for root");
1187 root->hw_id = pos + bitmap_ctzll(slab);
1188 root->flags |= NIX_TM_NODE_HWRES;
1189 plt_bitmap_clear(bmp, root->hw_id);
1191 /* Get TL1 id as well when root is not TL1 */
1192 if (!nix_tm_have_tl1_access(nix)) {
1193 bmp = nix->schq_bmp[NIX_TXSCH_LVL_TL1];
1195 plt_bitmap_scan_init(bmp);
1196 if (!plt_bitmap_scan(bmp, &pos, &slab)) {
1197 plt_err("Resource not found for TL1");
1200 root->parent_hw_id = pos + bitmap_ctzll(slab);
1201 plt_bitmap_clear(bmp, root->parent_hw_id);
1204 plt_tm_dbg("Resource %s(%u) for root(id %u) (%p)",
1205 nix_tm_hwlvl2str(root->hw_lvl), root->hw_id, root->id, root);
1211 nix_tm_copy_rsp_to_nix(struct nix *nix, struct nix_txsch_alloc_rsp *rsp)
1216 for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
1217 for (i = 0; i < rsp->schq[lvl]; i++)
1218 plt_bitmap_set(nix->schq_bmp[lvl],
1219 rsp->schq_list[lvl][i]);
1221 for (i = 0; i < rsp->schq_contig[lvl]; i++)
1222 plt_bitmap_set(nix->schq_contig_bmp[lvl],
1223 rsp->schq_contig_list[lvl][i]);
1228 nix_tm_alloc_txschq(struct nix *nix, enum roc_nix_tm_tree tree)
1230 uint16_t schq_contig[NIX_TXSCH_LVL_CNT];
1231 struct mbox *mbox = (&nix->dev)->mbox;
1232 uint16_t schq[NIX_TXSCH_LVL_CNT];
1233 struct nix_txsch_alloc_req *req;
1234 struct nix_txsch_alloc_rsp *rsp;
1239 memset(schq, 0, sizeof(schq));
1240 memset(schq_contig, 0, sizeof(schq_contig));
1242 /* Estimate requirement */
1243 rc = nix_tm_resource_estimate(nix, schq_contig, schq, tree);
1247 /* Release existing contiguous resources when realloc requested
1248 * as there is no way to guarantee continuity of old with new.
1250 for (hw_lvl = 0; hw_lvl < NIX_TXSCH_LVL_CNT; hw_lvl++) {
1251 if (schq_contig[hw_lvl])
1252 nix_tm_release_resources(nix, hw_lvl, true, false);
1255 /* Alloc as needed */
1258 req = mbox_alloc_msg_nix_txsch_alloc(mbox);
1263 mbox_memcpy(req->schq, schq, sizeof(req->schq));
1264 mbox_memcpy(req->schq_contig, schq_contig,
1265 sizeof(req->schq_contig));
1267 /* Each alloc can be at max of MAX_TXSCHQ_PER_FUNC per level.
1268 * So split alloc to multiple requests.
1270 for (i = 0; i < NIX_TXSCH_LVL_CNT; i++) {
1271 if (req->schq[i] > MAX_TXSCHQ_PER_FUNC)
1272 req->schq[i] = MAX_TXSCHQ_PER_FUNC;
1273 schq[i] -= req->schq[i];
1275 if (req->schq_contig[i] > MAX_TXSCHQ_PER_FUNC)
1276 req->schq_contig[i] = MAX_TXSCHQ_PER_FUNC;
1277 schq_contig[i] -= req->schq_contig[i];
1279 if (schq[i] || schq_contig[i])
1283 rc = mbox_process_msg(mbox, (void *)&rsp);
1287 nix_tm_copy_rsp_to_nix(nix, rsp);
1290 nix->tm_link_cfg_lvl = rsp->link_cfg_lvl;
1291 nix->tm_aggr_lvl_rr_prio = rsp->aggr_lvl_rr_prio;
1294 for (i = 0; i < NIX_TXSCH_LVL_CNT; i++) {
1295 if (nix_tm_release_resources(nix, i, true, false))
1296 plt_err("Failed to release contig resources of "
1299 if (nix_tm_release_resources(nix, i, false, false))
1300 plt_err("Failed to release discontig resources of "
1308 nix_tm_prepare_default_tree(struct roc_nix *roc_nix)
1310 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1311 uint32_t nonleaf_id = nix->nb_tx_queues;
1312 struct nix_tm_node *node = NULL;
1313 uint8_t leaf_lvl, lvl, lvl_end;
1317 /* Add ROOT, SCH1, SCH2, SCH3, [SCH4] nodes */
1318 parent = ROC_NIX_TM_NODE_ID_INVALID;
1319 /* With TL1 access we have an extra level */
1320 lvl_end = (nix_tm_have_tl1_access(nix) ? ROC_TM_LVL_SCH4 :
1323 for (lvl = ROC_TM_LVL_ROOT; lvl <= lvl_end; lvl++) {
1325 node = nix_tm_node_alloc();
1329 node->id = nonleaf_id;
1330 node->parent_id = parent;
1332 node->weight = NIX_TM_DFLT_RR_WT;
1333 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1335 node->tree = ROC_NIX_TM_DEFAULT;
1336 node->rel_chan = NIX_TM_CHAN_INVALID;
1338 rc = nix_tm_node_add(roc_nix, node);
1341 parent = nonleaf_id;
1345 parent = nonleaf_id - 1;
1346 leaf_lvl = (nix_tm_have_tl1_access(nix) ? ROC_TM_LVL_QUEUE :
1349 /* Add leaf nodes */
1350 for (i = 0; i < nix->nb_tx_queues; i++) {
1352 node = nix_tm_node_alloc();
1357 node->parent_id = parent;
1359 node->weight = NIX_TM_DFLT_RR_WT;
1360 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1361 node->lvl = leaf_lvl;
1362 node->tree = ROC_NIX_TM_DEFAULT;
1363 node->rel_chan = NIX_TM_CHAN_INVALID;
1365 rc = nix_tm_node_add(roc_nix, node);
1372 nix_tm_node_free(node);
1377 roc_nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix)
1379 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1380 uint32_t nonleaf_id = nix->nb_tx_queues;
1381 struct nix_tm_node *node = NULL;
1382 uint8_t leaf_lvl, lvl, lvl_end;
1386 /* Add ROOT, SCH1, SCH2 nodes */
1387 parent = ROC_NIX_TM_NODE_ID_INVALID;
1388 lvl_end = (nix_tm_have_tl1_access(nix) ? ROC_TM_LVL_SCH3 :
1391 for (lvl = ROC_TM_LVL_ROOT; lvl <= lvl_end; lvl++) {
1393 node = nix_tm_node_alloc();
1397 node->id = nonleaf_id;
1398 node->parent_id = parent;
1400 node->weight = NIX_TM_DFLT_RR_WT;
1401 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1403 node->tree = ROC_NIX_TM_RLIMIT;
1404 node->rel_chan = NIX_TM_CHAN_INVALID;
1406 rc = nix_tm_node_add(roc_nix, node);
1409 parent = nonleaf_id;
1413 /* SMQ is mapped to SCH4 when we have TL1 access and SCH3 otherwise */
1414 lvl = (nix_tm_have_tl1_access(nix) ? ROC_TM_LVL_SCH4 : ROC_TM_LVL_SCH3);
1416 /* Add per queue SMQ nodes i.e SCH4 / SCH3 */
1417 for (i = 0; i < nix->nb_tx_queues; i++) {
1419 node = nix_tm_node_alloc();
1423 node->id = nonleaf_id + i;
1424 node->parent_id = parent;
1426 node->weight = NIX_TM_DFLT_RR_WT;
1427 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1429 node->tree = ROC_NIX_TM_RLIMIT;
1430 node->rel_chan = NIX_TM_CHAN_INVALID;
1432 rc = nix_tm_node_add(roc_nix, node);
1437 parent = nonleaf_id;
1438 leaf_lvl = (nix_tm_have_tl1_access(nix) ? ROC_TM_LVL_QUEUE :
1441 /* Add leaf nodes */
1442 for (i = 0; i < nix->nb_tx_queues; i++) {
1444 node = nix_tm_node_alloc();
1449 node->parent_id = parent + i;
1451 node->weight = NIX_TM_DFLT_RR_WT;
1452 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1453 node->lvl = leaf_lvl;
1454 node->tree = ROC_NIX_TM_RLIMIT;
1455 node->rel_chan = NIX_TM_CHAN_INVALID;
1457 rc = nix_tm_node_add(roc_nix, node);
1464 nix_tm_node_free(node);
1469 roc_nix_tm_pfc_prepare_tree(struct roc_nix *roc_nix)
1471 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1472 uint32_t nonleaf_id = nix->nb_tx_queues;
1473 struct nix_tm_node *node = NULL;
1474 uint8_t leaf_lvl, lvl, lvl_end;
1475 uint32_t tl2_node_id;
1479 parent = ROC_NIX_TM_NODE_ID_INVALID;
1480 lvl_end = ROC_TM_LVL_SCH3;
1481 leaf_lvl = ROC_TM_LVL_QUEUE;
1484 node = nix_tm_node_alloc();
1488 node->id = nonleaf_id;
1489 node->parent_id = parent;
1491 node->weight = NIX_TM_DFLT_RR_WT;
1492 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1493 node->lvl = ROC_TM_LVL_ROOT;
1494 node->tree = ROC_NIX_TM_PFC;
1495 node->rel_chan = NIX_TM_CHAN_INVALID;
1497 rc = nix_tm_node_add(roc_nix, node);
1501 parent = nonleaf_id;
1506 node = nix_tm_node_alloc();
1510 node->id = nonleaf_id;
1511 node->parent_id = parent;
1513 node->weight = NIX_TM_DFLT_RR_WT;
1514 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1515 node->lvl = ROC_TM_LVL_SCH1;
1516 node->tree = ROC_NIX_TM_PFC;
1517 node->rel_chan = NIX_TM_CHAN_INVALID;
1519 rc = nix_tm_node_add(roc_nix, node);
1523 tl2_node_id = nonleaf_id;
1526 for (i = 0; i < nix->nb_tx_queues; i++) {
1527 parent = tl2_node_id;
1528 for (lvl = ROC_TM_LVL_SCH2; lvl <= lvl_end; lvl++) {
1530 node = nix_tm_node_alloc();
1534 node->id = nonleaf_id;
1535 node->parent_id = parent;
1537 node->weight = NIX_TM_DFLT_RR_WT;
1538 node->shaper_profile_id =
1539 ROC_NIX_TM_SHAPER_PROFILE_NONE;
1541 node->tree = ROC_NIX_TM_PFC;
1542 node->rel_chan = NIX_TM_CHAN_INVALID;
1544 rc = nix_tm_node_add(roc_nix, node);
1548 parent = nonleaf_id;
1552 lvl = ROC_TM_LVL_SCH4;
1555 node = nix_tm_node_alloc();
1559 node->id = nonleaf_id;
1560 node->parent_id = parent;
1562 node->weight = NIX_TM_DFLT_RR_WT;
1563 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1565 node->tree = ROC_NIX_TM_PFC;
1566 node->rel_chan = NIX_TM_CHAN_INVALID;
1568 rc = nix_tm_node_add(roc_nix, node);
1572 parent = nonleaf_id;
1576 node = nix_tm_node_alloc();
1581 node->parent_id = parent;
1583 node->weight = NIX_TM_DFLT_RR_WT;
1584 node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE;
1585 node->lvl = leaf_lvl;
1586 node->tree = ROC_NIX_TM_PFC;
1587 node->rel_chan = NIX_TM_CHAN_INVALID;
1589 rc = nix_tm_node_add(roc_nix, node);
1596 nix_tm_node_free(node);
1601 nix_tm_free_resources(struct roc_nix *roc_nix, uint32_t tree_mask, bool hw_only)
1603 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1604 struct nix_tm_shaper_profile *profile;
1605 struct nix_tm_node *node, *next_node;
1606 struct nix_tm_node_list *list;
1607 enum roc_nix_tm_tree tree;
1608 uint32_t profile_id;
1611 for (tree = 0; tree < ROC_NIX_TM_TREE_MAX; tree++) {
1612 if (!(tree_mask & BIT(tree)))
1615 plt_tm_dbg("Freeing resources of tree %u", tree);
1617 list = nix_tm_node_list(nix, tree);
1618 next_node = TAILQ_FIRST(list);
1621 next_node = TAILQ_NEXT(node, node);
1623 if (!nix_tm_is_leaf(nix, node->lvl) &&
1624 node->flags & NIX_TM_NODE_HWRES) {
1625 /* Clear xoff in path for flush to succeed */
1626 rc = nix_tm_clear_path_xoff(nix, node);
1629 rc = nix_tm_free_node_resource(nix, node);
1635 /* Leave software elements if needed */
1639 next_node = TAILQ_FIRST(list);
1642 next_node = TAILQ_NEXT(node, node);
1644 plt_tm_dbg("Free node lvl %u id %u (%p)", node->lvl,
1647 profile_id = node->shaper_profile_id;
1648 profile = nix_tm_shaper_profile_search(nix, profile_id);
1652 TAILQ_REMOVE(list, node, node);
1653 nix_tm_node_free(node);
1660 nix_tm_conf_init(struct roc_nix *roc_nix)
1662 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1663 uint32_t bmp_sz, hw_lvl;
1667 PLT_STATIC_ASSERT(sizeof(struct nix_tm_node) <= ROC_NIX_TM_NODE_SZ);
1668 PLT_STATIC_ASSERT(sizeof(struct nix_tm_shaper_profile) <=
1669 ROC_NIX_TM_SHAPER_PROFILE_SZ);
1672 for (i = 0; i < ROC_NIX_TM_TREE_MAX; i++)
1673 TAILQ_INIT(&nix->trees[i]);
1675 TAILQ_INIT(&nix->shaper_profile_list);
1676 nix->tm_rate_min = 1E9; /* 1Gbps */
1679 bmp_sz = plt_bitmap_get_memory_footprint(NIX_TM_MAX_HW_TXSCHQ);
1680 bmp_mem = plt_zmalloc(bmp_sz * NIX_TXSCH_LVL_CNT * 2, 0);
1683 nix->schq_bmp_mem = bmp_mem;
1685 /* Init contiguous and discontiguous bitmap per lvl */
1687 for (hw_lvl = 0; hw_lvl < NIX_TXSCH_LVL_CNT; hw_lvl++) {
1688 /* Bitmap for discontiguous resource */
1689 nix->schq_bmp[hw_lvl] =
1690 plt_bitmap_init(NIX_TM_MAX_HW_TXSCHQ, bmp_mem, bmp_sz);
1691 if (!nix->schq_bmp[hw_lvl])
1694 bmp_mem = PLT_PTR_ADD(bmp_mem, bmp_sz);
1696 /* Bitmap for contiguous resource */
1697 nix->schq_contig_bmp[hw_lvl] =
1698 plt_bitmap_init(NIX_TM_MAX_HW_TXSCHQ, bmp_mem, bmp_sz);
1699 if (!nix->schq_contig_bmp[hw_lvl])
1702 bmp_mem = PLT_PTR_ADD(bmp_mem, bmp_sz);
1705 rc = nix_tm_mark_init(nix);
1709 /* Disable TL1 Static Priority when VF's are enabled
1710 * as otherwise VF's TL2 reallocation will be needed
1711 * runtime to support a specific topology of PF.
1713 if (nix->pci_dev->max_vfs)
1714 nix->tm_flags |= NIX_TM_TL1_NO_SP;
1716 /* TL1 access is only for PF's */
1717 if (roc_nix_is_pf(roc_nix)) {
1718 nix->tm_flags |= NIX_TM_TL1_ACCESS;
1719 nix->tm_root_lvl = NIX_TXSCH_LVL_TL1;
1721 nix->tm_root_lvl = NIX_TXSCH_LVL_TL2;
1726 nix_tm_conf_fini(roc_nix);
1731 nix_tm_conf_fini(struct roc_nix *roc_nix)
1733 struct nix *nix = roc_nix_to_nix_priv(roc_nix);
1736 for (hw_lvl = 0; hw_lvl < NIX_TXSCH_LVL_CNT; hw_lvl++) {
1737 plt_bitmap_free(nix->schq_bmp[hw_lvl]);
1738 plt_bitmap_free(nix->schq_contig_bmp[hw_lvl]);
1740 plt_free(nix->schq_bmp_mem);