Skip to content

Commit

Permalink
mv643xx_eth: avoid reading ->byte_cnt twice during receive processing
Browse files Browse the repository at this point in the history
Currently, the receive processing reads ->byte_cnt twice (once to
update interface statistics and once to properly size the data area
of the received skb), but since receive descriptors live in uncached
memory, caching this value in a local variable saves one uncached
access, and increases routing performance a tiny little bit more.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
  • Loading branch information
Lennert Buytenhek authored and Lennert Buytenhek committed Sep 14, 2008
1 parent 2b4a624 commit 6b8f90c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/net/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ static int rxq_process(struct rx_queue *rxq, int budget)
struct rx_desc *rx_desc;
unsigned int cmd_sts;
struct sk_buff *skb;
u16 byte_cnt;

rx_desc = &rxq->rx_desc_area[rxq->rx_curr_desc];

Expand All @@ -499,6 +500,8 @@ static int rxq_process(struct rx_queue *rxq, int budget)

mp->work_rx_refill |= 1 << rxq->index;

byte_cnt = rx_desc->byte_cnt;

/*
* Update statistics.
*
Expand All @@ -508,7 +511,7 @@ static int rxq_process(struct rx_queue *rxq, int budget)
* byte CRC at the end of the packet (which we do count).
*/
stats->rx_packets++;
stats->rx_bytes += rx_desc->byte_cnt - 2;
stats->rx_bytes += byte_cnt - 2;

/*
* In case we received a packet without first / last bits
Expand Down Expand Up @@ -537,7 +540,7 @@ static int rxq_process(struct rx_queue *rxq, int budget)
* The -4 is for the CRC in the trailer of the
* received packet
*/
skb_put(skb, rx_desc->byte_cnt - 2 - 4);
skb_put(skb, byte_cnt - 2 - 4);

if (cmd_sts & LAYER_4_CHECKSUM_OK) {
skb->ip_summed = CHECKSUM_UNNECESSARY;
Expand Down

0 comments on commit 6b8f90c

Please sign in to comment.