Skip to content

Commit b356dac

Browse files
mawilli1Jeff Kirsher
authored andcommitted
i40e: avoid divide by zero
In some weird circumstances with DCB enabled, the firmware can fail to configure the VSI, leaving us with zero traffic classes. Check for this state when we configure RSS to avoid a panic. Signed-off-by: Mitch Williams <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent e3a5d6e commit b356dac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10783,8 +10783,13 @@ static int i40e_pf_config_rss(struct i40e_pf *pf)
1078310783
/* Determine the RSS size of the VSI */
1078410784
if (!vsi->rss_size) {
1078510785
u16 qcount;
10786-
10787-
qcount = vsi->num_queue_pairs / vsi->tc_config.numtc;
10786+
/* If the firmware does something weird during VSI init, we
10787+
* could end up with zero TCs. Check for that to avoid
10788+
* divide-by-zero. It probably won't pass traffic, but it also
10789+
* won't panic.
10790+
*/
10791+
qcount = vsi->num_queue_pairs /
10792+
(vsi->tc_config.numtc ? vsi->tc_config.numtc : 1);
1078810793
vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount);
1078910794
}
1079010795
if (!vsi->rss_size)

0 commit comments

Comments
 (0)