[07/47] net/bnxt: tf_core: fix slice count in case of HA entry move

Message ID 20240830140049.1715230-8-sriharsha.basavapatna@broadcom.com (mailing list archive)
State Superseded
Delegated to: Ajit Khaparde
Headers
Series TruFlow update for Thor2 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sriharsha Basavapatna Aug. 30, 2024, 2 p.m. UTC
From: Sangtani Parag Satishbhai <parag-satishbhai.sangtani@broadcom.com>

When entries are moved during HA, a shared move function transfers
TCAM entries by using get/set message APIs, and the slice number of the
entry is required to accomplish the movement. The slice number is
calculated as the product of row_slice and entry size. Before calling
get/set message APIs, the source entry size should be updated with the
destination entry size; otherwise, it might corrupt the slice number field,
which may result in writing an incorrect entry. A fix is made which now
copies the entry size from the source to the destination before calling
get/set message APIs, ensuring the correct slice number is modified.

Signed-off-by: Sangtani Parag Satishbhai <parag-satishbhai.sangtani@broadcom.com>
Reviewed-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
---
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
index 349f52caba..33b1e4121e 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
@@ -1717,6 +1717,11 @@  cfa_tcam_mgr_shared_entry_move(int sess_idx, struct cfa_tcam_mgr_context *contex
 	uint8_t  key[CFA_TCAM_MGR_MAX_KEY_SIZE];
 	uint8_t  mask[CFA_TCAM_MGR_MAX_KEY_SIZE];
 	uint8_t  result[CFA_TCAM_MGR_MAX_KEY_SIZE];
+	/*
+	 * Copy entry size before moving else if
+	 * slice number is non zero and entry size is zero it will cause issues
+	 */
+	dst_row->entry_size = src_row->entry_size;
 
 	int rc;
 
@@ -1791,7 +1796,6 @@  cfa_tcam_mgr_shared_entry_move(int sess_idx, struct cfa_tcam_mgr_context *contex
 
 	ROW_ENTRY_SET(dst_row, dst_row_slice);
 	dst_row->entries[dst_row_slice] = entry_id;
-	dst_row->entry_size = src_row->entry_size;
 	dst_row->priority = src_row->priority;
 	ROW_ENTRY_CLEAR(src_row, entry->slice);
 	entry->row = dst_row_index;