Skip to content

Commit 2e1c3ff

Browse files
Vadim Lomovtsevdavem330
authored andcommitted
net: thunderx: remove link change polling code and info from nicpf
Since link change polling routine was moved to nicvf side, we don't need anymore polling function at nicpf side along with link status info for all enabled Vfs as at VF side this info is already tracked. This commit is to remove unnecessary code & fields from nicpf structure. Signed-off-by: Vadim Lomovtsev <vlomovtsev@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2c632ad commit 2e1c3ff

File tree

1 file changed

+12
-102
lines changed

1 file changed

+12
-102
lines changed

drivers/net/ethernet/cavium/thunder/nic_main.c

Lines changed: 12 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@ struct nicpf {
5757
#define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF)
5858
#define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF)
5959
u8 *vf_lmac_map;
60-
struct delayed_work dwork;
61-
struct workqueue_struct *check_link;
62-
u8 *link;
63-
u8 *duplex;
64-
u32 *speed;
6560
u16 cpi_base[MAX_NUM_VFS_SUPPORTED];
6661
u16 rssi_base[MAX_NUM_VFS_SUPPORTED];
67-
bool mbx_lock[MAX_NUM_VFS_SUPPORTED];
6862

6963
/* MSI-X */
7064
u8 num_vec;
@@ -929,6 +923,10 @@ static void nic_config_timestamp(struct nicpf *nic, int vf, struct set_ptp *ptp)
929923
nic_reg_write(nic, NIC_PF_PKIND_0_15_CFG | (pkind_idx << 3), pkind_val);
930924
}
931925

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+
*/
932930
static void nic_link_status_get(struct nicpf *nic, u8 vf)
933931
{
934932
union nic_mbx mbx = {};
@@ -944,10 +942,6 @@ static void nic_link_status_get(struct nicpf *nic, u8 vf)
944942
/* Get interface link status */
945943
bgx_get_lmac_link_state(nic->node, bgx, lmac, &link);
946944

947-
nic->link[vf] = link.link_up;
948-
nic->duplex[vf] = link.duplex;
949-
nic->speed[vf] = link.speed;
950-
951945
/* Send a mbox message to VF with current link status */
952946
mbx.link_status.link_up = link.link_up;
953947
mbx.link_status.duplex = link.duplex;
@@ -970,8 +964,6 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
970964
int i;
971965
int ret = 0;
972966

973-
nic->mbx_lock[vf] = true;
974-
975967
mbx_addr = nic_get_mbx_addr(vf);
976968
mbx_data = (u64 *)&mbx;
977969

@@ -986,12 +978,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
986978
switch (mbx.msg.msg) {
987979
case NIC_MBOX_MSG_READY:
988980
nic_mbx_send_ready(nic, vf);
989-
if (vf < nic->num_vf_en) {
990-
nic->link[vf] = 0;
991-
nic->duplex[vf] = 0;
992-
nic->speed[vf] = 0;
993-
}
994-
goto unlock;
981+
return;
995982
case NIC_MBOX_MSG_QS_CFG:
996983
reg_addr = NIC_PF_QSET_0_127_CFG |
997984
(mbx.qs.num << NIC_QS_ID_SHIFT);
@@ -1060,7 +1047,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
10601047
break;
10611048
case NIC_MBOX_MSG_RSS_SIZE:
10621049
nic_send_rss_size(nic, vf);
1063-
goto unlock;
1050+
return;
10641051
case NIC_MBOX_MSG_RSS_CFG:
10651052
case NIC_MBOX_MSG_RSS_CFG_CONT:
10661053
nic_config_rss(nic, &mbx.rss_cfg);
@@ -1078,19 +1065,19 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
10781065
break;
10791066
case NIC_MBOX_MSG_ALLOC_SQS:
10801067
nic_alloc_sqs(nic, &mbx.sqs_alloc);
1081-
goto unlock;
1068+
return;
10821069
case NIC_MBOX_MSG_NICVF_PTR:
10831070
nic->nicvf[vf] = mbx.nicvf.nicvf;
10841071
break;
10851072
case NIC_MBOX_MSG_PNICVF_PTR:
10861073
nic_send_pnicvf(nic, vf);
1087-
goto unlock;
1074+
return;
10881075
case NIC_MBOX_MSG_SNICVF_PTR:
10891076
nic_send_snicvf(nic, &mbx.nicvf);
1090-
goto unlock;
1077+
return;
10911078
case NIC_MBOX_MSG_BGX_STATS:
10921079
nic_get_bgx_stats(nic, &mbx.bgx_stats);
1093-
goto unlock;
1080+
return;
10941081
case NIC_MBOX_MSG_LOOPBACK:
10951082
ret = nic_config_loopback(nic, &mbx.lbk);
10961083
break;
@@ -1099,7 +1086,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
10991086
break;
11001087
case NIC_MBOX_MSG_PFC:
11011088
nic_pause_frame(nic, vf, &mbx.pfc);
1102-
goto unlock;
1089+
return;
11031090
case NIC_MBOX_MSG_PTP_CFG:
11041091
nic_config_timestamp(nic, vf, &mbx.ptp);
11051092
break;
@@ -1143,7 +1130,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
11431130
break;
11441131
}
11451132
nic_link_status_get(nic, vf);
1146-
goto unlock;
1133+
return;
11471134
default:
11481135
dev_err(&nic->pdev->dev,
11491136
"Invalid msg from VF%d, msg 0x%x\n", vf, mbx.msg.msg);
@@ -1157,8 +1144,6 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
11571144
mbx.msg.msg, vf);
11581145
nic_mbx_send_nack(nic, vf);
11591146
}
1160-
unlock:
1161-
nic->mbx_lock[vf] = false;
11621147
}
11631148

11641149
static irqreturn_t nic_mbx_intr_handler(int irq, void *nic_irq)
@@ -1306,52 +1291,6 @@ static int nic_sriov_init(struct pci_dev *pdev, struct nicpf *nic)
13061291
return 0;
13071292
}
13081293

1309-
/* Poll for BGX LMAC link status and update corresponding VF
1310-
* if there is a change, valid only if internal L2 switch
1311-
* is not present otherwise VF link is always treated as up
1312-
*/
1313-
static void nic_poll_for_link(struct work_struct *work)
1314-
{
1315-
union nic_mbx mbx = {};
1316-
struct nicpf *nic;
1317-
struct bgx_link_status link;
1318-
u8 vf, bgx, lmac;
1319-
1320-
nic = container_of(work, struct nicpf, dwork.work);
1321-
1322-
mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE;
1323-
1324-
for (vf = 0; vf < nic->num_vf_en; vf++) {
1325-
/* Poll only if VF is UP */
1326-
if (!nic->vf_enabled[vf])
1327-
continue;
1328-
1329-
/* Get BGX, LMAC indices for the VF */
1330-
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
1331-
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
1332-
/* Get interface link status */
1333-
bgx_get_lmac_link_state(nic->node, bgx, lmac, &link);
1334-
1335-
/* Inform VF only if link status changed */
1336-
if (nic->link[vf] == link.link_up)
1337-
continue;
1338-
1339-
if (!nic->mbx_lock[vf]) {
1340-
nic->link[vf] = link.link_up;
1341-
nic->duplex[vf] = link.duplex;
1342-
nic->speed[vf] = link.speed;
1343-
1344-
/* Send a mbox message to VF with current link status */
1345-
mbx.link_status.link_up = link.link_up;
1346-
mbx.link_status.duplex = link.duplex;
1347-
mbx.link_status.speed = link.speed;
1348-
mbx.link_status.mac_type = link.mac_type;
1349-
nic_send_msg_to_vf(nic, vf, &mbx);
1350-
}
1351-
}
1352-
queue_delayed_work(nic->check_link, &nic->dwork, HZ * 2);
1353-
}
1354-
13551294
static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
13561295
{
13571296
struct device *dev = &pdev->dev;
@@ -1420,18 +1359,6 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
14201359
if (!nic->vf_lmac_map)
14211360
goto err_release_regions;
14221361

1423-
nic->link = devm_kmalloc_array(dev, max_lmac, sizeof(u8), GFP_KERNEL);
1424-
if (!nic->link)
1425-
goto err_release_regions;
1426-
1427-
nic->duplex = devm_kmalloc_array(dev, max_lmac, sizeof(u8), GFP_KERNEL);
1428-
if (!nic->duplex)
1429-
goto err_release_regions;
1430-
1431-
nic->speed = devm_kmalloc_array(dev, max_lmac, sizeof(u32), GFP_KERNEL);
1432-
if (!nic->speed)
1433-
goto err_release_regions;
1434-
14351362
/* Initialize hardware */
14361363
nic_init_hw(nic);
14371364

@@ -1447,19 +1374,8 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
14471374
if (err)
14481375
goto err_unregister_interrupts;
14491376

1450-
/* Register a physical link status poll fn() */
1451-
nic->check_link = alloc_workqueue("check_link_status",
1452-
WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
1453-
if (!nic->check_link) {
1454-
err = -ENOMEM;
1455-
goto err_disable_sriov;
1456-
}
1457-
14581377
return 0;
14591378

1460-
err_disable_sriov:
1461-
if (nic->flags & NIC_SRIOV_ENABLED)
1462-
pci_disable_sriov(pdev);
14631379
err_unregister_interrupts:
14641380
nic_unregister_interrupts(nic);
14651381
err_release_regions:
@@ -1480,12 +1396,6 @@ static void nic_remove(struct pci_dev *pdev)
14801396
if (nic->flags & NIC_SRIOV_ENABLED)
14811397
pci_disable_sriov(pdev);
14821398

1483-
if (nic->check_link) {
1484-
/* Destroy work Queue */
1485-
cancel_delayed_work_sync(&nic->dwork);
1486-
destroy_workqueue(nic->check_link);
1487-
}
1488-
14891399
nic_unregister_interrupts(nic);
14901400
pci_release_regions(pdev);
14911401

0 commit comments

Comments
 (0)