ixgbe: Fix endian handling for ACI descriptor registers
Subsystems (3)
PATCH v2 1/1 ixgbe: Fix endian handling for ACI descriptor registers
The ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
---
Changelog
v2:
- Updated the patch to include suggested fix
- Updated the commit message to describe the issue
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c +3 -3
@@ -113,7 +113,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,/* Descriptor is written to specific registers */ for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) -IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i), raw_desc[i]); +IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i),cpu_to_le32 (raw_desc[i]));/* SW has to set PF_HICR.C bit and clear PF_HICR.SV and * PF_HICR_EV
@@ -145,7 +145,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_SV )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA (i)); - raw_desc[i] = raw_desc[i]; + raw_desc[i] =le32_to_cpu (raw_desc[i]); } }
@@ -153,7 +153,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_EV ) && !(hicr &IXGBE_PF_HICR_C )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA_2 (i)); - raw_desc[i] = raw_desc[i]; + raw_desc[i] =le32_to_cpu (raw_desc[i]); } }
Signature · 1 line
2.34.1
Quoted 51 lines · Dheeraj Reddy Jonnalagadda
The ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
Fixes 46761fd52a88 ("ixgbe: Add support for E610 FW Admin Command Interface")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>---
Changelogv2:
- Updated the patch to include suggested fix
- Updated the commit message to describe the issuedrivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c +3
-3@@ -113,7 +113,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,/* Descriptor is written to specific registers */ for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) -IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i), raw_desc[i]); +IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i),cpu_to_le32 (raw_desc[i]));/* SW has to set PF_HICR.C bit and clear PF_HICR.SV and * PF_HICR_EV @@ -145,7 +145,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_SV )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA (i)); - raw_desc[i] = raw_desc[i]; + raw_desc[i] =le32_to_cpu (raw_desc[i]); } }@@ -153,7 +153,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_EV ) && !(hicr &IXGBE_PF_HICR_C )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA_2 (i)); - raw_desc[i] = raw_desc[i]; + raw_desc[i] =le32_to_cpu (raw_desc[i]); } }Signature · 1 line
2.34.1
Thanks for fixing it
Quoted 54 lines
-----Original Message-----
From: Dheeraj Reddy Jonnalagadda <[email protected]>
Sent: Wednesday, January 15, 2025 4:41 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kwapulinski, Piotr <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Dheeraj Reddy Jonnalagadda <[email protected]>
Subject: [PATCH v2 net-next] ixgbe: Fix endian handling for ACI descriptor registersThe ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
Fixes 46761fd52a88 ("ixgbe: Add support for E610 FW Admin Command Interface")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>---
Changelogv2:
- Updated the patch to include suggested fix
- Updated the commit message to describe the issue
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c +3
-4@@ -113,7 +113,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,/* Descriptor is written to specific registers */ for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) -IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i), raw_desc[i]); +IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i),cpu_to_le32 (raw_desc[i]));/* SW has to set PF_HICR.C bit and clear PF_HICR.SV and * PF_HICR_EV @@ -145,7 +145,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_SV )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA (i)); - raw_desc[i] = raw_desc[i]; + raw_desc[i] =le32_to_cpu (raw_desc[i]); } }@@ -153,7 +153,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_EV ) && !(hicr &IXGBE_PF_HICR_C )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA_2 (i)); - raw_desc[i] = raw_desc[i]; + raw_desc[i] =le32_to_cpu (raw_desc[i]); } } --
Quoted 2 lines
2.34.1
Please avoid the closed external links in the future. Thank you.
Simon Horman
reviewerQuoted 7 lines · Dheeraj Reddy Jonnalagadda
The ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
Fixes 46761fd52a88 ("ixgbe: Add support for E610 FW Admin Command Interface")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>
Hi Dheeraj,
It seems that Sparse is not very happy about __le32 values appearing where u32 ones are expected. I wonder if something like what is below (compile tested only!) would both address the problem at hand and keep Sparse happy (even if negting much of it's usefulness by using casts).
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +6 -0
@@ -150,6 +150,9 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) }#define IXGBE_WRITE_REG (a, reg, value) ixgbe_write_reg((a), (reg), (value)) +#define IXGBE_WRITE_REG_LE32 (a, reg, value) \ + ixgbe_write_reg((a), (reg), (u32 __force)cpu_to_le32(value)) +#ifndef writeq#define writeq writeqstatic inline void writeq (u64 val,void __iomem *addr)
@@ -172,6 +175,9 @@ static inline void ixgbe_write_reg64(struct ixgbe_hw *hw, u32 reg, u64 value)u32 ixgbe_read_reg (struct ixgbe_hw *hw,u32 reg);#define IXGBE_READ_REG (a, reg) ixgbe_read_reg((a), (reg)) +#define IXGBE_READ_REG_LE32 (a, reg) \ + le32_to_cpu((__le32 __force)ixgbe_read_reg((a), (reg))) +#define IXGBE_WRITE_REG_ARRAY (a, reg, offset, value) \ ixgbe_write_reg((a), (reg) + ((offset) << 2), (value))
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c +3 -3
@@ -113,7 +113,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,/* Descriptor is written to specific registers */ for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) -IXGBE_WRITE_REG (hw,IXGBE_PF_HIDA (i),cpu_to_le32 (raw_desc[i])); +IXGBE_WRITE_REG_LE32 (hw,IXGBE_PF_HIDA (i), raw_desc[i]);/* SW has to set PF_HICR.C bit and clear PF_HICR.SV and * PF_HICR_EV
@@ -145,7 +145,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_SV )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA (i)); - raw_desc[i] =le32_to_cpu (raw_desc[i]); + raw_desc[i] =IXGBE_READ_REG_LE32 (hw,IXGBE_PF_HIDA (i)); } }
@@ -153,7 +153,7 @@ static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,if ((hicr &IXGBE_PF_HICR_EV ) && !(hicr &IXGBE_PF_HICR_C )) {for (i =0 ; i <IXGBE_ACI_DESC_SIZE_IN_DWORDS ; i++) { raw_desc[i] =IXGBE_READ_REG (hw,IXGBE_PF_HIDA_2 (i)); - raw_desc[i] =le32_to_cpu (raw_desc[i]); + raw_desc[i] =IXGBE_READ_REG_LE32 (hw,IXGBE_PF_HIDA_2 (i)); } }
Przemek Kitszel
maintainerQuoted 21 lines · Simon Horman
Quoted 7 lines · Dheeraj Reddy Jonnalagadda
The ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
Fixes 46761fd52a88 ("ixgbe: Add support for E610 FW Admin Command Interface")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>Hi Dheeraj,
It seems that Sparse is not very happy about
__le32values appearing where u32 ones are expected. I wonder if something like what is below (compile tested only!) would both address the problem at hand and keep Sparse happy (even if negting much of it's usefulness by using casts).drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +0
-0
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) · line 151
Quoted 2 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +0
-0@@ -150,6 +150,9 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) }#define IXGBE_WRITE_REG (a, reg, value) ixgbe_write_reg((a), (reg), (value))
Simon,
As all ixgbe registers are LE, it would be beneficial to change ixgbe_write_reg(), as @value should be __le32, (perhaps @reg too). Similar for 64b.
This clearly would not be a "fix" material, as all call sites should be examined to check if they conform.
Quoted 4 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +3
-0+#define IXGBE_WRITE_REG_LE32 (a, reg, value) \ + ixgbe_write_reg((a), (reg), (u32 __force)cpu_to_le32(value)) +
Simon Horman
reviewerQuoted 27 lines · Przemek Kitszel
Quoted 21 lines · Simon Horman
Quoted 7 lines · Dheeraj Reddy Jonnalagadda
The ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
Fixes 46761fd52a88 ("ixgbe: Add support for E610 FW Admin Command Interface")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>Hi Dheeraj,
It seems that Sparse is not very happy about
__le32values appearing where u32 ones are expected. I wonder if something like what is below (compile tested only!) would both address the problem at hand and keep Sparse happy (even if negting much of it's usefulness by using casts).drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +0
-0drivers/net/ethernet/intel/ixgbe/ixgbe_common.h static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) · line 151
Quoted 2 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +0
-0@@ -150,6 +150,9 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) }#define IXGBE_WRITE_REG (a, reg, value) ixgbe_write_reg((a), (reg), (value))Simon,
Quoted 3 lines
As all ixgbe registers are LE, it would be beneficial to change
ixgbe_write_reg(), as @value should be__le32, (perhaps @reg too). Similar for 64b.
Understood, sounds good to me.
Quoted 2 lines
This clearly would not be a "fix" material, as all call sites should be examined to check if they conform.
Sure, that also seems reasonable.
But do you also think a more minimal fix is in order?
Quoted 5 lines
Quoted 4 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +3
-0+#define IXGBE_WRITE_REG_LE32 (a, reg, value) \ + ixgbe_write_reg((a), (reg), (u32 __force)cpu_to_le32(value)) +
Przemek Kitszel
maintainerQuoted 32 lines · Simon Horman
Quoted 27 lines · Przemek Kitszel
Quoted 21 lines · Simon Horman
Quoted 7 lines · Dheeraj Reddy Jonnalagadda
The ixgbe driver was missing proper endian conversion for ACI descriptor register operations. Add the necessary conversions when reading and writing to the registers.
Fixes 46761fd52a88 ("ixgbe: Add support for E610 FW Admin Command Interface")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>Hi Dheeraj,
It seems that Sparse is not very happy about
__le32values appearing where u32 ones are expected. I wonder if something like what is below (compile tested only!) would both address the problem at hand and keep Sparse happy (even if negting much of it's usefulness by using casts).drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +0
-0drivers/net/ethernet/intel/ixgbe/ixgbe_common.h static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) · line 151
Quoted 2 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +0
-0@@ -150,6 +150,9 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value) }#define IXGBE_WRITE_REG (a, reg, value) ixgbe_write_reg((a), (reg), (value))Simon,
Quoted 3 lines
As all ixgbe registers are LE, it would be beneficial to change
ixgbe_write_reg(), as @value should be__le32, (perhaps @reg too). Similar for 64b.
Quoted 8 lines
Understood, sounds good to me.
Quoted 2 lines
This clearly would not be a "fix" material, as all call sites should be examined to check if they conform.
Sure, that also seems reasonable.
But do you also think a more minimal fix is in order?
@Dheeraj, do you want to hone your minimal fix to avoid sparse warnings?
follow up question: do you want to proceed with a full conversion?
@Michal is going to send patches that depend on this "full conversion" next month, so he could also take care of the "full conversion".
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +3
-0+#define IXGBE_WRITE_REG_LE32 (a, reg, value) \ + ixgbe_write_reg((a), (reg), (u32 __force)cpu_to_le32(value)) +
Quoted 2 lines
@Dheeraj, do you want to hone your minimal fix to avoid sparse warnings?
Sure, I will update the patch to avoid sparse warnings.
Quoted 4 lines
follow up question: do you want to proceed with a full conversion?
@Michal is going to send patches that depend on this "full conversion" next month, so he could also take care of the "full conversion".
I don't mind sending a patch with the full conversion. Although that would have quite a few changes. To clarify
1. Are we updating both @reg and @value to be __le32 ?
2. Should we also update ixgbe_read_reg() to also handle and return
__le32 values?
-Dheeraj
Przemek Kitszel
maintainerQuoted 10 lines · Dheeraj Reddy Jonnalagadda
Quoted 2 lines
@Dheeraj, do you want to hone your minimal fix to avoid sparse warnings?
Sure, I will update the patch to avoid sparse warnings.
Quoted 4 lines
follow up question: do you want to proceed with a full conversion?
@Michal is going to send patches that depend on this "full conversion" next month, so he could also take care of the "full conversion".
Quoted 8 lines
I don't mind sending a patch with the full conversion. Although that would have quite a few changes. To clarify
1. Are we updating both @reg and @value to be
__le32?
2. Should we also updateixgbe_read_reg()to also handle and return__le32 values?-Dheeraj
Hi, noone objected, so the answer is 2 x Yes
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Dheeraj,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Dheeraj-Reddy-Jonnalagadda/ixgbe-Fix-endian-handling-for-ACI-descriptor-registers/20250115-114330 base: net-next/main patch link: https://lore.kernel.org/r/20250115034117.172999-1-dheeraj.linuxdev%40gmail.com patch subject: [PATCH v2 net-next] ixgbe: Fix endian handling for ACI descriptor registers config: x86_64-randconfig-r133-20250118 (https://download.01.org/0day-ci/archive/20250118/[email protected]/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250118/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c:116:17: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned int [usertype] value @@ got restricted __le32 [usertype] @@ drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c:116:17: sparse: expected unsigned int [usertype] value drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c:116:17: sparse: got restricted __le32 [usertype] >> drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c:148:39: sparse: sparse: cast to restricted __le32
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c:156:39: sparse: sparse: cast to restricted __le32
vim +116 drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
35
36 /**
37 * ixgbe_aci_send_cmd_execute - execute sending FW Admin Command to FW Admin
38 * Command Interface
39 * @hw: pointer to the HW struct
40 * @desc: descriptor describing the command
41 * @buf: buffer to use for indirect commands (NULL for direct commands)
42 * @buf_size: size of buffer for indirect commands (0 for direct commands)
43 *
44 * Admin Command is sent using CSR by setting descriptor and buffer in specific
45 * registers.
46 *
47 * Return: the exit code of the operation.
48 * * - 0 - success.
49 * * - -EIO - CSR mechanism is not enabled.
50 * * - -EBUSY - CSR mechanism is busy.
51 * * - -EINVAL - buf_size is too big or
52 * invalid argument buf or buf_size.
53 * * - -ETIME - Admin Command X command timeout.
54 * * - -EIO - Admin Command X invalid state of HICR register or
55 * Admin Command failed because of bad opcode was returned or
56 * Admin Command failed with error Y.
57 */
58 static int ixgbe_aci_send_cmd_execute(struct ixgbe_hw *hw,
59 struct ixgbe_aci_desc *desc,
60 void *buf, u16 buf_size)
61 {
62 u16 opcode, buf_tail_size = buf_size % 4;
63 u32 *raw_desc = (u32 *)desc;
64 u32 hicr, i, buf_tail = 0;
65 bool valid_buf = false;
66
67 hw->aci.last_status = IXGBE_ACI_RC_OK;
68
69 /* It's necessary to check if mechanism is enabled */
70 hicr = IXGBE_READ_REG(hw, IXGBE_PF_HICR);
71
72 if (!(hicr & IXGBE_PF_HICR_EN))
73 return -EIO;
74
75 if (hicr & IXGBE_PF_HICR_C) {
76 hw->aci.last_status = IXGBE_ACI_RC_EBUSY;
77 return -EBUSY;
78 }
79
80 opcode = le16_to_cpu(desc->opcode);
81
82 if (buf_size > IXGBE_ACI_MAX_BUFFER_SIZE)
83 return -EINVAL;
84
85 if (buf)
86 desc->flags |= cpu_to_le16(IXGBE_ACI_FLAG_BUF);
87
88 if (desc->flags & cpu_to_le16(IXGBE_ACI_FLAG_BUF)) {
89 if ((buf && !buf_size) ||
90 (!buf && buf_size))
91 return -EINVAL;
92 if (buf && buf_size)
93 valid_buf = true;
94 }
95
96 if (valid_buf) {
97 if (buf_tail_size)
98 memcpy(&buf_tail, buf + buf_size - buf_tail_size,
99 buf_tail_size);
100
101 if (((buf_size + 3) & ~0x3) > IXGBE_ACI_LG_BUF)
102 desc->flags |= cpu_to_le16(IXGBE_ACI_FLAG_LB);
103
104 desc->datalen = cpu_to_le16(buf_size);
105
106 if (desc->flags & cpu_to_le16(IXGBE_ACI_FLAG_RD)) {
107 for (i = 0; i < buf_size / 4; i++)
108 IXGBE_WRITE_REG(hw, IXGBE_PF_HIBA(i), ((u32 *)buf)[i]);
109 if (buf_tail_size)
110 IXGBE_WRITE_REG(hw, IXGBE_PF_HIBA(i), buf_tail);
111 }
112 }
113
114 /* Descriptor is written to specific registers */
115 for (i = 0; i < IXGBE_ACI_DESC_SIZE_IN_DWORDS; i++)
> 116 IXGBE_WRITE_REG(hw, IXGBE_PF_HIDA(i), cpu_to_le32(raw_desc[i]));
117
118 /* SW has to set PF_HICR.C bit and clear PF_HICR.SV and
119 * PF_HICR_EV
120 */
121 hicr = (IXGBE_READ_REG(hw, IXGBE_PF_HICR) | IXGBE_PF_HICR_C) &
122 ~(IXGBE_PF_HICR_SV | IXGBE_PF_HICR_EV);
123 IXGBE_WRITE_REG(hw, IXGBE_PF_HICR, hicr);
124
125 #define MAX_SLEEP_RESP_US 1000
126 #define MAX_TMOUT_RESP_SYNC_US 100000000
127
128 /* Wait for sync Admin Command response */
129 read_poll_timeout(IXGBE_READ_REG, hicr,
130 (hicr & IXGBE_PF_HICR_SV) ||
131 !(hicr & IXGBE_PF_HICR_C),
132 MAX_SLEEP_RESP_US, MAX_TMOUT_RESP_SYNC_US, true, hw,
133 IXGBE_PF_HICR);
134
135 #define MAX_TMOUT_RESP_ASYNC_US 150000000
136
137 /* Wait for async Admin Command response */
138 read_poll_timeout(IXGBE_READ_REG, hicr,
139 (hicr & IXGBE_PF_HICR_EV) ||
140 !(hicr & IXGBE_PF_HICR_C),
141 MAX_SLEEP_RESP_US, MAX_TMOUT_RESP_ASYNC_US, true, hw,
142 IXGBE_PF_HICR);
143
144 /* Read sync Admin Command response */
145 if ((hicr & IXGBE_PF_HICR_SV)) {
146 for (i = 0; i < IXGBE_ACI_DESC_SIZE_IN_DWORDS; i++) {
147 raw_desc[i] = IXGBE_READ_REG(hw, IXGBE_PF_HIDA(i));
> 148 raw_desc[i] = le32_to_cpu(raw_desc[i]); 149 }
150 }
151
152 /* Read async Admin Command response */
153 if ((hicr & IXGBE_PF_HICR_EV) && !(hicr & IXGBE_PF_HICR_C)) {
154 for (i = 0; i < IXGBE_ACI_DESC_SIZE_IN_DWORDS; i++) {
155 raw_desc[i] = IXGBE_READ_REG(hw, IXGBE_PF_HIDA_2(i));
156 raw_desc[i] = le32_to_cpu(raw_desc[i]);
157 }
158 }
159
160 /* Handle timeout and invalid state of HICR register */
161 if (hicr & IXGBE_PF_HICR_C)
162 return -ETIME;
163
164 if (!(hicr & IXGBE_PF_HICR_SV) && !(hicr & IXGBE_PF_HICR_EV))
165 return -EIO;
166
167 /* For every command other than 0x0014 treat opcode mismatch
168 * as an error. Response to 0x0014 command read from HIDA_2
169 * is a descriptor of an event which is expected to contain
170 * different opcode than the command.
171 */
172 if (desc->opcode != cpu_to_le16(opcode) &&
173 opcode != ixgbe_aci_opc_get_fw_event)
174 return -EIO;
175
176 if (desc->retval) {
177 hw->aci.last_status = (enum ixgbe_aci_err)
178 le16_to_cpu(desc->retval);
179 return -EIO;
180 }
181
182 /* Write a response values to a buf */
183 if (valid_buf) {
184 for (i = 0; i < buf_size / 4; i++)
185 ((u32 *)buf)[i] = IXGBE_READ_REG(hw, IXGBE_PF_HIBA(i));
186 if (buf_tail_size) {
187 buf_tail = IXGBE_READ_REG(hw, IXGBE_PF_HIBA(i));
188 memcpy(buf + buf_size - buf_tail_size, &buf_tail,
189 buf_tail_size);
190 }
191 }
192
193 return 0;
194 }
195
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki