18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include "ixgbe.h" 58c2ecf20Sopenharmony_ci#include "ixgbe_type.h" 68c2ecf20Sopenharmony_ci#include "ixgbe_dcb.h" 78c2ecf20Sopenharmony_ci#include "ixgbe_dcb_82598.h" 88c2ecf20Sopenharmony_ci#include "ixgbe_dcb_82599.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/** 118c2ecf20Sopenharmony_ci * ixgbe_ieee_credits - This calculates the ieee traffic class 128c2ecf20Sopenharmony_ci * credits from the configured bandwidth percentages. Credits 138c2ecf20Sopenharmony_ci * are the smallest unit programmable into the underlying 148c2ecf20Sopenharmony_ci * hardware. The IEEE 802.1Qaz specification do not use bandwidth 158c2ecf20Sopenharmony_ci * groups so this is much simplified from the CEE case. 168c2ecf20Sopenharmony_ci * @bw: bandwidth index by traffic class 178c2ecf20Sopenharmony_ci * @refill: refill credits index by traffic class 188c2ecf20Sopenharmony_ci * @max: max credits by traffic class 198c2ecf20Sopenharmony_ci * @max_frame: maximum frame size 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_cistatic s32 ixgbe_ieee_credits(__u8 *bw, __u16 *refill, 228c2ecf20Sopenharmony_ci __u16 *max, int max_frame) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci int min_percent = 100; 258c2ecf20Sopenharmony_ci int min_credit, multiplier; 268c2ecf20Sopenharmony_ci int i; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) / 298c2ecf20Sopenharmony_ci DCB_CREDIT_QUANTUM; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 328c2ecf20Sopenharmony_ci if (bw[i] < min_percent && bw[i]) 338c2ecf20Sopenharmony_ci min_percent = bw[i]; 348c2ecf20Sopenharmony_ci } 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci multiplier = (min_credit / min_percent) + 1; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci /* Find out the hw credits for each TC */ 398c2ecf20Sopenharmony_ci for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 408c2ecf20Sopenharmony_ci int val = min(bw[i] * multiplier, MAX_CREDIT_REFILL); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci if (val < min_credit) 438c2ecf20Sopenharmony_ci val = min_credit; 448c2ecf20Sopenharmony_ci refill[i] = val; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci max[i] = bw[i] ? (bw[i] * MAX_CREDIT)/100 : min_credit; 478c2ecf20Sopenharmony_ci } 488c2ecf20Sopenharmony_ci return 0; 498c2ecf20Sopenharmony_ci} 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/** 528c2ecf20Sopenharmony_ci * ixgbe_dcb_calculate_tc_credits - Calculates traffic class credits 538c2ecf20Sopenharmony_ci * @hw: pointer to hardware structure 548c2ecf20Sopenharmony_ci * @dcb_config: Struct containing DCB settings 558c2ecf20Sopenharmony_ci * @max_frame: Maximum frame size 568c2ecf20Sopenharmony_ci * @direction: Configuring either Tx or Rx 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * This function calculates the credits allocated to each traffic class. 598c2ecf20Sopenharmony_ci * It should be called only after the rules are checked by 608c2ecf20Sopenharmony_ci * ixgbe_dcb_check_config(). 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_cis32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw, 638c2ecf20Sopenharmony_ci struct ixgbe_dcb_config *dcb_config, 648c2ecf20Sopenharmony_ci int max_frame, u8 direction) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci struct tc_bw_alloc *p; 678c2ecf20Sopenharmony_ci int min_credit; 688c2ecf20Sopenharmony_ci int min_multiplier; 698c2ecf20Sopenharmony_ci int min_percent = 100; 708c2ecf20Sopenharmony_ci /* Initialization values default for Tx settings */ 718c2ecf20Sopenharmony_ci u32 credit_refill = 0; 728c2ecf20Sopenharmony_ci u32 credit_max = 0; 738c2ecf20Sopenharmony_ci u16 link_percentage = 0; 748c2ecf20Sopenharmony_ci u8 bw_percent = 0; 758c2ecf20Sopenharmony_ci u8 i; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci if (!dcb_config) 788c2ecf20Sopenharmony_ci return DCB_ERR_CONFIG; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci min_credit = ((max_frame / 2) + DCB_CREDIT_QUANTUM - 1) / 818c2ecf20Sopenharmony_ci DCB_CREDIT_QUANTUM; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* Find smallest link percentage */ 848c2ecf20Sopenharmony_ci for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 858c2ecf20Sopenharmony_ci p = &dcb_config->tc_config[i].path[direction]; 868c2ecf20Sopenharmony_ci bw_percent = dcb_config->bw_percentage[direction][p->bwg_id]; 878c2ecf20Sopenharmony_ci link_percentage = p->bwg_percent; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci link_percentage = (link_percentage * bw_percent) / 100; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci if (link_percentage && link_percentage < min_percent) 928c2ecf20Sopenharmony_ci min_percent = link_percentage; 938c2ecf20Sopenharmony_ci } 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* 968c2ecf20Sopenharmony_ci * The ratio between traffic classes will control the bandwidth 978c2ecf20Sopenharmony_ci * percentages seen on the wire. To calculate this ratio we use 988c2ecf20Sopenharmony_ci * a multiplier. It is required that the refill credits must be 998c2ecf20Sopenharmony_ci * larger than the max frame size so here we find the smallest 1008c2ecf20Sopenharmony_ci * multiplier that will allow all bandwidth percentages to be 1018c2ecf20Sopenharmony_ci * greater than the max frame size. 1028c2ecf20Sopenharmony_ci */ 1038c2ecf20Sopenharmony_ci min_multiplier = (min_credit / min_percent) + 1; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci /* Find out the link percentage for each TC first */ 1068c2ecf20Sopenharmony_ci for (i = 0; i < MAX_TRAFFIC_CLASS; i++) { 1078c2ecf20Sopenharmony_ci p = &dcb_config->tc_config[i].path[direction]; 1088c2ecf20Sopenharmony_ci bw_percent = dcb_config->bw_percentage[direction][p->bwg_id]; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci link_percentage = p->bwg_percent; 1118c2ecf20Sopenharmony_ci /* Must be careful of integer division for very small nums */ 1128c2ecf20Sopenharmony_ci link_percentage = (link_percentage * bw_percent) / 100; 1138c2ecf20Sopenharmony_ci if (p->bwg_percent > 0 && link_percentage == 0) 1148c2ecf20Sopenharmony_ci link_percentage = 1; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci /* Save link_percentage for reference */ 1178c2ecf20Sopenharmony_ci p->link_percent = (u8)link_percentage; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci /* Calculate credit refill ratio using multiplier */ 1208c2ecf20Sopenharmony_ci credit_refill = min(link_percentage * min_multiplier, 1218c2ecf20Sopenharmony_ci MAX_CREDIT_REFILL); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci /* Refill at least minimum credit */ 1248c2ecf20Sopenharmony_ci if (credit_refill < min_credit) 1258c2ecf20Sopenharmony_ci credit_refill = min_credit; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci p->data_credits_refill = (u16)credit_refill; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci /* Calculate maximum credit for the TC */ 1308c2ecf20Sopenharmony_ci credit_max = (link_percentage * MAX_CREDIT) / 100; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci /* 1338c2ecf20Sopenharmony_ci * Adjustment based on rule checking, if the percentage 1348c2ecf20Sopenharmony_ci * of a TC is too small, the maximum credit may not be 1358c2ecf20Sopenharmony_ci * enough to send out a jumbo frame in data plane arbitration. 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_ci if (credit_max < min_credit) 1388c2ecf20Sopenharmony_ci credit_max = min_credit; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci if (direction == DCB_TX_CONFIG) { 1418c2ecf20Sopenharmony_ci /* 1428c2ecf20Sopenharmony_ci * Adjustment based on rule checking, if the 1438c2ecf20Sopenharmony_ci * percentage of a TC is too small, the maximum 1448c2ecf20Sopenharmony_ci * credit may not be enough to send out a TSO 1458c2ecf20Sopenharmony_ci * packet in descriptor plane arbitration. 1468c2ecf20Sopenharmony_ci */ 1478c2ecf20Sopenharmony_ci if ((hw->mac.type == ixgbe_mac_82598EB) && 1488c2ecf20Sopenharmony_ci credit_max && 1498c2ecf20Sopenharmony_ci (credit_max < MINIMUM_CREDIT_FOR_TSO)) 1508c2ecf20Sopenharmony_ci credit_max = MINIMUM_CREDIT_FOR_TSO; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci dcb_config->tc_config[i].desc_credits_max = 1538c2ecf20Sopenharmony_ci (u16)credit_max; 1548c2ecf20Sopenharmony_ci } 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci p->data_credits_max = (u16)credit_max; 1578c2ecf20Sopenharmony_ci } 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci return 0; 1608c2ecf20Sopenharmony_ci} 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_civoid ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en) 1638c2ecf20Sopenharmony_ci{ 1648c2ecf20Sopenharmony_ci struct tc_configuration *tc_config = &cfg->tc_config[0]; 1658c2ecf20Sopenharmony_ci int tc; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci for (*pfc_en = 0, tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) { 1688c2ecf20Sopenharmony_ci if (tc_config[tc].dcb_pfc != pfc_disabled) 1698c2ecf20Sopenharmony_ci *pfc_en |= BIT(tc); 1708c2ecf20Sopenharmony_ci } 1718c2ecf20Sopenharmony_ci} 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_civoid ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *cfg, int direction, 1748c2ecf20Sopenharmony_ci u16 *refill) 1758c2ecf20Sopenharmony_ci{ 1768c2ecf20Sopenharmony_ci struct tc_configuration *tc_config = &cfg->tc_config[0]; 1778c2ecf20Sopenharmony_ci int tc; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) 1808c2ecf20Sopenharmony_ci refill[tc] = tc_config[tc].path[direction].data_credits_refill; 1818c2ecf20Sopenharmony_ci} 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_civoid ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *cfg, u16 *max) 1848c2ecf20Sopenharmony_ci{ 1858c2ecf20Sopenharmony_ci struct tc_configuration *tc_config = &cfg->tc_config[0]; 1868c2ecf20Sopenharmony_ci int tc; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) 1898c2ecf20Sopenharmony_ci max[tc] = tc_config[tc].desc_credits_max; 1908c2ecf20Sopenharmony_ci} 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_civoid ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *cfg, int direction, 1938c2ecf20Sopenharmony_ci u8 *bwgid) 1948c2ecf20Sopenharmony_ci{ 1958c2ecf20Sopenharmony_ci struct tc_configuration *tc_config = &cfg->tc_config[0]; 1968c2ecf20Sopenharmony_ci int tc; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) 1998c2ecf20Sopenharmony_ci bwgid[tc] = tc_config[tc].path[direction].bwg_id; 2008c2ecf20Sopenharmony_ci} 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_civoid ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *cfg, int direction, 2038c2ecf20Sopenharmony_ci u8 *ptype) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci struct tc_configuration *tc_config = &cfg->tc_config[0]; 2068c2ecf20Sopenharmony_ci int tc; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) 2098c2ecf20Sopenharmony_ci ptype[tc] = tc_config[tc].path[direction].prio_type; 2108c2ecf20Sopenharmony_ci} 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ciu8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up) 2138c2ecf20Sopenharmony_ci{ 2148c2ecf20Sopenharmony_ci struct tc_configuration *tc_config = &cfg->tc_config[0]; 2158c2ecf20Sopenharmony_ci u8 prio_mask = BIT(up); 2168c2ecf20Sopenharmony_ci u8 tc = cfg->num_tcs.pg_tcs; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci /* If tc is 0 then DCB is likely not enabled or supported */ 2198c2ecf20Sopenharmony_ci if (!tc) 2208c2ecf20Sopenharmony_ci return 0; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci /* 2238c2ecf20Sopenharmony_ci * Test from maximum TC to 1 and report the first match we find. If 2248c2ecf20Sopenharmony_ci * we find no match we can assume that the TC is 0 since the TC must 2258c2ecf20Sopenharmony_ci * be set for all user priorities 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_ci for (tc--; tc; tc--) { 2288c2ecf20Sopenharmony_ci if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap) 2298c2ecf20Sopenharmony_ci break; 2308c2ecf20Sopenharmony_ci } 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci return tc; 2338c2ecf20Sopenharmony_ci} 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_civoid ixgbe_dcb_unpack_map(struct ixgbe_dcb_config *cfg, int direction, u8 *map) 2368c2ecf20Sopenharmony_ci{ 2378c2ecf20Sopenharmony_ci u8 up; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci for (up = 0; up < MAX_USER_PRIORITY; up++) 2408c2ecf20Sopenharmony_ci map[up] = ixgbe_dcb_get_tc_from_up(cfg, direction, up); 2418c2ecf20Sopenharmony_ci} 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/** 2448c2ecf20Sopenharmony_ci * ixgbe_dcb_hw_config - Config and enable DCB 2458c2ecf20Sopenharmony_ci * @hw: pointer to hardware structure 2468c2ecf20Sopenharmony_ci * @dcb_config: pointer to ixgbe_dcb_config structure 2478c2ecf20Sopenharmony_ci * 2488c2ecf20Sopenharmony_ci * Configure dcb settings and enable dcb mode. 2498c2ecf20Sopenharmony_ci */ 2508c2ecf20Sopenharmony_cis32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, 2518c2ecf20Sopenharmony_ci struct ixgbe_dcb_config *dcb_config) 2528c2ecf20Sopenharmony_ci{ 2538c2ecf20Sopenharmony_ci u8 pfc_en; 2548c2ecf20Sopenharmony_ci u8 ptype[MAX_TRAFFIC_CLASS]; 2558c2ecf20Sopenharmony_ci u8 bwgid[MAX_TRAFFIC_CLASS]; 2568c2ecf20Sopenharmony_ci u8 prio_tc[MAX_TRAFFIC_CLASS]; 2578c2ecf20Sopenharmony_ci u16 refill[MAX_TRAFFIC_CLASS]; 2588c2ecf20Sopenharmony_ci u16 max[MAX_TRAFFIC_CLASS]; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci /* Unpack CEE standard containers */ 2618c2ecf20Sopenharmony_ci ixgbe_dcb_unpack_pfc(dcb_config, &pfc_en); 2628c2ecf20Sopenharmony_ci ixgbe_dcb_unpack_refill(dcb_config, DCB_TX_CONFIG, refill); 2638c2ecf20Sopenharmony_ci ixgbe_dcb_unpack_max(dcb_config, max); 2648c2ecf20Sopenharmony_ci ixgbe_dcb_unpack_bwgid(dcb_config, DCB_TX_CONFIG, bwgid); 2658c2ecf20Sopenharmony_ci ixgbe_dcb_unpack_prio(dcb_config, DCB_TX_CONFIG, ptype); 2668c2ecf20Sopenharmony_ci ixgbe_dcb_unpack_map(dcb_config, DCB_TX_CONFIG, prio_tc); 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci switch (hw->mac.type) { 2698c2ecf20Sopenharmony_ci case ixgbe_mac_82598EB: 2708c2ecf20Sopenharmony_ci return ixgbe_dcb_hw_config_82598(hw, pfc_en, refill, max, 2718c2ecf20Sopenharmony_ci bwgid, ptype); 2728c2ecf20Sopenharmony_ci case ixgbe_mac_82599EB: 2738c2ecf20Sopenharmony_ci case ixgbe_mac_X540: 2748c2ecf20Sopenharmony_ci case ixgbe_mac_X550: 2758c2ecf20Sopenharmony_ci case ixgbe_mac_X550EM_x: 2768c2ecf20Sopenharmony_ci case ixgbe_mac_x550em_a: 2778c2ecf20Sopenharmony_ci return ixgbe_dcb_hw_config_82599(hw, pfc_en, refill, max, 2788c2ecf20Sopenharmony_ci bwgid, ptype, prio_tc); 2798c2ecf20Sopenharmony_ci default: 2808c2ecf20Sopenharmony_ci break; 2818c2ecf20Sopenharmony_ci } 2828c2ecf20Sopenharmony_ci return 0; 2838c2ecf20Sopenharmony_ci} 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci/* Helper routines to abstract HW specifics from DCB netlink ops */ 2868c2ecf20Sopenharmony_cis32 ixgbe_dcb_hw_pfc_config(struct ixgbe_hw *hw, u8 pfc_en, u8 *prio_tc) 2878c2ecf20Sopenharmony_ci{ 2888c2ecf20Sopenharmony_ci switch (hw->mac.type) { 2898c2ecf20Sopenharmony_ci case ixgbe_mac_82598EB: 2908c2ecf20Sopenharmony_ci return ixgbe_dcb_config_pfc_82598(hw, pfc_en); 2918c2ecf20Sopenharmony_ci case ixgbe_mac_82599EB: 2928c2ecf20Sopenharmony_ci case ixgbe_mac_X540: 2938c2ecf20Sopenharmony_ci case ixgbe_mac_X550: 2948c2ecf20Sopenharmony_ci case ixgbe_mac_X550EM_x: 2958c2ecf20Sopenharmony_ci case ixgbe_mac_x550em_a: 2968c2ecf20Sopenharmony_ci return ixgbe_dcb_config_pfc_82599(hw, pfc_en, prio_tc); 2978c2ecf20Sopenharmony_ci default: 2988c2ecf20Sopenharmony_ci break; 2998c2ecf20Sopenharmony_ci } 3008c2ecf20Sopenharmony_ci return -EINVAL; 3018c2ecf20Sopenharmony_ci} 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cis32 ixgbe_dcb_hw_ets(struct ixgbe_hw *hw, struct ieee_ets *ets, int max_frame) 3048c2ecf20Sopenharmony_ci{ 3058c2ecf20Sopenharmony_ci __u16 refill[IEEE_8021QAZ_MAX_TCS], max[IEEE_8021QAZ_MAX_TCS]; 3068c2ecf20Sopenharmony_ci __u8 prio_type[IEEE_8021QAZ_MAX_TCS]; 3078c2ecf20Sopenharmony_ci int i; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci /* naively give each TC a bwg to map onto CEE hardware */ 3108c2ecf20Sopenharmony_ci __u8 bwg_id[IEEE_8021QAZ_MAX_TCS] = {0, 1, 2, 3, 4, 5, 6, 7}; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci /* Map TSA onto CEE prio type */ 3138c2ecf20Sopenharmony_ci for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 3148c2ecf20Sopenharmony_ci switch (ets->tc_tsa[i]) { 3158c2ecf20Sopenharmony_ci case IEEE_8021QAZ_TSA_STRICT: 3168c2ecf20Sopenharmony_ci prio_type[i] = 2; 3178c2ecf20Sopenharmony_ci break; 3188c2ecf20Sopenharmony_ci case IEEE_8021QAZ_TSA_ETS: 3198c2ecf20Sopenharmony_ci prio_type[i] = 0; 3208c2ecf20Sopenharmony_ci break; 3218c2ecf20Sopenharmony_ci default: 3228c2ecf20Sopenharmony_ci /* Hardware only supports priority strict or 3238c2ecf20Sopenharmony_ci * ETS transmission selection algorithms if 3248c2ecf20Sopenharmony_ci * we receive some other value from dcbnl 3258c2ecf20Sopenharmony_ci * throw an error 3268c2ecf20Sopenharmony_ci */ 3278c2ecf20Sopenharmony_ci return -EINVAL; 3288c2ecf20Sopenharmony_ci } 3298c2ecf20Sopenharmony_ci } 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci ixgbe_ieee_credits(ets->tc_tx_bw, refill, max, max_frame); 3328c2ecf20Sopenharmony_ci return ixgbe_dcb_hw_ets_config(hw, refill, max, 3338c2ecf20Sopenharmony_ci bwg_id, prio_type, ets->prio_tc); 3348c2ecf20Sopenharmony_ci} 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cis32 ixgbe_dcb_hw_ets_config(struct ixgbe_hw *hw, 3378c2ecf20Sopenharmony_ci u16 *refill, u16 *max, u8 *bwg_id, 3388c2ecf20Sopenharmony_ci u8 *prio_type, u8 *prio_tc) 3398c2ecf20Sopenharmony_ci{ 3408c2ecf20Sopenharmony_ci switch (hw->mac.type) { 3418c2ecf20Sopenharmony_ci case ixgbe_mac_82598EB: 3428c2ecf20Sopenharmony_ci ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, 3438c2ecf20Sopenharmony_ci prio_type); 3448c2ecf20Sopenharmony_ci ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max, 3458c2ecf20Sopenharmony_ci bwg_id, prio_type); 3468c2ecf20Sopenharmony_ci ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max, 3478c2ecf20Sopenharmony_ci bwg_id, prio_type); 3488c2ecf20Sopenharmony_ci break; 3498c2ecf20Sopenharmony_ci case ixgbe_mac_82599EB: 3508c2ecf20Sopenharmony_ci case ixgbe_mac_X540: 3518c2ecf20Sopenharmony_ci case ixgbe_mac_X550: 3528c2ecf20Sopenharmony_ci case ixgbe_mac_X550EM_x: 3538c2ecf20Sopenharmony_ci case ixgbe_mac_x550em_a: 3548c2ecf20Sopenharmony_ci ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, 3558c2ecf20Sopenharmony_ci bwg_id, prio_type, prio_tc); 3568c2ecf20Sopenharmony_ci ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, 3578c2ecf20Sopenharmony_ci bwg_id, prio_type); 3588c2ecf20Sopenharmony_ci ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id, 3598c2ecf20Sopenharmony_ci prio_type, prio_tc); 3608c2ecf20Sopenharmony_ci break; 3618c2ecf20Sopenharmony_ci default: 3628c2ecf20Sopenharmony_ci break; 3638c2ecf20Sopenharmony_ci } 3648c2ecf20Sopenharmony_ci return 0; 3658c2ecf20Sopenharmony_ci} 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_cistatic void ixgbe_dcb_read_rtrup2tc_82599(struct ixgbe_hw *hw, u8 *map) 3688c2ecf20Sopenharmony_ci{ 3698c2ecf20Sopenharmony_ci u32 reg, i; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci reg = IXGBE_READ_REG(hw, IXGBE_RTRUP2TC); 3728c2ecf20Sopenharmony_ci for (i = 0; i < MAX_USER_PRIORITY; i++) 3738c2ecf20Sopenharmony_ci map[i] = IXGBE_RTRUP2TC_UP_MASK & 3748c2ecf20Sopenharmony_ci (reg >> (i * IXGBE_RTRUP2TC_UP_SHIFT)); 3758c2ecf20Sopenharmony_ci} 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_civoid ixgbe_dcb_read_rtrup2tc(struct ixgbe_hw *hw, u8 *map) 3788c2ecf20Sopenharmony_ci{ 3798c2ecf20Sopenharmony_ci switch (hw->mac.type) { 3808c2ecf20Sopenharmony_ci case ixgbe_mac_82599EB: 3818c2ecf20Sopenharmony_ci case ixgbe_mac_X540: 3828c2ecf20Sopenharmony_ci case ixgbe_mac_X550: 3838c2ecf20Sopenharmony_ci case ixgbe_mac_X550EM_x: 3848c2ecf20Sopenharmony_ci case ixgbe_mac_x550em_a: 3858c2ecf20Sopenharmony_ci ixgbe_dcb_read_rtrup2tc_82599(hw, map); 3868c2ecf20Sopenharmony_ci break; 3878c2ecf20Sopenharmony_ci default: 3888c2ecf20Sopenharmony_ci break; 3898c2ecf20Sopenharmony_ci } 3908c2ecf20Sopenharmony_ci} 391