cxgb3 - MAC watchdog update

2007-06-20 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2090dee420911045258d50239dc2c527e4b1dd06
Commit: 2090dee420911045258d50239dc2c527e4b1dd06
Parent: 7b581a0fa85464f7f765b9a66f612e7ec4ab17f9
Author: Divy Le Ray [EMAIL PROTECTED]
AuthorDate: Wed May 30 10:01:50 2007 -0700
Committer:  Jeff Garzik [EMAIL PROTECTED]
CommitDate: Wed Jun 20 19:16:59 2007 -0400

cxgb3 - MAC watchdog update

Fix variables initialization and usage in the MAC watchdog.

Signed-off-by: Divy Le Ray [EMAIL PROTECTED]
Signed-off-by: Jeff Garzik [EMAIL PROTECTED]
---
 drivers/net/cxgb3/xgmac.c |   31 +--
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c
index 16cadba..b261be1 100644
--- a/drivers/net/cxgb3/xgmac.c
+++ b/drivers/net/cxgb3/xgmac.c
@@ -501,6 +501,10 @@ int t3b2_mac_watchdog_task(struct cmac *mac)
unsigned int rx_xcnt;
int status;
 
+   status = 0;
+   tx_xcnt = 1;/* By default tx_xcnt is making progress */
+   tx_tcnt = mac-tx_tcnt; /* If tx_mcnt is progressing ignore tx_tcnt */
+   rx_xcnt = 1;/* By default rx_xcnt is making progress */
if (tx_mcnt == mac-tx_mcnt) {
tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
A_XGM_TX_SPI4_SOP_EOP_CNT +
@@ -511,37 +515,44 @@ int t3b2_mac_watchdog_task(struct cmac *mac)
tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap,
  A_TP_PIO_DATA)));
} else {
-   mac-toggle_cnt = 0;
-   return 0;
+   goto rxcheck;
}
} else {
mac-toggle_cnt = 0;
-   return 0;
+   goto rxcheck;
}
 
if (((tx_tcnt != mac-tx_tcnt) 
 (tx_xcnt == 0)  (mac-tx_xcnt == 0)) ||
((mac-tx_mcnt == tx_mcnt) 
 (tx_xcnt != 0)  (mac-tx_xcnt != 0))) {
-   if (mac-toggle_cnt  4)
+   if (mac-toggle_cnt  4) {
status = 2;
-   else 
+   goto out;
+   } else {
status = 1;
+   goto out;
+   }
} else {
mac-toggle_cnt = 0;
-   return 0;
+   goto rxcheck;
}
 
+rxcheck:
if (rx_mcnt != mac-rx_mcnt)
rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
A_XGM_RX_SPI4_SOP_EOP_CNT +
mac-offset)));
-   else 
-   return 0;
+   else
+   goto out;
 
-   if (mac-rx_mcnt != s-rx_frames  rx_xcnt == 0  mac-rx_xcnt == 0) 
+   if (mac-rx_mcnt != s-rx_frames  rx_xcnt == 0 
+   mac-rx_xcnt == 0) {
status = 2;
-   
+   goto out;
+   }
+
+out:
mac-tx_tcnt = tx_tcnt;
mac-tx_xcnt = tx_xcnt;
mac-tx_mcnt = s-tx_frames;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cxgb3 - MAC watchdog update

2007-04-11 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=59cf81076a85e1df273155298c462574b49cc0fe
Commit: 59cf81076a85e1df273155298c462574b49cc0fe
Parent: f2d961c9827bab4b64a1b4ea30c68cf5ab2b2330
Author: Divy Le Ray [EMAIL PROTECTED]
AuthorDate: Mon Apr 9 20:10:27 2007 -0700
Committer:  Jeff Garzik [EMAIL PROTECTED]
CommitDate: Wed Apr 11 11:54:43 2007 -0400

cxgb3 - MAC watchdog update

The MAC watchdog was failing if the peer interface was brought down.

Signed-off-by: Divy Le Ray [EMAIL PROTECTED]
Signed-off-by: Jeff Garzik [EMAIL PROTECTED]
---
 drivers/net/cxgb3/common.h |7 ++-
 drivers/net/cxgb3/cxgb3_main.c |   10 ++--
 drivers/net/cxgb3/xgmac.c  |  107 ++--
 3 files changed, 89 insertions(+), 35 deletions(-)

diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 97128d8..8d13796 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -478,8 +478,11 @@ struct cmac {
struct adapter *adapter;
unsigned int offset;
unsigned int nucast;/* # of address filters for unicast MACs */
-   unsigned int tcnt;
-   unsigned int xcnt;
+   unsigned int tx_tcnt;
+   unsigned int tx_xcnt;
+   u64 tx_mcnt;
+   unsigned int rx_xcnt;
+   u64 rx_mcnt;
unsigned int toggle_cnt;
unsigned int txen;
struct mac_stats stats;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index c6ebe25..d6eb982 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -194,15 +194,13 @@ void t3_os_link_changed(struct adapter *adapter, int 
port_id, int link_stat,
 
if (link_stat != netif_carrier_ok(dev)) {
if (link_stat) {
-   t3_set_reg_field(adapter,
-A_XGM_TXFIFO_CFG + mac-offset,
-F_ENDROPPKT, 0);
+   t3_mac_enable(mac, MAC_DIRECTION_RX);
netif_carrier_on(dev);
} else {
netif_carrier_off(dev);
-   t3_set_reg_field(adapter,
-A_XGM_TXFIFO_CFG + mac-offset,
-F_ENDROPPKT, F_ENDROPPKT);
+   pi-phy.ops-power_down(pi-phy, 1);
+   t3_mac_disable(mac, MAC_DIRECTION_RX);
+   t3_link_start(pi-phy, mac, pi-link_config);
}
 
link_report(dev);
diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c
index 94aaff0..a506792 100644
--- a/drivers/net/cxgb3/xgmac.c
+++ b/drivers/net/cxgb3/xgmac.c
@@ -367,7 +367,8 @@ int t3_mac_enable(struct cmac *mac, int which)
int idx = macidx(mac);
struct adapter *adap = mac-adapter;
unsigned int oft = mac-offset;
-
+   struct mac_stats *s = mac-stats;
+   
if (which  MAC_DIRECTION_TX) {
t3_write_reg(adap, A_XGM_TX_CTRL + oft, F_TXEN);
t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CFG_CH0 + idx);
@@ -376,10 +377,16 @@ int t3_mac_enable(struct cmac *mac, int which)
t3_set_reg_field(adap, A_TP_PIO_DATA, 1  idx, 1  idx);
 
t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CNT_CH0 + idx);
-   mac-tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap,
-   A_TP_PIO_DATA)));
-   mac-xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
-   A_XGM_TX_SPI4_SOP_EOP_CNT)));
+   mac-tx_mcnt = s-tx_frames;
+   mac-tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap,
+   A_TP_PIO_DATA)));
+   mac-tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
+   A_XGM_TX_SPI4_SOP_EOP_CNT +
+   oft)));
+   mac-rx_mcnt = s-rx_frames;
+   mac-rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
+   A_XGM_RX_SPI4_SOP_EOP_CNT +
+   oft)));
mac-txen = F_TXEN;
mac-toggle_cnt = 0;
}
@@ -392,6 +399,7 @@ int t3_mac_disable(struct cmac *mac, int which)
 {
int idx = macidx(mac);
struct adapter *adap = mac-adapter;
+   int val;
 
if (which  MAC_DIRECTION_TX) {
t3_write_reg(adap, A_XGM_TX_CTRL + mac-offset, 0);
@@ -401,44 +409,89 @@ int t3_mac_disable(struct cmac *mac, int which)
t3_set_reg_field(adap, A_TP_PIO_DATA, 1  idx, 1  idx);
mac-txen = 0;
}
-   if (which  MAC_DIRECTION_RX)
+   if (which  MAC_DIRECTION_RX) {
+   t3_set_reg_field(mac-adapter, A_XGM_RESET_CTRL