net/i40e/base: add byte swaps in PHY register access
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 9 Jan 2018 20:30:04 +0000 (15:30 -0500)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Add byte swap commandwhen transferring data between memory and firmware
while using PHY register access functions. Endianness also need to be
handled correctly during these swaps.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/i40e/base/i40e_adminq_cmd.h
drivers/net/i40e/base/i40e_common.c

index 30e31ed..fcfb902 100644 (file)
@@ -2183,8 +2183,8 @@ struct i40e_aqc_phy_register_access {
 #define I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE 2
        u8      dev_addres;
        u8      reserved1[2];
-       u32     reg_address;
-       u32     reg_value;
+       __le32  reg_address;
+       __le32  reg_value;
        u8      reserved2[4];
 };
 
index 1dc5c62..7e7fa22 100644 (file)
@@ -7018,8 +7018,8 @@ enum i40e_status_code i40e_aq_set_phy_register(struct i40e_hw *hw,
 
        cmd->phy_interface = phy_select;
        cmd->dev_addres = dev_addr;
-       cmd->reg_address = reg_addr;
-       cmd->reg_value = reg_val;
+       cmd->reg_address = CPU_TO_LE32(reg_addr);
+       cmd->reg_value = CPU_TO_LE32(reg_val);
 
        status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
 
@@ -7052,11 +7052,11 @@ enum i40e_status_code i40e_aq_get_phy_register(struct i40e_hw *hw,
 
        cmd->phy_interface = phy_select;
        cmd->dev_addres = dev_addr;
-       cmd->reg_address = reg_addr;
+       cmd->reg_address = CPU_TO_LE32(reg_addr);
 
        status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
        if (!status)
-               *reg_val = cmd->reg_value;
+               *reg_val = LE32_TO_CPU(cmd->reg_value);
 
        return status;
 }