From: Bruce Allan <bruce.w.allan@intel.com>
To: netdev@vger.kernel.org
Subject: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identification
Date: Mon, 11 Apr 2011 16:16:35 -0700 [thread overview]
Message-ID: <20110411231635.9339.36369.stgit@gitlad.jf.intel.com> (raw)
When physical identification of an adapter is done by toggling the
mechanism on and off through software utilizing the .set_phys_id operation,
it is done with a fixed duration for both on and off states. Some drivers
may want to set a custom duration for the on/off intervals. This patch
changes the API so the return code from the driver's entry point can
specify the interval duration as a positive number; -EINVAL is still
allowed in order to use the default single on/off interval per second.
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
---
net/core/ethtool.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 43ef09f..02db945 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1640,7 +1640,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
return dev->ethtool_ops->phys_id(dev, id.data);
rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE);
- if (rc && rc != -EINVAL)
+ if (rc < 0 && rc != -EINVAL)
return rc;
/* Drop the RTNL lock while waiting, but prevent reentry or
@@ -1656,22 +1656,25 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
id.data ? (id.data * HZ) : MAX_SCHEDULE_TIMEOUT);
} else {
/* Driver expects to be called periodically */
+ int i = 0, interval = ((rc > 0) ? rc : (HZ / 2));
+
do {
rtnl_lock();
rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ON);
rtnl_unlock();
if (rc)
break;
- schedule_timeout_interruptible(HZ / 2);
+ schedule_timeout_interruptible(interval);
rtnl_lock();
rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_OFF);
rtnl_unlock();
if (rc)
break;
- schedule_timeout_interruptible(HZ / 2);
+ schedule_timeout_interruptible(interval);
} while (!signal_pending(current) &&
- (id.data == 0 || --id.data != 0));
+ (id.data == 0 ||
+ (++i * 2 * interval) < (id.data * HZ)));
}
rtnl_lock();
next reply other threads:[~2011-04-11 23:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-11 23:16 Bruce Allan [this message]
2011-04-11 23:26 ` [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identification Stephen Hemminger
2011-04-11 23:30 ` Allan, Bruce W
2011-04-12 0:00 ` Ben Hutchings
2011-04-12 1:07 ` Allan, Bruce W
2011-04-12 16:28 ` Ben Hutchings
2011-04-12 18:17 ` Allan, Bruce W
2011-04-12 18:23 ` Ben Hutchings
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=20110411231635.9339.36369.stgit@gitlad.jf.intel.com \
--to=bruce.w.allan@intel.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.