From patchwork Sun Mar 22 20:40:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 222067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0449C54FCF for ; Sun, 22 Mar 2020 20:40:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96C002072E for ; Sun, 22 Mar 2020 20:40:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="M8zYhGfR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726872AbgCVUkj (ORCPT ); Sun, 22 Mar 2020 16:40:39 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39799 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbgCVUkj (ORCPT ); Sun, 22 Mar 2020 16:40:39 -0400 Received: by mail-pg1-f196.google.com with SMTP id b22so6070565pgb.6 for ; Sun, 22 Mar 2020 13:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bZjbiiryPsuV5407y2y4uhlZU+VQ5S03KD4rXypyGHo=; b=M8zYhGfROvusxCsdULXOH/8t6ZHsueIOj0G/coE/Bn8i8MnE3jDCyOinwZac+CN5/S fcllK92fg/6dp2dLnh1ewnBVo+inltGWFsyIgLbyDpP4/SjP9xBSd+1B0rKhnNRVTudb Wz+T4+/qxG6SlsYnJu2nEXH3YX94kZ/d+hLDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bZjbiiryPsuV5407y2y4uhlZU+VQ5S03KD4rXypyGHo=; b=eV8m3tMkWr/PPZMNEmw5xAXhoyGQ0kgyJgV3vclg7Te4PUkX3yDw/lx+0jp1tHH8qj VEREiv9ErSyReab+EtS3w9w12+rPDtPs00pbVDIUrsJu+mI9LOJzqSYbLr0nbKEcxGb5 RYsel0WvSt0FrY7eMTO9jZfyfRtaobe/azKStvarx8HOAGmtCRwkWs7Pqe84Qkfueuh+ 88PMjB6TDuoOD3yo44isdpjUK87IiSmij5QE1DAM6QJIk8zG2RG6IbJi9ZdrIxJA/yN4 rreNX1l+9+OOSaMUayaxm2qWTZpsp75w/mJCucydEEynZMzg3udX57ofyUEMLHVvge+J xesg== X-Gm-Message-State: ANhLgQ3nfJyiloEjOD2TdIglrrGTNWVZuYYlO+wii6JFL4xXxZsacwNF HPylS0SPM9VNWiTsU6t/9+uhHF34yjg= X-Google-Smtp-Source: ADFU+vsM2sD7X6RejFG9/suEk54cCDYYChFwyhbyLo5rX6yDQhdfsz+c4hFTgW4o3xiILb4HgwZ21w== X-Received: by 2002:a05:6a00:48:: with SMTP id i8mr21788676pfk.20.1584909637716; Sun, 22 Mar 2020 13:40:37 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.com ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y131sm11575843pfb.78.2020.03.22.13.40.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2020 13:40:37 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org Subject: [PATCH net 1/5] bnxt_en: Fix Priority Bytes and Packets counters in ethtool -S. Date: Sun, 22 Mar 2020 16:40:01 -0400 Message-Id: <1584909605-19161-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584909605-19161-1-git-send-email-michael.chan@broadcom.com> References: <1584909605-19161-1-git-send-email-michael.chan@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is an indexing bug in determining these ethtool priority counters. Instead of using the queue ID to index, we need to normalize by modulo 10 to get the index. This index is then used to obtain the proper CoS queue counter. Rename bp->pri2cos to bp->pri2cos_idx to make this more clear. Fixes: e37fed790335 ("bnxt_en: Add ethtool -S priority counters.") Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c5c8eff..b66ee1d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7406,14 +7406,22 @@ static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp) pri2cos = &resp2->pri0_cos_queue_id; for (i = 0; i < 8; i++) { u8 queue_id = pri2cos[i]; + u8 queue_idx; + /* Per port queue IDs start from 0, 10, 20, etc */ + queue_idx = queue_id % 10; + if (queue_idx > BNXT_MAX_QUEUE) { + bp->pri2cos_valid = false; + goto qstats_done; + } for (j = 0; j < bp->max_q; j++) { if (bp->q_ids[j] == queue_id) - bp->pri2cos[i] = j; + bp->pri2cos_idx[i] = queue_idx; } } bp->pri2cos_valid = 1; } +qstats_done: mutex_unlock(&bp->hwrm_cmd_lock); return rc; } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index cabef0b..63b1706 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1716,7 +1716,7 @@ struct bnxt { u16 fw_rx_stats_ext_size; u16 fw_tx_stats_ext_size; u16 hw_ring_stats_size; - u8 pri2cos[8]; + u8 pri2cos_idx[8]; u8 pri2cos_valid; u16 hwrm_max_req_len; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 1f67e67..3f8a1de 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -589,25 +589,25 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, if (bp->pri2cos_valid) { for (i = 0; i < 8; i++, j++) { long n = bnxt_rx_bytes_pri_arr[i].base_off + - bp->pri2cos[i]; + bp->pri2cos_idx[i]; buf[j] = le64_to_cpu(*(rx_port_stats_ext + n)); } for (i = 0; i < 8; i++, j++) { long n = bnxt_rx_pkts_pri_arr[i].base_off + - bp->pri2cos[i]; + bp->pri2cos_idx[i]; buf[j] = le64_to_cpu(*(rx_port_stats_ext + n)); } for (i = 0; i < 8; i++, j++) { long n = bnxt_tx_bytes_pri_arr[i].base_off + - bp->pri2cos[i]; + bp->pri2cos_idx[i]; buf[j] = le64_to_cpu(*(tx_port_stats_ext + n)); } for (i = 0; i < 8; i++, j++) { long n = bnxt_tx_pkts_pri_arr[i].base_off + - bp->pri2cos[i]; + bp->pri2cos_idx[i]; buf[j] = le64_to_cpu(*(tx_port_stats_ext + n)); } From patchwork Sun Mar 22 20:40:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 222066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CEF1C54EEB for ; Sun, 22 Mar 2020 20:40:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 089852076E for ; Sun, 22 Mar 2020 20:40:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Zy5jMdh0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgCVUkn (ORCPT ); Sun, 22 Mar 2020 16:40:43 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39297 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbgCVUkm (ORCPT ); Sun, 22 Mar 2020 16:40:42 -0400 Received: by mail-pf1-f193.google.com with SMTP id d25so6404417pfn.6 for ; Sun, 22 Mar 2020 13:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T9HVlQ8lTXeZ2isQQq1S688+mHKaEmwWE+YdSKsQQhU=; b=Zy5jMdh0IO1ryc8b+vaKRxMjd/IEVKi/XGx6hpz5t+QHhugIWmXiK3joCvIuIbZ/CR 3HbgY3KHkF+SKV4ts+16LUiRe+aW7oSrB4jhRKrM0ASQJVR+hd2ZVTBGz0EfEddskqdt thAHGMjfQPNjaaKP/BYK0LOyneYgGDpSNvG+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T9HVlQ8lTXeZ2isQQq1S688+mHKaEmwWE+YdSKsQQhU=; b=T0Fbos8NFItetImRLgZNThvMbPG8D2jL94uC+T0bMT1ksHVXcWZKZdtBundQUmIm5B OPRvqx9cRMuphGFil/VUCEcjd9rOGH3iUdBop7lJsLcLUy+zkt2xhS/0fMgLMQJxTKwo +VKr+buaDNXAAS5MV4gAi9e3hx0CTdhWNhni3l/tck4un5HAw9QUcYZ6fMYujPVyMuzA o7Xq8cHfnP/cef1s6+NmiLa0IJViYJsjKyJhoxaGo1tNWKD1YsP2iN3eId/LTdVp9iBr LGbUbHMhWyH7I/e1CAJUZzxcmpjIdX6bc/94IfKJKvnKi2HwbxUFdPu5pCdZKpGWMAfv FZAg== X-Gm-Message-State: ANhLgQ1uOtS2fk43a2arpVmZ6h7+VqsMIz6VZQPxLPzO61Pwfd6tBXHc kdSlVtQGxwquhztNimXOyoyKrc8eewI= X-Google-Smtp-Source: ADFU+vtH/4U8i3ur+B6hb6Y3J3f1PV431OLLRx5oAMWxRGKL0o/0Z5FiFHzYo0F8zPiCMK0n6Jao+w== X-Received: by 2002:a63:f447:: with SMTP id p7mr18822607pgk.326.1584909641873; Sun, 22 Mar 2020 13:40:41 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.com ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y131sm11575843pfb.78.2020.03.22.13.40.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2020 13:40:41 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org Subject: [PATCH net 3/5] bnxt_en: Return error if bnxt_alloc_ctx_mem() fails. Date: Sun, 22 Mar 2020 16:40:03 -0400 Message-Id: <1584909605-19161-4-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584909605-19161-1-git-send-email-michael.chan@broadcom.com> References: <1584909605-19161-1-git-send-email-michael.chan@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The current code ignores the return value from bnxt_hwrm_func_backing_store_cfg(), causing the driver to proceed in the init path even when this vital firmware call has failed. Fix it by propagating the error code to the caller. Fixes: 1b9394e5a2ad ("bnxt_en: Configure context memory on new devices.") Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b66ee1d..0628a6a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6880,12 +6880,12 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp) } ena |= FUNC_BACKING_STORE_CFG_REQ_DFLT_ENABLES; rc = bnxt_hwrm_func_backing_store_cfg(bp, ena); - if (rc) + if (rc) { netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", rc); - else - ctx->flags |= BNXT_CTX_FLAG_INITED; - + return rc; + } + ctx->flags |= BNXT_CTX_FLAG_INITED; return 0; } From patchwork Sun Mar 22 20:40:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 222065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AC83C54EEB for ; Sun, 22 Mar 2020 20:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E14092072E for ; Sun, 22 Mar 2020 20:40:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="M7zDEUTX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbgCVUkt (ORCPT ); Sun, 22 Mar 2020 16:40:49 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39302 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbgCVUkr (ORCPT ); Sun, 22 Mar 2020 16:40:47 -0400 Received: by mail-pf1-f196.google.com with SMTP id d25so6404469pfn.6 for ; Sun, 22 Mar 2020 13:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qJJIJbYykf2eHlSy5B60H3/FaIsyaz1PfOiIJOMOPE8=; b=M7zDEUTXvKKhzjXXIL5sVT6tln/tu9kDTDeIVpZtVSZ+jr5G6s7ztjggNxAZye4mrq Wx0+/ihZ4I+6hAAl/9Pj9hzP/U+XNGZpohBY+FkfS8eLdbcH88K57CjYMR7VNBvyCIWI yd/J7mmygT+LG9cyLAdseBAv4iA1L/uJdZgww= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qJJIJbYykf2eHlSy5B60H3/FaIsyaz1PfOiIJOMOPE8=; b=k/je+Dx8LbgBfdhxmTNSx0pRtmGjUUTJlN8TN8QjjXNI5ukdPi2gGVd0A2orsTUc83 iJbBSkIL3OBMHd30O0JN9tFjMMq9mcs6NVtaUtnlFzktB5waolObWwdD4n+TUjHW1qRA zUDng3DZ7W1y1XhOBKawGepkFGj48bUHoxccIuJ2Qt4KSS9QhL4gul5KCE1RwgeJfg6u p0d8sd6NY9e0tkikri6JnDN1wp/OnmulwWJUANeWIIEQfM73qSb8LYuOKZqgWyY9kYlD TO01OTnXSc4pmJmJfdFIrXoeciCajra3+E6/FvwOeCFqYrQyl/V1IluIETSc0uqCHbJ5 DEGQ== X-Gm-Message-State: ANhLgQ29gFDZWcHGeSe3KWSNaBAgmz+MP43G+lpyFeKUpWLV4aqb8kCp RyaMXLc489xrPXQbYO183c/p8HKEE+c= X-Google-Smtp-Source: ADFU+vvS7wIJ1S28avU0NKSLn7HHjwdeFwLoHRkXBiJYIQGnO69ce9+/gk5uaNqhQEFl6euvFAfA+A== X-Received: by 2002:a63:cb4a:: with SMTP id m10mr18816271pgi.259.1584909645974; Sun, 22 Mar 2020 13:40:45 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.com ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y131sm11575843pfb.78.2020.03.22.13.40.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2020 13:40:45 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org Subject: [PATCH net 5/5] bnxt_en: Reset rings if ring reservation fails during open() Date: Sun, 22 Mar 2020 16:40:05 -0400 Message-Id: <1584909605-19161-6-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584909605-19161-1-git-send-email-michael.chan@broadcom.com> References: <1584909605-19161-1-git-send-email-michael.chan@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vasundhara Volam If ring counts are not reset when ring reservation fails, bnxt_init_dflt_ring_mode() will not be called again to reinitialise IRQs when open() is called and results in system crash as napi will also be not initialised. This patch fixes it by resetting the ring counts. Fixes: 47558acd56a7 ("bnxt_en: Reserve rings at driver open if none was reserved at probe time.") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 95f4c02..d28b406 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -11677,6 +11677,10 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) bp->rx_nr_rings++; bp->cp_nr_rings++; } + if (rc) { + bp->tx_nr_rings = 0; + bp->rx_nr_rings = 0; + } return rc; }