1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020
5 #include "txgbe_type.h"
10 * txgbe_dcb_config_rx_arbiter_raptor - Config Rx Data arbiter
11 * @hw: pointer to hardware structure
12 * @refill: refill credits index by traffic class
13 * @max: max credits index by traffic class
14 * @bwg_id: bandwidth grouping indexed by traffic class
15 * @tsa: transmission selection algorithm indexed by traffic class
16 * @map: priority to tc assignments indexed by priority
18 * Configure Rx Packet Arbiter and credits for each traffic class.
20 s32 txgbe_dcb_config_rx_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,
21 u16 *max, u8 *bwg_id, u8 *tsa,
25 u32 credit_refill = 0;
30 * Disable the arbiter before changing parameters
31 * (always enable recycle mode; WSP)
33 reg = TXGBE_ARBRXCTL_RRM | TXGBE_ARBRXCTL_WSP |
35 wr32(hw, TXGBE_ARBRXCTL, reg);
38 * map all UPs to TCs. up_to_tc_bitmap for each TC has corresponding
39 * bits sets for the UPs that needs to be mappped to that TC.
40 * e.g if priorities 6 and 7 are to be mapped to a TC then the
41 * up_to_tc_bitmap value for that TC will be 11000000 in binary.
44 for (i = 0; i < TXGBE_DCB_UP_MAX; i++)
45 reg |= (map[i] << (i * TXGBE_RPUP2TC_UP_SHIFT));
47 wr32(hw, TXGBE_RPUP2TC, reg);
49 /* Configure traffic class credits and priority */
50 for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
51 credit_refill = refill[i];
53 reg = TXGBE_QARBRXCFG_CRQ(credit_refill) |
54 TXGBE_QARBRXCFG_MCL(credit_max) |
55 TXGBE_QARBRXCFG_BWG(bwg_id[i]);
57 if (tsa[i] == txgbe_dcb_tsa_strict)
58 reg |= TXGBE_QARBRXCFG_LSP;
60 wr32(hw, TXGBE_QARBRXCFG(i), reg);
64 * Configure Rx packet plane (recycle mode; WSP) and
67 reg = TXGBE_ARBRXCTL_RRM | TXGBE_ARBRXCTL_WSP;
68 wr32(hw, TXGBE_ARBRXCTL, reg);
74 * txgbe_dcb_config_tx_desc_arbiter_raptor - Config Tx Desc. arbiter
75 * @hw: pointer to hardware structure
76 * @refill: refill credits index by traffic class
77 * @max: max credits index by traffic class
78 * @bwg_id: bandwidth grouping indexed by traffic class
79 * @tsa: transmission selection algorithm indexed by traffic class
81 * Configure Tx Descriptor Arbiter and credits for each traffic class.
83 s32 txgbe_dcb_config_tx_desc_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,
84 u16 *max, u8 *bwg_id, u8 *tsa)
89 /* Clear the per-Tx queue credits; we use per-TC instead */
90 for (i = 0; i < 128; i++)
91 wr32(hw, TXGBE_QARBTXCRED(i), 0);
93 /* Configure traffic class credits and priority */
94 for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
96 reg = TXGBE_QARBTXCFG_MCL(max_credits) |
97 TXGBE_QARBTXCFG_CRQ(refill[i]) |
98 TXGBE_QARBTXCFG_BWG(bwg_id[i]);
100 if (tsa[i] == txgbe_dcb_tsa_group_strict_cee)
101 reg |= TXGBE_QARBTXCFG_GSP;
103 if (tsa[i] == txgbe_dcb_tsa_strict)
104 reg |= TXGBE_QARBTXCFG_LSP;
106 wr32(hw, TXGBE_QARBTXCFG(i), reg);
110 * Configure Tx descriptor plane (recycle mode; WSP) and
113 reg = TXGBE_ARBTXCTL_WSP | TXGBE_ARBTXCTL_RRM;
114 wr32(hw, TXGBE_ARBTXCTL, reg);
120 * txgbe_dcb_config_tx_data_arbiter_raptor - Config Tx Data arbiter
121 * @hw: pointer to hardware structure
122 * @refill: refill credits index by traffic class
123 * @max: max credits index by traffic class
124 * @bwg_id: bandwidth grouping indexed by traffic class
125 * @tsa: transmission selection algorithm indexed by traffic class
126 * @map: priority to tc assignments indexed by priority
128 * Configure Tx Packet Arbiter and credits for each traffic class.
130 s32 txgbe_dcb_config_tx_data_arbiter_raptor(struct txgbe_hw *hw, u16 *refill,
131 u16 *max, u8 *bwg_id, u8 *tsa,
138 * Disable the arbiter before changing parameters
139 * (always enable recycle mode; SP; arb delay)
141 reg = TXGBE_PARBTXCTL_SP |
142 TXGBE_PARBTXCTL_RECYC |
144 wr32(hw, TXGBE_PARBTXCTL, reg);
147 * map all UPs to TCs. up_to_tc_bitmap for each TC has corresponding
148 * bits sets for the UPs that needs to be mappped to that TC.
149 * e.g if priorities 6 and 7 are to be mapped to a TC then the
150 * up_to_tc_bitmap value for that TC will be 11000000 in binary.
153 for (i = 0; i < TXGBE_DCB_UP_MAX; i++)
154 reg |= TXGBE_DCBUP2TC_MAP(i, map[i]);
156 wr32(hw, TXGBE_PBRXUP2TC, reg);
158 /* Configure traffic class credits and priority */
159 for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
160 reg = TXGBE_PARBTXCFG_CRQ(refill[i]) |
161 TXGBE_PARBTXCFG_MCL(max[i]) |
162 TXGBE_PARBTXCFG_BWG(bwg_id[i]);
164 if (tsa[i] == txgbe_dcb_tsa_group_strict_cee)
165 reg |= TXGBE_PARBTXCFG_GSP;
167 if (tsa[i] == txgbe_dcb_tsa_strict)
168 reg |= TXGBE_PARBTXCFG_LSP;
170 wr32(hw, TXGBE_PARBTXCFG(i), reg);
174 * Configure Tx packet plane (recycle mode; SP; arb delay) and
177 reg = TXGBE_PARBTXCTL_SP | TXGBE_PARBTXCTL_RECYC;
178 wr32(hw, TXGBE_PARBTXCTL, reg);
184 * txgbe_dcb_config_tc_stats_raptor - Config traffic class statistics
185 * @hw: pointer to hardware structure
186 * @dcb_config: pointer to txgbe_dcb_config structure
188 * Configure queue statistics registers, all queues belonging to same traffic
189 * class uses a single set of queue statistics counters.
191 s32 txgbe_dcb_config_tc_stats_raptor(struct txgbe_hw *hw,
192 struct txgbe_dcb_config *dcb_config)
195 bool vt_mode = false;
197 UNREFERENCED_PARAMETER(hw);
199 if (dcb_config != NULL) {
200 tc_count = dcb_config->num_tcs.pg_tcs;
201 vt_mode = dcb_config->vt_mode;
204 if (!((tc_count == 8 && !vt_mode) || tc_count == 4))
205 return TXGBE_ERR_PARAM;