diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2007-12-20 23:05:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:59:29 -0500 |
commit | 8d018621085b8d00511768c343d941676bd77ee9 (patch) | |
tree | 0649c902e48609a0af8391bcb99cc7ff5080ff97 /drivers/net | |
parent | a43d8994b959a6daeeadcd1be6d4a9045b7029ac (diff) |
[TG3]: Separate requested and actual flow control parameters
This patch removes the TX and RX flow control flags from tg3_flags and
adds two new flow control variables, flowctrl and active_flowctrl.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/tg3.c | 69 | ||||
-rw-r--r-- | drivers/net/tg3.h | 9 |
2 files changed, 42 insertions, 36 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 1f0fd7643249..ad0289ab26c9 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -1602,17 +1602,19 @@ static void tg3_link_report(struct tg3 *tp) | |||
1602 | (tp->link_config.active_duplex == DUPLEX_FULL ? | 1602 | (tp->link_config.active_duplex == DUPLEX_FULL ? |
1603 | "full" : "half")); | 1603 | "full" : "half")); |
1604 | 1604 | ||
1605 | printk(KERN_INFO PFX "%s: Flow control is %s for TX and " | 1605 | printk(KERN_INFO PFX |
1606 | "%s for RX.\n", | 1606 | "%s: Flow control is %s for TX and %s for RX.\n", |
1607 | tp->dev->name, | 1607 | tp->dev->name, |
1608 | (tp->tg3_flags & TG3_FLAG_TX_PAUSE) ? "on" : "off", | 1608 | (tp->link_config.active_flowctrl & TG3_FLOW_CTRL_TX) ? |
1609 | (tp->tg3_flags & TG3_FLAG_RX_PAUSE) ? "on" : "off"); | 1609 | "on" : "off", |
1610 | (tp->link_config.active_flowctrl & TG3_FLOW_CTRL_RX) ? | ||
1611 | "on" : "off"); | ||
1610 | } | 1612 | } |
1611 | } | 1613 | } |
1612 | 1614 | ||
1613 | static void tg3_setup_flow_control(struct tg3 *tp, u32 local_adv, u32 remote_adv) | 1615 | static void tg3_setup_flow_control(struct tg3 *tp, u32 local_adv, u32 remote_adv) |
1614 | { | 1616 | { |
1615 | u32 new_tg3_flags = 0; | 1617 | u8 new_tg3_flags = 0; |
1616 | u32 old_rx_mode = tp->rx_mode; | 1618 | u32 old_rx_mode = tp->rx_mode; |
1617 | u32 old_tx_mode = tp->tx_mode; | 1619 | u32 old_tx_mode = tp->tx_mode; |
1618 | 1620 | ||
@@ -1639,31 +1641,27 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 local_adv, u32 remote_adv | |||
1639 | if (local_adv & ADVERTISE_PAUSE_CAP) { | 1641 | if (local_adv & ADVERTISE_PAUSE_CAP) { |
1640 | if (local_adv & ADVERTISE_PAUSE_ASYM) { | 1642 | if (local_adv & ADVERTISE_PAUSE_ASYM) { |
1641 | if (remote_adv & LPA_PAUSE_CAP) | 1643 | if (remote_adv & LPA_PAUSE_CAP) |
1642 | new_tg3_flags |= | 1644 | new_tg3_flags = TG3_FLOW_CTRL_RX | |
1643 | (TG3_FLAG_RX_PAUSE | | 1645 | TG3_FLOW_CTRL_TX; |
1644 | TG3_FLAG_TX_PAUSE); | ||
1645 | else if (remote_adv & LPA_PAUSE_ASYM) | 1646 | else if (remote_adv & LPA_PAUSE_ASYM) |
1646 | new_tg3_flags |= | 1647 | new_tg3_flags = TG3_FLOW_CTRL_RX; |
1647 | (TG3_FLAG_RX_PAUSE); | ||
1648 | } else { | 1648 | } else { |
1649 | if (remote_adv & LPA_PAUSE_CAP) | 1649 | if (remote_adv & LPA_PAUSE_CAP) |
1650 | new_tg3_flags |= | 1650 | new_tg3_flags = TG3_FLOW_CTRL_RX | |
1651 | (TG3_FLAG_RX_PAUSE | | 1651 | TG3_FLOW_CTRL_TX; |
1652 | TG3_FLAG_TX_PAUSE); | ||
1653 | } | 1652 | } |
1654 | } else if (local_adv & ADVERTISE_PAUSE_ASYM) { | 1653 | } else if (local_adv & ADVERTISE_PAUSE_ASYM) { |
1655 | if ((remote_adv & LPA_PAUSE_CAP) && | 1654 | if ((remote_adv & LPA_PAUSE_CAP) && |
1656 | (remote_adv & LPA_PAUSE_ASYM)) | 1655 | (remote_adv & LPA_PAUSE_ASYM)) |
1657 | new_tg3_flags |= TG3_FLAG_TX_PAUSE; | 1656 | new_tg3_flags = TG3_FLOW_CTRL_TX; |
1658 | } | 1657 | } |
1659 | |||
1660 | tp->tg3_flags &= ~(TG3_FLAG_RX_PAUSE | TG3_FLAG_TX_PAUSE); | ||
1661 | tp->tg3_flags |= new_tg3_flags; | ||
1662 | } else { | 1658 | } else { |
1663 | new_tg3_flags = tp->tg3_flags; | 1659 | new_tg3_flags = tp->link_config.flowctrl; |
1664 | } | 1660 | } |
1665 | 1661 | ||
1666 | if (new_tg3_flags & TG3_FLAG_RX_PAUSE) | 1662 | tp->link_config.active_flowctrl = new_tg3_flags; |
1663 | |||
1664 | if (new_tg3_flags & TG3_FLOW_CTRL_RX) | ||
1667 | tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE; | 1665 | tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE; |
1668 | else | 1666 | else |
1669 | tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE; | 1667 | tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE; |
@@ -1672,7 +1670,7 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 local_adv, u32 remote_adv | |||
1672 | tw32_f(MAC_RX_MODE, tp->rx_mode); | 1670 | tw32_f(MAC_RX_MODE, tp->rx_mode); |
1673 | } | 1671 | } |
1674 | 1672 | ||
1675 | if (new_tg3_flags & TG3_FLAG_TX_PAUSE) | 1673 | if (new_tg3_flags & TG3_FLOW_CTRL_TX) |
1676 | tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE; | 1674 | tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE; |
1677 | else | 1675 | else |
1678 | tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE; | 1676 | tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE; |
@@ -2812,9 +2810,7 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int force_reset) | |||
2812 | int current_link_up; | 2810 | int current_link_up; |
2813 | int i; | 2811 | int i; |
2814 | 2812 | ||
2815 | orig_pause_cfg = | 2813 | orig_pause_cfg = tp->link_config.active_flowctrl; |
2816 | (tp->tg3_flags & (TG3_FLAG_RX_PAUSE | | ||
2817 | TG3_FLAG_TX_PAUSE)); | ||
2818 | orig_active_speed = tp->link_config.active_speed; | 2814 | orig_active_speed = tp->link_config.active_speed; |
2819 | orig_active_duplex = tp->link_config.active_duplex; | 2815 | orig_active_duplex = tp->link_config.active_duplex; |
2820 | 2816 | ||
@@ -2903,9 +2899,7 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int force_reset) | |||
2903 | netif_carrier_off(tp->dev); | 2899 | netif_carrier_off(tp->dev); |
2904 | tg3_link_report(tp); | 2900 | tg3_link_report(tp); |
2905 | } else { | 2901 | } else { |
2906 | u32 now_pause_cfg = | 2902 | u32 now_pause_cfg = tp->link_config.active_flowctrl; |
2907 | tp->tg3_flags & (TG3_FLAG_RX_PAUSE | | ||
2908 | TG3_FLAG_TX_PAUSE); | ||
2909 | if (orig_pause_cfg != now_pause_cfg || | 2903 | if (orig_pause_cfg != now_pause_cfg || |
2910 | orig_active_speed != tp->link_config.active_speed || | 2904 | orig_active_speed != tp->link_config.active_speed || |
2911 | orig_active_duplex != tp->link_config.active_duplex) | 2905 | orig_active_duplex != tp->link_config.active_duplex) |
@@ -8569,8 +8563,16 @@ static void tg3_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam | |||
8569 | struct tg3 *tp = netdev_priv(dev); | 8563 | struct tg3 *tp = netdev_priv(dev); |
8570 | 8564 | ||
8571 | epause->autoneg = (tp->tg3_flags & TG3_FLAG_PAUSE_AUTONEG) != 0; | 8565 | epause->autoneg = (tp->tg3_flags & TG3_FLAG_PAUSE_AUTONEG) != 0; |
8572 | epause->rx_pause = (tp->tg3_flags & TG3_FLAG_RX_PAUSE) != 0; | 8566 | |
8573 | epause->tx_pause = (tp->tg3_flags & TG3_FLAG_TX_PAUSE) != 0; | 8567 | if (tp->link_config.active_flowctrl & TG3_FLOW_CTRL_RX) |
8568 | epause->rx_pause = 1; | ||
8569 | else | ||
8570 | epause->rx_pause = 0; | ||
8571 | |||
8572 | if (tp->link_config.active_flowctrl & TG3_FLOW_CTRL_TX) | ||
8573 | epause->tx_pause = 1; | ||
8574 | else | ||
8575 | epause->tx_pause = 0; | ||
8574 | } | 8576 | } |
8575 | 8577 | ||
8576 | static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) | 8578 | static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) |
@@ -8590,13 +8592,13 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam | |||
8590 | else | 8592 | else |
8591 | tp->tg3_flags &= ~TG3_FLAG_PAUSE_AUTONEG; | 8593 | tp->tg3_flags &= ~TG3_FLAG_PAUSE_AUTONEG; |
8592 | if (epause->rx_pause) | 8594 | if (epause->rx_pause) |
8593 | tp->tg3_flags |= TG3_FLAG_RX_PAUSE; | 8595 | tp->link_config.flowctrl |= TG3_FLOW_CTRL_RX; |
8594 | else | 8596 | else |
8595 | tp->tg3_flags &= ~TG3_FLAG_RX_PAUSE; | 8597 | tp->link_config.flowctrl &= ~TG3_FLOW_CTRL_RX; |
8596 | if (epause->tx_pause) | 8598 | if (epause->tx_pause) |
8597 | tp->tg3_flags |= TG3_FLAG_TX_PAUSE; | 8599 | tp->link_config.flowctrl |= TG3_FLOW_CTRL_TX; |
8598 | else | 8600 | else |
8599 | tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE; | 8601 | tp->link_config.flowctrl &= ~TG3_FLOW_CTRL_TX; |
8600 | 8602 | ||
8601 | if (netif_running(dev)) { | 8603 | if (netif_running(dev)) { |
8602 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 8604 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
@@ -12631,6 +12633,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
12631 | 12633 | ||
12632 | /* flow control autonegotiation is default behavior */ | 12634 | /* flow control autonegotiation is default behavior */ |
12633 | tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; | 12635 | tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; |
12636 | tp->link_config.flowctrl = TG3_FLOW_CTRL_TX | TG3_FLOW_CTRL_RX; | ||
12634 | 12637 | ||
12635 | tg3_init_coal(tp); | 12638 | tg3_init_coal(tp); |
12636 | 12639 | ||
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index da18fb220712..ac47c176fc03 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -2103,13 +2103,18 @@ struct tg3_link_config { | |||
2103 | u16 speed; | 2103 | u16 speed; |
2104 | u8 duplex; | 2104 | u8 duplex; |
2105 | u8 autoneg; | 2105 | u8 autoneg; |
2106 | u8 flowctrl; | ||
2107 | #define TG3_FLOW_CTRL_TX 0x01 | ||
2108 | #define TG3_FLOW_CTRL_RX 0x02 | ||
2106 | 2109 | ||
2107 | /* Describes what we actually have. */ | 2110 | /* Describes what we actually have. */ |
2108 | u16 active_speed; | 2111 | u8 active_flowctrl; |
2112 | |||
2109 | u8 active_duplex; | 2113 | u8 active_duplex; |
2110 | #define SPEED_INVALID 0xffff | 2114 | #define SPEED_INVALID 0xffff |
2111 | #define DUPLEX_INVALID 0xff | 2115 | #define DUPLEX_INVALID 0xff |
2112 | #define AUTONEG_INVALID 0xff | 2116 | #define AUTONEG_INVALID 0xff |
2117 | u16 active_speed; | ||
2113 | 2118 | ||
2114 | /* When we go in and out of low power mode we need | 2119 | /* When we go in and out of low power mode we need |
2115 | * to swap with this state. | 2120 | * to swap with this state. |
@@ -2337,8 +2342,6 @@ struct tg3 { | |||
2337 | #define TG3_FLAG_EEPROM_WRITE_PROT 0x00001000 | 2342 | #define TG3_FLAG_EEPROM_WRITE_PROT 0x00001000 |
2338 | #define TG3_FLAG_NVRAM 0x00002000 | 2343 | #define TG3_FLAG_NVRAM 0x00002000 |
2339 | #define TG3_FLAG_NVRAM_BUFFERED 0x00004000 | 2344 | #define TG3_FLAG_NVRAM_BUFFERED 0x00004000 |
2340 | #define TG3_FLAG_RX_PAUSE 0x00008000 | ||
2341 | #define TG3_FLAG_TX_PAUSE 0x00010000 | ||
2342 | #define TG3_FLAG_PCIX_MODE 0x00020000 | 2345 | #define TG3_FLAG_PCIX_MODE 0x00020000 |
2343 | #define TG3_FLAG_PCI_HIGH_SPEED 0x00040000 | 2346 | #define TG3_FLAG_PCI_HIGH_SPEED 0x00040000 |
2344 | #define TG3_FLAG_PCI_32BIT 0x00080000 | 2347 | #define TG3_FLAG_PCI_32BIT 0x00080000 |