@@ -322,6 +322,25 @@ static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
322
322
return 0 ;
323
323
}
324
324
325
+ static void efx_ef10_read_licensed_features (struct efx_nic * efx )
326
+ {
327
+ MCDI_DECLARE_BUF (inbuf , MC_CMD_LICENSING_V3_IN_LEN );
328
+ MCDI_DECLARE_BUF (outbuf , MC_CMD_LICENSING_V3_OUT_LEN );
329
+ struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
330
+ size_t outlen ;
331
+ int rc ;
332
+
333
+ MCDI_SET_DWORD (inbuf , LICENSING_V3_IN_OP ,
334
+ MC_CMD_LICENSING_V3_IN_OP_REPORT_LICENSE );
335
+ rc = efx_mcdi_rpc_quiet (efx , MC_CMD_LICENSING_V3 , inbuf , sizeof (inbuf ),
336
+ outbuf , sizeof (outbuf ), & outlen );
337
+ if (rc || (outlen < MC_CMD_LICENSING_V3_OUT_LEN ))
338
+ return ;
339
+
340
+ nic_data -> licensed_features = MCDI_QWORD (outbuf ,
341
+ LICENSING_V3_OUT_LICENSED_FEATURES );
342
+ }
343
+
325
344
static int efx_ef10_get_sysclk_freq (struct efx_nic * efx )
326
345
{
327
346
MCDI_DECLARE_BUF (outbuf , MC_CMD_GET_CLOCK_OUT_LEN );
@@ -722,6 +741,8 @@ static int efx_ef10_probe(struct efx_nic *efx)
722
741
if (rc < 0 )
723
742
goto fail5 ;
724
743
744
+ efx_ef10_read_licensed_features (efx );
745
+
725
746
/* We can have one VI for each vi_stride-byte region.
726
747
* However, until we use TX option descriptors we need two TX queues
727
748
* per channel.
@@ -760,14 +781,7 @@ static int efx_ef10_probe(struct efx_nic *efx)
760
781
if (rc && rc != - EPERM )
761
782
goto fail5 ;
762
783
763
- rc = efx_ptp_probe (efx , NULL );
764
- /* Failure to probe PTP is not fatal.
765
- * In the case of EPERM, efx_ptp_probe will print its own message (in
766
- * efx_ptp_get_attributes()), so we don't need to.
767
- */
768
- if (rc && rc != - EPERM )
769
- netif_warn (efx , drv , efx -> net_dev ,
770
- "Failed to probe PTP, rc=%d\n" , rc );
784
+ efx_ptp_defer_probe_with_channel (efx );
771
785
772
786
#ifdef CONFIG_SFC_SRIOV
773
787
if ((efx -> pci_dev -> physfn ) && (!efx -> pci_dev -> is_physfn )) {
@@ -937,6 +951,11 @@ static int efx_ef10_link_piobufs(struct efx_nic *efx)
937
951
938
952
/* Link a buffer to each TX queue */
939
953
efx_for_each_channel (channel , efx ) {
954
+ /* Extra channels, even those with TXQs (PTP), do not require
955
+ * PIO resources.
956
+ */
957
+ if (!channel -> type -> want_pio )
958
+ continue ;
940
959
efx_for_each_channel_tx_queue (tx_queue , channel ) {
941
960
/* We assign the PIO buffers to queues in
942
961
* reverse order to allow for the following
@@ -1284,7 +1303,9 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)
1284
1303
void __iomem * membase ;
1285
1304
int rc ;
1286
1305
1287
- channel_vis = max (efx -> n_channels , efx -> n_tx_channels * EFX_TXQ_TYPES );
1306
+ channel_vis = max (efx -> n_channels ,
1307
+ (efx -> n_tx_channels + efx -> n_extra_tx_channels ) *
1308
+ EFX_TXQ_TYPES );
1288
1309
1289
1310
#ifdef EFX_USE_PIO
1290
1311
/* Try to allocate PIO buffers if wanted and if the full
@@ -2408,12 +2429,25 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
2408
2429
int i ;
2409
2430
BUILD_BUG_ON (MC_CMD_INIT_TXQ_OUT_LEN != 0 );
2410
2431
2432
+ /* Only attempt to enable TX timestamping if we have the license for it,
2433
+ * otherwise TXQ init will fail
2434
+ */
2435
+ if (!(nic_data -> licensed_features &
2436
+ (1 << LICENSED_V3_FEATURES_TX_TIMESTAMPS_LBN ))) {
2437
+ tx_queue -> timestamping = false;
2438
+ /* Disable sync events on this channel. */
2439
+ if (efx -> type -> ptp_set_ts_sync_events )
2440
+ efx -> type -> ptp_set_ts_sync_events (efx , false, false);
2441
+ }
2442
+
2411
2443
/* TSOv2 is a limited resource that can only be configured on a limited
2412
2444
* number of queues. TSO without checksum offload is not really a thing,
2413
2445
* so we only enable it for those queues.
2446
+ * TSOv2 cannot be used with Hardware timestamping.
2414
2447
*/
2415
2448
if (csum_offload && (nic_data -> datapath_caps2 &
2416
- (1 << MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_LBN ))) {
2449
+ (1 << MC_CMD_GET_CAPABILITIES_V2_OUT_TX_TSO_V2_LBN )) &&
2450
+ !tx_queue -> timestamping ) {
2417
2451
tso_v2 = true;
2418
2452
netif_dbg (efx , hw , efx -> net_dev , "Using TSOv2 for channel %u\n" ,
2419
2453
channel -> channel );
@@ -2439,14 +2473,16 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
2439
2473
inlen = MC_CMD_INIT_TXQ_IN_LEN (entries );
2440
2474
2441
2475
do {
2442
- MCDI_POPULATE_DWORD_3 (inbuf , INIT_TXQ_IN_FLAGS ,
2476
+ MCDI_POPULATE_DWORD_4 (inbuf , INIT_TXQ_IN_FLAGS ,
2443
2477
/* This flag was removed from mcdi_pcol.h for
2444
2478
* the non-_EXT version of INIT_TXQ. However,
2445
2479
* firmware still honours it.
2446
2480
*/
2447
2481
INIT_TXQ_EXT_IN_FLAG_TSOV2_EN , tso_v2 ,
2448
2482
INIT_TXQ_IN_FLAG_IP_CSUM_DIS , !csum_offload ,
2449
- INIT_TXQ_IN_FLAG_TCP_CSUM_DIS , !csum_offload );
2483
+ INIT_TXQ_IN_FLAG_TCP_CSUM_DIS , !csum_offload ,
2484
+ INIT_TXQ_EXT_IN_FLAG_TIMESTAMP ,
2485
+ tx_queue -> timestamping );
2450
2486
2451
2487
rc = efx_mcdi_rpc_quiet (efx , MC_CMD_INIT_TXQ , inbuf , inlen ,
2452
2488
NULL , 0 , NULL );
@@ -2472,12 +2508,13 @@ static void efx_ef10_tx_init(struct efx_tx_queue *tx_queue)
2472
2508
tx_queue -> buffer [0 ].flags = EFX_TX_BUF_OPTION ;
2473
2509
tx_queue -> insert_count = 1 ;
2474
2510
txd = efx_tx_desc (tx_queue , 0 );
2475
- EFX_POPULATE_QWORD_4 (* txd ,
2511
+ EFX_POPULATE_QWORD_5 (* txd ,
2476
2512
ESF_DZ_TX_DESC_IS_OPT , true,
2477
2513
ESF_DZ_TX_OPTION_TYPE ,
2478
2514
ESE_DZ_TX_OPTION_DESC_CRC_CSUM ,
2479
2515
ESF_DZ_TX_OPTION_UDP_TCP_CSUM , csum_offload ,
2480
- ESF_DZ_TX_OPTION_IP_CSUM , csum_offload );
2516
+ ESF_DZ_TX_OPTION_IP_CSUM , csum_offload ,
2517
+ ESF_DZ_TX_TIMESTAMP , tx_queue -> timestamping );
2481
2518
tx_queue -> write_count = 1 ;
2482
2519
2483
2520
if (tso_v2 ) {
@@ -3572,31 +3609,92 @@ static int efx_ef10_handle_rx_event(struct efx_channel *channel,
3572
3609
return n_packets ;
3573
3610
}
3574
3611
3575
- static int
3612
+ static u32 efx_ef10_extract_event_ts (efx_qword_t * event )
3613
+ {
3614
+ u32 tstamp ;
3615
+
3616
+ tstamp = EFX_QWORD_FIELD (* event , TX_TIMESTAMP_EVENT_TSTAMP_DATA_HI );
3617
+ tstamp <<= 16 ;
3618
+ tstamp |= EFX_QWORD_FIELD (* event , TX_TIMESTAMP_EVENT_TSTAMP_DATA_LO );
3619
+
3620
+ return tstamp ;
3621
+ }
3622
+
3623
+ static void
3576
3624
efx_ef10_handle_tx_event (struct efx_channel * channel , efx_qword_t * event )
3577
3625
{
3578
3626
struct efx_nic * efx = channel -> efx ;
3579
3627
struct efx_tx_queue * tx_queue ;
3580
3628
unsigned int tx_ev_desc_ptr ;
3581
3629
unsigned int tx_ev_q_label ;
3582
- int tx_descs = 0 ;
3630
+ unsigned int tx_ev_type ;
3631
+ u64 ts_part ;
3583
3632
3584
3633
if (unlikely (READ_ONCE (efx -> reset_pending )))
3585
- return 0 ;
3634
+ return ;
3586
3635
3587
3636
if (unlikely (EFX_QWORD_FIELD (* event , ESF_DZ_TX_DROP_EVENT )))
3588
- return 0 ;
3637
+ return ;
3589
3638
3590
- /* Transmit completion */
3591
- tx_ev_desc_ptr = EFX_QWORD_FIELD (* event , ESF_DZ_TX_DESCR_INDX );
3639
+ /* Get the transmit queue */
3592
3640
tx_ev_q_label = EFX_QWORD_FIELD (* event , ESF_DZ_TX_QLABEL );
3593
3641
tx_queue = efx_channel_get_tx_queue (channel ,
3594
3642
tx_ev_q_label % EFX_TXQ_TYPES );
3595
- tx_descs = ((tx_ev_desc_ptr + 1 - tx_queue -> read_count ) &
3596
- tx_queue -> ptr_mask );
3597
- efx_xmit_done (tx_queue , tx_ev_desc_ptr & tx_queue -> ptr_mask );
3598
3643
3599
- return tx_descs ;
3644
+ if (!tx_queue -> timestamping ) {
3645
+ /* Transmit completion */
3646
+ tx_ev_desc_ptr = EFX_QWORD_FIELD (* event , ESF_DZ_TX_DESCR_INDX );
3647
+ efx_xmit_done (tx_queue , tx_ev_desc_ptr & tx_queue -> ptr_mask );
3648
+ return ;
3649
+ }
3650
+
3651
+ /* Transmit timestamps are only available for 8XXX series. They result
3652
+ * in three events per packet. These occur in order, and are:
3653
+ * - the normal completion event
3654
+ * - the low part of the timestamp
3655
+ * - the high part of the timestamp
3656
+ *
3657
+ * Each part of the timestamp is itself split across two 16 bit
3658
+ * fields in the event.
3659
+ */
3660
+ tx_ev_type = EFX_QWORD_FIELD (* event , ESF_EZ_TX_SOFT1 );
3661
+
3662
+ switch (tx_ev_type ) {
3663
+ case TX_TIMESTAMP_EVENT_TX_EV_COMPLETION :
3664
+ /* In case of Queue flush or FLR, we might have received
3665
+ * the previous TX completion event but not the Timestamp
3666
+ * events.
3667
+ */
3668
+ if (tx_queue -> completed_desc_ptr != tx_queue -> ptr_mask )
3669
+ efx_xmit_done (tx_queue , tx_queue -> completed_desc_ptr );
3670
+
3671
+ tx_ev_desc_ptr = EFX_QWORD_FIELD (* event ,
3672
+ ESF_DZ_TX_DESCR_INDX );
3673
+ tx_queue -> completed_desc_ptr =
3674
+ tx_ev_desc_ptr & tx_queue -> ptr_mask ;
3675
+ break ;
3676
+
3677
+ case TX_TIMESTAMP_EVENT_TX_EV_TSTAMP_LO :
3678
+ ts_part = efx_ef10_extract_event_ts (event );
3679
+ tx_queue -> completed_timestamp_minor = ts_part ;
3680
+ break ;
3681
+
3682
+ case TX_TIMESTAMP_EVENT_TX_EV_TSTAMP_HI :
3683
+ ts_part = efx_ef10_extract_event_ts (event );
3684
+ tx_queue -> completed_timestamp_major = ts_part ;
3685
+
3686
+ efx_xmit_done (tx_queue , tx_queue -> completed_desc_ptr );
3687
+ tx_queue -> completed_desc_ptr = tx_queue -> ptr_mask ;
3688
+ break ;
3689
+
3690
+ default :
3691
+ netif_err (efx , hw , efx -> net_dev ,
3692
+ "channel %d unknown tx event type %d (data "
3693
+ EFX_QWORD_FMT ")\n" ,
3694
+ channel -> channel , tx_ev_type ,
3695
+ EFX_QWORD_VAL (* event ));
3696
+ break ;
3697
+ }
3600
3698
}
3601
3699
3602
3700
static void
@@ -3658,7 +3756,6 @@ static int efx_ef10_ev_process(struct efx_channel *channel, int quota)
3658
3756
efx_qword_t event , * p_event ;
3659
3757
unsigned int read_ptr ;
3660
3758
int ev_code ;
3661
- int tx_descs = 0 ;
3662
3759
int spent = 0 ;
3663
3760
3664
3761
if (quota <= 0 )
@@ -3698,13 +3795,7 @@ static int efx_ef10_ev_process(struct efx_channel *channel, int quota)
3698
3795
}
3699
3796
break ;
3700
3797
case ESE_DZ_EV_CODE_TX_EV :
3701
- tx_descs += efx_ef10_handle_tx_event (channel , & event );
3702
- if (tx_descs > efx -> txq_entries ) {
3703
- spent = quota ;
3704
- goto out ;
3705
- } else if (++ spent == quota ) {
3706
- goto out ;
3707
- }
3798
+ efx_ef10_handle_tx_event (channel , & event );
3708
3799
break ;
3709
3800
case ESE_DZ_EV_CODE_DRIVER_EV :
3710
3801
efx_ef10_handle_driver_event (channel , & event );
@@ -6179,7 +6270,8 @@ static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en,
6179
6270
efx_ef10_rx_enable_timestamping :
6180
6271
efx_ef10_rx_disable_timestamping ;
6181
6272
6182
- efx_for_each_channel (channel , efx ) {
6273
+ channel = efx_ptp_channel (efx );
6274
+ if (channel ) {
6183
6275
int rc = set (channel , temp );
6184
6276
if (en && rc != 0 ) {
6185
6277
efx_ef10_ptp_set_ts_sync_events (efx , false, temp );
0 commit comments