Convert more drivers to ethtool set_phys_id
Subsystems (2)
cover Convert more drivers to ethtool set_phys_id
Did a bunch of the easy drivers to convert.
PATCH 1/12 sky2: support ethtool set_phys_id
Use ethtool set_phys_id to control LED. Fixes issues with RTNL being held for extended periods.
drivers/net/sky2.c +13 -12
@@ -3826,23 +3826,24 @@ static void sky2_led(struct sky2_port *s }/* blink LED's for finding board */ -static int sky2_phys_id (struct net_device *dev,u32 data) +static int sky2_set_phys_id (struct net_device *dev, +enum ethtool_phys_id_state state) {struct sky2_port *sky2 =netdev_priv (dev); -unsigned int i; - -if (data ==0 ) - data =UINT_MAX ; -for (i =0 ; i < data; i++) { +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -EINVAL ; +case ETHTOOL_ID_INACTIVE : +sky2_led (sky2,MO_LED_NORM ); +break ; +case ETHTOOL_ID_ON :sky2_led (sky2,MO_LED_ON ); -if (msleep_interruptible (500 )) -break ; +break ; +case ETHTOOL_ID_OFF :sky2_led (sky2,MO_LED_OFF ); -if (msleep_interruptible (500 )) -break ; +break ; } -sky2_led (sky2,MO_LED_NORM );return 0 ; }
@@ -4269,7 +4270,7 @@ static const struct ethtool_ops sky2_eth .set_ringparam = sky2_set_ringparam, .get_pauseparam = sky2_get_pauseparam, .set_pauseparam = sky2_set_pauseparam, - .phys_id = sky2_phys_id, + .set_phys_id = sky2_set_phys_id, .get_sset_count = sky2_get_sset_count, .get_ethtool_stats = sky2_get_ethtool_stats, .set_flags = sky2_set_flags,
Re: [PATCH net-next-2.6 01/12] sky2: support ethtool set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:41 -0700
Quoted 4 lines
Use ethtool
set_phys_idto control LED. Fixes issues with RTNL being held for extended periods.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 2/12 skge: implement set_phys_id
In reply to Stephen HemmingerImplement set_phys_id led control on SysKonnect board.
drivers/net/skge.c +18 -19
@@ -786,29 +786,28 @@ static void skge_led(struct skge_port *s }/* blink LED's for finding board */ -static int skge_phys_id (struct net_device *dev,u32 data) +static int skge_set_phys_id (struct net_device *dev, +enum ethtool_phys_id_state state) {struct skge_port *skge =netdev_priv (dev); -unsigned long ms; -enum led_mode mode =LED_MODE_TST ; -if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT /HZ )) - ms =jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT /HZ ) *1000 ; -else - ms = data *1000 ; - -while (ms >0 ) { -skge_led (skge, mode); - mode ^=LED_MODE_TST ; - -if (msleep_interruptible (BLINK_MS )) -break ; - ms -=BLINK_MS ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -1 ; + +case ETHTOOL_ID_ON : +skge_led (skge,LED_MODE_TST ); +break ; + +case ETHTOOL_ID_OFF : +skge_led (skge,LED_MODE_OFF ); +break ; + +case ETHTOOL_ID_INACTIVE : +/* back to regular LED state */ +skge_led (skge,netif_running (dev) ?LED_MODE_ON :LED_MODE_OFF ); } -/* back to regular LED state */ -skge_led (skge,netif_running (dev) ?LED_MODE_ON :LED_MODE_OFF ); -return 0 ; }
@@ -930,7 +929,7 @@ static const struct ethtool_ops skge_eth .get_rx_csum = skge_get_rx_csum, .set_rx_csum = skge_set_rx_csum, .get_strings = skge_get_strings, - .phys_id = skge_phys_id, + .set_phys_id = skge_set_phys_id, .get_sset_count = skge_get_sset_count, .get_ethtool_stats = skge_get_ethtool_stats, };
Re: [PATCH net-next-2.6 02/12] skge: implement set_phys_id
Quoted 24 lines · Stephen Hemminger
Implement
set_phys_idled control on SysKonnect board.Signed-off-by Stephen Hemminger <[email protected]>drivers/net/skge.c +2
-8@@ -786,29 +786,28 @@ static void skge_led(struct skge_port *s }/* blink LED's for finding board */ -static int skge_phys_id (struct net_device *dev,u32 data) +static int skge_set_phys_id (struct net_device *dev, +enum ethtool_phys_id_state state) {struct skge_port *skge =netdev_priv (dev); -unsigned long ms; -enum led_mode mode =LED_MODE_TST ; -if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT /HZ )) - ms =jiffies_to_msecs (MAX_SCHEDULE_TIMEOUT /HZ ) *1000 ; -else - ms = data *1000 ; -
drivers/net/skge.c static void skge_led(struct skge_port *s · line 796
Quoted 10 lines
drivers/net/skge.c +3
-7-while (ms >0 ) { -skge_led (skge, mode); - mode ^=LED_MODE_TST ; - -if (msleep_interruptible (BLINK_MS )) -break ; - ms -=BLINK_MS ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -1 ;
[...]
Must be -EINVAL.
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.
David Miller
maintainerRe: [PATCH net-next-2.6 02/12] skge: implement set_phys_id
From: Ben Hutchings <[email protected]>
Date: Mon, 04 Apr 2011 23:57:32 +0100
Quoted 8 lines · Stephen Hemminger
drivers/net/skge.c static void skge_led(struct skge_port *s · line 796
Quoted 4 lines
drivers/net/skge.c +3
-1- ms -=BLINK_MS ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -1 ;[...]
Must be
-EINVAL.
I took care of this when I applied Stephen's patch.
Re: [PATCH net-next-2.6 02/12] skge: implement set_phys_id
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:42 -0700
Quoted 3 lines
Implement
set_phys_idled control on SysKonnect board.Signed-off-by Stephen Hemminger <[email protected]>
Applied, although I had to fix:
drivers/net/skge.c static void skge_led(struct skge_port *s · line 796
Quoted 2 lines
drivers/net/skge.c +2
-0+case ETHTOOL_ID_ACTIVE : +return -1 ;
to return -EINVAL.
PATCH 3/12 e100: implemenet set_phys_id
In reply to Stephen HemmingerImplement set_phys_id to control LED.
Compile tested only.
drivers/net/e100.c +28 -38
@@ -593,7 +593,6 @@ struct nic {enum phy phy;struct params params;struct timer_list watchdog; -struct timer_list blink_timer;struct mii_if_info mii;struct work_struct tx_timeout_task;enum loopback loopback;
@@ -618,7 +617,6 @@ struct nic {u32 rx_tco_frames;u32 rx_over_length_errors; -u16 leds;u16 eeprom_wc;__le16 eeprom[256 ];spinlock_t mdio_lock;
@@ -2351,30 +2349,6 @@ err_clean_rx:#define E100_82552_LED_OVERRIDE 0x19#define E100_82552_LED_ON 0x000F/* LEDTX and LED_RX both on */ #define E100_82552_LED_OFF 0x000A/* LEDTX and LED_RX both off */ -static void e100_blink_led (unsigned long data) -{ -struct nic *nic = (struct nic *)data; -enum led_state { - led_on =0x01 , - led_off =0x04 , - led_on_559 =0x05 , - led_on_557 =0x07 , - }; -u16 led_reg =MII_LED_CONTROL ; - -if (nic->phy == phy_82552_v) { - led_reg =E100_82552_LED_OVERRIDE ; - - nic->leds = (nic->leds ==E100_82552_LED_ON ) ? -E100_82552_LED_OFF :E100_82552_LED_ON ; - }else { - nic->leds = (nic->leds & led_on) ? led_off : - (nic->mac < mac_82559_D101M) ? led_on_557 : - led_on_559; - } -mdio_write (nic->netdev, nic->mii.phy_id, led_reg, nic->leds); -mod_timer (&nic->blink_timer, jiffies +HZ /4 ); -}static int e100_get_settings (struct net_device *netdev,struct ethtool_cmd *cmd) {
@@ -2598,19 +2572,38 @@ static void e100_diag_test(struct net_demsleep_interruptible (4 *1000 ); } -static int e100_phys_id (struct net_device *netdev,u32 data) +static int e100_set_phys_id (struct net_device *netdev, +enum ethtool_phys_id_state state) {struct nic *nic =netdev_priv (netdev); +enum led_state { + led_on =0x01 , + led_off =0x04 , + led_on_559 =0x05 , + led_on_557 =0x07 , + };u16 led_reg = (nic->phy == phy_82552_v) ?E100_82552_LED_OVERRIDE : -MII_LED_CONTROL ; +MII_LED_CONTROL ; +u16 leds =0 ; + +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -EINVAL ; + +case ETHTOOL_ID_ON : + leds = (nic->phy == phy_82552_v) ?E100_82552_LED_ON : + (nic->mac < mac_82559_D101M) ? led_on_557 : led_on_559; +break ; -if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT /HZ )) - data = (u32)(MAX_SCHEDULE_TIMEOUT /HZ ); -mod_timer (&nic->blink_timer, jiffies); -msleep_interruptible (data *1000 ); -del_timer_sync (&nic->blink_timer); -mdio_write (netdev, nic->mii.phy_id, led_reg,0 ); +case ETHTOOL_ID_OFF : + leds = (nic->phy == phy_82552_v) ?E100_82552_LED_OFF : led_off; +break ; + +case ETHTOOL_ID_INACTIVE : +break ; + } +mdio_write (netdev, nic->mii.phy_id, led_reg, leds);return 0 ; }
@@ -2691,7 +2684,7 @@ static const struct ethtool_ops e100_eth .set_ringparam = e100_set_ringparam, .self_test = e100_diag_test, .get_strings = e100_get_strings, - .phys_id = e100_phys_id, + .set_phys_id = e100_set_phys_id, .get_ethtool_stats = e100_get_ethtool_stats, .get_sset_count = e100_get_sset_count, };
@@ -2832,9 +2825,6 @@ static int __devinit e100_probe(struct pinit_timer (&nic->watchdog); nic->watchdog.function = e100_watchdog; nic->watchdog.data = (unsigned long )nic; -init_timer (&nic->blink_timer); - nic->blink_timer.function = e100_blink_led; - nic->blink_timer.data = (unsigned long )nic;INIT_WORK (&nic->tx_timeout_task, e100_tx_timeout_task);
David Miller
maintainerRe: [PATCH net-next-2.6 03/12] e100: implemenet set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:43 -0700
Quoted 4 lines
Implement
set_phys_idto control LED.
Compile tested only.Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 4/12 e1000: convert to set_phys_id
In reply to Stephen HemmingerConvert to new LED control infrastucture and remove no longer necessary bits.
--- drivers/net/e1000/e1000.h | 3 -- drivers/net/e1000/e1000_ethtool.c | 50 ++++++++++++-------------------------- 2 files changed, 16 insertions(+), 37 deletions(-)
drivers/net/e1000/e1000.h +0 -3
@@ -238,9 +238,6 @@ struct e1000_adapter {struct work_struct reset_task;u8 fc_autoneg; -struct timer_list blink_timer; -unsigned long led_status; -/* TX */ struct e1000_tx_ring *tx_ring;/* One per active queue */ unsigned int restart_queue;
drivers/net/e1000/e1000_ethtool.c +16 -34
69 lines not on this page · raw message
David Miller
maintainerRe: [PATCH net-next-2.6 04/12] e1000: convert to set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:44 -0700
Quoted 4 lines
Convert to new LED control infrastucture and remove no longer necessary bits.
Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 5/12 e1000e: implement ethtool set_phys_id
In reply to Stephen HemmingerThe new ethtool set_phys_id takes over controlling the LED for identifying boards. This fixes the lockout during that period.
For this device lots of extra infrastructure can also be removed by using set_phys_id.
drivers/net/e1000e/e1000.h +0 -4
@@ -389,13 +389,10 @@ struct e1000_adapter {bool fc_autoneg; -unsigned long led_status; -unsigned int flags;unsigned int flags2;struct work_struct downshift_task;struct work_struct update_phy_task; -struct work_struct led_blink_task;struct work_struct print_hang_task;bool idle_check;
@@ -484,7 +481,6 @@ extern const char e1000e_driver_version[extern void e1000e_check_options (struct e1000_adapter *adapter);extern void e1000e_set_ethtool_ops (struct net_device *netdev); -extern void e1000e_led_blink_task (struct work_struct *work);extern int e1000e_up (struct e1000_adapter *adapter);extern void e1000e_down (struct e1000_adapter *adapter);
drivers/net/e1000e/ethtool.c +25 -50
96 lines not on this page · raw message
drivers/net/e1000e/netdev.c +0 -2
@@ -5991,7 +5991,6 @@ static int __devinit e1000_probe(structINIT_WORK (&adapter->downshift_task, e1000e_downshift_workaround);INIT_WORK (&adapter->update_phy_task, e1000e_update_phy_task);INIT_WORK (&adapter->print_hang_task, e1000_print_hw_hang); -INIT_WORK (&adapter->led_blink_task, e1000e_led_blink_task);/* Initialize link parameters. User can change them with ethtool */ adapter->hw.mac.autoneg =1 ;
@@ -6124,7 +6123,6 @@ static void __devexit e1000_remove(struccancel_work_sync (&adapter->watchdog_task);cancel_work_sync (&adapter->downshift_task);cancel_work_sync (&adapter->update_phy_task); -cancel_work_sync (&adapter->led_blink_task);cancel_work_sync (&adapter->print_hang_task);if (!(netdev->flags &IFF_UP ))
David Miller
maintainerRe: [PATCH net-next-2.6 05/12] e1000e: implement ethtool set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:45 -0700
Quoted 6 lines
The new ethtool
set_phys_idtakes over controlling the LED for identifying boards. This fixes the lockout during that period.
For this device lots of extra infrastructure can also be removed by usingset_phys_id.Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 6/12 igb: convert to ethtool set_phys_id
In reply to Stephen HemmingerConvert igb driver to use new set_phys_id ethtool interface.
drivers/net/igb/igb_ethtool.c +16 -19
@@ -1963,29 +1963,26 @@ static int igb_set_wol(struct net_device/* bit defines for adapter->led_status */ #define IGB_LED_ON 0 -static int igb_phys_id (struct net_device *netdev,u32 data) +static int igb_set_phys_id (struct net_device *netdev, +enum ethtool_phys_id_state state) {struct igb_adapter *adapter =netdev_priv (netdev);struct e1000_hw *hw = &adapter->hw; -unsigned long timeout; - timeout = data *1000 ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +igb_blink_led (hw); +return 0 ; + +case ETHTOOL_ID_INACTIVE : +igb_led_off (hw); +clear_bit (IGB_LED_ON , &adapter->led_status); +igb_cleanup_led (hw); +return 0 ; -/* -* msleep_interruptable only accepts unsigned int so we are limited -* in how long a duration we can wait -*/ -if (!timeout || timeout >UINT_MAX ) - timeout =UINT_MAX ; - -igb_blink_led (hw); -msleep_interruptible (timeout); - -igb_led_off (hw); -clear_bit (IGB_LED_ON , &adapter->led_status); -igb_cleanup_led (hw); - -return 0 ; +default : +return -EINVAL ; + } } static int igb_set_coalesce(struct net_device *netdev,
@@ -2215,7 +2212,7 @@ static const struct ethtool_ops igb_etht .set_tso = igb_set_tso, .self_test = igb_diag_test, .get_strings = igb_get_strings, - .phys_id = igb_phys_id, + .set_phys_id = igb_set_phys_id, .get_sset_count = igb_get_sset_count, .get_ethtool_stats = igb_get_ethtool_stats, .get_coalesce = igb_get_coalesce,
David Miller
maintainerRe: [PATCH net-next-2.6 06/12] igb: convert to ethtool set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:46 -0700
Quoted 3 lines
Convert igb driver to use new
set_phys_idethtool interface.Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 7/12 igbvf: remove bogus phys_id
In reply to Stephen HemmingerThis device lies about supporting phys_id. Remove it and just let the upper layer report not supported.
drivers/net/igbvf/ethtool.c +0 -6
@@ -391,11 +391,6 @@ static int igbvf_set_wol(struct net_devireturn -EOPNOTSUPP ; } -static int igbvf_phys_id (struct net_device *netdev,u32 data) -{ -return 0 ; -} -static int igbvf_get_coalesce (struct net_device *netdev,struct ethtool_coalesce *ec) {
@@ -527,7 +522,6 @@ static const struct ethtool_ops igbvf_et .self_test = igbvf_diag_test, .get_sset_count = igbvf_get_sset_count, .get_strings = igbvf_get_strings, - .phys_id = igbvf_phys_id, .get_ethtool_stats = igbvf_get_ethtool_stats, .get_coalesce = igbvf_get_coalesce, .set_coalesce = igbvf_set_coalesce,
RE: [PATCH net-next-2.6 07/12] igbvf: remove bogus phys_id
Quoted 29 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, April 04, 2011 11:44 AM
To: David S. Miller; Ben Hutchings; Kirsher, Jeffrey T; Brandeburg, Jesse; Allan, Bruce W; Wyborny, Carolyn; Skidmore, Donald C; Ronciak, John
Cc: [email protected]
Subject: [PATCH net-next-2.6 07/12] igbvf: remove bogusphys_idThis device lies about supporting
phys_id. Remove it and just let the upper layer report not supported.Signed-off-by Stephen Hemminger <[email protected]>drivers/net/igbvf/ethtool.c +0
-5@@ -391,11 +391,6 @@ static int igbvf_set_wol(struct net_devireturn -EOPNOTSUPP ; } -static int igbvf_phys_id (struct net_device *netdev,u32 data) -{ -return 0 ; -} -static int igbvf_get_coalesce (struct net_device *netdev,struct ethtool_coalesce *ec) {
drivers/net/igbvf/ethtool.c static const struct ethtool_ops igbvf_et · line 527
Quoted 7 lines
drivers/net/igbvf/ethtool.c +0
-1@@ -527,7 +522,6 @@ static const struct ethtool_ops igbvf_et .self_test = igbvf_diag_test, .get_sset_count = igbvf_get_sset_count, .get_strings = igbvf_get_strings, - .phys_id = igbvf_phys_id, .get_ethtool_stats = igbvf_get_ethtool_stats, .get_coalesce = igbvf_get_coalesce, .set_coalesce = igbvf_set_coalesce,
I would just like to note that many virtual devices lie about their underlying capabilities. Many systems report having an Realtek adapter when in fact they don't. I'm agnostic about this change but at one time I had an internal bug report because my VF driver *didn't* report phys_id. I'll keep this email around if my tester writes up a big for me.
Regards,
- Greg
David Miller
maintainerRe: [PATCH net-next-2.6 07/12] igbvf: remove bogus phys_id
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:47 -0700
Quoted 4 lines
This device lies about supporting
phys_id. Remove it and just let the upper layer report not supported.Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 8/12 ixgbe: convert to ethtool set_phys_id
In reply to Stephen HemmingerConvert ixgbe driver to use new set_phys_id ethtool interface.
drivers/net/ixgbe/ixgbe_ethtool.c +15 -11
@@ -1999,25 +1999,29 @@ static int ixgbe_nway_reset(struct net_dreturn 0 ; } -static int ixgbe_phys_id (struct net_device *netdev,u32 data) +static int ixgbe_set_phys_id (struct net_device *netdev, +enum ethtool_phys_id_state state) {struct ixgbe_adapter *adapter =netdev_priv (netdev);struct ixgbe_hw *hw = &adapter->hw;u32 led_reg =IXGBE_READ_REG (hw,IXGBE_LEDCTL ); -u32 i; -if (!data || data >300 ) - data =300 ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -1 ; -for (i =0 ; i < (data *1000 ); i +=400 ) { +case ETHTOOL_ID_ON : hw->mac.ops.led_on (hw,IXGBE_LED_ON ); -msleep_interruptible (200 ); +break ; + +case ETHTOOL_ID_OFF : hw->mac.ops.led_off (hw,IXGBE_LED_ON ); -msleep_interruptible (200 ); - } +break ; -/* Restore LED settings */ -IXGBE_WRITE_REG (&adapter->hw,IXGBE_LEDCTL , led_reg); +case ETHTOOL_ID_INACTIVE : +/* Restore LED settings */ +IXGBE_WRITE_REG (&adapter->hw,IXGBE_LEDCTL , led_reg); + }return 0 ; }
@@ -2465,7 +2469,7 @@ static const struct ethtool_ops ixgbe_et .set_tso = ixgbe_set_tso, .self_test = ixgbe_diag_test, .get_strings = ixgbe_get_strings, - .phys_id = ixgbe_phys_id, + .set_phys_id = ixgbe_set_phys_id, .get_sset_count = ixgbe_get_sset_count, .get_ethtool_stats = ixgbe_get_ethtool_stats, .get_coalesce = ixgbe_get_coalesce,
David Miller
maintainerRe: [PATCH net-next-2.6 08/12] ixgbe: convert to ethtool set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:48 -0700
Quoted 3 lines
Convert ixgbe driver to use new
set_phys_idethtool interface.Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 9/12 ixgb: convert to set_phys_id
In reply to Stephen Hemmingerdrivers/net/ixgb/ixgb.h +0 -3
@@ -157,9 +157,6 @@ struct ixgb_adapter {u16 link_duplex;struct work_struct tx_timeout_task; -struct timer_list blink_timer; -unsigned long led_status; -/* TX */ struct ixgb_desc_ring tx_ring____cacheline_aligned_in_smp ;unsigned int restart_queue;
drivers/net/ixgb/ixgb_ethtool.c +12 -34
64 lines not on this page · raw message
David Miller
maintainerRe: [PATCH net-next-2.6 09/12] ixgb: convert to set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:49 -0700
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>
Deferred to Intel driver maintainers.
PATCH 10/12 tg3: implement ethtool set_phys_id
In reply to Stephen HemmingerImplement control of LED via set_phys_id.
Note: since PHY is powered off if device is down, this board only allows blinking if device is up.
drivers/net/tg3.c +23 -20
@@ -10317,35 +10317,38 @@ static void tg3_get_strings(struct net_d } } -static int tg3_phys_id (struct net_device *dev,u32 data) +static int tg3_set_phys_id (struct net_device *dev, +enum ethtool_phys_id_state state) {struct tg3 *tp =netdev_priv (dev); -int i;if (!netif_running (tp->dev))return -EAGAIN ; -if (data ==0 ) - data =UINT_MAX /2 ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -EINVAL ; -for (i =0 ; i < (data *2 ); i++) { -if ((i %2 ) ==0 ) -tw32 (MAC_LED_CTRL ,LED_CTRL_LNKLED_OVERRIDE | -LED_CTRL_1000MBPS_ON | -LED_CTRL_100MBPS_ON | -LED_CTRL_10MBPS_ON | -LED_CTRL_TRAFFIC_OVERRIDE | -LED_CTRL_TRAFFIC_BLINK | -LED_CTRL_TRAFFIC_LED ); +case ETHTOOL_ID_ON : +tw32 (MAC_LED_CTRL ,LED_CTRL_LNKLED_OVERRIDE | +LED_CTRL_1000MBPS_ON | +LED_CTRL_100MBPS_ON | +LED_CTRL_10MBPS_ON | +LED_CTRL_TRAFFIC_OVERRIDE | +LED_CTRL_TRAFFIC_BLINK | +LED_CTRL_TRAFFIC_LED ); +break ; -else -tw32 (MAC_LED_CTRL ,LED_CTRL_LNKLED_OVERRIDE | -LED_CTRL_TRAFFIC_OVERRIDE ); +case ETHTOOL_ID_OFF : +tw32 (MAC_LED_CTRL ,LED_CTRL_LNKLED_OVERRIDE | +LED_CTRL_TRAFFIC_OVERRIDE ); +break ; -if (msleep_interruptible (500 )) -break ; +case ETHTOOL_ID_INACTIVE : +tw32 (MAC_LED_CTRL , tp->led_ctrl); +break ; } -tw32 (MAC_LED_CTRL , tp->led_ctrl); +return 0 ; }
@@ -11371,7 +11374,7 @@ static const struct ethtool_ops tg3_etht .set_tso = tg3_set_tso, .self_test = tg3_self_test, .get_strings = tg3_get_strings, - .phys_id = tg3_phys_id, + .set_phys_id = tg3_set_phys_id, .get_ethtool_stats = tg3_get_ethtool_stats, .get_coalesce = tg3_get_coalesce, .set_coalesce = tg3_set_coalesce,
Re: [PATCH net-next-2.6 10/12] tg3: implement ethtool set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:50 -0700
Quoted 5 lines
Implement control of LED via
set_phys_id.
Note: since PHY is powered off if device is down, this board only allows blinking if device is up.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 11/12 cxgb3: implement set_phys_id
In reply to Stephen HemmingerImplement new ethtool set_phys_id on Chelsio cxgb3 board.
drivers/net/cxgb3/cxgb3_main.c +14 -11
@@ -1749,23 +1749,26 @@ static int restart_autoneg(struct net_dereturn 0 ; } -static int cxgb3_phys_id (struct net_device *dev,u32 data) +static int set_phys_id (struct net_device *dev, +enum ethtool_phys_id_state state) {struct port_info *pi =netdev_priv (dev);struct adapter *adapter = pi->adapter; -int i; -if (data ==0 ) - data =2 ; +switch (state) { +case ETHTOOL_ID_ACTIVE : +return -EINVAL ; + +case ETHTOOL_ID_OFF : +t3_set_reg_field (adapter,A_T3DBG_GPIO_EN ,F_GPIO0_OUT_VAL ,0 ); +break ; -for (i =0 ; i < data *2 ; i++) { +case ETHTOOL_ID_ON : +case ETHTOOL_ID_INACTIVE :t3_set_reg_field (adapter,A_T3DBG_GPIO_EN ,F_GPIO0_OUT_VAL , - (i &1 ) ?F_GPIO0_OUT_VAL :0 ); -if (msleep_interruptible (500 )) -break ; - } -t3_set_reg_field (adapter,A_T3DBG_GPIO_EN ,F_GPIO0_OUT_VAL ,F_GPIO0_OUT_VAL ); + } +return 0 ; }
@@ -2107,7 +2110,7 @@ static const struct ethtool_ops cxgb_eth .set_sg = ethtool_op_set_sg, .get_link = ethtool_op_get_link, .get_strings = get_strings, - .phys_id = cxgb3_phys_id, + .set_phys_id = set_phys_id, .nway_reset = restart_autoneg, .get_sset_count = get_sset_count, .get_ethtool_stats = get_stats,
Re: [PATCH net-next-2.6 11/12] cxgb3: implement set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:51 -0700
Quoted 3 lines
Implement new ethtool
set_phys_idon Chelsio cxgb3 board.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
PATCH 12/12 qlcnic: convert to set_phys_id
In reply to Stephen HemmingerConvert driver to use new ethtool set_phys_id.
Not completely sure that this is correct for all cases of device up/down and doing operation. Compile tested only.
drivers/net/qlcnic/qlcnic_ethtool.c +31 -28
@@ -831,48 +831,51 @@ static int qlcnic_set_tso(struct net_devreturn 0 ; } -static int qlcnic_blink_led (struct net_device *dev,u32 val) +static int qlcnic_set_led (struct net_device *dev, +enum ethtool_phys_id_state state) {struct qlcnic_adapter *adapter =netdev_priv (dev);int max_sds_rings = adapter->max_sds_rings; -int dev_down =0 ;int ret; -if (!test_bit (__QLCNIC_DEV_UP, &adapter->state)) { - dev_down =1 ; -if (test_and_set_bit (__QLCNIC_RESETTING, &adapter->state)) -return -EIO ; - - ret =qlcnic_diag_alloc_res (dev,QLCNIC_LED_TEST ); +switch (state) { +case ETHTOOL_ID_ACTIVE : +if (!test_bit (__QLCNIC_DEV_UP, &adapter->state)) { +if (test_and_set_bit (__QLCNIC_RESETTING, &adapter->state)) +return -EIO ; + + ret =qlcnic_diag_alloc_res (dev,QLCNIC_LED_TEST ); +if (ret) { +clear_bit (__QLCNIC_RESETTING, &adapter->state); +return ret; + } + } + + ret = adapter->nic_ops->config_led (adapter,1 ,0xf );if (ret) { -clear_bit (__QLCNIC_RESETTING, &adapter->state); -return ret; +dev_err (&adapter->pdev->dev, +"Failed to set LED blink state.\n" ); +break ; } - } - - ret = adapter->nic_ops->config_led (adapter,1 ,0xf ); -if (ret) { -dev_err (&adapter->pdev->dev, -"Failed to set LED blink state.\n" ); - goto done; - } +return 0 ; -msleep_interruptible (val *1000 ); +case ETHTOOL_ID_INACTIVE : + ret = adapter->nic_ops->config_led (adapter,0 ,0xf ); +if (ret) +dev_err (&adapter->pdev->dev, +"Failed to reset LED blink state.\n" ); +break ; - ret = adapter->nic_ops->config_led (adapter,0 ,0xf ); -if (ret) { -dev_err (&adapter->pdev->dev, -"Failed to reset LED blink state.\n" ); - goto done; +default : +return -EINVAL ; } -done: -if (dev_down) { +if (!netif_running (dev)) {qlcnic_diag_free_res (dev, max_sds_rings);clear_bit (__QLCNIC_RESETTING, &adapter->state); } -return ret; +return ret; } static void
@@ -1080,7 +1083,7 @@ const struct ethtool_ops qlcnic_ethtool_ .set_coalesce = qlcnic_set_intr_coalesce, .get_flags = ethtool_op_get_flags, .set_flags = qlcnic_set_flags, - .phys_id = qlcnic_blink_led, + .set_phys_id = qlcnic_set_led, .set_msglevel = qlcnic_set_msglevel, .get_msglevel = qlcnic_get_msglevel, };
RE: [PATCH net-next-2.6 12/12] qlcnic: convert to set_phys_id
Quoted 36 lines
drivers/net/qlcnic/qlcnic_ethtool.c +13
-16+ ret = adapter->nic_ops->config_led (adapter,1 ,0xf );if (ret) { -clear_bit (__QLCNIC_RESETTING, &adapter->state); -return ret; +dev_err (&adapter->pdev->dev, +"Failed to set LED blink state.\n" ); +break ; } - } - - ret = adapter->nic_ops->config_led (adapter,1 ,0xf ); -if (ret) { -dev_err (&adapter->pdev->dev, -"Failed to set LED blink state.\n" ); - goto done; - } +return 0 ; -msleep_interruptible (val *1000 ); +case ETHTOOL_ID_INACTIVE : + ret = adapter->nic_ops->config_led (adapter,0 ,0xf ); +if (ret) +dev_err (&adapter->pdev->dev, +"Failed to reset LED blink state.\n" ); +break ; - ret = adapter->nic_ops->config_led (adapter,0 ,0xf ); -if (ret) { -dev_err (&adapter->pdev->dev, -"Failed to reset LED blink state.\n" ); - goto done; +default : +return -EINVAL ; }
drivers/net/qlcnic/qlcnic_ethtool.c static int qlcnic_set_tso(struct net_dev · line 879
Quoted 10 lines
drivers/net/qlcnic/qlcnic_ethtool.c +2
-3-done: -if (dev_down) { +if (!netif_running (dev)) {qlcnic_diag_free_res (dev, max_sds_rings);clear_bit (__QLCNIC_RESETTING, &adapter->state); } -return ret; +return ret; }
"return ret" is return value of adapter->nic_ops->config_led, which can return any Error value.
And you have special check for -EINVAL. Though currently config_led doesn't return -EINVAL, but in future it may break (as 'ret' comes from config_led() -> send_cmd_desc()). So it will be better if you return some hard code error value instead of 'ret'.
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
David Miller
maintainerRe: [PATCH net-next-2.6 12/12] qlcnic: convert to set_phys_id
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 04 Apr 2011 11:43:52 -0700
Quoted 5 lines
Convert driver to use new ethtool
set_phys_id.
Not completely sure that this is correct for all cases of device up/down and doing operation. Compile tested only.Signed-off-by Stephen Hemminger <[email protected]>
Please address the feedback given by qlcnic developers.
Thanks.
Re: [PATCH net-next-2.6 12/12] qlcnic: convert to set_phys_id
Convert driver to use new ethtool set_phys_id.
Not completely sure that this is correct for all cases of device up/down and doing operation. Compile tested only.
---
v2 -use adapter variable to hold state across active/inactive
drivers/net/qlcnic/qlcnic_ethtool.c +28 -25
@@ -831,48 +831,51 @@ static int qlcnic_set_tso(struct net_devreturn 0 ; } -static int qlcnic_blink_led (struct net_device *dev,u32 val) +static int qlcnic_set_led (struct net_device *dev, +enum ethtool_phys_id_state state) {struct qlcnic_adapter *adapter =netdev_priv (dev);int max_sds_rings = adapter->max_sds_rings; -int dev_down =0 ; -int ret; -if (!test_bit (__QLCNIC_DEV_UP, &adapter->state)) { - dev_down =1 ; -if (test_and_set_bit (__QLCNIC_RESETTING, &adapter->state)) -return -EIO ; - - ret =qlcnic_diag_alloc_res (dev,QLCNIC_LED_TEST ); -if (ret) { -clear_bit (__QLCNIC_RESETTING, &adapter->state); -return ret; +switch (state) { +case ETHTOOL_ID_ACTIVE : + adapter->blink_was_down = false; +if (!test_bit (__QLCNIC_DEV_UP, &adapter->state)) { +if (test_and_set_bit (__QLCNIC_RESETTING, &adapter->state)) +return -EIO ; + +if (qlcnic_diag_alloc_res (dev,QLCNIC_LED_TEST )) { +clear_bit (__QLCNIC_RESETTING, &adapter->state); +return -EIO ; + } + adapter->blink_was_down = true; } - } - ret = adapter->nic_ops->config_led (adapter,1 ,0xf ); -if (ret) { +if (adapter->nic_ops->config_led (adapter,1 ,0xf ) ==0 ) +return 0 ; +dev_err (&adapter->pdev->dev,"Failed to set LED blink state.\n" ); - goto done; - } +break ; -msleep_interruptible (val *1000 ); +case ETHTOOL_ID_INACTIVE : +if (adapter->nic_ops->config_led (adapter,0 ,0xf ) ==0 ) +return 0 ; - ret = adapter->nic_ops->config_led (adapter,0 ,0xf ); -if (ret) {dev_err (&adapter->pdev->dev,"Failed to reset LED blink state.\n" ); - goto done; +break ; + +default : +return -EINVAL ; } -done: -if (dev_down) { +if (adapter->blink_was_down) {qlcnic_diag_free_res (dev, max_sds_rings);clear_bit (__QLCNIC_RESETTING, &adapter->state); } -return ret; +return -EIO ; } static void
@@ -1080,7 +1083,7 @@ const struct ethtool_ops qlcnic_ethtool_ .set_coalesce = qlcnic_set_intr_coalesce, .get_flags = ethtool_op_get_flags, .set_flags = qlcnic_set_flags, - .phys_id = qlcnic_blink_led, + .set_phys_id = qlcnic_set_led, .set_msglevel = qlcnic_set_msglevel, .get_msglevel = qlcnic_get_msglevel, };
drivers/net/qlcnic/qlcnic.h +1 -0
@@ -1056,6 +1056,7 @@ struct qlcnic_adapter {struct qlcnic_filter_hash fhash; +bool blink_was_down;unsigned long state;__le32 file_prd_off;/*File fw product offset*/ u32 fw_version;
Re: [PATCH net-next-2.6 12/12] qlcnic: convert to set_phys_id
From: Stephen Hemminger <[email protected]>
Date: Wed, 6 Apr 2011 14:47:23 -0700
Quoted 5 lines
Convert driver to use new ethtool
set_phys_id.
Not completely sure that this is correct for all cases of device up/down and doing operation. Compile tested only.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
Quoted 3 lines · Stephen Hemminger
Did a bunch of the easy drivers to convert.
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
Signature · 2 lines
Cheers, Jeff
David Miller
maintainerFrom: Jeff Kirsher <[email protected]>
Date: Mon, 4 Apr 2011 12:53:14 -0700
Quoted 7 lines · Stephen Hemminger
Quoted 3 lines
Did a bunch of the easy drivers to convert.
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
Careful, Ben's commit to add the interface still isn't in the tree.
He needs to respin his patch set based upon feedback that came in the other day.
Quoted 8 lines · David Miller
From: Jeff Kirsher <[email protected]>
Date: Mon, 4 Apr 2011 12:53:14 -0700Quoted 5 lines · Stephen Hemminger
Quoted 3 lines
Did a bunch of the easy drivers to convert.
Quoted 7 lines
Quoted 2 lines
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
Careful, Ben's commit to add the interface still isn't in the tree.
He needs to respin his patch set based upon feedback that came in the other day.
Yeah, I caught that. I will be adding the dependent patches to my internal tree for validation purposes only.
Quoted 7 lines · On Mon, 4 Apr 2011 12:53:14 -0700 Jeff Kirsher <[email protected]>…
Quoted 3 lines · Stephen Hemminger
Did a bunch of the easy drivers to convert.
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
I changed the behaviour of igbvf for 'ethtool -p' to return not supported. This seems correct, but it may break somebody who has some weird script running in a virt environment.
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Mon, 4 Apr 2011 12:53:14 -0700 Jeff Kirsher <[email protected]>…
Quoted 3 lines · Stephen Hemminger
Did a bunch of the easy drivers to convert.
Quoted 6 lines
Quoted 2 lines
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
I changed the behaviour of igbvf for 'ethtool -p' to return not supported. This seems correct, but it may break somebody who has some weird script running in a virt environment.
Surely it should be connected to a virtual LED. Doesn't virt-manager have those yet? ;-)
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 · Stephen Hemminger
Quoted 5 lines · On Mon, 4 Apr 2011 12:53:14 -0700 Jeff Kirsher <[email protected]>…
Quoted 3 lines · Stephen Hemminger
Did a bunch of the easy drivers to convert.
Quoted 6 lines
Quoted 2 lines
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
I changed the behaviour of igbvf for 'ethtool -p' to return not supported. This seems correct, but it may break somebody who has some weird script running in a virt environment.
I also noticed you did not convert ixgbevf, so we will take a look at your changes for igbvf and come up with a patch for ixgbevf.
Quoted 12 lines · On Mon, 04 Apr 2011 13:32:44 -0700 Jeff Kirsher <[email protected]>…
Quoted 11 lines · Stephen Hemminger
Quoted 7 lines · On Mon, 4 Apr 2011 12:53:14 -0700 Jeff Kirsher <[email protected]>…
Quoted 3 lines · Stephen Hemminger
Did a bunch of the easy drivers to convert.
I have added patches 3-9 (Intel driver conversions) to my queue of patches. Thanks Stephen.
Quoted 6 lines
Quoted 3 lines
I changed the behaviour of igbvf for 'ethtool -p' to return not supported. This seems correct, but it may break somebody who has some weird script running in a virt environment.
I also noticed you did not convert ixgbevf, so we will take a look at your changes for igbvf and come up with a patch for ixgbevf.
ixgbevf has no hook for phys_id and therefore no change is needed.
Quoted 1 line · Stephen Hemminger
Did a bunch of the easy drivers to convert.
Thanks Stephen. I would have done some of these but I'm pretty snowed under at the moment.
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.