162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#include "ixgbe.h"
562306a36Sopenharmony_ci#include "ixgbe_type.h"
662306a36Sopenharmony_ci#include "ixgbe_dcb.h"
762306a36Sopenharmony_ci#include "ixgbe_dcb_82598.h"
862306a36Sopenharmony_ci#include "ixgbe_dcb_82599.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/**
1162306a36Sopenharmony_ci * ixgbe_ieee_credits - This calculates the ieee traffic class
1262306a36Sopenharmony_ci * credits from the configured bandwidth percentages. Credits
1362306a36Sopenharmony_ci * are the smallest unit programmable into the underlying
1462306a36Sopenharmony_ci * hardware. The IEEE 802.1Qaz specification do not use bandwidth
1562306a36Sopenharmony_ci * groups so this is much simplified from the CEE case.
1662306a36Sopenharmony_ci * @bw: bandwidth index by traffic class
1762306a36Sopenharmony_ci * @refill: refill credits index by traffic class
1862306a36Sopenharmony_ci * @max: max credits by traffic class
1962306a36Sopenharmony_ci * @max_frame: maximum frame size
2062306a36Sopenharmony_ci */
2162306a36Sopenharmony_cistatic s32 ixgbe_ieee_credits(__u8 *bw, __u16 *refill,
2262306a36Sopenharmony_ci			      __u16 *max, int max_frame)
2362306a36Sopenharmony_ci{
2462306a36Sopenharmony_ci	int min_percent = 100;
2562306a36Sopenharmony_ci	int min_credit, multiplier;
2662306a36Sopenharmony_ci	int i;
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) /
2962306a36Sopenharmony_ci			DCB_CREDIT_QUANTUM;
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
3262306a36Sopenharmony_ci		if (bw[i] < min_percent && bw[i])
3362306a36Sopenharmony_ci			min_percent = bw[i];
3462306a36Sopenharmony_ci	}
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci	multiplier = (min_credit / min_percent) + 1;
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci	/* Find out the hw credits for each TC */
3962306a36Sopenharmony_ci	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
4062306a36Sopenharmony_ci		int val = min(bw[i] * multiplier, MAX_CREDIT_REFILL);
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci		if (val < min_credit)
4362306a36Sopenharmony_ci			val = min_credit;
4462306a36Sopenharmony_ci		refill[i] = val;
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci		max[i] = bw[i] ? (bw[i] * MAX_CREDIT)/100 : min_credit;
4762306a36Sopenharmony_ci	}
4862306a36Sopenharmony_ci	return 0;
4962306a36Sopenharmony_ci}
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci/**
5262306a36Sopenharmony_ci * ixgbe_dcb_calculate_tc_credits - Calculates traffic class credits
5362306a36Sopenharmony_ci * @hw: pointer to hardware structure
5462306a36Sopenharmony_ci * @dcb_config: Struct containing DCB settings
5562306a36Sopenharmony_ci * @max_frame: Maximum frame size
5662306a36Sopenharmony_ci * @direction: Configuring either Tx or Rx
5762306a36Sopenharmony_ci *
5862306a36Sopenharmony_ci * This function calculates the credits allocated to each traffic class.
5962306a36Sopenharmony_ci * It should be called only after the rules are checked by
6062306a36Sopenharmony_ci * ixgbe_dcb_check_config().
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_cis32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw,
6362306a36Sopenharmony_ci				   struct ixgbe_dcb_config *dcb_config,
6462306a36Sopenharmony_ci				   int max_frame, u8 direction)
6562306a36Sopenharmony_ci{
6662306a36Sopenharmony_ci	struct tc_bw_alloc *p;
6762306a36Sopenharmony_ci	int min_credit;
6862306a36Sopenharmony_ci	int min_multiplier;
6962306a36Sopenharmony_ci	int min_percent = 100;
7062306a36Sopenharmony_ci	/* Initialization values default for Tx settings */
7162306a36Sopenharmony_ci	u32 credit_refill       = 0;
7262306a36Sopenharmony_ci	u32 credit_max          = 0;
7362306a36Sopenharmony_ci	u16 link_percentage     = 0;
7462306a36Sopenharmony_ci	u8  bw_percent          = 0;
7562306a36Sopenharmony_ci	u8  i;
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	if (!dcb_config)
7862306a36Sopenharmony_ci		return DCB_ERR_CONFIG;
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci	min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) /
8162306a36Sopenharmony_ci			DCB_CREDIT_QUANTUM;
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci	/* Find smallest link percentage */
8462306a36Sopenharmony_ci	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
8562306a36Sopenharmony_ci		p = &dcb_config->tc_config[i].path[direction];
8662306a36Sopenharmony_ci		bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
8762306a36Sopenharmony_ci		link_percentage = p->bwg_percent;
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci		link_percentage = (link_percentage * bw_percent) / 100;
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci		if (link_percentage && link_percentage < min_percent)
9262306a36Sopenharmony_ci			min_percent = link_percentage;
9362306a36Sopenharmony_ci	}
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci	/*
9662306a36Sopenharmony_ci	 * The ratio between traffic classes will control the bandwidth
9762306a36Sopenharmony_ci	 * percentages seen on the wire. To calculate this ratio we use
9862306a36Sopenharmony_ci	 * a multiplier. It is required that the refill credits must be
9962306a36Sopenharmony_ci	 * larger than the max frame size so here we find the smallest
10062306a36Sopenharmony_ci	 * multiplier that will allow all bandwidth percentages to be
10162306a36Sopenharmony_ci	 * greater than the max frame size.
10262306a36Sopenharmony_ci	 */
10362306a36Sopenharmony_ci	min_multiplier = (min_credit / min_percent) + 1;
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci	/* Find out the link percentage for each TC first */
10662306a36Sopenharmony_ci	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
10762306a36Sopenharmony_ci		p = &dcb_config->tc_config[i].path[direction];
10862306a36Sopenharmony_ci		bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci		link_percentage = p->bwg_percent;
11162306a36Sopenharmony_ci		/* Must be careful of integer division for very small nums */
11262306a36Sopenharmony_ci		link_percentage = (link_percentage * bw_percent) / 100;
11362306a36Sopenharmony_ci		if (p->bwg_percent > 0 && link_percentage == 0)
11462306a36Sopenharmony_ci			link_percentage = 1;
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci		/* Save link_percentage for reference */
11762306a36Sopenharmony_ci		p->link_percent = (u8)link_percentage;
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci		/* Calculate credit refill ratio using multiplier */
12062306a36Sopenharmony_ci		credit_refill = min(link_percentage * min_multiplier,
12162306a36Sopenharmony_ci				    MAX_CREDIT_REFILL);
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci		/* Refill at least minimum credit */
12462306a36Sopenharmony_ci		if (credit_refill < min_credit)
12562306a36Sopenharmony_ci			credit_refill = min_credit;
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci		p->data_credits_refill = (u16)credit_refill;
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci		/* Calculate maximum credit for the TC */
13062306a36Sopenharmony_ci		credit_max = (link_percentage * MAX_CREDIT) / 100;
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci		/*
13362306a36Sopenharmony_ci		 * Adjustment based on rule checking, if the percentage
13462306a36Sopenharmony_ci		 * of a TC is too small, the maximum credit may not be
13562306a36Sopenharmony_ci		 * enough to send out a jumbo frame in data plane arbitration.
13662306a36Sopenharmony_ci		 */
13762306a36Sopenharmony_ci		if (credit_max < min_credit)
13862306a36Sopenharmony_ci			credit_max = min_credit;
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci		if (direction == DCB_TX_CONFIG) {
14162306a36Sopenharmony_ci			/*
14262306a36Sopenharmony_ci			 * Adjustment based on rule checking, if the
14362306a36Sopenharmony_ci			 * percentage of a TC is too small, the maximum
14462306a36Sopenharmony_ci			 * credit may not be enough to send out a TSO
14562306a36Sopenharmony_ci			 * packet in descriptor plane arbitration.
14662306a36Sopenharmony_ci			 */
14762306a36Sopenharmony_ci			if ((hw->mac.type == ixgbe_mac_82598EB) &&
14862306a36Sopenharmony_ci			    credit_max &&
14962306a36Sopenharmony_ci			    (credit_max < MINIMUM_CREDIT_FOR_TSO))
15062306a36Sopenharmony_ci				credit_max = MINIMUM_CREDIT_FOR_TSO;
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci			dcb_config->tc_config[i].desc_credits_max =
15362306a36Sopenharmony_ci				(u16)credit_max;
15462306a36Sopenharmony_ci		}
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci		p->data_credits_max = (u16)credit_max;
15762306a36Sopenharmony_ci	}
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci	return 0;
16062306a36Sopenharmony_ci}
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_civoid ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en)
16362306a36Sopenharmony_ci{
16462306a36Sopenharmony_ci	struct tc_configuration *tc_config = &cfg->tc_config[0];
16562306a36Sopenharmony_ci	int tc;
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci	for (*pfc_en = 0, tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) {
16862306a36Sopenharmony_ci		if (tc_config[tc].dcb_pfc != pfc_disabled)
16962306a36Sopenharmony_ci			*pfc_en |= BIT(tc);
17062306a36Sopenharmony_ci	}
17162306a36Sopenharmony_ci}
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_civoid ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *cfg, int direction,
17462306a36Sopenharmony_ci			     u16 *refill)
17562306a36Sopenharmony_ci{
17662306a36Sopenharmony_ci	struct tc_configuration *tc_config = &cfg->tc_config[0];
17762306a36Sopenharmony_ci	int tc;
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
18062306a36Sopenharmony_ci		refill[tc] = tc_config[tc].path[direction].data_credits_refill;
18162306a36Sopenharmony_ci}
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_civoid ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *cfg, u16 *max)
18462306a36Sopenharmony_ci{
18562306a36Sopenharmony_ci	struct tc_configuration *tc_config = &cfg->tc_config[0];
18662306a36Sopenharmony_ci	int tc;
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
18962306a36Sopenharmony_ci		max[tc] = tc_config[tc].desc_credits_max;
19062306a36Sopenharmony_ci}
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_civoid ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *cfg, int direction,
19362306a36Sopenharmony_ci			    u8 *bwgid)
19462306a36Sopenharmony_ci{
19562306a36Sopenharmony_ci	struct tc_configuration *tc_config = &cfg->tc_config[0];
19662306a36Sopenharmony_ci	int tc;
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
19962306a36Sopenharmony_ci		bwgid[tc] = tc_config[tc].path[direction].bwg_id;
20062306a36Sopenharmony_ci}
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_civoid ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *cfg, int direction,
20362306a36Sopenharmony_ci			    u8 *ptype)
20462306a36Sopenharmony_ci{
20562306a36Sopenharmony_ci	struct tc_configuration *tc_config = &cfg->tc_config[0];
20662306a36Sopenharmony_ci	int tc;
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
20962306a36Sopenharmony_ci		ptype[tc] = tc_config[tc].path[direction].prio_type;
21062306a36Sopenharmony_ci}
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ciu8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up)
21362306a36Sopenharmony_ci{
21462306a36Sopenharmony_ci	struct tc_configuration *tc_config = &cfg->tc_config[0];
21562306a36Sopenharmony_ci	u8 prio_mask = BIT(up);
21662306a36Sopenharmony_ci	u8 tc = cfg->num_tcs.pg_tcs;
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci	/* If tc is 0 then DCB is likely not enabled or supported */
21962306a36Sopenharmony_ci	if (!tc)
22062306a36Sopenharmony_ci		return 0;
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci	/*
22362306a36Sopenharmony_ci	 * Test from maximum TC to 1 and report the first match we find.  If
22462306a36Sopenharmony_ci	 * we find no match we can assume that the TC is 0 since the TC must
22562306a36Sopenharmony_ci	 * be set for all user priorities
22662306a36Sopenharmony_ci	 */
22762306a36Sopenharmony_ci	for (tc--; tc; tc--) {
22862306a36Sopenharmony_ci		if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap)
22962306a36Sopenharmony_ci			break;
23062306a36Sopenharmony_ci	}
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci	return tc;
23362306a36Sopenharmony_ci}
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_civoid ixgbe_dcb_unpack_map(struct ixgbe_dcb_config *cfg, int direction, u8 *map)
23662306a36Sopenharmony_ci{
23762306a36Sopenharmony_ci	u8 up;
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci	for (up = 0; up < MAX_USER_PRIORITY; up++)
24062306a36Sopenharmony_ci		map[up] = ixgbe_dcb_get_tc_from_up(cfg, direction, up);
24162306a36Sopenharmony_ci}
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/**
24462306a36Sopenharmony_ci * ixgbe_dcb_hw_config - Config and enable DCB
24562306a36Sopenharmony_ci * @hw: pointer to hardware structure
24662306a36Sopenharmony_ci * @dcb_config: pointer to ixgbe_dcb_config structure
24762306a36Sopenharmony_ci *
24862306a36Sopenharmony_ci * Configure dcb settings and enable dcb mode.
24962306a36Sopenharmony_ci */
25062306a36Sopenharmony_cis32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw,
25162306a36Sopenharmony_ci			struct ixgbe_dcb_config *dcb_config)
25262306a36Sopenharmony_ci{
25362306a36Sopenharmony_ci	u8 pfc_en;
25462306a36Sopenharmony_ci	u8 ptype[MAX_TRAFFIC_CLASS];
25562306a36Sopenharmony_ci	u8 bwgid[MAX_TRAFFIC_CLASS];
25662306a36Sopenharmony_ci	u8 prio_tc[MAX_TRAFFIC_CLASS];
25762306a36Sopenharmony_ci	u16 refill[MAX_TRAFFIC_CLASS];
25862306a36Sopenharmony_ci	u16 max[MAX_TRAFFIC_CLASS];
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci	/* Unpack CEE standard containers */
26162306a36Sopenharmony_ci	ixgbe_dcb_unpack_pfc(dcb_config, &pfc_en);
26262306a36Sopenharmony_ci	ixgbe_dcb_unpack_refill(dcb_config, DCB_TX_CONFIG, refill);
26362306a36Sopenharmony_ci	ixgbe_dcb_unpack_max(dcb_config, max);
26462306a36Sopenharmony_ci	ixgbe_dcb_unpack_bwgid(dcb_config, DCB_TX_CONFIG, bwgid);
26562306a36Sopenharmony_ci	ixgbe_dcb_unpack_prio(dcb_config, DCB_TX_CONFIG, ptype);
26662306a36Sopenharmony_ci	ixgbe_dcb_unpack_map(dcb_config, DCB_TX_CONFIG, prio_tc);
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci	switch (hw->mac.type) {
26962306a36Sopenharmony_ci	case ixgbe_mac_82598EB:
27062306a36Sopenharmony_ci		return ixgbe_dcb_hw_config_82598(hw, pfc_en, refill, max,
27162306a36Sopenharmony_ci						 bwgid, ptype);
27262306a36Sopenharmony_ci	case ixgbe_mac_82599EB:
27362306a36Sopenharmony_ci	case ixgbe_mac_X540:
27462306a36Sopenharmony_ci	case ixgbe_mac_X550:
27562306a36Sopenharmony_ci	case ixgbe_mac_X550EM_x:
27662306a36Sopenharmony_ci	case ixgbe_mac_x550em_a:
27762306a36Sopenharmony_ci		return ixgbe_dcb_hw_config_82599(hw, pfc_en, refill, max,
27862306a36Sopenharmony_ci						 bwgid, ptype, prio_tc);
27962306a36Sopenharmony_ci	default:
28062306a36Sopenharmony_ci		break;
28162306a36Sopenharmony_ci	}
28262306a36Sopenharmony_ci	return 0;
28362306a36Sopenharmony_ci}
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci/* Helper routines to abstract HW specifics from DCB netlink ops */
28662306a36Sopenharmony_cis32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc)
28762306a36Sopenharmony_ci{
28862306a36Sopenharmony_ci	switch (hw->mac.type) {
28962306a36Sopenharmony_ci	case ixgbe_mac_82598EB:
29062306a36Sopenharmony_ci		return ixgbe_dcb_config_pfc_82598(hw, pfc_en);
29162306a36Sopenharmony_ci	case ixgbe_mac_82599EB:
29262306a36Sopenharmony_ci	case ixgbe_mac_X540:
29362306a36Sopenharmony_ci	case ixgbe_mac_X550:
29462306a36Sopenharmony_ci	case ixgbe_mac_X550EM_x:
29562306a36Sopenharmony_ci	case ixgbe_mac_x550em_a:
29662306a36Sopenharmony_ci		return ixgbe_dcb_config_pfc_82599(hw, pfc_en, prio_tc);
29762306a36Sopenharmony_ci	default:
29862306a36Sopenharmony_ci		break;
29962306a36Sopenharmony_ci	}
30062306a36Sopenharmony_ci	return -EINVAL;
30162306a36Sopenharmony_ci}
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_cis32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max_frame)
30462306a36Sopenharmony_ci{
30562306a36Sopenharmony_ci	__u16 refill[IEEE_8021QAZ_MAX_TCS], max[IEEE_8021QAZ_MAX_TCS];
30662306a36Sopenharmony_ci	__u8 prio_type[IEEE_8021QAZ_MAX_TCS];
30762306a36Sopenharmony_ci	int i;
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci	/* naively give each TC a bwg to map onto CEE hardware */
31062306a36Sopenharmony_ci	__u8 bwg_id[IEEE_8021QAZ_MAX_TCS] = {0, 1, 2, 3, 4, 5, 6, 7};
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci	/* Map TSA onto CEE prio type */
31362306a36Sopenharmony_ci	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
31462306a36Sopenharmony_ci		switch (ets->tc_tsa[i]) {
31562306a36Sopenharmony_ci		case IEEE_8021QAZ_TSA_STRICT:
31662306a36Sopenharmony_ci			prio_type[i] = 2;
31762306a36Sopenharmony_ci			break;
31862306a36Sopenharmony_ci		case IEEE_8021QAZ_TSA_ETS:
31962306a36Sopenharmony_ci			prio_type[i] = 0;
32062306a36Sopenharmony_ci			break;
32162306a36Sopenharmony_ci		default:
32262306a36Sopenharmony_ci			/* Hardware only supports priority strict or
32362306a36Sopenharmony_ci			 * ETS transmission selection algorithms if
32462306a36Sopenharmony_ci			 * we receive some other value from dcbnl
32562306a36Sopenharmony_ci			 * throw an error
32662306a36Sopenharmony_ci			 */
32762306a36Sopenharmony_ci			return -EINVAL;
32862306a36Sopenharmony_ci		}
32962306a36Sopenharmony_ci	}
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci	ixgbe_ieee_credits(ets->tc_tx_bw, refill, max, max_frame);
33262306a36Sopenharmony_ci	return ixgbe_dcb_hw_ets_config(hw, refill, max,
33362306a36Sopenharmony_ci				       bwg_id, prio_type, ets->prio_tc);
33462306a36Sopenharmony_ci}
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_cis32 ixgbe_dcb_hw_ets_config(struct ixgbe_hw *hw,
33762306a36Sopenharmony_ci			    u16 *refill, u16 *max, u8 *bwg_id,
33862306a36Sopenharmony_ci			    u8 *prio_type, u8 *prio_tc)
33962306a36Sopenharmony_ci{
34062306a36Sopenharmony_ci	switch (hw->mac.type) {
34162306a36Sopenharmony_ci	case ixgbe_mac_82598EB:
34262306a36Sopenharmony_ci		ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max,
34362306a36Sopenharmony_ci							prio_type);
34462306a36Sopenharmony_ci		ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max,
34562306a36Sopenharmony_ci							     bwg_id, prio_type);
34662306a36Sopenharmony_ci		ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max,
34762306a36Sopenharmony_ci							     bwg_id, prio_type);
34862306a36Sopenharmony_ci		break;
34962306a36Sopenharmony_ci	case ixgbe_mac_82599EB:
35062306a36Sopenharmony_ci	case ixgbe_mac_X540:
35162306a36Sopenharmony_ci	case ixgbe_mac_X550:
35262306a36Sopenharmony_ci	case ixgbe_mac_X550EM_x:
35362306a36Sopenharmony_ci	case ixgbe_mac_x550em_a:
35462306a36Sopenharmony_ci		ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max,
35562306a36Sopenharmony_ci						  bwg_id, prio_type, prio_tc);
35662306a36Sopenharmony_ci		ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max,
35762306a36Sopenharmony_ci						       bwg_id, prio_type);
35862306a36Sopenharmony_ci		ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id,
35962306a36Sopenharmony_ci						       prio_type, prio_tc);
36062306a36Sopenharmony_ci		break;
36162306a36Sopenharmony_ci	default:
36262306a36Sopenharmony_ci		break;
36362306a36Sopenharmony_ci	}
36462306a36Sopenharmony_ci	return 0;
36562306a36Sopenharmony_ci}
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_cistatic void ixgbe_dcb_read_rtrup2tc_82599(struct ixgbe_hw *hw, u8 *map)
36862306a36Sopenharmony_ci{
36962306a36Sopenharmony_ci	u32 reg, i;
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci	reg = IXGBE_READ_REG(hw, IXGBE_RTRUP2TC);
37262306a36Sopenharmony_ci	for (i = 0; i < MAX_USER_PRIORITY; i++)
37362306a36Sopenharmony_ci		map[i] = IXGBE_RTRUP2TC_UP_MASK &
37462306a36Sopenharmony_ci			(reg >> (i * IXGBE_RTRUP2TC_UP_SHIFT));
37562306a36Sopenharmony_ci}
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_civoid ixgbe_dcb_read_rtrup2tc(struct ixgbe_hw *hw, u8 *map)
37862306a36Sopenharmony_ci{
37962306a36Sopenharmony_ci	switch (hw->mac.type) {
38062306a36Sopenharmony_ci	case ixgbe_mac_82599EB:
38162306a36Sopenharmony_ci	case ixgbe_mac_X540:
38262306a36Sopenharmony_ci	case ixgbe_mac_X550:
38362306a36Sopenharmony_ci	case ixgbe_mac_X550EM_x:
38462306a36Sopenharmony_ci	case ixgbe_mac_x550em_a:
38562306a36Sopenharmony_ci		ixgbe_dcb_read_rtrup2tc_82599(hw, map);
38662306a36Sopenharmony_ci		break;
38762306a36Sopenharmony_ci	default:
38862306a36Sopenharmony_ci		break;
38962306a36Sopenharmony_ci	}
39062306a36Sopenharmony_ci}
391