sfc: Use a single blink implementation
Subsystems (2)
PATCH 7/17 sfc: Use a single blink implementation
Only some PHYs have firmware support for a LED blink mode, so we currently blink the others in a timer function. Since all PHYs have simple on and off modes, we don't gain anything by using multiple blink implementations. Also, since we have a process context there is no need to use a timer.
Signed-off-by Ben Hutchings <[email protected]>
--- drivers/net/sfc/efx.c | 7 ++-- drivers/net/sfc/efx.h | 3 +- drivers/net/sfc/ethtool.c | 16 +++++---- drivers/net/sfc/falcon_boards.c | 66 +++++++++++++-------------------------- drivers/net/sfc/net_driver.h | 18 +++++------ drivers/net/sfc/phy.h | 2 +- drivers/net/sfc/qt202x_phy.c | 3 -- drivers/net/sfc/tenxpress.c | 24 +++++++++----- 8 files changed, 62 insertions(+), 77 deletions(-)
drivers/net/sfc/efx.c +4 -3
@@ -1890,7 +1890,9 @@ int efx_port_dummy_op_int(struct efx_nic *efx)return 0 ; }void efx_port_dummy_op_void (struct efx_nic *efx) {} -void efx_port_dummy_op_blink (struct efx_nic *efx,bool blink) {} +void efx_port_dummy_op_set_id_led (struct efx_nic *efx,enum efx_led_mode mode) +{ +}static struct efx_mac_operations efx_dummy_mac_operations = { .reconfigure = efx_port_dummy_op_void,
@@ -1909,9 +1911,8 @@ static struct efx_phy_operations efx_dummy_phy_operations = {static struct efx_board efx_dummy_board_info = { .init = efx_port_dummy_op_int, .init_leds = efx_port_dummy_op_void, - .set_id_led = efx_port_dummy_op_blink, + .set_id_led = efx_port_dummy_op_set_id_led, .monitor = efx_port_dummy_op_int, - .blink = efx_port_dummy_op_blink, .fini = efx_port_dummy_op_void, };
drivers/net/sfc/efx.h +2 -1
@@ -69,7 +69,8 @@ extern void efx_hex_dump(const u8 *, unsigned int, const char *);/* Dummy PHY ops for PHY drivers */ extern int efx_port_dummy_op_int (struct efx_nic *efx);extern void efx_port_dummy_op_void (struct efx_nic *efx); -extern void efx_port_dummy_op_blink (struct efx_nic *efx,bool blink); +extern void +efx_port_dummy_op_set_id_led (struct efx_nic *efx,enum efx_led_mode mode);/* MTD */ #ifdef CONFIG_SFC_MTD
drivers/net/sfc/ethtool.c +9 -7
@@ -187,13 +187,15 @@ static int efx_ethtool_phys_id(struct net_device *net_dev, u32 count) {struct efx_nic *efx =netdev_priv (net_dev); - efx->board_info.blink (efx,1 ); -set_current_state (TASK_INTERRUPTIBLE ); -if (count) -schedule_timeout (count *HZ ); -else -schedule (); - efx->board_info.blink (efx,0 ); +do { + efx->board_info.set_id_led (efx,EFX_LED_ON ); +schedule_timeout_interruptible (HZ /2 ); + + efx->board_info.set_id_led (efx,EFX_LED_OFF ); +schedule_timeout_interruptible (HZ /2 ); + }while (!signal_pending (current) && --count !=0 ); + + efx->board_info.set_id_led (efx,EFX_LED_DEFAULT );return 0 ; }
drivers/net/sfc/falcon_boards.c +22 -44
110 lines not on this page · raw message
drivers/net/sfc/net_driver.h +8 -10
@@ -388,6 +388,12 @@ struct efx_channel { }; +enum efx_led_mode { +EFX_LED_OFF =0 , +EFX_LED_ON =1 , +EFX_LED_DEFAULT =2 +}; +/** * struct efx_board - board information * @type: Board model type
@@ -395,13 +401,9 @@ struct efx_channel {* @minor: Minor rev. (0, 1, ...) * @init: Initialisation function * @init_leds: Sets up board LEDs. May be called repeatedly. -* @set_id_led: Turns the identification LED on or off -* @blink: Starts/stops blinking +* @set_id_led: Set state of identifying LED or revert to automatic function * @monitor: Board-specific health check function * @fini: Cleanup function -* @blink_state: Current blink state -* @blink_resubmit: Blink timer resubmission flag -* @blink_timer: Blink timer * @hwmon_client: I2C client for hardware monitor * @ioexp_client: I2C client for power/port control */
@@ -414,13 +416,9 @@ struct efx_board {* have a separate init callback that happens later than * board init. */ void (*init_leds)(struct efx_nic *efx); -void (*set_id_led) (struct efx_nic *efx,bool state); +void (*set_id_led) (struct efx_nic *efx,enum efx_led_mode mode);int (*monitor) (struct efx_nic *nic); -void (*blink) (struct efx_nic *efx,bool start);void (*fini) (struct efx_nic *nic); -bool blink_state; -bool blink_resubmit; -struct timer_list blink_timer;struct i2c_client *hwmon_client, *ioexp_client; };
drivers/net/sfc/phy.h +1 -1
@@ -16,7 +16,7 @@extern struct efx_phy_operations falcon_sfx7101_phy_ops;extern struct efx_phy_operations falcon_sft9001_phy_ops; -extern void tenxpress_phy_blink (struct efx_nic *efx,bool blink); +extern void tenxpress_set_id_led (struct efx_nic *efx,enum efx_led_mode mode);/* Wait for the PHY to boot. Return 0 on success, -EINVAL if the PHY failed * to boot due to corrupt flash, or some other negative error code. */
drivers/net/sfc/qt202x_phy.c +0 -3
@@ -228,9 +228,6 @@ static void qt202x_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmstatic void qt202x_phy_fini (struct efx_nic *efx) { -/* Clobber the LED if it was blinking */ - efx->board_info.blink (efx, false); -/* Free the context block */ kfree (efx->phy_data); efx->phy_data =NULL ;
drivers/net/sfc/tenxpress.c +16 -8
@@ -613,21 +613,29 @@ static void tenxpress_phy_fini(struct efx_nic *efx) } -/* Set the RX and TX LEDs and Link LED flashing. The other LEDs -* (which probably aren't wired anyway) are left in AUTO mode */ -void tenxpress_phy_blink (struct efx_nic *efx,bool blink) +/* Override the RX, TX and link LEDs */ +void tenxpress_set_id_led (struct efx_nic *efx,enum efx_led_mode mode) {int reg; -if (blink) - reg = (PMA_PMD_LED_FLASH <<PMA_PMD_LED_TX_LBN ) | - (PMA_PMD_LED_FLASH <<PMA_PMD_LED_RX_LBN ) | - (PMA_PMD_LED_FLASH <<PMA_PMD_LED_LINK_LBN ); -else +switch (mode) { +case EFX_LED_OFF : + reg = (PMA_PMD_LED_OFF <<PMA_PMD_LED_TX_LBN ) | + (PMA_PMD_LED_OFF <<PMA_PMD_LED_RX_LBN ) | + (PMA_PMD_LED_OFF <<PMA_PMD_LED_LINK_LBN ); +break ; +case EFX_LED_ON : + reg = (PMA_PMD_LED_ON <<PMA_PMD_LED_TX_LBN ) | + (PMA_PMD_LED_ON <<PMA_PMD_LED_RX_LBN ) | + (PMA_PMD_LED_ON <<PMA_PMD_LED_LINK_LBN ); +break ; +default :if (efx->phy_type ==PHY_TYPE_SFX7101 ) reg =SFX7101_PMA_PMD_LED_DEFAULT ;else reg =SFT9001_PMA_PMD_LED_DEFAULT ; +break ; + }efx_mdio_write (efx,MDIO_MMD_PMAPMD ,PMA_PMD_LED_OVERR_REG , reg); }
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.