phydev: Add sysctl variable for polling interval of phy
Subsystems (3)
Hello.
Quoted 6 lines
Hello,
On 03/11/2013 12:44 AM, EUNBONG SONG wrote:
This patch should be submitted according to the rules described in:
https://www.kernel.org/doc/Documentation/SubmittingPatches
Sorry, i made a mistake. so i rewrite the patches here.
--- drivers/net/phy/phy.c | 4 +++- drivers/net/phy/phy_device.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 1 - 3 files changed, 46 insertions(+), 2 deletions(-)
drivers/net/phy/phy.c +3 -1
@@ -42,6 +42,8 @@#include <asm/irq.h> #include <asm/uaccess.h> +extern unsigned int sysctl_phy_poll_interval; +/** * phy_print_status - Convenience function to print out the current phy status * @phydev: the phy_device struct
@@ -966,7 +968,7 @@ void phy_state_machine(struct work_struct *work)if (err <0 )phy_error (phydev); -schedule_delayed_work (&phydev->state_queue,PHY_STATE_TIME *HZ ); +schedule_delayed_work (&phydev->state_queue,msecs_to_jiffies (sysctl_phy_poll_interval)); } static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
drivers/net/phy/phy_device.c +43 -0
67 lines not on this page · raw message
include/linux/phy.h +0 -1
@@ -68,7 +68,6 @@ typedef enum {#define PHY_INIT_TIMEOUT 100000 -#define PHY_STATE_TIME 1#define PHY_FORCE_TIMEOUT 10#define PHY_AN_TIMEOUT 10
Quoted 3 lines
Besides that, I do not think that a system-wide knob here is appropriate, you may rather introduce a new ethtool
ioctl()to change the PHY device polling interval on a per-PHY device basis.
This patch follows current phy driver flow, "PHY_STATE_TIME" is system-wide variable for phy polling interval. So i just replace "PHY_STATE_TIME" variable to sysctl variable.
And I think it's better as a system-wide variable, because we usually expect all phys has same reponse-time to the change of state.
Quoted 3 lines
Having said that don't your devices support a dedicated PHY interrupt line? This would definitively be the way to get better latency with respect to PHY events reported back to the host.
I usually do not interrupt because if phy state goes down, there are so many jobs for this. For example, remove arp table entries for this port, remove all routing table entries for this port . If we plug and unplug the physical port in very rapid speed, there could be so many interrupt events. And this is not what we want.
Quoted 2 lines
1 millisecond sounds like we are going to eat up a lot of CPU time polling PHY registers. Do you need that much reactivity?
I agree with you, 1 milliseconds is very harmful to cpu. But it's just a minimum value not a default value. Actually, i'm not sure which minimum and maximum value is best. So i just take wide range.
Thanks
------- Original Message -------
Sender : Florian Fainelli<[email protected]>
Date : 2013-03-11 19:45 (GMT+09:00)
Title : Re: Fwd: [PATCH] phydev: Add sysctl variable for polling interval of phy
Hello,
Quoted 10 lines · EUNBONG SONG
From
d55a22be52e5a768409aa0999d6636cdfc369676Mon Sep 17 00:00:00 2001
From: eunbonsong
Date: Sun, 10 Mar 2013 04:57:39 -0700
Subject: [PATCH] phydev: Add sysctl variable for polling interval of phy stateThis adds a dev.phy.phy_poll_interval sysctl variable. This value is represented in milliseconds. And
phy_state_machine()is scheduled as this variable.
I think HZ is enough for PC. But sometimes especially in network devices
such as switches,routers, needs more granularity for detecting phy state change.
This patch should be submitted according to the rules described in:
https://www.kernel.org/doc/Documentation/SubmittingPatches
Besides that, I do not think that a system-wide knob here is appropriate, you may rather introduce a new ethtool ioctl() to change the PHY device polling interval on a per-PHY device basis.
Having said that don't your devices support a dedicated PHY interrupt line? This would definitively be the way to get better latency with respect to PHY events reported back to the host.
Quoted 43 lines
---
drivers/net/phy/phy.c | 4 +++- drivers/net/phy/phy_device.c | 43 ++++++++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 1 - 3 files changed, 46 insertions(+), 2 deletions(-)drivers/net/phy/phy.c +3
-1@@ -42,6 +42,8 @@ #include #include +extern unsigned long sysctl_phy_poll_interval; +/** * phy_print_status - Convenience function to print out the current phy status * @phydev: the phy_device struct @@ -966,7 +968,7 @@ void phy_state_machine(struct work_struct *work)if (err <0 )phy_error (phydev); -schedule_delayed_work (&phydev->state_queue,PHY_STATE_TIME *HZ ); +schedule_delayed_work (&phydev->state_queue,msecs_to_jiffies (sysctl_phy_poll_interval)); } static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,drivers/net/phy/phy_device.c +1
-0@@ -33,6 +33,7 @@ #include #include #include +#include #include #include
drivers/net/phy/phy_device.c MODULE_DESCRIPTION("PHY library"); · line 48
Quoted 6 lines
drivers/net/phy/phy_device.c +3
-0@@ -42,6 +43,45 @@ MODULE_DESCRIPTION("PHY library");MODULE_AUTHOR ("Andy Fleming" );MODULE_LICENSE ("GPL" ); +unsigned long sysctl_phy_poll_interval =1000 ; +static unsigned long min_phy_poll_interval =1 ; +static unsigned long max_phy_poll_interval =10000 ;
1 millisecond sounds like we are going to eat up a lot of CPU time polling PHY registers. Do you need that much reactivity? --
Florian