[dpdk-dev,v3,09/12] virtio: vfio: Enable RTE_PCI_DRV_NEED_MAPPING flag in driver

Message ID 1452184390-5994-10-git-send-email-sshukla@mvista.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Santosh Shukla Jan. 7, 2016, 4:33 p.m. UTC
  Flag required for vfio case, It helps to update vfio_dev_fd for each
virtio net interface.

Signed-off-by: Santosh Shukla <sshukla@mvista.com>
---
 drivers/net/virtio/virtio_ethdev.c |    4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Stephen Hemminger Jan. 7, 2016, 6:20 p.m. UTC | #1
On Thu,  7 Jan 2016 22:03:06 +0530
Santosh Shukla <sshukla@mvista.com> wrote:

> +#ifdef RTE_EAL_VFIO
> +		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
> +#else
>  		.drv_flags = RTE_PCI_DRV_DETACHABLE,
> +#endif

Since VFIO is determined at runtime not compile time, the flags should
be updated at runtime not compile time.
  
Santosh Shukla Jan. 9, 2016, 12:38 p.m. UTC | #2
On Thu, Jan 7, 2016 at 11:50 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Thu,  7 Jan 2016 22:03:06 +0530
> Santosh Shukla <sshukla@mvista.com> wrote:
>
>> +#ifdef RTE_EAL_VFIO
>> +             .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
>> +#else
>>               .drv_flags = RTE_PCI_DRV_DETACHABLE,
>> +#endif
>
> Since VFIO is determined at runtime not compile time, the flags should
> be updated at runtime not compile time.
>
>
In general, Yes, Its a wrong approach i..e. Wrapping __need_mapping
flag only for vfio case. I am thinking to add vfio parser routine
something similar to virtio_xxx_xx_uio_xx() / virtio_xx_xx_ioport()
currently exist. This will remove RTE_EAL_VFIO ifdef clutter for this
patch and [08/12] patch and also virtio pmd driver can then initialize
device for vfio mode..

_but_ I still need _MAPPING flag enabled for in virtio driver as
because for vfio case - I want vfio_xx_mmap() routine to create vfio
container/group_id and then create vfio_dev_fd for each virtio-net-pci
interface. Let me know my approach aligned to your suggestion.
  
Yuanhan Liu Jan. 12, 2016, 7:14 a.m. UTC | #3
On Sat, Jan 09, 2016 at 06:08:46PM +0530, Santosh Shukla wrote:
> On Thu, Jan 7, 2016 at 11:50 PM, Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> > On Thu,  7 Jan 2016 22:03:06 +0530
> > Santosh Shukla <sshukla@mvista.com> wrote:
> >
> >> +#ifdef RTE_EAL_VFIO
> >> +             .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
> >> +#else
> >>               .drv_flags = RTE_PCI_DRV_DETACHABLE,
> >> +#endif
> >
> > Since VFIO is determined at runtime not compile time, the flags should
> > be updated at runtime not compile time.
> >
> >
> In general, Yes, Its a wrong approach i..e. Wrapping __need_mapping
> flag only for vfio case. I am thinking to add vfio parser routine
> something similar to virtio_xxx_xx_uio_xx() / virtio_xx_xx_ioport()
> currently exist. This will remove RTE_EAL_VFIO ifdef clutter for this
> patch and [08/12] patch and also virtio pmd driver can then initialize
> device for vfio mode..
> 
> _but_ I still need _MAPPING flag enabled for in virtio driver as
> because for vfio case - I want vfio_xx_mmap() routine to create vfio
> container/group_id and then create vfio_dev_fd for each virtio-net-pci
> interface.

I'm thinking my following patch will help:

    http://dpdk.org/dev/patchwork/patch/9814/

	--yliu

> Let me know my approach aligned to your suggestion.
  
Santosh Shukla Jan. 13, 2016, 12:18 p.m. UTC | #4
On Tue, Jan 12, 2016 at 12:44 PM, Yuanhan Liu
<yuanhan.liu@linux.intel.com> wrote:
> On Sat, Jan 09, 2016 at 06:08:46PM +0530, Santosh Shukla wrote:
>> On Thu, Jan 7, 2016 at 11:50 PM, Stephen Hemminger
>> <stephen@networkplumber.org> wrote:
>> > On Thu,  7 Jan 2016 22:03:06 +0530
>> > Santosh Shukla <sshukla@mvista.com> wrote:
>> >
>> >> +#ifdef RTE_EAL_VFIO
>> >> +             .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
>> >> +#else
>> >>               .drv_flags = RTE_PCI_DRV_DETACHABLE,
>> >> +#endif
>> >
>> > Since VFIO is determined at runtime not compile time, the flags should
>> > be updated at runtime not compile time.
>> >
>> >
>> In general, Yes, Its a wrong approach i..e. Wrapping __need_mapping
>> flag only for vfio case. I am thinking to add vfio parser routine
>> something similar to virtio_xxx_xx_uio_xx() / virtio_xx_xx_ioport()
>> currently exist. This will remove RTE_EAL_VFIO ifdef clutter for this
>> patch and [08/12] patch and also virtio pmd driver can then initialize
>> device for vfio mode..
>>
>> _but_ I still need _MAPPING flag enabled for in virtio driver as
>> because for vfio case - I want vfio_xx_mmap() routine to create vfio
>> container/group_id and then create vfio_dev_fd for each virtio-net-pci
>> interface.
>
> I'm thinking my following patch will help:
>
>     http://dpdk.org/dev/patchwork/patch/9814/
>

Yes, It works, so wont need NEED_MAPPING flag, Sending v4 patch series
rebased on this patch..

>         --yliu
>
>> Let me know my approach aligned to your suggestion.
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 9ca99d5..8d55049 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1447,7 +1447,11 @@  static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
+#ifdef RTE_EAL_VFIO
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+#else
 		.drv_flags = RTE_PCI_DRV_DETACHABLE,
+#endif
 	},
 	.eth_dev_init = eth_virtio_dev_init,
 	.eth_dev_uninit = eth_virtio_dev_uninit,