Commit 6051cba7 authored by Sunil Goutham's avatar Sunil Goutham Committed by David S. Miller

net: thunderx: mailboxes: remove code duplication

Use the nicvf_send_msg_to_pf() function in the mailbox code.
Signed-off-by: default avatarSunil Goutham <sgoutham@cavium.com>
Signed-off-by: default avatarRobert Richter <rrichter@cavium.com>
Signed-off-by: default avatarAleksey Makarov <aleksey.makarov@caviumnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2dc5ded
...@@ -295,10 +295,9 @@ struct nicvf { ...@@ -295,10 +295,9 @@ struct nicvf {
char irq_name[NIC_VF_MSIX_VECTORS][20]; char irq_name[NIC_VF_MSIX_VECTORS][20];
bool irq_allocated[NIC_VF_MSIX_VECTORS]; bool irq_allocated[NIC_VF_MSIX_VECTORS];
bool pf_ready_to_rcv_msg; /* VF <-> PF mailbox communication */
bool pf_acked; bool pf_acked;
bool pf_nacked; bool pf_nacked;
bool bgx_stats_acked;
bool set_mac_pending; bool set_mac_pending;
} ____cacheline_aligned_in_smp; } ____cacheline_aligned_in_smp;
......
...@@ -105,7 +105,6 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, u64 offset, u64 qidx) ...@@ -105,7 +105,6 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, u64 offset, u64 qidx)
} }
/* VF -> PF mailbox communication */ /* VF -> PF mailbox communication */
static void nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx) static void nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx)
{ {
u64 *msg = (u64 *)mbx; u64 *msg = (u64 *)mbx;
...@@ -147,26 +146,15 @@ int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx) ...@@ -147,26 +146,15 @@ int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx)
*/ */
static int nicvf_check_pf_ready(struct nicvf *nic) static int nicvf_check_pf_ready(struct nicvf *nic)
{ {
int timeout = 5000, sleep = 20;
union nic_mbx mbx = {}; union nic_mbx mbx = {};
mbx.msg.msg = NIC_MBOX_MSG_READY; mbx.msg.msg = NIC_MBOX_MSG_READY;
if (nicvf_send_msg_to_pf(nic, &mbx)) {
nic->pf_ready_to_rcv_msg = false;
nicvf_write_to_mbx(nic, &mbx);
while (!nic->pf_ready_to_rcv_msg) {
msleep(sleep);
if (nic->pf_ready_to_rcv_msg)
break;
timeout -= sleep;
if (!timeout) {
netdev_err(nic->netdev, netdev_err(nic->netdev,
"PF didn't respond to READY msg\n"); "PF didn't respond to READY msg\n");
return 0; return 0;
} }
}
return 1; return 1;
} }
...@@ -197,7 +185,7 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic) ...@@ -197,7 +185,7 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic)
netdev_dbg(nic->netdev, "Mbox message: msg: 0x%x\n", mbx.msg.msg); netdev_dbg(nic->netdev, "Mbox message: msg: 0x%x\n", mbx.msg.msg);
switch (mbx.msg.msg) { switch (mbx.msg.msg) {
case NIC_MBOX_MSG_READY: case NIC_MBOX_MSG_READY:
nic->pf_ready_to_rcv_msg = true; nic->pf_acked = true;
nic->vf_id = mbx.nic_cfg.vf_id & 0x7F; nic->vf_id = mbx.nic_cfg.vf_id & 0x7F;
nic->tns_mode = mbx.nic_cfg.tns_mode & 0x7F; nic->tns_mode = mbx.nic_cfg.tns_mode & 0x7F;
nic->node = mbx.nic_cfg.node_id; nic->node = mbx.nic_cfg.node_id;
...@@ -221,7 +209,6 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic) ...@@ -221,7 +209,6 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic)
case NIC_MBOX_MSG_BGX_STATS: case NIC_MBOX_MSG_BGX_STATS:
nicvf_read_bgx_stats(nic, &mbx.bgx_stats); nicvf_read_bgx_stats(nic, &mbx.bgx_stats);
nic->pf_acked = true; nic->pf_acked = true;
nic->bgx_stats_acked = true;
break; break;
case NIC_MBOX_MSG_BGX_LINK_CHANGE: case NIC_MBOX_MSG_BGX_LINK_CHANGE:
nic->pf_acked = true; nic->pf_acked = true;
...@@ -1083,7 +1070,6 @@ void nicvf_update_lmac_stats(struct nicvf *nic) ...@@ -1083,7 +1070,6 @@ void nicvf_update_lmac_stats(struct nicvf *nic)
{ {
int stat = 0; int stat = 0;
union nic_mbx mbx = {}; union nic_mbx mbx = {};
int timeout;
if (!netif_running(nic->netdev)) if (!netif_running(nic->netdev))
return; return;
...@@ -1093,14 +1079,9 @@ void nicvf_update_lmac_stats(struct nicvf *nic) ...@@ -1093,14 +1079,9 @@ void nicvf_update_lmac_stats(struct nicvf *nic)
/* Rx stats */ /* Rx stats */
mbx.bgx_stats.rx = 1; mbx.bgx_stats.rx = 1;
while (stat < BGX_RX_STATS_COUNT) { while (stat < BGX_RX_STATS_COUNT) {
nic->bgx_stats_acked = 0;
mbx.bgx_stats.idx = stat; mbx.bgx_stats.idx = stat;
nicvf_send_msg_to_pf(nic, &mbx); if (nicvf_send_msg_to_pf(nic, &mbx))
timeout = 0; return;
while ((!nic->bgx_stats_acked) && (timeout < 10)) {
msleep(2);
timeout++;
}
stat++; stat++;
} }
...@@ -1109,14 +1090,9 @@ void nicvf_update_lmac_stats(struct nicvf *nic) ...@@ -1109,14 +1090,9 @@ void nicvf_update_lmac_stats(struct nicvf *nic)
/* Tx stats */ /* Tx stats */
mbx.bgx_stats.rx = 0; mbx.bgx_stats.rx = 0;
while (stat < BGX_TX_STATS_COUNT) { while (stat < BGX_TX_STATS_COUNT) {
nic->bgx_stats_acked = 0;
mbx.bgx_stats.idx = stat; mbx.bgx_stats.idx = stat;
nicvf_send_msg_to_pf(nic, &mbx); if (nicvf_send_msg_to_pf(nic, &mbx))
timeout = 0; return;
while ((!nic->bgx_stats_acked) && (timeout < 10)) {
msleep(2);
timeout++;
}
stat++; stat++;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment