* [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()
@ 2025-01-08 17:24 Sudheer Kumar Doredla
2025-01-08 21:24 ` Roger Quadros
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sudheer Kumar Doredla @ 2025-01-08 17:24 UTC (permalink / raw)
To: s-vadapalli, rogerq, andrew+netdev, davem, edumazet, kuba, pabeni,
horms, gnault, linux-omap, netdev, linux-kernel
Cc: s-doredla, t-patil, j-keerthy
CPSW ALE has 75-bit ALE entries stored across three 32-bit words.
The cpsw_ale_get_field() and cpsw_ale_set_field() functions support
ALE field entries spanning up to two words at the most.
The cpsw_ale_get_field() and cpsw_ale_set_field() functions work as
expected when ALE field spanned across word1 and word2, but fails when
ALE field spanned across word2 and word3.
For example, while reading the ALE field spanned across word2 and word3
(i.e. bits 62 to 64), the word3 data shifted to an incorrect position
due to the index becoming zero while flipping.
The same issue occurred when setting an ALE entry.
This issue has not been seen in practice but will be an issue in the future
if the driver supports accessing ALE fields spanning word2 and word3
Fix the methods to handle getting/setting fields spanning up to two words.
Fixes: b685f1a58956 ("net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field()")
Signed-off-by: Sudheer Kumar Doredla <s-doredla@ti.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v2:
1. Updated the subject and commit message
2. Added Fixes tag and reviewed suggested by Simon Horman
---
drivers/net/ethernet/ti/cpsw_ale.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 64bf22cd860c..9eccc7064c2b 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -106,15 +106,15 @@ struct cpsw_ale_dev_id {
static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
{
- int idx, idx2;
+ int idx, idx2, index;
u32 hi_val = 0;
idx = start / 32;
idx2 = (start + bits - 1) / 32;
/* Check if bits to be fetched exceed a word */
if (idx != idx2) {
- idx2 = 2 - idx2; /* flip */
- hi_val = ale_entry[idx2] << ((idx2 * 32) - start);
+ index = 2 - idx2; /* flip */
+ hi_val = ale_entry[index] << ((idx2 * 32) - start);
}
start -= idx * 32;
idx = 2 - idx; /* flip */
@@ -124,16 +124,16 @@ static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits,
u32 value)
{
- int idx, idx2;
+ int idx, idx2, index;
value &= BITMASK(bits);
idx = start / 32;
idx2 = (start + bits - 1) / 32;
/* Check if bits to be set exceed a word */
if (idx != idx2) {
- idx2 = 2 - idx2; /* flip */
- ale_entry[idx2] &= ~(BITMASK(bits + start - (idx2 * 32)));
- ale_entry[idx2] |= (value >> ((idx2 * 32) - start));
+ index = 2 - idx2; /* flip */
+ ale_entry[index] &= ~(BITMASK(bits + start - (idx2 * 32)));
+ ale_entry[index] |= (value >> ((idx2 * 32) - start));
}
start -= idx * 32;
idx = 2 - idx; /* flip */
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()
2025-01-08 17:24 [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field() Sudheer Kumar Doredla
@ 2025-01-08 21:24 ` Roger Quadros
2025-01-09 9:50 ` Siddharth Vadapalli
2025-01-10 2:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Roger Quadros @ 2025-01-08 21:24 UTC (permalink / raw)
To: Sudheer Kumar Doredla, s-vadapalli, andrew+netdev, davem,
edumazet, kuba, pabeni, horms, gnault, linux-omap, netdev,
linux-kernel
Cc: t-patil, j-keerthy
On 08/01/2025 19:24, Sudheer Kumar Doredla wrote:
> CPSW ALE has 75-bit ALE entries stored across three 32-bit words.
> The cpsw_ale_get_field() and cpsw_ale_set_field() functions support
> ALE field entries spanning up to two words at the most.
>
> The cpsw_ale_get_field() and cpsw_ale_set_field() functions work as
> expected when ALE field spanned across word1 and word2, but fails when
> ALE field spanned across word2 and word3.
>
> For example, while reading the ALE field spanned across word2 and word3
> (i.e. bits 62 to 64), the word3 data shifted to an incorrect position
> due to the index becoming zero while flipping.
> The same issue occurred when setting an ALE entry.
>
> This issue has not been seen in practice but will be an issue in the future
> if the driver supports accessing ALE fields spanning word2 and word3
>
> Fix the methods to handle getting/setting fields spanning up to two words.
>
> Fixes: b685f1a58956 ("net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field()")
> Signed-off-by: Sudheer Kumar Doredla <s-doredla@ti.com>
> Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
--
cheers,
-roger
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()
2025-01-08 17:24 [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field() Sudheer Kumar Doredla
2025-01-08 21:24 ` Roger Quadros
@ 2025-01-09 9:50 ` Siddharth Vadapalli
2025-01-10 2:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Siddharth Vadapalli @ 2025-01-09 9:50 UTC (permalink / raw)
To: Sudheer Kumar Doredla
Cc: s-vadapalli, rogerq, andrew+netdev, davem, edumazet, kuba, pabeni,
horms, gnault, linux-omap, netdev, linux-kernel, t-patil,
j-keerthy
On Wed, Jan 08, 2025 at 10:54:33PM +0530, Sudheer Kumar Doredla wrote:
> CPSW ALE has 75-bit ALE entries stored across three 32-bit words.
> The cpsw_ale_get_field() and cpsw_ale_set_field() functions support
> ALE field entries spanning up to two words at the most.
>
> The cpsw_ale_get_field() and cpsw_ale_set_field() functions work as
> expected when ALE field spanned across word1 and word2, but fails when
> ALE field spanned across word2 and word3.
>
> For example, while reading the ALE field spanned across word2 and word3
> (i.e. bits 62 to 64), the word3 data shifted to an incorrect position
> due to the index becoming zero while flipping.
> The same issue occurred when setting an ALE entry.
>
> This issue has not been seen in practice but will be an issue in the future
> if the driver supports accessing ALE fields spanning word2 and word3
>
> Fix the methods to handle getting/setting fields spanning up to two words.
>
> Fixes: b685f1a58956 ("net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field()")
> Signed-off-by: Sudheer Kumar Doredla <s-doredla@ti.com>
> Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Regards,
Siddharth.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()
2025-01-08 17:24 [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field() Sudheer Kumar Doredla
2025-01-08 21:24 ` Roger Quadros
2025-01-09 9:50 ` Siddharth Vadapalli
@ 2025-01-10 2:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-10 2:10 UTC (permalink / raw)
To: Sudheer Kumar Doredla
Cc: s-vadapalli, rogerq, andrew+netdev, davem, edumazet, kuba, pabeni,
horms, gnault, linux-omap, netdev, linux-kernel, t-patil,
j-keerthy
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 8 Jan 2025 22:54:33 +0530 you wrote:
> CPSW ALE has 75-bit ALE entries stored across three 32-bit words.
> The cpsw_ale_get_field() and cpsw_ale_set_field() functions support
> ALE field entries spanning up to two words at the most.
>
> The cpsw_ale_get_field() and cpsw_ale_set_field() functions work as
> expected when ALE field spanned across word1 and word2, but fails when
> ALE field spanned across word2 and word3.
>
> [...]
Here is the summary with links:
- [v2,net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()
https://git.kernel.org/netdev/net/c/03d120f27d05
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-10 2:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 17:24 [PATCH v2 net] net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field() Sudheer Kumar Doredla
2025-01-08 21:24 ` Roger Quadros
2025-01-09 9:50 ` Siddharth Vadapalli
2025-01-10 2:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox