@@ -156,6 +156,8 @@ struct mlxsw_pci {
156
156
} cmd ;
157
157
struct mlxsw_bus_info bus_info ;
158
158
const struct pci_device_id * id ;
159
+ enum mlxsw_pci_cqe_v max_cqe_ver ; /* Maximal supported CQE version */
160
+ u8 num_sdq_cqs ; /* Number of CQs used for SDQs */
159
161
};
160
162
161
163
static void mlxsw_pci_queue_tasklet_schedule (struct mlxsw_pci_queue * q )
@@ -477,6 +479,17 @@ static void mlxsw_pci_rdq_fini(struct mlxsw_pci *mlxsw_pci,
477
479
}
478
480
}
479
481
482
+ static void mlxsw_pci_cq_pre_init (struct mlxsw_pci * mlxsw_pci ,
483
+ struct mlxsw_pci_queue * q )
484
+ {
485
+ q -> u .cq .v = mlxsw_pci -> max_cqe_ver ;
486
+
487
+ /* For SDQ it is pointless to use CQEv2, so use CQEv1 instead */
488
+ if (q -> u .cq .v == MLXSW_PCI_CQE_V2 &&
489
+ q -> num < mlxsw_pci -> num_sdq_cqs )
490
+ q -> u .cq .v = MLXSW_PCI_CQE_V1 ;
491
+ }
492
+
480
493
static int mlxsw_pci_cq_init (struct mlxsw_pci * mlxsw_pci , char * mbox ,
481
494
struct mlxsw_pci_queue * q )
482
495
{
@@ -491,7 +504,13 @@ static int mlxsw_pci_cq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
491
504
mlxsw_pci_cqe_owner_set (q -> u .cq .v , elem , 1 );
492
505
}
493
506
494
- mlxsw_cmd_mbox_sw2hw_cq_cv_set (mbox , 0 ); /* CQE ver 0 */
507
+ if (q -> u .cq .v == MLXSW_PCI_CQE_V1 )
508
+ mlxsw_cmd_mbox_sw2hw_cq_cqe_ver_set (mbox ,
509
+ MLXSW_CMD_MBOX_SW2HW_CQ_CQE_VER_1 );
510
+ else if (q -> u .cq .v == MLXSW_PCI_CQE_V2 )
511
+ mlxsw_cmd_mbox_sw2hw_cq_cqe_ver_set (mbox ,
512
+ MLXSW_CMD_MBOX_SW2HW_CQ_CQE_VER_2 );
513
+
495
514
mlxsw_cmd_mbox_sw2hw_cq_c_eqn_set (mbox , MLXSW_PCI_EQ_COMP_NUM );
496
515
mlxsw_cmd_mbox_sw2hw_cq_st_set (mbox , 0 );
497
516
mlxsw_cmd_mbox_sw2hw_cq_log_cq_size_set (mbox , ilog2 (q -> count ));
@@ -643,6 +662,18 @@ static void mlxsw_pci_cq_tasklet(unsigned long data)
643
662
}
644
663
}
645
664
665
+ static u16 mlxsw_pci_cq_elem_count (const struct mlxsw_pci_queue * q )
666
+ {
667
+ return q -> u .cq .v == MLXSW_PCI_CQE_V2 ? MLXSW_PCI_CQE2_COUNT :
668
+ MLXSW_PCI_CQE01_COUNT ;
669
+ }
670
+
671
+ static u8 mlxsw_pci_cq_elem_size (const struct mlxsw_pci_queue * q )
672
+ {
673
+ return q -> u .cq .v == MLXSW_PCI_CQE_V2 ? MLXSW_PCI_CQE2_SIZE :
674
+ MLXSW_PCI_CQE01_SIZE ;
675
+ }
676
+
646
677
static int mlxsw_pci_eq_init (struct mlxsw_pci * mlxsw_pci , char * mbox ,
647
678
struct mlxsw_pci_queue * q )
648
679
{
@@ -755,11 +786,15 @@ static void mlxsw_pci_eq_tasklet(unsigned long data)
755
786
struct mlxsw_pci_queue_ops {
756
787
const char * name ;
757
788
enum mlxsw_pci_queue_type type ;
789
+ void (* pre_init )(struct mlxsw_pci * mlxsw_pci ,
790
+ struct mlxsw_pci_queue * q );
758
791
int (* init )(struct mlxsw_pci * mlxsw_pci , char * mbox ,
759
792
struct mlxsw_pci_queue * q );
760
793
void (* fini )(struct mlxsw_pci * mlxsw_pci ,
761
794
struct mlxsw_pci_queue * q );
762
795
void (* tasklet )(unsigned long data );
796
+ u16 (* elem_count_f )(const struct mlxsw_pci_queue * q );
797
+ u8 (* elem_size_f )(const struct mlxsw_pci_queue * q );
763
798
u16 elem_count ;
764
799
u8 elem_size ;
765
800
};
@@ -782,11 +817,12 @@ static const struct mlxsw_pci_queue_ops mlxsw_pci_rdq_ops = {
782
817
783
818
static const struct mlxsw_pci_queue_ops mlxsw_pci_cq_ops = {
784
819
.type = MLXSW_PCI_QUEUE_TYPE_CQ ,
820
+ .pre_init = mlxsw_pci_cq_pre_init ,
785
821
.init = mlxsw_pci_cq_init ,
786
822
.fini = mlxsw_pci_cq_fini ,
787
823
.tasklet = mlxsw_pci_cq_tasklet ,
788
- .elem_count = MLXSW_PCI_CQE01_COUNT ,
789
- .elem_size = MLXSW_PCI_CQE01_SIZE
824
+ .elem_count_f = mlxsw_pci_cq_elem_count ,
825
+ .elem_size_f = mlxsw_pci_cq_elem_size
790
826
};
791
827
792
828
static const struct mlxsw_pci_queue_ops mlxsw_pci_eq_ops = {
@@ -806,12 +842,15 @@ static int mlxsw_pci_queue_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
806
842
int i ;
807
843
int err ;
808
844
809
- q -> u .cq .v = MLXSW_PCI_CQE_V0 ;
845
+ q -> num = q_num ;
846
+ if (q_ops -> pre_init )
847
+ q_ops -> pre_init (mlxsw_pci , q );
810
848
811
849
spin_lock_init (& q -> lock );
812
- q -> num = q_num ;
813
- q -> count = q_ops -> elem_count ;
814
- q -> elem_size = q_ops -> elem_size ;
850
+ q -> count = q_ops -> elem_count_f ? q_ops -> elem_count_f (q ) :
851
+ q_ops -> elem_count ;
852
+ q -> elem_size = q_ops -> elem_size_f ? q_ops -> elem_size_f (q ) :
853
+ q_ops -> elem_size ;
815
854
q -> type = q_ops -> type ;
816
855
q -> pci = mlxsw_pci ;
817
856
@@ -840,7 +879,7 @@ static int mlxsw_pci_queue_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
840
879
841
880
elem_info = mlxsw_pci_queue_elem_info_get (q , i );
842
881
elem_info -> elem =
843
- __mlxsw_pci_queue_elem_get (q , q_ops -> elem_size , i );
882
+ __mlxsw_pci_queue_elem_get (q , q -> elem_size , i );
844
883
}
845
884
846
885
mlxsw_cmd_mbox_zero (mbox );
@@ -952,6 +991,8 @@ static int mlxsw_pci_aqs_init(struct mlxsw_pci *mlxsw_pci, char *mbox)
952
991
return - EINVAL ;
953
992
}
954
993
994
+ mlxsw_pci -> num_sdq_cqs = num_sdqs ;
995
+
955
996
err = mlxsw_pci_queue_group_init (mlxsw_pci , mbox , & mlxsw_pci_eq_ops ,
956
997
num_eqs );
957
998
if (err ) {
@@ -1192,6 +1233,11 @@ static int mlxsw_pci_config_profile(struct mlxsw_pci *mlxsw_pci, char *mbox,
1192
1233
mlxsw_pci_config_profile_swid_config (mlxsw_pci , mbox , i ,
1193
1234
& profile -> swid_config [i ]);
1194
1235
1236
+ if (mlxsw_pci -> max_cqe_ver > MLXSW_PCI_CQE_V0 ) {
1237
+ mlxsw_cmd_mbox_config_profile_set_cqe_version_set (mbox , 1 );
1238
+ mlxsw_cmd_mbox_config_profile_cqe_version_set (mbox , 1 );
1239
+ }
1240
+
1195
1241
return mlxsw_cmd_config_profile_set (mlxsw_pci -> core , mbox );
1196
1242
}
1197
1243
@@ -1386,6 +1432,21 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
1386
1432
if (err )
1387
1433
goto err_query_resources ;
1388
1434
1435
+ if (MLXSW_CORE_RES_VALID (mlxsw_core , CQE_V2 ) &&
1436
+ MLXSW_CORE_RES_GET (mlxsw_core , CQE_V2 ))
1437
+ mlxsw_pci -> max_cqe_ver = MLXSW_PCI_CQE_V2 ;
1438
+ else if (MLXSW_CORE_RES_VALID (mlxsw_core , CQE_V1 ) &&
1439
+ MLXSW_CORE_RES_GET (mlxsw_core , CQE_V1 ))
1440
+ mlxsw_pci -> max_cqe_ver = MLXSW_PCI_CQE_V1 ;
1441
+ else if ((MLXSW_CORE_RES_VALID (mlxsw_core , CQE_V0 ) &&
1442
+ MLXSW_CORE_RES_GET (mlxsw_core , CQE_V0 )) ||
1443
+ !MLXSW_CORE_RES_VALID (mlxsw_core , CQE_V0 )) {
1444
+ mlxsw_pci -> max_cqe_ver = MLXSW_PCI_CQE_V0 ;
1445
+ } else {
1446
+ dev_err (& pdev -> dev , "Invalid supported CQE version combination reported\n" );
1447
+ goto err_cqe_v_check ;
1448
+ }
1449
+
1389
1450
err = mlxsw_pci_config_profile (mlxsw_pci , mbox , profile , res );
1390
1451
if (err )
1391
1452
goto err_config_profile ;
@@ -1408,6 +1469,7 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
1408
1469
mlxsw_pci_aqs_fini (mlxsw_pci );
1409
1470
err_aqs_init :
1410
1471
err_config_profile :
1472
+ err_cqe_v_check :
1411
1473
err_query_resources :
1412
1474
err_boardinfo :
1413
1475
mlxsw_pci_fw_area_fini (mlxsw_pci );
0 commit comments