Skip to content

Commit fbfe12c

Browse files
dmertmanJeff Kirsher
authored andcommitted
i40e: check for and deal with non-contiguous TCs
The i40e driver was causing a kernel panic when non-contiguous Traffic Classes, or Traffic Classes not starting with TC0, were configured on a link partner switch. i40e does not support non-contiguous TCs. To fix this, the patch changes the logic when determining the total number of TCs enabled. Before, this would use the highest TC number enabled and assume that all TCs below it were also enabled. Now, we create a bitmask of enabled TCs and scan it to determine not only the number of TCs, but also if the set of enabled TCs starts at zero and is contiguous. If not, then DCB is disabled by only returning one TC. Signed-off-by: Dave Ertman <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 3d95182 commit fbfe12c

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4554,23 +4554,38 @@ static u8 i40e_get_iscsi_tc_map(struct i40e_pf *pf)
45544554
**/
45554555
static u8 i40e_dcb_get_num_tc(struct i40e_dcbx_config *dcbcfg)
45564556
{
4557+
int i, tc_unused = 0;
45574558
u8 num_tc = 0;
4558-
int i;
4559+
u8 ret = 0;
45594560

45604561
/* Scan the ETS Config Priority Table to find
45614562
* traffic class enabled for a given priority
4562-
* and use the traffic class index to get the
4563-
* number of traffic classes enabled
4563+
* and create a bitmask of enabled TCs
45644564
*/
4565-
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
4566-
if (dcbcfg->etscfg.prioritytable[i] > num_tc)
4567-
num_tc = dcbcfg->etscfg.prioritytable[i];
4568-
}
4565+
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
4566+
num_tc |= BIT(dcbcfg->etscfg.prioritytable[i]);
45694567

4570-
/* Traffic class index starts from zero so
4571-
* increment to return the actual count
4568+
/* Now scan the bitmask to check for
4569+
* contiguous TCs starting with TC0
45724570
*/
4573-
return num_tc + 1;
4571+
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
4572+
if (num_tc & BIT(i)) {
4573+
if (!tc_unused) {
4574+
ret++;
4575+
} else {
4576+
pr_err("Non-contiguous TC - Disabling DCB\n");
4577+
return 1;
4578+
}
4579+
} else {
4580+
tc_unused = 1;
4581+
}
4582+
}
4583+
4584+
/* There is always at least TC0 */
4585+
if (!ret)
4586+
ret = 1;
4587+
4588+
return ret;
45744589
}
45754590

45764591
/**

0 commit comments

Comments
 (0)