From bcb9ef4fe6a81398ce6a6e1c0e2f43ff055b4279 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Sun, 30 Jun 2002 22:05:46 +0000 Subject: [PATCH] Fix if_timer logic to make sure that there is always a timeout pending if there are packets queued for transmission. MFC after: 3 days --- sys/dev/dc/if_dc.c | 12 ++++++------ sys/pci/if_dc.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 189835c9616..7c553469de4 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2593,9 +2593,6 @@ static void dc_txeof(sc) ifp = &sc->arpcom.ac_if; - /* Clear the timeout timer. */ - ifp->if_timer = 0; - /* * Go through our tx list and free mbufs for those * frames that have been transmitted. @@ -2612,7 +2609,6 @@ static void dc_txeof(sc) if (!(cur_tx->dc_ctl & DC_TXCTL_LASTFRAG) || cur_tx->dc_ctl & DC_TXCTL_SETUP) { - sc->dc_cdata.dc_tx_cnt--; if (cur_tx->dc_ctl & DC_TXCTL_SETUP) { /* * Yes, the PNIC is so brain damaged @@ -2629,6 +2625,7 @@ static void dc_txeof(sc) } sc->dc_cdata.dc_tx_chain[idx] = NULL; } + sc->dc_cdata.dc_tx_cnt--; DC_INC(idx, DC_TX_LIST_CNT); continue; } @@ -2679,9 +2676,12 @@ static void dc_txeof(sc) DC_INC(idx, DC_TX_LIST_CNT); } - sc->dc_cdata.dc_tx_cons = idx; - if (cur_tx != NULL) + if (idx != sc->dc_cdata.dc_tx_cons) { + /* some buffers have been freed */ + sc->dc_cdata.dc_tx_cons = idx; ifp->if_flags &= ~IFF_OACTIVE; + } + ifp->if_timer = (sc->dc_cdata.dc_tx_cnt == 0) ? 0 : 5; return; } diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c index 189835c9616..7c553469de4 100644 --- a/sys/pci/if_dc.c +++ b/sys/pci/if_dc.c @@ -2593,9 +2593,6 @@ static void dc_txeof(sc) ifp = &sc->arpcom.ac_if; - /* Clear the timeout timer. */ - ifp->if_timer = 0; - /* * Go through our tx list and free mbufs for those * frames that have been transmitted. @@ -2612,7 +2609,6 @@ static void dc_txeof(sc) if (!(cur_tx->dc_ctl & DC_TXCTL_LASTFRAG) || cur_tx->dc_ctl & DC_TXCTL_SETUP) { - sc->dc_cdata.dc_tx_cnt--; if (cur_tx->dc_ctl & DC_TXCTL_SETUP) { /* * Yes, the PNIC is so brain damaged @@ -2629,6 +2625,7 @@ static void dc_txeof(sc) } sc->dc_cdata.dc_tx_chain[idx] = NULL; } + sc->dc_cdata.dc_tx_cnt--; DC_INC(idx, DC_TX_LIST_CNT); continue; } @@ -2679,9 +2676,12 @@ static void dc_txeof(sc) DC_INC(idx, DC_TX_LIST_CNT); } - sc->dc_cdata.dc_tx_cons = idx; - if (cur_tx != NULL) + if (idx != sc->dc_cdata.dc_tx_cons) { + /* some buffers have been freed */ + sc->dc_cdata.dc_tx_cons = idx; ifp->if_flags &= ~IFF_OACTIVE; + } + ifp->if_timer = (sc->dc_cdata.dc_tx_cnt == 0) ? 0 : 5; return; }