@@ -48,9 +48,11 @@ struct bgx {
48
48
u8 bgx_id ;
49
49
struct lmac lmac [MAX_LMAC_PER_BGX ];
50
50
int lmac_count ;
51
+ u8 max_lmac ;
51
52
void __iomem * reg_base ;
52
53
struct pci_dev * pdev ;
53
54
bool is_81xx ;
55
+ bool is_rgx ;
54
56
};
55
57
56
58
static struct bgx * bgx_vnic [MAX_BGX_THUNDER ];
@@ -61,6 +63,7 @@ static int bgx_xaui_check_link(struct lmac *lmac);
61
63
/* Supported devices */
62
64
static const struct pci_device_id bgx_id_table [] = {
63
65
{ PCI_DEVICE (PCI_VENDOR_ID_CAVIUM , PCI_DEVICE_ID_THUNDER_BGX ) },
66
+ { PCI_DEVICE (PCI_VENDOR_ID_CAVIUM , PCI_DEVICE_ID_THUNDER_RGX ) },
64
67
{ 0 , } /* end of table */
65
68
};
66
69
@@ -124,7 +127,7 @@ unsigned bgx_get_map(int node)
124
127
int i ;
125
128
unsigned map = 0 ;
126
129
127
- for (i = 0 ; i < MAX_BGX_PER_CN88XX ; i ++ ) {
130
+ for (i = 0 ; i < MAX_BGX_PER_CN81XX ; i ++ ) {
128
131
if (bgx_vnic [(node * MAX_BGX_PER_CN88XX ) + i ])
129
132
map |= (1 << i );
130
133
}
@@ -189,17 +192,22 @@ EXPORT_SYMBOL(bgx_set_lmac_mac);
189
192
void bgx_lmac_rx_tx_enable (int node , int bgx_idx , int lmacid , bool enable )
190
193
{
191
194
struct bgx * bgx = bgx_vnic [(node * MAX_BGX_PER_CN88XX ) + bgx_idx ];
195
+ struct lmac * lmac ;
192
196
u64 cfg ;
193
197
194
198
if (!bgx )
195
199
return ;
200
+ lmac = & bgx -> lmac [lmacid ];
196
201
197
202
cfg = bgx_reg_read (bgx , lmacid , BGX_CMRX_CFG );
198
203
if (enable )
199
204
cfg |= CMR_PKT_RX_EN | CMR_PKT_TX_EN ;
200
205
else
201
206
cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN );
202
207
bgx_reg_write (bgx , lmacid , BGX_CMRX_CFG , cfg );
208
+
209
+ if (bgx -> is_rgx )
210
+ xcv_setup_link (enable ? lmac -> link_up : 0 , lmac -> last_speed );
203
211
}
204
212
EXPORT_SYMBOL (bgx_lmac_rx_tx_enable );
205
213
@@ -266,9 +274,12 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac)
266
274
267
275
port_cfg = bgx_reg_read (bgx , lmac -> lmacid , BGX_GMP_GMI_PRTX_CFG );
268
276
269
- /* renable lmac */
277
+ /* Re-enable lmac */
270
278
cmr_cfg |= CMR_EN ;
271
279
bgx_reg_write (bgx , lmac -> lmacid , BGX_CMRX_CFG , cmr_cfg );
280
+
281
+ if (bgx -> is_rgx && (cmr_cfg & (CMR_PKT_RX_EN | CMR_PKT_TX_EN )))
282
+ xcv_setup_link (lmac -> link_up , lmac -> last_speed );
272
283
}
273
284
274
285
static void bgx_lmac_handler (struct net_device * netdev )
@@ -418,10 +429,12 @@ static int bgx_lmac_sgmii_init(struct bgx *bgx, struct lmac *lmac)
418
429
return 0 ;
419
430
}
420
431
421
- if (bgx_poll_reg (bgx , lmacid , BGX_GMP_PCS_MRX_STATUS ,
422
- PCS_MRX_STATUS_AN_CPT , false)) {
423
- dev_err (& bgx -> pdev -> dev , "BGX AN_CPT not completed\n" );
424
- return -1 ;
432
+ if (lmac -> lmac_type == BGX_MODE_SGMII ) {
433
+ if (bgx_poll_reg (bgx , lmacid , BGX_GMP_PCS_MRX_STATUS ,
434
+ PCS_MRX_STATUS_AN_CPT , false)) {
435
+ dev_err (& bgx -> pdev -> dev , "BGX AN_CPT not completed\n" );
436
+ return -1 ;
437
+ }
425
438
}
426
439
427
440
return 0 ;
@@ -663,6 +676,8 @@ static int phy_interface_mode(u8 lmac_type)
663
676
{
664
677
if (lmac_type == BGX_MODE_QSGMII )
665
678
return PHY_INTERFACE_MODE_QSGMII ;
679
+ if (lmac_type == BGX_MODE_RGMII )
680
+ return PHY_INTERFACE_MODE_RGMII ;
666
681
667
682
return PHY_INTERFACE_MODE_SGMII ;
668
683
}
@@ -676,7 +691,8 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
676
691
lmac -> bgx = bgx ;
677
692
678
693
if ((lmac -> lmac_type == BGX_MODE_SGMII ) ||
679
- (lmac -> lmac_type == BGX_MODE_QSGMII )) {
694
+ (lmac -> lmac_type == BGX_MODE_QSGMII ) ||
695
+ (lmac -> lmac_type == BGX_MODE_RGMII )) {
680
696
lmac -> is_sgmii = 1 ;
681
697
if (bgx_lmac_sgmii_init (bgx , lmac ))
682
698
return -1 ;
@@ -829,7 +845,7 @@ static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid)
829
845
char str [20 ];
830
846
u8 dlm ;
831
847
832
- if (lmacid > MAX_LMAC_PER_BGX )
848
+ if (lmacid > bgx -> max_lmac )
833
849
return ;
834
850
835
851
lmac = & bgx -> lmac [lmacid ];
@@ -870,6 +886,9 @@ static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid)
870
886
return ;
871
887
dev_info (dev , "%s: QSGMII\n" , (char * )str );
872
888
break ;
889
+ case BGX_MODE_RGMII :
890
+ dev_info (dev , "%s: RGMII\n" , (char * )str );
891
+ break ;
873
892
case BGX_MODE_INVALID :
874
893
/* Nothing to do */
875
894
break ;
@@ -885,6 +904,7 @@ static void lmac_set_lane2sds(struct bgx *bgx, struct lmac *lmac)
885
904
break ;
886
905
case BGX_MODE_XAUI :
887
906
case BGX_MODE_XLAUI :
907
+ case BGX_MODE_RGMII :
888
908
lmac -> lane_to_sds = 0xE4 ;
889
909
break ;
890
910
case BGX_MODE_RXAUI :
@@ -904,6 +924,18 @@ static void lmac_set_lane2sds(struct bgx *bgx, struct lmac *lmac)
904
924
}
905
925
}
906
926
927
+ static void lmac_set_training (struct bgx * bgx , struct lmac * lmac , int lmacid )
928
+ {
929
+ if ((lmac -> lmac_type != BGX_MODE_10G_KR ) &&
930
+ (lmac -> lmac_type != BGX_MODE_40G_KR )) {
931
+ lmac -> use_training = 0 ;
932
+ return ;
933
+ }
934
+
935
+ lmac -> use_training = bgx_reg_read (bgx , lmacid , BGX_SPUX_BR_PMD_CRTL ) &
936
+ SPU_PMD_CRTL_TRAIN_EN ;
937
+ }
938
+
907
939
static void bgx_set_lmac_config (struct bgx * bgx , u8 idx )
908
940
{
909
941
struct lmac * lmac ;
@@ -914,15 +946,15 @@ static void bgx_set_lmac_config(struct bgx *bgx, u8 idx)
914
946
915
947
lmac = & bgx -> lmac [idx ];
916
948
917
- if (!bgx -> is_81xx ) {
949
+ if (!bgx -> is_81xx || bgx -> is_rgx ) {
918
950
/* Read LMAC0 type to figure out QLM mode
919
951
* This is configured by low level firmware
920
952
*/
921
953
cmr_cfg = bgx_reg_read (bgx , 0 , BGX_CMRX_CFG );
922
954
lmac -> lmac_type = (cmr_cfg >> 8 ) & 0x07 ;
923
- lmac -> use_training =
924
- bgx_reg_read ( bgx , 0 , BGX_SPUX_BR_PMD_CRTL ) &
925
- SPU_PMD_CRTL_TRAIN_EN ;
955
+ if ( bgx -> is_rgx )
956
+ lmac -> lmac_type = BGX_MODE_RGMII ;
957
+ lmac_set_training ( bgx , lmac , 0 ) ;
926
958
lmac_set_lane2sds (bgx , lmac );
927
959
return ;
928
960
}
@@ -939,17 +971,13 @@ static void bgx_set_lmac_config(struct bgx *bgx, u8 idx)
939
971
lmac -> lmac_type = BGX_MODE_INVALID ;
940
972
else
941
973
lmac -> lmac_type = lmac_type ;
942
- lmac -> use_training =
943
- bgx_reg_read (bgx , idx , BGX_SPUX_BR_PMD_CRTL ) &
944
- SPU_PMD_CRTL_TRAIN_EN ;
974
+ lmac_set_training (bgx , lmac , lmac -> lmacid );
945
975
lmac_set_lane2sds (bgx , lmac );
946
976
947
977
/* Set LMAC type of other lmac on same DLM i.e LMAC 1/3 */
948
978
olmac = & bgx -> lmac [idx + 1 ];
949
979
olmac -> lmac_type = lmac -> lmac_type ;
950
- olmac -> use_training =
951
- bgx_reg_read (bgx , idx + 1 , BGX_SPUX_BR_PMD_CRTL ) &
952
- SPU_PMD_CRTL_TRAIN_EN ;
980
+ lmac_set_training (bgx , olmac , olmac -> lmacid );
953
981
lmac_set_lane2sds (bgx , olmac );
954
982
}
955
983
}
@@ -976,21 +1004,22 @@ static void bgx_get_qlm_mode(struct bgx *bgx)
976
1004
u8 idx ;
977
1005
978
1006
/* Init all LMAC's type to invalid */
979
- for (idx = 0 ; idx < MAX_LMAC_PER_BGX ; idx ++ ) {
1007
+ for (idx = 0 ; idx < bgx -> max_lmac ; idx ++ ) {
980
1008
lmac = & bgx -> lmac [idx ];
981
- lmac -> lmac_type = BGX_MODE_INVALID ;
982
1009
lmac -> lmacid = idx ;
1010
+ lmac -> lmac_type = BGX_MODE_INVALID ;
1011
+ lmac -> use_training = false;
983
1012
}
984
1013
985
1014
/* It is assumed that low level firmware sets this value */
986
1015
bgx -> lmac_count = bgx_reg_read (bgx , 0 , BGX_CMR_RX_LMACS ) & 0x7 ;
987
- if (bgx -> lmac_count > MAX_LMAC_PER_BGX )
988
- bgx -> lmac_count = MAX_LMAC_PER_BGX ;
1016
+ if (bgx -> lmac_count > bgx -> max_lmac )
1017
+ bgx -> lmac_count = bgx -> max_lmac ;
989
1018
990
- for (idx = 0 ; idx < MAX_LMAC_PER_BGX ; idx ++ )
1019
+ for (idx = 0 ; idx < bgx -> max_lmac ; idx ++ )
991
1020
bgx_set_lmac_config (bgx , idx );
992
1021
993
- if (!bgx -> is_81xx ) {
1022
+ if (!bgx -> is_81xx || bgx -> is_rgx ) {
994
1023
bgx_print_qlm_mode (bgx , 0 );
995
1024
return ;
996
1025
}
@@ -1140,7 +1169,7 @@ static int bgx_init_of_phy(struct bgx *bgx)
1140
1169
}
1141
1170
1142
1171
lmac ++ ;
1143
- if (lmac == MAX_LMAC_PER_BGX ) {
1172
+ if (lmac == bgx -> max_lmac ) {
1144
1173
of_node_put (node );
1145
1174
break ;
1146
1175
}
@@ -1218,10 +1247,22 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1218
1247
err = - ENOMEM ;
1219
1248
goto err_release_regions ;
1220
1249
}
1221
- bgx -> bgx_id = (pci_resource_start (pdev , PCI_CFG_REG_BAR_NUM ) >> 24 ) & 1 ;
1222
- bgx -> bgx_id += nic_get_node_id (pdev ) * MAX_BGX_PER_CN88XX ;
1223
1250
1224
- bgx_vnic [bgx -> bgx_id ] = bgx ;
1251
+ pci_read_config_word (pdev , PCI_DEVICE_ID , & sdevid );
1252
+ if (sdevid != PCI_DEVICE_ID_THUNDER_RGX ) {
1253
+ bgx -> bgx_id =
1254
+ (pci_resource_start (pdev , PCI_CFG_REG_BAR_NUM ) >> 24 ) & 1 ;
1255
+ bgx -> bgx_id += nic_get_node_id (pdev ) * MAX_BGX_PER_CN88XX ;
1256
+ bgx -> max_lmac = MAX_LMAC_PER_BGX ;
1257
+ bgx_vnic [bgx -> bgx_id ] = bgx ;
1258
+ } else {
1259
+ bgx -> is_rgx = true;
1260
+ bgx -> max_lmac = 1 ;
1261
+ bgx -> bgx_id = MAX_BGX_PER_CN81XX - 1 ;
1262
+ bgx_vnic [bgx -> bgx_id ] = bgx ;
1263
+ xcv_init_hw ();
1264
+ }
1265
+
1225
1266
bgx_get_qlm_mode (bgx );
1226
1267
1227
1268
err = bgx_init_phy (bgx );
0 commit comments