diff mbox series

[v2,01/44] bus/vdev: add helper to get vdev from eth dev

Message ID 20210119212507.1043636-2-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series net/virtio: Virtio PMD rework | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Maxime Coquelin Jan. 19, 2021, 9:24 p.m. UTC
This patch adds an helper macro to get the rte_vdev_device
pointer from a rte_eth_dev pointer.

This is similar to RTE_ETH_DEV_TO_PCI().

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/vdev/rte_bus_vdev.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Thomas Monjalon Jan. 20, 2021, 12:56 a.m. UTC | #1
19/01/2021 22:24, Maxime Coquelin:
> This patch adds an helper macro to get the rte_vdev_device
> pointer from a rte_eth_dev pointer.
> 
> This is similar to RTE_ETH_DEV_TO_PCI().
[...]
> --- a/drivers/bus/vdev/rte_bus_vdev.h
> +++ b/drivers/bus/vdev/rte_bus_vdev.h
> @@ -34,6 +34,8 @@ struct rte_vdev_device {
> +#define RTE_ETH_DEV_TO_VDEV(eth_dev)	RTE_DEV_TO_VDEV((eth_dev)->device)

Why these macros (vdev and PCI) are not in ethdev?
Chenbo Xia Jan. 21, 2021, 8:58 a.m. UTC | #2
Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, January 20, 2021 5:24 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; olivier.matz@6wind.com;
> amorenoz@redhat.com; david.marchand@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v2 01/44] bus/vdev: add helper to get vdev from eth dev

Sorry that I missed the title in v1..

Better use 'ethdev' or 'eth device'here?

Thanks,
Chenbo

> 
> This patch adds an helper macro to get the rte_vdev_device
> pointer from a rte_eth_dev pointer.
> 
> This is similar to RTE_ETH_DEV_TO_PCI().
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/bus/vdev/rte_bus_vdev.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h
> index d14eeb41b0..f99a41f825 100644
> --- a/drivers/bus/vdev/rte_bus_vdev.h
> +++ b/drivers/bus/vdev/rte_bus_vdev.h
> @@ -34,6 +34,8 @@ struct rte_vdev_device {
>  #define RTE_DEV_TO_VDEV_CONST(ptr) \
>  	container_of(ptr, const struct rte_vdev_device, device)
> 
> +#define RTE_ETH_DEV_TO_VDEV(eth_dev)	RTE_DEV_TO_VDEV((eth_dev)->device)
> +
>  static inline const char *
>  rte_vdev_device_name(const struct rte_vdev_device *dev)
>  {
> --
> 2.29.2
Maxime Coquelin Jan. 25, 2021, 10:53 a.m. UTC | #3
On 1/20/21 1:56 AM, Thomas Monjalon wrote:
> 19/01/2021 22:24, Maxime Coquelin:
>> This patch adds an helper macro to get the rte_vdev_device
>> pointer from a rte_eth_dev pointer.
>>
>> This is similar to RTE_ETH_DEV_TO_PCI().
> [...]
>> --- a/drivers/bus/vdev/rte_bus_vdev.h
>> +++ b/drivers/bus/vdev/rte_bus_vdev.h
>> @@ -34,6 +34,8 @@ struct rte_vdev_device {
>> +#define RTE_ETH_DEV_TO_VDEV(eth_dev)	RTE_DEV_TO_VDEV((eth_dev)->device)
> 
> Why these macros (vdev and PCI) are not in ethdev?
> 
> 

I think because that would put a dependency on vdev & pci bus drivers in
ethdev library.

Indeed, RTE_DEV_TO_VDEV needs to know about rte_vdev_device layout:

#define RTE_DEV_TO_VDEV(ptr) \
	container_of(ptr, struct rte_vdev_device, device)

Regards,
Maxime
Thomas Monjalon Jan. 25, 2021, 11:04 a.m. UTC | #4
25/01/2021 11:53, Maxime Coquelin:
> 
> On 1/20/21 1:56 AM, Thomas Monjalon wrote:
> > 19/01/2021 22:24, Maxime Coquelin:
> >> This patch adds an helper macro to get the rte_vdev_device
> >> pointer from a rte_eth_dev pointer.
> >>
> >> This is similar to RTE_ETH_DEV_TO_PCI().
> > [...]
> >> --- a/drivers/bus/vdev/rte_bus_vdev.h
> >> +++ b/drivers/bus/vdev/rte_bus_vdev.h
> >> @@ -34,6 +34,8 @@ struct rte_vdev_device {
> >> +#define RTE_ETH_DEV_TO_VDEV(eth_dev)	RTE_DEV_TO_VDEV((eth_dev)->device)
> > 
> > Why these macros (vdev and PCI) are not in ethdev?
> > 
> > 
> 
> I think because that would put a dependency on vdev & pci bus drivers in
> ethdev library.
> 
> Indeed, RTE_DEV_TO_VDEV needs to know about rte_vdev_device layout:
> 
> #define RTE_DEV_TO_VDEV(ptr) \
> 	container_of(ptr, struct rte_vdev_device, device)

OK
Maxime Coquelin Jan. 25, 2021, 2:51 p.m. UTC | #5
On 1/21/21 9:58 AM, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Wednesday, January 20, 2021 5:24 AM
>> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; olivier.matz@6wind.com;
>> amorenoz@redhat.com; david.marchand@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [PATCH v2 01/44] bus/vdev: add helper to get vdev from eth dev
> 
> Sorry that I missed the title in v1..
> 
> Better use 'ethdev' or 'eth device'here?

Changed to ethedv.

Thanks,
Maxime

> Thanks,
> Chenbo
> 
>>
>> This patch adds an helper macro to get the rte_vdev_device
>> pointer from a rte_eth_dev pointer.
>>
>> This is similar to RTE_ETH_DEV_TO_PCI().
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
>> Reviewed-by: David Marchand <david.marchand@redhat.com>
>> ---
>>  drivers/bus/vdev/rte_bus_vdev.h | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h
>> index d14eeb41b0..f99a41f825 100644
>> --- a/drivers/bus/vdev/rte_bus_vdev.h
>> +++ b/drivers/bus/vdev/rte_bus_vdev.h
>> @@ -34,6 +34,8 @@ struct rte_vdev_device {
>>  #define RTE_DEV_TO_VDEV_CONST(ptr) \
>>  	container_of(ptr, const struct rte_vdev_device, device)
>>
>> +#define RTE_ETH_DEV_TO_VDEV(eth_dev)	RTE_DEV_TO_VDEV((eth_dev)->device)
>> +
>>  static inline const char *
>>  rte_vdev_device_name(const struct rte_vdev_device *dev)
>>  {
>> --
>> 2.29.2
>
diff mbox series

Patch

diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h
index d14eeb41b0..f99a41f825 100644
--- a/drivers/bus/vdev/rte_bus_vdev.h
+++ b/drivers/bus/vdev/rte_bus_vdev.h
@@ -34,6 +34,8 @@  struct rte_vdev_device {
 #define RTE_DEV_TO_VDEV_CONST(ptr) \
 	container_of(ptr, const struct rte_vdev_device, device)
 
+#define RTE_ETH_DEV_TO_VDEV(eth_dev)	RTE_DEV_TO_VDEV((eth_dev)->device)
+
 static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {