From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC954A0352 for ; Mon, 23 Dec 2019 08:12:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 857641BE51; Mon, 23 Dec 2019 08:12:32 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 981AD1C01; Mon, 23 Dec 2019 08:12:29 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2019 23:12:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,346,1571727600"; d="scan'208";a="214160549" Received: from dpdk-yahui-skylake.sh.intel.com ([10.67.119.16]) by fmsmga008.fm.intel.com with ESMTP; 22 Dec 2019 23:12:27 -0800 From: Yahui Cao To: Jingjing Wu , Wenzhuo Lu Cc: dev@dpdk.org, stable@dpdk.org, Qi Zhang , Yahui Cao , Xiaolong Ye , Simei Su Date: Mon, 23 Dec 2019 15:11:36 +0800 Message-Id: <20191223071137.7166-1-yahui.cao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219055601.78490-1-yahui.cao@intel.com> References: <20191219055601.78490-1-yahui.cao@intel.com> Subject: [dpdk-stable] [PATCH v2] net/iavf: fix virtual channel return value error X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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