From: Michal Schmidt <mschmidt@redhat.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "Vlad Zolotarov" <vladz@broadcom.com>,
"Dmitry Kravkov" <dmitry@broadcom.com>,
"Eilon Greenstein" <eilong@broadcom.com>,
"mirqus@gmail.com" <mirqus@gmail.com>
Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG
Date: Wed, 31 Aug 2011 18:55:07 +0200 [thread overview]
Message-ID: <20110831185507.50a1940c@alice> (raw)
In-Reply-To: <201108311816.30468.vladz@broadcom.com>
On Wed, 31 Aug 2011 18:16:30 +0300 Vlad Zolotarov wrote:
> This is bogus - what if bnx2x_reload_if_running(dev)
> (bnx2x_nic_load()) failes? The original dev->features would be
> lost... Pls., see my latest response on your previouse patch series
> thread.
OK, so the conclusion in the other thread was to restore the features
before returning. Here's an updated patch.
Subject: [PATCH] bnx2x: remove TPA_ENABLE_FLAG
TPA_ENABLE_FLAG is unnecessary, because it mirrors NETIF_F_LRO.
"Cheating" in bnx2x_set_features() was suggested by Michał Mirosław.
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 2 +-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 31 ++++++++++++---------
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 7 +---
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 735e491..5d5f323 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1174,7 +1174,7 @@ struct bnx2x {
#define USING_MSIX_FLAG (1 << 5)
#define USING_MSI_FLAG (1 << 6)
#define DISABLE_MSI_FLAG (1 << 7)
-#define TPA_ENABLE_FLAG (1 << 8)
+
#define NO_MCP_FLAG (1 << 9)
#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index a08b101..399e71c 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -62,7 +62,7 @@ static inline void bnx2x_bz_fp(struct bnx2x *bp, int index)
* set the tpa flag for each queue. The tpa flag determines the queue
* minimal size so it must be set prior to queue memory allocation
*/
- fp->disable_tpa = ((bp->flags & TPA_ENABLE_FLAG) == 0);
+ fp->disable_tpa = !(bp->dev->features & NETIF_F_LRO);
#ifdef BCM_CNIC
/* We don't want TPA on an FCoE L2 ring */
@@ -3410,13 +3410,10 @@ u32 bnx2x_fix_features(struct net_device *dev, u32 features)
int bnx2x_set_features(struct net_device *dev, u32 features)
{
struct bnx2x *bp = netdev_priv(dev);
- u32 flags = bp->flags;
bool bnx2x_reload = false;
- if (features & NETIF_F_LRO)
- flags |= TPA_ENABLE_FLAG;
- else
- flags &= ~TPA_ENABLE_FLAG;
+ if ((features ^ dev->features) & NETIF_F_LRO)
+ bnx2x_reload = true;
if (features & NETIF_F_LOOPBACK) {
if (bp->link_params.loopback_mode != LOOPBACK_BMAC) {
@@ -3430,14 +3427,22 @@ int bnx2x_set_features(struct net_device *dev, u32 features)
}
}
- if (flags ^ bp->flags) {
- bp->flags = flags;
- bnx2x_reload = true;
- }
-
if (bnx2x_reload) {
- if (bp->recovery_state == BNX2X_RECOVERY_DONE)
- return bnx2x_reload_if_running(dev);
+ if (bp->recovery_state == BNX2X_RECOVERY_DONE) {
+ /*
+ * Cheat! Normally dev->features will be set after we
+ * return, but that's too late. We need to know how to
+ * configure the NIC when reloading it, so copy the
+ * features beforehand. Restore them after reload to
+ * avoid any possible confusion of the caller.
+ */
+ int ret;
+ u32 orig_features = dev->features;
+ dev->features = features;
+ ret = bnx2x_reload_if_running(dev);
+ dev->features = orig_features;
+ return ret;
+ }
/* else: bnx2x_nic_load() will be called at end of recovery */
}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index e7b584b..fd32c04 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -9757,13 +9757,10 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
bp->multi_mode = multi_mode;
/* Set TPA flags */
- if (disable_tpa) {
- bp->flags &= ~TPA_ENABLE_FLAG;
+ if (disable_tpa)
bp->dev->features &= ~NETIF_F_LRO;
- } else {
- bp->flags |= TPA_ENABLE_FLAG;
+ else
bp->dev->features |= NETIF_F_LRO;
- }
bp->disable_tpa = disable_tpa;
if (CHIP_IS_E1(bp))
--
1.7.6
next prev parent reply other threads:[~2011-08-31 17:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-31 15:00 [PATCH 0/3 net-next] bnx2x: VLAN stripping toggle and a small cleanup Michal Schmidt
2011-08-31 15:00 ` [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG Michal Schmidt
2011-08-31 15:16 ` Vlad Zolotarov
2011-08-31 15:58 ` Michal Schmidt
2011-08-31 16:13 ` Vladislav Zolotarov
2011-08-31 18:05 ` Michał Mirosław
2011-09-01 8:37 ` Vladislav Zolotarov
2011-09-01 9:37 ` Michał Mirosław
2011-09-01 10:52 ` Vladislav Zolotarov
2011-08-31 16:55 ` Michal Schmidt [this message]
2011-08-31 15:00 ` [PATCH 2/3] bnx2x: do not set NETIF_F_LRO in bnx2x_init_bp Michal Schmidt
2011-08-31 15:00 ` [PATCH 3/3] bnx2x: expose HW RX VLAN stripping toggle Michal Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110831185507.50a1940c@alice \
--to=mschmidt@redhat.com \
--cc=dmitry@broadcom.com \
--cc=eilong@broadcom.com \
--cc=mirqus@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vladz@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox