common/idpf: remove unnecessary field in vport

Message ID 20230420162038.637079-1-qi.z.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series common/idpf: remove unnecessary field in vport |

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/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Qi Zhang April 20, 2023, 4:20 p.m. UTC
  Remove the pointer to rte_eth_dev instance, as
1. there is already a pointer to  rte_eth_dev_data.
2. a pointer to rte_eth_dev will break multi-process usage.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/common/idpf/idpf_common_device.h | 1 -
 drivers/net/cpfl/cpfl_ethdev.c           | 4 ++--
 drivers/net/idpf/idpf_ethdev.c           | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)
  

Comments

Xing, Beilei April 26, 2023, 6:45 a.m. UTC | #1
> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Friday, April 21, 2023 12:21 AM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [PATCH] common/idpf: remove unnecessary field in vport
> 
> Remove the pointer to rte_eth_dev instance, as 1. there is already a pointer to
> rte_eth_dev_data.
> 2. a pointer to rte_eth_dev will break multi-process usage.

Basically it's OK for me, do we need to add fix line?

> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  drivers/common/idpf/idpf_common_device.h | 1 -
>  drivers/net/cpfl/cpfl_ethdev.c           | 4 ++--
>  drivers/net/idpf/idpf_ethdev.c           | 4 ++--
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/common/idpf/idpf_common_device.h
> b/drivers/common/idpf/idpf_common_device.h
> index 7a54f7c937..d29bcc71ab 100644
> --- a/drivers/common/idpf/idpf_common_device.h
> +++ b/drivers/common/idpf/idpf_common_device.h
> @@ -117,7 +117,6 @@ struct idpf_vport {
> 
>  	struct virtchnl2_vport_stats eth_stats_offset;
> 
> -	void *dev;
>  	/* Event from ipf */
>  	bool link_up;
>  	uint32_t link_speed;
> diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
> index f1d4425ce2..680c2326ec 100644
> --- a/drivers/net/cpfl/cpfl_ethdev.c
> +++ b/drivers/net/cpfl/cpfl_ethdev.c
> @@ -1061,7 +1061,8 @@ static void
>  cpfl_handle_event_msg(struct idpf_vport *vport, uint8_t *msg, uint16_t
> msglen)  {
>  	struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
> -	struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
> +	struct rte_eth_dev_data *data = vport->dev_data;
> +	struct rte_eth_dev *dev = &rte_eth_devices[data->port_id];
> 
>  	if (msglen < sizeof(struct virtchnl2_event)) {
>  		PMD_DRV_LOG(ERR, "Error event");
> @@ -1245,7 +1246,6 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void
> *init_params)
>  	vport->adapter = &adapter->base;
>  	vport->sw_idx = param->idx;
>  	vport->devarg_id = param->devarg_id;
> -	vport->dev = dev;
> 
>  	memset(&create_vport_info, 0, sizeof(create_vport_info));
>  	ret = idpf_vport_info_init(vport, &create_vport_info); diff --git
> a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c index
> e01eb3a2ec..38ad4e7ac0 100644
> --- a/drivers/net/idpf/idpf_ethdev.c
> +++ b/drivers/net/idpf/idpf_ethdev.c
> @@ -1024,7 +1024,8 @@ static void
>  idpf_handle_event_msg(struct idpf_vport *vport, uint8_t *msg, uint16_t
> msglen)  {
>  	struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
> -	struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
> +	struct rte_eth_dev_data *data = vport->dev_data;
> +	struct rte_eth_dev *dev = &rte_eth_devices[data->port_id];
> 
>  	if (msglen < sizeof(struct virtchnl2_event)) {
>  		PMD_DRV_LOG(ERR, "Error event");
> @@ -1235,7 +1236,6 @@ idpf_dev_vport_init(struct rte_eth_dev *dev, void
> *init_params)
>  	vport->adapter = &adapter->base;
>  	vport->sw_idx = param->idx;
>  	vport->devarg_id = param->devarg_id;
> -	vport->dev = dev;
> 
>  	memset(&create_vport_info, 0, sizeof(create_vport_info));
>  	ret = idpf_vport_info_init(vport, &create_vport_info);
> --
> 2.31.1
  
Qi Zhang April 26, 2023, 6:53 a.m. UTC | #2
> -----Original Message-----
> From: Xing, Beilei <beilei.xing@intel.com>
> Sent: Wednesday, April 26, 2023 2:46 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH] common/idpf: remove unnecessary field in vport
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Sent: Friday, April 21, 2023 12:21 AM
> > To: Xing, Beilei <beilei.xing@intel.com>
> > Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> > Subject: [PATCH] common/idpf: remove unnecessary field in vport
> >
> > Remove the pointer to rte_eth_dev instance, as 1. there is already a
> > pointer to rte_eth_dev_data.
> > 2. a pointer to rte_eth_dev will break multi-process usage.
> 
> Basically it's OK for me, do we need to add fix line?

the multi-process support has not been enabled  yet, so technically this is not a fix but code refactor.

> 
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > ---
> >  drivers/common/idpf/idpf_common_device.h | 1 -
> >  drivers/net/cpfl/cpfl_ethdev.c           | 4 ++--
> >  drivers/net/idpf/idpf_ethdev.c           | 4 ++--
> >  3 files changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/common/idpf/idpf_common_device.h
> > b/drivers/common/idpf/idpf_common_device.h
> > index 7a54f7c937..d29bcc71ab 100644
> > --- a/drivers/common/idpf/idpf_common_device.h
> > +++ b/drivers/common/idpf/idpf_common_device.h
> > @@ -117,7 +117,6 @@ struct idpf_vport {
> >
> >  	struct virtchnl2_vport_stats eth_stats_offset;
> >
> > -	void *dev;
> >  	/* Event from ipf */
> >  	bool link_up;
> >  	uint32_t link_speed;
> > diff --git a/drivers/net/cpfl/cpfl_ethdev.c
> > b/drivers/net/cpfl/cpfl_ethdev.c index f1d4425ce2..680c2326ec 100644
> > --- a/drivers/net/cpfl/cpfl_ethdev.c
> > +++ b/drivers/net/cpfl/cpfl_ethdev.c
> > @@ -1061,7 +1061,8 @@ static void
> >  cpfl_handle_event_msg(struct idpf_vport *vport, uint8_t *msg,
> > uint16_t
> > msglen)  {
> >  	struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
> > -	struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
> > +	struct rte_eth_dev_data *data = vport->dev_data;
> > +	struct rte_eth_dev *dev = &rte_eth_devices[data->port_id];
> >
> >  	if (msglen < sizeof(struct virtchnl2_event)) {
> >  		PMD_DRV_LOG(ERR, "Error event");
> > @@ -1245,7 +1246,6 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev,
> > void
> > *init_params)
> >  	vport->adapter = &adapter->base;
> >  	vport->sw_idx = param->idx;
> >  	vport->devarg_id = param->devarg_id;
> > -	vport->dev = dev;
> >
> >  	memset(&create_vport_info, 0, sizeof(create_vport_info));
> >  	ret = idpf_vport_info_init(vport, &create_vport_info); diff --git
> > a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
> > index
> > e01eb3a2ec..38ad4e7ac0 100644
> > --- a/drivers/net/idpf/idpf_ethdev.c
> > +++ b/drivers/net/idpf/idpf_ethdev.c
> > @@ -1024,7 +1024,8 @@ static void
> >  idpf_handle_event_msg(struct idpf_vport *vport, uint8_t *msg,
> > uint16_t
> > msglen)  {
> >  	struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
> > -	struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
> > +	struct rte_eth_dev_data *data = vport->dev_data;
> > +	struct rte_eth_dev *dev = &rte_eth_devices[data->port_id];
> >
> >  	if (msglen < sizeof(struct virtchnl2_event)) {
> >  		PMD_DRV_LOG(ERR, "Error event");
> > @@ -1235,7 +1236,6 @@ idpf_dev_vport_init(struct rte_eth_dev *dev,
> > void
> > *init_params)
> >  	vport->adapter = &adapter->base;
> >  	vport->sw_idx = param->idx;
> >  	vport->devarg_id = param->devarg_id;
> > -	vport->dev = dev;
> >
> >  	memset(&create_vport_info, 0, sizeof(create_vport_info));
> >  	ret = idpf_vport_info_init(vport, &create_vport_info);
> > --
> > 2.31.1
  
Xing, Beilei April 26, 2023, 7:38 a.m. UTC | #3
> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Friday, April 21, 2023 12:21 AM
> To: Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [PATCH] common/idpf: remove unnecessary field in vport
> 
> Remove the pointer to rte_eth_dev instance, as 1. there is already a pointer to
> rte_eth_dev_data.
> 2. a pointer to rte_eth_dev will break multi-process usage.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
  
Qi Zhang April 26, 2023, 8:04 a.m. UTC | #4
> -----Original Message-----
> From: Xing, Beilei <beilei.xing@intel.com>
> Sent: Wednesday, April 26, 2023 3:38 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH] common/idpf: remove unnecessary field in vport
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Sent: Friday, April 21, 2023 12:21 AM
> > To: Xing, Beilei <beilei.xing@intel.com>
> > Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> > Subject: [PATCH] common/idpf: remove unnecessary field in vport
> >
> > Remove the pointer to rte_eth_dev instance, as 1. there is already a
> > pointer to rte_eth_dev_data.
> > 2. a pointer to rte_eth_dev will break multi-process usage.
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> Acked-by: Beilei Xing <beilei.xing@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
index 7a54f7c937..d29bcc71ab 100644
--- a/drivers/common/idpf/idpf_common_device.h
+++ b/drivers/common/idpf/idpf_common_device.h
@@ -117,7 +117,6 @@  struct idpf_vport {
 
 	struct virtchnl2_vport_stats eth_stats_offset;
 
-	void *dev;
 	/* Event from ipf */
 	bool link_up;
 	uint32_t link_speed;
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index f1d4425ce2..680c2326ec 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -1061,7 +1061,8 @@  static void
 cpfl_handle_event_msg(struct idpf_vport *vport, uint8_t *msg, uint16_t msglen)
 {
 	struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
-	struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
+	struct rte_eth_dev_data *data = vport->dev_data;
+	struct rte_eth_dev *dev = &rte_eth_devices[data->port_id];
 
 	if (msglen < sizeof(struct virtchnl2_event)) {
 		PMD_DRV_LOG(ERR, "Error event");
@@ -1245,7 +1246,6 @@  cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
 	vport->adapter = &adapter->base;
 	vport->sw_idx = param->idx;
 	vport->devarg_id = param->devarg_id;
-	vport->dev = dev;
 
 	memset(&create_vport_info, 0, sizeof(create_vport_info));
 	ret = idpf_vport_info_init(vport, &create_vport_info);
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index e01eb3a2ec..38ad4e7ac0 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -1024,7 +1024,8 @@  static void
 idpf_handle_event_msg(struct idpf_vport *vport, uint8_t *msg, uint16_t msglen)
 {
 	struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
-	struct rte_eth_dev *dev = (struct rte_eth_dev *)vport->dev;
+	struct rte_eth_dev_data *data = vport->dev_data;
+	struct rte_eth_dev *dev = &rte_eth_devices[data->port_id];
 
 	if (msglen < sizeof(struct virtchnl2_event)) {
 		PMD_DRV_LOG(ERR, "Error event");
@@ -1235,7 +1236,6 @@  idpf_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
 	vport->adapter = &adapter->base;
 	vport->sw_idx = param->idx;
 	vport->devarg_id = param->devarg_id;
-	vport->dev = dev;
 
 	memset(&create_vport_info, 0, sizeof(create_vport_info));
 	ret = idpf_vport_info_init(vport, &create_vport_info);