@@ -46,6 +46,7 @@ void gve_parse_device_option(struct gve_priv *priv,
46
46
struct gve_device_option_buffer_sizes * * dev_op_buffer_sizes ,
47
47
struct gve_device_option_flow_steering * * dev_op_flow_steering ,
48
48
struct gve_device_option_rss_config * * dev_op_rss_config ,
49
+ struct gve_device_option_nic_timestamp * * dev_op_nic_timestamp ,
49
50
struct gve_device_option_modify_ring * * dev_op_modify_ring )
50
51
{
51
52
u32 req_feat_mask = be32_to_cpu (option -> required_features_mask );
@@ -225,6 +226,23 @@ void gve_parse_device_option(struct gve_priv *priv,
225
226
"RSS config" );
226
227
* dev_op_rss_config = (void * )(option + 1 );
227
228
break ;
229
+ case GVE_DEV_OPT_ID_NIC_TIMESTAMP :
230
+ if (option_length < sizeof (* * dev_op_nic_timestamp ) ||
231
+ req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_NIC_TIMESTAMP ) {
232
+ dev_warn (& priv -> pdev -> dev , GVE_DEVICE_OPTION_ERROR_FMT ,
233
+ "Nic Timestamp" ,
234
+ (int )sizeof (* * dev_op_nic_timestamp ),
235
+ GVE_DEV_OPT_REQ_FEAT_MASK_NIC_TIMESTAMP ,
236
+ option_length , req_feat_mask );
237
+ break ;
238
+ }
239
+
240
+ if (option_length > sizeof (* * dev_op_nic_timestamp ))
241
+ dev_warn (& priv -> pdev -> dev ,
242
+ GVE_DEVICE_OPTION_TOO_BIG_FMT ,
243
+ "Nic Timestamp" );
244
+ * dev_op_nic_timestamp = (void * )(option + 1 );
245
+ break ;
228
246
default :
229
247
/* If we don't recognize the option just continue
230
248
* without doing anything.
@@ -246,6 +264,7 @@ gve_process_device_options(struct gve_priv *priv,
246
264
struct gve_device_option_buffer_sizes * * dev_op_buffer_sizes ,
247
265
struct gve_device_option_flow_steering * * dev_op_flow_steering ,
248
266
struct gve_device_option_rss_config * * dev_op_rss_config ,
267
+ struct gve_device_option_nic_timestamp * * dev_op_nic_timestamp ,
249
268
struct gve_device_option_modify_ring * * dev_op_modify_ring )
250
269
{
251
270
const int num_options = be16_to_cpu (descriptor -> num_device_options );
@@ -269,6 +288,7 @@ gve_process_device_options(struct gve_priv *priv,
269
288
dev_op_dqo_rda , dev_op_jumbo_frames ,
270
289
dev_op_dqo_qpl , dev_op_buffer_sizes ,
271
290
dev_op_flow_steering , dev_op_rss_config ,
291
+ dev_op_nic_timestamp ,
272
292
dev_op_modify_ring );
273
293
dev_opt = next_opt ;
274
294
}
@@ -306,6 +326,7 @@ int gve_adminq_alloc(struct device *dev, struct gve_priv *priv)
306
326
priv -> adminq_set_driver_parameter_cnt = 0 ;
307
327
priv -> adminq_report_stats_cnt = 0 ;
308
328
priv -> adminq_report_link_speed_cnt = 0 ;
329
+ priv -> adminq_report_nic_timestamp_cnt = 0 ;
309
330
priv -> adminq_get_ptype_map_cnt = 0 ;
310
331
priv -> adminq_query_flow_rules_cnt = 0 ;
311
332
priv -> adminq_cfg_flow_rule_cnt = 0 ;
@@ -442,6 +463,8 @@ static int gve_adminq_kick_and_wait(struct gve_priv *priv)
442
463
int tail , head ;
443
464
int i ;
444
465
466
+ lockdep_assert_held (& priv -> adminq_lock );
467
+
445
468
tail = ioread32be (& priv -> reg_bar0 -> adminq_event_counter );
446
469
head = priv -> adminq_prod_cnt ;
447
470
@@ -467,16 +490,15 @@ static int gve_adminq_kick_and_wait(struct gve_priv *priv)
467
490
return 0 ;
468
491
}
469
492
470
- /* This function is not threadsafe - the caller is responsible for any
471
- * necessary locks.
472
- */
473
493
static int gve_adminq_issue_cmd (struct gve_priv * priv ,
474
494
union gve_adminq_command * cmd_orig )
475
495
{
476
496
union gve_adminq_command * cmd ;
477
497
u32 opcode ;
478
498
u32 tail ;
479
499
500
+ lockdep_assert_held (& priv -> adminq_lock );
501
+
480
502
tail = ioread32be (& priv -> reg_bar0 -> adminq_event_counter );
481
503
482
504
// Check if next command will overflow the buffer.
@@ -544,6 +566,9 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,
544
566
case GVE_ADMINQ_REPORT_LINK_SPEED :
545
567
priv -> adminq_report_link_speed_cnt ++ ;
546
568
break ;
569
+ case GVE_ADMINQ_REPORT_NIC_TIMESTAMP :
570
+ priv -> adminq_report_nic_timestamp_cnt ++ ;
571
+ break ;
547
572
case GVE_ADMINQ_GET_PTYPE_MAP :
548
573
priv -> adminq_get_ptype_map_cnt ++ ;
549
574
break ;
@@ -709,13 +734,19 @@ int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_que
709
734
int err ;
710
735
int i ;
711
736
737
+ mutex_lock (& priv -> adminq_lock );
738
+
712
739
for (i = start_id ; i < start_id + num_queues ; i ++ ) {
713
740
err = gve_adminq_create_tx_queue (priv , i );
714
741
if (err )
715
- return err ;
742
+ goto out ;
716
743
}
717
744
718
- return gve_adminq_kick_and_wait (priv );
745
+ err = gve_adminq_kick_and_wait (priv );
746
+
747
+ out :
748
+ mutex_unlock (& priv -> adminq_lock );
749
+ return err ;
719
750
}
720
751
721
752
static void gve_adminq_get_create_rx_queue_cmd (struct gve_priv * priv ,
@@ -788,13 +819,19 @@ int gve_adminq_create_rx_queues(struct gve_priv *priv, u32 num_queues)
788
819
int err ;
789
820
int i ;
790
821
822
+ mutex_lock (& priv -> adminq_lock );
823
+
791
824
for (i = 0 ; i < num_queues ; i ++ ) {
792
825
err = gve_adminq_create_rx_queue (priv , i );
793
826
if (err )
794
- return err ;
827
+ goto out ;
795
828
}
796
829
797
- return gve_adminq_kick_and_wait (priv );
830
+ err = gve_adminq_kick_and_wait (priv );
831
+
832
+ out :
833
+ mutex_unlock (& priv -> adminq_lock );
834
+ return err ;
798
835
}
799
836
800
837
static int gve_adminq_destroy_tx_queue (struct gve_priv * priv , u32 queue_index )
@@ -820,13 +857,19 @@ int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_qu
820
857
int err ;
821
858
int i ;
822
859
860
+ mutex_lock (& priv -> adminq_lock );
861
+
823
862
for (i = start_id ; i < start_id + num_queues ; i ++ ) {
824
863
err = gve_adminq_destroy_tx_queue (priv , i );
825
864
if (err )
826
- return err ;
865
+ goto out ;
827
866
}
828
867
829
- return gve_adminq_kick_and_wait (priv );
868
+ err = gve_adminq_kick_and_wait (priv );
869
+
870
+ out :
871
+ mutex_unlock (& priv -> adminq_lock );
872
+ return err ;
830
873
}
831
874
832
875
static void gve_adminq_make_destroy_rx_queue_cmd (union gve_adminq_command * cmd ,
@@ -861,13 +904,19 @@ int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 num_queues)
861
904
int err ;
862
905
int i ;
863
906
907
+ mutex_lock (& priv -> adminq_lock );
908
+
864
909
for (i = 0 ; i < num_queues ; i ++ ) {
865
910
err = gve_adminq_destroy_rx_queue (priv , i );
866
911
if (err )
867
- return err ;
912
+ goto out ;
868
913
}
869
914
870
- return gve_adminq_kick_and_wait (priv );
915
+ err = gve_adminq_kick_and_wait (priv );
916
+
917
+ out :
918
+ mutex_unlock (& priv -> adminq_lock );
919
+ return err ;
871
920
}
872
921
873
922
static void gve_set_default_desc_cnt (struct gve_priv * priv ,
@@ -904,6 +953,8 @@ static void gve_enable_supported_features(struct gve_priv *priv,
904
953
* dev_op_flow_steering ,
905
954
const struct gve_device_option_rss_config
906
955
* dev_op_rss_config ,
956
+ const struct gve_device_option_nic_timestamp
957
+ * dev_op_nic_timestamp ,
907
958
const struct gve_device_option_modify_ring
908
959
* dev_op_modify_ring )
909
960
{
@@ -980,10 +1031,15 @@ static void gve_enable_supported_features(struct gve_priv *priv,
980
1031
"RSS device option enabled with key size of %u, lut size of %u.\n" ,
981
1032
priv -> rss_key_size , priv -> rss_lut_size );
982
1033
}
1034
+
1035
+ if (dev_op_nic_timestamp &&
1036
+ (supported_features_mask & GVE_SUP_NIC_TIMESTAMP_MASK ))
1037
+ priv -> nic_timestamp_supported = true;
983
1038
}
984
1039
985
1040
int gve_adminq_describe_device (struct gve_priv * priv )
986
1041
{
1042
+ struct gve_device_option_nic_timestamp * dev_op_nic_timestamp = NULL ;
987
1043
struct gve_device_option_flow_steering * dev_op_flow_steering = NULL ;
988
1044
struct gve_device_option_buffer_sizes * dev_op_buffer_sizes = NULL ;
989
1045
struct gve_device_option_jumbo_frames * dev_op_jumbo_frames = NULL ;
@@ -1024,6 +1080,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
1024
1080
& dev_op_buffer_sizes ,
1025
1081
& dev_op_flow_steering ,
1026
1082
& dev_op_rss_config ,
1083
+ & dev_op_nic_timestamp ,
1027
1084
& dev_op_modify_ring );
1028
1085
if (err )
1029
1086
goto free_device_descriptor ;
@@ -1088,7 +1145,8 @@ int gve_adminq_describe_device(struct gve_priv *priv)
1088
1145
gve_enable_supported_features (priv , supported_features_mask ,
1089
1146
dev_op_jumbo_frames , dev_op_dqo_qpl ,
1090
1147
dev_op_buffer_sizes , dev_op_flow_steering ,
1091
- dev_op_rss_config , dev_op_modify_ring );
1148
+ dev_op_rss_config , dev_op_nic_timestamp ,
1149
+ dev_op_modify_ring );
1092
1150
1093
1151
free_device_descriptor :
1094
1152
dma_pool_free (priv -> adminq_pool , descriptor , descriptor_bus );
@@ -1200,6 +1258,22 @@ int gve_adminq_report_link_speed(struct gve_priv *priv)
1200
1258
return err ;
1201
1259
}
1202
1260
1261
+ int gve_adminq_report_nic_ts (struct gve_priv * priv ,
1262
+ dma_addr_t nic_ts_report_addr )
1263
+ {
1264
+ union gve_adminq_command cmd ;
1265
+
1266
+ memset (& cmd , 0 , sizeof (cmd ));
1267
+ cmd .opcode = cpu_to_be32 (GVE_ADMINQ_REPORT_NIC_TIMESTAMP );
1268
+ cmd .report_nic_ts = (struct gve_adminq_report_nic_ts ) {
1269
+ .nic_ts_report_len =
1270
+ cpu_to_be64 (sizeof (struct gve_nic_ts_report )),
1271
+ .nic_ts_report_addr = cpu_to_be64 (nic_ts_report_addr ),
1272
+ };
1273
+
1274
+ return gve_adminq_execute_cmd (priv , & cmd );
1275
+ }
1276
+
1203
1277
int gve_adminq_get_ptype_map_dqo (struct gve_priv * priv ,
1204
1278
struct gve_ptype_lut * ptype_lut )
1205
1279
{
0 commit comments