i40evf: Use le32_to_cpu before evaluating HW desc fields
authorTushar Dave <tushar.n.dave@oracle.com>
Thu, 22 Jun 2017 16:44:32 +0000 (09:44 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 26 Jul 2017 10:25:21 +0000 (03:25 -0700)
i40e hardware descriptor fields are in little-endian format. Driver
must use le32_to_cpu while evaluating these fields otherwise on
big-endian arch we end up evaluating incorrect values, cause errors
like:
i40evf 0000:03:0a.0: Expected response 24 from PF, received 402653184
i40evf 0000:03:0a.1: Expected response 7 from PF, received 117440512

Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com>
Reviewed-by: Shannon Nelson <shannon.nelson@oracle.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40evf/i40evf_main.c

index 7c213a3479093c040e6e6c4eeaaa020b65e9a3ca..93536b9fc6292452a6420ec67d39d27eeed7258d 100644 (file)
@@ -1957,8 +1957,8 @@ static void i40evf_adminq_task(struct work_struct *work)
                container_of(work, struct i40evf_adapter, adminq_task);
        struct i40e_hw *hw = &adapter->hw;
        struct i40e_arq_event_info event;
-       struct virtchnl_msg *v_msg;
-       i40e_status ret;
+       enum virtchnl_ops v_op;
+       i40e_status ret, v_ret;
        u32 val, oldval;
        u16 pending;
 
@@ -1970,15 +1970,15 @@ static void i40evf_adminq_task(struct work_struct *work)
        if (!event.msg_buf)
                goto out;
 
-       v_msg = (struct virtchnl_msg *)&event.desc;
        do {
                ret = i40evf_clean_arq_element(hw, &event, &pending);
-               if (ret || !v_msg->v_opcode)
+               v_op = (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
+               v_ret = (i40e_status)le32_to_cpu(event.desc.cookie_low);
+
+               if (ret || !v_op)
                        break; /* No event to process or error cleaning ARQ */
 
-               i40evf_virtchnl_completion(adapter, v_msg->v_opcode,
-                                          (i40e_status)v_msg->v_retval,
-                                          event.msg_buf,
+               i40evf_virtchnl_completion(adapter, v_op, v_ret, event.msg_buf,
                                           event.msg_len);
                if (pending != 0)
                        memset(event.msg_buf, 0, I40EVF_MAX_AQ_BUF_SIZE);