[PATCH 1/8] tg3: Separate requested and actual flow control parameters

2007-12-20 Thread Matt Carlson
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 [EMAIL PROTECTED]
Signed-off-by: Michael Chan [EMAIL PROTECTED]

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 4942f7d..d503214 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -1602,17 +1602,19 @@ static void tg3_link_report(struct tg3 *tp)
   (tp-link_config.active_duplex == DUPLEX_FULL ?
full : half));
 
-   printk(KERN_INFO PFX %s: Flow control is %s for TX and 
-  %s for RX.\n,
+   printk(KERN_INFO PFX
+  %s: Flow control is %s for TX and %s for RX.\n,
   tp-dev-name,
-  (tp-tg3_flags  TG3_FLAG_TX_PAUSE) ? on : off,
-  (tp-tg3_flags  TG3_FLAG_RX_PAUSE) ? on : off);
+  (tp-link_config.active_flowctrl  TG3_FLOW_CTRL_TX) ?
+  on : off,
+  (tp-link_config.active_flowctrl  TG3_FLOW_CTRL_RX) ?
+  on : off);
}
 }
 
 static void tg3_setup_flow_control(struct tg3 *tp, u32 local_adv, u32 
remote_adv)
 {
-   u32 new_tg3_flags = 0;
+   u8 new_tg3_flags = 0;
u32 old_rx_mode = tp-rx_mode;
u32 old_tx_mode = tp-tx_mode;
 
@@ -1639,31 +1641,27 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 
local_adv, u32 remote_adv
if (local_adv  ADVERTISE_PAUSE_CAP) {
if (local_adv  ADVERTISE_PAUSE_ASYM) {
if (remote_adv  LPA_PAUSE_CAP)
-   new_tg3_flags |=
-   (TG3_FLAG_RX_PAUSE |
-   TG3_FLAG_TX_PAUSE);
+   new_tg3_flags = TG3_FLOW_CTRL_RX |
+   TG3_FLOW_CTRL_TX;
else if (remote_adv  LPA_PAUSE_ASYM)
-   new_tg3_flags |=
-   (TG3_FLAG_RX_PAUSE);
+   new_tg3_flags = TG3_FLOW_CTRL_RX;
} else {
if (remote_adv  LPA_PAUSE_CAP)
-   new_tg3_flags |=
-   (TG3_FLAG_RX_PAUSE |
-   TG3_FLAG_TX_PAUSE);
+   new_tg3_flags = TG3_FLOW_CTRL_RX |
+   TG3_FLOW_CTRL_TX;
}
} else if (local_adv  ADVERTISE_PAUSE_ASYM) {
if ((remote_adv  LPA_PAUSE_CAP) 
-   (remote_adv  LPA_PAUSE_ASYM))
-   new_tg3_flags |= TG3_FLAG_TX_PAUSE;
+   (remote_adv  LPA_PAUSE_ASYM))
+   new_tg3_flags = TG3_FLOW_CTRL_TX;
}
-
-   tp-tg3_flags = ~(TG3_FLAG_RX_PAUSE | TG3_FLAG_TX_PAUSE);
-   tp-tg3_flags |= new_tg3_flags;
} else {
-   new_tg3_flags = tp-tg3_flags;
+   new_tg3_flags = tp-link_config.flowctrl;
}
 
-   if (new_tg3_flags  TG3_FLAG_RX_PAUSE)
+   tp-link_config.active_flowctrl = new_tg3_flags;
+
+   if (new_tg3_flags  TG3_FLOW_CTRL_RX)
tp-rx_mode |= RX_MODE_FLOW_CTRL_ENABLE;
else
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
tw32_f(MAC_RX_MODE, tp-rx_mode);
}
 
-   if (new_tg3_flags  TG3_FLAG_TX_PAUSE)
+   if (new_tg3_flags  TG3_FLOW_CTRL_TX)
tp-tx_mode |= TX_MODE_FLOW_CTRL_ENABLE;
else
tp-tx_mode = ~TX_MODE_FLOW_CTRL_ENABLE;
@@ -2812,9 +2810,7 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int 
force_reset)
int current_link_up;
int i;
 
-   orig_pause_cfg =
-   (tp-tg3_flags  (TG3_FLAG_RX_PAUSE |
- TG3_FLAG_TX_PAUSE));
+   orig_pause_cfg = tp-link_config.active_flowctrl;
orig_active_speed = tp-link_config.active_speed;
orig_active_duplex = tp-link_config.active_duplex;
 
@@ -2903,9 +2899,7 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int 
force_reset)
netif_carrier_off(tp-dev);
tg3_link_report(tp);
} else {
-   u32 now_pause_cfg =
-   tp-tg3_flags  (TG3_FLAG_RX_PAUSE |
-TG3_FLAG_TX_PAUSE);
+   u32 now_pause_cfg = tp-link_config.active_flowctrl;
if (orig_pause_cfg != now_pause_cfg ||
orig_active_speed != 

Re: [PATCH 1/8] tg3: Separate requested and actual flow control parameters

2007-12-20 Thread David Miller
From: Matt Carlson [EMAIL PROTECTED]
Date: Thu, 20 Dec 2007 14:59:49 -0800

 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 [EMAIL PROTECTED]
 Signed-off-by: Michael Chan [EMAIL PROTECTED]

Applied.
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html