aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2012-05-24 21:45:38 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-07-21 19:05:28 -0400
commitb92ad72dea9925359e9dfa70c4cbf8db6f1b2d65 (patch)
tree2ad2f30991a2d630ad0db895dda95d8237bc582f
parent252562c207a850106d9d5b41a41d29f96c0530b7 (diff)
ixgbe: Use num_tcs.pg_tcs as upper limit for TC when checking based on UP
This change makes it so the function ixgbe_dcb_get_tc_from_up will use the num_tcs.pg_tcs to determine the starting value for determining a traffic class based on a user priority. The main motivation for this change is to address possible bad configurations in which more TCs worth of data are populated then there are actual TCs. By limiting this value we can at least make certain we are not providing a map with values that are out of range. As a result any user priorities that are setup in the configuration with a traffic class mapping higher than what the hardware supports will be reported as being on TC 0. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Acked-by: Greg Rose <gregory.v.rose@intel.com> Tested-by: Stephen Ko <stephen.s.ko@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c
index 5442b359141e..9bc17c0cb972 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c
@@ -232,18 +232,22 @@ u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg, int direction, u8 up)
232{ 232{
233 struct tc_configuration *tc_config = &cfg->tc_config[0]; 233 struct tc_configuration *tc_config = &cfg->tc_config[0];
234 u8 prio_mask = 1 << up; 234 u8 prio_mask = 1 << up;
235 u8 tc; 235 u8 tc = cfg->num_tcs.pg_tcs;
236
237 /* If tc is 0 then DCB is likely not enabled or supported */
238 if (!tc)
239 goto out;
236 240
237 /* 241 /*
238 * Test for TCs 7 through 1 and report the first match we find. If 242 * Test from maximum TC to 1 and report the first match we find. If
239 * we find no match we can assume that the TC is 0 since the TC must 243 * we find no match we can assume that the TC is 0 since the TC must
240 * be set for all user priorities 244 * be set for all user priorities
241 */ 245 */
242 for (tc = MAX_TRAFFIC_CLASS - 1; tc; tc--) { 246 for (tc--; tc; tc--) {
243 if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap) 247 if (prio_mask & tc_config[tc].path[direction].up_to_tc_bitmap)
244 break; 248 break;
245 } 249 }
246 250out:
247 return tc; 251 return tc;
248} 252}
249 253