[v2] net/iavf: fix virtual channel return value error
Checks
Commit Message
In iavf_handle_virtchnl_msg(), it is not appropriate for _clear_cmd()
to be used as a notification to forground thread. So introduce
_notify_cmd() to fix this error.
Sending msg from VF to PF is mainly by calling iavf_execute_vf_cmd(),
the whole virtchnl msg process is like,
iavf_execute_vf_cmd() will call iavf_aq_send_msg_to_pf() to send
msg and then polling the cmd done flag as "if (vf->pend_cmd ==
VIRTCHNL_OP_UNKNOWN)"
When reply msg is returned by pf, iavf_handle_virtchnl_msg() in
isr will read msg return value by "vf->cmd_retval = msg_ret" and
immediately set the cmd done flag by calling _clear_cmd() to
notify the iavf_execute_vf_cmd().
iavf_execute_vf_cmd() find the cmd done flag is set and then
check whether command return value vf->cmd_retval is success or
not.
However _clear_cmd() also resets the vf->cmd_retval to success,
overwriting the actual return value which is used for
diagnosis. So iavf_execute_vf_cmd() will always find
vf->cmd_retval is success and then return success.
Fixes: 22b123a36d07 ("net/avf: initialize PMD")
Cc: stable@dpdk.org
Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
drivers/net/iavf/iavf.h | 10 ++++++++++
drivers/net/iavf/iavf_vchnl.c | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
@@ -173,6 +173,16 @@ struct iavf_cmd_info {
uint32_t out_size; /* buffer size for response */
};
+/* notify current command done. Only call in case execute
+ * _atomic_set_cmd successfully.
+ */
+static inline void
+_notify_cmd(struct iavf_info *vf)
+{
+ rte_wmb();
+ vf->pend_cmd = VIRTCHNL_OP_UNKNOWN;
+}
+
/* clear current command. Only call in case execute
* _atomic_set_cmd successfully.
*/
@@ -214,7 +214,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
vf->cmd_retval = msg_ret;
/* prevent compiler reordering */
rte_compiler_barrier();
- _clear_cmd(vf);
+ _notify_cmd(vf);
} else
PMD_DRV_LOG(ERR, "command mismatch,"
"expect %u, get %u",