Skip to content

Commit

Permalink
Integrating govdpa changes from release v0.1.7
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Milleri <[email protected]>
  • Loading branch information
lmilleri committed Aug 22, 2022
1 parent fc8984c commit a1703ca
Show file tree
Hide file tree
Showing 11 changed files with 778 additions and 247 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ replace (
github.com/containernetworking/cni => github.com/containernetworking/cni v0.8.1
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
)

replace github.com/k8snetworkplumbingwg/govdpa v0.1.3 => github.com/lmilleri/govdpa v0.1.7
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/k8snetworkplumbingwg/govdpa v0.1.3 h1:FZRhTMB1e3yWwSEy+l4eS73WioyMaL+vmFZ8JNwn+Uk=
github.com/k8snetworkplumbingwg/govdpa v0.1.3/go.mod h1:Jx2rlMquENdCd8M5Oc51xHCt10bQIXTloDU8F4nS4T4=
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.1-0.20201119153432-9d213757d22d h1:9QbZltQGRFe7temwcTDjj8rIbow48Gv6mIKOxuks+OI=
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.1-0.20201119153432-9d213757d22d/go.mod h1:+1DpV8uIwteAhxNO0lgRox8gHkTG6w3OeDfAlg+qqjA=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand All @@ -292,6 +290,8 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lmilleri/govdpa v0.1.7 h1:O2+6PwdfgIZBqRAS+IDoYIKwZyjU1FTOBM9EQQ1NbZY=
github.com/lmilleri/govdpa v0.1.7/go.mod h1:zC+FdDzIqMN38LAuA8L2oADVZjVX5lnHGHpHMNeQuI4=
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
Expand Down
15 changes: 14 additions & 1 deletion pkg/netdevice/vdpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type vdpaDevice struct {

// GetType returns the VdpaType associated with the VdpaDevice
func (v *vdpaDevice) GetType() types.VdpaType {
currentDriver := v.GetDriver()
currentDriver := v.VdpaDevice.Driver()
for vtype, driver := range supportedVdpaTypes {
if driver == currentDriver {
return vtype
Expand All @@ -49,6 +49,19 @@ func (v *vdpaDevice) GetType() types.VdpaType {
return types.VdpaInvalidType
}

func (v *vdpaDevice) GetParent() string {
return v.VdpaDevice.Name()
}

func (v *vdpaDevice) GetPath() string {
path, err := v.ParentDevicePath()
if err != nil {
glog.Infof("%s - No path for vDPA device found: %s", v.Name(), err)
return ""
}
return path
}

// GetVdpaDevice returns a VdpaDevice from a given VF PCI address
func GetVdpaDevice(pciAddr string) types.VdpaDevice {
detailVdpaDev, err := utils.GetVdpaProvider().GetVdpaDeviceByPci(pciAddr)
Expand Down
11 changes: 10 additions & 1 deletion pkg/utils/vdpa_provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package utils

import (
"fmt"

vdpa "github.com/k8snetworkplumbingwg/govdpa/pkg/kvdpa"
)

Expand All @@ -25,5 +27,12 @@ func GetVdpaProvider() VdpaProvider {
}

func (defaultVdpaProvider) GetVdpaDeviceByPci(pciAddr string) (vdpa.VdpaDevice, error) {
return vdpa.GetVdpaDeviceByPci(pciAddr)
vdpaDevices, err := vdpa.GetVdpaDevicesByPciAddress(pciAddr)
if err != nil {
return nil, err
}
if len(vdpaDevices) == 0 {
return nil, fmt.Errorf("no vdpa device associated to pciAddress %v", pciAddr)
}
return vdpaDevices[0], nil
}
322 changes: 322 additions & 0 deletions vendor/github.com/k8snetworkplumbingwg/govdpa/pkg/kvdpa/device.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a1703ca

Please sign in to comment.