net/idpf: refine idpf_dev_vport_init() function

Message ID 20230626140606.490871-1-mingxia.liu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/idpf: refine idpf_dev_vport_init() function |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Liu, Mingxia June 26, 2023, 2:06 p.m. UTC
  This patch adds 'cur_vports' and 'cur_vport_nb' updation in error path.

Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
---
 drivers/net/idpf/idpf_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Qi Zhang June 30, 2023, 8:13 a.m. UTC | #1
> -----Original Message-----
> From: Mingxia Liu <mingxia.liu@intel.com>
> Sent: Monday, June 26, 2023 10:06 PM
> To: dev@dpdk.org
> Cc: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>;
> Liu, Mingxia <mingxia.liu@intel.com>
> Subject: [PATCH] net/idpf: refine idpf_dev_vport_init() function
> 
> This patch adds 'cur_vports' and 'cur_vport_nb' updation in error path.
> 
> Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
> ---
>  drivers/net/idpf/idpf_ethdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
> index 801da57472..3e66898aaf 100644
> --- a/drivers/net/idpf/idpf_ethdev.c
> +++ b/drivers/net/idpf/idpf_ethdev.c
> @@ -1300,6 +1300,8 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void
> *init_params)
>  err_mac_addrs:
>  	adapter->vports[param->idx] = NULL;  /* reset */
>  	idpf_vport_deinit(vport);
> +	adapter->cur_vports &= ~RTE_BIT32(param->devarg_id);
> +	adapter->cur_vport_nb--;

Can we move below two lines to the last?

adapter->cur_vports |= RTE_BIT32(param->devarg_id);
adapter->cur_vport_nb++;

so we don't need to revert them in error handle

>  err:
>  	return ret;
>  }
> --
> 2.34.1
  
Qi Zhang June 30, 2023, 8:14 a.m. UTC | #2
> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Friday, June 30, 2023 4:13 PM
> To: Mingxia Liu <mingxia.liu@intel.com>; dev@dpdk.org
> Cc: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>;
> Liu, Mingxia <mingxia.liu@intel.com>
> Subject: RE: [PATCH] net/idpf: refine idpf_dev_vport_init() function
> 
> 
> 
> > -----Original Message-----
> > From: Mingxia Liu <mingxia.liu@intel.com>
> > Sent: Monday, June 26, 2023 10:06 PM
> > To: dev@dpdk.org
> > Cc: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Liu, Mingxia <mingxia.liu@intel.com>
> > Subject: [PATCH] net/idpf: refine idpf_dev_vport_init() function
> >
> > This patch adds 'cur_vports' and 'cur_vport_nb' updation in error path.
> >
> > Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
> > ---
> >  drivers/net/idpf/idpf_ethdev.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/net/idpf/idpf_ethdev.c
> > b/drivers/net/idpf/idpf_ethdev.c index 801da57472..3e66898aaf 100644
> > --- a/drivers/net/idpf/idpf_ethdev.c
> > +++ b/drivers/net/idpf/idpf_ethdev.c
> > @@ -1300,6 +1300,8 @@ idpf_dev_vport_init(struct rte_eth_dev *dev,
> > void
> > *init_params)
> >  err_mac_addrs:
> >  	adapter->vports[param->idx] = NULL;  /* reset */
> >  	idpf_vport_deinit(vport);
> > +	adapter->cur_vports &= ~RTE_BIT32(param->devarg_id);
> > +	adapter->cur_vport_nb--;
> 
> Can we move below two lines to the last?
> 
> adapter->cur_vports |= RTE_BIT32(param->devarg_id); cur_vport_nb++;
> 
> so we don't need to revert them in error handle

Btw this is a fix, please also add the fixline.
> 
> >  err:
> >  	return ret;
> >  }
> > --
> > 2.34.1
  
Liu, Mingxia June 30, 2023, 10:46 a.m. UTC | #3
> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Friday, June 30, 2023 4:14 PM
> To: Liu, Mingxia <mingxia.liu@intel.com>; dev@dpdk.org
> Cc: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>;
> Liu, Mingxia <mingxia.liu@intel.com>
> Subject: RE: [PATCH] net/idpf: refine idpf_dev_vport_init() function
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, Qi Z
> > Sent: Friday, June 30, 2023 4:13 PM
> > To: Mingxia Liu <mingxia.liu@intel.com>; dev@dpdk.org
> > Cc: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Liu, Mingxia <mingxia.liu@intel.com>
> > Subject: RE: [PATCH] net/idpf: refine idpf_dev_vport_init() function
> >
> >
> >
> > > -----Original Message-----
> > > From: Mingxia Liu <mingxia.liu@intel.com>
> > > Sent: Monday, June 26, 2023 10:06 PM
> > > To: dev@dpdk.org
> > > Cc: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > > <beilei.xing@intel.com>; Liu, Mingxia <mingxia.liu@intel.com>
> > > Subject: [PATCH] net/idpf: refine idpf_dev_vport_init() function
> > >
> > > This patch adds 'cur_vports' and 'cur_vport_nb' updation in error path.
> > >
> > > Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
> > > ---
> > >  drivers/net/idpf/idpf_ethdev.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/net/idpf/idpf_ethdev.c
> > > b/drivers/net/idpf/idpf_ethdev.c index 801da57472..3e66898aaf 100644
> > > --- a/drivers/net/idpf/idpf_ethdev.c
> > > +++ b/drivers/net/idpf/idpf_ethdev.c
> > > @@ -1300,6 +1300,8 @@ idpf_dev_vport_init(struct rte_eth_dev *dev,
> > > void
> > > *init_params)
> > >  err_mac_addrs:
> > >  	adapter->vports[param->idx] = NULL;  /* reset */
> > >  	idpf_vport_deinit(vport);
> > > +	adapter->cur_vports &= ~RTE_BIT32(param->devarg_id);
> > > +	adapter->cur_vport_nb--;
> >
> > Can we move below two lines to the last?
> >
> > adapter->cur_vports |= RTE_BIT32(param->devarg_id); cur_vport_nb++;
> >
> > so we don't need to revert them in error handle
> 
> Btw this is a fix, please also add the fixline.
> >
[Liu, Mingxia] Thanks, new patch has been sent.

> > >  err:
> > >  	return ret;
> > >  }
> > > --
> > > 2.34.1
  

Patch

diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 801da57472..3e66898aaf 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1300,6 +1300,8 @@  idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
 err_mac_addrs:
 	adapter->vports[param->idx] = NULL;  /* reset */
 	idpf_vport_deinit(vport);
+	adapter->cur_vports &= ~RTE_BIT32(param->devarg_id);
+	adapter->cur_vport_nb--;
 err:
 	return ret;
 }