Skip to contentSkip to conversation

bnx2x: Bug fixes patch series

PATCH In review Yuval Mintz 6 participants 13 messages Jan 5, 2014 – Jan 6, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover bnx2x: Bug fixes patch series

Hi Dave,

Most of what this parch series contains is SR-IOV related bug fixes. Additionally, it contains some small fixes for legacy devices/modes.

Please consider applying these patches to `net'.

Thanks,
Yuval Mintz

#1 lore raw

PATCH 1/5 bnx2x: limit number of interrupt vectors for 57711

From: Dmitry Kravkov <[email protected]>

Original straightforward division may lead to zeroing number of SB and null-pointer dereference when device is short of MSIX vectors or lacks MSIX capabilities.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h      | 2 ++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +2 -0
index a1f66e2..cb30d1a 100644
@@ -2499,4 +2499,6 @@ void bnx2x_set_local_cmng(struct bnx2x *bp);
 #define MCPR_SCRATCH_BASE(bp) \
 	(CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
 
+#define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))
+
 #endif /* bnx2x.h */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +3 -3
index 814d0ec..8b3107b 100644
@@ -11447,9 +11447,9 @@ static int bnx2x_get_hwinfo(struct bnx2x *bp)
 		}
 	}
 
-	/* adjust igu_sb_cnt to MF for E1x */
-	if (CHIP_IS_E1x(bp) && IS_MF(bp))
-		bp->igu_sb_cnt /= E1HVN_MAX;
+	/* adjust igu_sb_cnt to MF for E1H */
+	if (CHIP_IS_E1H(bp) && IS_MF(bp))
+		bp->igu_sb_cnt = min_t(u8, bp->igu_sb_cnt, E1H_MAX_MF_SB_COUNT);
 
 	/* port info */
 	bnx2x_get_port_hwinfo(bp);
Signature · 1 line
1.8.1.227.g44fe835
#2 lore raw

Re: [PATCH net 1/5] bnx2x: limit number of interrupt vectors for 57711

Hello.

Quoted 20 lines · Yuval Mintz

From: Dmitry Kravkov <[email protected]>

Original straightforward division may lead to zeroing number of SB and null-pointer dereference when device is short of MSIX vectors or lacks MSIX capabilities.

---
  drivers/net/ethernet/broadcom/bnx2x/bnx2x.h      | 2 ++
  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 6 +++---
  2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +0 -0
index a1f66e2..cb30d1a 100644

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h void bnx2x_set_local_cmng(struct bnx2x *bp); · line 2502

Quoted 4 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +1 -0
@@ -2499,4 +2499,6 @@ void bnx2x_set_local_cmng(struct bnx2x *bp);
  #define MCPR_SCRATCH_BASE(bp) \
  	(CHIP_IS_E1x(bp) ? MCP_REG_MCPR_SCRATCH : MCP_A_REG_MCPR_SCRATCH)
 
+#define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))

Be consistent and put spaces around / too, please.

WBR, Sergei

#3 lore raw

PATCH 2/5 bnx2x: Correct number of MSI-X vectors for VFs

In reply to Yuval Mintz

From: Michal Kalderon <[email protected]>

Number of VFs in PCIe configuration space is zero-based. Driver incorrectly sets the number of VFs to be larger by one than what actually is feasible by HW, which might cause later VFs to fail to allocate their MSI-X interrupts.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +6 -3
index 2e46c28..ddd95b9 100644
@@ -3202,13 +3202,16 @@ int bnx2x_enable_sriov(struct bnx2x *bp)
 		bnx2x_iov_static_resc(bp, vf);
 	}
 
-	/* prepare msix vectors in VF configuration space */
+	/* prepare msix vectors in VF configuration space - the value in the
+	 * PCI configuration space should be the index of the last entry,
+	 * namely one less than the actual size of the table
+	 */
 	for (vf_idx = first_vf; vf_idx < first_vf + req_vfs; vf_idx++) {
 		bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf_idx));
 		REG_WR(bp, PCICFG_OFFSET + GRC_CONFIG_REG_VF_MSIX_CONTROL,
-		       num_vf_queues);
+		       num_vf_queues - 1);
 		DP(BNX2X_MSG_IOV, "set msix vec num in VF %d cfg space to %d\n",
-		   vf_idx, num_vf_queues);
+		   vf_idx, num_vf_queues - 1);
 	}
 	bnx2x_pretend_func(bp, BP_ABS_FUNC(bp));
 
Signature · 1 line
1.8.1.227.g44fe835
#4 lore raw

[BUG] bnx2x : lockdep assertion

Caught this with latest net-next tree :

Does this ring a bell to you guys ?

[   27.339221] BUG: sleeping function called from invalid context at include/linux/netdevice.h:486
[   27.347927] in_atomic(): 1, irqs_disabled(): 0, pid: 5672, name: ethtool
[   27.354628] 1 lock held by ethtool/5672:
[   27.354629]  #0:  (rtnl_mutex){+.+.+.}, at: [<ffffffff814f3b97>] rtnl_lock+0x17/0x20
[   27.354641] CPU: 6 PID: 5672 Comm: ethtool Not tainted 3.13.0-dbg-DEV #430
[   27.354644]  0000000000000000 ffff880656881aa8 ffffffff81594454 0000000000000002
[   27.354648]  ffff88065d7f4ad0 ffff880656881ac8 ffffffff810c37af ffff880656881ac8
[   27.354651]  ffff880c50df8000 ffff880656881b18 ffffffffa00b8c18 ffff880c50df0940
[   27.354655] Call Trace:
[   27.354661]  [<ffffffff81594454>] dump_stack+0x4e/0x68
[   27.354666]  [<ffffffff810c37af>] __might_sleep+0xdf/0x110
[   27.354680]  [<ffffffffa00b8c18>] bnx2x_napi_disable.isra.84+0x58/0x130 [bnx2x]
[   27.354689]  [<ffffffffa00bdf65>] bnx2x_netif_stop+0x25/0x40 [bnx2x]
[   27.354696]  [<ffffffffa009123d>] bnx2x_chip_cleanup+0x24d/0x630 [bnx2x]
[   27.354700]  [<ffffffff810a2c55>] ? del_timer_sync+0x5/0xd0
[   27.354708]  [<ffffffffa00c0b40>] bnx2x_nic_unload+0x1f0/0x7f0 [bnx2x]
[   27.354714]  [<ffffffff8118e1af>] ? might_fault+0x5f/0xb0
[   27.354722]  [<ffffffffa00c3a0c>] bnx2x_reload_if_running+0x2c/0x50 [bnx2x]
[   27.354730]  [<ffffffffa00c57e4>] bnx2x_set_ringparam+0x2a4/0x400 [bnx2x]
[   27.354735]  [<ffffffff814ea242>] dev_ethtool+0x752/0x1b30
[   27.354741]  [<ffffffff810e3e1d>] ? trace_hardirqs_on+0xd/0x10
[   27.354743]  [<ffffffff814f3b97>] ? rtnl_lock+0x17/0x20
[   27.354747]  [<ffffffff814fa31d>] dev_ioctl+0x25d/0x5a0
[   27.354752]  [<ffffffff814c9746>] compat_sock_ioctl+0x4e6/0xa50
[   27.354757]  [<ffffffff815a0334>] ? __do_page_fault+0x2c4/0x560
[   27.354763]  [<ffffffff81224c08>] compat_sys_ioctl+0xc8/0x1500
[   27.354765]  [<ffffffff814c832b>] ? sock_map_fd+0x4b/0x70
[   27.354768]  [<ffffffff8159c989>] ? retint_swapgs+0xe/0x13
[   27.354771]  [<ffffffff810e3d45>] ? trace_hardirqs_on_caller+0x105/0x1d0
[   27.354774]  [<ffffffff813207ad>] ? trace_hardirqs_off_thunk+0x3a/0x3c
[   27.354779]  [<ffffffff815a65e5>] sysenter_dispatch+0x7/0x1f
[   27.354781]  [<ffffffff8132076e>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[   28.096865] bnx2x 0000:03:00.0 eth0: using MSI-X  IRQs: sp 41  fp[0] 43 ... fp[3] 46
[   28.211869] bnx2x 0000:03:00.0 eth0: NIC Link is Up, 10000 Mbps full duplex, Flow control: ON - receive
#5 lore raw

RE: [BUG] bnx2x : lockdep assertion

Quoted 8 lines

-----Original Message-----
From: Eric Dumazet [mailto:[email protected]]
Sent: Monday, January 06, 2014 6:28 PM
To: Yuval Mintz
Cc: [email protected]; [email protected]; Ariel Elior; Michal Kalderon
Subject: [BUG] bnx2x : lockdep assertion

Quoted 4 lines

Caught this with latest net-next tree :

Does this ring a bell to you guys ?

Hi Eric,
This was introduced by the low latency patch which added a 'might_sleep()' to napi_disable a while ago. There is a fix in the works.
Thanks,
Ariel

#6 lore raw

RE: [BUG] bnx2x : lockdep assertion

Quoted 4 lines · Ariel Elior

Hi Eric,
This was introduced by the low latency patch which added a 'might_sleep()' to napi_disable a while ago. There is a fix in the works.
Thanks,

Hmm, commit 80c33ddd31d0e801953 is 3 months old.

Do you have an idea of ETA for the fix ?

Thanks !

#7 lore raw

PATCH 3/5 bnx2x: Clean before update RSS arrives

In reply to Yuval Mintz

From: Michal Kalderon <[email protected]>

When a PF receives a VF message indicating a change in RSS properties it should clean the flags' bit-fields; Otherwise, it's possible that some random values will be considered as flags by the lower layers configuring the RSS in FW.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c   | 5 ++++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +4 -1
index 32c92ab..95feada 100644
@@ -4382,8 +4382,11 @@ int bnx2x_config_rss(struct bnx2x *bp,
 	struct bnx2x_raw_obj *r = &o->raw;
 
 	/* Do nothing if only driver cleanup was requested */
-	if (test_bit(RAMROD_DRV_CLR_ONLY, &p->ramrod_flags))
+	if (test_bit(RAMROD_DRV_CLR_ONLY, &p->ramrod_flags)) {
+		DP(BNX2X_MSG_SP, "Not configuring RSS ramrod_flags=%lx\n",
+		   p->ramrod_flags);
 		return 0;
+	}
 
 	r->set_pending(r);
 
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +3 -0
index 3dc2537..26fcba2 100644
@@ -1805,6 +1805,9 @@ static void bnx2x_vf_mbx_update_rss(struct bnx2x *bp, struct bnx2x_virtf *vf,
 	vf_op_params->rss_result_mask = rss_tlv->rss_result_mask;
 
 	/* flags handled individually for backward/forward compatability */
+	vf_op_params->rss_flags = 0;
+	vf_op_params->ramrod_flags = 0;
+
 	if (rss_tlv->rss_flags & VFPF_RSS_MODE_DISABLED)
 		__set_bit(BNX2X_RSS_MODE_DISABLED, &vf_op_params->rss_flags);
 	if (rss_tlv->rss_flags & VFPF_RSS_MODE_REGULAR)
Signature · 1 line
1.8.1.227.g44fe835
#8 lore raw

PATCH 4/5 bnx2x: fix AFEX memory overflow

In reply to Yuval Mintz

There are 2 different (related) flows in the slowpath configuration that utilize the same pointer and cast it to different structs; This is obviously incorrect as the intended allocated memory is that of the smaller struct, possibly causing the flow utilizing the larger struct to corrupt other slowpath configuration.

Since both flows are exclusive, set the allocated memory to be a union of both structs.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +4 -1
index cb30d1a..2d5fce4 100644
@@ -1250,7 +1250,10 @@ struct bnx2x_slowpath {
 	 * Therefore, if they would have been defined in the same union,
 	 * data can get corrupted.
 	 */
-	struct afex_vif_list_ramrod_data func_afex_rdata;
+	union {
+		struct afex_vif_list_ramrod_data	viflist_data;
+		struct function_update_data		func_update;
+	} func_afex_rdata;
 
 	/* used by dmae command executer */
 	struct dmae_command		dmae[MAX_DMAE_C];
Signature · 1 line
1.8.1.227.g44fe835
#9 lore raw

PATCH 5/5 bnx2x: fix VLAN configuration for VFs.

In reply to Yuval Mintz

If the hypervisor configures a vlan for the VF via the PF, the expected result is that only packets tagged by said vlan will be received by the VF (and that vlan will be silently removed).
Do to an incorrect manipulation of vlan filters in the driver, the VF can receive untagged traffic even if the hypervisor configured some vlan for it.

This patch corrects the behaviour.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c    |  10 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h    |   7 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 245 ++++++++++++----------
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h |   1 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c  |  23 +-
 5 files changed, 174 insertions(+), 112 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +7 -3
index 95feada..18438a5 100644
@@ -2038,6 +2038,7 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
 	struct bnx2x_vlan_mac_ramrod_params p;
 	struct bnx2x_exe_queue_obj *exeq = &o->exe_queue;
 	struct bnx2x_exeq_elem *exeq_pos, *exeq_pos_n;
+	unsigned long flags;
 	int read_lock;
 	int rc = 0;
 
@@ -2046,8 +2047,9 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
 	spin_lock_bh(&exeq->lock);
 
 	list_for_each_entry_safe(exeq_pos, exeq_pos_n, &exeq->exe_queue, link) {
-		if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags ==
-		    *vlan_mac_flags) {
+		flags = exeq_pos->cmd_data.vlan_mac.vlan_mac_flags;
+		if (BNX2X_VLAN_MAC_CMP_FLAGS(flags) ==
+		    BNX2X_VLAN_MAC_CMP_FLAGS(*vlan_mac_flags)) {
 			rc = exeq->remove(bp, exeq->owner, exeq_pos);
 			if (rc) {
 				BNX2X_ERR("Failed to remove command\n");
@@ -2080,7 +2082,9 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
 		return read_lock;
 
 	list_for_each_entry(pos, &o->head, link) {
-		if (pos->vlan_mac_flags == *vlan_mac_flags) {
+		flags = pos->vlan_mac_flags;
+		if (BNX2X_VLAN_MAC_CMP_FLAGS(flags) ==
+		    BNX2X_VLAN_MAC_CMP_FLAGS(*vlan_mac_flags)) {
 			p.user_req.vlan_mac_flags = pos->vlan_mac_flags;
 			memcpy(&p.user_req.u, &pos->u, sizeof(pos->u));
 			rc = bnx2x_config_vlan_mac(bp, &p);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +7 -0
index 658f4e3..6a53c15 100644
@@ -266,6 +266,13 @@ enum {
 	BNX2X_DONT_CONSUME_CAM_CREDIT,
 	BNX2X_DONT_CONSUME_CAM_CREDIT_DEST,
 };
+/* When looking for matching filters, some flags are not interesting */
+#define BNX2X_VLAN_MAC_CMP_MASK	(1 << BNX2X_UC_LIST_MAC | \
+				 1 << BNX2X_ETH_MAC | \
+				 1 << BNX2X_ISCSI_ETH_MAC | \
+				 1 << BNX2X_NETQ_ETH_MAC)
+#define BNX2X_VLAN_MAC_CMP_FLAGS(flags) \
+	((flags) & BNX2X_VLAN_MAC_CMP_MASK)
 
 struct bnx2x_vlan_mac_ramrod_params {
 	/* Object to run the command from */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +138 -107

297 lines not on this page · raw message

drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h +1 -0
index 1ff6a93..8c213fa52 100644
@@ -74,6 +74,7 @@ struct bnx2x_vf_queue {
 	/* VLANs object */
 	struct bnx2x_vlan_mac_obj	vlan_obj;
 	atomic_t vlan_count;		/* 0 means vlan-0 is set  ~ untagged */
+	unsigned long accept_flags;	/* last accept flags configured */
 
 	/* Queue Slow-path State object */
 	struct bnx2x_queue_sp_obj	sp_obj;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +21 -2
index 26fcba2..0756d7d 100644
@@ -1598,6 +1598,8 @@ static void bnx2x_vfop_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
 
 		if (msg->flags & VFPF_SET_Q_FILTERS_RX_MASK_CHANGED) {
 			unsigned long accept = 0;
+			struct pf_vf_bulletin_content *bulletin =
+				BP_VF_BULLETIN(bp, vf->index);
 
 			/* covert VF-PF if mask to bnx2x accept flags */
 			if (msg->rx_mask & VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST)
@@ -1617,9 +1619,11 @@ static void bnx2x_vfop_mbx_qfilters(struct bnx2x *bp, struct bnx2x_virtf *vf)
 				__set_bit(BNX2X_ACCEPT_BROADCAST, &accept);
 
 			/* A packet arriving the vf's mac should be accepted
-			 * with any vlan
+			 * with any vlan, unless a vlan has already been
+			 * configured.
 			 */
-			__set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept);
+			if (!(bulletin->valid_bitmap & (1 << VLAN_VALID)))
+				__set_bit(BNX2X_ACCEPT_ANY_VLAN, &accept);
 
 			/* set rx-mode */
 			rc = bnx2x_vfop_rxmode_cmd(bp, vf, &cmd,
@@ -1710,6 +1714,21 @@ static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp,
 			goto response;
 		}
 	}
+	/* if vlan was set by hypervisor we don't allow guest to config vlan */
+	if (bulletin->valid_bitmap & 1 << VLAN_VALID) {
+		int i;
+
+		/* search for vlan filters */
+		for (i = 0; i < filters->n_mac_vlan_filters; i++) {
+			if (filters->filters[i].flags &
+			    VFPF_Q_FILTER_VLAN_TAG_VALID) {
+				BNX2X_ERR("VF[%d] attempted to configure vlan but one was already set by Hypervisor. Aborting request\n",
+					  vf->abs_vfid);
+				vf->op_rc = -EPERM;
+				goto response;
+			}
+		}
+	}
 
 	/* verify vf_qid */
 	if (filters->vf_qid > vf_rxq_count(vf))
Signature · 1 line
1.8.1.227.g44fe835
#10 lore raw

Re: [PATCH net 5/5] bnx2x: fix VLAN configuration for VFs.

Quoted 4 lines · Yuval Mintz

If the hypervisor configures a vlan for the VF via the PF, the expected result is that only packets tagged by said vlan will be received by the VF (and that vlan will be silently removed).
Do to an incorrect manipulation of vlan filters in the driver, the

Did you want to say "Due to an incorrect"?

Quoted 2 lines

VF can receive untagged traffic even if the hypervisor configured some vlan for it.

#11 lore raw

RE: [PATCH net 5/5] bnx2x: fix VLAN configuration for VFs.

Quoted 8 lines
Quoted 4 lines · Yuval Mintz

If the hypervisor configures a vlan for the VF via the PF, the expected result is that only packets tagged by said vlan will be received by the VF (and that vlan will be silently removed).
Do to an incorrect manipulation of vlan filters in the driver, the

Did you want to say "Due to an incorrect"?

Yeps... Typo, obviously.

Quoted 3 lines
Quoted 3 lines

VF can receive untagged traffic even if the hypervisor configured some vlan for it.

maintainer
#12 lore raw
In reply to Yuval Mintz

From: Yuval Mintz <[email protected]>
Date: Sun, 5 Jan 2014 18:33:49 +0200

Quoted 4 lines

Most of what this parch series contains is SR-IOV related bug fixes. Additionally, it contains some small fixes for legacy devices/modes.

Please consider applying these patches to `net'.

Series applied with the typo in the commit message of patch #5 fixed.

Thanks.