@@ -361,7 +361,14 @@ lio_ethtool_get_channels(struct net_device *dev,
361
361
rx_count = CFG_GET_NUM_RXQS_NIC_IF (conf6x , lio -> ifidx );
362
362
tx_count = CFG_GET_NUM_TXQS_NIC_IF (conf6x , lio -> ifidx );
363
363
} else if (OCTEON_CN23XX_PF (oct )) {
364
- max_combined = lio -> linfo .num_txpciq ;
364
+ if (oct -> sriov_info .sriov_enabled ) {
365
+ max_combined = lio -> linfo .num_txpciq ;
366
+ } else {
367
+ struct octeon_config * conf23_pf =
368
+ CHIP_CONF (oct , cn23xx_pf );
369
+
370
+ max_combined = CFG_GET_IQ_MAX_Q (conf23_pf );
371
+ }
365
372
combined_count = oct -> num_iqs ;
366
373
} else if (OCTEON_CN23XX_VF (oct )) {
367
374
u64 reg_val = 0ULL ;
@@ -425,9 +432,15 @@ lio_irq_reallocate_irqs(struct octeon_device *oct, uint32_t num_ioqs)
425
432
426
433
kfree (oct -> irq_name_storage );
427
434
oct -> irq_name_storage = NULL ;
435
+
436
+ if (octeon_allocate_ioq_vector (oct , num_ioqs )) {
437
+ dev_err (& oct -> pci_dev -> dev , "OCTEON: ioq vector allocation failed\n" );
438
+ return -1 ;
439
+ }
440
+
428
441
if (octeon_setup_interrupt (oct , num_ioqs )) {
429
442
dev_info (& oct -> pci_dev -> dev , "Setup interrupt failed\n" );
430
- return 1 ;
443
+ return - 1 ;
431
444
}
432
445
433
446
/* Enable Octeon device interrupts */
@@ -457,7 +470,16 @@ lio_ethtool_set_channels(struct net_device *dev,
457
470
combined_count = channel -> combined_count ;
458
471
459
472
if (OCTEON_CN23XX_PF (oct )) {
460
- max_combined = channel -> max_combined ;
473
+ if (oct -> sriov_info .sriov_enabled ) {
474
+ max_combined = lio -> linfo .num_txpciq ;
475
+ } else {
476
+ struct octeon_config * conf23_pf =
477
+ CHIP_CONF (oct ,
478
+ cn23xx_pf );
479
+
480
+ max_combined =
481
+ CFG_GET_IQ_MAX_Q (conf23_pf );
482
+ }
461
483
} else if (OCTEON_CN23XX_VF (oct )) {
462
484
u64 reg_val = 0ULL ;
463
485
u64 ctrl = CN23XX_VF_SLI_IQ_PKT_CONTROL64 (0 );
@@ -485,7 +507,6 @@ lio_ethtool_set_channels(struct net_device *dev,
485
507
if (lio_reset_queues (dev , combined_count ))
486
508
return - EINVAL ;
487
509
488
- lio_irq_reallocate_irqs (oct , combined_count );
489
510
if (stopped )
490
511
dev -> netdev_ops -> ndo_open (dev );
491
512
@@ -824,12 +845,120 @@ lio_ethtool_get_ringparam(struct net_device *netdev,
824
845
ering -> rx_jumbo_max_pending = 0 ;
825
846
}
826
847
848
+ static int lio_23xx_reconfigure_queue_count (struct lio * lio )
849
+ {
850
+ struct octeon_device * oct = lio -> oct_dev ;
851
+ struct liquidio_if_cfg_context * ctx ;
852
+ u32 resp_size , ctx_size , data_size ;
853
+ struct liquidio_if_cfg_resp * resp ;
854
+ struct octeon_soft_command * sc ;
855
+ union oct_nic_if_cfg if_cfg ;
856
+ struct lio_version * vdata ;
857
+ u32 ifidx_or_pfnum ;
858
+ int retval ;
859
+ int j ;
860
+
861
+ resp_size = sizeof (struct liquidio_if_cfg_resp );
862
+ ctx_size = sizeof (struct liquidio_if_cfg_context );
863
+ data_size = sizeof (struct lio_version );
864
+ sc = (struct octeon_soft_command * )
865
+ octeon_alloc_soft_command (oct , data_size ,
866
+ resp_size , ctx_size );
867
+ if (!sc ) {
868
+ dev_err (& oct -> pci_dev -> dev , "%s: Failed to allocate soft command\n" ,
869
+ __func__ );
870
+ return -1 ;
871
+ }
872
+
873
+ resp = (struct liquidio_if_cfg_resp * )sc -> virtrptr ;
874
+ ctx = (struct liquidio_if_cfg_context * )sc -> ctxptr ;
875
+ vdata = (struct lio_version * )sc -> virtdptr ;
876
+
877
+ vdata -> major = (__force u16 )cpu_to_be16 (LIQUIDIO_BASE_MAJOR_VERSION );
878
+ vdata -> minor = (__force u16 )cpu_to_be16 (LIQUIDIO_BASE_MINOR_VERSION );
879
+ vdata -> micro = (__force u16 )cpu_to_be16 (LIQUIDIO_BASE_MICRO_VERSION );
880
+
881
+ ifidx_or_pfnum = oct -> pf_num ;
882
+ WRITE_ONCE (ctx -> cond , 0 );
883
+ ctx -> octeon_id = lio_get_device_id (oct );
884
+ init_waitqueue_head (& ctx -> wc );
885
+
886
+ if_cfg .u64 = 0 ;
887
+ if_cfg .s .num_iqueues = oct -> sriov_info .num_pf_rings ;
888
+ if_cfg .s .num_oqueues = oct -> sriov_info .num_pf_rings ;
889
+ if_cfg .s .base_queue = oct -> sriov_info .pf_srn ;
890
+ if_cfg .s .gmx_port_id = oct -> pf_num ;
891
+
892
+ sc -> iq_no = 0 ;
893
+ octeon_prepare_soft_command (oct , sc , OPCODE_NIC ,
894
+ OPCODE_NIC_QCOUNT_UPDATE , 0 ,
895
+ if_cfg .u64 , 0 );
896
+ sc -> callback = lio_if_cfg_callback ;
897
+ sc -> callback_arg = sc ;
898
+ sc -> wait_time = LIO_IFCFG_WAIT_TIME ;
899
+
900
+ retval = octeon_send_soft_command (oct , sc );
901
+ if (retval == IQ_SEND_FAILED ) {
902
+ dev_err (& oct -> pci_dev -> dev ,
903
+ "iq/oq config failed status: %x\n" ,
904
+ retval );
905
+ goto qcount_update_fail ;
906
+ }
907
+
908
+ if (sleep_cond (& ctx -> wc , & ctx -> cond ) == - EINTR ) {
909
+ dev_err (& oct -> pci_dev -> dev , "Wait interrupted\n" );
910
+ return -1 ;
911
+ }
912
+
913
+ retval = resp -> status ;
914
+ if (retval ) {
915
+ dev_err (& oct -> pci_dev -> dev , "iq/oq config failed\n" );
916
+ goto qcount_update_fail ;
917
+ }
918
+
919
+ octeon_swap_8B_data ((u64 * )(& resp -> cfg_info ),
920
+ (sizeof (struct liquidio_if_cfg_info )) >> 3 );
921
+
922
+ lio -> ifidx = ifidx_or_pfnum ;
923
+ lio -> linfo .num_rxpciq = hweight64 (resp -> cfg_info .iqmask );
924
+ lio -> linfo .num_txpciq = hweight64 (resp -> cfg_info .iqmask );
925
+ for (j = 0 ; j < lio -> linfo .num_rxpciq ; j ++ ) {
926
+ lio -> linfo .rxpciq [j ].u64 =
927
+ resp -> cfg_info .linfo .rxpciq [j ].u64 ;
928
+ }
929
+
930
+ for (j = 0 ; j < lio -> linfo .num_txpciq ; j ++ ) {
931
+ lio -> linfo .txpciq [j ].u64 =
932
+ resp -> cfg_info .linfo .txpciq [j ].u64 ;
933
+ }
934
+
935
+ lio -> linfo .hw_addr = resp -> cfg_info .linfo .hw_addr ;
936
+ lio -> linfo .gmxport = resp -> cfg_info .linfo .gmxport ;
937
+ lio -> linfo .link .u64 = resp -> cfg_info .linfo .link .u64 ;
938
+ lio -> txq = lio -> linfo .txpciq [0 ].s .q_no ;
939
+ lio -> rxq = lio -> linfo .rxpciq [0 ].s .q_no ;
940
+
941
+ octeon_free_soft_command (oct , sc );
942
+ dev_info (& oct -> pci_dev -> dev , "Queue count updated to %d\n" ,
943
+ lio -> linfo .num_rxpciq );
944
+
945
+ return 0 ;
946
+
947
+ qcount_update_fail :
948
+ octeon_free_soft_command (oct , sc );
949
+
950
+ return -1 ;
951
+ }
952
+
827
953
static int lio_reset_queues (struct net_device * netdev , uint32_t num_qs )
828
954
{
829
955
struct lio * lio = GET_LIO (netdev );
830
956
struct octeon_device * oct = lio -> oct_dev ;
957
+ int i , queue_count_update = 0 ;
831
958
struct napi_struct * napi , * n ;
832
- int i , update = 0 ;
959
+ int ret ;
960
+
961
+ schedule_timeout_uninterruptible (msecs_to_jiffies (100 ));
833
962
834
963
if (wait_for_pending_requests (oct ))
835
964
dev_err (& oct -> pci_dev -> dev , "There were pending requests\n" );
@@ -838,7 +967,7 @@ static int lio_reset_queues(struct net_device *netdev, uint32_t num_qs)
838
967
dev_err (& oct -> pci_dev -> dev , "IQ had pending instructions\n" );
839
968
840
969
if (octeon_set_io_queues_off (oct )) {
841
- dev_err (& oct -> pci_dev -> dev , "setting io queues off failed\n" );
970
+ dev_err (& oct -> pci_dev -> dev , "Setting io queues off failed\n" );
842
971
return -1 ;
843
972
}
844
973
@@ -851,9 +980,40 @@ static int lio_reset_queues(struct net_device *netdev, uint32_t num_qs)
851
980
netif_napi_del (napi );
852
981
853
982
if (num_qs != oct -> num_iqs ) {
854
- netif_set_real_num_rx_queues (netdev , num_qs );
855
- netif_set_real_num_tx_queues (netdev , num_qs );
856
- update = 1 ;
983
+ ret = netif_set_real_num_rx_queues (netdev , num_qs );
984
+ if (ret ) {
985
+ dev_err (& oct -> pci_dev -> dev ,
986
+ "Setting real number rx failed\n" );
987
+ return ret ;
988
+ }
989
+
990
+ ret = netif_set_real_num_tx_queues (netdev , num_qs );
991
+ if (ret ) {
992
+ dev_err (& oct -> pci_dev -> dev ,
993
+ "Setting real number tx failed\n" );
994
+ return ret ;
995
+ }
996
+
997
+ /* The value of queue_count_update decides whether it is the
998
+ * queue count or the descriptor count that is being
999
+ * re-configured.
1000
+ */
1001
+ queue_count_update = 1 ;
1002
+ }
1003
+
1004
+ /* Re-configuration of queues can happen in two scenarios, SRIOV enabled
1005
+ * and SRIOV disabled. Few things like recreating queue zero, resetting
1006
+ * glists and IRQs are required for both. For the latter, some more
1007
+ * steps like updating sriov_info for the octeon device need to be done.
1008
+ */
1009
+ if (queue_count_update ) {
1010
+ lio_delete_glists (lio );
1011
+
1012
+ /* Delete mbox for PF which is SRIOV disabled because sriov_info
1013
+ * will be now changed.
1014
+ */
1015
+ if ((OCTEON_CN23XX_PF (oct )) && !oct -> sriov_info .sriov_enabled )
1016
+ oct -> fn_list .free_mbox (oct );
857
1017
}
858
1018
859
1019
for (i = 0 ; i < MAX_OCTEON_OUTPUT_QUEUES (oct ); i ++ ) {
@@ -868,24 +1028,91 @@ static int lio_reset_queues(struct net_device *netdev, uint32_t num_qs)
868
1028
octeon_delete_instr_queue (oct , i );
869
1029
}
870
1030
1031
+ if (queue_count_update ) {
1032
+ /* For PF re-configure sriov related information */
1033
+ if ((OCTEON_CN23XX_PF (oct )) &&
1034
+ !oct -> sriov_info .sriov_enabled ) {
1035
+ oct -> sriov_info .num_pf_rings = num_qs ;
1036
+ if (cn23xx_sriov_config (oct )) {
1037
+ dev_err (& oct -> pci_dev -> dev ,
1038
+ "Queue reset aborted: SRIOV config failed\n" );
1039
+ return -1 ;
1040
+ }
1041
+
1042
+ num_qs = oct -> sriov_info .num_pf_rings ;
1043
+ }
1044
+ }
1045
+
871
1046
if (oct -> fn_list .setup_device_regs (oct )) {
872
1047
dev_err (& oct -> pci_dev -> dev , "Failed to configure device registers\n" );
873
1048
return -1 ;
874
1049
}
875
1050
876
- if (liquidio_setup_io_queues (oct , 0 , num_qs , num_qs )) {
877
- dev_err (& oct -> pci_dev -> dev , "IO queues initialization failed\n" );
878
- return -1 ;
1051
+ /* The following are needed in case of queue count re-configuration and
1052
+ * not for descriptor count re-configuration.
1053
+ */
1054
+ if (queue_count_update ) {
1055
+ if (octeon_setup_instr_queues (oct ))
1056
+ return -1 ;
1057
+
1058
+ if (octeon_setup_output_queues (oct ))
1059
+ return -1 ;
1060
+
1061
+ /* Recreating mbox for PF that is SRIOV disabled */
1062
+ if (OCTEON_CN23XX_PF (oct ) && !oct -> sriov_info .sriov_enabled ) {
1063
+ if (oct -> fn_list .setup_mbox (oct )) {
1064
+ dev_err (& oct -> pci_dev -> dev , "Mailbox setup failed\n" );
1065
+ return -1 ;
1066
+ }
1067
+ }
1068
+
1069
+ /* Deleting and recreating IRQs whether the interface is SRIOV
1070
+ * enabled or disabled.
1071
+ */
1072
+ if (lio_irq_reallocate_irqs (oct , num_qs )) {
1073
+ dev_err (& oct -> pci_dev -> dev , "IRQs could not be allocated\n" );
1074
+ return -1 ;
1075
+ }
1076
+
1077
+ /* Enable the input and output queues for this Octeon device */
1078
+ if (oct -> fn_list .enable_io_queues (oct )) {
1079
+ dev_err (& oct -> pci_dev -> dev , "Failed to enable input/output queues\n" );
1080
+ return -1 ;
1081
+ }
1082
+
1083
+ for (i = 0 ; i < oct -> num_oqs ; i ++ )
1084
+ writel (oct -> droq [i ]-> max_count ,
1085
+ oct -> droq [i ]-> pkts_credit_reg );
1086
+
1087
+ /* Informing firmware about the new queue count. It is required
1088
+ * for firmware to allocate more number of queues than those at
1089
+ * load time.
1090
+ */
1091
+ if (OCTEON_CN23XX_PF (oct ) && !oct -> sriov_info .sriov_enabled ) {
1092
+ if (lio_23xx_reconfigure_queue_count (lio ))
1093
+ return -1 ;
1094
+ }
879
1095
}
880
1096
881
- /* Enable the input and output queues for this Octeon device */
882
- if (oct -> fn_list . enable_io_queues (oct )) {
883
- dev_err (& oct -> pci_dev -> dev , "Failed to enable input/output queues" );
1097
+ /* Once firmware is aware of the new value, queues can be recreated */
1098
+ if (liquidio_setup_io_queues (oct , 0 , num_qs , num_qs )) {
1099
+ dev_err (& oct -> pci_dev -> dev , "I/O queues creation failed\n " );
884
1100
return -1 ;
885
1101
}
886
1102
887
- if (update && lio_send_queue_count_update (netdev , num_qs ))
888
- return -1 ;
1103
+ if (queue_count_update ) {
1104
+ if (lio_setup_glists (oct , lio , num_qs )) {
1105
+ dev_err (& oct -> pci_dev -> dev , "Gather list allocation failed\n" );
1106
+ return -1 ;
1107
+ }
1108
+
1109
+ /* Send firmware the information about new number of queues
1110
+ * if the interface is a VF or a PF that is SRIOV enabled.
1111
+ */
1112
+ if (oct -> sriov_info .sriov_enabled || OCTEON_CN23XX_VF (oct ))
1113
+ if (lio_send_queue_count_update (netdev , num_qs ))
1114
+ return -1 ;
1115
+ }
889
1116
890
1117
return 0 ;
891
1118
}
@@ -930,7 +1157,7 @@ static int lio_ethtool_set_ringparam(struct net_device *netdev,
930
1157
CFG_SET_NUM_RX_DESCS_NIC_IF (octeon_get_conf (oct ), lio -> ifidx ,
931
1158
rx_count );
932
1159
933
- if (lio_reset_queues (netdev , lio -> linfo . num_txpciq ))
1160
+ if (lio_reset_queues (netdev , oct -> num_iqs ))
934
1161
goto err_lio_reset_queues ;
935
1162
936
1163
if (stopped )
0 commit comments