net: bcmgenet: simplify __bcmgenet_tx_reclaim()
authorPetri Gynther <pgynther@google.com>
Wed, 4 Mar 2015 22:30:01 +0000 (14:30 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Mar 2015 04:54:54 +0000 (23:54 -0500)
commit66d06757d9eb74a29775737b8c770e3b57e536d9
treef840abd25341fa137e0f48a3562294f6b4f6aa5b
parentf93eb4ba0f6c089252c8358563b5859a4daf40b1
net: bcmgenet: simplify __bcmgenet_tx_reclaim()

1. Use c_index and ring->c_index to determine how many TxCBs/TxBDs are
   ready for cleanup
   - c_index = the current value of TDMA_CONS_INDEX
   - TDMA_CONS_INDEX is HW-incremented and auto-wraparound (0x0-0xFFFF)
   - ring->c_index = __bcmgenet_tx_reclaim() cleaned up to this point on
     the previous invocation

2. Add bcmgenet_tx_ring->clean_ptr
   - index of the next TxCB to be cleaned
   - incremented as TxCBs/TxBDs are processed
   - value always in range [ring->cb_ptr, ring->end_ptr]

3. Fix incrementing of dev->stats.tx_packets
   - should be incremented only when tx_cb_ptr->skb != NULL

These changes simplify __bcmgenet_tx_reclaim(). Furthermore, Tx ring size
can now be any value.

With the old code, Tx ring size had to be a power-of-2:
   num_tx_bds = ring->size;
   c_index &= (num_tx_bds - 1);
   last_c_index &= (num_tx_bds - 1);

Signed-off-by: Petri Gynther <pgynther@google.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/genet/bcmgenet.h
This page took 0.02854 seconds and 5 git commands to generate.