Skip to content

Commit 1924136

Browse files
Jeffrey Huangdavem330
authored andcommitted
bnxt_en: Send PF driver unload notification to all VFs.
During remove_one() when SRIOV is enabled, the PF driver should broadcast PF driver unload notification to all VFs that are attached to VMs. Upon receiving the PF driver unload notification, the VF driver should print a warning message to message log. Certain operations on the VF may not succeed after the PF has unloaded. Signed-off-by: Jeffrey Huang <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3874d6a commit 1924136

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,13 +1239,17 @@ static int bnxt_async_event_process(struct bnxt *bp,
12391239
switch (event_id) {
12401240
case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
12411241
set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event);
1242-
schedule_work(&bp->sp_task);
1242+
break;
1243+
case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD:
1244+
set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event);
12431245
break;
12441246
default:
12451247
netdev_err(bp->dev, "unhandled ASYNC event (id 0x%x)\n",
12461248
event_id);
1247-
break;
1249+
goto async_event_process_exit;
12481250
}
1251+
schedule_work(&bp->sp_task);
1252+
async_event_process_exit:
12491253
return 0;
12501254
}
12511255

@@ -5559,6 +5563,8 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
55595563
}
55605564
}
55615565
}
5566+
if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event))
5567+
netdev_info(bp->dev, "Receive PF driver unload event!");
55625568
}
55635569

55645570
#else

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ struct bnxt {
986986
#define BNXT_VXLAN_DEL_PORT_SP_EVENT 5
987987
#define BNXT_RESET_TASK_SP_EVENT 6
988988
#define BNXT_RST_RING_SP_EVENT 7
989+
#define BNXT_HWRM_PF_UNLOAD_SP_EVENT 8
989990

990991
struct bnxt_pf_info pf;
991992
#ifdef CONFIG_BNXT_SRIOV

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,46 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
522522
return rc;
523523
}
524524

525+
static int bnxt_hwrm_fwd_async_event_cmpl(struct bnxt *bp,
526+
struct bnxt_vf_info *vf,
527+
u16 event_id)
528+
{
529+
int rc = 0;
530+
struct hwrm_fwd_async_event_cmpl_input req = {0};
531+
struct hwrm_fwd_async_event_cmpl_output *resp = bp->hwrm_cmd_resp_addr;
532+
struct hwrm_async_event_cmpl *async_cmpl;
533+
534+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FWD_ASYNC_EVENT_CMPL, -1, -1);
535+
if (vf)
536+
req.encap_async_event_target_id = cpu_to_le16(vf->fw_fid);
537+
else
538+
/* broadcast this async event to all VFs */
539+
req.encap_async_event_target_id = cpu_to_le16(0xffff);
540+
async_cmpl = (struct hwrm_async_event_cmpl *)req.encap_async_event_cmpl;
541+
async_cmpl->type =
542+
cpu_to_le16(HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT);
543+
async_cmpl->event_id = cpu_to_le16(event_id);
544+
545+
mutex_lock(&bp->hwrm_cmd_lock);
546+
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
547+
548+
if (rc) {
549+
netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl failed. rc:%d\n",
550+
rc);
551+
goto fwd_async_event_cmpl_exit;
552+
}
553+
554+
if (resp->error_code) {
555+
netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl error %d\n",
556+
resp->error_code);
557+
rc = -1;
558+
}
559+
560+
fwd_async_event_cmpl_exit:
561+
mutex_unlock(&bp->hwrm_cmd_lock);
562+
return rc;
563+
}
564+
525565
void bnxt_sriov_disable(struct bnxt *bp)
526566
{
527567
u16 num_vfs = pci_num_vf(bp->pdev);
@@ -530,6 +570,9 @@ void bnxt_sriov_disable(struct bnxt *bp)
530570
return;
531571

532572
if (pci_vfs_assigned(bp->pdev)) {
573+
bnxt_hwrm_fwd_async_event_cmpl(
574+
bp, NULL,
575+
HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD);
533576
netdev_warn(bp->dev, "Unable to free %d VFs because some are assigned to VMs.\n",
534577
num_vfs);
535578
} else {

0 commit comments

Comments
 (0)