From patchwork Mon Apr 12 07:41:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Pan X-Patchwork-Id: 12197037 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DEA0C433ED for ; Mon, 12 Apr 2021 07:41:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1214B61207 for ; Mon, 12 Apr 2021 07:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236931AbhDLHlp (ORCPT ); Mon, 12 Apr 2021 03:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236837AbhDLHlp (ORCPT ); Mon, 12 Apr 2021 03:41:45 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02017C061574 for ; Mon, 12 Apr 2021 00:41:28 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id i25-20020a4aa1190000b02901bbd9429832so2856026ool.0 for ; Mon, 12 Apr 2021 00:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OD9w8Kmg0mzXYvbDUWGakxasKghAMLGXaDnFTp1OrKw=; b=loLt4qb2J3aRPFyRgr07WATaBS8gBNjRp0TvwbLgcrKnaHTA1TQhyMbx/48KYk/FOE tIXe6OOADDpG1A4sEseLsfroqdklgyJRMfr7ixRMrteEPJTI6h4WiurCZb43lxS/8euk 7QAFZkkcvWhRqxbxZqWvoNIoQMYpGBkASEuEUmoxTIABxu3G8MvrL/rnxA2kISlygF/A 6gYJcQPc7Tduafa+VGm78/7lRNwf2fpNh2dTNxYHbYGIiHBJOFtfaoKGWpkLDky2cxfm hKA3qnqryTUay8K70I5MfK5fwQLTpck7IcQkSuR3MaCHVXGUrZze5BNLB6phND0kjzHW ZPgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OD9w8Kmg0mzXYvbDUWGakxasKghAMLGXaDnFTp1OrKw=; b=iEzInlZI67fLO6LzymkGoaMODg6qaHPa+CW8xS0BsadnXSZ92mnAf+sn5EhJQLxIx6 oxHk+5Q8mdGLN1/WFlb6W08BEhnm8gmzMO4jl693O56HjmXmryCW5xUiMwQw8WoJZkZs Biu4jXWC2QKkF8TuWoOvv3mZOTJ78n1+W+9SfSLiHSULBCeYllKxpjxjiRkM0l9zixh1 oHRl8+U6yYWD3MBmhTHQRG3ANKWhmCM2SvwQGxNEceE8aqWxTrycPoSoN/tXlvNTwyyu diEZ9oX3BDHtu6llaPiOZqLK0bT0PztRWS2kjjH4xWUXQkVCAI/VNPAoTsicZnirFEoM 8UOQ== X-Gm-Message-State: AOAM531xdADQTlsjYWLb5kvwPco0Hx5qA+lR1E3BjNaiFvoxk/RqbsAF 4pzMHAiSVlYRRHEiHf3Tn31lNcnIRM4= X-Google-Smtp-Source: ABdhPJwbkydzkhLrJU2glngzNmaZuI1T6utDQkojg1Br6olXCBsJiNy0Ph/rO968bypmd0CR+MyteQ== X-Received: by 2002:a4a:e1d3:: with SMTP id n19mr1908059oot.21.1618213287246; Mon, 12 Apr 2021 00:41:27 -0700 (PDT) Received: from pear.attlocal.net ([2600:1700:271:1a80:70fe:cfb5:1414:607d]) by smtp.gmail.com with ESMTPSA id 62sm2508421oto.60.2021.04.12.00.41.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Apr 2021 00:41:26 -0700 (PDT) From: Lijun Pan To: netdev@vger.kernel.org Cc: Lijun Pan Subject: [PATCH net-next 1/2] ibmvnic: print reset reason as a string Date: Mon, 12 Apr 2021 02:41:27 -0500 Message-Id: <20210412074128.9313-2-lijunp213@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210412074128.9313-1-lijunp213@gmail.com> References: <20210412074128.9313-1-lijunp213@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The reset reason can be added or deleted over different versions of the source code. Print a string instead of a number. Signed-off-by: Lijun Pan --- drivers/net/ethernet/ibm/ibmvnic.c | 35 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 473411542911..5c89dd7fa3de 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -1911,6 +1911,26 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p) return rc; } +static const char *reset_reason_to_string(enum ibmvnic_reset_reason reason) +{ + switch (reason) { + case VNIC_RESET_FAILOVER: + return "FAILOVER"; + case VNIC_RESET_MOBILITY: + return "MOBILITY"; + case VNIC_RESET_FATAL: + return "FATAL"; + case VNIC_RESET_NON_FATAL: + return "NON_FATAL"; + case VNIC_RESET_TIMEOUT: + return "TIMEOUT"; + case VNIC_RESET_CHANGE_PARAM: + return "CHANGE_PARAM"; + default: + return "UNKNOWN"; + } +} + /* * do_reset returns zero if we are able to keep processing reset events, or * non-zero if we hit a fatal error and must halt. @@ -1924,9 +1944,9 @@ static int do_reset(struct ibmvnic_adapter *adapter, int i, rc; netdev_dbg(adapter->netdev, - "[S:%d FOP:%d] Reset reason %d, reset_state %d\n", + "[S:%d FOP:%d] Reset reason: %s, reset_state %d\n", adapter->state, adapter->failover_pending, - rwi->reset_reason, reset_state); + reset_reason_to_string(rwi->reset_reason), reset_state); adapter->reset_reason = rwi->reset_reason; /* requestor of VNIC_RESET_CHANGE_PARAM already has the rtnl lock */ @@ -2139,8 +2159,8 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter, struct net_device *netdev = adapter->netdev; int rc; - netdev_dbg(adapter->netdev, "Hard resetting driver (%d)\n", - rwi->reset_reason); + netdev_dbg(adapter->netdev, "Hard resetting driver (%s)\n", + reset_reason_to_string(rwi->reset_reason)); /* read the state and check (again) after getting rtnl */ reset_state = adapter->state; @@ -2363,8 +2383,8 @@ static int ibmvnic_reset(struct ibmvnic_adapter *adapter, list_for_each(entry, &adapter->rwi_list) { tmp = list_entry(entry, struct ibmvnic_rwi, list); if (tmp->reset_reason == reason) { - netdev_dbg(netdev, "Skipping matching reset, reason=%d\n", - reason); + netdev_dbg(netdev, "Skipping matching reset, reason=%s\n", + reset_reason_to_string(reason)); ret = EBUSY; goto err; } @@ -2384,7 +2404,8 @@ static int ibmvnic_reset(struct ibmvnic_adapter *adapter, } rwi->reset_reason = reason; list_add_tail(&rwi->list, &adapter->rwi_list); - netdev_dbg(adapter->netdev, "Scheduling reset (reason %d)\n", reason); + netdev_dbg(adapter->netdev, "Scheduling reset (reason %s)\n", + reset_reason_to_string(reason)); schedule_work(&adapter->ibmvnic_reset); ret = 0; From patchwork Mon Apr 12 07:41:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Pan X-Patchwork-Id: 12197041 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D06EFC43461 for ; Mon, 12 Apr 2021 07:41:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9740860201 for ; Mon, 12 Apr 2021 07:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236942AbhDLHls (ORCPT ); Mon, 12 Apr 2021 03:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236837AbhDLHlr (ORCPT ); Mon, 12 Apr 2021 03:41:47 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C55C061574 for ; Mon, 12 Apr 2021 00:41:29 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id m13so12530558oiw.13 for ; Mon, 12 Apr 2021 00:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2XJrww2eG4cJLvvogiSKBUXx57S/jNiH3qDaZbV0zCI=; b=JvUI07gI6P4EFSAEMQc49ST48XyF988u0nl8GPrWk9SvaL87kACsloqRcNyIFdl9pr 8PpF5tWem3jCph1Rnwc8n6tu1Pagag2ioOszS08D5L4pvURPYD1y3U66xiP+sWdi9Qir 6G1O8bUnqyXfK2M54RgIS339dIvviKN6/EaAPebwGeCHbgcH6U0sRbdEJTUPI/Cpfzq/ QwFgQd7mYXDEQcF1HY/41ZUTAaBgmiBscYh8yvnQ34nF1JteH/8Umnrb5xEs8F7yMau9 FrLLDRWqntxDBwdCO54GLMyqzhqazQRle+WQDSUi6+0NiZUIGVz/fDAcXwSmgi3KSmvs U6PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2XJrww2eG4cJLvvogiSKBUXx57S/jNiH3qDaZbV0zCI=; b=h5hID0iMXtDae9gvuKwbJL24I2Urgls5eOtkKkpq3lSziST3aN8d8miq99MOZB8L3q ICfqbFNG4/m/Ycu4f9ht47EelNjHYoMIWmZzT25VOCm9piddm1z4I9YFkxXjPETjLME9 EtYSR9jgmIO3CNIfNwSVpL8hwRjUb9YEvJGkhzyyXafzGDL4/FZp/hj/JqG2TaGgTkJY EyVgV1RHueXfXI5YpTZtPrx0zKQJ4L7SvgpyXH1thlQEGGOcL4mCLm5XznwGRdbjyRi6 aw9EMSosqx2N6WabPzmGSJKYFlWpqMZSpWSyVB0r6VbX435idoT7BucWn1bki6O7nktK gSxA== X-Gm-Message-State: AOAM531isz+9lbiFTIjQUsDEMmjkDbCT14RtgJV46CgAjdfP55gH/rrK LzjY8MZFmaO7/FbHMMzO8lUinvCmV+U= X-Google-Smtp-Source: ABdhPJzYp4zncLICmMGQ9WseipbS6o6JwmnPsmXtVjMErUwy16uaZNbjEoETWPX/eClS9gd0k8+9Tw== X-Received: by 2002:aca:2b07:: with SMTP id i7mr18884205oik.66.1618213288129; Mon, 12 Apr 2021 00:41:28 -0700 (PDT) Received: from pear.attlocal.net ([2600:1700:271:1a80:70fe:cfb5:1414:607d]) by smtp.gmail.com with ESMTPSA id 62sm2508421oto.60.2021.04.12.00.41.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Apr 2021 00:41:27 -0700 (PDT) From: Lijun Pan To: netdev@vger.kernel.org Cc: Lijun Pan Subject: [PATCH net-next 2/2] ibmvnic: print adapter state as a string Date: Mon, 12 Apr 2021 02:41:28 -0500 Message-Id: <20210412074128.9313-3-lijunp213@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210412074128.9313-1-lijunp213@gmail.com> References: <20210412074128.9313-1-lijunp213@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The adapter state can be added or deleted over different versions of the source code. Print a string instead of a number. Signed-off-by: Lijun Pan --- drivers/net/ethernet/ibm/ibmvnic.c | 67 ++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 5c89dd7fa3de..ee9bf18c597f 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -827,6 +827,30 @@ static void release_napi(struct ibmvnic_adapter *adapter) adapter->napi_enabled = false; } +static const char *adapter_state_to_string(enum vnic_state state) +{ + switch (state) { + case VNIC_PROBING: + return "PROBING"; + case VNIC_PROBED: + return "PROBED"; + case VNIC_OPENING: + return "OPENING"; + case VNIC_OPEN: + return "OPEN"; + case VNIC_CLOSING: + return "CLOSING"; + case VNIC_CLOSED: + return "CLOSED"; + case VNIC_REMOVING: + return "REMOVING"; + case VNIC_REMOVED: + return "REMOVED"; + default: + return "UNKNOWN"; + } +} + static int ibmvnic_login(struct net_device *netdev) { struct ibmvnic_adapter *adapter = netdev_priv(netdev); @@ -905,7 +929,7 @@ static int ibmvnic_login(struct net_device *netdev) __ibmvnic_set_mac(netdev, adapter->mac_addr); - netdev_dbg(netdev, "[S:%d] Login succeeded\n", adapter->state); + netdev_dbg(netdev, "[S:%s] Login succeeded\n", adapter_state_to_string(adapter->state)); return 0; } @@ -1185,8 +1209,9 @@ static int ibmvnic_open(struct net_device *netdev) * honor our setting below. */ if (adapter->failover_pending || (test_bit(0, &adapter->resetting))) { - netdev_dbg(netdev, "[S:%d FOP:%d] Resetting, deferring open\n", - adapter->state, adapter->failover_pending); + netdev_dbg(netdev, "[S:%s FOP:%d] Resetting, deferring open\n", + adapter_state_to_string(adapter->state), + adapter->failover_pending); adapter->state = VNIC_OPEN; rc = 0; goto out; @@ -1350,8 +1375,9 @@ static int ibmvnic_close(struct net_device *netdev) struct ibmvnic_adapter *adapter = netdev_priv(netdev); int rc; - netdev_dbg(netdev, "[S:%d FOP:%d FRR:%d] Closing\n", - adapter->state, adapter->failover_pending, + netdev_dbg(netdev, "[S:%s FOP:%d FRR:%d] Closing\n", + adapter_state_to_string(adapter->state), + adapter->failover_pending, adapter->force_reset_recovery); /* If device failover is pending, just set device state and return. @@ -1944,9 +1970,11 @@ static int do_reset(struct ibmvnic_adapter *adapter, int i, rc; netdev_dbg(adapter->netdev, - "[S:%d FOP:%d] Reset reason: %s, reset_state %d\n", - adapter->state, adapter->failover_pending, - reset_reason_to_string(rwi->reset_reason), reset_state); + "[S:%s FOP:%d] Reset reason: %s, reset_state: %s\n", + adapter_state_to_string(adapter->state), + adapter->failover_pending, + reset_reason_to_string(rwi->reset_reason), + adapter_state_to_string(reset_state)); adapter->reset_reason = rwi->reset_reason; /* requestor of VNIC_RESET_CHANGE_PARAM already has the rtnl lock */ @@ -2006,8 +2034,8 @@ static int do_reset(struct ibmvnic_adapter *adapter, * from VNIC_CLOSING state. */ netdev_dbg(netdev, - "Open changed state from %d, updating.\n", - reset_state); + "Open changed state from %s, updating.\n", + adapter_state_to_string(reset_state)); reset_state = VNIC_OPEN; adapter->state = VNIC_CLOSING; } @@ -2148,8 +2176,9 @@ static int do_reset(struct ibmvnic_adapter *adapter, if (!(adapter->reset_reason == VNIC_RESET_CHANGE_PARAM)) rtnl_unlock(); - netdev_dbg(adapter->netdev, "[S:%d FOP:%d] Reset done, rc %d\n", - adapter->state, adapter->failover_pending, rc); + netdev_dbg(adapter->netdev, "[S:%s FOP:%d] Reset done, rc %d\n", + adapter_state_to_string(adapter->state), + adapter->failover_pending, rc); return rc; } @@ -2226,8 +2255,9 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter, /* restore adapter state if reset failed */ if (rc) adapter->state = reset_state; - netdev_dbg(adapter->netdev, "[S:%d FOP:%d] Hard reset done, rc %d\n", - adapter->state, adapter->failover_pending, rc); + netdev_dbg(adapter->netdev, "[S:%s FOP:%d] Hard reset done, rc %d\n", + adapter_state_to_string(adapter->state), + adapter->failover_pending, rc); return rc; } @@ -2306,8 +2336,8 @@ static void __ibmvnic_reset(struct work_struct *work) if (rc) { /* give backing device time to settle down */ netdev_dbg(adapter->netdev, - "[S:%d] Hard reset failed, waiting 60 secs\n", - adapter->state); + "[S:%s] Hard reset failed, waiting 60 secs\n", + adapter_state_to_string(adapter->state)); set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(60 * HZ); } @@ -2335,8 +2365,9 @@ static void __ibmvnic_reset(struct work_struct *work) clear_bit_unlock(0, &adapter->resetting); netdev_dbg(adapter->netdev, - "[S:%d FRR:%d WFR:%d] Done processing resets\n", - adapter->state, adapter->force_reset_recovery, + "[S:%s FRR:%d WFR:%d] Done processing resets\n", + adapter_state_to_string(adapter->state), + adapter->force_reset_recovery, adapter->wait_for_reset); }