All of lore.kernel.org
 help / color / mirror / Atom feed
* net: thunder: change q_len's type to handle max ring size
@ 2018-02-08 19:21 Dean Nelson
  2018-02-08 20:34   ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Dean Nelson @ 2018-02-08 19:21 UTC (permalink / raw)
  To: Robert Richter, Sunil Goutham, David Miller
  Cc: netdev, Vadim Lomovtsev, linux-kernel, linux-arm-kernel

The Cavium thunder nicvf driver supports rx/tx rings of up to 65536 entries per.
The number of entires are stored in the q_len member of struct q_desc_mem. The
problem is that q_len being a u16, results in 65536 becoming 0.

In getting pointers to descriptors in the rings, the driver uses q_len minus 1
as a mask after incrementing the pointer, in order to go back to the beginning
and not go past the end of the ring.

With the q_len set to 0 the mask is no longer correct and the driver does go
beyond the end of the ring, causing various ills. Usually the first thing that
shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7 timed out"
warning.

This patch remedies the problem by changing q_len to a u32.

Signed-off-by: Dean Nelson <dnelson@redhat.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_queues.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h
index 7d1e4e2aaad0..ce1eed7a6d63 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h
@@ -213,7 +213,7 @@ struct rx_tx_queue_stats {
 struct q_desc_mem {
 	dma_addr_t	dma;
 	u64		size;
-	u16		q_len;
+	u32		q_len;
 	dma_addr_t	phys_base;
 	void		*base;
 	void		*unalign_base;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: net: thunder: change q_len's type to handle max ring size
  2018-02-08 19:21 net: thunder: change q_len's type to handle max ring size Dean Nelson
@ 2018-02-08 20:34   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2018-02-08 20:34 UTC (permalink / raw)
  To: dnelson
  Cc: rric, sgoutham, netdev, Vadim.Lomovtsev, linux-kernel, linux-arm-kernel

From: Dean Nelson <dnelson@redhat.com>
Date: 

> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536 entries per.
> The number of entires are stored in the q_len member of struct q_desc_mem. The
> problem is that q_len being a u16, results in 65536 becoming 0.
> 
> In getting pointers to descriptors in the rings, the driver uses q_len minus 1
> as a mask after incrementing the pointer, in order to go back to the beginning
> and not go past the end of the ring.
> 
> With the q_len set to 0 the mask is no longer correct and the driver does go
> beyond the end of the ring, causing various ills. Usually the first thing that
> shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7 timed out"
> warning.
> 
> This patch remedies the problem by changing q_len to a u32.
> 
> Signed-off-by: Dean Nelson <dnelson@redhat.com>

Applied, thanks.

Another way to solve this could have been to encode that length
as "length - 1"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* net: thunder: change q_len's type to handle max ring size
@ 2018-02-08 20:34   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2018-02-08 20:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Dean Nelson <dnelson@redhat.com>
Date: 

> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536 entries per.
> The number of entires are stored in the q_len member of struct q_desc_mem. The
> problem is that q_len being a u16, results in 65536 becoming 0.
> 
> In getting pointers to descriptors in the rings, the driver uses q_len minus 1
> as a mask after incrementing the pointer, in order to go back to the beginning
> and not go past the end of the ring.
> 
> With the q_len set to 0 the mask is no longer correct and the driver does go
> beyond the end of the ring, causing various ills. Usually the first thing that
> shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7 timed out"
> warning.
> 
> This patch remedies the problem by changing q_len to a u32.
> 
> Signed-off-by: Dean Nelson <dnelson@redhat.com>

Applied, thanks.

Another way to solve this could have been to encode that length
as "length - 1"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: net: thunder: change q_len's type to handle max ring size
  2018-02-08 20:34   ` David Miller
@ 2018-02-08 21:57     ` Dean Nelson
  -1 siblings, 0 replies; 9+ messages in thread
From: Dean Nelson @ 2018-02-08 21:57 UTC (permalink / raw)
  To: David Miller
  Cc: rric, sgoutham, netdev, Vadim.Lomovtsev, linux-kernel, linux-arm-kernel

On 02/08/2018 02:34 PM, David Miller wrote:
> From: Dean Nelson <dnelson@redhat.com>
> Date:
> 
>> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536 entries per.
>> The number of entires are stored in the q_len member of struct q_desc_mem. The
>> problem is that q_len being a u16, results in 65536 becoming 0.
>>
>> In getting pointers to descriptors in the rings, the driver uses q_len minus 1
>> as a mask after incrementing the pointer, in order to go back to the beginning
>> and not go past the end of the ring.
>>
>> With the q_len set to 0 the mask is no longer correct and the driver does go
>> beyond the end of the ring, causing various ills. Usually the first thing that
>> shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7 timed out"
>> warning.
>>
>> This patch remedies the problem by changing q_len to a u32.
>>
>> Signed-off-by: Dean Nelson <dnelson@redhat.com>
> 
> Applied, thanks.

Thank you!

> 
> Another way to solve this could have been to encode that length
> as "length - 1"

True. I had pondered that, but felt that since changing q_len's type
didn't add any length to the structure and that it was less impactful
from a number-of-lines of code changed perspective, I'd opt for this
route.

Cavium, if you'd prefer this goes the route that Dave just mentioned,
please let me know and I can make a new patch against what's been
applied?

Thanks,
Dean

^ permalink raw reply	[flat|nested] 9+ messages in thread

* net: thunder: change q_len's type to handle max ring size
@ 2018-02-08 21:57     ` Dean Nelson
  0 siblings, 0 replies; 9+ messages in thread
From: Dean Nelson @ 2018-02-08 21:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/08/2018 02:34 PM, David Miller wrote:
> From: Dean Nelson <dnelson@redhat.com>
> Date:
> 
>> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536 entries per.
>> The number of entires are stored in the q_len member of struct q_desc_mem. The
>> problem is that q_len being a u16, results in 65536 becoming 0.
>>
>> In getting pointers to descriptors in the rings, the driver uses q_len minus 1
>> as a mask after incrementing the pointer, in order to go back to the beginning
>> and not go past the end of the ring.
>>
>> With the q_len set to 0 the mask is no longer correct and the driver does go
>> beyond the end of the ring, causing various ills. Usually the first thing that
>> shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7 timed out"
>> warning.
>>
>> This patch remedies the problem by changing q_len to a u32.
>>
>> Signed-off-by: Dean Nelson <dnelson@redhat.com>
> 
> Applied, thanks.

Thank you!

> 
> Another way to solve this could have been to encode that length
> as "length - 1"

True. I had pondered that, but felt that since changing q_len's type
didn't add any length to the structure and that it was less impactful
from a number-of-lines of code changed perspective, I'd opt for this
route.

Cavium, if you'd prefer this goes the route that Dave just mentioned,
please let me know and I can make a new patch against what's been
applied?

Thanks,
Dean

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: net: thunder: change q_len's type to handle max ring size
  2018-02-08 21:57     ` Dean Nelson
@ 2018-02-09  4:29       ` Sunil Kovvuri
  -1 siblings, 0 replies; 9+ messages in thread
From: Sunil Kovvuri @ 2018-02-09  4:29 UTC (permalink / raw)
  To: Dean Nelson
  Cc: David Miller, Vadim.Lomovtsev, Robert Richter, Linux Netdev List,
	LKML, Sunil Goutham, LAKML

On Fri, Feb 9, 2018 at 3:27 AM, Dean Nelson <dnelson@redhat.com> wrote:
> On 02/08/2018 02:34 PM, David Miller wrote:
>>
>> From: Dean Nelson <dnelson@redhat.com>
>> Date:
>>
>>> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536
>>> entries per.
>>> The number of entires are stored in the q_len member of struct
>>> q_desc_mem. The
>>> problem is that q_len being a u16, results in 65536 becoming 0.
>>>
>>> In getting pointers to descriptors in the rings, the driver uses q_len
>>> minus 1
>>> as a mask after incrementing the pointer, in order to go back to the
>>> beginning
>>> and not go past the end of the ring.
>>>
>>> With the q_len set to 0 the mask is no longer correct and the driver does
>>> go
>>> beyond the end of the ring, causing various ills. Usually the first thing
>>> that
>>> shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7
>>> timed out"
>>> warning.
>>>
>>> This patch remedies the problem by changing q_len to a u32.
>>>
>>> Signed-off-by: Dean Nelson <dnelson@redhat.com>
>>
>>
>> Applied, thanks.
>
>
> Thank you!
>
>>
>> Another way to solve this could have been to encode that length
>> as "length - 1"
>
>
> True. I had pondered that, but felt that since changing q_len's type
> didn't add any length to the structure and that it was less impactful
> from a number-of-lines of code changed perspective, I'd opt for this
> route.
>
> Cavium, if you'd prefer this goes the route that Dave just mentioned,
> please let me know and I can make a new patch against what's been
> applied?

Thanks for fixing this and i think the current patch is fine.

Thanks,
Sunil.

>
> Thanks,
> Dean
>
>
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* net: thunder: change q_len's type to handle max ring size
@ 2018-02-09  4:29       ` Sunil Kovvuri
  0 siblings, 0 replies; 9+ messages in thread
From: Sunil Kovvuri @ 2018-02-09  4:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Feb 9, 2018 at 3:27 AM, Dean Nelson <dnelson@redhat.com> wrote:
> On 02/08/2018 02:34 PM, David Miller wrote:
>>
>> From: Dean Nelson <dnelson@redhat.com>
>> Date:
>>
>>> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536
>>> entries per.
>>> The number of entires are stored in the q_len member of struct
>>> q_desc_mem. The
>>> problem is that q_len being a u16, results in 65536 becoming 0.
>>>
>>> In getting pointers to descriptors in the rings, the driver uses q_len
>>> minus 1
>>> as a mask after incrementing the pointer, in order to go back to the
>>> beginning
>>> and not go past the end of the ring.
>>>
>>> With the q_len set to 0 the mask is no longer correct and the driver does
>>> go
>>> beyond the end of the ring, causing various ills. Usually the first thing
>>> that
>>> shows up is a "NETDEV WATCHDOG: enP2p1s0f1 (nicvf): transmit queue 7
>>> timed out"
>>> warning.
>>>
>>> This patch remedies the problem by changing q_len to a u32.
>>>
>>> Signed-off-by: Dean Nelson <dnelson@redhat.com>
>>
>>
>> Applied, thanks.
>
>
> Thank you!
>
>>
>> Another way to solve this could have been to encode that length
>> as "length - 1"
>
>
> True. I had pondered that, but felt that since changing q_len's type
> didn't add any length to the structure and that it was less impactful
> from a number-of-lines of code changed perspective, I'd opt for this
> route.
>
> Cavium, if you'd prefer this goes the route that Dave just mentioned,
> please let me know and I can make a new patch against what's been
> applied?

Thanks for fixing this and i think the current patch is fine.

Thanks,
Sunil.

>
> Thanks,
> Dean
>
>
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: net: thunder: change q_len's type to handle max ring size
  2018-02-09  4:29       ` Sunil Kovvuri
@ 2018-02-09 12:52         ` Dean Nelson
  -1 siblings, 0 replies; 9+ messages in thread
From: Dean Nelson @ 2018-02-09 12:52 UTC (permalink / raw)
  To: Sunil Kovvuri
  Cc: David Miller, Vadim.Lomovtsev, Robert Richter, Linux Netdev List,
	LKML, Sunil Goutham, LAKML

On 02/08/2018 10:29 PM, Sunil Kovvuri wrote:
> On Fri, Feb 9, 2018 at 3:27 AM, Dean Nelson <dnelson@redhat.com> wrote:
>> On 02/08/2018 02:34 PM, David Miller wrote:
>>>
>>> From: Dean Nelson <dnelson@redhat.com>
>>> Date:
>>>
>>>> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536
>>>> entries per.
  ...
>>>
>>> Another way to solve this could have been to encode that length
>>> as "length - 1"
>>
>>
>> True. I had pondered that, but felt that since changing q_len's type
>> didn't add any length to the structure and that it was less impactful
>> from a number-of-lines of code changed perspective, I'd opt for this
>> route.
>>
>> Cavium, if you'd prefer this goes the route that Dave just mentioned,
>> please let me know and I can make a new patch against what's been
>> applied?
> 
> Thanks for fixing this and i think the current patch is fine.

You're welcome. And thanks for responding. So I'll leave things as they
are.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* net: thunder: change q_len's type to handle max ring size
@ 2018-02-09 12:52         ` Dean Nelson
  0 siblings, 0 replies; 9+ messages in thread
From: Dean Nelson @ 2018-02-09 12:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/08/2018 10:29 PM, Sunil Kovvuri wrote:
> On Fri, Feb 9, 2018 at 3:27 AM, Dean Nelson <dnelson@redhat.com> wrote:
>> On 02/08/2018 02:34 PM, David Miller wrote:
>>>
>>> From: Dean Nelson <dnelson@redhat.com>
>>> Date:
>>>
>>>> The Cavium thunder nicvf driver supports rx/tx rings of up to 65536
>>>> entries per.
  ...
>>>
>>> Another way to solve this could have been to encode that length
>>> as "length - 1"
>>
>>
>> True. I had pondered that, but felt that since changing q_len's type
>> didn't add any length to the structure and that it was less impactful
>> from a number-of-lines of code changed perspective, I'd opt for this
>> route.
>>
>> Cavium, if you'd prefer this goes the route that Dave just mentioned,
>> please let me know and I can make a new patch against what's been
>> applied?
> 
> Thanks for fixing this and i think the current patch is fine.

You're welcome. And thanks for responding. So I'll leave things as they
are.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-02-09 12:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 19:21 net: thunder: change q_len's type to handle max ring size Dean Nelson
2018-02-08 20:34 ` David Miller
2018-02-08 20:34   ` David Miller
2018-02-08 21:57   ` Dean Nelson
2018-02-08 21:57     ` Dean Nelson
2018-02-09  4:29     ` Sunil Kovvuri
2018-02-09  4:29       ` Sunil Kovvuri
2018-02-09 12:52       ` Dean Nelson
2018-02-09 12:52         ` Dean Nelson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.