ethtool: allow custom interval for physical identification
Subsystems (2)
RFC PATCH 1/1 ethtool: allow custom interval for physical identification
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.
---
net/core/ethtool.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
net/core/ethtool.c +7 -4
@@ -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 ();
Quoted 9 lines · On Mon, 11 Apr 2011 16:16:35 -0700 Bruce Allan <[email protected]> wrote:
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;
-EINVALis still allowed in order to use the default single on/off interval per second.Signed-off-by Bruce Allan <[email protected]>
IMHO this is -EOVERKILL.
Quoted 19 lines
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, April 11, 2011 4:26 PM
To: Allan, Bruce W
Cc: [email protected]
Subject: Re: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identificationQuoted 8 lines · On Mon, 11 Apr 2011 16:16:35 -0700 Bruce Allan <[email protected]> wrote:
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;
-EINVALis still allowed in order to use the default single on/off interval per second.
Quoted 3 lines
Quoted 1 line
Signed-off-by Bruce Allan <[email protected]>IMHO this is
-EOVERKILL.
I realize it does seem like that, but we have OEMs that expect the LEDs to blink a certain way during a physical identification (twice a second vs. once a second per the original .set_phys_id patchset). There may be other drivers from different hardware vendors that have similar but different requirements.
Quoted 21 lines · Bruce W
Quoted 21 lines
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, April 11, 2011 4:26 PM
To: Allan, Bruce W
Cc: [email protected]
Subject: Re: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identificationQuoted 9 lines · On Mon, 11 Apr 2011 16:16:35 -0700 Bruce Allan <[email protected]> wrote:
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;
-EINVALis still allowed in order to use the default single on/off interval per second.Signed-off-by Bruce Allan <[email protected]>
Quoted 7 lines
Quoted 1 line
IMHO this is
-EOVERKILL.I realize it does seem like that, but we have OEMs that expect the LEDs to blink a certain way during a physical identification (twice a second vs. once a second per the original .set_phys_id patchset). There may be other drivers from different hardware vendors that have similar but different requirements.
I noticed that some drivers did this. Do you know if these OEMs expect this of all hardware, or do they actually want different vendors' hardware to blink in different ways? If it's a common requirement to blink at 2 Hz then let's use that frequency for all the drivers that want to be called periodically.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 8 lines
-----Original Message-----
From: Ben Hutchings [mailto:[email protected]]
Sent: Monday, April 11, 2011 5:01 PM
To: Allan, Bruce W
Cc: Stephen Hemminger; [email protected]
Subject: RE: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identification
Quoted 7 lines
I noticed that some drivers did this. Do you know if these OEMs expect this of all hardware, or do they actually want different vendors' hardware to blink in different ways? If it's a common requirement to blink at 2 Hz then let's use that frequency for all the drivers that want to be called periodically.
Ben.
Sorry, I don't know. I'll ask around, but doubt I will get a definitive answer.
FWIW, without digging too deep into how other drivers identify their respective ports through software, it appears it was split:
* bnx2*, cxgb3, niu, s2io, sfc, sky2, tg3 - once per second
* e100*, igb, ixgb*, pcnet32, ewrk3, cxgb4 - approx. twice per second
AFAIK for parts that can set the physical identification through hardware, the Intel drivers set the on/off intervals to approximately twice/second; I don't know what other drivers do in that situation.
So, I would guess it is not a common requirement to blink at a specific Hz. I have no problem with changing the hard-coded blink frequency to what our OEMs expect, but that might be an issue for those other vendors; I was just trying to make it flexible.
Thanks,
Bruce.
Quoted 14 lines · Bruce W
Quoted 14 lines
-----Original Message-----
From: Ben Hutchings [mailto:[email protected]]
Sent: Monday, April 11, 2011 5:01 PM
To: Allan, Bruce W
Cc: Stephen Hemminger; [email protected]
Subject: RE: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identificationI noticed that some drivers did this. Do you know if these OEMs expect this of all hardware, or do they actually want different vendors' hardware to blink in different ways? If it's a common requirement to blink at 2 Hz then let's use that frequency for all the drivers that want to be called periodically.
Quoted 4 lines
Quoted 1 line
Ben.
Sorry, I don't know. I'll ask around, but doubt I will get a definitive answer.
I enquired here and found that we do have an OEM specifying 1 Hz.
Quoted 5 lines
FWIW, without digging too deep into how other drivers identify their respective ports through software, it appears it was split:
* bnx2*, cxgb3, niu, s2io, sfc, sky2, tg3 - once per second
* e100*, igb, ixgb*, pcnet32, ewrk3, cxgb4 - approx. twice per second
Quoted 8 lines
AFAIK for parts that can set the physical identification through hardware, the Intel drivers set the on/off intervals to approximately twice/second; I don't know what other drivers do in that situation.
So, I would guess it is not a common requirement to blink at a specific Hz. I have no problem with changing the hard-coded blink frequency to what our OEMs expect, but that might be an issue for those other vendors; I was just trying to make it flexible.
Sadly it appears this is necessary.
Let's define the return value for drivers wanting periodic callbacks to be the blink frequency in Hz (normally 1 or 2), and get rid of the special case of -EINVAL. This also removes the rather inelegant semantic that drivers may need to change their state despite returning an error code.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 26 lines
-----Original Message-----
From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, April 12, 2011 9:28 AM
To: Allan, Bruce W
Cc: Stephen Hemminger; [email protected]
Subject: RE: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identificationI enquired here and found that we do have an OEM specifying 1 Hz.
Quoted 5 lines
FWIW, without digging too deep into how other drivers identify their respective ports through software, it appears it was split:
* bnx2*, cxgb3, niu, s2io, sfc, sky2, tg3 - once per second
* e100*, igb, ixgb*, pcnet32, ewrk3, cxgb4 - approx. twice per secondQuoted 8 lines
AFAIK for parts that can set the physical identification through hardware, the Intel drivers set the on/off intervals to approximately twice/second; I don't know what other drivers do in that situation.
So, I would guess it is not a common requirement to blink at a specific Hz. I have no problem with changing the hard-coded blink frequency to what our OEMs expect, but that might be an issue for those other vendors; I was just trying to make it flexible.
Sadly it appears this is necessary.
Quoted 7 lines
Let's define the return value for drivers wanting periodic callbacks to be the blink frequency in Hz (normally 1 or 2), and get rid of the special case of
-EINVAL. This also removes the rather inelegant semantic that drivers may need to change their state despite returning an error code.Ben.
OK. Would you like me to send an updated patch?
Bruce.
Quoted 32 lines · Bruce W
Quoted 32 lines
-----Original Message-----
From: Ben Hutchings [mailto:[email protected]]
Sent: Tuesday, April 12, 2011 9:28 AM
To: Allan, Bruce W
Cc: Stephen Hemminger; [email protected]
Subject: RE: [net-next-2.6 RFC PATCH] ethtool: allow custom interval for physical identificationI enquired here and found that we do have an OEM specifying 1 Hz.
Quoted 5 lines
FWIW, without digging too deep into how other drivers identify their respective ports through software, it appears it was split:
* bnx2*, cxgb3, niu, s2io, sfc, sky2, tg3 - once per second
* e100*, igb, ixgb*, pcnet32, ewrk3, cxgb4 - approx. twice per secondQuoted 8 lines
AFAIK for parts that can set the physical identification through hardware, the Intel drivers set the on/off intervals to approximately twice/second; I don't know what other drivers do in that situation.
So, I would guess it is not a common requirement to blink at a specific Hz. I have no problem with changing the hard-coded blink frequency to what our OEMs expect, but that might be an issue for those other vendors; I was just trying to make it flexible.
Sadly it appears this is necessary.
Let's define the return value for drivers wanting periodic callbacks to be the blink frequency in Hz (normally 1 or 2), and get rid of the special case of
-EINVAL. This also removes the rather inelegant semantic that drivers may need to change their state despite returning an error code.
Quoted 3 lines
Quoted 1 line
Ben.
OK. Would you like me to send an updated patch?
Please.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.