aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 7d824cf8ee2d..f296c37f29b6 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -217,9 +217,16 @@ static inline u32 bnx2_tx_avail(struct bnx2 *bp)
217 u32 diff; 217 u32 diff;
218 218
219 smp_mb(); 219 smp_mb();
220 diff = TX_RING_IDX(bp->tx_prod) - TX_RING_IDX(bp->tx_cons); 220
221 if (diff > MAX_TX_DESC_CNT) 221 /* The ring uses 256 indices for 255 entries, one of them
222 diff = (diff & MAX_TX_DESC_CNT) - 1; 222 * needs to be skipped.
223 */
224 diff = bp->tx_prod - bp->tx_cons;
225 if (unlikely(diff >= TX_DESC_CNT)) {
226 diff &= 0xffff;
227 if (diff == TX_DESC_CNT)
228 diff = MAX_TX_DESC_CNT;
229 }
223 return (bp->tx_ring_size - diff); 230 return (bp->tx_ring_size - diff);
224} 231}
225 232