diff options
author | Emil Tantilov <emil.s.tantilov@intel.com> | 2011-10-22 01:21:32 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-11-02 19:55:48 -0400 |
commit | 331bcf45feb76d507a769d9d3b26ff5626804117 (patch) | |
tree | 6c3d3ba0a7f440d263a776aa55d44caa41b09c59 /drivers | |
parent | 9487dc844054e1fc691fb82f4e19da337e2ca35e (diff) |
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: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 834f044be4c3..f1365fef4ed2 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | |||
@@ -3344,7 +3344,7 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length) | |||
3344 | static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, | 3344 | static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, |
3345 | u32 length) | 3345 | u32 length) |
3346 | { | 3346 | { |
3347 | u32 hicr, i; | 3347 | u32 hicr, i, bi; |
3348 | u32 hdr_size = sizeof(struct ixgbe_hic_hdr); | 3348 | u32 hdr_size = sizeof(struct ixgbe_hic_hdr); |
3349 | u8 buf_len, dword_len; | 3349 | u8 buf_len, dword_len; |
3350 | 3350 | ||
@@ -3398,9 +3398,9 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, | |||
3398 | dword_len = hdr_size >> 2; | 3398 | dword_len = hdr_size >> 2; |
3399 | 3399 | ||
3400 | /* first pull in the header so we know the buffer length */ | 3400 | /* first pull in the header so we know the buffer length */ |
3401 | for (i = 0; i < dword_len; i++) { | 3401 | for (bi = 0; bi < dword_len; bi++) { |
3402 | buffer[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i); | 3402 | buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); |
3403 | le32_to_cpus(&buffer[i]); | 3403 | le32_to_cpus(&buffer[bi]); |
3404 | } | 3404 | } |
3405 | 3405 | ||
3406 | /* If there is any thing in data position pull it in */ | 3406 | /* 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 | goto out; | 3414 | goto out; |
3415 | } | 3415 | } |
3416 | 3416 | ||
3417 | /* Calculate length in DWORDs, add one for odd lengths */ | 3417 | /* Calculate length in DWORDs, add 3 for odd lengths */ |
3418 | dword_len = (buf_len + 1) >> 2; | 3418 | dword_len = (buf_len + 3) >> 2; |
3419 | 3419 | ||
3420 | /* Pull in the rest of the buffer (i is where we left off)*/ | 3420 | /* Pull in the rest of the buffer (bi is where we left off)*/ |
3421 | for (; i < buf_len; i++) | 3421 | for (; bi <= dword_len; bi++) { |
3422 | buffer[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i); | 3422 | buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); |
3423 | le32_to_cpus(&buffer[bi]); | ||
3424 | } | ||
3423 | 3425 | ||
3424 | out: | 3426 | out: |
3425 | return ret_val; | 3427 | return ret_val; |