mbox series

[iproute2-next,v3,0/5] Add vdpa device management tool

Message ID 20210202103518.3858-1-parav@nvidia.com
Headers show
Series Add vdpa device management tool | expand

Message

Parav Pandit Feb. 2, 2021, 10:35 a.m. UTC
Linux vdpa interface allows vdpa device management functionality.
This includes adding, removing, querying vdpa devices.

vdpa interface also includes showing supported management devices
which support such operations.

This patchset includes kernel uapi headers and a vdpa tool.

examples:

$ vdpa mgmtdev show
vdpasim:
  supported_classes net

$ vdpa mgmtdev show -jp
{
    "show": {
        "vdpasim": {
            "supported_classes": [ "net" ]
        }
    }
}

Create a vdpa device of type networking named as "foo2" from
the management device vdpasim_net:

$ vdpa dev add mgmtdev vdpasim_net name foo2

Show the newly created vdpa device by its name:
$ vdpa dev show foo2
foo2: type network mgmtdev vdpasim_net vendor_id 0 max_vqs 2 max_vq_size 256

$ vdpa dev show foo2 -jp
{
    "dev": {
        "foo2": {
            "type": "network",
            "mgmtdev": "vdpasim_net",
            "vendor_id": 0,
            "max_vqs": 2,
            "max_vq_size": 256
        }
    }
}

Delete the vdpa device after its use:
$ vdpa dev del foo2

Patch summary:
Patch-1 adds kernel headers for vdpa subsystem
Patch-2 adds library routines for indent handling
Patch-3 adds library routines for generic socket communication
PAtch-4 adds library routine for number to string mapping
Patch-5 adds vdpa tool

Kernel headers are from the vhost kernel tree [1] from branch linux-next.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

---
changelog:
v2->v3:
 - addressed David's comment to split patch for utils and other parts
 - rebased
 - using newly added helper routine for number to string mapping
v1->v2:
 - addressed below comments from David
 - added and used library helpers for socket communication
 - added and used library functions for string processing helpers
 - added and used library functions indent processing helpers

Parav Pandit (5):
  Add kernel headers
  utils: Add helper routines for indent handling
  utils: Add generic socket helpers
  utils: Add helper to map string to unsigned int
  vdpa: Add vdpa tool

 Makefile                        |   2 +-
 include/mnl_utils.h             |  16 +
 include/uapi/linux/vdpa.h       |  40 ++
 include/uapi/linux/virtio_ids.h |  58 +++
 include/utils.h                 |  20 +-
 lib/mnl_utils.c                 | 121 ++++++
 lib/utils.c                     |  83 +++-
 man/man8/vdpa-dev.8             |  96 +++++
 man/man8/vdpa-mgmtdev.8         |  53 +++
 man/man8/vdpa.8                 |  76 ++++
 vdpa/Makefile                   |  24 ++
 vdpa/vdpa.c                     | 675 ++++++++++++++++++++++++++++++++
 12 files changed, 1260 insertions(+), 4 deletions(-)
 create mode 100644 include/uapi/linux/vdpa.h
 create mode 100644 include/uapi/linux/virtio_ids.h
 create mode 100644 man/man8/vdpa-dev.8
 create mode 100644 man/man8/vdpa-mgmtdev.8
 create mode 100644 man/man8/vdpa.8
 create mode 100644 vdpa/Makefile
 create mode 100644 vdpa/vdpa.c

Comments

Jason Wang Feb. 4, 2021, 3:16 a.m. UTC | #1
On 2021/2/2 下午6:35, Parav Pandit wrote:
> Linux vdpa interface allows vdpa device management functionality.

> This includes adding, removing, querying vdpa devices.

>

> vdpa interface also includes showing supported management devices

> which support such operations.

>

> This patchset includes kernel uapi headers and a vdpa tool.

>

> examples:

>

> $ vdpa mgmtdev show

> vdpasim:

>    supported_classes net

>

> $ vdpa mgmtdev show -jp

> {

>      "show": {

>          "vdpasim": {

>              "supported_classes": [ "net" ]

>          }

>      }

> }

>

> Create a vdpa device of type networking named as "foo2" from

> the management device vdpasim_net:

>

> $ vdpa dev add mgmtdev vdpasim_net name foo2

>

> Show the newly created vdpa device by its name:

> $ vdpa dev show foo2

> foo2: type network mgmtdev vdpasim_net vendor_id 0 max_vqs 2 max_vq_size 256

>

> $ vdpa dev show foo2 -jp

> {

>      "dev": {

>          "foo2": {

>              "type": "network",

>              "mgmtdev": "vdpasim_net",

>              "vendor_id": 0,

>              "max_vqs": 2,

>              "max_vq_size": 256

>          }

>      }

> }

>

> Delete the vdpa device after its use:

> $ vdpa dev del foo2

>

> Patch summary:

> Patch-1 adds kernel headers for vdpa subsystem

> Patch-2 adds library routines for indent handling

> Patch-3 adds library routines for generic socket communication

> PAtch-4 adds library routine for number to string mapping

> Patch-5 adds vdpa tool

>

> Kernel headers are from the vhost kernel tree [1] from branch linux-next.

>

> [1] https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

>

> ---



Adding Adrian to see if this looks good for k8s integration.

Thanks
Adrian Moreno Feb. 4, 2021, 11:15 a.m. UTC | #2
Sorry I have not followed this work as close as I would have wanted.
Some questions below.

On 2/4/21 4:16 AM, Jason Wang wrote:
> 

> On 2021/2/2 下午6:35, Parav Pandit wrote:

>> Linux vdpa interface allows vdpa device management functionality.

>> This includes adding, removing, querying vdpa devices.

>>

>> vdpa interface also includes showing supported management devices

>> which support such operations.

>>

>> This patchset includes kernel uapi headers and a vdpa tool.

>>

>> examples:

>>

>> $ vdpa mgmtdev show

>> vdpasim:

>>    supported_classes net

>>

>> $ vdpa mgmtdev show -jp

>> {

>>      "show": {

>>          "vdpasim": {

>>              "supported_classes": [ "net" ]

>>          }

>>      }

>> }

>>


How can a user establish the relationship between a mgmtdev and it's parent
device (pci vf, sf, etc)?

>> Create a vdpa device of type networking named as "foo2" from

>> the management device vdpasim_net:

>>

>> $ vdpa dev add mgmtdev vdpasim_net name foo2

>>


I guess this command will accept a 'type' parameter once more supported_classes
are added?

Also, will this tool also handle the vdpa driver binding or will the user handle
that through the vdpa bus' sysfs interface?

>> Show the newly created vdpa device by its name:

>> $ vdpa dev show foo2

>> foo2: type network mgmtdev vdpasim_net vendor_id 0 max_vqs 2 max_vq_size 256

>>

>> $ vdpa dev show foo2 -jp

>> {

>>      "dev": {

>>          "foo2": {

>>              "type": "network",

>>              "mgmtdev": "vdpasim_net",

>>              "vendor_id": 0,

>>              "max_vqs": 2,

>>              "max_vq_size": 256

>>          }

>>      }

>> }

>>

>> Delete the vdpa device after its use:

>> $ vdpa dev del foo2

>>

>> Patch summary:

>> Patch-1 adds kernel headers for vdpa subsystem

>> Patch-2 adds library routines for indent handling

>> Patch-3 adds library routines for generic socket communication

>> PAtch-4 adds library routine for number to string mapping

>> Patch-5 adds vdpa tool

>>

>> Kernel headers are from the vhost kernel tree [1] from branch linux-next.

>>

>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

>>

>> ---

> 

> 

> Adding Adrian to see if this looks good for k8s integration.

> 

> Thanks

> 


Thanks
-- 
Adrián Moreno
Jason Wang Feb. 5, 2021, 3:40 a.m. UTC | #3
On 2021/2/4 下午7:15, Adrian Moreno wrote:
> Sorry I have not followed this work as close as I would have wanted.

> Some questions below.

>

> On 2/4/21 4:16 AM, Jason Wang wrote:

>> On 2021/2/2 下午6:35, Parav Pandit wrote:

>>> Linux vdpa interface allows vdpa device management functionality.

>>> This includes adding, removing, querying vdpa devices.

>>>

>>> vdpa interface also includes showing supported management devices

>>> which support such operations.

>>>

>>> This patchset includes kernel uapi headers and a vdpa tool.

>>>

>>> examples:

>>>

>>> $ vdpa mgmtdev show

>>> vdpasim:

>>>     supported_classes net

>>>

>>> $ vdpa mgmtdev show -jp

>>> {

>>>       "show": {

>>>           "vdpasim": {

>>>               "supported_classes": [ "net" ]

>>>           }

>>>       }

>>> }

>>>

> How can a user establish the relationship between a mgmtdev and it's parent

> device (pci vf, sf, etc)?



Parav should know more but I try to answer.

I think there should be BDF information in the mgmtdev show command if 
the parent is a PCI device, or we can simply show the parent here?


>

>>> Create a vdpa device of type networking named as "foo2" from

>>> the management device vdpasim_net:

>>>

>>> $ vdpa dev add mgmtdev vdpasim_net name foo2

>>>

> I guess this command will accept a 'type' parameter once more supported_classes

> are added?



This could be extended in the future.


>

> Also, will this tool also handle the vdpa driver binding or will the user handle

> that through the vdpa bus' sysfs interface?



I think not, it's the configuration below the vdpa bus. The sysfs should 
be the only interface for managing driver binding.

Thanks


>

>>> Show the newly created vdpa device by its name:

>>> $ vdpa dev show foo2

>>> foo2: type network mgmtdev vdpasim_net vendor_id 0 max_vqs 2 max_vq_size 256

>>>

>>> $ vdpa dev show foo2 -jp

>>> {

>>>       "dev": {

>>>           "foo2": {

>>>               "type": "network",

>>>               "mgmtdev": "vdpasim_net",

>>>               "vendor_id": 0,

>>>               "max_vqs": 2,

>>>               "max_vq_size": 256

>>>           }

>>>       }

>>> }

>>>

>>> Delete the vdpa device after its use:

>>> $ vdpa dev del foo2

>>>

>>> Patch summary:

>>> Patch-1 adds kernel headers for vdpa subsystem

>>> Patch-2 adds library routines for indent handling

>>> Patch-3 adds library routines for generic socket communication

>>> PAtch-4 adds library routine for number to string mapping

>>> Patch-5 adds vdpa tool

>>>

>>> Kernel headers are from the vhost kernel tree [1] from branch linux-next.

>>>

>>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

>>>

>>> ---

>>

>> Adding Adrian to see if this looks good for k8s integration.

>>

>> Thanks

>>

> Thanks
Parav Pandit Feb. 5, 2021, 5:53 p.m. UTC | #4
> From: Jason Wang <jasowang@redhat.com>

> Sent: Friday, February 5, 2021 9:11 AM

> 

> 

> On 2021/2/4 下午7:15, Adrian Moreno wrote:

> > Sorry I have not followed this work as close as I would have wanted.

> > Some questions below.

> >

> > On 2/4/21 4:16 AM, Jason Wang wrote:

> >> On 2021/2/2 下午6:35, Parav Pandit wrote:

> >>> Linux vdpa interface allows vdpa device management functionality.

> >>> This includes adding, removing, querying vdpa devices.

> >>>

> >>> vdpa interface also includes showing supported management devices

> >>> which support such operations.

> >>>

> >>> This patchset includes kernel uapi headers and a vdpa tool.

> >>>

> >>> examples:

> >>>

> >>> $ vdpa mgmtdev show

> >>> vdpasim:

> >>>     supported_classes net

> >>>

> >>> $ vdpa mgmtdev show -jp

> >>> {

> >>>       "show": {

> >>>           "vdpasim": {

> >>>               "supported_classes": [ "net" ]

> >>>           }

> >>>       }

> >>> }

> >>>

> > How can a user establish the relationship between a mgmtdev and it's

> > parent device (pci vf, sf, etc)?

> 

> 

> Parav should know more but I try to answer.

> 

> I think there should be BDF information in the mgmtdev show command if

> the parent is a PCI device, or we can simply show the parent here?

>

Yes, it is present in the mgmtdev show command.
I should have added the example from the kernel cover letter here.
Link to the kernel cover letter is at 

An example for real PCI PF,VF,SF device looks like below.
I will cover below example to the v4 cover letter while addressing David's comment for header file relocation.

$ vdpa mgmtdev list
pci/0000:03.00:0
  supported_classes
    net
pci/0000:03.00:4
  supported_classes
    net
auxiliary/mlx5_core.sf.8
  supported_classes
    net

[1] https://lore.kernel.org/netdev/20210105103203.82508-1-parav@nvidia.com/
Adrian Moreno Feb. 5, 2021, 6:06 p.m. UTC | #5
On 2/5/21 6:53 PM, Parav Pandit wrote:
> 

> 

>> From: Jason Wang <jasowang@redhat.com>

>> Sent: Friday, February 5, 2021 9:11 AM

>>

>>

>> On 2021/2/4 下午7:15, Adrian Moreno wrote:

>>> Sorry I have not followed this work as close as I would have wanted.

>>> Some questions below.

>>>

>>> On 2/4/21 4:16 AM, Jason Wang wrote:

>>>> On 2021/2/2 下午6:35, Parav Pandit wrote:

>>>>> Linux vdpa interface allows vdpa device management functionality.

>>>>> This includes adding, removing, querying vdpa devices.

>>>>>

>>>>> vdpa interface also includes showing supported management devices

>>>>> which support such operations.

>>>>>

>>>>> This patchset includes kernel uapi headers and a vdpa tool.

>>>>>

>>>>> examples:

>>>>>

>>>>> $ vdpa mgmtdev show

>>>>> vdpasim:

>>>>>     supported_classes net

>>>>>

>>>>> $ vdpa mgmtdev show -jp

>>>>> {

>>>>>       "show": {

>>>>>           "vdpasim": {

>>>>>               "supported_classes": [ "net" ]

>>>>>           }

>>>>>       }

>>>>> }

>>>>>

>>> How can a user establish the relationship between a mgmtdev and it's

>>> parent device (pci vf, sf, etc)?

>>

>>

>> Parav should know more but I try to answer.

>>

>> I think there should be BDF information in the mgmtdev show command if

>> the parent is a PCI device, or we can simply show the parent here?

>>

> Yes, it is present in the mgmtdev show command.

> I should have added the example from the kernel cover letter here.

> Link to the kernel cover letter is at 

> 

> An example for real PCI PF,VF,SF device looks like below.

> I will cover below example to the v4 cover letter while addressing David's comment for header file relocation.

> 

> $ vdpa mgmtdev list

> pci/0000:03.00:0

>   supported_classes

>     net

> pci/0000:03.00:4

>   supported_classes

>     net

> auxiliary/mlx5_core.sf.8

>   supported_classes

>     net

> 

> [1] https://lore.kernel.org/netdev/20210105103203.82508-1-parav@nvidia.com/

> 


Thanks Parav

-- 
Adrián Moreno
Adrian Moreno Feb. 5, 2021, 6:07 p.m. UTC | #6
On 2/5/21 4:40 AM, Jason Wang wrote:
> 

> On 2021/2/4 下午7:15, Adrian Moreno wrote:

>> Sorry I have not followed this work as close as I would have wanted.

>> Some questions below.

>>

>> On 2/4/21 4:16 AM, Jason Wang wrote:

>>> On 2021/2/2 下午6:35, Parav Pandit wrote:

>>>> Linux vdpa interface allows vdpa device management functionality.

>>>> This includes adding, removing, querying vdpa devices.

>>>>

>>>> vdpa interface also includes showing supported management devices

>>>> which support such operations.

>>>>

>>>> This patchset includes kernel uapi headers and a vdpa tool.

>>>>

>>>> examples:

>>>>

>>>> $ vdpa mgmtdev show

>>>> vdpasim:

>>>>     supported_classes net

>>>>

>>>> $ vdpa mgmtdev show -jp

>>>> {

>>>>       "show": {

>>>>           "vdpasim": {

>>>>               "supported_classes": [ "net" ]

>>>>           }

>>>>       }

>>>> }

>>>>

>> How can a user establish the relationship between a mgmtdev and it's parent

>> device (pci vf, sf, etc)?

> 

> 

> Parav should know more but I try to answer.

> 

> I think there should be BDF information in the mgmtdev show command if the

> parent is a PCI device, or we can simply show the parent here?

> 

> 

>>

>>>> Create a vdpa device of type networking named as "foo2" from

>>>> the management device vdpasim_net:

>>>>

>>>> $ vdpa dev add mgmtdev vdpasim_net name foo2

>>>>

>> I guess this command will accept a 'type' parameter once more supported_classes

>> are added?

> 

> 

> This could be extended in the future.

> 

> 

>>

>> Also, will this tool also handle the vdpa driver binding or will the user handle

>> that through the vdpa bus' sysfs interface?

> 

> 

> I think not, it's the configuration below the vdpa bus. The sysfs should be the

> only interface for managing driver binding.

> 

Understood, thanks.

-- 
Adrián Moreno