@@ -57,14 +57,8 @@ struct nicpf {
57
57
#define NIC_GET_BGX_FROM_VF_LMAC_MAP (map ) ((map >> 4) & 0xF)
58
58
#define NIC_GET_LMAC_FROM_VF_LMAC_MAP (map ) (map & 0xF)
59
59
u8 * vf_lmac_map ;
60
- struct delayed_work dwork ;
61
- struct workqueue_struct * check_link ;
62
- u8 * link ;
63
- u8 * duplex ;
64
- u32 * speed ;
65
60
u16 cpi_base [MAX_NUM_VFS_SUPPORTED ];
66
61
u16 rssi_base [MAX_NUM_VFS_SUPPORTED ];
67
- bool mbx_lock [MAX_NUM_VFS_SUPPORTED ];
68
62
69
63
/* MSI-X */
70
64
u8 num_vec ;
@@ -929,6 +923,35 @@ static void nic_config_timestamp(struct nicpf *nic, int vf, struct set_ptp *ptp)
929
923
nic_reg_write (nic , NIC_PF_PKIND_0_15_CFG | (pkind_idx << 3 ), pkind_val );
930
924
}
931
925
926
+ /* Get BGX LMAC link status and update corresponding VF
927
+ * if there is a change, valid only if internal L2 switch
928
+ * is not present otherwise VF link is always treated as up
929
+ */
930
+ static void nic_link_status_get (struct nicpf * nic , u8 vf )
931
+ {
932
+ union nic_mbx mbx = {};
933
+ struct bgx_link_status link ;
934
+ u8 bgx , lmac ;
935
+
936
+ mbx .link_status .msg = NIC_MBOX_MSG_BGX_LINK_CHANGE ;
937
+
938
+ /* Get BGX, LMAC indices for the VF */
939
+ bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
940
+ lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
941
+
942
+ /* Get interface link status */
943
+ bgx_get_lmac_link_state (nic -> node , bgx , lmac , & link );
944
+
945
+ /* Send a mbox message to VF with current link status */
946
+ mbx .link_status .link_up = link .link_up ;
947
+ mbx .link_status .duplex = link .duplex ;
948
+ mbx .link_status .speed = link .speed ;
949
+ mbx .link_status .mac_type = link .mac_type ;
950
+
951
+ /* reply with link status */
952
+ nic_send_msg_to_vf (nic , vf , & mbx );
953
+ }
954
+
932
955
/* Interrupt handler to handle mailbox messages from VFs */
933
956
static void nic_handle_mbx_intr (struct nicpf * nic , int vf )
934
957
{
@@ -941,8 +964,6 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
941
964
int i ;
942
965
int ret = 0 ;
943
966
944
- nic -> mbx_lock [vf ] = true;
945
-
946
967
mbx_addr = nic_get_mbx_addr (vf );
947
968
mbx_data = (u64 * )& mbx ;
948
969
@@ -957,12 +978,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
957
978
switch (mbx .msg .msg ) {
958
979
case NIC_MBOX_MSG_READY :
959
980
nic_mbx_send_ready (nic , vf );
960
- if (vf < nic -> num_vf_en ) {
961
- nic -> link [vf ] = 0 ;
962
- nic -> duplex [vf ] = 0 ;
963
- nic -> speed [vf ] = 0 ;
964
- }
965
- goto unlock ;
981
+ return ;
966
982
case NIC_MBOX_MSG_QS_CFG :
967
983
reg_addr = NIC_PF_QSET_0_127_CFG |
968
984
(mbx .qs .num << NIC_QS_ID_SHIFT );
@@ -1031,15 +1047,15 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
1031
1047
break ;
1032
1048
case NIC_MBOX_MSG_RSS_SIZE :
1033
1049
nic_send_rss_size (nic , vf );
1034
- goto unlock ;
1050
+ return ;
1035
1051
case NIC_MBOX_MSG_RSS_CFG :
1036
1052
case NIC_MBOX_MSG_RSS_CFG_CONT :
1037
1053
nic_config_rss (nic , & mbx .rss_cfg );
1038
1054
break ;
1039
1055
case NIC_MBOX_MSG_CFG_DONE :
1040
1056
/* Last message of VF config msg sequence */
1041
1057
nic_enable_vf (nic , vf , true);
1042
- goto unlock ;
1058
+ break ;
1043
1059
case NIC_MBOX_MSG_SHUTDOWN :
1044
1060
/* First msg in VF teardown sequence */
1045
1061
if (vf >= nic -> num_vf_en )
@@ -1049,19 +1065,19 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
1049
1065
break ;
1050
1066
case NIC_MBOX_MSG_ALLOC_SQS :
1051
1067
nic_alloc_sqs (nic , & mbx .sqs_alloc );
1052
- goto unlock ;
1068
+ return ;
1053
1069
case NIC_MBOX_MSG_NICVF_PTR :
1054
1070
nic -> nicvf [vf ] = mbx .nicvf .nicvf ;
1055
1071
break ;
1056
1072
case NIC_MBOX_MSG_PNICVF_PTR :
1057
1073
nic_send_pnicvf (nic , vf );
1058
- goto unlock ;
1074
+ return ;
1059
1075
case NIC_MBOX_MSG_SNICVF_PTR :
1060
1076
nic_send_snicvf (nic , & mbx .nicvf );
1061
- goto unlock ;
1077
+ return ;
1062
1078
case NIC_MBOX_MSG_BGX_STATS :
1063
1079
nic_get_bgx_stats (nic , & mbx .bgx_stats );
1064
- goto unlock ;
1080
+ return ;
1065
1081
case NIC_MBOX_MSG_LOOPBACK :
1066
1082
ret = nic_config_loopback (nic , & mbx .lbk );
1067
1083
break ;
@@ -1070,7 +1086,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
1070
1086
break ;
1071
1087
case NIC_MBOX_MSG_PFC :
1072
1088
nic_pause_frame (nic , vf , & mbx .pfc );
1073
- goto unlock ;
1089
+ return ;
1074
1090
case NIC_MBOX_MSG_PTP_CFG :
1075
1091
nic_config_timestamp (nic , vf , & mbx .ptp );
1076
1092
break ;
@@ -1094,7 +1110,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
1094
1110
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
1095
1111
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
1096
1112
bgx_set_dmac_cam_filter (nic -> node , bgx , lmac ,
1097
- mbx .xcast .data . mac ,
1113
+ mbx .xcast .mac ,
1098
1114
vf < NIC_VF_PER_MBX_REG ? vf :
1099
1115
vf - NIC_VF_PER_MBX_REG );
1100
1116
break ;
@@ -1106,8 +1122,15 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
1106
1122
}
1107
1123
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
1108
1124
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
1109
- bgx_set_xcast_mode (nic -> node , bgx , lmac , mbx .xcast .data . mode );
1125
+ bgx_set_xcast_mode (nic -> node , bgx , lmac , mbx .xcast .mode );
1110
1126
break ;
1127
+ case NIC_MBOX_MSG_BGX_LINK_CHANGE :
1128
+ if (vf >= nic -> num_vf_en ) {
1129
+ ret = -1 ; /* NACK */
1130
+ break ;
1131
+ }
1132
+ nic_link_status_get (nic , vf );
1133
+ return ;
1111
1134
default :
1112
1135
dev_err (& nic -> pdev -> dev ,
1113
1136
"Invalid msg from VF%d, msg 0x%x\n" , vf , mbx .msg .msg );
@@ -1121,8 +1144,6 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
1121
1144
mbx .msg .msg , vf );
1122
1145
nic_mbx_send_nack (nic , vf );
1123
1146
}
1124
- unlock :
1125
- nic -> mbx_lock [vf ] = false;
1126
1147
}
1127
1148
1128
1149
static irqreturn_t nic_mbx_intr_handler (int irq , void * nic_irq )
@@ -1270,52 +1291,6 @@ static int nic_sriov_init(struct pci_dev *pdev, struct nicpf *nic)
1270
1291
return 0 ;
1271
1292
}
1272
1293
1273
- /* Poll for BGX LMAC link status and update corresponding VF
1274
- * if there is a change, valid only if internal L2 switch
1275
- * is not present otherwise VF link is always treated as up
1276
- */
1277
- static void nic_poll_for_link (struct work_struct * work )
1278
- {
1279
- union nic_mbx mbx = {};
1280
- struct nicpf * nic ;
1281
- struct bgx_link_status link ;
1282
- u8 vf , bgx , lmac ;
1283
-
1284
- nic = container_of (work , struct nicpf , dwork .work );
1285
-
1286
- mbx .link_status .msg = NIC_MBOX_MSG_BGX_LINK_CHANGE ;
1287
-
1288
- for (vf = 0 ; vf < nic -> num_vf_en ; vf ++ ) {
1289
- /* Poll only if VF is UP */
1290
- if (!nic -> vf_enabled [vf ])
1291
- continue ;
1292
-
1293
- /* Get BGX, LMAC indices for the VF */
1294
- bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
1295
- lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP (nic -> vf_lmac_map [vf ]);
1296
- /* Get interface link status */
1297
- bgx_get_lmac_link_state (nic -> node , bgx , lmac , & link );
1298
-
1299
- /* Inform VF only if link status changed */
1300
- if (nic -> link [vf ] == link .link_up )
1301
- continue ;
1302
-
1303
- if (!nic -> mbx_lock [vf ]) {
1304
- nic -> link [vf ] = link .link_up ;
1305
- nic -> duplex [vf ] = link .duplex ;
1306
- nic -> speed [vf ] = link .speed ;
1307
-
1308
- /* Send a mbox message to VF with current link status */
1309
- mbx .link_status .link_up = link .link_up ;
1310
- mbx .link_status .duplex = link .duplex ;
1311
- mbx .link_status .speed = link .speed ;
1312
- mbx .link_status .mac_type = link .mac_type ;
1313
- nic_send_msg_to_vf (nic , vf , & mbx );
1314
- }
1315
- }
1316
- queue_delayed_work (nic -> check_link , & nic -> dwork , HZ * 2 );
1317
- }
1318
-
1319
1294
static int nic_probe (struct pci_dev * pdev , const struct pci_device_id * ent )
1320
1295
{
1321
1296
struct device * dev = & pdev -> dev ;
@@ -1384,18 +1359,6 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1384
1359
if (!nic -> vf_lmac_map )
1385
1360
goto err_release_regions ;
1386
1361
1387
- nic -> link = devm_kmalloc_array (dev , max_lmac , sizeof (u8 ), GFP_KERNEL );
1388
- if (!nic -> link )
1389
- goto err_release_regions ;
1390
-
1391
- nic -> duplex = devm_kmalloc_array (dev , max_lmac , sizeof (u8 ), GFP_KERNEL );
1392
- if (!nic -> duplex )
1393
- goto err_release_regions ;
1394
-
1395
- nic -> speed = devm_kmalloc_array (dev , max_lmac , sizeof (u32 ), GFP_KERNEL );
1396
- if (!nic -> speed )
1397
- goto err_release_regions ;
1398
-
1399
1362
/* Initialize hardware */
1400
1363
nic_init_hw (nic );
1401
1364
@@ -1411,22 +1374,8 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1411
1374
if (err )
1412
1375
goto err_unregister_interrupts ;
1413
1376
1414
- /* Register a physical link status poll fn() */
1415
- nic -> check_link = alloc_workqueue ("check_link_status" ,
1416
- WQ_UNBOUND | WQ_MEM_RECLAIM , 1 );
1417
- if (!nic -> check_link ) {
1418
- err = - ENOMEM ;
1419
- goto err_disable_sriov ;
1420
- }
1421
-
1422
- INIT_DELAYED_WORK (& nic -> dwork , nic_poll_for_link );
1423
- queue_delayed_work (nic -> check_link , & nic -> dwork , 0 );
1424
-
1425
1377
return 0 ;
1426
1378
1427
- err_disable_sriov :
1428
- if (nic -> flags & NIC_SRIOV_ENABLED )
1429
- pci_disable_sriov (pdev );
1430
1379
err_unregister_interrupts :
1431
1380
nic_unregister_interrupts (nic );
1432
1381
err_release_regions :
@@ -1447,12 +1396,6 @@ static void nic_remove(struct pci_dev *pdev)
1447
1396
if (nic -> flags & NIC_SRIOV_ENABLED )
1448
1397
pci_disable_sriov (pdev );
1449
1398
1450
- if (nic -> check_link ) {
1451
- /* Destroy work Queue */
1452
- cancel_delayed_work_sync (& nic -> dwork );
1453
- destroy_workqueue (nic -> check_link );
1454
- }
1455
-
1456
1399
nic_unregister_interrupts (nic );
1457
1400
pci_release_regions (pdev );
1458
1401
0 commit comments