@@ -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,21 +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 ;
734
-
735
- skb = entry -> skb ;
721
+ spin_lock_irqsave (& port -> tx_skbs .lock , flags );
736
722
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 ;
728
+ break ;
739
729
}
740
730
731
+ spin_unlock_irqrestore (& port -> tx_skbs .lock , flags );
732
+
741
733
/* Next ts */
742
734
ocelot_write (ocelot , SYS_PTP_NXT_PTP_NXT , SYS_PTP_NXT );
743
735
744
- if (unlikely (!skb ))
736
+ if (unlikely (!skb_match ))
745
737
continue ;
746
738
747
739
/* Get the h/w timestamp */
@@ -750,9 +742,9 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
750
742
/* Set the timestamp into the skb */
751
743
memset (& shhwtstamps , 0 , sizeof (shhwtstamps ));
752
744
shhwtstamps .hwtstamp = ktime_set (ts .tv_sec , ts .tv_nsec );
753
- skb_tstamp_tx (skb , & shhwtstamps );
745
+ skb_tstamp_tx (skb_match , & shhwtstamps );
754
746
755
- dev_kfree_skb_any (skb );
747
+ dev_kfree_skb_any (skb_match );
756
748
}
757
749
}
758
750
EXPORT_SYMBOL (ocelot_get_txtstamp );
@@ -2205,7 +2197,7 @@ void ocelot_init_port(struct ocelot *ocelot, int port)
2205
2197
{
2206
2198
struct ocelot_port * ocelot_port = ocelot -> ports [port ];
2207
2199
2208
- INIT_LIST_HEAD (& ocelot_port -> skbs );
2200
+ skb_queue_head_init (& ocelot_port -> tx_skbs );
2209
2201
2210
2202
/* Basic L2 initialization */
2211
2203
@@ -2490,9 +2482,7 @@ EXPORT_SYMBOL(ocelot_init);
2490
2482
2491
2483
void ocelot_deinit (struct ocelot * ocelot )
2492
2484
{
2493
- struct list_head * pos , * tmp ;
2494
2485
struct ocelot_port * port ;
2495
- struct ocelot_skb * entry ;
2496
2486
int i ;
2497
2487
2498
2488
cancel_delayed_work (& ocelot -> stats_work );
@@ -2502,14 +2492,7 @@ void ocelot_deinit(struct ocelot *ocelot)
2502
2492
2503
2493
for (i = 0 ; i < ocelot -> num_phys_ports ; i ++ ) {
2504
2494
port = ocelot -> ports [i ];
2505
-
2506
- list_for_each_safe (pos , tmp , & port -> skbs ) {
2507
- entry = list_entry (pos , struct ocelot_skb , head );
2508
-
2509
- list_del (pos );
2510
- dev_kfree_skb_any (entry -> skb );
2511
- kfree (entry );
2512
- }
2495
+ skb_queue_purge (& port -> tx_skbs );
2513
2496
}
2514
2497
}
2515
2498
EXPORT_SYMBOL (ocelot_deinit );
0 commit comments