-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2664 from amorenoz/vdpa
Add support to virtio-vDPA devices
- Loading branch information
Showing
14 changed files
with
1,165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/k8snetworkplumbingwg/govdpa/pkg/kvdpa" | ||
) | ||
|
||
type VdpaDevice interface { | ||
kvdpa.VdpaDevice | ||
} | ||
|
||
type VdpaOps interface { | ||
GetVdpaDeviceByPci(pciAddress string) (kvdpa.VdpaDevice, error) | ||
} | ||
|
||
type defaultVdpaOps struct { | ||
} | ||
|
||
var vdpaOps VdpaOps = &defaultVdpaOps{} | ||
|
||
// SetVdpaOpsInst method should be used by unit tests in | ||
func SetVdpaOpsInst(mockInst VdpaOps) { | ||
vdpaOps = mockInst | ||
} | ||
|
||
// GetVdpaOps will be invoked by functions in other packages that would need access to the govdpa library methods. | ||
func GetVdpaOps() VdpaOps { | ||
return vdpaOps | ||
} | ||
|
||
func (v *defaultVdpaOps) GetVdpaDeviceByPci(pciAddress string) (kvdpa.VdpaDevice, error) { | ||
// the PCI prefix is required by the govdpa library | ||
vdpaDevices, err := kvdpa.GetVdpaDevicesByPciAddress("pci/" + pciAddress) | ||
if len(vdpaDevices) > 0 { | ||
return vdpaDevices[0], nil | ||
} | ||
return nil, err | ||
} |
Oops, something went wrong.