1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Marvell RVU Ethernet driver
4 * Copyright (C) 2023 Marvell.
10 #include <linux/types.h>
11 #include <linux/netdevice.h>
12 #include <linux/rhashtable.h>
14 #define OTX2_QOS_MAX_LVL 4
15 #define OTX2_QOS_MAX_PRIO 7
16 #define OTX2_QOS_MAX_LEAF_NODES 16
18 enum qos_smq_operations {
23 u64 otx2_get_txschq_rate_regval(struct otx2_nic *nic, u64 maxrate, u32 burst);
25 int otx2_setup_tc_htb(struct net_device *ndev, struct tc_htb_qopt_offload *htb);
26 int otx2_qos_get_qid(struct otx2_nic *pfvf);
27 void otx2_qos_free_qid(struct otx2_nic *pfvf, int qidx);
28 int otx2_qos_enable_sq(struct otx2_nic *pfvf, int qidx);
29 void otx2_qos_disable_sq(struct otx2_nic *pfvf, int qidx);
32 u16 schq[NIX_TXSCH_LVL_CNT];
33 u16 schq_contig[NIX_TXSCH_LVL_CNT];
34 int static_node_pos[NIX_TXSCH_LVL_CNT];
35 int dwrr_node_pos[NIX_TXSCH_LVL_CNT];
36 u16 schq_contig_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
37 u16 schq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
38 bool schq_index_used[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
42 DECLARE_HASHTABLE(qos_hlist, order_base_2(OTX2_QOS_MAX_LEAF_NODES));
43 struct mutex qos_lock; /* child list lock */
44 u16 qid_to_sqmap[OTX2_QOS_MAX_LEAF_NODES];
45 struct list_head qos_tree;
46 DECLARE_BITMAP(qos_sq_bmap, OTX2_QOS_MAX_LEAF_NODES);
49 u8 link_cfg_lvl; /* LINKX_CFG CSRs mapped to TL3 or TL2's index ? */
52 struct otx2_qos_node {
53 struct list_head list; /* list management */
54 struct list_head child_list;
55 struct list_head child_schq_list;
56 struct hlist_node hlist;
57 DECLARE_BITMAP(prio_bmap, OTX2_QOS_MAX_PRIO + 1);
58 struct otx2_qos_node *parent; /* parent qos node */
59 u64 rate; /* htb params */
72 u16 txschq_idx; /* txschq allocation index */