aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Williams <mitch.a.williams@intel.com>2017-12-18 05:15:25 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-01-23 14:29:19 -0500
commitb356dac8ab9e5e5954e550f2e2501b28511e90b8 (patch)
treeb88a09d8ddcff0b3c0b3d1933be1776d07aac101
parente3a5d6e6fa8aae99f12f181597d065ae2ecf768d (diff)
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 <mitch.a.williams@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index e29d42c67fa9..db7dd812c1df 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -10783,8 +10783,13 @@ static int i40e_pf_config_rss(struct i40e_pf *pf)
10783 /* Determine the RSS size of the VSI */ 10783 /* Determine the RSS size of the VSI */
10784 if (!vsi->rss_size) { 10784 if (!vsi->rss_size) {
10785 u16 qcount; 10785 u16 qcount;
10786 10786 /* If the firmware does something weird during VSI init, we
10787 qcount = vsi->num_queue_pairs / vsi->tc_config.numtc; 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);
10788 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount); 10793 vsi->rss_size = min_t(int, pf->alloc_rss_size, qcount);
10789 } 10794 }
10790 if (!vsi->rss_size) 10795 if (!vsi->rss_size)