Commit 5cffde30 authored by Mark Rustad's avatar Mark Rustad Committed by Jeff Kirsher

ixgbe: Clean up interface for firmware commands

Clean up the interface for issuing firmware commands to use a
void * instead of a u32 *. This eliminates a number of casts.
Also clean up ixgbe_host_interface_command in a few other ways,
eliminating comparisons with 0, redundant parens and minor
formatting issues.
Signed-off-by: default avatarMark Rustad <mark.d.rustad@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 73457165
...@@ -3483,15 +3483,19 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length) ...@@ -3483,15 +3483,19 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
* Communicates with the manageability block. On success return 0 * Communicates with the manageability block. On success return 0
* else return IXGBE_ERR_HOST_INTERFACE_COMMAND. * else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
**/ **/
s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, void *buffer,
u32 length, u32 timeout, u32 length, u32 timeout,
bool return_data) bool return_data)
{ {
u32 hicr, i, bi, fwsts;
u32 hdr_size = sizeof(struct ixgbe_hic_hdr); u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u32 hicr, i, bi, fwsts;
u16 buf_len, dword_len; u16 buf_len, dword_len;
union {
struct ixgbe_hic_hdr hdr;
u32 u32arr[1];
} *bp = buffer;
if (length == 0 || length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) { if (!length || length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) {
hw_dbg(hw, "Buffer length failure buffersize-%d.\n", length); hw_dbg(hw, "Buffer length failure buffersize-%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
} }
...@@ -3502,26 +3506,25 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3502,26 +3506,25 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
/* Check that the host interface is enabled. */ /* Check that the host interface is enabled. */
hicr = IXGBE_READ_REG(hw, IXGBE_HICR); hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if ((hicr & IXGBE_HICR_EN) == 0) { if (!(hicr & IXGBE_HICR_EN)) {
hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n"); hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n");
return IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
} }
/* Calculate length in DWORDs. We must be DWORD aligned */ /* Calculate length in DWORDs. We must be DWORD aligned */
if ((length % (sizeof(u32))) != 0) { if (length % sizeof(u32)) {
hw_dbg(hw, "Buffer length failure, not aligned to dword"); hw_dbg(hw, "Buffer length failure, not aligned to dword");
return IXGBE_ERR_INVALID_ARGUMENT; return IXGBE_ERR_INVALID_ARGUMENT;
} }
dword_len = length >> 2; dword_len = length >> 2;
/* /* The device driver writes the relevant command block
* The device driver writes the relevant command block
* into the ram area. * into the ram area.
*/ */
for (i = 0; i < dword_len; i++) for (i = 0; i < dword_len; i++)
IXGBE_WRITE_REG_ARRAY(hw, IXGBE_FLEX_MNG, IXGBE_WRITE_REG_ARRAY(hw, IXGBE_FLEX_MNG,
i, cpu_to_le32(buffer[i])); i, cpu_to_le32(bp->u32arr[i]));
/* Setting this bit tells the ARC that a new command is pending. */ /* Setting this bit tells the ARC that a new command is pending. */
IXGBE_WRITE_REG(hw, IXGBE_HICR, hicr | IXGBE_HICR_C); IXGBE_WRITE_REG(hw, IXGBE_HICR, hicr | IXGBE_HICR_C);
...@@ -3534,8 +3537,8 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3534,8 +3537,8 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
} }
/* Check command successful completion. */ /* Check command successful completion. */
if ((timeout != 0 && i == timeout) || if ((timeout && i == timeout) ||
(!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV))) { !(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
hw_dbg(hw, "Command has failed with no status valid.\n"); hw_dbg(hw, "Command has failed with no status valid.\n");
return IXGBE_ERR_HOST_INTERFACE_COMMAND; return IXGBE_ERR_HOST_INTERFACE_COMMAND;
} }
...@@ -3548,13 +3551,13 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3548,13 +3551,13 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
/* first pull in the header so we know the buffer length */ /* first pull in the header so we know the buffer length */
for (bi = 0; bi < dword_len; bi++) { for (bi = 0; bi < dword_len; bi++) {
buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); bp->u32arr[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
le32_to_cpus(&buffer[bi]); le32_to_cpus(&bp->u32arr[bi]);
} }
/* If there is any thing in data position pull it in */ /* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len; buf_len = bp->hdr.buf_len;
if (buf_len == 0) if (!buf_len)
return 0; return 0;
if (length < round_up(buf_len, 4) + hdr_size) { if (length < round_up(buf_len, 4) + hdr_size) {
...@@ -3565,10 +3568,10 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, ...@@ -3565,10 +3568,10 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
/* Calculate length in DWORDs, add 3 for odd lengths */ /* Calculate length in DWORDs, add 3 for odd lengths */
dword_len = (buf_len + 3) >> 2; dword_len = (buf_len + 3) >> 2;
/* Pull in the rest of the buffer (bi is where we left off)*/ /* Pull in the rest of the buffer (bi is where we left off) */
for (; bi <= dword_len; bi++) { for (; bi <= dword_len; bi++) {
buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); bp->u32arr[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
le32_to_cpus(&buffer[bi]); le32_to_cpus(&bp->u32arr[bi]);
} }
return 0; return 0;
...@@ -3612,7 +3615,7 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, ...@@ -3612,7 +3615,7 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
fw_cmd.pad2 = 0; fw_cmd.pad2 = 0;
for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) { for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd, ret_val = ixgbe_host_interface_command(hw, &fw_cmd,
sizeof(fw_cmd), sizeof(fw_cmd),
IXGBE_HI_COMMAND_TIMEOUT, IXGBE_HI_COMMAND_TIMEOUT,
true); true);
......
...@@ -111,8 +111,8 @@ void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf); ...@@ -111,8 +111,8 @@ void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps); s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
u8 build, u8 ver); u8 build, u8 ver);
s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, void *, u32 length,
u32 length, u32 timeout, bool return_data); u32 timeout, bool return_data);
void ixgbe_clear_tx_pending(struct ixgbe_hw *hw); void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
bool ixgbe_mng_present(struct ixgbe_hw *hw); bool ixgbe_mng_present(struct ixgbe_hw *hw);
bool ixgbe_mng_enabled(struct ixgbe_hw *hw); bool ixgbe_mng_enabled(struct ixgbe_hw *hw);
......
...@@ -437,8 +437,7 @@ static s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset, ...@@ -437,8 +437,7 @@ static s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
/* one word */ /* one word */
buffer.length = cpu_to_be16(sizeof(u16)); buffer.length = cpu_to_be16(sizeof(u16));
status = ixgbe_host_interface_command(hw, (u32 *)&buffer, status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
sizeof(buffer),
IXGBE_HI_COMMAND_TIMEOUT, false); IXGBE_HI_COMMAND_TIMEOUT, false);
if (status) if (status)
return status; return status;
...@@ -488,7 +487,7 @@ static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw, ...@@ -488,7 +487,7 @@ static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
buffer.address = cpu_to_be32((offset + current_word) * 2); buffer.address = cpu_to_be32((offset + current_word) * 2);
buffer.length = cpu_to_be16(words_to_read * 2); buffer.length = cpu_to_be16(words_to_read * 2);
status = ixgbe_host_interface_command(hw, (u32 *)&buffer, status = ixgbe_host_interface_command(hw, &buffer,
sizeof(buffer), sizeof(buffer),
IXGBE_HI_COMMAND_TIMEOUT, IXGBE_HI_COMMAND_TIMEOUT,
false); false);
...@@ -771,8 +770,7 @@ static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset, ...@@ -771,8 +770,7 @@ static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
buffer.data = data; buffer.data = data;
buffer.address = cpu_to_be32(offset * 2); buffer.address = cpu_to_be32(offset * 2);
status = ixgbe_host_interface_command(hw, (u32 *)&buffer, status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
sizeof(buffer),
IXGBE_HI_COMMAND_TIMEOUT, false); IXGBE_HI_COMMAND_TIMEOUT, false);
return status; return status;
} }
...@@ -814,8 +812,7 @@ static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw) ...@@ -814,8 +812,7 @@ static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN; buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
buffer.req.checksum = FW_DEFAULT_CHECKSUM; buffer.req.checksum = FW_DEFAULT_CHECKSUM;
status = ixgbe_host_interface_command(hw, (u32 *)&buffer, status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
sizeof(buffer),
IXGBE_HI_COMMAND_TIMEOUT, false); IXGBE_HI_COMMAND_TIMEOUT, false);
return status; return status;
} }
...@@ -864,7 +861,7 @@ static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw) ...@@ -864,7 +861,7 @@ static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM; fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
fw_cmd.port_number = hw->bus.lan_id; fw_cmd.port_number = hw->bus.lan_id;
status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd, status = ixgbe_host_interface_command(hw, &fw_cmd,
sizeof(struct ixgbe_hic_disable_rxen), sizeof(struct ixgbe_hic_disable_rxen),
IXGBE_HI_COMMAND_TIMEOUT, true); IXGBE_HI_COMMAND_TIMEOUT, true);
......
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