@@ -451,7 +451,7 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
451451
452452 i = rx_ring -> next_to_use ;
453453 rx_swbd = & rx_ring -> rx_swbd [i ];
454- rxbd = ENETC_RXBD ( * rx_ring , i );
454+ rxbd = enetc_rxbd ( rx_ring , i );
455455
456456 for (j = 0 ; j < buff_cnt ; j ++ ) {
457457 /* try reuse page */
@@ -468,13 +468,12 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
468468 /* clear 'R" as well */
469469 rxbd -> r .lstatus = 0 ;
470470
471+ rxbd = enetc_rxbd_next (rx_ring , rxbd , i );
471472 rx_swbd ++ ;
472- rxbd ++ ;
473473 i ++ ;
474474 if (unlikely (i == rx_ring -> bd_count )) {
475475 i = 0 ;
476476 rx_swbd = rx_ring -> rx_swbd ;
477- rxbd = ENETC_RXBD (* rx_ring , 0 );
478477 }
479478 }
480479
@@ -488,7 +487,7 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
488487 return j ;
489488}
490489
491- #ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
490+ #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
492491static void enetc_get_rx_tstamp (struct net_device * ndev ,
493492 union enetc_rx_bd * rxbd ,
494493 struct sk_buff * skb )
@@ -502,7 +501,8 @@ static void enetc_get_rx_tstamp(struct net_device *ndev,
502501 if (le16_to_cpu (rxbd -> r .flags ) & ENETC_RXBD_FLAG_TSTMP ) {
503502 lo = enetc_rd (hw , ENETC_SICTR0 );
504503 hi = enetc_rd (hw , ENETC_SICTR1 );
505- tstamp_lo = le32_to_cpu (rxbd -> r .tstamp );
504+ rxbd = enetc_rxbd_ext (rxbd );
505+ tstamp_lo = le32_to_cpu (rxbd -> ext .tstamp );
506506 if (lo <= tstamp_lo )
507507 hi -= 1 ;
508508
@@ -516,7 +516,7 @@ static void enetc_get_rx_tstamp(struct net_device *ndev,
516516static void enetc_get_offloads (struct enetc_bdr * rx_ring ,
517517 union enetc_rx_bd * rxbd , struct sk_buff * skb )
518518{
519- #ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
519+ #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
520520 struct enetc_ndev_priv * priv = netdev_priv (rx_ring -> ndev );
521521#endif
522522 /* TODO: hashing */
@@ -533,7 +533,7 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring,
533533 if (le16_to_cpu (rxbd -> r .flags ) & ENETC_RXBD_FLAG_VLAN )
534534 __vlan_hwaccel_put_tag (skb , htons (ETH_P_8021Q ),
535535 le16_to_cpu (rxbd -> r .vlan_opt ));
536- #ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
536+ #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
537537 if (priv -> active_offloads & ENETC_F_RX_TSTAMP )
538538 enetc_get_rx_tstamp (rx_ring -> ndev , rxbd , skb );
539539#endif
@@ -655,7 +655,7 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
655655 cleaned_cnt -= count ;
656656 }
657657
658- rxbd = ENETC_RXBD ( * rx_ring , i );
658+ rxbd = enetc_rxbd ( rx_ring , i );
659659 bd_status = le32_to_cpu (rxbd -> r .lstatus );
660660 if (!bd_status )
661661 break ;
@@ -670,25 +670,21 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
670670 enetc_get_offloads (rx_ring , rxbd , skb );
671671
672672 cleaned_cnt ++ ;
673- rxbd ++ ;
674- i ++ ;
675- if (unlikely (i == rx_ring -> bd_count )) {
673+
674+ rxbd = enetc_rxbd_next ( rx_ring , rxbd , i ) ;
675+ if (unlikely (++ i == rx_ring -> bd_count ))
676676 i = 0 ;
677- rxbd = ENETC_RXBD (* rx_ring , 0 );
678- }
679677
680678 if (unlikely (bd_status &
681679 ENETC_RXBD_LSTATUS (ENETC_RXBD_ERR_MASK ))) {
682680 dev_kfree_skb (skb );
683681 while (!(bd_status & ENETC_RXBD_LSTATUS_F )) {
684682 dma_rmb ();
685683 bd_status = le32_to_cpu (rxbd -> r .lstatus );
686- rxbd ++ ;
687- i ++ ;
688- if (unlikely (i == rx_ring -> bd_count )) {
684+
685+ rxbd = enetc_rxbd_next ( rx_ring , rxbd , i ) ;
686+ if (unlikely (++ i == rx_ring -> bd_count ))
689687 i = 0 ;
690- rxbd = ENETC_RXBD (* rx_ring , 0 );
691- }
692688 }
693689
694690 rx_ring -> ndev -> stats .rx_dropped ++ ;
@@ -710,12 +706,10 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
710706 enetc_add_rx_buff_to_skb (rx_ring , i , size , skb );
711707
712708 cleaned_cnt ++ ;
713- rxbd ++ ;
714- i ++ ;
715- if (unlikely (i == rx_ring -> bd_count )) {
709+
710+ rxbd = enetc_rxbd_next ( rx_ring , rxbd , i ) ;
711+ if (unlikely (++ i == rx_ring -> bd_count ))
716712 i = 0 ;
717- rxbd = ENETC_RXBD (* rx_ring , 0 );
718- }
719713 }
720714
721715 rx_byte_cnt += skb -> len ;
@@ -845,15 +839,19 @@ static void enetc_free_tx_resources(struct enetc_ndev_priv *priv)
845839 enetc_free_txbdr (priv -> tx_ring [i ]);
846840}
847841
848- static int enetc_alloc_rxbdr (struct enetc_bdr * rxr )
842+ static int enetc_alloc_rxbdr (struct enetc_bdr * rxr , bool extended )
849843{
844+ size_t size = sizeof (union enetc_rx_bd );
850845 int err ;
851846
852847 rxr -> rx_swbd = vzalloc (rxr -> bd_count * sizeof (struct enetc_rx_swbd ));
853848 if (!rxr -> rx_swbd )
854849 return - ENOMEM ;
855850
856- err = enetc_dma_alloc_bdr (rxr , sizeof (union enetc_rx_bd ));
851+ if (extended )
852+ size *= 2 ;
853+
854+ err = enetc_dma_alloc_bdr (rxr , size );
857855 if (err ) {
858856 vfree (rxr -> rx_swbd );
859857 return err ;
@@ -862,6 +860,7 @@ static int enetc_alloc_rxbdr(struct enetc_bdr *rxr)
862860 rxr -> next_to_clean = 0 ;
863861 rxr -> next_to_use = 0 ;
864862 rxr -> next_to_alloc = 0 ;
863+ rxr -> ext_en = extended ;
865864
866865 return 0 ;
867866}
@@ -881,10 +880,11 @@ static void enetc_free_rxbdr(struct enetc_bdr *rxr)
881880
882881static int enetc_alloc_rx_resources (struct enetc_ndev_priv * priv )
883882{
883+ bool extended = !!(priv -> active_offloads & ENETC_F_RX_TSTAMP );
884884 int i , err ;
885885
886886 for (i = 0 ; i < priv -> num_rx_rings ; i ++ ) {
887- err = enetc_alloc_rxbdr (priv -> rx_ring [i ]);
887+ err = enetc_alloc_rxbdr (priv -> rx_ring [i ], extended );
888888
889889 if (err )
890890 goto fail ;
@@ -1174,9 +1174,10 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
11741174 enetc_rxbdr_wr (hw , idx , ENETC_RBICIR0 , ENETC_RBICIR0_ICEN | 0x1 );
11751175
11761176 rbmr = ENETC_RBMR_EN ;
1177- #ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
1178- rbmr |= ENETC_RBMR_BDS ;
1179- #endif
1177+
1178+ if (rx_ring -> ext_en )
1179+ rbmr |= ENETC_RBMR_BDS ;
1180+
11801181 if (rx_ring -> ndev -> features & NETIF_F_HW_VLAN_CTAG_RX )
11811182 rbmr |= ENETC_RBMR_VTE ;
11821183
@@ -1577,11 +1578,12 @@ int enetc_set_features(struct net_device *ndev,
15771578 return 0 ;
15781579}
15791580
1580- #ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
1581+ #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
15811582static int enetc_hwtstamp_set (struct net_device * ndev , struct ifreq * ifr )
15821583{
15831584 struct enetc_ndev_priv * priv = netdev_priv (ndev );
15841585 struct hwtstamp_config config ;
1586+ int ao ;
15851587
15861588 if (copy_from_user (& config , ifr -> ifr_data , sizeof (config )))
15871589 return - EFAULT ;
@@ -1597,6 +1599,7 @@ static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
15971599 return - ERANGE ;
15981600 }
15991601
1602+ ao = priv -> active_offloads ;
16001603 switch (config .rx_filter ) {
16011604 case HWTSTAMP_FILTER_NONE :
16021605 priv -> active_offloads &= ~ENETC_F_RX_TSTAMP ;
@@ -1606,6 +1609,11 @@ static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
16061609 config .rx_filter = HWTSTAMP_FILTER_ALL ;
16071610 }
16081611
1612+ if (netif_running (ndev ) && ao != priv -> active_offloads ) {
1613+ enetc_close (ndev );
1614+ enetc_open (ndev );
1615+ }
1616+
16091617 return copy_to_user (ifr -> ifr_data , & config , sizeof (config )) ?
16101618 - EFAULT : 0 ;
16111619}
@@ -1632,7 +1640,7 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
16321640
16331641int enetc_ioctl (struct net_device * ndev , struct ifreq * rq , int cmd )
16341642{
1635- #ifdef CONFIG_FSL_ENETC_HW_TIMESTAMPING
1643+ #ifdef CONFIG_FSL_ENETC_PTP_CLOCK
16361644 if (cmd == SIOCSHWTSTAMP )
16371645 return enetc_hwtstamp_set (ndev , rq );
16381646 if (cmd == SIOCGHWTSTAMP )
0 commit comments