Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78c3bcc5 authored by Ariel Elior's avatar Ariel Elior Committed by David S. Miller
Browse files

bnx2x: Improve PF behaviour toward VF



If PF is unloaded with loaded VFs, signal towards VFs so they can detect
this gracefully.

Signed-off-by: default avatarAriel Elior <ariele@broadcom.com>
Signed-off-by: default avatarYuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: default avatarEilon Greenstein <eilong@broadcom.com>
----
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h       |  2 ++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c   |  3 +++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 23 +++++++++++++++++++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 24 ++++++++++++++++++++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h |  2 ++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c  | 12 +++++++++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h  |  5 ++++-
 7 files changed, 63 insertions(+), 8 deletions(-)
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a49dd9dc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1330,6 +1330,7 @@ enum {
	BNX2X_SP_RTNL_AFEX_F_UPDATE,
	BNX2X_SP_RTNL_ENABLE_SRIOV,
	BNX2X_SP_RTNL_VFPF_MCAST,
	BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
	BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
	BNX2X_SP_RTNL_HYPERVISOR_VLAN,
};
@@ -1500,6 +1501,7 @@ struct bnx2x {
#define USING_SINGLE_MSIX_FLAG		(1 << 20)
#define BC_SUPPORTS_DCBX_MSG_NON_PMF	(1 << 21)
#define IS_VF_FLAG			(1 << 22)
#define INTERRUPTS_ENABLED_FLAG		(1 << 23)

#define BP_NOMCP(bp)			((bp)->flags & NO_MCP_FLAG)

+3 −0
Original line number Diff line number Diff line
@@ -2871,6 +2871,9 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
	bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT;
	smp_mb();

	/* indicate to VFs that the PF is going down */
	bnx2x_iov_channel_down(bp);

	if (CNIC_LOADED(bp))
		bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);

+20 −3
Original line number Diff line number Diff line
@@ -5457,9 +5457,19 @@ static void bnx2x_timer(unsigned long data)
		bnx2x_stats_handle(bp, STATS_EVENT_UPDATE);

	/* sample pf vf bulletin board for new posts from pf */
	if (IS_VF(bp))
	if (IS_VF(bp)) {
		bnx2x_sample_bulletin(bp);

		/* if channel is down we need to self destruct */
		if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
			smp_mb__before_clear_bit();
			set_bit(BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
				&bp->sp_rtnl_state);
			smp_mb__after_clear_bit();
			schedule_delayed_work(&bp->sp_rtnl_task, 0);
		}
	}

	mod_timer(&bp->timer, jiffies + bp->current_interval);
}

@@ -9620,6 +9630,13 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
		   "sending set mcast vf pf channel message from rtnl sp-task\n");
		bnx2x_vfpf_set_mcast(bp->dev);
	}
	if (test_and_clear_bit(BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
			       &bp->sp_rtnl_state)){
		if (!test_bit(__LINK_STATE_NOCARRIER, &bp->dev->state)) {
			bnx2x_tx_disable(bp);
			BNX2X_ERR("PF indicated channel is not servicable anymore. This means this VF device is no longer operational\n");
		}
	}

	if (test_and_clear_bit(BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
			       &bp->sp_rtnl_state)) {
@@ -12814,6 +12831,8 @@ static void __bnx2x_remove(struct pci_dev *pdev,
		rtnl_unlock();
	}

	bnx2x_iov_remove_one(bp);

	/* Power on: we can't let PCI layer write to us while we are in D3 */
	if (IS_PF(bp))
		bnx2x_set_power_state(bp, PCI_D0);
@@ -12828,8 +12847,6 @@ static void __bnx2x_remove(struct pci_dev *pdev,
	/* Make sure RESET task is not scheduled before continuing */
	cancel_delayed_work_sync(&bp->sp_rtnl_task);

	bnx2x_iov_remove_one(bp);

	/* send message via vfpf channel to release the resources of this vf */
	if (IS_VF(bp))
		bnx2x_vfpf_release(bp);
+21 −3
Original line number Diff line number Diff line
@@ -1459,13 +1459,11 @@ static u8 bnx2x_vf_is_pcie_pending(struct bnx2x *bp, u8 abs_vfid)
	struct bnx2x_virtf *vf = bnx2x_vf_by_abs_fid(bp, abs_vfid);

	if (!vf)
		goto unknown_dev;
		return false;

	dev = pci_get_bus_and_slot(vf->bus, vf->devfn);
	if (dev)
		return bnx2x_is_pcie_pending(dev);

unknown_dev:
	return false;
}

@@ -3469,3 +3467,23 @@ int bnx2x_open_epilog(struct bnx2x *bp)

	return 0;
}

void bnx2x_iov_channel_down(struct bnx2x *bp)
{
	int vf_idx;
	struct pf_vf_bulletin_content *bulletin;

	if (!IS_SRIOV(bp))
		return;

	for_each_vf(bp, vf_idx) {
		/* locate this VFs bulletin board and update the channel down
		 * bit
		 */
		bulletin = BP_VF_BULLETIN(bp, vf_idx);
		bulletin->valid_bitmap |= 1 << CHANNEL_DOWN;

		/* update vf bulletin board */
		bnx2x_post_vf_bulletin(bp, vf_idx);
	}
}
+2 −0
Original line number Diff line number Diff line
@@ -761,6 +761,7 @@ static inline int bnx2x_vf_headroom(struct bnx2x *bp)
}
void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp);
int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs);
void bnx2x_iov_channel_down(struct bnx2x *bp);
int bnx2x_open_epilog(struct bnx2x *bp);

#else /* CONFIG_BNX2X_SRIOV */
@@ -817,6 +818,7 @@ static inline void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; }
static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {}
static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; }
static inline void bnx2x_iov_channel_down(struct bnx2x *bp) {}
static inline int bnx2x_open_epilog(struct bnx2x *bp) {return 0; }

#endif /* CONFIG_BNX2X_SRIOV */
Loading