Skip to content

Commit 364a97f

Browse files
Roman Yeryomindavem330
authored andcommitted
net: korina: optimize rx descriptor flags processing
Signed-off-by: Roman Yeryomin <roman@advem.lv> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7ce103b commit 364a97f

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed

drivers/net/ethernet/korina.c

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -363,59 +363,60 @@ static int korina_rx(struct net_device *dev, int limit)
363363
if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0)
364364
break;
365365

366-
/* Update statistics counters */
367-
if (devcs & ETH_RX_CRC)
368-
dev->stats.rx_crc_errors++;
369-
if (devcs & ETH_RX_LOR)
370-
dev->stats.rx_length_errors++;
371-
if (devcs & ETH_RX_LE)
372-
dev->stats.rx_length_errors++;
373-
if (devcs & ETH_RX_OVR)
374-
dev->stats.rx_fifo_errors++;
375-
if (devcs & ETH_RX_CV)
376-
dev->stats.rx_frame_errors++;
377-
if (devcs & ETH_RX_CES)
378-
dev->stats.rx_length_errors++;
379-
if (devcs & ETH_RX_MP)
380-
dev->stats.multicast++;
381-
382-
if ((devcs & ETH_RX_LD) != ETH_RX_LD) {
383-
/* check that this is a whole packet
384-
* WARNING: DMA_FD bit incorrectly set
385-
* in Rc32434 (errata ref #077) */
366+
/* check that this is a whole packet
367+
* WARNING: DMA_FD bit incorrectly set
368+
* in Rc32434 (errata ref #077) */
369+
if (!(devcs & ETH_RX_LD))
370+
goto next;
371+
372+
if (!(devcs & ETH_RX_ROK)) {
373+
/* Update statistics counters */
386374
dev->stats.rx_errors++;
387375
dev->stats.rx_dropped++;
388-
} else if ((devcs & ETH_RX_ROK)) {
389-
pkt_len = RCVPKT_LENGTH(devcs);
376+
if (devcs & ETH_RX_CRC)
377+
dev->stats.rx_crc_errors++;
378+
if (devcs & ETH_RX_LE)
379+
dev->stats.rx_length_errors++;
380+
if (devcs & ETH_RX_OVR)
381+
dev->stats.rx_fifo_errors++;
382+
if (devcs & ETH_RX_CV)
383+
dev->stats.rx_frame_errors++;
384+
if (devcs & ETH_RX_CES)
385+
dev->stats.rx_frame_errors++;
386+
387+
goto next;
388+
}
390389

391-
/* must be the (first and) last
392-
* descriptor then */
393-
pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
390+
pkt_len = RCVPKT_LENGTH(devcs);
394391

395-
/* invalidate the cache */
396-
dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
392+
/* must be the (first and) last
393+
* descriptor then */
394+
pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
397395

398-
/* Malloc up new buffer. */
399-
skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
396+
/* invalidate the cache */
397+
dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
400398

401-
if (!skb_new)
402-
break;
403-
/* Do not count the CRC */
404-
skb_put(skb, pkt_len - 4);
405-
skb->protocol = eth_type_trans(skb, dev);
399+
/* Malloc up new buffer. */
400+
skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
406401

407-
/* Pass the packet to upper layers */
408-
netif_receive_skb(skb);
409-
dev->stats.rx_packets++;
410-
dev->stats.rx_bytes += pkt_len;
402+
if (!skb_new)
403+
break;
404+
/* Do not count the CRC */
405+
skb_put(skb, pkt_len - 4);
406+
skb->protocol = eth_type_trans(skb, dev);
411407

412-
/* Update the mcast stats */
413-
if (devcs & ETH_RX_MP)
414-
dev->stats.multicast++;
408+
/* Pass the packet to upper layers */
409+
netif_receive_skb(skb);
410+
dev->stats.rx_packets++;
411+
dev->stats.rx_bytes += pkt_len;
415412

416-
lp->rx_skb[lp->rx_next_done] = skb_new;
417-
}
413+
/* Update the mcast stats */
414+
if (devcs & ETH_RX_MP)
415+
dev->stats.multicast++;
416+
417+
lp->rx_skb[lp->rx_next_done] = skb_new;
418418

419+
next:
419420
rd->devcs = 0;
420421

421422
/* Restore descriptor's curr_addr */

0 commit comments

Comments
 (0)