Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a MgmtDev interface to VdpaDevice #13

Merged
merged 17 commits into from
Sep 19, 2022

Conversation

amorenoz
Copy link
Collaborator

@amorenoz amorenoz commented Dec 30, 2021

The netlink interface sends mgmtdev information on each device. So we can use it to create a MgmtDev on each VdpaDevice.

Also, the pGetVdpaDeviceByPci can now be generalized to use MgmtDev information (busName / devName). pci addresses can still be used but also SF, stand-alone devices (such as vdpasim_net), etc.

Based on #12


func TestVdpaDevGetByMgmt(t *testing.T) {

list_result := []VdpaDevice{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change variable name in "listResult"

This layer uses an interface and an empty struct that implements it to
be able to mock it for unit tests in the future

Uses github.com/vishvananda/netlink for low level netlink handling.

For now, it just exposes two operations:
- RunVdpaNetlinkCmd: executes a netlink command against the vdpa
  subsystem
- NewAttribute: Creates a new vdpa attribute

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Based on netlink, add support for reading operations (list and get)

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
They are skipped if the right version of the kernel is not found.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Some helper functions can be used by unit tests to mock a response from
the netlink layer

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Also, move supported golang version to 1.17 as it's netlink's requirement.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Move the information about vhost and virtio devices out of the vdpa
device definition to enable extension and clean the API

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Prepare the vdpaDevice for expansion by moving some external functions
to vdpaDevice methods.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
The vdpa API sends the vdpa busName and devName alogside the vdpa
device's attributes. Use it to create a MgmtDev and expose it in the
API.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Right now we can only get a VdpaDevice by PCI address and we do it by
inspecting the pci address hierarchy. This is limitted and error prone.

Use the management device information to get all the devices whose
mgmtDev match.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Copy link

@lmilleri lmilleri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@amorenoz amorenoz merged commit 7027487 into k8snetworkplumbingwg:master Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants