[dpdk-dev] net/i40e: fix wrong return value when handling PF message

Message ID 1482308980-76777-1-git-send-email-wenzhuo.lu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Wenzhuo Lu Dec. 21, 2016, 8:29 a.m. UTC
  When VF receives a message from PF, it should check the return
value. But in i40evf_execute_vf_cmd the value is ignored and not
returned to the caller.

Fixes: 95cd21f45d1b ("i40evf: allocate virtchnl commands buffer per VF")

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/i40e/i40e_ethdev.h    | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit Dec. 22, 2016, 4:59 p.m. UTC | #1
On 12/21/2016 8:29 AM, Wenzhuo Lu wrote:
> When VF receives a message from PF, it should check the return
> value. But in i40evf_execute_vf_cmd the value is ignored and not
> returned to the caller.
> 
> Fixes: 95cd21f45d1b ("i40evf: allocate virtchnl commands buffer per VF")
> 
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.h    | 2 +-
>  drivers/net/i40e/i40e_ethdev_vf.c | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
> index 298cef4..28111a7 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -527,7 +527,7 @@ struct i40e_vf {
>  	enum i40e_aq_link_speed link_speed;
>  	bool vf_reset;
>  	volatile uint32_t pend_cmd; /* pending command not finished yet */
> -	uint32_t cmd_retval; /* return value of the cmd response from PF */
> +	int32_t cmd_retval; /* return value of the cmd response from PF */
>  	u16 pend_msg; /* flags indicates events from pf not handled yet */
>  	uint8_t *aq_resp; /* buffer to store the adminq response from PF */
>  
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
> index 12da0ec..5d25764 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -361,6 +361,7 @@ struct rte_i40evf_xstats_name_off {
>  		err = -1;
>  		do {
>  			ret = i40evf_read_pfmsg(dev, &info);
> +			vf->cmd_retval = info.result;

This is for op_version, and op_get_vf_resources! Which seems good.

Is something similar required for other commands (default case of the
switch),
but for them not sure how to get retval (event.desc.cookie_low to
vf->cmd_retval) ?

>  			if (ret == I40EVF_MSG_CMD) {
>  				err = 0;
>  				break;
>
  
Wenzhuo Lu Jan. 3, 2017, 2:58 a.m. UTC | #2
Hi Ferruh,


> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Friday, December 23, 2016 12:59 AM
> To: Lu, Wenzhuo; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix wrong return value when handling
> PF message
> 
> On 12/21/2016 8:29 AM, Wenzhuo Lu wrote:
> > When VF receives a message from PF, it should check the return value.
> > But in i40evf_execute_vf_cmd the value is ignored and not returned to
> > the caller.
> >
> > Fixes: 95cd21f45d1b ("i40evf: allocate virtchnl commands buffer per
> > VF")
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.h    | 2 +-
> >  drivers/net/i40e/i40e_ethdev_vf.c | 1 +
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.h
> > b/drivers/net/i40e/i40e_ethdev.h index 298cef4..28111a7 100644
> > --- a/drivers/net/i40e/i40e_ethdev.h
> > +++ b/drivers/net/i40e/i40e_ethdev.h
> > @@ -527,7 +527,7 @@ struct i40e_vf {
> >  	enum i40e_aq_link_speed link_speed;
> >  	bool vf_reset;
> >  	volatile uint32_t pend_cmd; /* pending command not finished yet */
> > -	uint32_t cmd_retval; /* return value of the cmd response from PF */
> > +	int32_t cmd_retval; /* return value of the cmd response from PF */
> >  	u16 pend_msg; /* flags indicates events from pf not handled yet */
> >  	uint8_t *aq_resp; /* buffer to store the adminq response from PF */
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> > b/drivers/net/i40e/i40e_ethdev_vf.c
> > index 12da0ec..5d25764 100644
> > --- a/drivers/net/i40e/i40e_ethdev_vf.c
> > +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> > @@ -361,6 +361,7 @@ struct rte_i40evf_xstats_name_off {
> >  		err = -1;
> >  		do {
> >  			ret = i40evf_read_pfmsg(dev, &info);
> > +			vf->cmd_retval = info.result;
> 
> This is for op_version, and op_get_vf_resources! Which seems good.
> 
> Is something similar required for other commands (default case of the switch),
> but for them not sure how to get retval (event.desc.cookie_low to
> vf->cmd_retval) ?
There's no same issue for the other ops :)

> 
> >  			if (ret == I40EVF_MSG_CMD) {
> >  				err = 0;
> >  				break;
> >
  
Ferruh Yigit Jan. 3, 2017, 5:13 p.m. UTC | #3
On 12/21/2016 8:29 AM, Wenzhuo Lu wrote:
> When VF receives a message from PF, it should check the return
> value. But in i40evf_execute_vf_cmd the value is ignored and not
> returned to the caller.
> 
> Fixes: 95cd21f45d1b ("i40evf: allocate virtchnl commands buffer per VF")
> 
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

CC: stable@dpdk.org

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 298cef4..28111a7 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -527,7 +527,7 @@  struct i40e_vf {
 	enum i40e_aq_link_speed link_speed;
 	bool vf_reset;
 	volatile uint32_t pend_cmd; /* pending command not finished yet */
-	uint32_t cmd_retval; /* return value of the cmd response from PF */
+	int32_t cmd_retval; /* return value of the cmd response from PF */
 	u16 pend_msg; /* flags indicates events from pf not handled yet */
 	uint8_t *aq_resp; /* buffer to store the adminq response from PF */
 
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 12da0ec..5d25764 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -361,6 +361,7 @@  struct rte_i40evf_xstats_name_off {
 		err = -1;
 		do {
 			ret = i40evf_read_pfmsg(dev, &info);
+			vf->cmd_retval = info.result;
 			if (ret == I40EVF_MSG_CMD) {
 				err = 0;
 				break;