xref: /linux/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
151dce24bSJeff Kirsher // SPDX-License-Identifier: GPL-2.0
251dce24bSJeff Kirsher /* Copyright(c) 1999 - 2018 Intel Corporation. */
3dee1ad47SJeff Kirsher 
4dee1ad47SJeff Kirsher #include "ixgbe.h"
5dee1ad47SJeff Kirsher #include "ixgbe_type.h"
6dee1ad47SJeff Kirsher #include "ixgbe_dcb.h"
7dee1ad47SJeff Kirsher #include "ixgbe_dcb_82599.h"
8dee1ad47SJeff Kirsher 
9dee1ad47SJeff Kirsher /**
10dee1ad47SJeff Kirsher  * ixgbe_dcb_config_rx_arbiter_82599 - Config Rx Data arbiter
11dee1ad47SJeff Kirsher  * @hw: pointer to hardware structure
12dee1ad47SJeff Kirsher  * @refill: refill credits index by traffic class
13dee1ad47SJeff Kirsher  * @max: max credits index by traffic class
14dee1ad47SJeff Kirsher  * @bwg_id: bandwidth grouping indexed by traffic class
15dee1ad47SJeff Kirsher  * @prio_type: priority type indexed by traffic class
165ba643c6STony Nguyen  * @prio_tc: priority to tc assignments indexed by priority
17dee1ad47SJeff Kirsher  *
18dee1ad47SJeff Kirsher  * Configure Rx Packet Arbiter and credits for each traffic class.
19dee1ad47SJeff Kirsher  */
ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw * hw,u16 * refill,u16 * max,u8 * bwg_id,u8 * prio_type,u8 * prio_tc)20*8f76c0f4SJedrzej Jagielski int ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,
21dee1ad47SJeff Kirsher 				      u16 *refill,
22dee1ad47SJeff Kirsher 				      u16 *max,
23dee1ad47SJeff Kirsher 				      u8 *bwg_id,
24dee1ad47SJeff Kirsher 				      u8 *prio_type,
25dee1ad47SJeff Kirsher 				      u8 *prio_tc)
26dee1ad47SJeff Kirsher {
27dee1ad47SJeff Kirsher 	u32    reg           = 0;
28dee1ad47SJeff Kirsher 	u32    credit_refill = 0;
29dee1ad47SJeff Kirsher 	u32    credit_max    = 0;
30dee1ad47SJeff Kirsher 	u8     i             = 0;
31dee1ad47SJeff Kirsher 
32dee1ad47SJeff Kirsher 	/*
33dee1ad47SJeff Kirsher 	 * Disable the arbiter before changing parameters
34dee1ad47SJeff Kirsher 	 * (always enable recycle mode; WSP)
35dee1ad47SJeff Kirsher 	 */
36dee1ad47SJeff Kirsher 	reg = IXGBE_RTRPCS_RRM | IXGBE_RTRPCS_RAC | IXGBE_RTRPCS_ARBDIS;
37dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, reg);
38dee1ad47SJeff Kirsher 
3932701dc2SJohn Fastabend 	/* Map all traffic classes to their UP */
40dee1ad47SJeff Kirsher 	reg = 0;
4132701dc2SJohn Fastabend 	for (i = 0; i < MAX_USER_PRIORITY; i++)
42dee1ad47SJeff Kirsher 		reg |= (prio_tc[i] << (i * IXGBE_RTRUP2TC_UP_SHIFT));
43dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTRUP2TC, reg);
44dee1ad47SJeff Kirsher 
45dee1ad47SJeff Kirsher 	/* Configure traffic class credits and priority */
46dee1ad47SJeff Kirsher 	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
47dee1ad47SJeff Kirsher 		credit_refill = refill[i];
48dee1ad47SJeff Kirsher 		credit_max    = max[i];
49dee1ad47SJeff Kirsher 		reg = credit_refill | (credit_max << IXGBE_RTRPT4C_MCL_SHIFT);
50dee1ad47SJeff Kirsher 
51dee1ad47SJeff Kirsher 		reg |= (u32)(bwg_id[i]) << IXGBE_RTRPT4C_BWG_SHIFT;
52dee1ad47SJeff Kirsher 
53dee1ad47SJeff Kirsher 		if (prio_type[i] == prio_link)
54dee1ad47SJeff Kirsher 			reg |= IXGBE_RTRPT4C_LSP;
55dee1ad47SJeff Kirsher 
56dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_RTRPT4C(i), reg);
57dee1ad47SJeff Kirsher 	}
58dee1ad47SJeff Kirsher 
59dee1ad47SJeff Kirsher 	/*
60dee1ad47SJeff Kirsher 	 * Configure Rx packet plane (recycle mode; WSP) and
61dee1ad47SJeff Kirsher 	 * enable arbiter
62dee1ad47SJeff Kirsher 	 */
63dee1ad47SJeff Kirsher 	reg = IXGBE_RTRPCS_RRM | IXGBE_RTRPCS_RAC;
64dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTRPCS, reg);
65dee1ad47SJeff Kirsher 
66dee1ad47SJeff Kirsher 	return 0;
67dee1ad47SJeff Kirsher }
68dee1ad47SJeff Kirsher 
69dee1ad47SJeff Kirsher /**
70dee1ad47SJeff Kirsher  * ixgbe_dcb_config_tx_desc_arbiter_82599 - Config Tx Desc. arbiter
71dee1ad47SJeff Kirsher  * @hw: pointer to hardware structure
72dee1ad47SJeff Kirsher  * @refill: refill credits index by traffic class
73dee1ad47SJeff Kirsher  * @max: max credits index by traffic class
74dee1ad47SJeff Kirsher  * @bwg_id: bandwidth grouping indexed by traffic class
75dee1ad47SJeff Kirsher  * @prio_type: priority type indexed by traffic class
76dee1ad47SJeff Kirsher  *
77dee1ad47SJeff Kirsher  * Configure Tx Descriptor Arbiter and credits for each traffic class.
78dee1ad47SJeff Kirsher  */
ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw * hw,u16 * refill,u16 * max,u8 * bwg_id,u8 * prio_type)79*8f76c0f4SJedrzej Jagielski int ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,
80dee1ad47SJeff Kirsher 					   u16 *refill,
81dee1ad47SJeff Kirsher 					   u16 *max,
82dee1ad47SJeff Kirsher 					   u8 *bwg_id,
83dee1ad47SJeff Kirsher 					   u8 *prio_type)
84dee1ad47SJeff Kirsher {
85dee1ad47SJeff Kirsher 	u32    reg, max_credits;
86dee1ad47SJeff Kirsher 	u8     i;
87dee1ad47SJeff Kirsher 
88dee1ad47SJeff Kirsher 	/* Clear the per-Tx queue credits; we use per-TC instead */
89dee1ad47SJeff Kirsher 	for (i = 0; i < 128; i++) {
90dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, i);
91dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_RTTDT1C, 0);
92dee1ad47SJeff Kirsher 	}
93dee1ad47SJeff Kirsher 
94dee1ad47SJeff Kirsher 	/* Configure traffic class credits and priority */
95dee1ad47SJeff Kirsher 	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
96dee1ad47SJeff Kirsher 		max_credits = max[i];
97dee1ad47SJeff Kirsher 		reg = max_credits << IXGBE_RTTDT2C_MCL_SHIFT;
98dee1ad47SJeff Kirsher 		reg |= refill[i];
99dee1ad47SJeff Kirsher 		reg |= (u32)(bwg_id[i]) << IXGBE_RTTDT2C_BWG_SHIFT;
100dee1ad47SJeff Kirsher 
101dee1ad47SJeff Kirsher 		if (prio_type[i] == prio_group)
102dee1ad47SJeff Kirsher 			reg |= IXGBE_RTTDT2C_GSP;
103dee1ad47SJeff Kirsher 
104dee1ad47SJeff Kirsher 		if (prio_type[i] == prio_link)
105dee1ad47SJeff Kirsher 			reg |= IXGBE_RTTDT2C_LSP;
106dee1ad47SJeff Kirsher 
107dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_RTTDT2C(i), reg);
108dee1ad47SJeff Kirsher 	}
109dee1ad47SJeff Kirsher 
110dee1ad47SJeff Kirsher 	/*
111dee1ad47SJeff Kirsher 	 * Configure Tx descriptor plane (recycle mode; WSP) and
112dee1ad47SJeff Kirsher 	 * enable arbiter
113dee1ad47SJeff Kirsher 	 */
114dee1ad47SJeff Kirsher 	reg = IXGBE_RTTDCS_TDPAC | IXGBE_RTTDCS_TDRM;
115dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTTDCS, reg);
116dee1ad47SJeff Kirsher 
117dee1ad47SJeff Kirsher 	return 0;
118dee1ad47SJeff Kirsher }
119dee1ad47SJeff Kirsher 
120dee1ad47SJeff Kirsher /**
121dee1ad47SJeff Kirsher  * ixgbe_dcb_config_tx_data_arbiter_82599 - Config Tx Data arbiter
122dee1ad47SJeff Kirsher  * @hw: pointer to hardware structure
123dee1ad47SJeff Kirsher  * @refill: refill credits index by traffic class
124dee1ad47SJeff Kirsher  * @max: max credits index by traffic class
125dee1ad47SJeff Kirsher  * @bwg_id: bandwidth grouping indexed by traffic class
126dee1ad47SJeff Kirsher  * @prio_type: priority type indexed by traffic class
1275ba643c6STony Nguyen  * @prio_tc: priority to tc assignments indexed by priority
128dee1ad47SJeff Kirsher  *
129dee1ad47SJeff Kirsher  * Configure Tx Packet Arbiter and credits for each traffic class.
130dee1ad47SJeff Kirsher  */
ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw * hw,u16 * refill,u16 * max,u8 * bwg_id,u8 * prio_type,u8 * prio_tc)131*8f76c0f4SJedrzej Jagielski int ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,
132dee1ad47SJeff Kirsher 					   u16 *refill,
133dee1ad47SJeff Kirsher 					   u16 *max,
134dee1ad47SJeff Kirsher 					   u8 *bwg_id,
135dee1ad47SJeff Kirsher 					   u8 *prio_type,
136dee1ad47SJeff Kirsher 					   u8 *prio_tc)
137dee1ad47SJeff Kirsher {
138dee1ad47SJeff Kirsher 	u32 reg;
139dee1ad47SJeff Kirsher 	u8 i;
140dee1ad47SJeff Kirsher 
141dee1ad47SJeff Kirsher 	/*
142dee1ad47SJeff Kirsher 	 * Disable the arbiter before changing parameters
143dee1ad47SJeff Kirsher 	 * (always enable recycle mode; SP; arb delay)
144dee1ad47SJeff Kirsher 	 */
145dee1ad47SJeff Kirsher 	reg = IXGBE_RTTPCS_TPPAC | IXGBE_RTTPCS_TPRM |
146dee1ad47SJeff Kirsher 	      (IXGBE_RTTPCS_ARBD_DCB << IXGBE_RTTPCS_ARBD_SHIFT) |
147dee1ad47SJeff Kirsher 	      IXGBE_RTTPCS_ARBDIS;
148dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTTPCS, reg);
149dee1ad47SJeff Kirsher 
15032701dc2SJohn Fastabend 	/* Map all traffic classes to their UP */
151dee1ad47SJeff Kirsher 	reg = 0;
15232701dc2SJohn Fastabend 	for (i = 0; i < MAX_USER_PRIORITY; i++)
153dee1ad47SJeff Kirsher 		reg |= (prio_tc[i] << (i * IXGBE_RTTUP2TC_UP_SHIFT));
154dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTTUP2TC, reg);
155dee1ad47SJeff Kirsher 
156dee1ad47SJeff Kirsher 	/* Configure traffic class credits and priority */
157dee1ad47SJeff Kirsher 	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
158dee1ad47SJeff Kirsher 		reg = refill[i];
159dee1ad47SJeff Kirsher 		reg |= (u32)(max[i]) << IXGBE_RTTPT2C_MCL_SHIFT;
160dee1ad47SJeff Kirsher 		reg |= (u32)(bwg_id[i]) << IXGBE_RTTPT2C_BWG_SHIFT;
161dee1ad47SJeff Kirsher 
162dee1ad47SJeff Kirsher 		if (prio_type[i] == prio_group)
163dee1ad47SJeff Kirsher 			reg |= IXGBE_RTTPT2C_GSP;
164dee1ad47SJeff Kirsher 
165dee1ad47SJeff Kirsher 		if (prio_type[i] == prio_link)
166dee1ad47SJeff Kirsher 			reg |= IXGBE_RTTPT2C_LSP;
167dee1ad47SJeff Kirsher 
168dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_RTTPT2C(i), reg);
169dee1ad47SJeff Kirsher 	}
170dee1ad47SJeff Kirsher 
171dee1ad47SJeff Kirsher 	/*
172dee1ad47SJeff Kirsher 	 * Configure Tx packet plane (recycle mode; SP; arb delay) and
173dee1ad47SJeff Kirsher 	 * enable arbiter
174dee1ad47SJeff Kirsher 	 */
175dee1ad47SJeff Kirsher 	reg = IXGBE_RTTPCS_TPPAC | IXGBE_RTTPCS_TPRM |
176dee1ad47SJeff Kirsher 	      (IXGBE_RTTPCS_ARBD_DCB << IXGBE_RTTPCS_ARBD_SHIFT);
177dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_RTTPCS, reg);
178dee1ad47SJeff Kirsher 
179dee1ad47SJeff Kirsher 	return 0;
180dee1ad47SJeff Kirsher }
181dee1ad47SJeff Kirsher 
182dee1ad47SJeff Kirsher /**
183dee1ad47SJeff Kirsher  * ixgbe_dcb_config_pfc_82599 - Configure priority flow control
184dee1ad47SJeff Kirsher  * @hw: pointer to hardware structure
185dee1ad47SJeff Kirsher  * @pfc_en: enabled pfc bitmask
18632701dc2SJohn Fastabend  * @prio_tc: priority to tc assignments indexed by priority
187dee1ad47SJeff Kirsher  *
188dee1ad47SJeff Kirsher  * Configure Priority Flow Control (PFC) for each traffic class.
189dee1ad47SJeff Kirsher  */
ixgbe_dcb_config_pfc_82599(struct ixgbe_hw * hw,u8 pfc_en,u8 * prio_tc)190*8f76c0f4SJedrzej Jagielski int ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc)
191dee1ad47SJeff Kirsher {
192943561d3SAlexander Duyck 	u32 i, j, fcrtl, reg;
19332701dc2SJohn Fastabend 	u8 max_tc = 0;
19432701dc2SJohn Fastabend 
195943561d3SAlexander Duyck 	/* Enable Transmit Priority Flow Control */
196943561d3SAlexander Duyck 	IXGBE_WRITE_REG(hw, IXGBE_FCCFG, IXGBE_FCCFG_TFCE_PRIORITY);
197943561d3SAlexander Duyck 
198943561d3SAlexander Duyck 	/* Enable Receive Priority Flow Control */
199943561d3SAlexander Duyck 	reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
200943561d3SAlexander Duyck 	reg |= IXGBE_MFLCN_DPF;
201943561d3SAlexander Duyck 
202943561d3SAlexander Duyck 	/*
203cb78cf12SVasu Dev 	 * X540 & X550 supports per TC Rx priority flow control.
204cb78cf12SVasu Dev 	 * So clear all TCs and only enable those that should be
205943561d3SAlexander Duyck 	 * enabled.
206943561d3SAlexander Duyck 	 */
207943561d3SAlexander Duyck 	reg &= ~(IXGBE_MFLCN_RPFCE_MASK | IXGBE_MFLCN_RFCE);
208943561d3SAlexander Duyck 
209cb78cf12SVasu Dev 	if (hw->mac.type >= ixgbe_mac_X540)
210943561d3SAlexander Duyck 		reg |= pfc_en << IXGBE_MFLCN_RPFCE_SHIFT;
211943561d3SAlexander Duyck 
212943561d3SAlexander Duyck 	if (pfc_en)
213943561d3SAlexander Duyck 		reg |= IXGBE_MFLCN_RPFCE;
214943561d3SAlexander Duyck 
215943561d3SAlexander Duyck 	IXGBE_WRITE_REG(hw, IXGBE_MFLCN, reg);
216943561d3SAlexander Duyck 
217943561d3SAlexander Duyck 	for (i = 0; i < MAX_USER_PRIORITY; i++) {
21832701dc2SJohn Fastabend 		if (prio_tc[i] > max_tc)
21932701dc2SJohn Fastabend 			max_tc = prio_tc[i];
220943561d3SAlexander Duyck 	}
221943561d3SAlexander Duyck 
222dee1ad47SJeff Kirsher 
223dee1ad47SJeff Kirsher 	/* Configure PFC Tx thresholds per TC */
224943561d3SAlexander Duyck 	for (i = 0; i <= max_tc; i++) {
22532701dc2SJohn Fastabend 		int enabled = 0;
22632701dc2SJohn Fastabend 
22732701dc2SJohn Fastabend 		for (j = 0; j < MAX_USER_PRIORITY; j++) {
228b4f47a48SJacob Keller 			if ((prio_tc[j] == i) && (pfc_en & BIT(j))) {
22932701dc2SJohn Fastabend 				enabled = 1;
23032701dc2SJohn Fastabend 				break;
23132701dc2SJohn Fastabend 			}
23232701dc2SJohn Fastabend 		}
233dee1ad47SJeff Kirsher 
234943561d3SAlexander Duyck 		if (enabled) {
235943561d3SAlexander Duyck 			reg = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
236e5776620SJacob Keller 			fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;
237943561d3SAlexander Duyck 			IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), fcrtl);
238943561d3SAlexander Duyck 		} else {
239bc1fc64fSMark Rustad 			/* In order to prevent Tx hangs when the internal Tx
240bc1fc64fSMark Rustad 			 * switch is enabled we must set the high water mark
241bc1fc64fSMark Rustad 			 * to the Rx packet buffer size - 24KB.  This allows
242bc1fc64fSMark Rustad 			 * the Tx switch to function even under heavy Rx
243bc1fc64fSMark Rustad 			 * workloads.
244bc1fc64fSMark Rustad 			 */
245bc1fc64fSMark Rustad 			reg = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 24576;
246943561d3SAlexander Duyck 			IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
247943561d3SAlexander Duyck 		}
248dee1ad47SJeff Kirsher 
249dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), reg);
250dee1ad47SJeff Kirsher 	}
251dee1ad47SJeff Kirsher 
252943561d3SAlexander Duyck 	for (; i < MAX_TRAFFIC_CLASS; i++) {
253943561d3SAlexander Duyck 		IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
254943561d3SAlexander Duyck 		IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), 0);
255943561d3SAlexander Duyck 	}
256943561d3SAlexander Duyck 
257dee1ad47SJeff Kirsher 	/* Configure pause time (2 TCs per register) */
258943561d3SAlexander Duyck 	reg = hw->fc.pause_time * 0x00010001;
259dee1ad47SJeff Kirsher 	for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
260dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
261dee1ad47SJeff Kirsher 
262dee1ad47SJeff Kirsher 	/* Configure flow control refresh threshold value */
263dee1ad47SJeff Kirsher 	IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
264dee1ad47SJeff Kirsher 
265dee1ad47SJeff Kirsher 	return 0;
266dee1ad47SJeff Kirsher }
267dee1ad47SJeff Kirsher 
268dee1ad47SJeff Kirsher /**
269dee1ad47SJeff Kirsher  * ixgbe_dcb_config_tc_stats_82599 - Config traffic class statistics
270dee1ad47SJeff Kirsher  * @hw: pointer to hardware structure
271dee1ad47SJeff Kirsher  *
272dee1ad47SJeff Kirsher  * Configure queue statistics registers, all queues belonging to same traffic
273dee1ad47SJeff Kirsher  * class uses a single set of queue statistics counters.
274dee1ad47SJeff Kirsher  */
ixgbe_dcb_config_tc_stats_82599(struct ixgbe_hw * hw)275*8f76c0f4SJedrzej Jagielski static int ixgbe_dcb_config_tc_stats_82599(struct ixgbe_hw *hw)
276dee1ad47SJeff Kirsher {
277dee1ad47SJeff Kirsher 	u32 reg = 0;
278dee1ad47SJeff Kirsher 	u8  i   = 0;
279dee1ad47SJeff Kirsher 
280dee1ad47SJeff Kirsher 	/*
281dee1ad47SJeff Kirsher 	 * Receive Queues stats setting
282dee1ad47SJeff Kirsher 	 * 32 RQSMR registers, each configuring 4 queues.
283dee1ad47SJeff Kirsher 	 * Set all 16 queues of each TC to the same stat
284dee1ad47SJeff Kirsher 	 * with TC 'n' going to stat 'n'.
285dee1ad47SJeff Kirsher 	 */
286dee1ad47SJeff Kirsher 	for (i = 0; i < 32; i++) {
287dee1ad47SJeff Kirsher 		reg = 0x01010101 * (i / 4);
288dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), reg);
289dee1ad47SJeff Kirsher 	}
290dee1ad47SJeff Kirsher 	/*
291dee1ad47SJeff Kirsher 	 * Transmit Queues stats setting
292dee1ad47SJeff Kirsher 	 * 32 TQSM registers, each controlling 4 queues.
293dee1ad47SJeff Kirsher 	 * Set all queues of each TC to the same stat
294dee1ad47SJeff Kirsher 	 * with TC 'n' going to stat 'n'.
295dee1ad47SJeff Kirsher 	 * Tx queues are allocated non-uniformly to TCs:
296dee1ad47SJeff Kirsher 	 * 32, 32, 16, 16, 8, 8, 8, 8.
297dee1ad47SJeff Kirsher 	 */
298dee1ad47SJeff Kirsher 	for (i = 0; i < 32; i++) {
299dee1ad47SJeff Kirsher 		if (i < 8)
300dee1ad47SJeff Kirsher 			reg = 0x00000000;
301dee1ad47SJeff Kirsher 		else if (i < 16)
302dee1ad47SJeff Kirsher 			reg = 0x01010101;
303dee1ad47SJeff Kirsher 		else if (i < 20)
304dee1ad47SJeff Kirsher 			reg = 0x02020202;
305dee1ad47SJeff Kirsher 		else if (i < 24)
306dee1ad47SJeff Kirsher 			reg = 0x03030303;
307dee1ad47SJeff Kirsher 		else if (i < 26)
308dee1ad47SJeff Kirsher 			reg = 0x04040404;
309dee1ad47SJeff Kirsher 		else if (i < 28)
310dee1ad47SJeff Kirsher 			reg = 0x05050505;
311dee1ad47SJeff Kirsher 		else if (i < 30)
312dee1ad47SJeff Kirsher 			reg = 0x06060606;
313dee1ad47SJeff Kirsher 		else
314dee1ad47SJeff Kirsher 			reg = 0x07070707;
315dee1ad47SJeff Kirsher 		IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), reg);
316dee1ad47SJeff Kirsher 	}
317dee1ad47SJeff Kirsher 
318dee1ad47SJeff Kirsher 	return 0;
319dee1ad47SJeff Kirsher }
320dee1ad47SJeff Kirsher 
321dee1ad47SJeff Kirsher /**
322dee1ad47SJeff Kirsher  * ixgbe_dcb_hw_config_82599 - Configure and enable DCB
323dee1ad47SJeff Kirsher  * @hw: pointer to hardware structure
3245ba643c6STony Nguyen  * @pfc_en: enabled pfc bitmask
325dee1ad47SJeff Kirsher  * @refill: refill credits index by traffic class
326dee1ad47SJeff Kirsher  * @max: max credits index by traffic class
327dee1ad47SJeff Kirsher  * @bwg_id: bandwidth grouping indexed by traffic class
328dee1ad47SJeff Kirsher  * @prio_type: priority type indexed by traffic class
3295ba643c6STony Nguyen  * @prio_tc: priority to tc assignments indexed by priority
330dee1ad47SJeff Kirsher  *
331dee1ad47SJeff Kirsher  * Configure dcb settings and enable dcb mode.
332dee1ad47SJeff Kirsher  */
ixgbe_dcb_hw_config_82599(struct ixgbe_hw * hw,u8 pfc_en,u16 * refill,u16 * max,u8 * bwg_id,u8 * prio_type,u8 * prio_tc)333*8f76c0f4SJedrzej Jagielski int ixgbe_dcb_hw_config_82599(struct ixgbe_hw *hw, u8 pfc_en, u16 *refill,
334dee1ad47SJeff Kirsher 			      u16 *max, u8 *bwg_id, u8 *prio_type, u8 *prio_tc)
335dee1ad47SJeff Kirsher {
336dee1ad47SJeff Kirsher 	ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id,
337dee1ad47SJeff Kirsher 					  prio_type, prio_tc);
338dee1ad47SJeff Kirsher 	ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max,
339dee1ad47SJeff Kirsher 					       bwg_id, prio_type);
340dee1ad47SJeff Kirsher 	ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max,
341dee1ad47SJeff Kirsher 					       bwg_id, prio_type, prio_tc);
34232701dc2SJohn Fastabend 	ixgbe_dcb_config_pfc_82599(hw, pfc_en, prio_tc);
343dee1ad47SJeff Kirsher 	ixgbe_dcb_config_tc_stats_82599(hw);
344dee1ad47SJeff Kirsher 
345dee1ad47SJeff Kirsher 	return 0;
346dee1ad47SJeff Kirsher }
347dee1ad47SJeff Kirsher 
348