From patchwork Tue Mar 30 19:52:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12173607 X-Patchwork-Delegate: kuba@kernel.org 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 473CBC433E0 for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 112CE619B9 for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233291AbhC3Twj (ORCPT ); Tue, 30 Mar 2021 15:52:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233250AbhC3Tw1 (ORCPT ); Tue, 30 Mar 2021 15:52:27 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA736C061574 for ; Tue, 30 Mar 2021 12:52:27 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so10021657pjh.1 for ; Tue, 30 Mar 2021 12:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hjp36YVQCEN7242R32qoUQEFP1Ou+GKP/PepmS7kURk=; b=yoTAgZo+jNjxSGoWOm12m/8bg87JncPigxtUuZMammWqWIwWExHqsGbPZ0fbpSInkh pPh0HEWml2pI3X3Ng83ltW8zrZX7fd05Z3MZRPGe+Aetg9S1sTV4tNfn/rPMhGMMizEX UlQT2evX3EWJ4O1cMwzXcsHjnUGcNwwu+L/GQlTfUNosYvfeiVo6/FFwC4II/Na4cqez fqUcvJDsFIc2Lq+AAiwnUrIZW1+NvnEgJzWh5Of+3Pz6nmeO6mxvA368ilvHuC05783b oEvPaun6QqmjLUEKuAhv0GJ9PFMuAAfQnHWLlZRb+4nNNspYaQ4UvXujB5A78VnrR11G cBMw== 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=Hjp36YVQCEN7242R32qoUQEFP1Ou+GKP/PepmS7kURk=; b=EKfe9euvnZBL7zH8O67gHP4VsVFRH79mQVEngURs5VBotmnf/Lc7Fg/69ddkj7Vbve N/WqNAiJXkzUpaYGt6fMUjbtWSzxXSapaKQl5+4U/DLGAaoePkOB11n3w9Pzl3KzDNxR 3V8r3npvNPrj92g68fYvHMZks8Ul8TWBJKkRCJPxGYkG1rtaDphjdJGZxa+KP//QVhCX fOVd6Lc2H4btOFy3zK/GUPfr4i38NCyUBynzFxVOVkjScM7sLX1/lduCSaL83ineUfRi Tc4bcv2A054eaxdN4p3RIZWnlurnuhl/7AJAtDAS85hghZ79411Zhz1u0XdcFmF7PLGi Bmlg== X-Gm-Message-State: AOAM531n11gtdMqxbnimTQ2lz4Z700Hv1alYbelyPXfMJlbe0MS++r5f GmOP2gOElifMUysNkn+3L1okaavfoyQJ3g== X-Google-Smtp-Source: ABdhPJxBxqorvWLhaqNjxRavH3e1zeAZbip16WKQrv7taN3Vwk+2FwgUkjDBvMivlUDzJccek2X3Nw== X-Received: by 2002:a17:90a:8c86:: with SMTP id b6mr7095pjo.8.1617133946796; Tue, 30 Mar 2021 12:52:26 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id y8sm20433pge.56.2021.03.30.12.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 12:52:26 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net-next 1/4] ionic: count dma errors Date: Tue, 30 Mar 2021 12:52:07 -0700 Message-Id: <20210330195210.49069-2-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210330195210.49069-1-snelson@pensando.io> References: <20210330195210.49069-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Increment our dma-error counter in a couple of spots that were missed before. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 5985f7c504a9..42d29cd2ca47 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -609,6 +609,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb, struct ionic_desc_info *desc_info) { struct ionic_buf_info *buf_info = desc_info->bufs; + struct ionic_tx_stats *stats = q_to_tx_stats(q); struct device *dev = q->dev; dma_addr_t dma_addr; unsigned int nfrags; @@ -616,8 +617,10 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb, int frag_idx; dma_addr = ionic_tx_map_single(q, skb->data, skb_headlen(skb)); - if (dma_mapping_error(dev, dma_addr)) + if (dma_mapping_error(dev, dma_addr)) { + stats->dma_map_err++; return -EIO; + } buf_info->dma_addr = dma_addr; buf_info->len = skb_headlen(skb); buf_info++; @@ -626,8 +629,10 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb, nfrags = skb_shinfo(skb)->nr_frags; for (frag_idx = 0; frag_idx < nfrags; frag_idx++, frag++) { dma_addr = ionic_tx_map_frag(q, frag, 0, skb_frag_size(frag)); - if (dma_mapping_error(dev, dma_addr)) + if (dma_mapping_error(dev, dma_addr)) { + stats->dma_map_err++; goto dma_fail; + } buf_info->dma_addr = dma_addr; buf_info->len = skb_frag_size(frag); buf_info++; From patchwork Tue Mar 30 19:52:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12173605 X-Patchwork-Delegate: kuba@kernel.org 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 2CF8DC433DB for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E943E619CF for ; Tue, 30 Mar 2021 19:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233296AbhC3Twk (ORCPT ); Tue, 30 Mar 2021 15:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233283AbhC3Tw2 (ORCPT ); Tue, 30 Mar 2021 15:52:28 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BF1C061574 for ; Tue, 30 Mar 2021 12:52:28 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id y2so6708791plg.5 for ; Tue, 30 Mar 2021 12:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wtdnyZve1zf5hHise/TtlCTCKeg9DkAbAnGlNUYiSZ0=; b=Q26dtBbiwrv9B0mJTCkaFX/8xFBF53F2TXmqEqryH6hy1UGhdZDpGawXzWkplzUA5M X/NJ2piWuF0O06knWAuMlkMo7aZSBDFmblJ68cp7mcVhIfOjCw2+dHRMg2kUgSGJdtYW NGFypdqD3EUJQGn2gxqWpWmm1g7dRtHVaXScF9nyD0Dm/rMFeIgCxBsudNGuzQAai3Q+ j6QrECZOxKGAMtguNber+OOShVyWkW4RQqWqnIrVF4ZnSB+49paH2zz30kqaDKy5VWNq bVKKgEI2eJcsbTV27+AX7jRApY5fRF/4EcZZcSy85Ji14JTN5NoDNLUYj68nb0gLeTIu S78Q== 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=wtdnyZve1zf5hHise/TtlCTCKeg9DkAbAnGlNUYiSZ0=; b=m4Qjko0lnANqQHtvKWygTwM9aKvkYjUsk27jz0UfsJ/VvWQKKzIKULIqQnq36NXAMy 5Mj84grQZBp18+Z2t7WnlW/4LFD66LhR1dLc2QzdJ0WPSh5qK0/ZvCEqx5pVpOE6TZpI gn38ZDdl9ZGhVAdRhUg8cGUoCdgNPI7mtvnceEiMnunyq9q/gca0hFP3oNvMLYtqAbuJ +2fF+isWogc+mFahB010DnAISwYYse7dXUjXJcXpCmKDM71ZoVU36wRQ2uPdFdMesBB4 XqWnhJKCzBmImkqNrM1Png+4wyEaePAXNVnxwPYdqeCphf3cfQwgQM/KpkRYEbRdlxXK Dw4A== X-Gm-Message-State: AOAM530/cBAcYswEYsv3p/SzNk0aJLmLugGuBpj3Fv1Xlihws/VdF6xj 4hMd/09lWYg9oksQUbeACBhwYJ1Qwb94zw== X-Google-Smtp-Source: ABdhPJwpM8Y8/J1S8tDBb03OjMmyrugM+X1JT8WhTtPzi9U5h2OOITnYF0uDtEbCOpoc/1yQgBHenQ== X-Received: by 2002:a17:902:8c92:b029:e6:60ad:6924 with SMTP id t18-20020a1709028c92b02900e660ad6924mr34584026plo.16.1617133947757; Tue, 30 Mar 2021 12:52:27 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id y8sm20433pge.56.2021.03.30.12.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 12:52:27 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net-next 2/4] ionic: fix sizeof usage Date: Tue, 30 Mar 2021 12:52:08 -0700 Message-Id: <20210330195210.49069-3-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210330195210.49069-1-snelson@pensando.io> References: <20210330195210.49069-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use the actual pointer that we care about as the subject of the sizeof, rather than a struct name. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 889d234e2ffa..a51be25723a5 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -676,20 +676,20 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif) err = -ENOMEM; lif->txqcqs = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif, - sizeof(struct ionic_qcq *), GFP_KERNEL); + sizeof(*lif->txqcqs), GFP_KERNEL); if (!lif->txqcqs) goto err_out; lif->rxqcqs = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif, - sizeof(struct ionic_qcq *), GFP_KERNEL); + sizeof(*lif->rxqcqs), GFP_KERNEL); if (!lif->rxqcqs) goto err_out; lif->txqstats = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif, - sizeof(struct ionic_tx_stats), GFP_KERNEL); + sizeof(*lif->txqstats), GFP_KERNEL); if (!lif->txqstats) goto err_out; lif->rxqstats = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif, - sizeof(struct ionic_rx_stats), GFP_KERNEL); + sizeof(*lif->rxqstats), GFP_KERNEL); if (!lif->rxqstats) goto err_out; From patchwork Tue Mar 30 19:52:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12173609 X-Patchwork-Delegate: kuba@kernel.org 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 762B8C433E1 for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B7F6619C2 for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233305AbhC3Twl (ORCPT ); Tue, 30 Mar 2021 15:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233284AbhC3Tw3 (ORCPT ); Tue, 30 Mar 2021 15:52:29 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9401DC061574 for ; Tue, 30 Mar 2021 12:52:29 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id a12so3987532pfc.7 for ; Tue, 30 Mar 2021 12:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0OmKx8ekCG10elPwxClm7fQHkDXsDBiqxtsKwxlhAf4=; b=kcxmgKK9mbvU0M+2UKRYnyfvKF7La3NeNbI0te1oSLPlfzrisrmAXmfY2Ef/mqa/pN IFNhD4p7Hr0HNAsO9ybiPAufK1+16OXkabVXYtCIRdeH7na79duHk1tclp30QfkalrAI jmqjp7sLULQR7Z0L/4ZDvyFAemVzQzJxbzwCyFqqWlP1ZM8pRj5YiFxDZ45X3tP2Bsrs bQucXLMatDc4hboUKaPc8Q34rFX2/YNp/zGKUjvKkno/p4Hm1dloEQMsjWI3Z61DhwDT xYwV9bE0qqUzbB5L4x+F08W+tOpRzv1Vs/94gYer4qmPJ3kGP/1OY9LeT76CVeEMCizF bm3g== 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=0OmKx8ekCG10elPwxClm7fQHkDXsDBiqxtsKwxlhAf4=; b=mNDnp4aQ4Vaq0fYuGGFXZWpzfbTI9+qKVV6KjD0EIkySVqE1D7tE4Y1lnOCxhvxPo5 TOOskGRi0W6qrIiHSzIwNmEaI9sL02zvzt8nlJzQgi3BxT2MCy0r24QyzHP6N907IufU spPg94fSzlrHuPXOifTCF6sjwJZde/oApMvg8Z1LQzH8k8ZqbgT+KQG0K4AvMC0cztsZ Nq6nsVdcMzS4NistAxW/f7uG+uMBiRYg5XBFLt32/DpXbm0ENPJ8Ir2oSCFAqDDnIYqj LpuF0k/X16YCwi7v+x3EHKqtBDjgMbK/Gw7HDYUWSulpHHff8A1phD/HHCaPgcvAuEWu SEaA== X-Gm-Message-State: AOAM5326eUVL4NBmEc0kpATl3F1aGP+DpS8WduWWHYkPUqiiRitisIKa mSkcVmGuiMHmuytJ10hl3bDQLKPbHmTBmw== X-Google-Smtp-Source: ABdhPJxeT67YXA8pdBXF5TFSRJgYDpDCIJ2no8kQ2lzGDdMNjBGNbV8uWY2JkGzOnlFvSOWsv+nDhQ== X-Received: by 2002:a62:5e05:0:b029:20b:241e:4e18 with SMTP id s5-20020a625e050000b029020b241e4e18mr31634605pfb.1.1617133948808; Tue, 30 Mar 2021 12:52:28 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id y8sm20433pge.56.2021.03.30.12.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 12:52:28 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson , Allen Hubbe Subject: [PATCH net-next 3/4] ionic: avoid races in ionic_heartbeat_check Date: Tue, 30 Mar 2021 12:52:09 -0700 Message-Id: <20210330195210.49069-4-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210330195210.49069-1-snelson@pensando.io> References: <20210330195210.49069-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Rework the heartbeat checks to be sure that we're getting an atomic operation. Through testing we found occasions where a separate thread could clash with this check and cause erroneous heartbeat check results. Signed-off-by: Allen Hubbe Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.c | 93 ++++++++++++------- .../net/ethernet/pensando/ionic/ionic_dev.h | 7 +- 2 files changed, 63 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 0532f7cf086d..0e8e88c69e1c 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -24,6 +24,9 @@ static void ionic_watchdog_cb(struct timer_list *t) return; hb = ionic_heartbeat_check(ionic); + dev_dbg(ionic->dev, "%s: hb %d running %d UP %d\n", + __func__, hb, netif_running(lif->netdev), + test_bit(IONIC_LIF_F_UP, lif->state)); if (hb >= 0 && !test_bit(IONIC_LIF_F_FW_RESET, lif->state)) @@ -91,9 +94,17 @@ int ionic_dev_setup(struct ionic *ionic) return -EFAULT; } - idev->last_fw_status = 0xff; timer_setup(&ionic->watchdog_timer, ionic_watchdog_cb, 0); ionic->watchdog_period = IONIC_WATCHDOG_SECS * HZ; + + /* set times to ensure the first check will proceed */ + atomic_long_set(&idev->last_check_time, jiffies - 2 * HZ); + idev->last_hb_time = jiffies - 2 * ionic->watchdog_period; + /* init as ready, so no transition if the first check succeeds */ + idev->last_fw_hb = 0; + idev->fw_hb_ready = true; + idev->fw_status_ready = true; + mod_timer(&ionic->watchdog_timer, round_jiffies(jiffies + ionic->watchdog_period)); @@ -107,29 +118,38 @@ int ionic_dev_setup(struct ionic *ionic) int ionic_heartbeat_check(struct ionic *ionic) { struct ionic_dev *idev = &ionic->idev; - unsigned long hb_time; + unsigned long check_time, last_check_time; + bool fw_status_ready, fw_hb_ready; u8 fw_status; - u32 hb; + u32 fw_hb; - /* wait a little more than one second before testing again */ - hb_time = jiffies; - if (time_before(hb_time, (idev->last_hb_time + ionic->watchdog_period))) + /* wait a least one second before testing again */ + check_time = jiffies; + last_check_time = atomic_long_read(&idev->last_check_time); +do_check_time: + if (time_before(check_time, last_check_time + HZ)) return 0; + if (!atomic_long_try_cmpxchg_relaxed(&idev->last_check_time, + &last_check_time, check_time)) { + /* if called concurrently, only the first should proceed. */ + dev_dbg(ionic->dev, "%s: do_check_time again\n", __func__); + goto do_check_time; + } /* firmware is useful only if the running bit is set and * fw_status != 0xff (bad PCI read) */ fw_status = ioread8(&idev->dev_info_regs->fw_status); - if (fw_status != 0xff) - fw_status &= IONIC_FW_STS_F_RUNNING; /* use only the run bit */ + fw_status_ready = (fw_status != 0xff) && (fw_status & IONIC_FW_STS_F_RUNNING); /* is this a transition? */ - if (fw_status != idev->last_fw_status && - idev->last_fw_status != 0xff) { + if (fw_status_ready != idev->fw_status_ready) { struct ionic_lif *lif = ionic->lif; bool trigger = false; - if (!fw_status || fw_status == 0xff) { + idev->fw_status_ready = fw_status_ready; + + if (!fw_status_ready) { dev_info(ionic->dev, "FW stopped %u\n", fw_status); if (lif && !test_bit(IONIC_LIF_F_FW_RESET, lif->state)) trigger = true; @@ -143,44 +163,47 @@ int ionic_heartbeat_check(struct ionic *ionic) struct ionic_deferred_work *work; work = kzalloc(sizeof(*work), GFP_ATOMIC); - if (!work) { - dev_err(ionic->dev, "LIF reset trigger dropped\n"); - } else { + if (work) { work->type = IONIC_DW_TYPE_LIF_RESET; - if (fw_status & IONIC_FW_STS_F_RUNNING && - fw_status != 0xff) - work->fw_status = 1; + work->fw_status = fw_status_ready; ionic_lif_deferred_enqueue(&lif->deferred, work); } } } - idev->last_fw_status = fw_status; - if (!fw_status || fw_status == 0xff) + if (!fw_status_ready) return -ENXIO; - /* early FW has no heartbeat, else FW will return non-zero */ - hb = ioread32(&idev->dev_info_regs->fw_heartbeat); - if (!hb) + /* wait at least one watchdog period since the last heartbeat */ + last_check_time = idev->last_hb_time; + if (time_before(check_time, last_check_time + ionic->watchdog_period)) return 0; - /* are we stalled? */ - if (hb == idev->last_hb) { - /* only complain once for each stall seen */ - if (idev->last_hb_time != 1) { - dev_info(ionic->dev, "FW heartbeat stalled at %d\n", - idev->last_hb); - idev->last_hb_time = 1; - } + fw_hb = ioread32(&idev->dev_info_regs->fw_heartbeat); + fw_hb_ready = fw_hb != idev->last_fw_hb; - return -ENXIO; + /* early FW version had no heartbeat, so fake it */ + if (!fw_hb_ready && !fw_hb) + fw_hb_ready = true; + + dev_dbg(ionic->dev, "%s: fw_hb %u last_fw_hb %u ready %u\n", + __func__, fw_hb, idev->last_fw_hb, fw_hb_ready); + + idev->last_fw_hb = fw_hb; + + /* log a transition */ + if (fw_hb_ready != idev->fw_hb_ready) { + idev->fw_hb_ready = fw_hb_ready; + if (!fw_hb_ready) + dev_info(ionic->dev, "FW heartbeat stalled at %d\n", fw_hb); + else + dev_info(ionic->dev, "FW heartbeat restored at %d\n", fw_hb); } - if (idev->last_hb_time == 1) - dev_info(ionic->dev, "FW heartbeat restored at %d\n", hb); + if (!fw_hb_ready) + return -ENXIO; - idev->last_hb = hb; - idev->last_hb_time = hb_time; + idev->last_hb_time = check_time; return 0; } diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index ca7e55455165..0c0533737b2b 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -4,6 +4,7 @@ #ifndef _IONIC_DEV_H_ #define _IONIC_DEV_H_ +#include #include #include @@ -135,9 +136,11 @@ struct ionic_dev { union ionic_dev_info_regs __iomem *dev_info_regs; union ionic_dev_cmd_regs __iomem *dev_cmd_regs; + atomic_long_t last_check_time; unsigned long last_hb_time; - u32 last_hb; - u8 last_fw_status; + u32 last_fw_hb; + bool fw_hb_ready; + bool fw_status_ready; u64 __iomem *db_pages; dma_addr_t phy_db_pages; From patchwork Tue Mar 30 19:52:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12173611 X-Patchwork-Delegate: kuba@kernel.org 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 86B80C433E3 for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D806619C0 for ; Tue, 30 Mar 2021 19:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbhC3Two (ORCPT ); Tue, 30 Mar 2021 15:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233285AbhC3Twa (ORCPT ); Tue, 30 Mar 2021 15:52:30 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B281DC061574 for ; Tue, 30 Mar 2021 12:52:30 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id t18so8307241pjs.3 for ; Tue, 30 Mar 2021 12:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=igb8AFJOz2HY+uDgvmiXGk65QJUZspiuoDl3hWYoChk=; b=LM4Hq/lhNsc7MSnviK1MpvEvEaq7pufgwVUvk6zqy+YYnmFsmuwViBajON2FzFF0pB PMjZuYSXLDVuKJ1UyNsb3t/uUbppg4pDEHMvVX6dkOhVYE3tXFZDNv9LsOGWp/1+4EAk x+LPnSzVKApFCB+14j9Ydq8WYwhc8lhBeT6WB83YzawzyarAK55L6nZo2qmmoiYvBTsV cyRvWRzKxipAX+L+e6ybd0muy3nG9bzkELZ7C3w2I+mFXVfIYLN/ujf5cvaVExZSfeck sjS5aHr0eyCzJAfF8sWB7Q6TEGjZs2GRaD8Iv9KnATP+7jMgRkfeUx37CeSc7zzMQySq XgFw== 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=igb8AFJOz2HY+uDgvmiXGk65QJUZspiuoDl3hWYoChk=; b=jXRMy5MxykhStqnE9VtoDcl/N8VBGVXw69jJl2/GdihlOCws4PFL+bLgNcuq7Z6+AC b+TfWeoE8YTMnOIbO+QVtK1RyurQncLPZJZQ4wPHqZEto/iyHWZU7T/3UyiQl4qWgCKK FrbaF3RTMIKhCE3zuTlp1zVIJcQ7cZr/Q0HhY/HP/AjARofAFGZeuQPChyCMmar6Y8CN jClJGqQP+OG55GgzrM+dtNAMece2haAslJgveeCexpsn0KKrgPNcrgTNN8hZDJ44ve/a X3HAfoXWbK6Bf1xJzKNPjb1L0wkrG+gxoLfH2931L3Mt1gnnIE7E/rz8Bl4vekJQPQYM oRZw== X-Gm-Message-State: AOAM533gYUEm2diGctwf3ov7sBYT9bt1jqVXI2kCh9wsOXBtAhHRFxbF jXW9N4QAsJVFdhmrA3GFLbj3FxIBM66VEA== X-Google-Smtp-Source: ABdhPJyPVMVVFRzu7d/uPJu35xQKfsjkY5rc2JnfoOd/3P1YHGULXZKPh4r0DAOJfe5eSbUGZm2cKA== X-Received: by 2002:a17:90a:bb95:: with SMTP id v21mr6472pjr.30.1617133949890; Tue, 30 Mar 2021 12:52:29 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id y8sm20433pge.56.2021.03.30.12.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 12:52:29 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net-next 4/4] ionic: pull per-q stats work out of queue loops Date: Tue, 30 Mar 2021 12:52:10 -0700 Message-Id: <20210330195210.49069-5-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210330195210.49069-1-snelson@pensando.io> References: <20210330195210.49069-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Abstract out the per-queue data collection work into separate functions from the per-queue loops in the stats reporting, similar to what Alex did for the data label strings in commit acebe5b6107c ("ionic: Update driver to use ethtool_sprintf") Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_stats.c | 219 ++++++++++-------- 1 file changed, 125 insertions(+), 94 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c index 308b4ac6c57b..ed9cf93d9acd 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c @@ -177,31 +177,42 @@ static const struct ionic_stat_desc ionic_dbg_napi_stats_desc[] = { #define MAX_Q(lif) ((lif)->netdev->real_num_tx_queues) +static void ionic_add_lif_txq_stats(struct ionic_lif *lif, int q_num, + struct ionic_lif_sw_stats *stats) +{ + struct ionic_tx_stats *txstats = &lif->txqstats[q_num]; + + stats->tx_packets += txstats->pkts; + stats->tx_bytes += txstats->bytes; + stats->tx_tso += txstats->tso; + stats->tx_tso_bytes += txstats->tso_bytes; + stats->tx_csum_none += txstats->csum_none; + stats->tx_csum += txstats->csum; +} + +static void ionic_add_lif_rxq_stats(struct ionic_lif *lif, int q_num, + struct ionic_lif_sw_stats *stats) +{ + struct ionic_rx_stats *rxstats = &lif->rxqstats[q_num]; + + stats->rx_packets += rxstats->pkts; + stats->rx_bytes += rxstats->bytes; + stats->rx_csum_none += rxstats->csum_none; + stats->rx_csum_complete += rxstats->csum_complete; + stats->rx_csum_error += rxstats->csum_error; +} + static void ionic_get_lif_stats(struct ionic_lif *lif, struct ionic_lif_sw_stats *stats) { - struct ionic_tx_stats *txstats; - struct ionic_rx_stats *rxstats; struct rtnl_link_stats64 ns; int q_num; memset(stats, 0, sizeof(*stats)); for (q_num = 0; q_num < MAX_Q(lif); q_num++) { - txstats = &lif->txqstats[q_num]; - stats->tx_packets += txstats->pkts; - stats->tx_bytes += txstats->bytes; - stats->tx_tso += txstats->tso; - stats->tx_tso_bytes += txstats->tso_bytes; - stats->tx_csum_none += txstats->csum_none; - stats->tx_csum += txstats->csum; - - rxstats = &lif->rxqstats[q_num]; - stats->rx_packets += rxstats->pkts; - stats->rx_bytes += rxstats->bytes; - stats->rx_csum_none += rxstats->csum_none; - stats->rx_csum_complete += rxstats->csum_complete; - stats->rx_csum_error += rxstats->csum_error; + ionic_add_lif_txq_stats(lif, q_num, stats); + ionic_add_lif_rxq_stats(lif, q_num, stats); } ionic_get_stats64(lif->netdev, &ns); @@ -214,16 +225,12 @@ static void ionic_get_lif_stats(struct ionic_lif *lif, static u64 ionic_sw_stats_get_count(struct ionic_lif *lif) { - u64 total = 0; + u64 total = 0, tx_queues = MAX_Q(lif), rx_queues = MAX_Q(lif); /* lif stats */ total += IONIC_NUM_LIF_STATS; - - /* tx stats */ - total += MAX_Q(lif) * IONIC_NUM_TX_STATS; - - /* rx stats */ - total += MAX_Q(lif) * IONIC_NUM_RX_STATS; + total += tx_queues * IONIC_NUM_TX_STATS; + total += rx_queues * IONIC_NUM_RX_STATS; /* port stats */ total += IONIC_NUM_PORT_STATS; @@ -231,13 +238,13 @@ static u64 ionic_sw_stats_get_count(struct ionic_lif *lif) if (test_bit(IONIC_LIF_F_UP, lif->state) && test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) { /* tx debug stats */ - total += MAX_Q(lif) * (IONIC_NUM_DBG_CQ_STATS + + total += tx_queues * (IONIC_NUM_DBG_CQ_STATS + IONIC_NUM_TX_Q_STATS + IONIC_NUM_DBG_INTR_STATS + IONIC_MAX_NUM_SG_CNTR); /* rx debug stats */ - total += MAX_Q(lif) * (IONIC_NUM_DBG_CQ_STATS + + total += rx_queues * (IONIC_NUM_DBG_CQ_STATS + IONIC_NUM_DBG_INTR_STATS + IONIC_NUM_DBG_NAPI_STATS + IONIC_MAX_NUM_NAPI_CNTR); @@ -315,13 +322,99 @@ static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf) ionic_sw_stats_get_rx_strings(lif, buf, q_num); } +static void ionic_sw_stats_get_txq_values(struct ionic_lif *lif, u64 **buf, + int q_num) +{ + struct ionic_tx_stats *txstats; + struct ionic_qcq *txqcq; + int i; + + txstats = &lif->txqstats[q_num]; + + for (i = 0; i < IONIC_NUM_TX_STATS; i++) { + **buf = IONIC_READ_STAT64(txstats, &ionic_tx_stats_desc[i]); + (*buf)++; + } + + if (!test_bit(IONIC_LIF_F_UP, lif->state) || + !test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) + return; + + txqcq = lif->txqcqs[q_num]; + for (i = 0; i < IONIC_NUM_TX_Q_STATS; i++) { + **buf = IONIC_READ_STAT64(&txqcq->q, + &ionic_txq_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) { + **buf = IONIC_READ_STAT64(&txqcq->cq, + &ionic_dbg_cq_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) { + **buf = IONIC_READ_STAT64(&txqcq->intr, + &ionic_dbg_intr_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) { + **buf = IONIC_READ_STAT64(&txqcq->napi_stats, + &ionic_dbg_napi_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) { + **buf = txqcq->napi_stats.work_done_cntr[i]; + (*buf)++; + } + for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++) { + **buf = txstats->sg_cntr[i]; + (*buf)++; + } +} + +static void ionic_sw_stats_get_rxq_values(struct ionic_lif *lif, u64 **buf, + int q_num) +{ + struct ionic_rx_stats *rxstats; + struct ionic_qcq *rxqcq; + int i; + + rxstats = &lif->rxqstats[q_num]; + + for (i = 0; i < IONIC_NUM_RX_STATS; i++) { + **buf = IONIC_READ_STAT64(rxstats, &ionic_rx_stats_desc[i]); + (*buf)++; + } + + if (!test_bit(IONIC_LIF_F_UP, lif->state) || + !test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) + return; + + rxqcq = lif->rxqcqs[q_num]; + for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) { + **buf = IONIC_READ_STAT64(&rxqcq->cq, + &ionic_dbg_cq_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) { + **buf = IONIC_READ_STAT64(&rxqcq->intr, + &ionic_dbg_intr_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) { + **buf = IONIC_READ_STAT64(&rxqcq->napi_stats, + &ionic_dbg_napi_stats_desc[i]); + (*buf)++; + } + for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) { + **buf = rxqcq->napi_stats.work_done_cntr[i]; + (*buf)++; + } +} + static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf) { struct ionic_port_stats *port_stats; struct ionic_lif_sw_stats lif_stats; - struct ionic_qcq *txqcq, *rxqcq; - struct ionic_tx_stats *txstats; - struct ionic_rx_stats *rxstats; int i, q_num; ionic_get_lif_stats(lif, &lif_stats); @@ -338,73 +431,11 @@ static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf) (*buf)++; } - for (q_num = 0; q_num < MAX_Q(lif); q_num++) { - txstats = &lif->txqstats[q_num]; - - for (i = 0; i < IONIC_NUM_TX_STATS; i++) { - **buf = IONIC_READ_STAT64(txstats, - &ionic_tx_stats_desc[i]); - (*buf)++; - } - - if (test_bit(IONIC_LIF_F_UP, lif->state) && - test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) { - txqcq = lif->txqcqs[q_num]; - for (i = 0; i < IONIC_NUM_TX_Q_STATS; i++) { - **buf = IONIC_READ_STAT64(&txqcq->q, - &ionic_txq_stats_desc[i]); - (*buf)++; - } - for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) { - **buf = IONIC_READ_STAT64(&txqcq->cq, - &ionic_dbg_cq_stats_desc[i]); - (*buf)++; - } - for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) { - **buf = IONIC_READ_STAT64(&txqcq->intr, - &ionic_dbg_intr_stats_desc[i]); - (*buf)++; - } - for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++) { - **buf = txstats->sg_cntr[i]; - (*buf)++; - } - } - } + for (q_num = 0; q_num < MAX_Q(lif); q_num++) + ionic_sw_stats_get_txq_values(lif, buf, q_num); - for (q_num = 0; q_num < MAX_Q(lif); q_num++) { - rxstats = &lif->rxqstats[q_num]; - - for (i = 0; i < IONIC_NUM_RX_STATS; i++) { - **buf = IONIC_READ_STAT64(rxstats, - &ionic_rx_stats_desc[i]); - (*buf)++; - } - - if (test_bit(IONIC_LIF_F_UP, lif->state) && - test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) { - rxqcq = lif->rxqcqs[q_num]; - for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) { - **buf = IONIC_READ_STAT64(&rxqcq->cq, - &ionic_dbg_cq_stats_desc[i]); - (*buf)++; - } - for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) { - **buf = IONIC_READ_STAT64(&rxqcq->intr, - &ionic_dbg_intr_stats_desc[i]); - (*buf)++; - } - for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) { - **buf = IONIC_READ_STAT64(&rxqcq->napi_stats, - &ionic_dbg_napi_stats_desc[i]); - (*buf)++; - } - for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) { - **buf = rxqcq->napi_stats.work_done_cntr[i]; - (*buf)++; - } - } - } + for (q_num = 0; q_num < MAX_Q(lif); q_num++) + ionic_sw_stats_get_rxq_values(lif, buf, q_num); } const struct ionic_stats_group_intf ionic_stats_groups[] = {