Skip to contentSkip to conversation

invalid requirement from ethtool?

DISCUSSION Eli Cohen 3 participants 8 messages Jul 26, 2011 – Aug 15, 2011

Subsystems (2)
lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

Hi,
I see the following text in include/linux/ethtool.h and wonder what is the reasoning for requiring that both params cannot be zero. I could not track when and who inserted this text as it dates before git was used to track kernel code, but my feeling is that is related to a specific hardware limitation.

/* How many packets to delay an RX interrupt after
* a packet arrives. If 0, only rx_coalesce_usecs is
* used. It is illegal to set both usecs and max frames
* to zero as this would cause RX interrupts to never be
* generated.
*/
__u32 rx_max_coalesced_frames;

/* How many packets to delay a TX interrupt after
* a packet is sent. If 0, only tx_coalesce_usecs is
* used. It is illegal to set both usecs and max frames
* to zero as this would cause TX interrupts to never be
* generated.
*/
__u32 tx_max_coalesced_frames;

I found this in tg3 driver:

         /* No rx interrupts will be generated if both are zero */
        if ((ec->rx_coalesce_usecs == 0) &&
            (ec->rx_max_coalesced_frames == 0))
                return -EINVAL;

However, bnx2 for example allows setting both to zero.

I think both params zero should be allowed and mean coalescing is not operational, thus we can remove these comments from ethtool.h

maintainer
#1 lore raw

From: Eli Cohen <[email protected]>
Date: Tue, 26 Jul 2011 15:42:22 +0300

Quoted 2 lines

I think both params zero should be allowed and mean coalescing is not operational, thus we can remove these comments from ethtool.h

The existing precendence has existed for more than 10 years. You can't just change it like this.

You'll need to find a new way to encode "disabled" coalescing.

author
#2 lore raw
Quoted 10 lines · David Miller

From: Eli Cohen <[email protected]>
Date: Tue, 26 Jul 2011 15:42:22 +0300

Quoted 2 lines

I think both params zero should be allowed and mean coalescing is not operational, thus we can remove these comments from ethtool.h

The existing precendence has existed for more than 10 years. You can't just change it like this.

You'll need to find a new way to encode "disabled" coalescing.

I can't see the text explicitly specifies how to "disable" coalescing. If I ignore the specific comment that disallows both params 0, I could interpret the text such that when they're both zero, the feature is disabled.

BTW, I checked also Intel 10GBE Nic (ixgbe) driver and it allows setting both 0.

maintainer
#3 lore raw

From: Eli Cohen <[email protected]>
Date: Thu, 28 Jul 2011 10:23:26 +0300

Quoted 10 lines · David Miller
Quoted 9 lines

From: Eli Cohen <[email protected]>
Date: Tue, 26 Jul 2011 15:42:22 +0300

Quoted 2 lines

I think both params zero should be allowed and mean coalescing is not operational, thus we can remove these comments from ethtool.h

The existing precendence has existed for more than 10 years. You can't just change it like this.

Quoted 6 lines
Quoted 1 line

You'll need to find a new way to encode "disabled" coalescing.

I can't see the text explicitly specifies how to "disable" coalescing. If I ignore the specific comment that disallows both params 0, I could interpret the text such that when they're both zero, the feature is disabled.

The documentation does not determine what the rules are, the cpu does not execute the documentation it executes the code, and that's what determines the rules.

#4 lore raw
Quoted 15 lines · David Miller

From: Eli Cohen <[email protected]>
Date: Thu, 28 Jul 2011 10:23:26 +0300

Quoted 12 lines · David Miller
Quoted 10 lines

From: Eli Cohen <[email protected]>
Date: Tue, 26 Jul 2011 15:42:22 +0300

Quoted 2 lines

I think both params zero should be allowed and mean coalescing is not operational, thus we can remove these comments from ethtool.h

The existing precendence has existed for more than 10 years. You can't just change it like this.

You'll need to find a new way to encode "disabled" coalescing.

Quoted 8 lines
Quoted 4 lines

I can't see the text explicitly specifies how to "disable" coalescing. If I ignore the specific comment that disallows both params 0, I could interpret the text such that when they're both zero, the feature is disabled.

The documentation does not determine what the rules are, the cpu does not execute the documentation it executes the code, and that's what determines the rules.

The ethtool core doesn't check the values in struct ethtool_coalesce, so the rules are really driver-specific.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
author
#5 lore raw
Quoted 4 lines · Ben Hutchings

The ethtool core doesn't check the values in struct ethtool_coalesce, so the rules are really driver-specific.

Exactly. That's why I think those comments are not in place.

#6 lore raw
In reply to Eli Cohen
Quoted 29 lines · Eli Cohen

Hi,
I see the following text in include/linux/ethtool.h and wonder what is the reasoning for requiring that both params cannot be zero. I could not track when and who inserted this text as it dates before git was used to track kernel code, but my feeling is that is related to a specific hardware limitation.

/* How many packets to delay an RX interrupt after
* a packet arrives. If 0, only rx_coalesce_usecs is
* used. It is illegal to set both usecs and max frames
* to zero as this would cause RX interrupts to never be
* generated.
*/
__u32 rx_max_coalesced_frames;

/* How many packets to delay a TX interrupt after
* a packet is sent. If 0, only tx_coalesce_usecs is
* used. It is illegal to set both usecs and max frames
* to zero as this would cause TX interrupts to never be
* generated.
*/
__u32 tx_max_coalesced_frames;

I found this in tg3 driver:

         /* No rx interrupts will be generated if both are zero */
        if ((ec->rx_coalesce_usecs == 0) &&
            (ec->rx_max_coalesced_frames == 0))
                return -EINVAL;
Quoted 4 lines

However, bnx2 for example allows setting both to zero.

I think both params zero should be allowed and mean coalescing is not operational, thus we can remove these comments from ethtool.h

If coalescing is not operational, the maximum number of completions before an interrupt is 1. So logically {rx,tx}_max_coalesced_frames should be 1, right? Although the comment does say 'How many packets ... after ...' which implies that the value of the field must be 1 less than the wanted maximum, i.e. 0, which is supposedly invalid.

The first implementation of ethtool coalescing control was in tg3, so it should be a useful reference.

David, I know you maintained tg3 for some time so I assume you have a hardware reference. Can you confirm whether a value of 1 in HOSTCC_{RX,TX}MAX_FRAMES results in an interrupt after 1 completion or after 2 completions?

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#7 lore raw

From: Ben Hutchings <[email protected]>
Date: Mon, 15 Aug 2011 18:24:00 +0100

Quoted 4 lines

David, I know you maintained tg3 for some time so I assume you have a hardware reference. Can you confirm whether a value of 1 in HOSTCC_{RX,TX}MAX_FRAMES results in an interrupt after 1 completion or after 2 completions?

A value of 1 results in an interrupt after 1 completion.

If you put a zero there, the packet count comparison never triggers.