-
Notifications
You must be signed in to change notification settings - Fork 111
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 wrapper for utils package from sriov-device-plugin #598
Merged
zeeke
merged 2 commits into
k8snetworkplumbingwg:master
from
ykulazhenkov:pr-dputis-wrapper
Feb 1, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package dputils | ||
|
||
import ( | ||
dputils "github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils" | ||
) | ||
|
||
func New() DPUtilsLib { | ||
return &libWrapper{} | ||
} | ||
|
||
//go:generate ../../../../../bin/mockgen -destination mock/mock_dputils.go -source dputils.go | ||
type DPUtilsLib interface { | ||
// GetNetNames returns host net interface names as string for a PCI device from its pci address | ||
GetNetNames(pciAddr string) ([]string, error) | ||
// GetDriverName returns current driver attached to a pci device from its pci address | ||
GetDriverName(pciAddr string) (string, error) | ||
// GetVFID returns VF ID index (within specific PF) based on PCI address | ||
GetVFID(pciAddr string) (vfID int, err error) | ||
// IsSriovVF check if a pci device has link to a PF | ||
IsSriovVF(pciAddr string) bool | ||
// IsSriovPF check if a pci device SRIOV capable given its pci address | ||
IsSriovPF(pciAddr string) bool | ||
// GetSriovVFcapacity returns SRIOV VF capacity | ||
GetSriovVFcapacity(pf string) int | ||
// GetVFconfigured returns number of VF configured for a PF | ||
GetVFconfigured(pf string) int | ||
// SriovConfigured returns true if sriov_numvfs reads > 0 else false | ||
SriovConfigured(addr string) bool | ||
// GetVFList returns a List containing PCI addr for all VF discovered in a given PF | ||
GetVFList(pf string) (vfList []string, err error) | ||
} | ||
|
||
type libWrapper struct{} | ||
|
||
// GetNetNames returns host net interface names as string for a PCI device from its pci address | ||
func (w *libWrapper) GetNetNames(pciAddr string) ([]string, error) { | ||
return dputils.GetNetNames(pciAddr) | ||
} | ||
|
||
// GetDriverName returns current driver attached to a pci device from its pci address | ||
func (w *libWrapper) GetDriverName(pciAddr string) (string, error) { | ||
return dputils.GetDriverName(pciAddr) | ||
} | ||
|
||
// GetVFID returns VF ID index (within specific PF) based on PCI address | ||
func (w *libWrapper) GetVFID(pciAddr string) (vfID int, err error) { | ||
return dputils.GetVFID(pciAddr) | ||
} | ||
|
||
// IsSriovVF check if a pci device has link to a PF | ||
func (w *libWrapper) IsSriovVF(pciAddr string) bool { | ||
return dputils.IsSriovVF(pciAddr) | ||
} | ||
|
||
// IsSriovPF check if a pci device SRIOV capable given its pci address | ||
func (w *libWrapper) IsSriovPF(pciAddr string) bool { | ||
return dputils.IsSriovPF(pciAddr) | ||
} | ||
|
||
// GetSriovVFcapacity returns SRIOV VF capacity | ||
func (w *libWrapper) GetSriovVFcapacity(pf string) int { | ||
return dputils.GetSriovVFcapacity(pf) | ||
} | ||
|
||
// GetVFconfigured returns number of VF configured for a PF | ||
func (w *libWrapper) GetVFconfigured(pf string) int { | ||
return dputils.GetVFconfigured(pf) | ||
} | ||
|
||
// SriovConfigured returns true if sriov_numvfs reads > 0 else false | ||
func (w *libWrapper) SriovConfigured(addr string) bool { | ||
return dputils.SriovConfigured(addr) | ||
} | ||
|
||
// GetVFList returns a List containing PCI addr for all VF discovered in a given PF | ||
func (w *libWrapper) GetVFList(pf string) (vfList []string, err error) { | ||
return dputils.GetVFList(pf) | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These might be good candidates for sriovnet (not related to this PR)