diff options
author | stephen hemminger <shemminger@vyatta.com> | 2011-04-04 11:09:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-06 17:35:23 -0400 |
commit | 034e345081cfb442abeb0e00fa26edeedb5ba96a (patch) | |
tree | 7b1f3fdc59d3cf03c92d0c964dd8ca775870fce1 /drivers/net/s2io.c | |
parent | 7bc93714042418cbc4ca89c51d3ab448ea3ef2fe (diff) |
s2io: convert to set_phys_id (v2)
Convert to new ethtool set physical id model. Remove no longer used
timer, and fix docbook comment.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/s2io.c')
-rw-r--r-- | drivers/net/s2io.c | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 356e74d20b80..cae08edb833e 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -5484,83 +5484,79 @@ static void s2io_ethtool_gregs(struct net_device *dev, | |||
5484 | } | 5484 | } |
5485 | } | 5485 | } |
5486 | 5486 | ||
5487 | /** | 5487 | /* |
5488 | * s2io_phy_id - timer function that alternates adapter LED. | 5488 | * s2io_set_led - control NIC led |
5489 | * @data : address of the private member of the device structure, which | ||
5490 | * is a pointer to the s2io_nic structure, provided as an u32. | ||
5491 | * Description: This is actually the timer function that alternates the | ||
5492 | * adapter LED bit of the adapter control bit to set/reset every time on | ||
5493 | * invocation. The timer is set for 1/2 a second, hence tha NIC blinks | ||
5494 | * once every second. | ||
5495 | */ | 5489 | */ |
5496 | static void s2io_phy_id(unsigned long data) | 5490 | static void s2io_set_led(struct s2io_nic *sp, bool on) |
5497 | { | 5491 | { |
5498 | struct s2io_nic *sp = (struct s2io_nic *)data; | ||
5499 | struct XENA_dev_config __iomem *bar0 = sp->bar0; | 5492 | struct XENA_dev_config __iomem *bar0 = sp->bar0; |
5500 | u64 val64 = 0; | 5493 | u16 subid = sp->pdev->subsystem_device; |
5501 | u16 subid; | 5494 | u64 val64; |
5502 | 5495 | ||
5503 | subid = sp->pdev->subsystem_device; | ||
5504 | if ((sp->device_type == XFRAME_II_DEVICE) || | 5496 | if ((sp->device_type == XFRAME_II_DEVICE) || |
5505 | ((subid & 0xFF) >= 0x07)) { | 5497 | ((subid & 0xFF) >= 0x07)) { |
5506 | val64 = readq(&bar0->gpio_control); | 5498 | val64 = readq(&bar0->gpio_control); |
5507 | val64 ^= GPIO_CTRL_GPIO_0; | 5499 | if (on) |
5500 | val64 |= GPIO_CTRL_GPIO_0; | ||
5501 | else | ||
5502 | val64 &= ~GPIO_CTRL_GPIO_0; | ||
5503 | |||
5508 | writeq(val64, &bar0->gpio_control); | 5504 | writeq(val64, &bar0->gpio_control); |
5509 | } else { | 5505 | } else { |
5510 | val64 = readq(&bar0->adapter_control); | 5506 | val64 = readq(&bar0->adapter_control); |
5511 | val64 ^= ADAPTER_LED_ON; | 5507 | if (on) |
5508 | val64 |= ADAPTER_LED_ON; | ||
5509 | else | ||
5510 | val64 &= ~ADAPTER_LED_ON; | ||
5511 | |||
5512 | writeq(val64, &bar0->adapter_control); | 5512 | writeq(val64, &bar0->adapter_control); |
5513 | } | 5513 | } |
5514 | 5514 | ||
5515 | mod_timer(&sp->id_timer, jiffies + HZ / 2); | ||
5516 | } | 5515 | } |
5517 | 5516 | ||
5518 | /** | 5517 | /** |
5519 | * s2io_ethtool_idnic - To physically identify the nic on the system. | 5518 | * s2io_ethtool_set_led - To physically identify the nic on the system. |
5520 | * @sp : private member of the device structure, which is a pointer to the | 5519 | * @dev : network device |
5521 | * s2io_nic structure. | 5520 | * @state: led setting |
5522 | * @id : pointer to the structure with identification parameters given by | 5521 | * |
5523 | * ethtool. | ||
5524 | * Description: Used to physically identify the NIC on the system. | 5522 | * Description: Used to physically identify the NIC on the system. |
5525 | * The Link LED will blink for a time specified by the user for | 5523 | * The Link LED will blink for a time specified by the user for |
5526 | * identification. | 5524 | * identification. |
5527 | * NOTE: The Link has to be Up to be able to blink the LED. Hence | 5525 | * NOTE: The Link has to be Up to be able to blink the LED. Hence |
5528 | * identification is possible only if it's link is up. | 5526 | * identification is possible only if it's link is up. |
5529 | * Return value: | ||
5530 | * int , returns 0 on success | ||
5531 | */ | 5527 | */ |
5532 | 5528 | ||
5533 | static int s2io_ethtool_idnic(struct net_device *dev, u32 data) | 5529 | static int s2io_ethtool_set_led(struct net_device *dev, |
5530 | enum ethtool_phys_id_state state) | ||
5534 | { | 5531 | { |
5535 | u64 val64 = 0, last_gpio_ctrl_val; | ||
5536 | struct s2io_nic *sp = netdev_priv(dev); | 5532 | struct s2io_nic *sp = netdev_priv(dev); |
5537 | struct XENA_dev_config __iomem *bar0 = sp->bar0; | 5533 | struct XENA_dev_config __iomem *bar0 = sp->bar0; |
5538 | u16 subid; | 5534 | u16 subid = sp->pdev->subsystem_device; |
5539 | 5535 | ||
5540 | subid = sp->pdev->subsystem_device; | ||
5541 | last_gpio_ctrl_val = readq(&bar0->gpio_control); | ||
5542 | if ((sp->device_type == XFRAME_I_DEVICE) && ((subid & 0xFF) < 0x07)) { | 5536 | if ((sp->device_type == XFRAME_I_DEVICE) && ((subid & 0xFF) < 0x07)) { |
5543 | val64 = readq(&bar0->adapter_control); | 5537 | u64 val64 = readq(&bar0->adapter_control); |
5544 | if (!(val64 & ADAPTER_CNTL_EN)) { | 5538 | if (!(val64 & ADAPTER_CNTL_EN)) { |
5545 | pr_err("Adapter Link down, cannot blink LED\n"); | 5539 | pr_err("Adapter Link down, cannot blink LED\n"); |
5546 | return -EFAULT; | 5540 | return -EAGAIN; |
5547 | } | 5541 | } |
5548 | } | 5542 | } |
5549 | if (sp->id_timer.function == NULL) { | ||
5550 | init_timer(&sp->id_timer); | ||
5551 | sp->id_timer.function = s2io_phy_id; | ||
5552 | sp->id_timer.data = (unsigned long)sp; | ||
5553 | } | ||
5554 | mod_timer(&sp->id_timer, jiffies); | ||
5555 | if (data) | ||
5556 | msleep_interruptible(data * HZ); | ||
5557 | else | ||
5558 | msleep_interruptible(MAX_FLICKER_TIME); | ||
5559 | del_timer_sync(&sp->id_timer); | ||
5560 | 5543 | ||
5561 | if (CARDS_WITH_FAULTY_LINK_INDICATORS(sp->device_type, subid)) { | 5544 | switch (state) { |
5562 | writeq(last_gpio_ctrl_val, &bar0->gpio_control); | 5545 | case ETHTOOL_ID_ACTIVE: |
5563 | last_gpio_ctrl_val = readq(&bar0->gpio_control); | 5546 | sp->adapt_ctrl_org = readq(&bar0->gpio_control); |
5547 | return -EINVAL; | ||
5548 | |||
5549 | case ETHTOOL_ID_ON: | ||
5550 | s2io_set_led(sp, true); | ||
5551 | break; | ||
5552 | |||
5553 | case ETHTOOL_ID_OFF: | ||
5554 | s2io_set_led(sp, false); | ||
5555 | break; | ||
5556 | |||
5557 | case ETHTOOL_ID_INACTIVE: | ||
5558 | if (CARDS_WITH_FAULTY_LINK_INDICATORS(sp->device_type, subid)) | ||
5559 | writeq(sp->adapt_ctrl_org, &bar0->gpio_control); | ||
5564 | } | 5560 | } |
5565 | 5561 | ||
5566 | return 0; | 5562 | return 0; |
@@ -6776,7 +6772,7 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
6776 | .set_ufo = ethtool_op_set_ufo, | 6772 | .set_ufo = ethtool_op_set_ufo, |
6777 | .self_test = s2io_ethtool_test, | 6773 | .self_test = s2io_ethtool_test, |
6778 | .get_strings = s2io_ethtool_get_strings, | 6774 | .get_strings = s2io_ethtool_get_strings, |
6779 | .phys_id = s2io_ethtool_idnic, | 6775 | .set_phys_id = s2io_ethtool_set_led, |
6780 | .get_ethtool_stats = s2io_get_ethtool_stats, | 6776 | .get_ethtool_stats = s2io_get_ethtool_stats, |
6781 | .get_sset_count = s2io_get_sset_count, | 6777 | .get_sset_count = s2io_get_sset_count, |
6782 | }; | 6778 | }; |