Skip to content

Commit b0b02c7

Browse files
committed
Merge branch 'bnx2x'
Yuval Mintz says: ==================== This patch series mostly revolves around improving SR-IOV implementation (Better PF-VF relation, sanity checks and timings), as well as including a patch correcting the (outward) advertisement of 20G capabilities. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a49dd9d + b8e0d88 commit b0b02c7

File tree

7 files changed

+79
-11
lines changed

7 files changed

+79
-11
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ enum {
13301330
BNX2X_SP_RTNL_AFEX_F_UPDATE,
13311331
BNX2X_SP_RTNL_ENABLE_SRIOV,
13321332
BNX2X_SP_RTNL_VFPF_MCAST,
1333+
BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
13331334
BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
13341335
BNX2X_SP_RTNL_HYPERVISOR_VLAN,
13351336
};
@@ -1500,6 +1501,7 @@ struct bnx2x {
15001501
#define USING_SINGLE_MSIX_FLAG (1 << 20)
15011502
#define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21)
15021503
#define IS_VF_FLAG (1 << 22)
1504+
#define INTERRUPTS_ENABLED_FLAG (1 << 23)
15031505

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

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,6 +2871,9 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
28712871
bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT;
28722872
smp_mb();
28732873

2874+
/* indicate to VFs that the PF is going down */
2875+
bnx2x_iov_channel_down(bp);
2876+
28742877
if (CNIC_LOADED(bp))
28752878
bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);
28762879

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5457,9 +5457,19 @@ static void bnx2x_timer(unsigned long data)
54575457
bnx2x_stats_handle(bp, STATS_EVENT_UPDATE);
54585458

54595459
/* sample pf vf bulletin board for new posts from pf */
5460-
if (IS_VF(bp))
5460+
if (IS_VF(bp)) {
54615461
bnx2x_sample_bulletin(bp);
54625462

5463+
/* if channel is down we need to self destruct */
5464+
if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
5465+
smp_mb__before_clear_bit();
5466+
set_bit(BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
5467+
&bp->sp_rtnl_state);
5468+
smp_mb__after_clear_bit();
5469+
schedule_delayed_work(&bp->sp_rtnl_task, 0);
5470+
}
5471+
}
5472+
54635473
mod_timer(&bp->timer, jiffies + bp->current_interval);
54645474
}
54655475

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

96249641
if (test_and_clear_bit(BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
96259642
&bp->sp_rtnl_state)) {
@@ -10541,6 +10558,10 @@ static void bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg)
1054110558
if (!(bp->link_params.speed_cap_mask[idx] &
1054210559
PORT_HW_CFG_SPEED_CAPABILITY_D0_10G))
1054310560
bp->port.supported[idx] &= ~SUPPORTED_10000baseT_Full;
10561+
10562+
if (!(bp->link_params.speed_cap_mask[idx] &
10563+
PORT_HW_CFG_SPEED_CAPABILITY_D0_20G))
10564+
bp->port.supported[idx] &= ~SUPPORTED_20000baseKR2_Full;
1054410565
}
1054510566

1054610567
BNX2X_DEV_INFO("supported 0x%x 0x%x\n", bp->port.supported[0],
@@ -12814,6 +12835,8 @@ static void __bnx2x_remove(struct pci_dev *pdev,
1281412835
rtnl_unlock();
1281512836
}
1281612837

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

12831-
bnx2x_iov_remove_one(bp);
12832-
1283312854
/* send message via vfpf channel to release the resources of this vf */
1283412855
if (IS_VF(bp))
1283512856
bnx2x_vfpf_release(bp);

drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,21 +1459,16 @@ static u8 bnx2x_vf_is_pcie_pending(struct bnx2x *bp, u8 abs_vfid)
14591459
struct bnx2x_virtf *vf = bnx2x_vf_by_abs_fid(bp, abs_vfid);
14601460

14611461
if (!vf)
1462-
goto unknown_dev;
1462+
return false;
14631463

14641464
dev = pci_get_bus_and_slot(vf->bus, vf->devfn);
14651465
if (dev)
14661466
return bnx2x_is_pcie_pending(dev);
1467-
1468-
unknown_dev:
14691467
return false;
14701468
}
14711469

14721470
int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid)
14731471
{
1474-
/* Wait 100ms */
1475-
msleep(100);
1476-
14771472
/* Verify no pending pci transactions */
14781473
if (bnx2x_vf_is_pcie_pending(bp, abs_vfid))
14791474
BNX2X_ERR("PCIE Transactions still pending\n");
@@ -2176,6 +2171,9 @@ int bnx2x_iov_nic_init(struct bnx2x *bp)
21762171

21772172
DP(BNX2X_MSG_IOV, "num of vfs: %d\n", (bp)->vfdb->sriov.nr_virtfn);
21782173

2174+
/* let FLR complete ... */
2175+
msleep(100);
2176+
21792177
/* initialize vf database */
21802178
for_each_vf(bp, vfid) {
21812179
struct bnx2x_virtf *vf = BP_VF(bp, vfid);
@@ -2777,6 +2775,10 @@ int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf, dma_addr_t *sb_map)
27772775
vf->abs_vfid, vf->state);
27782776
return -EINVAL;
27792777
}
2778+
2779+
/* let FLR complete ... */
2780+
msleep(100);
2781+
27802782
/* FLR cleanup epilogue */
27812783
if (bnx2x_vf_flr_clnup_epilog(bp, vf->abs_vfid))
27822784
return -EBUSY;
@@ -3085,6 +3087,11 @@ void bnx2x_disable_sriov(struct bnx2x *bp)
30853087
static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx,
30863088
struct bnx2x_virtf *vf)
30873089
{
3090+
if (bp->state != BNX2X_STATE_OPEN) {
3091+
BNX2X_ERR("vf ndo called though PF is down\n");
3092+
return -EINVAL;
3093+
}
3094+
30883095
if (!IS_SRIOV(bp)) {
30893096
BNX2X_ERR("vf ndo called though sriov is disabled\n");
30903097
return -EINVAL;
@@ -3469,3 +3476,23 @@ int bnx2x_open_epilog(struct bnx2x *bp)
34693476

34703477
return 0;
34713478
}
3479+
3480+
void bnx2x_iov_channel_down(struct bnx2x *bp)
3481+
{
3482+
int vf_idx;
3483+
struct pf_vf_bulletin_content *bulletin;
3484+
3485+
if (!IS_SRIOV(bp))
3486+
return;
3487+
3488+
for_each_vf(bp, vf_idx) {
3489+
/* locate this VFs bulletin board and update the channel down
3490+
* bit
3491+
*/
3492+
bulletin = BP_VF_BULLETIN(bp, vf_idx);
3493+
bulletin->valid_bitmap |= 1 << CHANNEL_DOWN;
3494+
3495+
/* update vf bulletin board */
3496+
bnx2x_post_vf_bulletin(bp, vf_idx);
3497+
}
3498+
}

drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ static inline int bnx2x_vf_headroom(struct bnx2x *bp)
761761
}
762762
void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp);
763763
int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs);
764+
void bnx2x_iov_channel_down(struct bnx2x *bp);
764765
int bnx2x_open_epilog(struct bnx2x *bp);
765766

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

822824
#endif /* CONFIG_BNX2X_SRIOV */

drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,24 @@ static int bnx2x_send_msg2pf(struct bnx2x *bp, u8 *done, dma_addr_t msg_mapping)
113113
{
114114
struct cstorm_vf_zone_data __iomem *zone_data =
115115
REG_ADDR(bp, PXP_VF_ADDR_CSDM_GLOBAL_START);
116-
int tout = 600, interval = 100; /* wait for 60 seconds */
116+
int tout = 100, interval = 100; /* wait for 10 seconds */
117117

118118
if (*done) {
119119
BNX2X_ERR("done was non zero before message to pf was sent\n");
120120
WARN_ON(true);
121121
return -EINVAL;
122122
}
123123

124+
/* if PF indicated channel is down avoid sending message. Return success
125+
* so calling flow can continue
126+
*/
127+
bnx2x_sample_bulletin(bp);
128+
if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
129+
DP(BNX2X_MSG_IOV, "detecting channel down. Aborting message\n");
130+
*done = PFVF_STATUS_SUCCESS;
131+
return 0;
132+
}
133+
124134
/* Write message address */
125135
writel(U64_LO(msg_mapping),
126136
&zone_data->non_trigger.vf_pf_channel.msg_addr_lo);

drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ struct pf_vf_bulletin_content {
331331
#define VLAN_VALID 1 /* when set, the vf should not access
332332
* the vfpf channel
333333
*/
334-
334+
#define CHANNEL_DOWN 2 /* vfpf channel is disabled. VFs are not
335+
* to attempt to send messages on the
336+
* channel after this bit is set
337+
*/
335338
u8 mac[ETH_ALEN];
336339
u8 mac_padding[2];
337340

0 commit comments

Comments
 (0)