Skip to content

Commit

Permalink
Add support for VDPA devices management
Browse files Browse the repository at this point in the history
Current implementation support
following functions:
- VDPANewDev
- VDPADelDev
- VDPAGetDevList
- VDPAGetDevByName
- VDPAGetDevConfigList
- VDPAGetDevConfigByName
- VDPAGetDevVStats
- VDPAGetMGMTDevList
- VDPAGetMGMTDevByBusAndName

Signed-off-by: Yury Kulazhenkov <ykulazhenkov@nvidia.com>
  • Loading branch information
ykulazhenkov authored and aboch committed Jan 29, 2024
1 parent 06219cd commit 857968a
Show file tree
Hide file tree
Showing 5 changed files with 929 additions and 16 deletions.
39 changes: 23 additions & 16 deletions netlink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ func skipUnlessRoot(t *testing.T) {
}
}

func skipUnlessKModuleLoaded(t *testing.T, module ...string) {
t.Helper()
file, err := ioutil.ReadFile("/proc/modules")
if err != nil {
t.Fatal("Failed to open /proc/modules", err)
}
for _, mod := range module {
found := false
for _, line := range strings.Split(string(file), "\n") {
n := strings.Split(line, " ")[0]
if n == mod {
found = true
break
}

}
if !found {
t.Skipf("Test requires kmodule %q.", mod)
}
}
}

func setUpNetlinkTest(t *testing.T) tearDownNetlinkTest {
skipUnlessRoot(t)

Expand Down Expand Up @@ -159,22 +181,7 @@ func setUpSEG6NetlinkTest(t *testing.T) tearDownNetlinkTest {
}

func setUpNetlinkTestWithKModule(t *testing.T, name string) tearDownNetlinkTest {
file, err := ioutil.ReadFile("/proc/modules")
if err != nil {
t.Fatal("Failed to open /proc/modules", err)
}
found := false
for _, line := range strings.Split(string(file), "\n") {
n := strings.Split(line, " ")[0]
if n == name {
found = true
break
}

}
if !found {
t.Skipf("Test requires kmodule %q.", name)
}
skipUnlessKModuleLoaded(t, name)
return setUpNetlinkTest(t)
}

Expand Down
41 changes: 41 additions & 0 deletions nl/vdpa_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package nl

const (
VDPA_GENL_NAME = "vdpa"
VDPA_GENL_VERSION = 0x1
)

const (
VDPA_CMD_UNSPEC = iota
VDPA_CMD_MGMTDEV_NEW
VDPA_CMD_MGMTDEV_GET /* can dump */
VDPA_CMD_DEV_NEW
VDPA_CMD_DEV_DEL
VDPA_CMD_DEV_GET /* can dump */
VDPA_CMD_DEV_CONFIG_GET /* can dump */
VDPA_CMD_DEV_VSTATS_GET
)

const (
VDPA_ATTR_UNSPEC = iota
VDPA_ATTR_MGMTDEV_BUS_NAME
VDPA_ATTR_MGMTDEV_DEV_NAME
VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES
VDPA_ATTR_DEV_NAME
VDPA_ATTR_DEV_ID
VDPA_ATTR_DEV_VENDOR_ID
VDPA_ATTR_DEV_MAX_VQS
VDPA_ATTR_DEV_MAX_VQ_SIZE
VDPA_ATTR_DEV_MIN_VQ_SIZE
VDPA_ATTR_DEV_NET_CFG_MACADDR
VDPA_ATTR_DEV_NET_STATUS
VDPA_ATTR_DEV_NET_CFG_MAX_VQP
VDPA_ATTR_DEV_NET_CFG_MTU
VDPA_ATTR_DEV_NEGOTIATED_FEATURES
VDPA_ATTR_DEV_MGMTDEV_MAX_VQS
VDPA_ATTR_DEV_SUPPORTED_FEATURES
VDPA_ATTR_DEV_QUEUE_INDEX
VDPA_ATTR_DEV_VENDOR_ATTR_NAME
VDPA_ATTR_DEV_VENDOR_ATTR_VALUE
VDPA_ATTR_DEV_FEATURES
)
Loading

0 comments on commit 857968a

Please sign in to comment.