diff mbox

[1/3] bnx2x: remove TPA_ENABLE_FLAG

Message ID 1314802836-9862-2-git-send-email-mschmidt@redhat.com
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Michal Schmidt Aug. 31, 2011, 3 p.m. UTC
TPA_ENABLE_FLAG is unnecessary, because it mirrors NETIF_F_LRO.

The "cheat" 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  |   24 +++++++++++-----------
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    7 +----
 3 files changed, 15 insertions(+), 18 deletions(-)

Comments

Vladislav Zolotarov Aug. 31, 2011, 3:16 p.m. UTC | #1
On Wednesday 31 August 2011 18:00:34 Michal Schmidt wrote:
>  	if (bnx2x_reload) {
> -		if (bp->recovery_state == BNX2X_RECOVERY_DONE)
> +		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 update
> +			 * the features early.
> +			 */
> +			dev->features = features;
>  			return bnx2x_reload_if_running(dev);

NACK 

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.

thanks,
vlad

> +		}
>  		/* 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))

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Schmidt Aug. 31, 2011, 3:58 p.m. UTC | #2
On Wed, 31 Aug 2011 18:16:30 +0300 Vlad Zolotarov wrote:
> On Wednesday 31 August 2011 18:00:34 Michal Schmidt wrote:
> >  	if (bnx2x_reload) {
> > -		if (bp->recovery_state == BNX2X_RECOVERY_DONE)
> > +		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
> > update
> > +			 * the features early.
> > +			 */
> > +			dev->features = features;
> >  			return bnx2x_reload_if_running(dev);
> 
> NACK 
> 
> This is bogus - what if bnx2x_reload_if_running(dev)
> (bnx2x_nic_load()) failes? The original dev->features would be
> lost... 

Well, yes, but since the NIC would be now not working, do we really
care about its features? :-)

Michal
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladislav Zolotarov Aug. 31, 2011, 4:13 p.m. UTC | #3
> -----Original Message-----
> From: Michal Schmidt [mailto:mschmidt@redhat.com]
> Sent: Wednesday, August 31, 2011 6:59 PM
> To: Vladislav Zolotarov
> Cc: netdev@vger.kernel.org; Dmitry Kravkov; Eilon Greenstein;
> mirqus@gmail.com
> Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG
> 
> On Wed, 31 Aug 2011 18:16:30 +0300 Vlad Zolotarov wrote:
> > On Wednesday 31 August 2011 18:00:34 Michal Schmidt wrote:
> > >  	if (bnx2x_reload) {
> > > -		if (bp->recovery_state == BNX2X_RECOVERY_DONE)
> > > +		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
> > > update
> > > +			 * the features early.
> > > +			 */
> > > +			dev->features = features;
> > >  			return bnx2x_reload_if_running(dev);
> >
> > NACK
> >
> > This is bogus - what if bnx2x_reload_if_running(dev)
> > (bnx2x_nic_load()) failes? The original dev->features would be
> > lost...
> 
> Well, yes, but since the NIC would be now not working, do we really
> care about its features? :-)

U r kidding, right? ;)
We care about the consistency in the netdev features state - if we failed 
to configure the requested feature and returned an error on e.g. "ethtool -K ethX lro on"
call, it's expected that a subsequent ethtool -k ethX call won't report the requested
feature (LRO) as set.

Thanks,
vlad

> 
> Michal


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
=?ISO-8859-2?Q?Micha=B3_Miros=B3aw?= Aug. 31, 2011, 6:05 p.m. UTC | #4
2011/8/31 Vladislav Zolotarov <vladz@broadcom.com>:
>> -----Original Message-----
>> From: Michal Schmidt [mailto:mschmidt@redhat.com]
>> Sent: Wednesday, August 31, 2011 6:59 PM
>> To: Vladislav Zolotarov
>> Cc: netdev@vger.kernel.org; Dmitry Kravkov; Eilon Greenstein;
>> mirqus@gmail.com
>> Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG
>>
>> On Wed, 31 Aug 2011 18:16:30 +0300 Vlad Zolotarov wrote:
>> > On Wednesday 31 August 2011 18:00:34 Michal Schmidt wrote:
>> > >   if (bnx2x_reload) {
>> > > -         if (bp->recovery_state == BNX2X_RECOVERY_DONE)
>> > > +         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
>> > > update
>> > > +                  * the features early.
>> > > +                  */
>> > > +                 dev->features = features;
>> > >                   return bnx2x_reload_if_running(dev);
>> >
>> > NACK
>> >
>> > This is bogus - what if bnx2x_reload_if_running(dev)
>> > (bnx2x_nic_load()) failes? The original dev->features would be
>> > lost...
>>
>> Well, yes, but since the NIC would be now not working, do we really
>> care about its features? :-)
>
> U r kidding, right? ;)
> We care about the consistency in the netdev features state - if we failed
> to configure the requested feature and returned an error on e.g. "ethtool -K ethX lro on"
> call, it's expected that a subsequent ethtool -k ethX call won't report the requested
> feature (LRO) as set.

If bnx2x_reload_if_running() failure means that NIC is disabled, then
Michal is right that there's no point in caring about dev->features,
sice 'load' operation (NIC configuration) needs to be done again
anyway.

Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladislav Zolotarov Sept. 1, 2011, 8:37 a.m. UTC | #5
> -----Original Message-----

> From: netdev-owner@vger.kernel.org [mailto:netdev-

> owner@vger.kernel.org] On Behalf Of Michal Miroslaw

> Sent: Wednesday, August 31, 2011 9:05 PM

> To: Vladislav Zolotarov

> Cc: Michal Schmidt; netdev@vger.kernel.org; Dmitry Kravkov; Eilon

> Greenstein

> Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG

> 

> 2011/8/31 Vladislav Zolotarov <vladz@broadcom.com>:

> >> -----Original Message-----

> >> From: Michal Schmidt [mailto:mschmidt@redhat.com]

> >> Sent: Wednesday, August 31, 2011 6:59 PM

> >> To: Vladislav Zolotarov

> >> Cc: netdev@vger.kernel.org; Dmitry Kravkov; Eilon Greenstein;

> >> mirqus@gmail.com

> >> Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG

> >>

> >> On Wed, 31 Aug 2011 18:16:30 +0300 Vlad Zolotarov wrote:

> >> > On Wednesday 31 August 2011 18:00:34 Michal Schmidt wrote:

> >> > >   if (bnx2x_reload) {

> >> > > -         if (bp->recovery_state == BNX2X_RECOVERY_DONE)

> >> > > +         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

> >> > > update

> >> > > +                  * the features early.

> >> > > +                  */

> >> > > +                 dev->features = features;

> >> > >                   return bnx2x_reload_if_running(dev);

> >> >

> >> > NACK

> >> >

> >> > This is bogus - what if bnx2x_reload_if_running(dev)

> >> > (bnx2x_nic_load()) failes? The original dev->features would be

> >> > lost...

> >>

> >> Well, yes, but since the NIC would be now not working, do we really

> >> care about its features? :-)

> >

> > U r kidding, right? ;)

> > We care about the consistency in the netdev features state - if we

> failed

> > to configure the requested feature and returned an error on e.g.

> "ethtool -K ethX lro on"

> > call, it's expected that a subsequent ethtool -k ethX call won't

> report the requested

> > feature (LRO) as set.

> 

> If bnx2x_reload_if_running() failure means that NIC is disabled, then

> Michal is right that there's no point in caring about dev->features,

> sice 'load' operation (NIC configuration) needs to be done again

> anyway.


Michal, it's a matter of a consistent semantics/behavior of the ethtool callbacks just as I described above.
As long as dev->features may be queried both when device is down I'm afraid I can't agree with u.

Thanks,
vlad

> 

> Best Regards,

> Michał Mirosław

> --

> To unsubscribe from this list: send the line "unsubscribe netdev" in

> the body of a message to majordomo@vger.kernel.org

> More majordomo info at  http://vger.kernel.org/majordomo-info.html
=?ISO-8859-2?Q?Micha=B3_Miros=B3aw?= Sept. 1, 2011, 9:37 a.m. UTC | #6
W dniu 1 września 2011 10:37 użytkownik Vladislav Zolotarov
<vladz@broadcom.com> napisał:
>> -----Original Message-----
>> From: netdev-owner@vger.kernel.org [mailto:netdev-
>> owner@vger.kernel.org] On Behalf Of Michal Miroslaw
>> Sent: Wednesday, August 31, 2011 9:05 PM
>> To: Vladislav Zolotarov
>> Cc: Michal Schmidt; netdev@vger.kernel.org; Dmitry Kravkov; Eilon
>> Greenstein
>> Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG
>>
>> 2011/8/31 Vladislav Zolotarov <vladz@broadcom.com>:
>> >> -----Original Message-----
>> >> From: Michal Schmidt [mailto:mschmidt@redhat.com]
>> >> Sent: Wednesday, August 31, 2011 6:59 PM
>> >> To: Vladislav Zolotarov
>> >> Cc: netdev@vger.kernel.org; Dmitry Kravkov; Eilon Greenstein;
>> >> mirqus@gmail.com
>> >> Subject: Re: [PATCH 1/3] bnx2x: remove TPA_ENABLE_FLAG
>> >>
>> >> On Wed, 31 Aug 2011 18:16:30 +0300 Vlad Zolotarov wrote:
>> >> > On Wednesday 31 August 2011 18:00:34 Michal Schmidt wrote:
>> >> > >   if (bnx2x_reload) {
>> >> > > -         if (bp->recovery_state == BNX2X_RECOVERY_DONE)
>> >> > > +         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
>> >> > > update
>> >> > > +                  * the features early.
>> >> > > +                  */
>> >> > > +                 dev->features = features;
>> >> > >                   return bnx2x_reload_if_running(dev);
>> >> >
>> >> > NACK
>> >> >
>> >> > This is bogus - what if bnx2x_reload_if_running(dev)
>> >> > (bnx2x_nic_load()) failes? The original dev->features would be
>> >> > lost...
>> >>
>> >> Well, yes, but since the NIC would be now not working, do we really
>> >> care about its features? :-)
>> >
>> > U r kidding, right? ;)
>> > We care about the consistency in the netdev features state - if we
>> failed
>> > to configure the requested feature and returned an error on e.g.
>> "ethtool -K ethX lro on"
>> > call, it's expected that a subsequent ethtool -k ethX call won't
>> report the requested
>> > feature (LRO) as set.
>>
>> If bnx2x_reload_if_running() failure means that NIC is disabled, then
>> Michal is right that there's no point in caring about dev->features,
>> sice 'load' operation (NIC configuration) needs to be done again
>> anyway.
> Michal, it's a matter of a consistent semantics/behavior of the ethtool callbacks just as I described above.
> As long as dev->features may be queried both when device is down I'm afraid I can't agree with u.

If I understand correctly, bnx2x_reload_if_running() failure does not
mean exactly that features change failed. It means that device failed
to initialize, possibly because of other (transient?) conditions. So
unless reverting features change and retrying the initialization is
known to allow the device to be brought back, there's no difference
whether old or new dev->features value is kept and which set is
reported by ethtool.

Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vladislav Zolotarov Sept. 1, 2011, 10:52 a.m. UTC | #7
> If I understand correctly, bnx2x_reload_if_running() failure does not
> mean exactly that features change failed. It means that device failed
> to initialize, possibly because of other (transient?) conditions. So
> unless reverting features change and retrying the initialization is
> known to allow the device to be brought back, 

In a general case u can't be sure which (if at all) features change caused
the failure. So, u should return the configuration to the last known "good" one.

> there's no difference
> whether old or new dev->features value is kept and which set is
> reported by ethtool.

Well, I disagree with u on this one - I think that if the state change operation
(of any object, in our case it's a netdev) fails, the current state should remain unchanged.

Thanks,
vlad

> 
> Best Regards,
> Michał Mirosław


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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..c660317 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,17 @@  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)
+		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 update
+			 * the features early.
+			 */
+			dev->features = features;
 			return bnx2x_reload_if_running(dev);
+		}
 		/* 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))