* [dpdk-dev] [PATCH] i40evf: fix return value if command fails
@ 2016-05-05 6:22 Jingjing Wu
2016-05-06 15:13 ` Bruce Richardson
2016-05-10 2:51 ` [dpdk-dev] [PATCH v2] " Jingjing Wu
0 siblings, 2 replies; 5+ messages in thread
From: Jingjing Wu @ 2016-05-05 6:22 UTC (permalink / raw)
To: helin.zhang; +Cc: jingjing.wu, dev
Previously, if message is sent successfully, but no response is
received, function "i40evf_execute_vf_cmd" will return without error.
The root cause is value "err" is overwritten. This patch fixes it.
Fixes: ae19955e7c86 ("i40evf: support reporting PF reset")
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
drivers/net/i40e/i40e_ethdev_vf.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 2bce69b..9380019 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -327,8 +327,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct i40evf_arq_msg_info info;
enum i40evf_aq_result ret;
- int err = -1;
- int i = 0;
+ int err, i = 0;
if (_atomic_set_cmd(vf, args->ops))
return -1;
@@ -346,6 +345,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
return err;
}
+ err = -1;
switch (args->ops) {
case I40E_VIRTCHNL_OP_RESET_VF:
/*no need to process in this function */
@@ -358,10 +358,8 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
if (ret == I40EVF_MSG_CMD) {
err = 0;
break;
- } else if (ret == I40EVF_MSG_ERR) {
- err = -1;
+ } else if (ret == I40EVF_MSG_ERR)
break;
- }
rte_delay_ms(ASQ_DELAY_MS);
/* If don't read msg or read sys event, continue */
} while (i++ < MAX_TRY_TIMES);
--
2.4.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] i40evf: fix return value if command fails
2016-05-05 6:22 [dpdk-dev] [PATCH] i40evf: fix return value if command fails Jingjing Wu
@ 2016-05-06 15:13 ` Bruce Richardson
2016-05-09 1:39 ` Wu, Jingjing
2016-05-10 2:51 ` [dpdk-dev] [PATCH v2] " Jingjing Wu
1 sibling, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2016-05-06 15:13 UTC (permalink / raw)
To: Jingjing Wu; +Cc: helin.zhang, dev
On Thu, May 05, 2016 at 02:22:54PM +0800, Jingjing Wu wrote:
> Previously, if message is sent successfully, but no response is
> received, function "i40evf_execute_vf_cmd" will return without error.
> The root cause is value "err" is overwritten. This patch fixes it.
>
> Fixes: ae19955e7c86 ("i40evf: support reporting PF reset")
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> ---
> drivers/net/i40e/i40e_ethdev_vf.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
> index 2bce69b..9380019 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -327,8 +327,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
> struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
> struct i40evf_arq_msg_info info;
> enum i40evf_aq_result ret;
> - int err = -1;
> - int i = 0;
> + int err, i = 0;
>
> if (_atomic_set_cmd(vf, args->ops))
> return -1;
> @@ -346,6 +345,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
> return err;
> }
>
> + err = -1;
> switch (args->ops) {
> case I40E_VIRTCHNL_OP_RESET_VF:
> /*no need to process in this function */
Hi Jingjing,
this patch changes this return value in this case (I40E_VIRTCHNL_OP_RESET_VF).
Is this intentional - if so it probably needs to be documented in the commit
message. If not, the "err = -1" should be put at the start of the do { } while
loop for the GET_VF_RESOURCES command.
Perhaps to avoid future errors, each case in the switch should explicitly set
it's own default error value?
/Bruce
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] i40evf: fix return value if command fails
2016-05-06 15:13 ` Bruce Richardson
@ 2016-05-09 1:39 ` Wu, Jingjing
0 siblings, 0 replies; 5+ messages in thread
From: Wu, Jingjing @ 2016-05-09 1:39 UTC (permalink / raw)
To: Richardson, Bruce; +Cc: Zhang, Helin, dev
> -----Original Message-----
> From: Richardson, Bruce
> Sent: Friday, May 06, 2016 11:14 PM
> To: Wu, Jingjing
> Cc: Zhang, Helin; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] i40evf: fix return value if command fails
>
> On Thu, May 05, 2016 at 02:22:54PM +0800, Jingjing Wu wrote:
> > Previously, if message is sent successfully, but no response is
> > received, function "i40evf_execute_vf_cmd" will return without error.
> > The root cause is value "err" is overwritten. This patch fixes it.
> >
> > Fixes: ae19955e7c86 ("i40evf: support reporting PF reset")
> > Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> > ---
> > drivers/net/i40e/i40e_ethdev_vf.c | 8 +++-----
> > 1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> > b/drivers/net/i40e/i40e_ethdev_vf.c
> > index 2bce69b..9380019 100644
> > --- a/drivers/net/i40e/i40e_ethdev_vf.c
> > +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> > @@ -327,8 +327,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev,
> struct vf_cmd_info *args)
> > struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> >dev_private);
> > struct i40evf_arq_msg_info info;
> > enum i40evf_aq_result ret;
> > - int err = -1;
> > - int i = 0;
> > + int err, i = 0;
> >
> > if (_atomic_set_cmd(vf, args->ops))
> > return -1;
> > @@ -346,6 +345,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev,
> struct vf_cmd_info *args)
> > return err;
> > }
> >
> > + err = -1;
> > switch (args->ops) {
> > case I40E_VIRTCHNL_OP_RESET_VF:
> > /*no need to process in this function */
>
> Hi Jingjing,
>
> this patch changes this return value in this case
> (I40E_VIRTCHNL_OP_RESET_VF).
> Is this intentional - if so it probably needs to be documented in the commit
> message. If not, the "err = -1" should be put at the start of the do { } while
> loop for the GET_VF_RESOURCES command.
>
> Perhaps to avoid future errors, each case in the switch should explicitly set
> it's own default error value?
>
Yes, you reminded me the case I40E_VIRTCHNL_OP_RESET_VF. Let me rework this.
Thanks
Jingjing
> /Bruce
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH v2] i40evf: fix return value if command fails
2016-05-05 6:22 [dpdk-dev] [PATCH] i40evf: fix return value if command fails Jingjing Wu
2016-05-06 15:13 ` Bruce Richardson
@ 2016-05-10 2:51 ` Jingjing Wu
2016-05-30 16:31 ` Bruce Richardson
1 sibling, 1 reply; 5+ messages in thread
From: Jingjing Wu @ 2016-05-10 2:51 UTC (permalink / raw)
To: helin.zhang; +Cc: dev, jingjing.wu
Previously, if message is sent successfully, but no response is
received, function "i40evf_execute_vf_cmd" will return without error.
The root cause is value "err" is overwritten. This patch fixes it.
Fixes: ae19955e7c86 ("i40evf: support reporting PF reset")
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
v2 changes:
set default err value for each case in switch.
drivers/net/i40e/i40e_ethdev_vf.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..c6efa1a 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -330,8 +330,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct i40evf_arq_msg_info info;
enum i40evf_aq_result ret;
- int err = -1;
- int i = 0;
+ int err, i = 0;
if (_atomic_set_cmd(vf, args->ops))
return -1;
@@ -352,19 +351,19 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
switch (args->ops) {
case I40E_VIRTCHNL_OP_RESET_VF:
/*no need to process in this function */
+ err = 0;
break;
case I40E_VIRTCHNL_OP_VERSION:
case I40E_VIRTCHNL_OP_GET_VF_RESOURCES:
/* for init adminq commands, need to poll the response */
+ err = -1;
do {
ret = i40evf_read_pfmsg(dev, &info);
if (ret == I40EVF_MSG_CMD) {
err = 0;
break;
- } else if (ret == I40EVF_MSG_ERR) {
- err = -1;
+ } else if (ret == I40EVF_MSG_ERR)
break;
- }
rte_delay_ms(ASQ_DELAY_MS);
/* If don't read msg or read sys event, continue */
} while (i++ < MAX_TRY_TIMES);
@@ -373,6 +372,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)
default:
/* for other adminq in running time, waiting the cmd done flag */
+ err = -1;
do {
if (vf->pend_cmd == I40E_VIRTCHNL_OP_UNKNOWN) {
err = 0;
--
2.4.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] i40evf: fix return value if command fails
2016-05-10 2:51 ` [dpdk-dev] [PATCH v2] " Jingjing Wu
@ 2016-05-30 16:31 ` Bruce Richardson
0 siblings, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2016-05-30 16:31 UTC (permalink / raw)
To: Jingjing Wu; +Cc: helin.zhang, dev
On Tue, May 10, 2016 at 10:51:59AM +0800, Jingjing Wu wrote:
> Previously, if message is sent successfully, but no response is
> received, function "i40evf_execute_vf_cmd" will return without error.
> The root cause is value "err" is overwritten. This patch fixes it.
>
> Fixes: ae19955e7c86 ("i40evf: support reporting PF reset")
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> ---
Applied to dpdk-next-net/rel_16_07
/Bruce
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-30 16:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-05 6:22 [dpdk-dev] [PATCH] i40evf: fix return value if command fails Jingjing Wu
2016-05-06 15:13 ` Bruce Richardson
2016-05-09 1:39 ` Wu, Jingjing
2016-05-10 2:51 ` [dpdk-dev] [PATCH v2] " Jingjing Wu
2016-05-30 16:31 ` Bruce Richardson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).