1 /*******************************************************************************
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
31 #include "ixgbe_type.h"
32 #include "ixgbe_dcb.h"
33 #include "ixgbe_dcb_82598.h"
34 #include "ixgbe_dcb_82599.h"
37 * ixgbe_dcb_calculate_tc_credits - Calculates traffic class credits
38 * @ixgbe_dcb_config: Struct containing DCB settings.
39 * @direction: Configuring either Tx or Rx.
41 * This function calculates the credits allocated to each traffic class.
42 * It should be called only after the rules are checked by
43 * ixgbe_dcb_check_config().
45 s32
ixgbe_dcb_calculate_tc_credits(struct ixgbe_dcb_config
*dcb_config
,
48 struct tc_bw_alloc
*p
;
50 /* Initialization values default for Tx settings */
51 u32 credit_refill
= 0;
53 u16 link_percentage
= 0;
57 if (dcb_config
== NULL
) {
58 ret_val
= DCB_ERR_CONFIG
;
62 /* Find out the link percentage for each TC first */
63 for (i
= 0; i
< MAX_TRAFFIC_CLASS
; i
++) {
64 p
= &dcb_config
->tc_config
[i
].path
[direction
];
65 bw_percent
= dcb_config
->bw_percentage
[direction
][p
->bwg_id
];
67 link_percentage
= p
->bwg_percent
;
68 /* Must be careful of integer division for very small nums */
69 link_percentage
= (link_percentage
* bw_percent
) / 100;
70 if (p
->bwg_percent
> 0 && link_percentage
== 0)
73 /* Save link_percentage for reference */
74 p
->link_percent
= (u8
)link_percentage
;
76 /* Calculate credit refill and save it */
77 credit_refill
= link_percentage
* MINIMUM_CREDIT_REFILL
;
78 p
->data_credits_refill
= (u16
)credit_refill
;
80 /* Calculate maximum credit for the TC */
81 credit_max
= (link_percentage
* MAX_CREDIT
) / 100;
84 * Adjustment based on rule checking, if the percentage
85 * of a TC is too small, the maximum credit may not be
86 * enough to send out a jumbo frame in data plane arbitration.
88 if (credit_max
&& (credit_max
< MINIMUM_CREDIT_FOR_JUMBO
))
89 credit_max
= MINIMUM_CREDIT_FOR_JUMBO
;
91 if (direction
== DCB_TX_CONFIG
) {
93 * Adjustment based on rule checking, if the
94 * percentage of a TC is too small, the maximum
95 * credit may not be enough to send out a TSO
96 * packet in descriptor plane arbitration.
99 (credit_max
< MINIMUM_CREDIT_FOR_TSO
))
100 credit_max
= MINIMUM_CREDIT_FOR_TSO
;
102 dcb_config
->tc_config
[i
].desc_credits_max
=
106 p
->data_credits_max
= (u16
)credit_max
;
114 * ixgbe_dcb_hw_config - Config and enable DCB
115 * @hw: pointer to hardware structure
116 * @dcb_config: pointer to ixgbe_dcb_config structure
118 * Configure dcb settings and enable dcb mode.
120 s32
ixgbe_dcb_hw_config(struct ixgbe_hw
*hw
,
121 struct ixgbe_dcb_config
*dcb_config
)
124 if (hw
->mac
.type
== ixgbe_mac_82598EB
)
125 ret
= ixgbe_dcb_hw_config_82598(hw
, dcb_config
);
126 else if (hw
->mac
.type
== ixgbe_mac_82599EB
)
127 ret
= ixgbe_dcb_hw_config_82599(hw
, dcb_config
);
This page took 0.039413 seconds and 5 git commands to generate.