From patchwork Mon Jan 24 18:52:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722802 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A92C433FE for ; Mon, 24 Jan 2022 18:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344351AbiAXS62 (ORCPT ); Mon, 24 Jan 2022 13:58:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344433AbiAXSyk (ORCPT ); Mon, 24 Jan 2022 13:54:40 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7558C06175D for ; Mon, 24 Jan 2022 10:53:27 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id p37so16896710pfh.4 for ; Mon, 24 Jan 2022 10:53:27 -0800 (PST) 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=d9XEdqcvKhqXvvc9/6zlC8tzG3yqZE/13DygdJczKik=; b=kPUyimVXuNw/CddYTLIR2gwjaLsTHEMpyScoI8SPOYIZ17s6Nt1PLBY75lOLumtZA7 prye1wfZpnduoHJDfV1NUuywHZvnhkd7dVEnRDzCKSmhljR4j/hjhBgt4/tud36uYNUk 3ML5J9EgSiPe7uUsi9Hn654yVXmQJ5h0Gx8Z1oq7trpUfuZ1B3NAsDXAN1XpmhlQXwRA TxIjK7FxEDLi+C2rgVBElGtqKeVVW8DzjqSKXBr7YD98PDDv8RAvST25INP5A/gyUxao VkZsJSam9Efa6Ga0aINia2c1RxnzbjR1YGQc7fh4/iwnuklPe+XoOtAckxTA4CuGQplI xWRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d9XEdqcvKhqXvvc9/6zlC8tzG3yqZE/13DygdJczKik=; b=zg4TxiZMdJ0UfCERM10eN6uJV0gyIKWYidhfPg94cnElHIVQRwPC6y40+V7MkTjRf5 xX6/z15FQKQXNiL/thVa7Sq+B6z/fpyCKpkixjawH9AjRNIOD1tHdHX7STDxWp9zbnwC k4eJwi36HbyQUKhwi+LnEiB1cwNyF2qMI7t9OSChrFXxfnCuxA1un8KH36PSmqz8Of1v ZJAHgPJ7M07MnkIqwf6DnlfRUaAjhwJ5CGB4piAeS61o49gbem2ukABS8CFLFqaMctlq epxV311pmdylHdYy1xddzQmuAEtCYt0avJClITUWxYCv2eXwDY8LPgajMB2hLg4huw44 dZiQ== X-Gm-Message-State: AOAM530m98vADlUKV6IvLMw7lymkQWTI9qQ6h13MO0MWTxxEvPYiws61 6hqSrsTxfsSFSSO8YhwXHY/FUw== X-Google-Smtp-Source: ABdhPJwagG5HzFD6ak/8A4fd0oTSd3XybUsHRdHvUzmcul2C8ZpRZ9ky2kCiLqylyTWqpng7a1QgNw== X-Received: by 2002:a62:140a:0:b0:4c9:df3b:7443 with SMTP id 10-20020a62140a000000b004c9df3b7443mr3851408pfu.73.1643050407416; Mon, 24 Jan 2022 10:53:27 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:27 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 01/16] ionic: fix type complaint in ionic_dev_cmd_clean() Date: Mon, 24 Jan 2022 10:52:57 -0800 Message-Id: <20220124185312.72646-2-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Sparse seems to have gotten a little more picky lately and we need to revisit this bit of code to make sparse happy. warning: incorrect type in initializer (different address spaces) expected union ionic_dev_cmd_regs *regs got union ionic_dev_cmd_regs [noderef] __iomem *dev_cmd_regs warning: incorrect type in argument 2 (different address spaces) expected void [noderef] __iomem * got unsigned int * warning: incorrect type in argument 1 (different address spaces) expected void volatile [noderef] __iomem * got union ionic_dev_cmd * Fixes: d701ec326a31 ("ionic: clean up sparse complaints") Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 875f4ec42efe..a89ad768e4a0 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -370,10 +370,10 @@ int ionic_adminq_post_wait_nomsg(struct ionic_lif *lif, struct ionic_admin_ctx * static void ionic_dev_cmd_clean(struct ionic *ionic) { - union __iomem ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs; + struct ionic_dev *idev = &ionic->idev; - iowrite32(0, ®s->doorbell); - memset_io(®s->cmd, 0, sizeof(regs->cmd)); + iowrite32(0, &idev->dev_cmd_regs->doorbell); + memset_io(&idev->dev_cmd_regs->cmd, 0, sizeof(idev->dev_cmd_regs->cmd)); } int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) From patchwork Mon Jan 24 18:52:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722801 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EA86C4332F for ; Mon, 24 Jan 2022 18:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344250AbiAXS6Y (ORCPT ); Mon, 24 Jan 2022 13:58:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344438AbiAXSyk (ORCPT ); Mon, 24 Jan 2022 13:54:40 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E89FAC06176F for ; Mon, 24 Jan 2022 10:53:28 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id 192so13467675pfz.3 for ; Mon, 24 Jan 2022 10:53:28 -0800 (PST) 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=Ra8Ps2jZvFPDf3HnLFC6X3YCeKlI5Q4v2gjiu5SN0hc=; b=zRA9DFJ/Tz9BQPiOiQAgGls/GtRnOXHxzeyynRC82dY1YlUQd5agxMtsofcK617x7k aSiDJHidkeavImGzXwSuVAJOfiPW10TPI8uoMX1wirLkFm6IEDdXZpycpmjAAZxTo4yh 8jSgS6fQD72VbP2Z576ERxvUC4kMQkYr/d6PsCzWdJOQMYRp6DjhB4F1YDrxoQ6OYuMH yZAEytH2prYsPmWHxjGMx+lR2Yz4pn91kCIOQl7vFqJNwxI5yOBWQHBr6bMFxsv7YHvh sIYXNNL0phOJXD4vNo4jR3QDUtr+TK9YXuRYjglnepK35/5/S1oR7PceZOrwxSngJJuB rcnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ra8Ps2jZvFPDf3HnLFC6X3YCeKlI5Q4v2gjiu5SN0hc=; b=iC9WXmTDBqcD9mxgItva4MzM9qAYvx9qx05bRKMcbyWaWw57EpPxwqXDK8ndjjgk7Q GSMlXxtH4nWAQ8kmrdIEYZxcl2fD8pm8UvcBPC3xR2XZClXIs48SGbPYQIwFuPALnynP y9Oilr0/BS+8LRqetqzN7Dfb5IEDQpXmHJrncf/+wDju9JrQ9FOLivhGPzIYSvSrSGGc NTKczkMfBlb+7fPWeWPD6vctC8OwIeVoHZvJiDmRxSfUUgMsRljYrPd3VN5Dp87ue2nT xz+fFuus+PQTWzlPxoaPD9qlbGZ1jGai+WhpNQzGzu/eBZ+arTFWZYzavMjegc94kQms 4ojg== X-Gm-Message-State: AOAM533hWQjS59L4CiUZfS4wmilQLOmOXNxcpDgO/HJdicRE3VpanU53 RA51OAgkH30xoqFe3+W5ZnCbcw== X-Google-Smtp-Source: ABdhPJyw6o3a9YTBM582yXU26suZPOMT0H5JcU/RQ1myW1Ew2hR4NW7oWa2LrebgTLp8hC0D1NynwA== X-Received: by 2002:a05:6a00:18a6:b0:4ca:38e0:400d with SMTP id x38-20020a056a0018a600b004ca38e0400dmr2259677pfh.22.1643050408453; Mon, 24 Jan 2022 10:53:28 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:28 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 02/16] ionic: start watchdog after all is setup Date: Mon, 24 Jan 2022 10:52:58 -0800 Message-Id: <20220124185312.72646-3-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The watchdog expects the lif to fully exist when it goes off, so lets not start the watchdog until all is ready in case there is some quirky time dialation that makes probe take multiple seconds. Fixes: 089406bc5ad6 ("ionic: add a watchdog timer to monitor heartbeat") Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 4 +++- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c index 7e296fa71b36..40fa5bce2ac2 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c @@ -331,6 +331,9 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_deregister_lifs; } + mod_timer(&ionic->watchdog_timer, + round_jiffies(jiffies + ionic->watchdog_period)); + return 0; err_out_deregister_lifs: @@ -348,7 +351,6 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_reset: ionic_reset(ionic); err_out_teardown: - del_timer_sync(&ionic->watchdog_timer); pci_clear_master(pdev); /* Don't fail the probe for these errors, keep * the hw interface around for inspection diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index d57e80d44c9d..4044c630f8b4 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -122,9 +122,6 @@ int ionic_dev_setup(struct ionic *ionic) idev->fw_generation = IONIC_FW_STS_F_GENERATION & ioread8(&idev->dev_info_regs->fw_status); - mod_timer(&ionic->watchdog_timer, - round_jiffies(jiffies + ionic->watchdog_period)); - idev->db_pages = bar->vaddr; idev->phy_db_pages = bar->bus_addr; From patchwork Mon Jan 24 18:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722787 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BCBAC433EF for ; Mon, 24 Jan 2022 18:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344230AbiAXS6X (ORCPT ); Mon, 24 Jan 2022 13:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344447AbiAXSyl (ORCPT ); Mon, 24 Jan 2022 13:54:41 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF94C061771 for ; Mon, 24 Jan 2022 10:53:29 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id y17so6299290plg.7 for ; Mon, 24 Jan 2022 10:53:29 -0800 (PST) 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=TCopsfaOKUODS6k02BcpS9IBDbiEXYmHn8QmS/l7mUQ=; b=z0UL7hmHOjq1ZcxJ8yCjFualQ/143EO/hWqASfVYg7zz64NW5bv67vOzsMpanDJvRg Wagm4gaFb/lvI3IBCdlPBRl7NXCUH3jkpTlXEIz49pDnJjhUPWmj/A5roNlWRdfDqImg +3AA+VOcGhUHRHlNYOSnS7Jcn6cMO2MT/sqn2Gq66HXaD/gOqhseYmk/QcFTTprDbBj+ Rv1uFO0jrthY5qXLXg3RX2/6+Qxz5UqMv9T/V+JYB2bfNuqJ/jOpQxIRBa38xrV3BL3T W3rEjNo3W4DMyTUyiwVgMyUojb00s2MLF5fP9+JryTo0baV72RroHsI4JgGCgiIkx4pl pExA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TCopsfaOKUODS6k02BcpS9IBDbiEXYmHn8QmS/l7mUQ=; b=w/jITWOG9jzOpLUjnLlGnL69yT3DrJrnjgNKRqYkCN3rUHeUuPqWb7Er0dVYy+buTM J1ivPvpYpUcVFNrhj7NQGfClBLmkFLUe9uoLtcFZ3s7LBOUY7t3vJJPMdLGu+2BoORVv 57uvkc8qy1zSx0Y4b3soTcPFCJi/DdwRyLgHigRsEU0E0/kCh5vevGKHy3HE8zn5tmqu BnenjdVVgUTS9LP95dwG1rla9hIyauePd0RuC9QHgc7DqYb5H1Hizi+2uzekpMYCzwWl NzARyHxTm3WVgKMx/by1DaFWyFPg7GqCSjJiVyWuWPLCb+mHBb7RNgU6xSOjCZUYCih6 1z6A== X-Gm-Message-State: AOAM531mbGW6LNdtC42DVkt1RUGDmuYvVlL/e4QOgADJKiAPzU8jTiNG nwb2c9Gee6Lwyre1qYwD0kWqbw== X-Google-Smtp-Source: ABdhPJzMqZO/13GSr2HdBPvKL5aPSIJRPw6fU0IolTvD7iWm4q+MnqHcmVcBwi9r1H19mhvl4S6wTg== X-Received: by 2002:a17:90b:1646:: with SMTP id il6mr3263363pjb.12.1643050409466; Mon, 24 Jan 2022 10:53:29 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:29 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 03/16] ionic: separate function for watchdog init Date: Mon, 24 Jan 2022 10:52:59 -0800 Message-Id: <20220124185312.72646-4-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Pull the watchdog init code out to a separate bite-sized function. Code cleaning for now, will be a useful change in the near future. Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 4044c630f8b4..34b7708917d1 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -46,6 +46,24 @@ static void ionic_watchdog_cb(struct timer_list *t) } } +static void ionic_watchdog_init(struct ionic *ionic) +{ + struct ionic_dev *idev = &ionic->idev; + + 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; + idev->fw_generation = IONIC_FW_STS_F_GENERATION & + ioread8(&idev->dev_info_regs->fw_status); +} + void ionic_init_devinfo(struct ionic *ionic) { struct ionic_dev *idev = &ionic->idev; @@ -109,18 +127,7 @@ int ionic_dev_setup(struct ionic *ionic) return -EFAULT; } - 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; - idev->fw_generation = IONIC_FW_STS_F_GENERATION & - ioread8(&idev->dev_info_regs->fw_status); + ionic_watchdog_init(ionic); idev->db_pages = bar->vaddr; idev->phy_db_pages = bar->bus_addr; From patchwork Mon Jan 24 18:53:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722786 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98BA6C4332F for ; Mon, 24 Jan 2022 18:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343503AbiAXS6W (ORCPT ); Mon, 24 Jan 2022 13:58:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344473AbiAXSyn (ORCPT ); Mon, 24 Jan 2022 13:54:43 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06336C061775 for ; Mon, 24 Jan 2022 10:53:31 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id j16so6102030plx.4 for ; Mon, 24 Jan 2022 10:53:31 -0800 (PST) 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=gftFiybPsp4f/ef4q6t+0YuKdfevzxGi9+2OMOJ+pwg=; b=2x9pcnyh3b2USGCuoe8PSCyJHLq2R3qdX+YtnkJXrTRkcT2amT/mn/m4YQSdCl5nsv PQ6qCzQPhxdkjfgvb2k/AHSg5nDV9fIG9n/SSeyTAsxav73ftnM4xEIPTvM4defzdLYs HvCbCrPA67y4IeCAKS0r/N28aU6EebHeCX3bm+dn0Vhm3IQ1ZfCNvnWwpiC8XmmWXHKI 0dCWmJNu0snCggFH9WhHs1N3Bj68qPFc5evF7cBkvjD8qFvORSpLyCIVsq6BczWoaxWv Xa6R6PKGmIaUmIrSeJxYe1EAZm+sRTwzB5UvziP1UJN6F2CNpz07cc676V7tbVbQc9Z+ dtBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gftFiybPsp4f/ef4q6t+0YuKdfevzxGi9+2OMOJ+pwg=; b=fqQkhNT8lQQERSNSo2Cu53WDMdEKXF9ZBmFUMyTcinKhF7fxYUrs3vFYrl6Ylk9INu IM2cbh1OgMsTyYSjrVwa4VTxmc0sH33thKjuf8RUJpUXok08+TfTKrs0cM2QSn+eqbpo QrMiwRV6CIavQso4oW3dkWGR89hoaW2+NCoMpoLdPA8fzkwQPb/aKqAfE+9D2mPn5RLN nf+ALKztNVuwzar5ypKLyp2lIDBgHPUU/+UP/67O0Bh/ualfL+v0bJo03YrqAE2biM3c akx28rYqijwsABshauHI4CReDgOsRe6RoRUP2/9bYsdf4Lg1EzrkFDxz9N+oCedAJLaP 9DMg== X-Gm-Message-State: AOAM530jT6wGWpGMKB95oV0lyr+RecwVhNvoLfyqCKolb0ZA+yA4CzWp UNnE/LOeovngtHgqNzsltehXPw== X-Google-Smtp-Source: ABdhPJw+jlrZvYFsvHdD1Hb2YR/eJfEZzcAi6XR6Kr5X+GS2HJkcKx064rKaH3VE1K9DDpT8ZQCMAw== X-Received: by 2002:a17:90a:7bce:: with SMTP id d14mr3212300pjl.7.1643050410511; Mon, 24 Jan 2022 10:53:30 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:30 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 04/16] ionic: Don't send reset commands if FW isn't running Date: Mon, 24 Jan 2022 10:53:00 -0800 Message-Id: <20220124185312.72646-5-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley It's possible the FW is already shutting down while the driver is being removed and/or when the driver is going through reset. This can cause unexpected/unnecessary errors to be printed: eth0: DEV_CMD IONIC_CMD_PORT_RESET (12) error, IONIC_RC_ERROR (29) failed eth1: DEV_CMD IONIC_CMD_RESET (3) error, IONIC_RC_ERROR (29) failed Fix this by checking the FW status register before issuing the reset commands. Also, since err may not be assigned in ionic_port_reset(), assign it a default value of 0, and remove an unnecessary log message. Fixes: fbfb8031533c ("ionic: Add hardware init and device commands") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.c | 17 ++++++++++++----- .../net/ethernet/pensando/ionic/ionic_dev.h | 1 + .../net/ethernet/pensando/ionic/ionic_main.c | 18 ++++++++++-------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 34b7708917d1..86791e0f2d72 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -136,6 +136,16 @@ int ionic_dev_setup(struct ionic *ionic) } /* Devcmd Interface */ +bool ionic_is_fw_running(struct ionic_dev *idev) +{ + u8 fw_status = ioread8(&idev->dev_info_regs->fw_status); + + /* firmware is useful only if the running bit is set and + * fw_status != 0xff (bad PCI read) + */ + return (fw_status != 0xff) && (fw_status & IONIC_FW_STS_F_RUNNING); +} + int ionic_heartbeat_check(struct ionic *ionic) { struct ionic_dev *idev = &ionic->idev; @@ -159,13 +169,10 @@ int ionic_heartbeat_check(struct ionic *ionic) goto do_check_time; } - /* firmware is useful only if the running bit is set and - * fw_status != 0xff (bad PCI read) - * If fw_status is not ready don't bother with the generation. - */ fw_status = ioread8(&idev->dev_info_regs->fw_status); - if (fw_status == 0xff || !(fw_status & IONIC_FW_STS_F_RUNNING)) { + /* If fw_status is not ready don't bother with the generation */ + if (!ionic_is_fw_running(idev)) { fw_status_ready = false; } else { fw_generation = fw_status & IONIC_FW_STS_F_GENERATION; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index e5acf3bd62b2..73b950ac1272 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -353,5 +353,6 @@ void ionic_q_rewind(struct ionic_queue *q, struct ionic_desc_info *start); void ionic_q_service(struct ionic_queue *q, struct ionic_cq_info *cq_info, unsigned int stop_index); int ionic_heartbeat_check(struct ionic *ionic); +bool ionic_is_fw_running(struct ionic_dev *idev); #endif /* _IONIC_DEV_H_ */ diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index a89ad768e4a0..a548f2a01806 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -540,6 +540,9 @@ int ionic_reset(struct ionic *ionic) struct ionic_dev *idev = &ionic->idev; int err; + if (!ionic_is_fw_running(idev)) + return 0; + mutex_lock(&ionic->dev_cmd_lock); ionic_dev_cmd_reset(idev); err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); @@ -612,15 +615,17 @@ int ionic_port_init(struct ionic *ionic) int ionic_port_reset(struct ionic *ionic) { struct ionic_dev *idev = &ionic->idev; - int err; + int err = 0; if (!idev->port_info) return 0; - mutex_lock(&ionic->dev_cmd_lock); - ionic_dev_cmd_port_reset(idev); - err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); - mutex_unlock(&ionic->dev_cmd_lock); + if (ionic_is_fw_running(idev)) { + mutex_lock(&ionic->dev_cmd_lock); + ionic_dev_cmd_port_reset(idev); + err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); + mutex_unlock(&ionic->dev_cmd_lock); + } dma_free_coherent(ionic->dev, idev->port_info_sz, idev->port_info, idev->port_info_pa); @@ -628,9 +633,6 @@ int ionic_port_reset(struct ionic *ionic) idev->port_info = NULL; idev->port_info_pa = 0; - if (err) - dev_err(ionic->dev, "Failed to reset port\n"); - return err; } From patchwork Mon Jan 24 18:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722785 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 304F7C433EF for ; Mon, 24 Jan 2022 18:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344124AbiAXS6S (ORCPT ); Mon, 24 Jan 2022 13:58:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344518AbiAXSyq (ORCPT ); Mon, 24 Jan 2022 13:54:46 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4281DC06178A for ; Mon, 24 Jan 2022 10:53:32 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id t18so16640147plg.9 for ; Mon, 24 Jan 2022 10:53:32 -0800 (PST) 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=zOJ8SK7XOrM2AokhWaTdmBkoxMZYj4UY76hfY8D3EUE=; b=3vaFe1y00oK4gWOT4+qvi39LpHv7HWeAbrkO8yZoezKFtGffCJmDAQc/h1Jwtq2BbT mlKlGsnEsceUaOHuN9Vd3FtdT3oVVyPYA3g47LajiuGV8ofmLlIb07Tt276TMgLjAVbz ozkqUyeTET7IIdOP7cIi5gqlkfwgVNZiX+luVaVXMIYlERGSCQaTtnnx4W7Jr05mn/qV y8D/7YiEKH5KgFTVkkWoAWfHAe0/pE/0Kjt85drxiG/REbPd+5/JCwss3l2eAe3QTB61 EO1vFwUmg6a3/42LPoEAxGLDp+LLF5Yg1ERWVKZPoYcbCf3msYH/oFuDa8Q6TBamRqnL pWyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zOJ8SK7XOrM2AokhWaTdmBkoxMZYj4UY76hfY8D3EUE=; b=L/TopObBLNa9VowehstPi4g3hMkz7FE7aZjAeVOs6Z8SwRH5Mn2zOoHk7reaxSvSdX fkkN6i1R0zW1KqhBoYWz+xK3rEXMtVunTPNoCaYuqOMRsxuFvKw+OSgAahrgNwUK/J+x qRiRR+4hc9f/aQD5S+rCIaGahEopGg6iXV5GtxY8eFYf7wnnr3BkJzngsN1FslXamOTZ IaE6LcEEdAQETmYcwaXHYZbipyuCFXSsdEdCP+ESJutWQg8Xr7Ejlf4kJzcx+JVppF0C G1cGLMtVG74SU5uaP0AZyYHWtfO6X1njbBX7vBINV/Gyrd43rgTImUtqO6kJzaq1RAyZ aRvw== X-Gm-Message-State: AOAM530WkJqK8ZF/ozhFs6JE6k2QH/3eqsW808mkkWV32FdWSVzxvBGc L9Wt66vG8JeZr6lQg+Lw86n6Fw== X-Google-Smtp-Source: ABdhPJwpFn3T542CscWfuNIjuwNFJmMPLCauhaDgO6gMzgO0jEddt0nMit42LG7/UdIfqE+3s5lHAg== X-Received: by 2002:a17:90a:2e09:: with SMTP id q9mr3281672pjd.2.1643050411755; Mon, 24 Jan 2022 10:53:31 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:31 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 05/16] ionic: add FW_STOPPING state Date: Mon, 24 Jan 2022 10:53:01 -0800 Message-Id: <20220124185312.72646-6-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Between fw running and fw actually stopped into reset, we need a fw_stopping concept to catch and block some actions while we're transitioning to FW_RESET state. This will help to be sure the fw_up task is not scheduled until after the fw_down task has completed. On some rare occasion timing, it is possible for the fw_up task to try to run before the fw_down task, then not get run after the fw_down task has run, leaving the device in a down state. This is possible if the watchdog goes off in between finding the down transition and starting the fw_down task, where the later watchdog sees the FW is back up and schedules a fw_up task. Fixes: c672412f6172 ("ionic: remove lifs on fw reset") Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.c | 25 +++++++++++-------- .../net/ethernet/pensando/ionic/ionic_lif.c | 1 + .../net/ethernet/pensando/ionic/ionic_lif.h | 1 + .../net/ethernet/pensando/ionic/ionic_main.c | 4 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 86791e0f2d72..8edbd7c30ccc 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -197,21 +197,24 @@ int ionic_heartbeat_check(struct ionic *ionic) struct ionic_lif *lif = ionic->lif; bool trigger = false; - 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; - } else { - dev_info(ionic->dev, "FW running %u\n", fw_status); - if (lif && test_bit(IONIC_LIF_F_FW_RESET, lif->state)) - trigger = true; + if (!fw_status_ready && lif && + !test_bit(IONIC_LIF_F_FW_RESET, lif->state) && + !test_and_set_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { + dev_info(ionic->dev, "FW stopped 0x%02x\n", fw_status); + trigger = true; + + } else if (fw_status_ready && lif && + test_bit(IONIC_LIF_F_FW_RESET, lif->state) && + !test_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { + dev_info(ionic->dev, "FW running 0x%02x\n", fw_status); + trigger = true; } if (trigger) { struct ionic_deferred_work *work; + idev->fw_status_ready = fw_status_ready; + work = kzalloc(sizeof(*work), GFP_ATOMIC); if (work) { work->type = IONIC_DW_TYPE_LIF_RESET; @@ -221,7 +224,7 @@ int ionic_heartbeat_check(struct ionic *ionic) } } - if (!fw_status_ready) + if (!idev->fw_status_ready) return -ENXIO; /* wait at least one watchdog period since the last heartbeat */ diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 2ff7be17e5af..08c8589e875a 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -2835,6 +2835,7 @@ static void ionic_lif_handle_fw_down(struct ionic_lif *lif) mutex_unlock(&lif->queue_lock); + clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); dev_info(ionic->dev, "FW Down: LIFs stopped\n"); } diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index 9f7ab2f17f93..2db708df6b55 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -135,6 +135,7 @@ enum ionic_lif_state_flags { IONIC_LIF_F_LINK_CHECK_REQUESTED, IONIC_LIF_F_FILTER_SYNC_NEEDED, IONIC_LIF_F_FW_RESET, + IONIC_LIF_F_FW_STOPPING, IONIC_LIF_F_SPLIT_INTR, IONIC_LIF_F_BROKEN, IONIC_LIF_F_TX_DIM_INTR, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index a548f2a01806..449e9ee2acf0 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -332,7 +332,9 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, break; /* interrupt the wait if FW stopped */ - if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { + if ((test_bit(IONIC_LIF_F_FW_RESET, lif->state) && + !lif->ionic->idev.fw_status_ready) || + test_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { if (do_msg) netdev_err(netdev, "%s (%d) interrupted, FW in reset\n", name, ctx->cmd.cmd.opcode); From patchwork Mon Jan 24 18:53:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722781 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58362C433FE for ; Mon, 24 Jan 2022 18:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344115AbiAXS56 (ORCPT ); Mon, 24 Jan 2022 13:57:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344527AbiAXSyq (ORCPT ); Mon, 24 Jan 2022 13:54:46 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ECE0C061793 for ; Mon, 24 Jan 2022 10:53:33 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id nn16-20020a17090b38d000b001b56b2bce31so42962pjb.3 for ; Mon, 24 Jan 2022 10:53:33 -0800 (PST) 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=5U7DgCFcnZ1n8kyHk3IMbj1iF8HAhpo6uzE8G34cl6I=; b=HGB/tpmnLMo6WYX0+jx8qWxgddAnGeYxmLGAH0gCU1aRZyvpkh/P9GnrdWvTYW3uAh N/jzvtiOEmjG/XJXAVwd6zXB6/pbWrY4ndHOFpL9mmm65T3TtKTmyFmqVmESleezsCSp 9X8v+LibGAyHEBesb0bld5Eb3iuZoNva17tRjZiV6O595WIAfk7msCNECi17p7BIQHSV XSnmRKd9ccF/DUvL3MeaNkiirPSt6b5uujRGRPGTf7mLv7VX4SEZU6SkpDopupBGbMAL u/o9/eWy80Jh5esJfQdl1CTzQq6vENv73QE9ldO2bZqwq9YHV6Nstu2aMZrjLJJj/v7N aDiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5U7DgCFcnZ1n8kyHk3IMbj1iF8HAhpo6uzE8G34cl6I=; b=s3gA320+61472S4Bh4fqUdH0QfNUmsI9WJO2Aqla5Hm3NlQfsIHT+KPNeQ6Dv6Zj06 X0NOqiATGH1AlC4zwFRuczFJtgAvbPiCnBJX43mwinGX5MBmrp/SvjZxG2kHN5lQtFtM YDlaiuOTqP56XWugN0ZsCMwOt/VCA7Q8whuRCHUTHpEA0RicjNaF8Ny4Biv3tOvuJehv 6yjoMPkgh+fcOMOTCHfZ9Czs18lo3Nv3nMrFFYlwVGDMQ4aR3WaJo10kK0vGcHuklTbk 1N3+oGtO+su2o0E8o7ZWc/ajRmAfdSzvs6MSXmStP2i4JBaoeqbQKxwBH3pq9hVV6Hly cJ1A== X-Gm-Message-State: AOAM531bv1/yyP14sD+uoF1g1qpzb9tO6dQdmprfnGWn9GLsbBoioiZF JNHGh7fWDfKOZ64Zq3rURdeLag== X-Google-Smtp-Source: ABdhPJzx3xviAclqPvxGBBt7pLTeHmaRenxbAOeRz/nMx0g/TKSVMO7t8q4Hmtwve/f+5IB76jDfaA== X-Received: by 2002:a17:902:6b06:b0:14b:f88:5f9b with SMTP id o6-20020a1709026b0600b0014b0f885f9bmr15377136plk.169.1643050413063; Mon, 24 Jan 2022 10:53:33 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:32 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 06/16] ionic: better handling of RESET event Date: Mon, 24 Jan 2022 10:53:02 -0800 Message-Id: <20220124185312.72646-7-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When IONIC_EVENT_RESET is received, we only need to start the fw_down process if we aren't already down, and we need to be sure to set the FW_STOPPING state on the way. If this is how we noticed that FW was stopped, it is most likely from a FW update, and we'll see a new FW generation. The update happens quickly enough that we might not see fw_status==0, so we need to be sure things get restarted when we see the fw_generation change. Fixes: d2662072c094 ("ionic: monitor fw status generation") Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 17 +++++++++++++---- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 +++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 8edbd7c30ccc..35581cabbae3 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -33,7 +33,8 @@ static void ionic_watchdog_cb(struct timer_list *t) !test_bit(IONIC_LIF_F_FW_RESET, lif->state)) ionic_link_status_check_request(lif, CAN_NOT_SLEEP); - if (test_bit(IONIC_LIF_F_FILTER_SYNC_NEEDED, lif->state)) { + if (test_bit(IONIC_LIF_F_FILTER_SYNC_NEEDED, lif->state) && + !test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { work = kzalloc(sizeof(*work), GFP_ATOMIC); if (!work) { netdev_err(lif->netdev, "rxmode change dropped\n"); @@ -148,8 +149,9 @@ bool ionic_is_fw_running(struct ionic_dev *idev) int ionic_heartbeat_check(struct ionic *ionic) { - struct ionic_dev *idev = &ionic->idev; unsigned long check_time, last_check_time; + struct ionic_dev *idev = &ionic->idev; + struct ionic_lif *lif = ionic->lif; bool fw_status_ready = true; bool fw_hb_ready; u8 fw_generation; @@ -187,14 +189,21 @@ int ionic_heartbeat_check(struct ionic *ionic) * the down, the next watchdog will see the fw is up * and the generation value stable, so will trigger * the fw-up activity. + * + * If we had already moved to FW_RESET from a RESET event, + * it is possible that we never saw the fw_status go to 0, + * so we fake the current idev->fw_status_ready here to + * force the transition and get FW up again. */ - fw_status_ready = false; + if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) + idev->fw_status_ready = false; /* go to running */ + else + fw_status_ready = false; /* go to down */ } } /* is this a transition? */ if (fw_status_ready != idev->fw_status_ready) { - struct ionic_lif *lif = ionic->lif; bool trigger = false; if (!fw_status_ready && lif && diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 08c8589e875a..13c00466023f 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -1112,12 +1112,17 @@ static bool ionic_notifyq_service(struct ionic_cq *cq, ionic_link_status_check_request(lif, CAN_NOT_SLEEP); break; case IONIC_EVENT_RESET: - work = kzalloc(sizeof(*work), GFP_ATOMIC); - if (!work) { - netdev_err(lif->netdev, "Reset event dropped\n"); - } else { - work->type = IONIC_DW_TYPE_LIF_RESET; - ionic_lif_deferred_enqueue(&lif->deferred, work); + if (lif->ionic->idev.fw_status_ready && + !test_bit(IONIC_LIF_F_FW_RESET, lif->state) && + !test_and_set_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { + work = kzalloc(sizeof(*work), GFP_ATOMIC); + if (!work) { + netdev_err(lif->netdev, "Reset event dropped\n"); + clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); + } else { + work->type = IONIC_DW_TYPE_LIF_RESET; + ionic_lif_deferred_enqueue(&lif->deferred, work); + } } break; default: From patchwork Mon Jan 24 18:53:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722783 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE279C43217 for ; Mon, 24 Jan 2022 18:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344141AbiAXS6C (ORCPT ); Mon, 24 Jan 2022 13:58:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344525AbiAXSyq (ORCPT ); Mon, 24 Jan 2022 13:54:46 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACABDC061796 for ; Mon, 24 Jan 2022 10:53:34 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id d18so3962445plg.2 for ; Mon, 24 Jan 2022 10:53:34 -0800 (PST) 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=vL1qGSXsPep8AFh0pLtJDwX+8jYU1IJ9Z1/HMykJPtI=; b=n2M0h0wtqhWd8M89HoOZ0HP41CssQj6Vo7dEaBAwjPyVa+yTW2YtM9yVQ20cJ8LMhS zhrBebZ0v8ViP8tr5aNbYv7QRkad8yr9UIWI5Go7Z3RZjXWFFUlkmA3R8gNLAdf6S1UB /1zbx7yV84KqCYvs8eaulTa+Bq7mbflVxGy0KBNbzvTe+u+wB/vKEsRIpfN86W3auGAy mC06IsquHtZOGau3Ws4DPsFBAdMViYOBvTAYfDo1vAexTWbjAytMd6cxvbhR37NAqXno HZEoyw1r+PSvtqsBHKKMdEeYMffGaw1mSGEA9HsKPvMEtyy3PegROmPKrXxdONm/dPmr ZodQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vL1qGSXsPep8AFh0pLtJDwX+8jYU1IJ9Z1/HMykJPtI=; b=S3i9LYXowd1+QLx8NA2G8cnPUT6O5TPmF3XIGSjheE6nzekbziw2oo/3s0H4d5Seo9 SkXdxiTksQaXwT8qLc6/YJTsSUggao25ogr6qMzJJX3ZOpdCHUWErFJz0pYlOvXn7ks/ 59r9N0IUu8K8tE4oZ7aMRwLf/1x5nHxmdkllp0YVQgaszFAf4G4PzDgR/NJfYCPwwrNP 9JAdWmIHLU9MmBHs61BdZMqsj1rB2bjZbpsJ3rSxvYUBg95/Vy3NW7vOJ8MUeswbe0wu rfqtw2h2lT5bBt14dsyDqDGEhRMsrTINJ8IrYLHb1eoGjF49O7pacSwOrWnQqhkPAI5b XzdQ== X-Gm-Message-State: AOAM533sPCkfLHxBn9kJCvhDFSRNR+8iPh4vcXVbPBKTeGvxHYL/VS/H uwUQ7g2gTzTr0AXrxHIQqobNGg== X-Google-Smtp-Source: ABdhPJyL9uEjVwDIrd4Y11Z9roQmlNsOJQUAsk+SxZkv/RU0M9rVJ4BIFumkDjdjppUBLiZArrcPgQ== X-Received: by 2002:a17:90b:3503:: with SMTP id ls3mr3207244pjb.186.1643050414200; Mon, 24 Jan 2022 10:53:34 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:33 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 07/16] ionic: fix up printing of timeout error Date: Mon, 24 Jan 2022 10:53:03 -0800 Message-Id: <20220124185312.72646-8-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Make sure we print the TIMEOUT string if we had a timeout error, rather than printing the wrong status. Fixes: 8c9d956ab6fb ("ionic: allow adminq requests to override default error message") Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 449e9ee2acf0..04fc2342b055 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -215,9 +215,13 @@ static void ionic_adminq_flush(struct ionic_lif *lif) void ionic_adminq_netdev_err_print(struct ionic_lif *lif, u8 opcode, u8 status, int err) { + const char *stat_str; + + stat_str = (err == -ETIMEDOUT) ? "TIMEOUT" : + ionic_error_to_str(status); + netdev_err(lif->netdev, "%s (%d) failed: %s (%d)\n", - ionic_opcode_to_str(opcode), opcode, - ionic_error_to_str(status), err); + ionic_opcode_to_str(opcode), opcode, stat_str, err); } static int ionic_adminq_check_err(struct ionic_lif *lif, From patchwork Mon Jan 24 18:53:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722784 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77F5FC43219 for ; Mon, 24 Jan 2022 18:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344558AbiAXS6D (ORCPT ); Mon, 24 Jan 2022 13:58:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344529AbiAXSyq (ORCPT ); Mon, 24 Jan 2022 13:54:46 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1532C061392 for ; Mon, 24 Jan 2022 10:53:35 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d18so3962526plg.2 for ; Mon, 24 Jan 2022 10:53:35 -0800 (PST) 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=7vQNBaHG6Ptstllb0Cqk3fQCnDZdvoLkhVTkNBipFEM=; b=mWcWV6nUITsbWsndFiLAK7pQR2qH/o5CxFLaBELytiFdvn4KBDaeEcZGzPRYYs9xrX IBC3KcTT38AYsHdrDe9x0EJTSNBHNw+1KUYvvU4vSiqywOIlrqADiBdeGZ3qwUKV4Hfa dYedk9S92BF2pa73OmGNfHTkzvEdphaAMn3gBHvfnwwZenC0PYGRSBGAiICq4lrICOse mgYTbcytJWNdR+oaekzioi5Q3MhStNmRDpJcw/2g7jx8ed3gwi/Y6JunFGkBY0wW5L31 MvCTICjoNPQKCthshzRutkNEEM8Jy06xby2p8VW34ymCl6Gsq6ht+3A43Ez6GJ0C2r9u Dkew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7vQNBaHG6Ptstllb0Cqk3fQCnDZdvoLkhVTkNBipFEM=; b=eln9ArDeRTuuVSDKTBselQslWl0tIiH8kKCMB4pZXOofciTyO1ctarqpRLTtz12C3G 9BuzxZorK4I/ldwi3Z4PmYtZ4DiOfrfHg4I5fG2y/osc1E39dwGfozKHmXeDk2hbo9Dv hpc/p5klv+vvA0uDsEpLA2O5RhVegcdfZFcKWZd8OeBa4VojbztYxf1eF7blemFtpuZz rTLXHQVQkoj+d1aQSlYQBQjrf/s+1o7h+CPQRHfaIPvOqOsj6krPQa4L6g4qHXAPndEt ZWeS7kBF9C3bxOSGwzExGJK8ZiiJf1n9caCNFAToDXdNiDcIUn9Dcptynq80rwqdqLqv AO8g== X-Gm-Message-State: AOAM533JhxYZROMLFf55L89eIWFjwS5QwiLvOyq4XZqVGHugKtmZNrU7 mqdPmOUZJHawZzw+8esPvRUEEA== X-Google-Smtp-Source: ABdhPJz+YHPZqzlbDtLaUIcyjPzOg3ZB40QqnBd4bOx3d0PW+dHWe9CNWReEIZMoAJ3/sf4PXXAKXQ== X-Received: by 2002:a17:902:8ec5:b0:149:d41a:baa8 with SMTP id x5-20020a1709028ec500b00149d41abaa8mr15020726plo.115.1643050415389; Mon, 24 Jan 2022 10:53:35 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:34 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 08/16] ionic: Correctly print AQ errors if completions aren't received Date: Mon, 24 Jan 2022 10:53:04 -0800 Message-Id: <20220124185312.72646-9-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley Recent changes went into the driver to allow flexibility when printing error messages. Unfortunately this had the unexpected consequence of printing confusing messages like the following: IONIC_CMD_RX_FILTER_ADD (31) failed: IONIC_RC_SUCCESS (-6) In cases like this the completion of the admin queue command never completes, so the completion status is 0, hence IONIC_RC_SUCCESS is printed even though the command clearly failed. For example, this could happen when the driver tries to add a filter and at the same time the FW goes through a reset, so the AQ command never completes. Fix this by forcing the FW completion status to IONIC_RC_ERROR in cases where we never get the completion. Fixes: 8c9d956ab6fb ("ionic: allow adminq requests to override default error message") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 04fc2342b055..7693b4336394 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -322,6 +322,7 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, if (do_msg && !test_bit(IONIC_LIF_F_FW_RESET, lif->state)) netdev_err(netdev, "Posting of %s (%d) failed: %d\n", name, ctx->cmd.cmd.opcode, err); + ctx->comp.comp.status = IONIC_RC_ERROR; return err; } @@ -342,6 +343,7 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, if (do_msg) netdev_err(netdev, "%s (%d) interrupted, FW in reset\n", name, ctx->cmd.cmd.opcode); + ctx->comp.comp.status = IONIC_RC_ERROR; return -ENXIO; } From patchwork Mon Jan 24 18:53:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722782 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DE0C4332F for ; Mon, 24 Jan 2022 18:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344163AbiAXS6B (ORCPT ); Mon, 24 Jan 2022 13:58:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344537AbiAXSyq (ORCPT ); Mon, 24 Jan 2022 13:54:46 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 572F6C061344 for ; Mon, 24 Jan 2022 10:53:37 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id d15-20020a17090a110f00b001b4e7d27474so47124pja.2 for ; Mon, 24 Jan 2022 10:53:37 -0800 (PST) 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=PLArnqefwgDmb7xF33Ph9ouGYL3xAlbp6gYpsYpMxpg=; b=IbMWrwYiXVvhbkuGImQ0XJK1Q0Hlr+dMh5HymsJW6Tgd3YBs5nwiGYyyc70xuiDOAe BSafNoeVnh6fXC3Vp95OPXF5FKKBcSXvNZgTwWUfsT/DdXqVpOjzc3RXPnWmXHlZG5B9 70KZqb7bjbJwIqc34SUhxTh7jDjnYKahB14IX6rCNh7BBG/Y/A4CieCBsxko5OUaBFwD ahoLfQ6mEjCPz7yJ7mqx9wMBAK8o6zFX9UVBUYyyVo4oxdFkHT9YIUDoYqrE/Ets83Mb Q/AARKloL3GgWokoaOxXryIgAyKVJ4xwcZDdBp6OFYLRak7wnFdFMd/wguE5pH02fxDk q3PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PLArnqefwgDmb7xF33Ph9ouGYL3xAlbp6gYpsYpMxpg=; b=UIqmhslbuMzWuH16Vty5RbRuHkVVpwfMXdpf66qKG4L/H61d7isK19akD95fPn7INW v/JjN8eZoinfUej4aSWG/d1Mr314w/M1fvEto7XD1CiXtL0PEzcoUK4MM8VsnaeJbfEv WA2u639axmEuMdbdTTGtgGCYfw5YPVRN897Tx+j+gqasXvgQtbHLaAySq0lfJwhApYfw D/Dfo2NfyZ1w08d2eFVd9JVI7YAmJLC0gA8fYO+QVqb0yvcWOCmW0kAak/i4Sl9SuRtD VxxKGfvAB7/u8nmnmJ6KSNxhJ1Y75lVgXTa5E++urgdhzpx3r5M66Z2SU/lZFzXKYRFy T66Q== X-Gm-Message-State: AOAM532U5Vp7oJ2zysEu9yw/jpkjlw5/70+dR3CcQnsKFkXIg7D3yP9p taAoynvh8Vk14Nuk/ZWxqCNABQ== X-Google-Smtp-Source: ABdhPJwbywn9zvRnkCMaISrd6wFhuVxL8mPKz9vftJp0gX8F30ijNMZ2WMkIrABuIrqjaoeBi2FOhw== X-Received: by 2002:a17:90b:4ad2:: with SMTP id mh18mr3269039pjb.3.1643050416663; Mon, 24 Jan 2022 10:53:36 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:36 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 09/16] ionic: Allow flexibility for error reporting on dev commands Date: Mon, 24 Jan 2022 10:53:05 -0800 Message-Id: <20220124185312.72646-10-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley When dev commands fail, an error message will always be printed, which may be overly alarming the to system administrators, especially if the driver shouldn't be printing the error due to some unsupported capability. Similar to recent adminq request changes, we can update the dev command interface with the ability to selectively print error messages to allow the driver to prevent printing errors that are expected. Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic.h | 3 ++ .../net/ethernet/pensando/ionic/ionic_main.c | 31 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic.h b/drivers/net/ethernet/pensando/ionic/ionic.h index 5e25411ff02f..6783c0e6ba4f 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic.h +++ b/drivers/net/ethernet/pensando/ionic/ionic.h @@ -78,6 +78,9 @@ void ionic_adminq_netdev_err_print(struct ionic_lif *lif, u8 opcode, u8 status, int err); int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait); +int ionic_dev_cmd_wait_nomsg(struct ionic *ionic, unsigned long max_wait); +void ionic_dev_cmd_dev_err_print(struct ionic *ionic, u8 opcode, u8 status, + int err); int ionic_set_dma_mask(struct ionic *ionic); int ionic_setup(struct ionic *ionic); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 7693b4336394..163174f07ed7 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -384,7 +384,20 @@ static void ionic_dev_cmd_clean(struct ionic *ionic) memset_io(&idev->dev_cmd_regs->cmd, 0, sizeof(idev->dev_cmd_regs->cmd)); } -int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) +void ionic_dev_cmd_dev_err_print(struct ionic *ionic, u8 opcode, u8 status, + int err) +{ + const char *stat_str; + + stat_str = (err == -ETIMEDOUT) ? "TIMEOUT" : + ionic_error_to_str(status); + + dev_err(ionic->dev, "DEV_CMD %s (%d) error, %s (%d) failed\n", + ionic_opcode_to_str(opcode), opcode, stat_str, err); +} + +static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, + const bool do_msg) { struct ionic_dev *idev = &ionic->idev; unsigned long start_time; @@ -452,9 +465,9 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) } if (!(opcode == IONIC_CMD_FW_CONTROL && err == IONIC_RC_EAGAIN)) - dev_err(ionic->dev, "DEV_CMD %s (%d) error, %s (%d) failed\n", - ionic_opcode_to_str(opcode), opcode, - ionic_error_to_str(err), err); + if (do_msg) + ionic_dev_cmd_dev_err_print(ionic, opcode, err, + ionic_error_to_errno(err)); return ionic_error_to_errno(err); } @@ -462,6 +475,16 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) return 0; } +int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) +{ + return __ionic_dev_cmd_wait(ionic, max_seconds, true); +} + +int ionic_dev_cmd_wait_nomsg(struct ionic *ionic, unsigned long max_seconds) +{ + return __ionic_dev_cmd_wait(ionic, max_seconds, false); +} + int ionic_setup(struct ionic *ionic) { int err; From patchwork Mon Jan 24 18:53:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722780 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3630C433EF for ; Mon, 24 Jan 2022 18:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344005AbiAXS5p (ORCPT ); Mon, 24 Jan 2022 13:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344550AbiAXSyr (ORCPT ); Mon, 24 Jan 2022 13:54:47 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31A3DC061346 for ; Mon, 24 Jan 2022 10:53:38 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id u11so16647683plh.13 for ; Mon, 24 Jan 2022 10:53:38 -0800 (PST) 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=OI4rP+JeoPyWCXhhETrKLDuIMO3CdQ/C4uCwN/0EkCU=; b=Zma79X3V+rd6IkhvnfCqY4knZiYYeFYpb5XjJPJVjbXbuDhk/5HK8jzXlokOstDqYe IK/OVVu8lLlANqzx7LizJnsxArex3M1rf4iOQcSTdDXOIZq+lm31SebxuxGtCn3ypHHe TpCXKyEDlAMgJ7/Ubldh05C4a2Lk/HMrLq9xhQTwsTq9jrHyw8wC0lrchN62A79KZWHw Y3IE5Smxv4w6Aen1QgS/HLg0L4aOKGS2GWfveCSfH18PpoS05zq2s/JNFHVpUkWA7JyE 2Vwti5Iy9Nmc0cyaaYhZNxFFAaa5DJHWgwx6sGKul4bepbEGWoMie1bQyKBpY7wp6R1J 3gzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OI4rP+JeoPyWCXhhETrKLDuIMO3CdQ/C4uCwN/0EkCU=; b=LBqV1+kuKMOLs4CfRj36bcATVBlenuilRLF5C3oDyDXQaOsVIWa+ioOnMQZfH9vZw6 DLkzZGJonHQ6BC+ZWTHvraFm08pq+M7hrN40ZPW7nKK07+bBkGnngkc5L33wy2b9U5Lx UTjOwnxmtpOahCXd8LjOc3u0Vd2aAvLbIOEzLtdtyE6dMmoO8jiJErkXlFfXtKCv34fl oKbVRJfHSbdKkURDl2oKq2R9pPWlQknmTtroyupB15yTqyGaQIzpNdEPtzqv+NC7c4q2 ZNUTRU0SzdQ1Svi6YXsk5AFGd7VENEBX+tcxvpJ/k/ledJQHUvqlnAqT4hvkdGyHNUeU Q92g== X-Gm-Message-State: AOAM5318B1wf2MTmayucS8WLrGROjX+771IiyapblUIP10f36rVZgfOY 2OEZYlJHws4qhx09KZq/AUtf1A== X-Google-Smtp-Source: ABdhPJy8AuyQNxb4whKNCctkbA1azs0IZhY9O9LytlnZ5z+TbqJPk5olaevBrzC2skG27x8KfcXmRQ== X-Received: by 2002:a17:90b:1648:: with SMTP id il8mr3197315pjb.227.1643050417648; Mon, 24 Jan 2022 10:53:37 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:37 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 10/16] ionic: Query FW when getting VF info via ndo_get_vf_config Date: Mon, 24 Jan 2022 10:53:06 -0800 Message-Id: <20220124185312.72646-11-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley Currently when an administrator configures a VF via ndo_set_vf*, the driver will send the set command to FW and then update the cached value. The cached value is then used when reporting VF info via ndo_get_vf_config. A problem is that the VF info may have been updated between the last ndo_set_vf* and ndo_get_vf_info commands via some other method, i.e. a VF changes its MAC address (assuming it's allowed to do so) and since this is all managed by the FW, this new value won't be reflected in the PF's cache of values. To fix this, update the driver to always get the latest VF information by making use of the IONIC_CMD_VF_GETATTR dev command. The FW may not support getting all the attributes for IONIC_CMD_VF_GETATTR, so the driver will only update the cached VF config members if their associated IONIC_CMD_VF_GETATTR was successful. Otherwise the cached VF config members will remain the same as what was set in ndo_set_vf*. Fixes: fbb39807e9ae ("ionic: support sr-iov operations") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic.h | 2 + .../net/ethernet/pensando/ionic/ionic_dev.c | 40 +++++++++ .../net/ethernet/pensando/ionic/ionic_dev.h | 2 + .../net/ethernet/pensando/ionic/ionic_lif.c | 90 +++++++++++++++++-- .../net/ethernet/pensando/ionic/ionic_main.c | 22 +++++ 5 files changed, 148 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic.h b/drivers/net/ethernet/pensando/ionic/ionic.h index 6783c0e6ba4f..04fdaf5c1a02 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic.h +++ b/drivers/net/ethernet/pensando/ionic/ionic.h @@ -92,4 +92,6 @@ int ionic_port_identify(struct ionic *ionic); int ionic_port_init(struct ionic *ionic); int ionic_port_reset(struct ionic *ionic); +const char *ionic_vf_attr_to_str(enum ionic_vf_attr attr); + #endif /* _IONIC_H_ */ diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 35581cabbae3..1535a40a5fab 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -472,6 +472,46 @@ int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data) return err; } +int ionic_dev_cmd_vf_getattr(struct ionic *ionic, int vf, u8 attr, + struct ionic_vf_getattr_comp *comp) +{ + union ionic_dev_cmd cmd = { + .vf_getattr.opcode = IONIC_CMD_VF_GETATTR, + .vf_getattr.attr = attr, + .vf_getattr.vf_index = cpu_to_le16(vf), + }; + int err; + + if (vf >= ionic->num_vfs) + return -EINVAL; + + switch (attr) { + case IONIC_VF_ATTR_SPOOFCHK: + case IONIC_VF_ATTR_TRUST: + case IONIC_VF_ATTR_LINKSTATE: + case IONIC_VF_ATTR_MAC: + case IONIC_VF_ATTR_VLAN: + case IONIC_VF_ATTR_RATE: + break; + case IONIC_VF_ATTR_STATSADDR: + default: + return -EINVAL; + } + + mutex_lock(&ionic->dev_cmd_lock); + ionic_dev_cmd_go(&ionic->idev, &cmd); + err = ionic_dev_cmd_wait_nomsg(ionic, DEVCMD_TIMEOUT); + memcpy_fromio(comp, &ionic->idev.dev_cmd_regs->comp.vf_getattr, + sizeof(*comp)); + mutex_unlock(&ionic->dev_cmd_lock); + + if (err && comp->status != IONIC_RC_ENOSUPP) + ionic_dev_cmd_dev_err_print(ionic, cmd.vf_getattr.opcode, + comp->status, err); + + return err; +} + /* LIF commands */ void ionic_dev_cmd_queue_identify(struct ionic_dev *idev, u16 lif_type, u8 qtype, u8 qver) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 73b950ac1272..564c148f5fb4 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -319,6 +319,8 @@ void ionic_dev_cmd_port_fec(struct ionic_dev *idev, u8 fec_type); void ionic_dev_cmd_port_pause(struct ionic_dev *idev, u8 pause_type); int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data); +int ionic_dev_cmd_vf_getattr(struct ionic *ionic, int vf, u8 attr, + struct ionic_vf_getattr_comp *comp); void ionic_dev_cmd_queue_identify(struct ionic_dev *idev, u16 lif_type, u8 qtype, u8 qver); void ionic_dev_cmd_lif_identify(struct ionic_dev *idev, u8 type, u8 ver); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 13c00466023f..adee1b129e92 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -2157,6 +2157,76 @@ static int ionic_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd } } +static int ionic_update_cached_vf_config(struct ionic *ionic, int vf) +{ + struct ionic_vf_getattr_comp comp = { 0 }; + int err; + u8 attr; + + attr = IONIC_VF_ATTR_VLAN; + err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp); + if (err && comp.status != IONIC_RC_ENOSUPP) + goto err_out; + if (!err) + ionic->vfs[vf].vlanid = comp.vlanid; + + attr = IONIC_VF_ATTR_SPOOFCHK; + err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp); + if (err && comp.status != IONIC_RC_ENOSUPP) + goto err_out; + if (!err) + ionic->vfs[vf].spoofchk = comp.spoofchk; + + attr = IONIC_VF_ATTR_LINKSTATE; + err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp); + if (err && comp.status != IONIC_RC_ENOSUPP) + goto err_out; + if (!err) { + switch (comp.linkstate) { + case IONIC_VF_LINK_STATUS_UP: + ionic->vfs[vf].linkstate = IFLA_VF_LINK_STATE_ENABLE; + break; + case IONIC_VF_LINK_STATUS_DOWN: + ionic->vfs[vf].linkstate = IFLA_VF_LINK_STATE_DISABLE; + break; + case IONIC_VF_LINK_STATUS_AUTO: + ionic->vfs[vf].linkstate = IFLA_VF_LINK_STATE_AUTO; + break; + default: + dev_warn(ionic->dev, "Unexpected link state %u\n", comp.linkstate); + break; + } + } + + attr = IONIC_VF_ATTR_RATE; + err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp); + if (err && comp.status != IONIC_RC_ENOSUPP) + goto err_out; + if (!err) + ionic->vfs[vf].maxrate = comp.maxrate; + + attr = IONIC_VF_ATTR_TRUST; + err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp); + if (err && comp.status != IONIC_RC_ENOSUPP) + goto err_out; + if (!err) + ionic->vfs[vf].trusted = comp.trust; + + attr = IONIC_VF_ATTR_MAC; + err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp); + if (err && comp.status != IONIC_RC_ENOSUPP) + goto err_out; + if (!err) + ether_addr_copy(ionic->vfs[vf].macaddr, comp.macaddr); + +err_out: + if (err) + dev_err(ionic->dev, "Failed to get %s for VF %d\n", + ionic_vf_attr_to_str(attr), vf); + + return err; +} + static int ionic_get_vf_config(struct net_device *netdev, int vf, struct ifla_vf_info *ivf) { @@ -2172,14 +2242,18 @@ static int ionic_get_vf_config(struct net_device *netdev, if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ivf->vf = vf; - ivf->vlan = le16_to_cpu(ionic->vfs[vf].vlanid); - ivf->qos = 0; - ivf->spoofchk = ionic->vfs[vf].spoofchk; - ivf->linkstate = ionic->vfs[vf].linkstate; - ivf->max_tx_rate = le32_to_cpu(ionic->vfs[vf].maxrate); - ivf->trusted = ionic->vfs[vf].trusted; - ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr); + ivf->vf = vf; + ivf->qos = 0; + + ret = ionic_update_cached_vf_config(ionic, vf); + if (!ret) { + ivf->vlan = le16_to_cpu(ionic->vfs[vf].vlanid); + ivf->spoofchk = ionic->vfs[vf].spoofchk; + ivf->linkstate = ionic->vfs[vf].linkstate; + ivf->max_tx_rate = le32_to_cpu(ionic->vfs[vf].maxrate); + ivf->trusted = ionic->vfs[vf].trusted; + ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr); + } } up_read(&ionic->vf_op_lock); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 163174f07ed7..78771663808a 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -188,6 +188,28 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode) } } +const char *ionic_vf_attr_to_str(enum ionic_vf_attr attr) +{ + switch (attr) { + case IONIC_VF_ATTR_SPOOFCHK: + return "IONIC_VF_ATTR_SPOOFCHK"; + case IONIC_VF_ATTR_TRUST: + return "IONIC_VF_ATTR_TRUST"; + case IONIC_VF_ATTR_LINKSTATE: + return "IONIC_VF_ATTR_LINKSTATE"; + case IONIC_VF_ATTR_MAC: + return "IONIC_VF_ATTR_MAC"; + case IONIC_VF_ATTR_VLAN: + return "IONIC_VF_ATTR_VLAN"; + case IONIC_VF_ATTR_RATE: + return "IONIC_VF_ATTR_RATE"; + case IONIC_VF_ATTR_STATSADDR: + return "IONIC_VF_ATTR_STATSADDR"; + default: + return "IONIC_VF_ATTR_UNKNOWN"; + } +} + static void ionic_adminq_flush(struct ionic_lif *lif) { struct ionic_desc_info *desc_info; From patchwork Mon Jan 24 18:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722779 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F023C433FE for ; Mon, 24 Jan 2022 18:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343954AbiAXS5o (ORCPT ); Mon, 24 Jan 2022 13:57:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344554AbiAXSyr (ORCPT ); Mon, 24 Jan 2022 13:54:47 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221A5C061347 for ; Mon, 24 Jan 2022 10:53:39 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d7so16639864plr.12 for ; Mon, 24 Jan 2022 10:53:39 -0800 (PST) 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=MKIdVSYy7eCuFEVyN9FrYorP896yXAvKr1Vh748K9i8=; b=X47QfY3Sbgh2386AJhCB/tp57FFhJFularC7qbFlQ9qsYTp1e+syn8EFWWLFUvyRmJ fAK7f0S/vUsT0eYZ8KZ8RvR7xqJtNQhjdjulTD83CrpF9jPYaFPr4YNxpEGCTphEVxvP Mt56Fkv4VNCqG51VFdpJ/AjXYcZAAJvwJBBNc3zqxNG5wRMqtDK6cWQ2yy5sCHy0mqC9 SHr1ucvllXYZHQbvynFqZFgTdTIVp7sD2cGDuB7HZl4rDl3FPqS3RZ6u8iU6oRd+B8f3 PbbZKGTda8Yc+9+MjnVs8VLTIcfixBk9NEfFNdDz05BQ+2bPUbnWKORy4HI/etF0vD30 Sp3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MKIdVSYy7eCuFEVyN9FrYorP896yXAvKr1Vh748K9i8=; b=U2qwdmZa+4pBO/oETxKj2gN7v8yHy4z1JMSmtZioOiF6w5auGMqgaH5UMuDBA8THfk ndOZOSwG6TwWom82kayOUB+zpHA7WTEp5t4e9p0Y1ugRliHaBwlvHCb/F6OuCLutdtyB wmvOK9uK9qvX9e7zwNw3yVClrxPcH70taOuYfY4qnxexKuiB4c3Qbsc2sVHmX79hMMq3 miCsAPADCQyFJWMjB4rcLK/sx8AMPzSZd1EKYMlsg8Rs1TO+hUBOqwKib1sfIXcq/W1R 8g/bHKdnvh8QJzFb+pm8g1kzLF6Xo6nhmt/bQyeQjYTMNx1ED/gOOTJNgR1DLuwJLXib IKvw== X-Gm-Message-State: AOAM533skKMSWYoY//c3d7yFKwk8yIDv+ppaqILW/VfSzDQl9LVS9IEH 6JlMxiwJr2eufx2m9G3kZa5uhA== X-Google-Smtp-Source: ABdhPJxIztLX/DejVTYNKawrgFSX269Q6PZsURY66AuI4uqy0UHiA/RgB6mSc9gWNWxLKtZ9pP/rWA== X-Received: by 2002:a17:90b:33ca:: with SMTP id lk10mr3233468pjb.45.1643050418650; Mon, 24 Jan 2022 10:53:38 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:38 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 11/16] ionic: Prevent filter add/del err msgs when the device is not available Date: Mon, 24 Jan 2022 10:53:07 -0800 Message-Id: <20220124185312.72646-12-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley Currently when a request for add/deleting a filter is made when ionic_heartbeat_check() returns failure the driver will be overly verbose about failures, especially when these are usually temporary fails and the request will be retried later. An example of this is a filter add when the FW is in the middle of resetting: IONIC_CMD_RX_FILTER_ADD (31) failed: IONIC_RC_ERROR (-6) rx_filter add failed: ADDR 01:80:c2:00:00:0e Fix this by checking for -ENXIO and other error values on filter request fails before printing the error message. Add similar checking to the delete filter code. Fixes: f91958cc9622 ("ionic: tame the filter no space message") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../ethernet/pensando/ionic/ionic_rx_filter.c | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c index f6e785f949f9..b7363376dfc8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c @@ -376,10 +376,24 @@ static int ionic_lif_filter_add(struct ionic_lif *lif, spin_unlock_bh(&lif->rx_filters.lock); - if (err == -ENOSPC) { - if (le16_to_cpu(ctx.cmd.rx_filter_add.match) == IONIC_RX_FILTER_MATCH_VLAN) - lif->max_vlans = lif->nvlans; + /* store the max_vlans limit that we found */ + if (err == -ENOSPC && + le16_to_cpu(ctx.cmd.rx_filter_add.match) == IONIC_RX_FILTER_MATCH_VLAN) + lif->max_vlans = lif->nvlans; + + /* Prevent unnecessary error messages on recoverable + * errors as the filter will get retried on the next + * sync attempt. + */ + switch (err) { + case -ENOSPC: + case -ENXIO: + case -ETIMEDOUT: + case -EAGAIN: + case -EBUSY: return 0; + default: + break; } ionic_adminq_netdev_err_print(lif, ctx.cmd.cmd.opcode, @@ -494,9 +508,22 @@ static int ionic_lif_filter_del(struct ionic_lif *lif, spin_unlock_bh(&lif->rx_filters.lock); if (state != IONIC_FILTER_STATE_NEW) { - err = ionic_adminq_post_wait(lif, &ctx); - if (err && err != -EEXIST) + err = ionic_adminq_post_wait_nomsg(lif, &ctx); + + switch (err) { + /* ignore these errors */ + case -EEXIST: + case -ENXIO: + case -ETIMEDOUT: + case -EAGAIN: + case -EBUSY: + case 0: + break; + default: + ionic_adminq_netdev_err_print(lif, ctx.cmd.cmd.opcode, + ctx.comp.comp.status, err); return err; + } } return 0; From patchwork Mon Jan 24 18:53:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722778 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75D2AC43217 for ; Mon, 24 Jan 2022 18:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343812AbiAXS5n (ORCPT ); Mon, 24 Jan 2022 13:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344557AbiAXSys (ORCPT ); Mon, 24 Jan 2022 13:54:48 -0500 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 16949C061353 for ; Mon, 24 Jan 2022 10:53:40 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id z10-20020a17090acb0a00b001b520826011so9903pjt.5 for ; Mon, 24 Jan 2022 10:53:40 -0800 (PST) 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=mRU3UqtxyNf1zAAKIVJndcZ825EJaYE1oPvODudWCQ8=; b=Su6A/z1pEFp1PrJM9Cg/QxRHfMlW71lKnCMn5sEdyu10lKtz9GmtWoGE87dcgWbVjN zbI4C+SXP9p9WVwHCLaj8I6OE2hY6+Lc3CK6xJg2UKzyWp9GRWmvucITUxyQDXCdhgUK YCFVJfHhpwO5tMdSMEvfaCrRtSbpS8gtaC6Nk28gWBTfU/ur7vWx6HjL7Zc1gh+6AIRk lLat39EvFtAUdfj8mtv/kum16R5up352K4INvcspr1CdlgJuaJHgtJZwnuVgPbDYRxNR rzQDsqHmr5urPnOemcjI5aXIxlkS4YgbUDSII5KkPPjLIMmtIqZPfi9DozfXeMYJjVXA Ajtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mRU3UqtxyNf1zAAKIVJndcZ825EJaYE1oPvODudWCQ8=; b=4Vn7EtUirFNoqbksTYJUukzrDZRqxAmmhxz+yvonm2n/+w/s4b+46evvNhnh3Fk8hh dc9447kC261fuyOjhY4yB5hfUoT9mYrsxsviPf3uzh7r94xakIlMe9xjeQMcFc+DduF3 mym0Q+vLQT7xawKPFPNHNvMX4EdnlbYptOkYHY1Ys2TkLV7C42E1OTmwJCmWiG+TQI2p ACzstseM1GWHxWxwWqS8lCA94Fo/EZlLQkggSruHKEsHxb6xK0NCcszXaRTH0McbDqwq ySlXksffw63cYR0OCi2kQEUDmBfVwJy1lQh7X7es7KTGg2LQpuaHE37hkLm4JnY3tfC4 xjGQ== X-Gm-Message-State: AOAM533u38aIoKFIhg3BVIrKSNwu+0L1upF/9VZYkfvpBpR4wOe64vV/ 2YlSUCdWBU42wnsw4sfceliibA== X-Google-Smtp-Source: ABdhPJwiZlI+6lM4zYtUDrSGJziOeZRwsyDLx1c9BsYLXmuW9dbbfoDbNQ8EvUCAlZZX75p3ZF+iWQ== X-Received: by 2002:a17:90a:5a0e:: with SMTP id b14mr3240419pjd.148.1643050419609; Mon, 24 Jan 2022 10:53:39 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:39 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 12/16] ionic: Cleanups in the Tx hotpath code Date: Mon, 24 Jan 2022 10:53:08 -0800 Message-Id: <20220124185312.72646-13-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley Buffer DMA mapping happens in ionic_tx_map_skb() and this function is called from ionic_tx() and ionic_tx_tso(). If ionic_tx_map_skb() succeeds, but a failure is encountered later in ionic_tx() or ionic_tx_tso() we aren't unmapping the buffers. This can be fixed in ionic_tx() by changing functions it calls to return void because they always return 0. For ionic_tx_tso(), there's an actual possibility that we leave the buffers mapped, so fix this by introducing the helper function ionic_tx_desc_unmap_bufs(). This function is also re-used in ionic_tx_clean(). Fixes: 0f3154e6bcb3 ("ionic: Add Tx and Rx handling") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_txrx.c | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 94384f5d2a22..d197a70a49c9 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -669,27 +669,37 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb, return -EIO; } +static void ionic_tx_desc_unmap_bufs(struct ionic_queue *q, + struct ionic_desc_info *desc_info) +{ + struct ionic_buf_info *buf_info = desc_info->bufs; + struct device *dev = q->dev; + unsigned int i; + + if (!desc_info->nbufs) + return; + + dma_unmap_single(dev, (dma_addr_t)buf_info->dma_addr, + buf_info->len, DMA_TO_DEVICE); + buf_info++; + for (i = 1; i < desc_info->nbufs; i++, buf_info++) + dma_unmap_page(dev, (dma_addr_t)buf_info->dma_addr, + buf_info->len, DMA_TO_DEVICE); + + desc_info->nbufs = 0; +} + static void ionic_tx_clean(struct ionic_queue *q, struct ionic_desc_info *desc_info, struct ionic_cq_info *cq_info, void *cb_arg) { - struct ionic_buf_info *buf_info = desc_info->bufs; struct ionic_tx_stats *stats = q_to_tx_stats(q); struct ionic_qcq *qcq = q_to_qcq(q); struct sk_buff *skb = cb_arg; - struct device *dev = q->dev; - unsigned int i; u16 qi; - if (desc_info->nbufs) { - dma_unmap_single(dev, (dma_addr_t)buf_info->dma_addr, - buf_info->len, DMA_TO_DEVICE); - buf_info++; - for (i = 1; i < desc_info->nbufs; i++, buf_info++) - dma_unmap_page(dev, (dma_addr_t)buf_info->dma_addr, - buf_info->len, DMA_TO_DEVICE); - } + ionic_tx_desc_unmap_bufs(q, desc_info); if (!skb) return; @@ -931,8 +941,11 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb) err = ionic_tx_tcp_inner_pseudo_csum(skb); else err = ionic_tx_tcp_pseudo_csum(skb); - if (err) + if (err) { + /* clean up mapping from ionic_tx_map_skb */ + ionic_tx_desc_unmap_bufs(q, desc_info); return err; + } if (encap) hdrlen = skb_inner_transport_header(skb) - skb->data + @@ -1003,8 +1016,8 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb) return 0; } -static int ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb, - struct ionic_desc_info *desc_info) +static void ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb, + struct ionic_desc_info *desc_info) { struct ionic_txq_desc *desc = desc_info->txq_desc; struct ionic_buf_info *buf_info = desc_info->bufs; @@ -1038,12 +1051,10 @@ static int ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb, stats->crc32_csum++; else stats->csum++; - - return 0; } -static int ionic_tx_calc_no_csum(struct ionic_queue *q, struct sk_buff *skb, - struct ionic_desc_info *desc_info) +static void ionic_tx_calc_no_csum(struct ionic_queue *q, struct sk_buff *skb, + struct ionic_desc_info *desc_info) { struct ionic_txq_desc *desc = desc_info->txq_desc; struct ionic_buf_info *buf_info = desc_info->bufs; @@ -1074,12 +1085,10 @@ static int ionic_tx_calc_no_csum(struct ionic_queue *q, struct sk_buff *skb, desc->csum_offset = 0; stats->csum_none++; - - return 0; } -static int ionic_tx_skb_frags(struct ionic_queue *q, struct sk_buff *skb, - struct ionic_desc_info *desc_info) +static void ionic_tx_skb_frags(struct ionic_queue *q, struct sk_buff *skb, + struct ionic_desc_info *desc_info) { struct ionic_txq_sg_desc *sg_desc = desc_info->txq_sg_desc; struct ionic_buf_info *buf_info = &desc_info->bufs[1]; @@ -1093,31 +1102,24 @@ static int ionic_tx_skb_frags(struct ionic_queue *q, struct sk_buff *skb, } stats->frags += skb_shinfo(skb)->nr_frags; - - return 0; } static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb) { struct ionic_desc_info *desc_info = &q->info[q->head_idx]; struct ionic_tx_stats *stats = q_to_tx_stats(q); - int err; if (unlikely(ionic_tx_map_skb(q, skb, desc_info))) return -EIO; /* set up the initial descriptor */ if (skb->ip_summed == CHECKSUM_PARTIAL) - err = ionic_tx_calc_csum(q, skb, desc_info); + ionic_tx_calc_csum(q, skb, desc_info); else - err = ionic_tx_calc_no_csum(q, skb, desc_info); - if (err) - return err; + ionic_tx_calc_no_csum(q, skb, desc_info); /* add frags */ - err = ionic_tx_skb_frags(q, skb, desc_info); - if (err) - return err; + ionic_tx_skb_frags(q, skb, desc_info); skb_tx_timestamp(skb); stats->pkts++; From patchwork Mon Jan 24 18:53:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722777 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 448E8C433EF for ; Mon, 24 Jan 2022 18:57:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242475AbiAXS5i (ORCPT ); Mon, 24 Jan 2022 13:57:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344565AbiAXSys (ORCPT ); Mon, 24 Jan 2022 13:54:48 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2663CC06135B for ; Mon, 24 Jan 2022 10:53:41 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id c3so16654835pls.5 for ; Mon, 24 Jan 2022 10:53:41 -0800 (PST) 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=G+QrDu8pRdRC9MbHC3CaoWKFwfJNJuGA8iAzraMDrGg=; b=v+x0QPoWKJGB9YoyU2Ht9fvUvmvUEPkM/B6p12XSuPmJTtOBIx5KaJky6UddP3wyml k5KVwoOuJNUoSKKkxG63hOTIuqhlZUkBxTXHk3yDwW/nm7m1DWRejJg9qoiQoczQYQiC Ay3uLpS/6TVI0nU8s7L+IWqOn0CiTqMDDwt0jNvis22OULRyVq1onSNZTLz3TcC/PLrC jhCvz482oBIWryYNddPWNhv2EuUtf7643xNO206imMWOBV7MH2ZsaIhqdvAE7u0Cxvcj 4xROm/e8qxKDovPI0NX9EscTrmzJUW/rVXq5QiB/PCwx4KJHT+1WuWs6rtgaaTXVwL+0 FbGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G+QrDu8pRdRC9MbHC3CaoWKFwfJNJuGA8iAzraMDrGg=; b=lvoWWHkXun49+vXH4f2Mh2KFCa5DPlaYv4mQr6hGAQ+IWYXUVasBQWQSIXKKbYBIFa UgynOe4d/KeD/kCH1IW4hWRGly15DpjT1omwjzLg0Piu7Z2Zu+ES/hIsZEvnPiO1BKu8 x/QJ3myjE2dOQoL8KDfN5AtspmjiggZnlLFvTihwntO4ZdtQwSYMwiQ+fgR4MeirGgOs lP62DkB6laR8MdJHtGzw7k8Clv1d0WoZdrCi4/mLZTjxB2Yd0TdTVPCgF1pTmN1TjzpL GtNqTfqktyHXIJt6v3oS3nt54EtkNU/R59mvfC0mFGcJ6zuwoQGkVdaOnVgDp0Zl6Vte s7Fg== X-Gm-Message-State: AOAM531+tMRxJ/GqhG0310ywHBA3SX1PtKQmcerJRtFEFtmsMgc5eZ2w Ll5vE6TzUP0qdxKZ5/tHa1JYFw== X-Google-Smtp-Source: ABdhPJwT82ZGRukHhKFrN3fsZEK2q2PMldOQojx6oIfP6C7p5fSpJ9vcUViI6oTTyd1d7HTy/k6GNg== X-Received: by 2002:a17:90a:77c6:: with SMTP id e6mr3262385pjs.115.1643050420701; Mon, 24 Jan 2022 10:53:40 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:40 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Brett Creeley , Shannon Nelson Subject: [PATCH net 13/16] ionic: disable napi when ionic_lif_init() fails Date: Mon, 24 Jan 2022 10:53:09 -0800 Message-Id: <20220124185312.72646-14-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Brett Creeley When the driver is going through reset, it will eventually call ionic_lif_init(), which does a lot of re-initialization. One of the re-initialization steps is to setup the adminq and enable napi for it. If something breaks after this point we can end up with a kernel NULL pointer dereference through ionic_adminq_napi. Fix this by making sure to call napi_disable() in the cleanup path of ionic_lif_init(). This forces any pending napi contexts to finish and prevents them from being recalled before deleting the napi context. Fixes: 77ceb68e29cc ("ionic: Add notifyq support") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index adee1b129e92..c9535f4863ba 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -3266,6 +3266,7 @@ int ionic_lif_init(struct ionic_lif *lif) return 0; err_out_notifyq_deinit: + napi_disable(&lif->adminqcq->napi); ionic_lif_qcq_deinit(lif, lif->notifyqcq); err_out_adminq_deinit: ionic_lif_qcq_deinit(lif, lif->adminqcq); From patchwork Mon Jan 24 18:53:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722774 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ACE8C433F5 for ; Mon, 24 Jan 2022 18:57:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245519AbiAXS46 (ORCPT ); Mon, 24 Jan 2022 13:56:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344564AbiAXSys (ORCPT ); Mon, 24 Jan 2022 13:54:48 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D410C061776 for ; Mon, 24 Jan 2022 10:53:42 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id l17so10456983plg.1 for ; Mon, 24 Jan 2022 10:53:42 -0800 (PST) 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=bz5OSIhu8tiUBZ2woPncS24gjC0NBZkHI9Xptd2J15Y=; b=oGbCyt/2eQJkSETc6yVa0XvS2hDM5VjAQRijEKP6rEDMmKGVzqO8coiuXjON/SPeSG etKGzgf0hJrCcC4ap/Iwo5WlGR2jL/XTnRvoIvhECUhlFDk45YJNn71a1pLdNRVCxEXK f6EpdeIlfhR70gpM7i9g6c5ggIVaWw1F+U9hfEW9A7ymampwUY6Zh08cZSFnEvVCSPPo H2nQnXe4DAnFMTq5/eJj6Xq/0FWFcb6LbqAr1qT76XLX1xwD+B0NJ3JP1XbdiFcQDZ3u l7ApuTZ9i8LY+ID7l2NQwFVhY6bl8oaWrFM7Pedn5z3mQw3KMRGi0sWceJoJP+uw6wSI 5ujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bz5OSIhu8tiUBZ2woPncS24gjC0NBZkHI9Xptd2J15Y=; b=rLmcbaPPNOielkbh5NjmYz4TmIJdFDGN6pboD3IW3wvRUUTAgTodRyeo5lRFxZADHc Gmd2ecoDXcPn09M4vTtfdO58I9PByRADxxOTxu+4SEK8OXvpuo4EQb1j5dQ1AAIK+sNN ZJMGMvjSzaO5jux5aWDicu3y2o245YxRCRp98zr/ik149iiB3elBEHgwGsKsvk2qerAJ ArW8IH//xtx24ES7NUacMv4dg+40PLRQw8weiLMNEss3IZk1Pz9HndfJ0vIWcoVk0E+k wyYUsd5NwQMWoyqz83Qc2qhPGSdBAEZp6uckSyuAFtWtagjGE7xiHJd3QUkJc5k97/rb af4w== X-Gm-Message-State: AOAM531rciNMNHzoAPkirmFETHQjonqG/M3HOTgD1u0ZXA/DZykZVbVy UUf/iCp53Oef5YELHaF2bcY1tfNHdW+P1A== X-Google-Smtp-Source: ABdhPJwa6ojTNQ/rZtP8/PpYUXu8H9JTi3+uJx6rLU9V2e8rgDgg4TZW3AXM93NCPxiW7x2wLW13qw== X-Received: by 2002:a17:902:be08:b0:14a:ef2e:60e2 with SMTP id r8-20020a170902be0800b0014aef2e60e2mr15164204pls.128.1643050422056; Mon, 24 Jan 2022 10:53:42 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:41 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 14/16] ionic: remove the dbid_inuse bitmap Date: Mon, 24 Jan 2022 10:53:10 -0800 Message-Id: <20220124185312.72646-15-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The dbid_inuse bitmap is not useful in this driver so remove it. Fixes: 6461b446f2a0 ("ionic: Add interrupts and doorbells") Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 +---------------- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 - 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index c9535f4863ba..e84a01edc4e4 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -3014,8 +3014,6 @@ void ionic_lif_free(struct ionic_lif *lif) /* unmap doorbell page */ ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); lif->kern_dbpage = NULL; - kfree(lif->dbid_inuse); - lif->dbid_inuse = NULL; mutex_destroy(&lif->config_lock); mutex_destroy(&lif->queue_lock); @@ -3215,22 +3213,12 @@ int ionic_lif_init(struct ionic_lif *lif) return -EINVAL; } - lif->dbid_inuse = bitmap_zalloc(lif->dbid_count, GFP_KERNEL); - if (!lif->dbid_inuse) { - dev_err(dev, "Failed alloc doorbell id bitmap, aborting\n"); - return -ENOMEM; - } - - /* first doorbell id reserved for kernel (dbid aka pid == zero) */ - set_bit(0, lif->dbid_inuse); lif->kern_pid = 0; - dbpage_num = ionic_db_page_num(lif, lif->kern_pid); lif->kern_dbpage = ionic_bus_map_dbpage(lif->ionic, dbpage_num); if (!lif->kern_dbpage) { dev_err(dev, "Cannot map dbpage, aborting\n"); - err = -ENOMEM; - goto err_out_free_dbid; + return -ENOMEM; } err = ionic_lif_adminq_init(lif); @@ -3273,9 +3261,6 @@ int ionic_lif_init(struct ionic_lif *lif) ionic_lif_reset(lif); ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); lif->kern_dbpage = NULL; -err_out_free_dbid: - kfree(lif->dbid_inuse); - lif->dbid_inuse = NULL; return err; } diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index 2db708df6b55..a53984bf3544 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -214,7 +214,6 @@ struct ionic_lif { u32 rx_coalesce_hw; /* what the hw is using */ u32 tx_coalesce_usecs; /* what the user asked for */ u32 tx_coalesce_hw; /* what the hw is using */ - unsigned long *dbid_inuse; unsigned int dbid_count; struct ionic_phc *phc; From patchwork Mon Jan 24 18:53:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722776 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6047C4332F for ; Mon, 24 Jan 2022 18:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245752AbiAXS5d (ORCPT ); Mon, 24 Jan 2022 13:57:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344591AbiAXSyv (ORCPT ); Mon, 24 Jan 2022 13:54:51 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16432C061361 for ; Mon, 24 Jan 2022 10:53:44 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d18so3963307plg.2 for ; Mon, 24 Jan 2022 10:53:44 -0800 (PST) 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=LDiJ4O9YgSkrxT2JnPNMqnuvU7WYXCkaM3BNfwrpAdc=; b=fHPBknhuLvoz6SHTLBa70TtjGR49UMyqoi2r2uar1ka0DatPD+I4UUhiqpa5LbN3lm 52f3UMfCmztQNOmF9yaXm/hUKuvKwNwqwSUfzaw3kmsBHX/dx4SQh1/N/bjoenKW/USL 4rawtvYGk0PVioQlUabyogDOX4IpzU0ZMP0oWAp/7hXk6fwH9TmNq6OyEMGKBdDVM2ah yL4CH4/EYJCMi9uPbiQt4poqMCWCOAbdSHdgwsUZQG8EERw3jnLqJW+ljgXc3eh4btmX hlXG1cZpzZ2nYRkmsy30BYYKU/t7Z1DLFgNsrOKEMg7AHV/soGtN7FSc6LdsKgneSzr6 fspA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LDiJ4O9YgSkrxT2JnPNMqnuvU7WYXCkaM3BNfwrpAdc=; b=T8CmAGSC0ELiuYrr9SNXNa/O36BKhU6dcxjk4DNgsKEDAjgh42ZzJ5CQpaKBibjrcR F2Q7dydDM/n7KJZf/4ofxfhyvZmEQ8grvGwxplOI9nz1kBXP/bpk3TzDQFBGElxdM5Ra h6XHqVwP7MYUIpDe63MCq1wNLqbHeN1JktLwIw/YjCBO2eT9bAGUAHvYbtP69GMyT0Lv AwOTa3lru/Q7WCblsAJiE+nXEtklTcCMczfnSqGC56tzKH9Ha4cm4JFLHN2c83pt12x7 HuVclKAAEDnUg5gTrdyC20lWthYWIiiVpeTupeixxBycFXyG12wTT9npTeHC7yFvi1l8 /2JQ== X-Gm-Message-State: AOAM531l495WZAw3WGl7N0GR1Mg/AQJlud2wKnaorxQB2Exr3y3RpnG6 Rsp/Np8dIA106AJcoN4Mkg7faA== X-Google-Smtp-Source: ABdhPJwjiiDDr9foIUX9zVWNrEEAVdN8rv+KZpkfrr0IrpN80n+jWV95SspZu5ikJlTA5vHfXH68xg== X-Received: by 2002:a17:903:2443:b0:14b:3758:f07b with SMTP id l3-20020a170903244300b0014b3758f07bmr9390302pls.28.1643050423555; Mon, 24 Jan 2022 10:53:43 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:42 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson , Brett Creeley Subject: [PATCH net 15/16] ionic: stretch heartbeat detection Date: Mon, 24 Jan 2022 10:53:11 -0800 Message-Id: <20220124185312.72646-16-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The driver can be premature in detecting stalled firmware when the heartbeat is not updated because the firmware can occasionally take a long time (more than 2 seconds) to service a request, and doesn't update the heartbeat during that time. The firmware heartbeat is not necessarily a steady 1 second periodic beat, but better described as something that should progress at least once in every DECVMD_TIMEOUT period. The single-threaded design in the FW means that if a devcmd or adminq request launches a large internal job, it is stuck waiting for that job to finish before it can get back to updating the heartbeat. Since all requests are "guaranteed" to finish within the DEVCMD_TIMEOUT period, the driver needs to less aggressive in checking the heartbeat progress. We change our current 2 second window to something bigger than DEVCMD_TIMEOUT which should take care of most of the issue. We stop checking for the heartbeat while waiting for a request, as long as we're still watching for the FW status. Lastly, we make sure our FW status is up to date before running a devcmd request. Once we do this, we need to not check the heartbeat on DEV commands because it may be stalled while we're on the fw_down path. Instead, we can rely on the is_fw_running check. Fixes: b2b9a8d7ed13 ("ionic: avoid races in ionic_heartbeat_check") Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic.h | 2 +- .../net/ethernet/pensando/ionic/ionic_dev.c | 6 ++-- .../net/ethernet/pensando/ionic/ionic_lif.c | 2 +- .../net/ethernet/pensando/ionic/ionic_main.c | 34 ++++++++----------- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic.h b/drivers/net/ethernet/pensando/ionic/ionic.h index 04fdaf5c1a02..602f4d45d529 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic.h +++ b/drivers/net/ethernet/pensando/ionic/ionic.h @@ -18,7 +18,7 @@ struct ionic_lif; #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF 0x1002 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF 0x1003 -#define DEVCMD_TIMEOUT 10 +#define DEVCMD_TIMEOUT 5 #define IONIC_ADMINQ_TIME_SLICE msecs_to_jiffies(100) #define IONIC_PHC_UPDATE_NS 10000000000 /* 10s in nanoseconds */ diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 1535a40a5fab..51d36a549ef7 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -236,9 +236,11 @@ int ionic_heartbeat_check(struct ionic *ionic) if (!idev->fw_status_ready) return -ENXIO; - /* wait at least one watchdog period since the last heartbeat */ + /* Because of some variability in the actual FW heartbeat, we + * wait longer than the DEVCMD_TIMEOUT before checking again. + */ last_check_time = idev->last_hb_time; - if (time_before(check_time, last_check_time + ionic->watchdog_period)) + if (time_before(check_time, last_check_time + DEVCMD_TIMEOUT * 2 * HZ)) return 0; fw_hb = ioread32(&idev->dev_info_regs->fw_heartbeat); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index e84a01edc4e4..05dd8c4f5466 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -1787,7 +1787,7 @@ static void ionic_lif_quiesce(struct ionic_lif *lif) err = ionic_adminq_post_wait(lif, &ctx); if (err) - netdev_err(lif->netdev, "lif quiesce failed %d\n", err); + netdev_dbg(lif->netdev, "lif quiesce failed %d\n", err); } static void ionic_txrx_disable(struct ionic_lif *lif) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 78771663808a..4029b4e021f8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -358,13 +358,14 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx, if (remaining) break; - /* interrupt the wait if FW stopped */ + /* force a check of FW status and break out if FW reset */ + (void)ionic_heartbeat_check(lif->ionic); if ((test_bit(IONIC_LIF_F_FW_RESET, lif->state) && !lif->ionic->idev.fw_status_ready) || test_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { if (do_msg) - netdev_err(netdev, "%s (%d) interrupted, FW in reset\n", - name, ctx->cmd.cmd.opcode); + netdev_warn(netdev, "%s (%d) interrupted, FW in reset\n", + name, ctx->cmd.cmd.opcode); ctx->comp.comp.status = IONIC_RC_ERROR; return -ENXIO; } @@ -425,9 +426,9 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, unsigned long start_time; unsigned long max_wait; unsigned long duration; + int done = 0; + bool fw_up; int opcode; - int hb = 0; - int done; int err; /* Wait for dev cmd to complete, retrying if we get EAGAIN, @@ -437,31 +438,24 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, try_again: opcode = readb(&idev->dev_cmd_regs->cmd.cmd.opcode); start_time = jiffies; - do { + for (fw_up = ionic_is_fw_running(idev); + !done && fw_up && time_before(jiffies, max_wait); + fw_up = ionic_is_fw_running(idev)) { done = ionic_dev_cmd_done(idev); if (done) break; usleep_range(100, 200); - - /* Don't check the heartbeat on FW_CONTROL commands as they are - * notorious for interrupting the firmware's heartbeat update. - */ - if (opcode != IONIC_CMD_FW_CONTROL) - hb = ionic_heartbeat_check(ionic); - } while (!done && !hb && time_before(jiffies, max_wait)); + } duration = jiffies - start_time; dev_dbg(ionic->dev, "DEVCMD %s (%d) done=%d took %ld secs (%ld jiffies)\n", ionic_opcode_to_str(opcode), opcode, done, duration / HZ, duration); - if (!done && hb) { - /* It is possible (but unlikely) that FW was busy and missed a - * heartbeat check but is still alive and will process this - * request, so don't clean the dev_cmd in this case. - */ - dev_dbg(ionic->dev, "DEVCMD %s (%d) failed - FW halted\n", - ionic_opcode_to_str(opcode), opcode); + if (!done && !fw_up) { + ionic_dev_cmd_clean(ionic); + dev_warn(ionic->dev, "DEVCMD %s (%d) interrupted - FW is down\n", + ionic_opcode_to_str(opcode), opcode); return -ENXIO; } From patchwork Mon Jan 24 18:53:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 12722775 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E88BC433FE for ; Mon, 24 Jan 2022 18:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbiAXS5d (ORCPT ); Mon, 24 Jan 2022 13:57:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344596AbiAXSyv (ORCPT ); Mon, 24 Jan 2022 13:54:51 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13894C061364 for ; Mon, 24 Jan 2022 10:53:45 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d18so3963386plg.2 for ; Mon, 24 Jan 2022 10:53:45 -0800 (PST) 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=atiah5p2M2X+8gNdWdE4V/GZ2Lqe02AcZhr/ftx73qc=; b=rls3E/gUZQhz22fb9GcMK+oXI8lITtRhlmq9ptuWWwF/PZ6Mmv9YOABDTpMiQCp9+w evP8GeTMc1lxzd37fOQbuCgLt1wM55ElS/fI+2LiWTLdp9r6cKsPUtI3hXPvpZT34fXT LORdcK7r+m2XVcSTUOEhPID+Cf4OIIxjY3s+kWE0gtHNGr/FUjdtnuo6cx8Fw+vQJDDh DxZB3IQQgS/7o+M1fuw2R+HhkG2rPelCoOHvUHorenMhR/UmX9yP5j/eBbuQA4n5xCYJ mXVcXIy8Kj5wX6zumRLZ4nQ2exX12+3nGhDnoHQO/eRoy1g7szrqV+GHOOfyeCAoXICd hjMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=atiah5p2M2X+8gNdWdE4V/GZ2Lqe02AcZhr/ftx73qc=; b=tCBpH/P0D1WLII9Mq77Yc93PD9jQLXE2SOOwJJmyvabX8H7m8Yl0NVTCbQ4i6taIk6 nGlcOwZ2lNnpaZMKsa+aQvnRwXTikWhWPO6B+RnKWBrA9s8dbdNJd7z8f+6LZSvFrVqc lexpbLF5jDnpWCfnvX+WST4oG+TWDe1sBMBsNggdKc9wlv9vn+MbNfUT0YOSQYJXu+8c ojp/DUXL9qLgAiOWXGU0DUrnSwda6cN6L0WYPDwMiIaAhz6/7wlEIHMozD92DL2WmXT5 xaaoH/f8Jbz3TLdcTGLf3Ks9lB21fcYxY3wP7DDwf7N0J+1HwiImYJKpN3r5TTI/2TWW nypA== X-Gm-Message-State: AOAM530zLOhgJr4bfqQXIj4pQv1lHmqUzNzFx6Doj65PQWr9T7rWmf67 LVbcVVJ0t1qzPuiHgiYG11HinQ== X-Google-Smtp-Source: ABdhPJzOFlRLKWxnwKmRg/INMZMFCqEinSJg1GCrMru/7AG8PBChtz5jbKx2dec+b6vjA2Tc9a5Zrg== X-Received: by 2002:a17:903:41c9:b0:14b:54e6:c6b7 with SMTP id u9-20020a17090341c900b0014b54e6c6b7mr5276536ple.36.1643050424573; Mon, 24 Jan 2022 10:53:44 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id cq14sm85177pjb.33.2022.01.24.10.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 10:53:44 -0800 (PST) From: Shannon Nelson To: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org Cc: drivers@pensando.io, Shannon Nelson Subject: [PATCH net 16/16] ionic: replace set_vf data with union Date: Mon, 24 Jan 2022 10:53:12 -0800 Message-Id: <20220124185312.72646-17-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124185312.72646-1-snelson@pensando.io> References: <20220124185312.72646-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This (ab)use of a data buffer made some static code checkers rather itchy, so we replace the a generic data buffer with the union in the struct ionic_vf_setattr_cmd. Fixes: fbb39807e9ae ("ionic: support sr-iov operations") Signed-off-by: Shannon Nelson --- .../ethernet/pensando/ionic/ionic_bus_pci.c | 13 ++-- .../net/ethernet/pensando/ionic/ionic_dev.c | 45 ++------------ .../net/ethernet/pensando/ionic/ionic_dev.h | 3 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 61 +++++++++++++------ 4 files changed, 55 insertions(+), 67 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c index 40fa5bce2ac2..6ffc62c41165 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c @@ -109,8 +109,8 @@ void ionic_bus_unmap_dbpage(struct ionic *ionic, void __iomem *page) static void ionic_vf_dealloc_locked(struct ionic *ionic) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_STATSADDR }; struct ionic_vf *v; - dma_addr_t dma = 0; int i; if (!ionic->vfs) @@ -120,9 +120,8 @@ static void ionic_vf_dealloc_locked(struct ionic *ionic) v = &ionic->vfs[i]; if (v->stats_pa) { - (void)ionic_set_vf_config(ionic, i, - IONIC_VF_ATTR_STATSADDR, - (u8 *)&dma); + vfc.stats_pa = 0; + (void)ionic_set_vf_config(ionic, i, &vfc); dma_unmap_single(ionic->dev, v->stats_pa, sizeof(v->stats), DMA_FROM_DEVICE); v->stats_pa = 0; @@ -143,6 +142,7 @@ static void ionic_vf_dealloc(struct ionic *ionic) static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_STATSADDR }; struct ionic_vf *v; int err = 0; int i; @@ -166,9 +166,10 @@ static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) } ionic->num_vfs++; + /* ignore failures from older FW, we just won't get stats */ - (void)ionic_set_vf_config(ionic, i, IONIC_VF_ATTR_STATSADDR, - (u8 *)&v->stats_pa); + vfc.stats_pa = cpu_to_le64(v->stats_pa); + (void)ionic_set_vf_config(ionic, i, &vfc); } out: diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c index 51d36a549ef7..52a1b5cfd8e7 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c @@ -417,54 +417,17 @@ void ionic_dev_cmd_port_pause(struct ionic_dev *idev, u8 pause_type) } /* VF commands */ -int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data) +int ionic_set_vf_config(struct ionic *ionic, int vf, + struct ionic_vf_setattr_cmd *vfc) { union ionic_dev_cmd cmd = { .vf_setattr.opcode = IONIC_CMD_VF_SETATTR, - .vf_setattr.attr = attr, + .vf_setattr.attr = vfc->attr, .vf_setattr.vf_index = cpu_to_le16(vf), }; int err; - switch (attr) { - case IONIC_VF_ATTR_SPOOFCHK: - cmd.vf_setattr.spoofchk = *data; - dev_dbg(ionic->dev, "%s: vf %d spoof %d\n", - __func__, vf, *data); - break; - case IONIC_VF_ATTR_TRUST: - cmd.vf_setattr.trust = *data; - dev_dbg(ionic->dev, "%s: vf %d trust %d\n", - __func__, vf, *data); - break; - case IONIC_VF_ATTR_LINKSTATE: - cmd.vf_setattr.linkstate = *data; - dev_dbg(ionic->dev, "%s: vf %d linkstate %d\n", - __func__, vf, *data); - break; - case IONIC_VF_ATTR_MAC: - ether_addr_copy(cmd.vf_setattr.macaddr, data); - dev_dbg(ionic->dev, "%s: vf %d macaddr %pM\n", - __func__, vf, data); - break; - case IONIC_VF_ATTR_VLAN: - cmd.vf_setattr.vlanid = cpu_to_le16(*(u16 *)data); - dev_dbg(ionic->dev, "%s: vf %d vlan %d\n", - __func__, vf, *(u16 *)data); - break; - case IONIC_VF_ATTR_RATE: - cmd.vf_setattr.maxrate = cpu_to_le32(*(u32 *)data); - dev_dbg(ionic->dev, "%s: vf %d maxrate %d\n", - __func__, vf, *(u32 *)data); - break; - case IONIC_VF_ATTR_STATSADDR: - cmd.vf_setattr.stats_pa = cpu_to_le64(*(u64 *)data); - dev_dbg(ionic->dev, "%s: vf %d stats_pa 0x%08llx\n", - __func__, vf, *(u64 *)data); - break; - default: - return -EINVAL; - } + memcpy(cmd.vf_setattr.pad, vfc->pad, sizeof(vfc->pad)); mutex_lock(&ionic->dev_cmd_lock); ionic_dev_cmd_go(&ionic->idev, &cmd); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 564c148f5fb4..563c302eb033 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -318,7 +318,8 @@ void ionic_dev_cmd_port_autoneg(struct ionic_dev *idev, u8 an_enable); void ionic_dev_cmd_port_fec(struct ionic_dev *idev, u8 fec_type); void ionic_dev_cmd_port_pause(struct ionic_dev *idev, u8 pause_type); -int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data); +int ionic_set_vf_config(struct ionic *ionic, int vf, + struct ionic_vf_setattr_cmd *vfc); int ionic_dev_cmd_vf_getattr(struct ionic *ionic, int vf, u8 attr, struct ionic_vf_getattr_comp *comp); void ionic_dev_cmd_queue_identify(struct ionic_dev *idev, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 05dd8c4f5466..542e395fb037 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -2299,6 +2299,7 @@ static int ionic_get_vf_stats(struct net_device *netdev, int vf, static int ionic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_MAC }; struct ionic_lif *lif = netdev_priv(netdev); struct ionic *ionic = lif->ionic; int ret; @@ -2314,7 +2315,11 @@ static int ionic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ret = ionic_set_vf_config(ionic, vf, IONIC_VF_ATTR_MAC, mac); + ether_addr_copy(vfc.macaddr, mac); + dev_dbg(ionic->dev, "%s: vf %d macaddr %pM\n", + __func__, vf, vfc.macaddr); + + ret = ionic_set_vf_config(ionic, vf, &vfc); if (!ret) ether_addr_copy(ionic->vfs[vf].macaddr, mac); } @@ -2326,6 +2331,7 @@ static int ionic_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos, __be16 proto) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_VLAN }; struct ionic_lif *lif = netdev_priv(netdev); struct ionic *ionic = lif->ionic; int ret; @@ -2348,8 +2354,11 @@ static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ret = ionic_set_vf_config(ionic, vf, - IONIC_VF_ATTR_VLAN, (u8 *)&vlan); + vfc.vlanid = cpu_to_le16(vlan); + dev_dbg(ionic->dev, "%s: vf %d vlan %d\n", + __func__, vf, le16_to_cpu(vfc.vlanid)); + + ret = ionic_set_vf_config(ionic, vf, &vfc); if (!ret) ionic->vfs[vf].vlanid = cpu_to_le16(vlan); } @@ -2361,6 +2370,7 @@ static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, static int ionic_set_vf_rate(struct net_device *netdev, int vf, int tx_min, int tx_max) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_RATE }; struct ionic_lif *lif = netdev_priv(netdev); struct ionic *ionic = lif->ionic; int ret; @@ -2377,8 +2387,11 @@ static int ionic_set_vf_rate(struct net_device *netdev, int vf, if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ret = ionic_set_vf_config(ionic, vf, - IONIC_VF_ATTR_RATE, (u8 *)&tx_max); + vfc.maxrate = cpu_to_le32(tx_max); + dev_dbg(ionic->dev, "%s: vf %d maxrate %d\n", + __func__, vf, le32_to_cpu(vfc.maxrate)); + + ret = ionic_set_vf_config(ionic, vf, &vfc); if (!ret) lif->ionic->vfs[vf].maxrate = cpu_to_le32(tx_max); } @@ -2389,9 +2402,9 @@ static int ionic_set_vf_rate(struct net_device *netdev, int vf, static int ionic_set_vf_spoofchk(struct net_device *netdev, int vf, bool set) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_SPOOFCHK }; struct ionic_lif *lif = netdev_priv(netdev); struct ionic *ionic = lif->ionic; - u8 data = set; /* convert to u8 for config */ int ret; if (!netif_device_present(netdev)) @@ -2402,10 +2415,13 @@ static int ionic_set_vf_spoofchk(struct net_device *netdev, int vf, bool set) if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ret = ionic_set_vf_config(ionic, vf, - IONIC_VF_ATTR_SPOOFCHK, &data); + vfc.spoofchk = set; + dev_dbg(ionic->dev, "%s: vf %d spoof %d\n", + __func__, vf, vfc.spoofchk); + + ret = ionic_set_vf_config(ionic, vf, &vfc); if (!ret) - ionic->vfs[vf].spoofchk = data; + ionic->vfs[vf].spoofchk = set; } up_write(&ionic->vf_op_lock); @@ -2414,9 +2430,9 @@ static int ionic_set_vf_spoofchk(struct net_device *netdev, int vf, bool set) static int ionic_set_vf_trust(struct net_device *netdev, int vf, bool set) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_TRUST }; struct ionic_lif *lif = netdev_priv(netdev); struct ionic *ionic = lif->ionic; - u8 data = set; /* convert to u8 for config */ int ret; if (!netif_device_present(netdev)) @@ -2427,10 +2443,13 @@ static int ionic_set_vf_trust(struct net_device *netdev, int vf, bool set) if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ret = ionic_set_vf_config(ionic, vf, - IONIC_VF_ATTR_TRUST, &data); + vfc.trust = set; + dev_dbg(ionic->dev, "%s: vf %d trust %d\n", + __func__, vf, vfc.trust); + + ret = ionic_set_vf_config(ionic, vf, &vfc); if (!ret) - ionic->vfs[vf].trusted = data; + ionic->vfs[vf].trusted = set; } up_write(&ionic->vf_op_lock); @@ -2439,20 +2458,21 @@ static int ionic_set_vf_trust(struct net_device *netdev, int vf, bool set) static int ionic_set_vf_link_state(struct net_device *netdev, int vf, int set) { + struct ionic_vf_setattr_cmd vfc = { .attr = IONIC_VF_ATTR_LINKSTATE }; struct ionic_lif *lif = netdev_priv(netdev); struct ionic *ionic = lif->ionic; - u8 data; + u8 vfls; int ret; switch (set) { case IFLA_VF_LINK_STATE_ENABLE: - data = IONIC_VF_LINK_STATUS_UP; + vfls = IONIC_VF_LINK_STATUS_UP; break; case IFLA_VF_LINK_STATE_DISABLE: - data = IONIC_VF_LINK_STATUS_DOWN; + vfls = IONIC_VF_LINK_STATUS_DOWN; break; case IFLA_VF_LINK_STATE_AUTO: - data = IONIC_VF_LINK_STATUS_AUTO; + vfls = IONIC_VF_LINK_STATUS_AUTO; break; default: return -EINVAL; @@ -2466,8 +2486,11 @@ static int ionic_set_vf_link_state(struct net_device *netdev, int vf, int set) if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { ret = -EINVAL; } else { - ret = ionic_set_vf_config(ionic, vf, - IONIC_VF_ATTR_LINKSTATE, &data); + vfc.linkstate = vfls; + dev_dbg(ionic->dev, "%s: vf %d linkstate %d\n", + __func__, vf, vfc.linkstate); + + ret = ionic_set_vf_config(ionic, vf, &vfc); if (!ret) ionic->vfs[vf].linkstate = set; }