@@ -477,19 +477,16 @@ static void m_can_receive_skb(struct m_can_classdev *cdev,
477
477
}
478
478
}
479
479
480
- static int m_can_read_fifo (struct net_device * dev , u32 rxfs )
480
+ static int m_can_read_fifo (struct net_device * dev , u32 fgi )
481
481
{
482
482
struct net_device_stats * stats = & dev -> stats ;
483
483
struct m_can_classdev * cdev = netdev_priv (dev );
484
484
struct canfd_frame * cf ;
485
485
struct sk_buff * skb ;
486
486
struct id_and_dlc fifo_header ;
487
- u32 fgi ;
488
487
u32 timestamp = 0 ;
489
488
int err ;
490
489
491
- /* calculate the fifo get index for where to read data */
492
- fgi = FIELD_GET (RXFS_FGI_MASK , rxfs );
493
490
err = m_can_fifo_read (cdev , fgi , M_CAN_FIFO_ID , & fifo_header , 2 );
494
491
if (err )
495
492
goto out_fail ;
@@ -554,6 +551,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
554
551
struct m_can_classdev * cdev = netdev_priv (dev );
555
552
u32 pkts = 0 ;
556
553
u32 rxfs ;
554
+ u32 rx_count ;
555
+ u32 fgi ;
556
+ int i ;
557
557
int err ;
558
558
559
559
rxfs = m_can_read (cdev , M_CAN_RXF0S );
@@ -562,14 +562,17 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
562
562
return 0 ;
563
563
}
564
564
565
- while ((rxfs & RXFS_FFL_MASK ) && (quota > 0 )) {
566
- err = m_can_read_fifo (dev , rxfs );
565
+ rx_count = FIELD_GET (RXFS_FFL_MASK , rxfs );
566
+ fgi = FIELD_GET (RXFS_FGI_MASK , rxfs );
567
+
568
+ for (i = 0 ; i < rx_count && quota > 0 ; ++ i ) {
569
+ err = m_can_read_fifo (dev , fgi );
567
570
if (err )
568
571
return err ;
569
572
570
573
quota -- ;
571
574
pkts ++ ;
572
- rxfs = m_can_read ( cdev , M_CAN_RXF0S );
575
+ fgi = ( ++ fgi >= cdev -> mcfg [ MRAM_RXF0 ]. num ? 0 : fgi );
573
576
}
574
577
575
578
return pkts ;
0 commit comments