@@ -583,18 +583,10 @@ int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
583
583
584
584
if (ocelot -> ptp && shinfo -> tx_flags & SKBTX_HW_TSTAMP &&
585
585
ocelot_port -> ptp_cmd == IFH_REW_OP_TWO_STEP_PTP ) {
586
- struct ocelot_skb * oskb =
587
- kzalloc (sizeof (struct ocelot_skb ), GFP_ATOMIC );
588
-
589
- if (unlikely (!oskb ))
590
- return - ENOMEM ;
591
-
592
586
shinfo -> tx_flags |= SKBTX_IN_PROGRESS ;
593
-
594
- oskb -> skb = skb ;
595
- oskb -> id = ocelot_port -> ts_id % 4 ;
596
-
597
- list_add_tail (& oskb -> head , & ocelot_port -> skbs );
587
+ /* Store timestamp ID in cb[0] of sk_buff */
588
+ skb -> cb [0 ] = ocelot_port -> ts_id % 4 ;
589
+ skb_queue_tail (& ocelot_port -> tx_skbs , skb );
598
590
return 0 ;
599
591
}
600
592
return - ENODATA ;
@@ -704,12 +696,11 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
704
696
int budget = OCELOT_PTP_QUEUE_SZ ;
705
697
706
698
while (budget -- ) {
699
+ struct sk_buff * skb , * skb_tmp , * skb_match = NULL ;
707
700
struct skb_shared_hwtstamps shhwtstamps ;
708
- struct list_head * pos , * tmp ;
709
- struct sk_buff * skb = NULL ;
710
- struct ocelot_skb * entry ;
711
701
struct ocelot_port * port ;
712
702
struct timespec64 ts ;
703
+ unsigned long flags ;
713
704
u32 val , id , txport ;
714
705
715
706
val = ocelot_read (ocelot , SYS_PTP_STATUS );
@@ -727,22 +718,22 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
727
718
/* Retrieve its associated skb */
728
719
port = ocelot -> ports [txport ];
729
720
730
- list_for_each_safe (pos , tmp , & port -> skbs ) {
731
- entry = list_entry (pos , struct ocelot_skb , head );
732
- if (entry -> id != id )
733
- continue ;
721
+ spin_lock_irqsave (& port -> tx_skbs .lock , flags );
734
722
735
- skb = entry -> skb ;
736
-
737
- list_del (pos );
738
- kfree (entry );
723
+ skb_queue_walk_safe (& port -> tx_skbs , skb , skb_tmp ) {
724
+ if (skb -> cb [0 ] != id )
725
+ continue ;
726
+ __skb_unlink (skb , & port -> tx_skbs );
727
+ skb_match = skb ;
739
728
break ;
740
729
}
741
730
731
+ spin_unlock_irqrestore (& port -> tx_skbs .lock , flags );
732
+
742
733
/* Next ts */
743
734
ocelot_write (ocelot , SYS_PTP_NXT_PTP_NXT , SYS_PTP_NXT );
744
735
745
- if (unlikely (!skb ))
736
+ if (unlikely (!skb_match ))
746
737
continue ;
747
738
748
739
/* Get the h/w timestamp */
@@ -751,9 +742,9 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
751
742
/* Set the timestamp into the skb */
752
743
memset (& shhwtstamps , 0 , sizeof (shhwtstamps ));
753
744
shhwtstamps .hwtstamp = ktime_set (ts .tv_sec , ts .tv_nsec );
754
- skb_tstamp_tx (skb , & shhwtstamps );
745
+ skb_tstamp_tx (skb_match , & shhwtstamps );
755
746
756
- dev_kfree_skb_any (skb );
747
+ dev_kfree_skb_any (skb_match );
757
748
}
758
749
}
759
750
EXPORT_SYMBOL (ocelot_get_txtstamp );
@@ -2206,7 +2197,7 @@ void ocelot_init_port(struct ocelot *ocelot, int port)
2206
2197
{
2207
2198
struct ocelot_port * ocelot_port = ocelot -> ports [port ];
2208
2199
2209
- INIT_LIST_HEAD (& ocelot_port -> skbs );
2200
+ skb_queue_head_init (& ocelot_port -> tx_skbs );
2210
2201
2211
2202
/* Basic L2 initialization */
2212
2203
@@ -2491,9 +2482,7 @@ EXPORT_SYMBOL(ocelot_init);
2491
2482
2492
2483
void ocelot_deinit (struct ocelot * ocelot )
2493
2484
{
2494
- struct list_head * pos , * tmp ;
2495
2485
struct ocelot_port * port ;
2496
- struct ocelot_skb * entry ;
2497
2486
int i ;
2498
2487
2499
2488
cancel_delayed_work (& ocelot -> stats_work );
@@ -2503,14 +2492,7 @@ void ocelot_deinit(struct ocelot *ocelot)
2503
2492
2504
2493
for (i = 0 ; i < ocelot -> num_phys_ports ; i ++ ) {
2505
2494
port = ocelot -> ports [i ];
2506
-
2507
- list_for_each_safe (pos , tmp , & port -> skbs ) {
2508
- entry = list_entry (pos , struct ocelot_skb , head );
2509
-
2510
- list_del (pos );
2511
- dev_kfree_skb_any (entry -> skb );
2512
- kfree (entry );
2513
- }
2495
+ skb_queue_purge (& port -> tx_skbs );
2514
2496
}
2515
2497
}
2516
2498
EXPORT_SYMBOL (ocelot_deinit );
0 commit comments