From patchwork Tue Mar 14 14:24:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 738724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vjH7r4dK7z9ryT; Wed, 15 Mar 2017 01:25:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="VmyKtgVe"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1cnnNo-0004fm-Jt; Tue, 14 Mar 2017 14:25:04 +0000 Received: from mail-io0-f179.google.com ([209.85.223.179]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1cnnNg-0004du-V0 for kernel-team@lists.ubuntu.com; Tue, 14 Mar 2017 14:24:57 +0000 Received: by mail-io0-f179.google.com with SMTP id b140so307077iof.1 for ; Tue, 14 Mar 2017 07:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=BI622c8GWxQR7WhDJZn9ykjnkyZ+l/mjGv9g/owSmC0=; b=VmyKtgVeY6pfJ0oWWWzz+aQYJ4Pr1iEew5ek9M6s1Gwo+4i2Nfx5cGcGKkOit7/hc6 9qrOzune4Pd2YVhAEfbfaxcXCUaf0P/6ksg4VsrP79rzHxj4yeMjmfKSbp0uD/2HkE3t MmyncOSaivtHm8MNnxOjYtlTdZWjO/pLdTexwFdY4gQXJ8DFfbwLUw2x2MVeiX3XaYTQ 9pNH5u5SFh8P3yOgePx4quzNVamkiW3ZMxLTX7WEa6qriaogW4zo+VA9Myag18zRxhlI FJXXEPAwwuOwORMO87NPs441kWQ++wuO9ZJW7AQVYLt4ooz0gStxI3iY6m9AugL/cHiC 3fug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=BI622c8GWxQR7WhDJZn9ykjnkyZ+l/mjGv9g/owSmC0=; b=K4t2QwommXwkIwe0wO6rY+Tj7O88cibPQtVpVB7XB5QOadYJ/BjP+iqUKKKyo8VT6C 9jUaI4/Up2Ae3M8dldBaBOPlW+Pe3fgWgJLLd1/1jn8fVB2ExOAIU+gE3scbzTvmigjr aYsbZYNBrU6JVU5LSi6/UqATiYerdKoBaEhV+NbWnpkcCi1oApIFAC05WWWXVBPcWdpS UT1mP9WzbzJbGU+zxnYqqsG0667WsR2nzyfrFAxmstnS34pAxYG2hWihdzTAQm+WyXsd OHEfZz1jMMFRpftumI7NCGDCDku/MMwhDxmsmOK6ejl9Rm3Lrr4lX0YncevW86JRL1cZ xpOQ== X-Gm-Message-State: AFeK/H2+EsnG3trYBfxyj03k/IOpBfgUboSkseN5THyOKXbgs+h61riiE+MQYvkejtE4sRBU X-Received: by 10.107.57.68 with SMTP id g65mr101785ioa.118.1489501495399; Tue, 14 Mar 2017 07:24:55 -0700 (PDT) Received: from localhost ([2605:a601:aa7:8220:d525:2d8c:d0b4:d509]) by smtp.gmail.com with ESMTPSA id t90sm16069ioi.31.2017.03.14.07.24.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 07:24:54 -0700 (PDT) From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [PATCH][Xenial SRU] i40e: check for and deal with non-contiguous TCs Date: Tue, 14 Mar 2017 09:24:54 -0500 Message-Id: <1489501494-44001-1-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Dave Ertman BugLink: http://bugs.launchpad.net/bugs/1672550 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 Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher (cherry picked from commit fbfe12c64f9650aa22f434dd9dd22df7ddf63221) Signed-off-by: Seth Forshee --- drivers/net/ethernet/intel/i40e/i40e_main.c | 35 ++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 49d405036bcf..8a252cd7a1bc 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -4509,23 +4509,38 @@ static u8 i40e_get_iscsi_tc_map(struct i40e_pf *pf) **/ static u8 i40e_dcb_get_num_tc(struct i40e_dcbx_config *dcbcfg) { + int i, tc_unused = 0; u8 num_tc = 0; - int i; + u8 ret = 0; /* Scan the ETS Config Priority Table to find * traffic class enabled for a given priority - * and use the traffic class index to get the - * number of traffic classes enabled + * and create a bitmask of enabled TCs */ - for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) { - if (dcbcfg->etscfg.prioritytable[i] > num_tc) - num_tc = dcbcfg->etscfg.prioritytable[i]; - } + for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) + num_tc |= BIT(dcbcfg->etscfg.prioritytable[i]); - /* Traffic class index starts from zero so - * increment to return the actual count + /* Now scan the bitmask to check for + * contiguous TCs starting with TC0 */ - return num_tc + 1; + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { + if (num_tc & BIT(i)) { + if (!tc_unused) { + ret++; + } else { + pr_err("Non-contiguous TC - Disabling DCB\n"); + return 1; + } + } else { + tc_unused = 1; + } + } + + /* There is always at least TC0 */ + if (!ret) + ret = 1; + + return ret; } /**