Commit 331bcf45 authored by Emil Tantilov's avatar Emil Tantilov Committed by Jeff Kirsher

ixgbe: fix reading of the buffer returned by the firmware

This patch fixes some issues found in the buffer read portion of
ixgbe_host_interface_command()

- use `bi` as the buffer index counter instead of `i`
- add conversion to native cpu byte ordering on register read
- fix conversion from bytes to dword
- use dword_len instead of buf_len when reading the register
Signed-off-by: default avatarEmil Tantilov <emil.s.tantilov@intel.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 9487dc84
...@@ -3344,7 +3344,7 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length) ...@@ -3344,7 +3344,7 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
u32 length) u32 length)
{ {
u32 hicr, i; u32 hicr, i, bi;
u32 hdr_size = sizeof(struct ixgbe_hic_hdr); u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u8 buf_len, dword_len; u8 buf_len, dword_len;
...@@ -3398,9 +3398,9 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3398,9 +3398,9 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
dword_len = hdr_size >> 2; dword_len = hdr_size >> 2;
/* first pull in the header so we know the buffer length */ /* first pull in the header so we know the buffer length */
for (i = 0; i < dword_len; i++) { for (bi = 0; bi < dword_len; bi++) {
buffer[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i); buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
le32_to_cpus(&buffer[i]); le32_to_cpus(&buffer[bi]);
} }
/* If there is any thing in data position pull it in */ /* If there is any thing in data position pull it in */
...@@ -3414,12 +3414,14 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3414,12 +3414,14 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
goto out; goto out;
} }
/* Calculate length in DWORDs, add one for odd lengths */ /* Calculate length in DWORDs, add 3 for odd lengths */
dword_len = (buf_len + 1) >> 2; dword_len = (buf_len + 3) >> 2;
/* Pull in the rest of the buffer (i is where we left off)*/ /* Pull in the rest of the buffer (bi is where we left off)*/
for (; i < buf_len; i++) for (; bi <= dword_len; bi++) {
buffer[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i); buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
le32_to_cpus(&buffer[bi]);
}
out: out:
return ret_val; return ret_val;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment