patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/iavf: fix virtual channel return value error
@ 2019-12-19  5:56 Yahui Cao
  2019-12-23  7:11 ` [dpdk-stable] [PATCH v2] " Yahui Cao
  2019-12-24  4:13 ` [dpdk-stable] [PATCH v3] " Yahui Cao
  0 siblings, 2 replies; 5+ messages in thread
From: Yahui Cao @ 2019-12-19  5:56 UTC (permalink / raw)
  To: Jingjing Wu, Wenzhuo Lu
  Cc: dev, stable, Qi Zhang, Yahui Cao, Xiaolong Ye, Simei Su

Original virtual channel return value is overwritten by _clear_cmd().

Fixes: 22b123a36d07 ("net/avf: initialize PMD")
Cc: stable@dpdk.org

Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
 drivers/net/iavf/iavf.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index bbd4d75d0..b12ad4119 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -181,7 +181,6 @@ _clear_cmd(struct iavf_info *vf)
 {
 	rte_wmb();
 	vf->pend_cmd = VIRTCHNL_OP_UNKNOWN;
-	vf->cmd_retval = VIRTCHNL_STATUS_SUCCESS;
 }
 
 /* Check there is pending cmd in execution. If none, set new command. */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-stable] [PATCH v2] net/iavf: fix virtual channel return value error
  2019-12-19  5:56 [dpdk-stable] [PATCH] net/iavf: fix virtual channel return value error Yahui Cao
@ 2019-12-23  7:11 ` Yahui Cao
  2019-12-24  4:13 ` [dpdk-stable] [PATCH v3] " Yahui Cao
  1 sibling, 0 replies; 5+ messages in thread
From: Yahui Cao @ 2019-12-23  7:11 UTC (permalink / raw)
  To: Jingjing Wu, Wenzhuo Lu
  Cc: dev, stable, Qi Zhang, Yahui Cao, Xiaolong Ye, Simei Su

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

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 */
 					rte_compiler_barrier();
-					_clear_cmd(vf);
+					_notify_cmd(vf);
 				} else
 					PMD_DRV_LOG(ERR, "command mismatch,"
 						    "expect %u, get %u",
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-stable] [PATCH v3] net/iavf: fix virtual channel return value error
  2019-12-19  5:56 [dpdk-stable] [PATCH] net/iavf: fix virtual channel return value error Yahui Cao
  2019-12-23  7:11 ` [dpdk-stable] [PATCH v2] " Yahui Cao
@ 2019-12-24  4:13 ` Yahui Cao
  2019-12-24  5:16   ` Zhang, Qi Z
  1 sibling, 1 reply; 5+ messages in thread
From: Yahui Cao @ 2019-12-24  4:13 UTC (permalink / raw)
  To: Jingjing Wu, Wenzhuo Lu
  Cc: dev, stable, Qi Zhang, Yahui Cao, Xiaolong Ye, Simei Su

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. In addition, since _notify_cmd()
contains rte_wmb(), rte_compiler_barrier() is not necessary.

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       | 11 +++++++++++
 drivers/net/iavf/iavf_vchnl.c |  9 +++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index bbd4d75d0..84f821354 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -173,6 +173,17 @@ 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, uint32_t msg_ret)
+{
+	vf->cmd_retval = msg_ret;
+	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..cf0f6458e 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -210,12 +210,9 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 							info.msg_len);
 			} else {
 				/* read message and it's expected one */
-				if (msg_opc == vf->pend_cmd) {
-					vf->cmd_retval = msg_ret;
-					/* prevent compiler reordering */
-					rte_compiler_barrier();
-					_clear_cmd(vf);
-				} else
+				if (msg_opc == vf->pend_cmd)
+					_notify_cmd(vf, msg_ret);
+				else
 					PMD_DRV_LOG(ERR, "command mismatch,"
 						    "expect %u, get %u",
 						    vf->pend_cmd, msg_opc);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [PATCH v3] net/iavf: fix virtual channel return value error
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Qi Z @ 2019-12-24  5:16 UTC (permalink / raw)
  To: Cao, Yahui, Wu, Jingjing, Lu, Wenzhuo
  Cc: dev, stable, Ye, Xiaolong, Su, Simei



> -----Original Message-----
> From: Cao, Yahui <yahui.cao@intel.com>
> Sent: Tuesday, December 24, 2019 12:13 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Cao,
> Yahui <yahui.cao@intel.com>; Ye, Xiaolong <xiaolong.ye@intel.com>; Su,
> Simei <simei.su@intel.com>
> Subject: [PATCH v3] net/iavf: fix virtual channel return value error
> 
> 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. In addition, since _notify_cmd() contains
> rte_wmb(), rte_compiler_barrier() is not necessary.
> 
> 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>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [PATCH v3] net/iavf: fix virtual channel return value error
  2019-12-24  5:16   ` Zhang, Qi Z
@ 2020-01-04 10:20     ` Ye Xiaolong
  0 siblings, 0 replies; 5+ messages in thread
From: Ye Xiaolong @ 2020-01-04 10:20 UTC (permalink / raw)
  To: Zhang, Qi Z; +Cc: Cao, Yahui, Wu, Jingjing, Lu, Wenzhuo, dev, stable, Su, Simei

On 12/24, Zhang, Qi Z wrote:
>
>
>> -----Original Message-----
>> From: Cao, Yahui <yahui.cao@intel.com>
>> Sent: Tuesday, December 24, 2019 12:13 PM
>> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
>> <wenzhuo.lu@intel.com>
>> Cc: dev@dpdk.org; stable@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Cao,
>> Yahui <yahui.cao@intel.com>; Ye, Xiaolong <xiaolong.ye@intel.com>; Su,
>> Simei <simei.su@intel.com>
>> Subject: [PATCH v3] net/iavf: fix virtual channel return value error
>> 
>> 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. In addition, since _notify_cmd() contains
>> rte_wmb(), rte_compiler_barrier() is not necessary.
>> 
>> 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>
>
>Acked-by: Qi Zhang <qi.z.zhang@intel.com>
>

Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>

Applied to dpdk-next-net-intel, Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-04 10:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19  5:56 [dpdk-stable] [PATCH] net/iavf: fix virtual channel return value error Yahui Cao
2019-12-23  7:11 ` [dpdk-stable] [PATCH v2] " Yahui Cao
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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 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/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git