patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yahui Cao <>
To: Jingjing Wu <>, Wenzhuo Lu <>
Cc:,, Qi Zhang <>,
	Yahui Cao <>,
	Xiaolong Ye <>,
	Simei Su <>
Subject: [dpdk-stable] [PATCH v2] net/iavf: fix virtual channel return value error
Date: Mon, 23 Dec 2019 15:11:36 +0800
Message-ID: <> (raw)
In-Reply-To: <>

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 ==

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

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")

Signed-off-by: Yahui Cao <>
 drivers/net/iavf/iavf.h       | 10 ++++++++++
 drivers/net/iavf/iavf_vchnl.c |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index bbd4d75d0..215a1f28f 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -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.
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 14395fed3..285b1fc97 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -214,7 +214,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 					vf->cmd_retval = msg_ret;
 					/* prevent compiler reordering */
-					_clear_cmd(vf);
+					_notify_cmd(vf);
 				} else
 					PMD_DRV_LOG(ERR, "command mismatch,"
 						    "expect %u, get %u",

  reply	other threads:[~2019-12-23  7:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19  5:56 [dpdk-stable] [PATCH] " Yahui Cao
2019-12-23  7:11 ` Yahui Cao [this message]
2019-12-24  4:13 ` [dpdk-stable] [PATCH v3] " Yahui Cao
2019-12-24  5:16   ` Zhang, Qi Z
2020-01-04 10:20     ` Ye Xiaolong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ \
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone