ixgbe_dcb.c revision 1.10       1  1.10   msaitoh /* $NetBSD: ixgbe_dcb.c,v 1.10 2021/04/30 06:41:36 msaitoh Exp $ */
      2   1.1   msaitoh /******************************************************************************
      3   1.6   msaitoh   SPDX-License-Identifier: BSD-3-Clause
      4   1.1   msaitoh 
      5   1.5   msaitoh   Copyright (c) 2001-2017, Intel Corporation
      6   1.1   msaitoh   All rights reserved.
      7   1.5   msaitoh 
      8   1.5   msaitoh   Redistribution and use in source and binary forms, with or without
      9   1.1   msaitoh   modification, are permitted provided that the following conditions are met:
     10   1.5   msaitoh 
     11   1.5   msaitoh    1. Redistributions of source code must retain the above copyright notice,
     12   1.1   msaitoh       this list of conditions and the following disclaimer.
     13   1.5   msaitoh 
     14   1.5   msaitoh    2. Redistributions in binary form must reproduce the above copyright
     15   1.5   msaitoh       notice, this list of conditions and the following disclaimer in the
     16   1.1   msaitoh       documentation and/or other materials provided with the distribution.
     17   1.5   msaitoh 
     18   1.5   msaitoh    3. Neither the name of the Intel Corporation nor the names of its
     19   1.5   msaitoh       contributors may be used to endorse or promote products derived from
     20   1.1   msaitoh       this software without specific prior written permission.
     21   1.5   msaitoh 
     22   1.1   msaitoh   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     23   1.5   msaitoh   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24   1.5   msaitoh   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25   1.5   msaitoh   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     26   1.5   msaitoh   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27   1.5   msaitoh   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28   1.5   msaitoh   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29   1.5   msaitoh   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30   1.5   msaitoh   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31   1.1   msaitoh   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32   1.1   msaitoh   POSSIBILITY OF SUCH DAMAGE.
     33   1.1   msaitoh 
     34   1.1   msaitoh ******************************************************************************/
     35   1.8   msaitoh /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_dcb.c 331224 2018-03-19 20:55:05Z erj $*/
     36   1.1   msaitoh 
     37   1.1   msaitoh 
     38   1.1   msaitoh #include "ixgbe_type.h"
     39   1.1   msaitoh #include "ixgbe_dcb.h"
     40   1.1   msaitoh #include "ixgbe_dcb_82598.h"
     41   1.1   msaitoh #include "ixgbe_dcb_82599.h"
     42   1.1   msaitoh 
     43   1.1   msaitoh /**
     44   1.1   msaitoh  * ixgbe_dcb_calculate_tc_credits - This calculates the ieee traffic class
     45   1.1   msaitoh  * credits from the configured bandwidth percentages. Credits
     46   1.1   msaitoh  * are the smallest unit programmable into the underlying
     47   1.1   msaitoh  * hardware. The IEEE 802.1Qaz specification do not use bandwidth
     48   1.1   msaitoh  * groups so this is much simplified from the CEE case.
     49   1.8   msaitoh  * @bw: bandwidth index by traffic class
     50   1.8   msaitoh  * @refill: refill credits index by traffic class
     51   1.8   msaitoh  * @max: max credits by traffic class
     52   1.8   msaitoh  * @max_frame_size: maximum frame size
     53   1.1   msaitoh  */
     54   1.1   msaitoh s32 ixgbe_dcb_calculate_tc_credits(u8 *bw, u16 *refill, u16 *max,
     55   1.1   msaitoh 				   int max_frame_size)
     56   1.1   msaitoh {
     57   1.1   msaitoh 	int min_percent = 100;
     58   1.1   msaitoh 	int min_credit, multiplier;
     59   1.1   msaitoh 	int i;
     60   1.1   msaitoh 
     61   1.1   msaitoh 	min_credit = ((max_frame_size / 2) + IXGBE_DCB_CREDIT_QUANTUM - 1) /
     62   1.1   msaitoh 			IXGBE_DCB_CREDIT_QUANTUM;
     63   1.1   msaitoh 
     64   1.1   msaitoh 	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
     65   1.1   msaitoh 		if (bw[i] < min_percent && bw[i])
     66   1.1   msaitoh 			min_percent = bw[i];
     67   1.1   msaitoh 	}
     68   1.1   msaitoh 
     69   1.1   msaitoh 	multiplier = (min_credit / min_percent) + 1;
     70   1.1   msaitoh 
     71   1.1   msaitoh 	/* Find out the hw credits for each TC */
     72   1.1   msaitoh 	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
     73   1.9  riastrad 		int val = uimin(bw[i] * multiplier, IXGBE_DCB_MAX_CREDIT_REFILL);
     74   1.1   msaitoh 
     75   1.1   msaitoh 		if (val < min_credit)
     76   1.1   msaitoh 			val = min_credit;
     77   1.1   msaitoh 		refill[i] = (u16)val;
     78   1.1   msaitoh 
     79   1.1   msaitoh 		max[i] = bw[i] ? (bw[i]*IXGBE_DCB_MAX_CREDIT)/100 : min_credit;
     80   1.1   msaitoh 	}
     81   1.1   msaitoh 
     82   1.1   msaitoh 	return 0;
     83   1.1   msaitoh }
     84   1.1   msaitoh 
     85   1.1   msaitoh /**
     86   1.1   msaitoh  * ixgbe_dcb_calculate_tc_credits_cee - Calculates traffic class credits
     87   1.8   msaitoh  * @hw: pointer to hardware structure
     88   1.8   msaitoh  * @dcb_config: Struct containing DCB settings
     89   1.8   msaitoh  * @max_frame_size: Maximum frame size
     90   1.8   msaitoh  * @direction: Configuring either Tx or Rx
     91   1.1   msaitoh  *
     92   1.1   msaitoh  * This function calculates the credits allocated to each traffic class.
     93   1.1   msaitoh  * It should be called only after the rules are checked by
     94   1.1   msaitoh  * ixgbe_dcb_check_config_cee().
     95   1.1   msaitoh  */
     96   1.1   msaitoh s32 ixgbe_dcb_calculate_tc_credits_cee(struct ixgbe_hw *hw,
     97   1.1   msaitoh 				   struct ixgbe_dcb_config *dcb_config,
     98   1.1   msaitoh 				   u32 max_frame_size, u8 direction)
     99   1.1   msaitoh {
    100   1.1   msaitoh 	struct ixgbe_dcb_tc_path *p;
    101   1.1   msaitoh 	u32 min_multiplier	= 0;
    102   1.1   msaitoh 	u16 min_percent		= 100;
    103   1.1   msaitoh 	s32 ret_val =		IXGBE_SUCCESS;
    104   1.1   msaitoh 	/* Initialization values default for Tx settings */
    105   1.1   msaitoh 	u32 min_credit		= 0;
    106   1.1   msaitoh 	u32 credit_refill	= 0;
    107   1.1   msaitoh 	u32 credit_max		= 0;
    108   1.1   msaitoh 	u16 link_percentage	= 0;
    109   1.1   msaitoh 	u8  bw_percent		= 0;
    110   1.1   msaitoh 	u8  i;
    111   1.1   msaitoh 
    112   1.1   msaitoh 	if (dcb_config == NULL) {
    113   1.1   msaitoh 		ret_val = IXGBE_ERR_CONFIG;
    114   1.1   msaitoh 		goto out;
    115   1.1   msaitoh 	}
    116   1.1   msaitoh 
    117   1.1   msaitoh 	min_credit = ((max_frame_size / 2) + IXGBE_DCB_CREDIT_QUANTUM - 1) /
    118   1.1   msaitoh 		     IXGBE_DCB_CREDIT_QUANTUM;
    119   1.1   msaitoh 
    120   1.1   msaitoh 	/* Find smallest link percentage */
    121   1.1   msaitoh 	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
    122   1.1   msaitoh 		p = &dcb_config->tc_config[i].path[direction];
    123   1.1   msaitoh 		bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
    124   1.1   msaitoh 		link_percentage = p->bwg_percent;
    125   1.1   msaitoh 
    126   1.1   msaitoh 		link_percentage = (link_percentage * bw_percent) / 100;
    127   1.1   msaitoh 
    128   1.1   msaitoh 		if (link_percentage && link_percentage < min_percent)
    129   1.1   msaitoh 			min_percent = link_percentage;
    130   1.1   msaitoh 	}
    131   1.1   msaitoh 
    132   1.1   msaitoh 	/*
    133   1.1   msaitoh 	 * The ratio between traffic classes will control the bandwidth
    134   1.1   msaitoh 	 * percentages seen on the wire. To calculate this ratio we use
    135   1.1   msaitoh 	 * a multiplier. It is required that the refill credits must be
    136   1.1   msaitoh 	 * larger than the max frame size so here we find the smallest
    137   1.1   msaitoh 	 * multiplier that will allow all bandwidth percentages to be
    138   1.1   msaitoh 	 * greater than the max frame size.
    139   1.1   msaitoh 	 */
    140   1.1   msaitoh 	min_multiplier = (min_credit / min_percent) + 1;
    141   1.1   msaitoh 
    142   1.1   msaitoh 	/* Find out the link percentage for each TC first */
    143   1.1   msaitoh 	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
    144   1.1   msaitoh 		p = &dcb_config->tc_config[i].path[direction];
    145   1.1   msaitoh 		bw_percent = dcb_config->bw_percentage[direction][p->bwg_id];
    146   1.1   msaitoh 
    147   1.1   msaitoh 		link_percentage = p->bwg_percent;
    148   1.1   msaitoh 		/* Must be careful of integer division for very small nums */
    149   1.1   msaitoh 		link_percentage = (link_percentage * bw_percent) / 100;
    150   1.1   msaitoh 		if (p->bwg_percent > 0 && link_percentage == 0)
    151   1.1   msaitoh 			link_percentage = 1;
    152   1.1   msaitoh 
    153   1.1   msaitoh 		/* Save link_percentage for reference */
    154   1.1   msaitoh 		p->link_percent = (u8)link_percentage;
    155   1.1   msaitoh 
    156   1.1   msaitoh 		/* Calculate credit refill ratio using multiplier */
    157   1.9  riastrad 		credit_refill = uimin(link_percentage * min_multiplier,
    158   1.1   msaitoh 				    (u32)IXGBE_DCB_MAX_CREDIT_REFILL);
    159   1.4   msaitoh 
    160   1.4   msaitoh 		/* Refill at least minimum credit */
    161   1.4   msaitoh 		if (credit_refill < min_credit)
    162   1.4   msaitoh 			credit_refill = min_credit;
    163   1.4   msaitoh 
    164   1.1   msaitoh 		p->data_credits_refill = (u16)credit_refill;
    165   1.1   msaitoh 
    166   1.1   msaitoh 		/* Calculate maximum credit for the TC */
    167   1.1   msaitoh 		credit_max = (link_percentage * IXGBE_DCB_MAX_CREDIT) / 100;
    168   1.1   msaitoh 
    169   1.1   msaitoh 		/*
    170   1.1   msaitoh 		 * Adjustment based on rule checking, if the percentage
    171   1.1   msaitoh 		 * of a TC is too small, the maximum credit may not be
    172   1.1   msaitoh 		 * enough to send out a jumbo frame in data plane arbitration.
    173   1.1   msaitoh 		 */
    174   1.4   msaitoh 		if (credit_max < min_credit)
    175   1.1   msaitoh 			credit_max = min_credit;
    176   1.1   msaitoh 
    177   1.1   msaitoh 		if (direction == IXGBE_DCB_TX_CONFIG) {
    178   1.1   msaitoh 			/*
    179   1.1   msaitoh 			 * Adjustment based on rule checking, if the
    180   1.1   msaitoh 			 * percentage of a TC is too small, the maximum
    181   1.1   msaitoh 			 * credit may not be enough to send out a TSO
    182   1.1   msaitoh 			 * packet in descriptor plane arbitration.
    183   1.1   msaitoh 			 */
    184   1.1   msaitoh 			if (credit_max && (credit_max <
    185   1.1   msaitoh 			    IXGBE_DCB_MIN_TSO_CREDIT)
    186   1.1   msaitoh 			    && (hw->mac.type == ixgbe_mac_82598EB))
    187   1.1   msaitoh 				credit_max = IXGBE_DCB_MIN_TSO_CREDIT;
    188   1.1   msaitoh 
    189   1.1   msaitoh 			dcb_config->tc_config[i].desc_credits_max =
    190   1.1   msaitoh 								(u16)credit_max;
    191   1.1   msaitoh 		}
    192   1.1   msaitoh 
    193   1.1   msaitoh 		p->data_credits_max = (u16)credit_max;
    194   1.1   msaitoh 	}
    195   1.1   msaitoh 
    196   1.1   msaitoh out:
    197   1.1   msaitoh 	return ret_val;
    198   1.1   msaitoh }
    199   1.1   msaitoh 
    200   1.1   msaitoh /**
    201   1.1   msaitoh  * ixgbe_dcb_unpack_pfc_cee - Unpack dcb_config PFC info
    202   1.1   msaitoh  * @cfg: dcb configuration to unpack into hardware consumable fields
    203   1.1   msaitoh  * @map: user priority to traffic class map
    204   1.1   msaitoh  * @pfc_up: u8 to store user priority PFC bitmask
    205   1.1   msaitoh  *
    206   1.1   msaitoh  * This unpacks the dcb configuration PFC info which is stored per
    207   1.1   msaitoh  * traffic class into a 8bit user priority bitmask that can be
    208   1.1   msaitoh  * consumed by hardware routines. The priority to tc map must be
    209   1.1   msaitoh  * updated before calling this routine to use current up-to maps.
    210   1.1   msaitoh  */
    211   1.1   msaitoh void ixgbe_dcb_unpack_pfc_cee(struct ixgbe_dcb_config *cfg, u8 *map, u8 *pfc_up)
    212   1.1   msaitoh {
    213   1.1   msaitoh 	struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
    214   1.1   msaitoh 	int up;
    215   1.1   msaitoh 
    216   1.1   msaitoh 	/*
    217   1.1   msaitoh 	 * If the TC for this user priority has PFC enabled then set the
    218   1.1   msaitoh 	 * matching bit in 'pfc_up' to reflect that PFC is enabled.
    219   1.1   msaitoh 	 */
    220   1.1   msaitoh 	for (*pfc_up = 0, up = 0; up < IXGBE_DCB_MAX_USER_PRIORITY; up++) {
    221   1.1   msaitoh 		if (tc_config[map[up]].pfc != ixgbe_dcb_pfc_disabled)
    222   1.1   msaitoh 			*pfc_up |= 1 << up;
    223   1.1   msaitoh 	}
    224   1.1   msaitoh }
    225   1.1   msaitoh 
    226   1.1   msaitoh void ixgbe_dcb_unpack_refill_cee(struct ixgbe_dcb_config *cfg, int direction,
    227   1.1   msaitoh 			     u16 *refill)
    228   1.1   msaitoh {
    229   1.1   msaitoh 	struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
    230   1.1   msaitoh 	int tc;
    231   1.1   msaitoh 
    232   1.1   msaitoh 	for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
    233   1.1   msaitoh 		refill[tc] = tc_config[tc].path[direction].data_credits_refill;
    234   1.1   msaitoh }
    235   1.1   msaitoh 
    236   1.1   msaitoh void ixgbe_dcb_unpack_max_cee(struct ixgbe_dcb_config *cfg, u16 *max)
    237   1.1   msaitoh {
    238   1.1   msaitoh 	struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
    239   1.1   msaitoh 	int tc;
    240   1.1   msaitoh 
    241   1.1   msaitoh 	for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
    242   1.1   msaitoh 		max[tc] = tc_config[tc].desc_credits_max;
    243   1.1   msaitoh }
    244   1.1   msaitoh 
    245   1.1   msaitoh void ixgbe_dcb_unpack_bwgid_cee(struct ixgbe_dcb_config *cfg, int direction,
    246   1.1   msaitoh 			    u8 *bwgid)
    247   1.1   msaitoh {
    248   1.1   msaitoh 	struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
    249   1.1   msaitoh 	int tc;
    250   1.1   msaitoh 
    251   1.1   msaitoh 	for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
    252   1.1   msaitoh 		bwgid[tc] = tc_config[tc].path[direction].bwg_id;
    253   1.1   msaitoh }
    254   1.1   msaitoh 
    255   1.1   msaitoh void ixgbe_dcb_unpack_tsa_cee(struct ixgbe_dcb_config *cfg, int direction,
    256   1.1   msaitoh 			   u8 *tsa)
    257   1.1   msaitoh {
    258   1.1   msaitoh 	struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
    259   1.1   msaitoh 	int tc;
    260   1.1   msaitoh 
    261   1.1   msaitoh 	for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++)
    262   1.1   msaitoh 		tsa[tc] = tc_config[tc].path[direction].tsa;
    263   1.1   msaitoh }
    264   1.1   msaitoh 
    265   1.1   msaitoh u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up)
    266   1.1   msaitoh {
    267   1.1   msaitoh 	struct ixgbe_dcb_tc_config *tc_config = &cfg->tc_config[0];
    268   1.1   msaitoh 	u8 prio_mask = 1 << up;
    269   1.1   msaitoh 	u8 tc = cfg->num_tcs.pg_tcs;
    270   1.1   msaitoh 
    271   1.1   msaitoh 	/* If tc is 0 then DCB is likely not enabled or supported */
    272   1.1   msaitoh 	if (!tc)
    273   1.1   msaitoh 		goto out;
    274   1.1   msaitoh 
    275   1.1   msaitoh 	/*
    276   1.1   msaitoh 	 * Test from maximum TC to 1 and report the first match we find.  If
    277   1.1   msaitoh 	 * we find no match we can assume that the TC is 0 since the TC must
    278   1.1   msaitoh 	 * be set for all user priorities
    279   1.1   msaitoh 	 */
    280   1.1   msaitoh 	for (tc--; tc; tc--) {
    281   1.1   msaitoh 		if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap)
    282   1.1   msaitoh 			break;
    283   1.1   msaitoh 	}
    284   1.1   msaitoh out:
    285   1.1   msaitoh 	return tc;
    286   1.1   msaitoh }
    287   1.1   msaitoh 
    288   1.1   msaitoh void ixgbe_dcb_unpack_map_cee(struct ixgbe_dcb_config *cfg, int direction,
    289   1.1   msaitoh 			      u8 *map)
    290   1.1   msaitoh {
    291   1.1   msaitoh 	u8 up;
    292   1.1   msaitoh 
    293   1.1   msaitoh 	for (up = 0; up < IXGBE_DCB_MAX_USER_PRIORITY; up++)
    294   1.1   msaitoh 		map[up] = ixgbe_dcb_get_tc_from_up(cfg, direction, up);
    295   1.1   msaitoh }
    296   1.1   msaitoh 
    297   1.1   msaitoh /**
    298   1.1   msaitoh  * ixgbe_dcb_config - Struct containing DCB settings.
    299   1.1   msaitoh  * @dcb_config: Pointer to DCB config structure
    300   1.1   msaitoh  *
    301   1.1   msaitoh  * This function checks DCB rules for DCB settings.
    302   1.1   msaitoh  * The following rules are checked:
    303   1.1   msaitoh  * 1. The sum of bandwidth percentages of all Bandwidth Groups must total 100%.
    304   1.1   msaitoh  * 2. The sum of bandwidth percentages of all Traffic Classes within a Bandwidth
    305   1.1   msaitoh  *    Group must total 100.
    306   1.1   msaitoh  * 3. A Traffic Class should not be set to both Link Strict Priority
    307   1.1   msaitoh  *    and Group Strict Priority.
    308   1.1   msaitoh  * 4. Link strict Bandwidth Groups can only have link strict traffic classes
    309   1.1   msaitoh  *    with zero bandwidth.
    310   1.1   msaitoh  */
    311   1.1   msaitoh s32 ixgbe_dcb_check_config_cee(struct ixgbe_dcb_config *dcb_config)
    312   1.1   msaitoh {
    313   1.1   msaitoh 	struct ixgbe_dcb_tc_path *p;
    314   1.1   msaitoh 	s32 ret_val = IXGBE_SUCCESS;
    315   1.1   msaitoh 	u8 i, j, bw = 0, bw_id;
    316   1.1   msaitoh 	u8 bw_sum[2][IXGBE_DCB_MAX_BW_GROUP];
    317   1.1   msaitoh 	bool link_strict[2][IXGBE_DCB_MAX_BW_GROUP];
    318   1.1   msaitoh 
    319   1.1   msaitoh 	memset(bw_sum, 0, sizeof(bw_sum));
    320   1.1   msaitoh 	memset(link_strict, 0, sizeof(link_strict));
    321   1.1   msaitoh 
    322   1.1   msaitoh 	/* First Tx, then Rx */
    323   1.1   msaitoh 	for (i = 0; i < 2; i++) {
    324   1.1   msaitoh 		/* Check each traffic class for rule violation */
    325   1.1   msaitoh 		for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
    326   1.1   msaitoh 			p = &dcb_config->tc_config[j].path[i];
    327   1.1   msaitoh 
    328   1.1   msaitoh 			bw = p->bwg_percent;
    329   1.1   msaitoh 			bw_id = p->bwg_id;
    330   1.1   msaitoh 
    331   1.1   msaitoh 			if (bw_id >= IXGBE_DCB_MAX_BW_GROUP) {
    332   1.1   msaitoh 				ret_val = IXGBE_ERR_CONFIG;
    333   1.1   msaitoh 				goto err_config;
    334   1.1   msaitoh 			}
    335   1.1   msaitoh 			if (p->tsa == ixgbe_dcb_tsa_strict) {
    336   1.1   msaitoh 				link_strict[i][bw_id] = TRUE;
    337   1.1   msaitoh 				/* Link strict should have zero bandwidth */
    338   1.1   msaitoh 				if (bw) {
    339   1.1   msaitoh 					ret_val = IXGBE_ERR_CONFIG;
    340   1.1   msaitoh 					goto err_config;
    341   1.1   msaitoh 				}
    342   1.1   msaitoh 			} else if (!bw) {
    343   1.1   msaitoh 				/*
    344   1.1   msaitoh 				 * Traffic classes without link strict
    345   1.1   msaitoh 				 * should have non-zero bandwidth.
    346   1.1   msaitoh 				 */
    347   1.1   msaitoh 				ret_val = IXGBE_ERR_CONFIG;
    348   1.1   msaitoh 				goto err_config;
    349   1.1   msaitoh 			}
    350   1.1   msaitoh 			bw_sum[i][bw_id] += bw;
    351   1.1   msaitoh 		}
    352   1.1   msaitoh 
    353   1.1   msaitoh 		bw = 0;
    354   1.1   msaitoh 
    355   1.1   msaitoh 		/* Check each bandwidth group for rule violation */
    356   1.1   msaitoh 		for (j = 0; j < IXGBE_DCB_MAX_BW_GROUP; j++) {
    357   1.1   msaitoh 			bw += dcb_config->bw_percentage[i][j];
    358   1.1   msaitoh 			/*
    359   1.1   msaitoh 			 * Sum of bandwidth percentages of all traffic classes
    360   1.1   msaitoh 			 * within a Bandwidth Group must total 100 except for
    361   1.1   msaitoh 			 * link strict group (zero bandwidth).
    362   1.1   msaitoh 			 */
    363   1.1   msaitoh 			if (link_strict[i][j]) {
    364   1.1   msaitoh 				if (bw_sum[i][j]) {
    365   1.1   msaitoh 					/*
    366   1.1   msaitoh 					 * Link strict group should have zero
    367   1.1   msaitoh 					 * bandwidth.
    368   1.1   msaitoh 					 */
    369   1.1   msaitoh 					ret_val = IXGBE_ERR_CONFIG;
    370   1.1   msaitoh 					goto err_config;
    371   1.1   msaitoh 				}
    372   1.1   msaitoh 			} else if (bw_sum[i][j] != IXGBE_DCB_BW_PERCENT &&
    373   1.1   msaitoh 				   bw_sum[i][j] != 0) {
    374   1.1   msaitoh 				ret_val = IXGBE_ERR_CONFIG;
    375   1.1   msaitoh 				goto err_config;
    376   1.1   msaitoh 			}
    377   1.1   msaitoh 		}
    378   1.1   msaitoh 
    379   1.1   msaitoh 		if (bw != IXGBE_DCB_BW_PERCENT) {
    380   1.1   msaitoh 			ret_val = IXGBE_ERR_CONFIG;
    381   1.1   msaitoh 			goto err_config;
    382   1.1   msaitoh 		}
    383   1.1   msaitoh 	}
    384   1.1   msaitoh 
    385   1.1   msaitoh err_config:
    386   1.1   msaitoh 	DEBUGOUT2("DCB error code %d while checking %s settings.\n",
    387   1.1   msaitoh 		  ret_val, (i == IXGBE_DCB_TX_CONFIG) ? "Tx" : "Rx");
    388   1.1   msaitoh 
    389   1.1   msaitoh 	return ret_val;
    390   1.1   msaitoh }
    391   1.1   msaitoh 
    392   1.1   msaitoh /**
    393   1.1   msaitoh  * ixgbe_dcb_get_tc_stats - Returns status of each traffic class
    394   1.1   msaitoh  * @hw: pointer to hardware structure
    395   1.1   msaitoh  * @stats: pointer to statistics structure
    396   1.1   msaitoh  * @tc_count:  Number of elements in bwg_array.
    397   1.1   msaitoh  *
    398   1.1   msaitoh  * This function returns the status data for each of the Traffic Classes in use.
    399   1.1   msaitoh  */
    400   1.1   msaitoh s32 ixgbe_dcb_get_tc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats,
    401   1.1   msaitoh 			   u8 tc_count)
    402   1.1   msaitoh {
    403   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    404   1.1   msaitoh 	switch (hw->mac.type) {
    405   1.1   msaitoh 	case ixgbe_mac_82598EB:
    406   1.1   msaitoh 		ret = ixgbe_dcb_get_tc_stats_82598(hw, stats, tc_count);
    407   1.1   msaitoh 		break;
    408   1.1   msaitoh 	case ixgbe_mac_82599EB:
    409   1.1   msaitoh 	case ixgbe_mac_X540:
    410   1.2   msaitoh 	case ixgbe_mac_X550:
    411   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    412   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    413   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    414   1.1   msaitoh 		ret = ixgbe_dcb_get_tc_stats_82599(hw, stats, tc_count);
    415   1.1   msaitoh 		break;
    416   1.1   msaitoh #endif
    417   1.1   msaitoh 	default:
    418   1.1   msaitoh 		break;
    419   1.1   msaitoh 	}
    420   1.1   msaitoh 	return ret;
    421   1.1   msaitoh }
    422   1.1   msaitoh 
    423   1.1   msaitoh /**
    424   1.1   msaitoh  * ixgbe_dcb_get_pfc_stats - Returns CBFC status of each traffic class
    425   1.1   msaitoh  * @hw: pointer to hardware structure
    426   1.1   msaitoh  * @stats: pointer to statistics structure
    427   1.1   msaitoh  * @tc_count:  Number of elements in bwg_array.
    428   1.1   msaitoh  *
    429   1.1   msaitoh  * This function returns the CBFC status data for each of the Traffic Classes.
    430   1.1   msaitoh  */
    431   1.1   msaitoh s32 ixgbe_dcb_get_pfc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats,
    432   1.1   msaitoh 			    u8 tc_count)
    433   1.1   msaitoh {
    434   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    435   1.1   msaitoh 	switch (hw->mac.type) {
    436   1.1   msaitoh 	case ixgbe_mac_82598EB:
    437   1.1   msaitoh 		ret = ixgbe_dcb_get_pfc_stats_82598(hw, stats, tc_count);
    438   1.1   msaitoh 		break;
    439   1.1   msaitoh 	case ixgbe_mac_82599EB:
    440   1.1   msaitoh 	case ixgbe_mac_X540:
    441   1.2   msaitoh 	case ixgbe_mac_X550:
    442   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    443   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    444   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    445   1.1   msaitoh 		ret = ixgbe_dcb_get_pfc_stats_82599(hw, stats, tc_count);
    446   1.1   msaitoh 		break;
    447   1.1   msaitoh #endif
    448   1.1   msaitoh 	default:
    449   1.1   msaitoh 		break;
    450   1.1   msaitoh 	}
    451   1.1   msaitoh 	return ret;
    452   1.1   msaitoh }
    453   1.1   msaitoh 
    454   1.1   msaitoh /**
    455   1.1   msaitoh  * ixgbe_dcb_config_rx_arbiter_cee - Config Rx arbiter
    456   1.1   msaitoh  * @hw: pointer to hardware structure
    457   1.1   msaitoh  * @dcb_config: pointer to ixgbe_dcb_config structure
    458   1.1   msaitoh  *
    459   1.1   msaitoh  * Configure Rx Data Arbiter and credits for each traffic class.
    460   1.1   msaitoh  */
    461   1.1   msaitoh s32 ixgbe_dcb_config_rx_arbiter_cee(struct ixgbe_hw *hw,
    462   1.1   msaitoh 				struct ixgbe_dcb_config *dcb_config)
    463   1.1   msaitoh {
    464   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    465   1.1   msaitoh 	u8 tsa[IXGBE_DCB_MAX_TRAFFIC_CLASS]	= { 0 };
    466   1.1   msaitoh 	u8 bwgid[IXGBE_DCB_MAX_TRAFFIC_CLASS]	= { 0 };
    467   1.1   msaitoh 	u8 map[IXGBE_DCB_MAX_USER_PRIORITY]	= { 0 };
    468   1.1   msaitoh 	u16 refill[IXGBE_DCB_MAX_TRAFFIC_CLASS]	= { 0 };
    469   1.1   msaitoh 	u16 max[IXGBE_DCB_MAX_TRAFFIC_CLASS]	= { 0 };
    470   1.1   msaitoh 
    471   1.1   msaitoh 	ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_TX_CONFIG, refill);
    472   1.1   msaitoh 	ixgbe_dcb_unpack_max_cee(dcb_config, max);
    473   1.1   msaitoh 	ixgbe_dcb_unpack_bwgid_cee(dcb_config, IXGBE_DCB_TX_CONFIG, bwgid);
    474   1.1   msaitoh 	ixgbe_dcb_unpack_tsa_cee(dcb_config, IXGBE_DCB_TX_CONFIG, tsa);
    475   1.1   msaitoh 	ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_TX_CONFIG, map);
    476   1.1   msaitoh 
    477   1.1   msaitoh 	switch (hw->mac.type) {
    478   1.1   msaitoh 	case ixgbe_mac_82598EB:
    479   1.1   msaitoh 		ret = ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, tsa);
    480   1.1   msaitoh 		break;
    481   1.1   msaitoh 	case ixgbe_mac_82599EB:
    482   1.1   msaitoh 	case ixgbe_mac_X540:
    483   1.2   msaitoh 	case ixgbe_mac_X550:
    484   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    485   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    486   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    487   1.1   msaitoh 		ret = ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwgid,
    488   1.1   msaitoh 							tsa, map);
    489   1.1   msaitoh 		break;
    490   1.1   msaitoh #endif
    491   1.1   msaitoh 	default:
    492   1.1   msaitoh 		break;
    493   1.1   msaitoh 	}
    494   1.1   msaitoh 	return ret;
    495   1.1   msaitoh }
    496   1.1   msaitoh 
    497   1.1   msaitoh /**
    498   1.1   msaitoh  * ixgbe_dcb_config_tx_desc_arbiter_cee - Config Tx Desc arbiter
    499   1.1   msaitoh  * @hw: pointer to hardware structure
    500   1.1   msaitoh  * @dcb_config: pointer to ixgbe_dcb_config structure
    501   1.1   msaitoh  *
    502   1.1   msaitoh  * Configure Tx Descriptor Arbiter and credits for each traffic class.
    503   1.1   msaitoh  */
    504   1.1   msaitoh s32 ixgbe_dcb_config_tx_desc_arbiter_cee(struct ixgbe_hw *hw,
    505   1.1   msaitoh 				     struct ixgbe_dcb_config *dcb_config)
    506   1.1   msaitoh {
    507   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    508   1.1   msaitoh 	u8 tsa[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    509   1.1   msaitoh 	u8 bwgid[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    510   1.1   msaitoh 	u16 refill[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    511   1.1   msaitoh 	u16 max[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    512   1.1   msaitoh 
    513   1.1   msaitoh 	ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_TX_CONFIG, refill);
    514   1.1   msaitoh 	ixgbe_dcb_unpack_max_cee(dcb_config, max);
    515   1.1   msaitoh 	ixgbe_dcb_unpack_bwgid_cee(dcb_config, IXGBE_DCB_TX_CONFIG, bwgid);
    516   1.1   msaitoh 	ixgbe_dcb_unpack_tsa_cee(dcb_config, IXGBE_DCB_TX_CONFIG, tsa);
    517   1.1   msaitoh 
    518   1.1   msaitoh 	switch (hw->mac.type) {
    519   1.1   msaitoh 	case ixgbe_mac_82598EB:
    520   1.1   msaitoh 		ret = ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max,
    521   1.1   msaitoh 							     bwgid, tsa);
    522   1.1   msaitoh 		break;
    523   1.1   msaitoh 	case ixgbe_mac_82599EB:
    524   1.1   msaitoh 	case ixgbe_mac_X540:
    525   1.2   msaitoh 	case ixgbe_mac_X550:
    526   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    527   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    528   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    529   1.1   msaitoh 		ret = ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max,
    530   1.1   msaitoh 							     bwgid, tsa);
    531   1.1   msaitoh 		break;
    532   1.1   msaitoh #endif
    533   1.1   msaitoh 	default:
    534   1.1   msaitoh 		break;
    535   1.1   msaitoh 	}
    536   1.1   msaitoh 	return ret;
    537   1.1   msaitoh }
    538   1.1   msaitoh 
    539   1.1   msaitoh /**
    540   1.1   msaitoh  * ixgbe_dcb_config_tx_data_arbiter_cee - Config Tx data arbiter
    541   1.1   msaitoh  * @hw: pointer to hardware structure
    542   1.1   msaitoh  * @dcb_config: pointer to ixgbe_dcb_config structure
    543   1.1   msaitoh  *
    544   1.1   msaitoh  * Configure Tx Data Arbiter and credits for each traffic class.
    545   1.1   msaitoh  */
    546   1.1   msaitoh s32 ixgbe_dcb_config_tx_data_arbiter_cee(struct ixgbe_hw *hw,
    547   1.1   msaitoh 				     struct ixgbe_dcb_config *dcb_config)
    548   1.1   msaitoh {
    549   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    550   1.1   msaitoh 	u8 tsa[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    551   1.1   msaitoh 	u8 bwgid[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    552   1.1   msaitoh 	u8 map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
    553   1.1   msaitoh 	u16 refill[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    554   1.1   msaitoh 	u16 max[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    555   1.1   msaitoh 
    556   1.1   msaitoh 	ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_TX_CONFIG, refill);
    557   1.1   msaitoh 	ixgbe_dcb_unpack_max_cee(dcb_config, max);
    558   1.1   msaitoh 	ixgbe_dcb_unpack_bwgid_cee(dcb_config, IXGBE_DCB_TX_CONFIG, bwgid);
    559   1.1   msaitoh 	ixgbe_dcb_unpack_tsa_cee(dcb_config, IXGBE_DCB_TX_CONFIG, tsa);
    560   1.1   msaitoh 	ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_TX_CONFIG, map);
    561   1.1   msaitoh 
    562   1.1   msaitoh 	switch (hw->mac.type) {
    563   1.1   msaitoh 	case ixgbe_mac_82598EB:
    564   1.1   msaitoh 		ret = ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max,
    565   1.1   msaitoh 							     bwgid, tsa);
    566   1.1   msaitoh 		break;
    567   1.1   msaitoh 	case ixgbe_mac_82599EB:
    568   1.1   msaitoh 	case ixgbe_mac_X540:
    569   1.2   msaitoh 	case ixgbe_mac_X550:
    570   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    571   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    572   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    573   1.1   msaitoh 		ret = ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max,
    574   1.1   msaitoh 							     bwgid, tsa,
    575   1.1   msaitoh 							     map);
    576   1.1   msaitoh 		break;
    577   1.1   msaitoh #endif
    578   1.1   msaitoh 	default:
    579   1.1   msaitoh 		break;
    580   1.1   msaitoh 	}
    581   1.1   msaitoh 	return ret;
    582   1.1   msaitoh }
    583   1.1   msaitoh 
    584   1.1   msaitoh /**
    585   1.1   msaitoh  * ixgbe_dcb_config_pfc_cee - Config priority flow control
    586   1.1   msaitoh  * @hw: pointer to hardware structure
    587   1.1   msaitoh  * @dcb_config: pointer to ixgbe_dcb_config structure
    588   1.1   msaitoh  *
    589   1.1   msaitoh  * Configure Priority Flow Control for each traffic class.
    590   1.1   msaitoh  */
    591   1.1   msaitoh s32 ixgbe_dcb_config_pfc_cee(struct ixgbe_hw *hw,
    592   1.1   msaitoh 			 struct ixgbe_dcb_config *dcb_config)
    593   1.1   msaitoh {
    594   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    595   1.1   msaitoh 	u8 pfc_en;
    596   1.1   msaitoh 	u8 map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
    597   1.1   msaitoh 
    598   1.1   msaitoh 	ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_TX_CONFIG, map);
    599   1.1   msaitoh 	ixgbe_dcb_unpack_pfc_cee(dcb_config, map, &pfc_en);
    600   1.1   msaitoh 
    601   1.1   msaitoh 	switch (hw->mac.type) {
    602   1.1   msaitoh 	case ixgbe_mac_82598EB:
    603   1.1   msaitoh 		ret = ixgbe_dcb_config_pfc_82598(hw, pfc_en);
    604   1.1   msaitoh 		break;
    605   1.1   msaitoh 	case ixgbe_mac_82599EB:
    606   1.1   msaitoh 	case ixgbe_mac_X540:
    607   1.2   msaitoh 	case ixgbe_mac_X550:
    608   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    609   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    610   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    611   1.1   msaitoh 		ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map);
    612   1.1   msaitoh 		break;
    613   1.1   msaitoh #endif
    614   1.1   msaitoh 	default:
    615   1.1   msaitoh 		break;
    616   1.1   msaitoh 	}
    617   1.1   msaitoh 	return ret;
    618   1.1   msaitoh }
    619   1.1   msaitoh 
    620   1.1   msaitoh /**
    621   1.1   msaitoh  * ixgbe_dcb_config_tc_stats - Config traffic class statistics
    622   1.1   msaitoh  * @hw: pointer to hardware structure
    623   1.1   msaitoh  *
    624   1.1   msaitoh  * Configure queue statistics registers, all queues belonging to same traffic
    625   1.1   msaitoh  * class uses a single set of queue statistics counters.
    626   1.1   msaitoh  */
    627   1.1   msaitoh s32 ixgbe_dcb_config_tc_stats(struct ixgbe_hw *hw)
    628   1.1   msaitoh {
    629   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    630   1.1   msaitoh 	switch (hw->mac.type) {
    631   1.1   msaitoh 	case ixgbe_mac_82598EB:
    632   1.1   msaitoh 		ret = ixgbe_dcb_config_tc_stats_82598(hw);
    633   1.1   msaitoh 		break;
    634   1.1   msaitoh 	case ixgbe_mac_82599EB:
    635   1.1   msaitoh 	case ixgbe_mac_X540:
    636   1.2   msaitoh 	case ixgbe_mac_X550:
    637   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    638   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    639   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    640   1.1   msaitoh 		ret = ixgbe_dcb_config_tc_stats_82599(hw, NULL);
    641   1.1   msaitoh 		break;
    642   1.1   msaitoh #endif
    643   1.1   msaitoh 	default:
    644   1.1   msaitoh 		break;
    645   1.1   msaitoh 	}
    646   1.1   msaitoh 	return ret;
    647   1.1   msaitoh }
    648   1.1   msaitoh 
    649   1.1   msaitoh /**
    650   1.1   msaitoh  * ixgbe_dcb_hw_config_cee - Config and enable DCB
    651   1.1   msaitoh  * @hw: pointer to hardware structure
    652   1.1   msaitoh  * @dcb_config: pointer to ixgbe_dcb_config structure
    653   1.1   msaitoh  *
    654   1.1   msaitoh  * Configure dcb settings and enable dcb mode.
    655   1.1   msaitoh  */
    656   1.1   msaitoh s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *hw,
    657   1.1   msaitoh 			struct ixgbe_dcb_config *dcb_config)
    658   1.1   msaitoh {
    659   1.1   msaitoh 	s32 ret = IXGBE_NOT_IMPLEMENTED;
    660   1.1   msaitoh 	u8 pfc_en;
    661   1.1   msaitoh 	u8 tsa[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    662   1.1   msaitoh 	u8 bwgid[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    663   1.1   msaitoh 	u8 map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
    664   1.1   msaitoh 	u16 refill[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    665   1.1   msaitoh 	u16 max[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    666   1.1   msaitoh 
    667   1.1   msaitoh 	/* Unpack CEE standard containers */
    668   1.1   msaitoh 	ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_TX_CONFIG, refill);
    669   1.1   msaitoh 	ixgbe_dcb_unpack_max_cee(dcb_config, max);
    670   1.1   msaitoh 	ixgbe_dcb_unpack_bwgid_cee(dcb_config, IXGBE_DCB_TX_CONFIG, bwgid);
    671   1.1   msaitoh 	ixgbe_dcb_unpack_tsa_cee(dcb_config, IXGBE_DCB_TX_CONFIG, tsa);
    672   1.1   msaitoh 	ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_TX_CONFIG, map);
    673   1.1   msaitoh 
    674   1.1   msaitoh 	hw->mac.ops.setup_rxpba(hw, dcb_config->num_tcs.pg_tcs,
    675   1.1   msaitoh 				0, dcb_config->rx_pba_cfg);
    676   1.1   msaitoh 
    677   1.1   msaitoh 	switch (hw->mac.type) {
    678   1.1   msaitoh 	case ixgbe_mac_82598EB:
    679   1.1   msaitoh 		ret = ixgbe_dcb_hw_config_82598(hw, dcb_config->link_speed,
    680   1.1   msaitoh 						refill, max, bwgid, tsa);
    681   1.1   msaitoh 		break;
    682   1.1   msaitoh 	case ixgbe_mac_82599EB:
    683   1.1   msaitoh 	case ixgbe_mac_X540:
    684   1.2   msaitoh 	case ixgbe_mac_X550:
    685   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    686   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    687   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    688   1.1   msaitoh 		ixgbe_dcb_config_82599(hw, dcb_config);
    689   1.1   msaitoh 		ret = ixgbe_dcb_hw_config_82599(hw, dcb_config->link_speed,
    690   1.1   msaitoh 						refill, max, bwgid,
    691   1.1   msaitoh 						tsa, map);
    692   1.1   msaitoh 
    693   1.1   msaitoh 		ixgbe_dcb_config_tc_stats_82599(hw, dcb_config);
    694   1.1   msaitoh 		break;
    695   1.1   msaitoh #endif
    696   1.1   msaitoh 	default:
    697   1.1   msaitoh 		break;
    698   1.1   msaitoh 	}
    699   1.1   msaitoh 
    700   1.1   msaitoh 	if (!ret && dcb_config->pfc_mode_enable) {
    701   1.1   msaitoh 		ixgbe_dcb_unpack_pfc_cee(dcb_config, map, &pfc_en);
    702   1.1   msaitoh 		ret = ixgbe_dcb_config_pfc(hw, pfc_en, map);
    703   1.1   msaitoh 	}
    704   1.1   msaitoh 
    705   1.1   msaitoh 	return ret;
    706   1.1   msaitoh }
    707   1.1   msaitoh 
    708   1.1   msaitoh /* Helper routines to abstract HW specifics from DCB netlink ops */
    709   1.1   msaitoh s32 ixgbe_dcb_config_pfc(struct ixgbe_hw *hw, u8 pfc_en, u8 *map)
    710   1.1   msaitoh {
    711   1.1   msaitoh 	int ret = IXGBE_ERR_PARAM;
    712   1.1   msaitoh 
    713   1.1   msaitoh 	switch (hw->mac.type) {
    714   1.1   msaitoh 	case ixgbe_mac_82598EB:
    715   1.1   msaitoh 		ret = ixgbe_dcb_config_pfc_82598(hw, pfc_en);
    716   1.1   msaitoh 		break;
    717   1.1   msaitoh 	case ixgbe_mac_82599EB:
    718   1.1   msaitoh 	case ixgbe_mac_X540:
    719   1.2   msaitoh 	case ixgbe_mac_X550:
    720   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    721   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    722   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    723   1.1   msaitoh 		ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map);
    724   1.1   msaitoh 		break;
    725   1.1   msaitoh #endif
    726   1.1   msaitoh 	default:
    727   1.1   msaitoh 		break;
    728   1.1   msaitoh 	}
    729   1.1   msaitoh 	return ret;
    730   1.1   msaitoh }
    731   1.1   msaitoh 
    732   1.1   msaitoh s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, u16 *refill, u16 *max,
    733   1.1   msaitoh 			    u8 *bwg_id, u8 *tsa, u8 *map)
    734   1.1   msaitoh {
    735   1.1   msaitoh 	switch (hw->mac.type) {
    736   1.1   msaitoh 	case ixgbe_mac_82598EB:
    737   1.1   msaitoh 		ixgbe_dcb_config_rx_arbiter_82598(hw, refill, max, tsa);
    738   1.1   msaitoh 		ixgbe_dcb_config_tx_desc_arbiter_82598(hw, refill, max, bwg_id,
    739   1.1   msaitoh 						       tsa);
    740   1.1   msaitoh 		ixgbe_dcb_config_tx_data_arbiter_82598(hw, refill, max, bwg_id,
    741   1.1   msaitoh 						       tsa);
    742   1.1   msaitoh 		break;
    743   1.1   msaitoh 	case ixgbe_mac_82599EB:
    744   1.1   msaitoh 	case ixgbe_mac_X540:
    745   1.2   msaitoh 	case ixgbe_mac_X550:
    746   1.2   msaitoh 	case ixgbe_mac_X550EM_x:
    747   1.5   msaitoh 	case ixgbe_mac_X550EM_a:
    748   1.1   msaitoh #if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
    749   1.1   msaitoh 		ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id,
    750   1.1   msaitoh 						  tsa, map);
    751   1.1   msaitoh 		ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwg_id,
    752   1.1   msaitoh 						       tsa);
    753   1.1   msaitoh 		ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id,
    754   1.1   msaitoh 						       tsa, map);
    755   1.1   msaitoh 		break;
    756   1.1   msaitoh #endif
    757   1.1   msaitoh 	default:
    758   1.1   msaitoh 		break;
    759   1.1   msaitoh 	}
    760   1.1   msaitoh 	return 0;
    761   1.1   msaitoh }
    762