diff mbox series

[net]

Message ID 20250108081303.228653-1-s-doredla@ti.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-01-08--09-00 (tests: 880)

Commit Message

Sudheer Kumar Doredla Jan. 8, 2025, 8:13 a.m. UTC
cpsw_ale_get_field was returning incorrect data when requesting higher
word fields. Additionally, cpsw_ale_set_field was writing incorrect 
data into the ALE entry while updating.

For example, while reading word2, word3 fields (62 to 64 bits), the word3
data was shifted to an incorrect position after reading. The same issue
occurred when setting an ALE entry.

This patch fixes the shifting of the word3 data by aligning it with the
required fileds, ensuring the correct value is returned from
cpsw_ale_get_field, even for higher words.
It also ensures the correct vlaue is written into ALE entry using
cpsw_ale_set_field.

Signed-off-by: Sudheer Kumar Doredla <s-doredla@ti.com>
---
 drivers/net/ethernet/ti/cpsw_ale.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Simon Horman Jan. 8, 2025, 10:21 a.m. UTC | #1
On Wed, Jan 08, 2025 at 01:43:03PM +0530, Sudheer Kumar Doredla wrote:
> cpsw_ale_get_field was returning incorrect data when requesting higher
> word fields. Additionally, cpsw_ale_set_field was writing incorrect 
> data into the ALE entry while updating.
> 
> For example, while reading word2, word3 fields (62 to 64 bits), the word3
> data was shifted to an incorrect position after reading. The same issue
> occurred when setting an ALE entry.
> 
> This patch fixes the shifting of the word3 data by aligning it with the
> required fileds, ensuring the correct value is returned from
> cpsw_ale_get_field, even for higher words.
> It also ensures the correct vlaue is written into ALE entry using
> cpsw_ale_set_field.

Hi Sudheer,

It would be interesting to include some information on how this problem
manifests in practice.

And, as a fix for net this should have a fixes tag.
(Immediately above the other tags, no blank line in between.)

Perhaps this one is appropriate?

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>

And, lastly, the subject for this patch seems to be missing.
Please add one:

	Subject: [PATCH v2 net] net: ethernet: ti: cpsw_ale: ...

The code changes themselves look good to me.
So with the above addressed, feel free to include.

Reviewed-by: Simon Horman <horms@kernel.org>

...
diff mbox series

Patch

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 */