aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorMark Rustad <mark.d.rustad@intel.com>2016-03-14 14:05:57 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2016-04-07 18:46:11 -0400
commit5cffde309cb3f6f7aaaa459abd3eba245a863f8a (patch)
tree5b9a5c46a31b8abb158e3e008de0b1ec79eef573 /drivers/net/ethernet
parent73457165d71d5ce0e41c0adb7bfa484702c36248 (diff)
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: Mark Rustad <mark.d.rustad@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c39
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.h4
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c13
3 files changed, 28 insertions, 28 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index a2ca9ef0daab..b8cdff7fe673 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -3483,15 +3483,19 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
3483 * Communicates with the manageability block. On success return 0 3483 * Communicates with the manageability block. On success return 0
3484 * else return IXGBE_ERR_HOST_INTERFACE_COMMAND. 3484 * else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
3485 **/ 3485 **/
3486s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, 3486s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, void *buffer,
3487 u32 length, u32 timeout, 3487 u32 length, u32 timeout,
3488 bool return_data) 3488 bool return_data)
3489{ 3489{
3490 u32 hicr, i, bi, fwsts;
3491 u32 hdr_size = sizeof(struct ixgbe_hic_hdr); 3490 u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
3491 u32 hicr, i, bi, fwsts;
3492 u16 buf_len, dword_len; 3492 u16 buf_len, dword_len;
3493 union {
3494 struct ixgbe_hic_hdr hdr;
3495 u32 u32arr[1];
3496 } *bp = buffer;
3493 3497
3494 if (length == 0 || length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) { 3498 if (!length || length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) {
3495 hw_dbg(hw, "Buffer length failure buffersize-%d.\n", length); 3499 hw_dbg(hw, "Buffer length failure buffersize-%d.\n", length);
3496 return IXGBE_ERR_HOST_INTERFACE_COMMAND; 3500 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
3497 } 3501 }
@@ -3502,26 +3506,25 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
3502 3506
3503 /* Check that the host interface is enabled. */ 3507 /* Check that the host interface is enabled. */
3504 hicr = IXGBE_READ_REG(hw, IXGBE_HICR); 3508 hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
3505 if ((hicr & IXGBE_HICR_EN) == 0) { 3509 if (!(hicr & IXGBE_HICR_EN)) {
3506 hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n"); 3510 hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n");
3507 return IXGBE_ERR_HOST_INTERFACE_COMMAND; 3511 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
3508 } 3512 }
3509 3513
3510 /* Calculate length in DWORDs. We must be DWORD aligned */ 3514 /* Calculate length in DWORDs. We must be DWORD aligned */
3511 if ((length % (sizeof(u32))) != 0) { 3515 if (length % sizeof(u32)) {
3512 hw_dbg(hw, "Buffer length failure, not aligned to dword"); 3516 hw_dbg(hw, "Buffer length failure, not aligned to dword");
3513 return IXGBE_ERR_INVALID_ARGUMENT; 3517 return IXGBE_ERR_INVALID_ARGUMENT;
3514 } 3518 }
3515 3519
3516 dword_len = length >> 2; 3520 dword_len = length >> 2;
3517 3521
3518 /* 3522 /* The device driver writes the relevant command block
3519 * The device driver writes the relevant command block
3520 * into the ram area. 3523 * into the ram area.
3521 */ 3524 */
3522 for (i = 0; i < dword_len; i++) 3525 for (i = 0; i < dword_len; i++)
3523 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_FLEX_MNG, 3526 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_FLEX_MNG,
3524 i, cpu_to_le32(buffer[i])); 3527 i, cpu_to_le32(bp->u32arr[i]));
3525 3528
3526 /* Setting this bit tells the ARC that a new command is pending. */ 3529 /* Setting this bit tells the ARC that a new command is pending. */
3527 IXGBE_WRITE_REG(hw, IXGBE_HICR, hicr | IXGBE_HICR_C); 3530 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 } 3537 }
3535 3538
3536 /* Check command successful completion. */ 3539 /* Check command successful completion. */
3537 if ((timeout != 0 && i == timeout) || 3540 if ((timeout && i == timeout) ||
3538 (!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV))) { 3541 !(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
3539 hw_dbg(hw, "Command has failed with no status valid.\n"); 3542 hw_dbg(hw, "Command has failed with no status valid.\n");
3540 return IXGBE_ERR_HOST_INTERFACE_COMMAND; 3543 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
3541 } 3544 }
@@ -3548,13 +3551,13 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
3548 3551
3549 /* first pull in the header so we know the buffer length */ 3552 /* first pull in the header so we know the buffer length */
3550 for (bi = 0; bi < dword_len; bi++) { 3553 for (bi = 0; bi < dword_len; bi++) {
3551 buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); 3554 bp->u32arr[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
3552 le32_to_cpus(&buffer[bi]); 3555 le32_to_cpus(&bp->u32arr[bi]);
3553 } 3556 }
3554 3557
3555 /* If there is any thing in data position pull it in */ 3558 /* If there is any thing in data position pull it in */
3556 buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len; 3559 buf_len = bp->hdr.buf_len;
3557 if (buf_len == 0) 3560 if (!buf_len)
3558 return 0; 3561 return 0;
3559 3562
3560 if (length < round_up(buf_len, 4) + hdr_size) { 3563 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 /* Calculate length in DWORDs, add 3 for odd lengths */ 3568 /* Calculate length in DWORDs, add 3 for odd lengths */
3566 dword_len = (buf_len + 3) >> 2; 3569 dword_len = (buf_len + 3) >> 2;
3567 3570
3568 /* Pull in the rest of the buffer (bi is where we left off)*/ 3571 /* Pull in the rest of the buffer (bi is where we left off) */
3569 for (; bi <= dword_len; bi++) { 3572 for (; bi <= dword_len; bi++) {
3570 buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); 3573 bp->u32arr[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
3571 le32_to_cpus(&buffer[bi]); 3574 le32_to_cpus(&bp->u32arr[bi]);
3572 } 3575 }
3573 3576
3574 return 0; 3577 return 0;
@@ -3612,7 +3615,7 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
3612 fw_cmd.pad2 = 0; 3615 fw_cmd.pad2 = 0;
3613 3616
3614 for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) { 3617 for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
3615 ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd, 3618 ret_val = ixgbe_host_interface_command(hw, &fw_cmd,
3616 sizeof(fw_cmd), 3619 sizeof(fw_cmd),
3617 IXGBE_HI_COMMAND_TIMEOUT, 3620 IXGBE_HI_COMMAND_TIMEOUT,
3618 true); 3621 true);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index 2e290150ab54..6f8e6a56e242 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -111,8 +111,8 @@ void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
111s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps); 111s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
112s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, 112s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
113 u8 build, u8 ver); 113 u8 build, u8 ver);
114s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, 114s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, void *, u32 length,
115 u32 length, u32 timeout, bool return_data); 115 u32 timeout, bool return_data);
116void ixgbe_clear_tx_pending(struct ixgbe_hw *hw); 116void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
117bool ixgbe_mng_present(struct ixgbe_hw *hw); 117bool ixgbe_mng_present(struct ixgbe_hw *hw);
118bool ixgbe_mng_enabled(struct ixgbe_hw *hw); 118bool ixgbe_mng_enabled(struct ixgbe_hw *hw);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 5affac123b75..65832fa30426 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -437,8 +437,7 @@ static s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
437 /* one word */ 437 /* one word */
438 buffer.length = cpu_to_be16(sizeof(u16)); 438 buffer.length = cpu_to_be16(sizeof(u16));
439 439
440 status = ixgbe_host_interface_command(hw, (u32 *)&buffer, 440 status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
441 sizeof(buffer),
442 IXGBE_HI_COMMAND_TIMEOUT, false); 441 IXGBE_HI_COMMAND_TIMEOUT, false);
443 if (status) 442 if (status)
444 return status; 443 return status;
@@ -488,7 +487,7 @@ static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
488 buffer.address = cpu_to_be32((offset + current_word) * 2); 487 buffer.address = cpu_to_be32((offset + current_word) * 2);
489 buffer.length = cpu_to_be16(words_to_read * 2); 488 buffer.length = cpu_to_be16(words_to_read * 2);
490 489
491 status = ixgbe_host_interface_command(hw, (u32 *)&buffer, 490 status = ixgbe_host_interface_command(hw, &buffer,
492 sizeof(buffer), 491 sizeof(buffer),
493 IXGBE_HI_COMMAND_TIMEOUT, 492 IXGBE_HI_COMMAND_TIMEOUT,
494 false); 493 false);
@@ -771,8 +770,7 @@ static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
771 buffer.data = data; 770 buffer.data = data;
772 buffer.address = cpu_to_be32(offset * 2); 771 buffer.address = cpu_to_be32(offset * 2);
773 772
774 status = ixgbe_host_interface_command(hw, (u32 *)&buffer, 773 status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
775 sizeof(buffer),
776 IXGBE_HI_COMMAND_TIMEOUT, false); 774 IXGBE_HI_COMMAND_TIMEOUT, false);
777 return status; 775 return status;
778} 776}
@@ -814,8 +812,7 @@ static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
814 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN; 812 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
815 buffer.req.checksum = FW_DEFAULT_CHECKSUM; 813 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
816 814
817 status = ixgbe_host_interface_command(hw, (u32 *)&buffer, 815 status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
818 sizeof(buffer),
819 IXGBE_HI_COMMAND_TIMEOUT, false); 816 IXGBE_HI_COMMAND_TIMEOUT, false);
820 return status; 817 return status;
821} 818}
@@ -864,7 +861,7 @@ static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
864 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM; 861 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
865 fw_cmd.port_number = hw->bus.lan_id; 862 fw_cmd.port_number = hw->bus.lan_id;
866 863
867 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd, 864 status = ixgbe_host_interface_command(hw, &fw_cmd,
868 sizeof(struct ixgbe_hic_disable_rxen), 865 sizeof(struct ixgbe_hic_disable_rxen),
869 IXGBE_HI_COMMAND_TIMEOUT, true); 866 IXGBE_HI_COMMAND_TIMEOUT, true);
870 867