From patchwork Mon Apr 12 07:43:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Pan X-Patchwork-Id: 12197057 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 305DFC433ED for ; Mon, 12 Apr 2021 07:43:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E66E2600CD for ; Mon, 12 Apr 2021 07:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236983AbhDLHns (ORCPT ); Mon, 12 Apr 2021 03:43:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236968AbhDLHnr (ORCPT ); Mon, 12 Apr 2021 03:43:47 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94557C061574 for ; Mon, 12 Apr 2021 00:43:29 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id l131so7519988oih.0 for ; Mon, 12 Apr 2021 00:43: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=P/T6Ns85BhUFKOc+ZeWiNGWVmab9FfDlLPs5EqVU/fs=; b=Zufe5x1eph7jQ7xKlAUGSVrxI8KxJKaOuwQQOPXoryvn+8fC6pzHdzC4WlvbRQCmZl T/JUyjzK2FocHQ1aeQaHdAlvbEthkgnHi5/g+5vbAWtroXk+aRPAizRQ3PigfBMRN2hB Are43VK6WwfkRxdZ0bXGNtNE4NJmKNi5hPG2pRs8LlM5pIUKrrDbebxjd4PDLz4ETxDX oQoiJ7ZUDANeFIiCuPl4ilLqJrYRB25btElA9fMazpTJWRASDwgZppVtQ0nKE0j+cs92 bu5COvJBM9wSACjbIlNapDArd5m8plqEfwCV4w/LLqhOxLj7tMD5ZOAqkWKpoAfePUw9 3Scw== 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=P/T6Ns85BhUFKOc+ZeWiNGWVmab9FfDlLPs5EqVU/fs=; b=DA+Eh1H++4Ckk+zgv/pCdDbYvO8ra1ojPxK2/AXpQ+n9vU4IZANFLT9581gdYUbmRG 1sGi2MxfoZrPISif4oL/DAF6xJkrHzf60FFF3YVbvXV1tvWFo7aLeAXzo7bUkiHoCPYO ZyQ4hf3CAcvlV15tVN56Sb5jN7k6KePTXIN98/4d8/j7zrLNmtTE4/tYdKjOt3AWtMUo /tdYn6NMWZUT9j7eMcCnAV1MYjLCiXeMyCZChIUtcddIdBavYgJylw0GRgw6LRqpYZEU F7sxNYhZQJORdBMqyGgRW66vJBtBeY7s6NMeG0PmCcxB6oVHdzGJ2Ku80etp2uhJ8YLL gdBw== X-Gm-Message-State: AOAM5321/zilcD9s9JkkHJ3QiuV9h+Bjn07Qeg7+2hBYKeJqL24Idigo jVWQkvlW1YFhZYduOgXeTlSF93tt2mU= X-Google-Smtp-Source: ABdhPJwwLCSnX9H748XejI4ea5RP1AfArsUj2p3kp3Ma16W+zcAHoCIS3BSzUBLIZaRZMQO7wJIUYQ== X-Received: by 2002:aca:bb06:: with SMTP id l6mr18421185oif.121.1618213408848; Mon, 12 Apr 2021 00:43:28 -0700 (PDT) Received: from pear.attlocal.net ([2600:1700:271:1a80:70fe:cfb5:1414:607d]) by smtp.gmail.com with ESMTPSA id f12sm2485676otf.65.2021.04.12.00.43.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Apr 2021 00:43:28 -0700 (PDT) From: Lijun Pan To: netdev@vger.kernel.org Cc: Lijun Pan Subject: [PATCH net-next 1/2] ibmvnic: improve failover sysfs entry Date: Mon, 12 Apr 2021 02:43:29 -0500 Message-Id: <20210412074330.9371-2-lijunp213@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210412074330.9371-1-lijunp213@gmail.com> References: <20210412074330.9371-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 current implementation replies on H_IOCTL call to issue a H_SESSION_ERR_DETECTED command to let the hypervisor to send a failover signal. However, it may not work while the vnic is already in error state, e.g., "ibmvnic 30000003 env3: rx buffer returned with rc 6". Add a last resort, that is to schedule a failover reset via CRQ command. Signed-off-by: Lijun Pan --- drivers/net/ethernet/ibm/ibmvnic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index ee9bf18c597f..d44a7b5b8f67 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -5512,14 +5512,14 @@ static ssize_t failover_store(struct device *dev, struct device_attribute *attr, rc = plpar_hcall_norets(H_VIOCTL, adapter->vdev->unit_address, H_SESSION_ERR_DETECTED, session_token, 0, 0); if (rc) { - netdev_err(netdev, "Client initiated failover failed, rc %ld\n", + netdev_err(netdev, + "H_VIOCTL initiated failover failed, rc %ld, trying to send CRQ_CMD, the last resort\n", rc); - return -EINVAL; + ibmvnic_reset(adapter, VNIC_RESET_FAILOVER); } return count; } - static DEVICE_ATTR_WO(failover); static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev) From patchwork Mon Apr 12 07:43:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Pan X-Patchwork-Id: 12197059 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=-12.9 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,UNWANTED_LANGUAGE_BODY, 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 CDAC3C43462 for ; Mon, 12 Apr 2021 07:43:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91F206121D for ; Mon, 12 Apr 2021 07:43:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236994AbhDLHny (ORCPT ); Mon, 12 Apr 2021 03:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236977AbhDLHns (ORCPT ); Mon, 12 Apr 2021 03:43:48 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E4A2C061574 for ; Mon, 12 Apr 2021 00:43:30 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id 25so11087226oiy.5 for ; Mon, 12 Apr 2021 00:43:30 -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=kYfsAs5oGGnESDxFtqUD5yQatjSVHZVLXv9XYqH+nLg=; b=qEn/B9JUzgRXgnI4W9Rx0xQ1sApbu5KsVQ+LVuM0Rc3Zpnsx715eKulEMHVK01QDcW Q6Hb7DO6WCA0968wmZFuCElAHN6r7F/UPQYIa9B4Mod+53CBTuapU+FOo38hKu5GN4cp /TWQALxKaZMlAfIK9p5MPip+1ZDwNdzhHIxDOSW7bek06WQPGVeuwOWW8NVi3MWTwHaI fH/3qV9WRJf17Gn6BKyMT2ku4UYUTB5laNpiV7VILUhCPOB9TrG8Mt4JIIHmXVVMYgli R+ZiGvrUya65TX+ISCRdX1YCvxU/tt/iJlL1b6wxRaiowGzOJjWJIjPjqSPWYjSGmAgf 4Yiw== 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=kYfsAs5oGGnESDxFtqUD5yQatjSVHZVLXv9XYqH+nLg=; b=soBD9mVk77rPsbnIGaqgcGDXHiTNF2+F5asR2FoFUqSP5LsaKMOcjPYW2zpqZtK+iV d+hrTayVy0fRPwppiWruV/szjPQ5EojpsR7woX4MJ1AvSmpuTHHeBQyRPiJIl88OlN8o A68OC1rYNUsT+m766nL7bitBaptXr4K2xhKTObAMWJMqUbUlRqWpZu0rpd3gUG7R6Af0 L7ex5qVs2R0VRZDna2wUzM9gbO/T/NErSlGjbOUv5tHyc43Ep08vysspUpqezgImIj1b 36xUM0ljrD1vPivcmg3x+TNAs4PNCq/niqgG877Jq3CJS5BQGEjHkk0BjBtJBeD/YCzz pcpQ== X-Gm-Message-State: AOAM533Ec0o8P53KNaRIJf+Prylgb/UYkyu/10Hdzwm/nYTmjQgh3UGL Hu8TYygE+kNBu1pF3TVbtJUwc+mI0sg= X-Google-Smtp-Source: ABdhPJxOqnJ+YzHMEhdN/rPI5UmJ933pB60qzUIzsc/4cRTAQlCDn5unWyGZzzSbw/nJh2WkZ8Pltg== X-Received: by 2002:aca:4c0c:: with SMTP id z12mr18682734oia.109.1618213409473; Mon, 12 Apr 2021 00:43:29 -0700 (PDT) Received: from pear.attlocal.net ([2600:1700:271:1a80:70fe:cfb5:1414:607d]) by smtp.gmail.com with ESMTPSA id f12sm2485676otf.65.2021.04.12.00.43.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Apr 2021 00:43:29 -0700 (PDT) From: Lijun Pan To: netdev@vger.kernel.org Cc: Lijun Pan Subject: [PATCH net-next 2/2] ibmvnic: add sysfs entry for timeout and fatal reset Date: Mon, 12 Apr 2021 02:43:30 -0500 Message-Id: <20210412074330.9371-3-lijunp213@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210412074330.9371-1-lijunp213@gmail.com> References: <20210412074330.9371-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 Add timeout and fatal reset sysfs entries so that both functions can be triggered manually the tested. Otherwise, you have to run the program for enough time and check both randomly generated resets in the long long log. Signed-off-by: Lijun Pan --- drivers/net/ethernet/ibm/ibmvnic.c | 50 ++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index d44a7b5b8f67..b4d2c055a284 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -5329,6 +5329,8 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter, bool reset) return rc; } +static struct device_attribute dev_attr_timeout; +static struct device_attribute dev_attr_fatal; static struct device_attribute dev_attr_failover; static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) @@ -5407,9 +5409,15 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) netdev->min_mtu = adapter->min_mtu - ETH_HLEN; netdev->max_mtu = adapter->max_mtu - ETH_HLEN; + rc = device_create_file(&dev->dev, &dev_attr_timeout); + if (rc) + goto ibmvnic_dev_file_timeout_err; + rc = device_create_file(&dev->dev, &dev_attr_fatal); + if (rc) + goto ibmvnic_dev_file_fatal_err; rc = device_create_file(&dev->dev, &dev_attr_failover); if (rc) - goto ibmvnic_dev_file_err; + goto ibmvnic_dev_file_failover_err; netif_carrier_off(netdev); rc = register_netdev(netdev); @@ -5428,7 +5436,13 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) ibmvnic_register_fail: device_remove_file(&dev->dev, &dev_attr_failover); -ibmvnic_dev_file_err: +ibmvnic_dev_file_failover_err: + device_remove_file(&dev->dev, &dev_attr_fatal); + +ibmvnic_dev_file_fatal_err: + device_remove_file(&dev->dev, &dev_attr_timeout); + +ibmvnic_dev_file_timeout_err: release_stats_token(adapter); ibmvnic_stats_fail: @@ -5481,11 +5495,43 @@ static void ibmvnic_remove(struct vio_dev *dev) rtnl_unlock(); mutex_destroy(&adapter->fw_lock); + device_remove_file(&dev->dev, &dev_attr_timeout); + device_remove_file(&dev->dev, &dev_attr_fatal); device_remove_file(&dev->dev, &dev_attr_failover); free_netdev(netdev); dev_set_drvdata(&dev->dev, NULL); } +static ssize_t timeout_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct net_device *netdev = dev_get_drvdata(dev); + struct ibmvnic_adapter *adapter = netdev_priv(netdev); + + if (!sysfs_streq(buf, "1")) + return -EINVAL; + + ibmvnic_reset(adapter, VNIC_RESET_TIMEOUT); + + return count; +} +static DEVICE_ATTR_WO(timeout); + +static ssize_t fatal_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct net_device *netdev = dev_get_drvdata(dev); + struct ibmvnic_adapter *adapter = netdev_priv(netdev); + + if (!sysfs_streq(buf, "1")) + return -EINVAL; + + ibmvnic_reset(adapter, VNIC_RESET_FATAL); + + return count; +} +static DEVICE_ATTR_WO(fatal); + static ssize_t failover_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {