All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lijun Pan <lijunp213@gmail.com>
To: netdev@vger.kernel.org
Cc: Lijun Pan <lijunp213@gmail.com>
Subject: [PATCH net-next 2/2] ibmvnic: add sysfs entry for timeout and fatal reset
Date: Mon, 12 Apr 2021 02:43:30 -0500	[thread overview]
Message-ID: <20210412074330.9371-3-lijunp213@gmail.com> (raw)
In-Reply-To: <20210412074330.9371-1-lijunp213@gmail.com>

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 <lijunp213@gmail.com>
---
 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)
 {
-- 
2.23.0


  parent reply	other threads:[~2021-04-12  7:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  7:43 [PATCH net-next 0/2] ibmvnic: sysfs changes Lijun Pan
2021-04-12  7:43 ` [PATCH net-next 1/2] ibmvnic: improve failover sysfs entry Lijun Pan
2021-04-12  7:43 ` Lijun Pan [this message]
2021-04-12 18:23   ` [PATCH net-next 2/2] ibmvnic: add sysfs entry for timeout and fatal reset Jakub Kicinski
2021-04-12 20:26     ` Lijun Pan
2021-04-13  2:49       ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412074330.9371-3-lijunp213@gmail.com \
    --to=lijunp213@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.