Skip to content

Commit efccf65

Browse files
Hao ChenPaolo Abeni
authored andcommitted
net: hns3: fix byte order conversion issue in hclge_dbg_fd_tcam_read()
req1->tcam_data is defined as "u8 tcam_data[8]", and we convert it as (u32 *) without considerring byte order conversion, it may result in printing wrong data for tcam_data. Convert tcam_data to (__le32 *) first to fix it. Fixes: b5a0b70 ("net: hns3: refactor dump fd tcam of debugfs") Signed-off-by: Hao Chen <chenhao418@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent dd2bbc2 commit efccf65

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
15191519
struct hclge_desc desc[3];
15201520
int pos = 0;
15211521
int ret, i;
1522-
u32 *req;
1522+
__le32 *req;
15231523

15241524
hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_FD_TCAM_OP, true);
15251525
desc[0].flag |= cpu_to_le16(HCLGE_COMM_CMD_FLAG_NEXT);
@@ -1544,22 +1544,22 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, bool sel_x,
15441544
tcam_msg.loc);
15451545

15461546
/* tcam_data0 ~ tcam_data1 */
1547-
req = (u32 *)req1->tcam_data;
1547+
req = (__le32 *)req1->tcam_data;
15481548
for (i = 0; i < 2; i++)
15491549
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
1550-
"%08x\n", *req++);
1550+
"%08x\n", le32_to_cpu(*req++));
15511551

15521552
/* tcam_data2 ~ tcam_data7 */
1553-
req = (u32 *)req2->tcam_data;
1553+
req = (__le32 *)req2->tcam_data;
15541554
for (i = 0; i < 6; i++)
15551555
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
1556-
"%08x\n", *req++);
1556+
"%08x\n", le32_to_cpu(*req++));
15571557

15581558
/* tcam_data8 ~ tcam_data12 */
1559-
req = (u32 *)req3->tcam_data;
1559+
req = (__le32 *)req3->tcam_data;
15601560
for (i = 0; i < 5; i++)
15611561
pos += scnprintf(tcam_buf + pos, HCLGE_DBG_TCAM_BUF_SIZE - pos,
1562-
"%08x\n", *req++);
1562+
"%08x\n", le32_to_cpu(*req++));
15631563

15641564
return ret;
15651565
}

0 commit comments

Comments
 (0)