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

Support for acquiring DDP profile using devlink #387

Merged
merged 21 commits into from
Jun 2, 2024
Merged
17 changes: 14 additions & 3 deletions pkg/cdi/mocks/CDI.go

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

3 changes: 3 additions & 0 deletions pkg/devices/devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ var _ = Describe("Devices", func() {
testMockProvider.
On("GetIPv4RouteList", mock.AnythingOfType("string")).
Return([]nl.Route{{Dst: nil}}, nil)
testMockProvider.
On("DevlinkGetDeviceInfoByNameAsMap", mock.AnythingOfType("string"), mock.AnythingOfType("string")).
Return(map[string]string{"someKey": "someValue"}, nil)
utils.SetNetlinkProviderInst(&testMockProvider)

pciAddr := "0000:00:00.1"
Expand Down
27 changes: 23 additions & 4 deletions pkg/netdevice/pciNetDevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,30 @@ func NewPciNetDevice(dev *ghw.PCIDevice,
}

func (nd *pciNetDevice) GetDDPProfiles() string {
ddpProfile := ""
pciAddr := nd.GetPciAddr()
ddpProfile, err := utils.GetDDPProfiles(pciAddr)
if err != nil {
glog.Infof("GetDDPProfiles(): unable to get ddp profiles for device %s : %q", pciAddr, err)
return ""
if utils.IsDevlinkDDPSupportedByDevice(nd.GetPfPciAddr()) {
var err error
ddpProfile, err = utils.DevlinkGetDDPProfiles(pciAddr)
if err != nil {
pfPCI := nd.GetPfPciAddr()
ddpProfile, err = utils.DevlinkGetDDPProfiles(pfPCI)
if err != nil {
Eoghan1232 marked this conversation as resolved.
Show resolved Hide resolved
// default to ddptool if devlink failed
ddpProfile, err = utils.GetDDPProfiles(pciAddr)
adrianchiris marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
glog.Infof("GetDDPProfiles(): unable to get ddp profiles for PCI %s and PF PCI device %s : %q", pciAddr, pfPCI, err)
return ""
}
}
}
} else if utils.IsDDPToolSupportedByDevice(pciAddr) {
var err error
ddpProfile, err = utils.GetDDPProfiles(pciAddr)
if err != nil {
glog.Infof("GetDDPProfiles(): unable to get ddp profiles for PCI %s and PF PCI device %s : %q", pciAddr, nd.GetPfPciAddr(), err)
return ""
}
}
Eoghan1232 marked this conversation as resolved.
Show resolved Hide resolved
return ddpProfile
}
Expand Down
21 changes: 18 additions & 3 deletions pkg/types/mocks/APIDevice.go

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

45 changes: 42 additions & 3 deletions pkg/types/mocks/AccelDevice.go

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

Loading
Loading