rb532: add 4.14 support
[oweals/openwrt.git] / target / linux / rb532 / patches-4.14 / 107-korina-refactor-rx-descriptor-flags-processing.patch
1 --- a/drivers/net/ethernet/korina.c
2 +++ b/drivers/net/ethernet/korina.c
3 @@ -363,59 +363,60 @@ static int korina_rx(struct net_device *
4                 if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0)
5                         break;
6  
7 -               /* Update statistics counters */
8 -               if (devcs & ETH_RX_CRC)
9 -                       dev->stats.rx_crc_errors++;
10 -               if (devcs & ETH_RX_LOR)
11 -                       dev->stats.rx_length_errors++;
12 -               if (devcs & ETH_RX_LE)
13 -                       dev->stats.rx_length_errors++;
14 -               if (devcs & ETH_RX_OVR)
15 -                       dev->stats.rx_fifo_errors++;
16 -               if (devcs & ETH_RX_CV)
17 -                       dev->stats.rx_frame_errors++;
18 -               if (devcs & ETH_RX_CES)
19 -                       dev->stats.rx_length_errors++;
20 -               if (devcs & ETH_RX_MP)
21 -                       dev->stats.multicast++;
22 +               /* check that this is a whole packet
23 +                * WARNING: DMA_FD bit incorrectly set
24 +                * in Rc32434 (errata ref #077) */
25 +               if (!(devcs & ETH_RX_LD))
26 +                       goto next;
27  
28 -               if ((devcs & ETH_RX_LD) != ETH_RX_LD) {
29 -                       /* check that this is a whole packet
30 -                        * WARNING: DMA_FD bit incorrectly set
31 -                        * in Rc32434 (errata ref #077) */
32 +               if (!(devcs & ETH_RX_ROK)) {
33 +                       /* Update statistics counters */
34                         dev->stats.rx_errors++;
35                         dev->stats.rx_dropped++;
36 -               } else if ((devcs & ETH_RX_ROK)) {
37 -                       pkt_len = RCVPKT_LENGTH(devcs);
38 +                       if (devcs & ETH_RX_CRC)
39 +                               dev->stats.rx_crc_errors++;
40 +                       if (devcs & ETH_RX_LE)
41 +                               dev->stats.rx_length_errors++;
42 +                       if (devcs & ETH_RX_OVR)
43 +                               dev->stats.rx_fifo_errors++;
44 +                       if (devcs & ETH_RX_CV)
45 +                               dev->stats.rx_frame_errors++;
46 +                       if (devcs & ETH_RX_CES)
47 +                               dev->stats.rx_frame_errors++;
48  
49 -                       /* must be the (first and) last
50 -                        * descriptor then */
51 -                       pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
52 -
53 -                       /* invalidate the cache */
54 -                       dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
55 -
56 -                       /* Malloc up new buffer. */
57 -                       skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
58 -
59 -                       if (!skb_new)
60 -                               break;
61 -                       /* Do not count the CRC */
62 -                       skb_put(skb, pkt_len - 4);
63 -                       skb->protocol = eth_type_trans(skb, dev);
64 -
65 -                       /* Pass the packet to upper layers */
66 -                       netif_receive_skb(skb);
67 -                       dev->stats.rx_packets++;
68 -                       dev->stats.rx_bytes += pkt_len;
69 -
70 -                       /* Update the mcast stats */
71 -                       if (devcs & ETH_RX_MP)
72 -                               dev->stats.multicast++;
73 -
74 -                       lp->rx_skb[lp->rx_next_done] = skb_new;
75 +                       goto next;
76                 }
77  
78 +               pkt_len = RCVPKT_LENGTH(devcs);
79 +
80 +               /* must be the (first and) last
81 +                * descriptor then */
82 +               pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
83 +
84 +               /* invalidate the cache */
85 +               dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
86 +
87 +               /* Malloc up new buffer. */
88 +               skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
89 +
90 +               if (!skb_new)
91 +                       break;
92 +               /* Do not count the CRC */
93 +               skb_put(skb, pkt_len - 4);
94 +               skb->protocol = eth_type_trans(skb, dev);
95 +
96 +               /* Pass the packet to upper layers */
97 +               netif_receive_skb(skb);
98 +               dev->stats.rx_packets++;
99 +               dev->stats.rx_bytes += pkt_len;
100 +
101 +               /* Update the mcast stats */
102 +               if (devcs & ETH_RX_MP)
103 +                       dev->stats.multicast++;
104 +
105 +               lp->rx_skb[lp->rx_next_done] = skb_new;
106 +
107 +next:
108                 rd->devcs = 0;
109  
110                 /* Restore descriptor's curr_addr */