forked from NVIDIA/k8s-device-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com>
- Loading branch information
1 parent
5281fde
commit c2ab8a7
Showing
23 changed files
with
39,034 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
**/ | ||
|
||
package resource | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/NVIDIA/go-nvlib/pkg/nvpci" | ||
) | ||
|
||
type vfioDevice struct { | ||
nvidiaPCIDevice *nvpci.NvidiaPCIDevice | ||
} | ||
|
||
// GetMigDevices returns the list of MIG devices configured on this device | ||
func (d vfioDevice) GetMigDevices() ([]Device, error) { | ||
return nil, nil | ||
} | ||
|
||
// GetCudaComputeCapability is not supported for GPU devices with vfio pci driver. | ||
func (d vfioDevice) GetCudaComputeCapability() (int, int, error) { | ||
return -1, -1, nil | ||
} | ||
|
||
// GetAttributes is only supported for MIG devices. | ||
func (d vfioDevice) GetAttributes() (map[string]interface{}, error) { | ||
return nil, fmt.Errorf("GetAttributes is not supported for non-MIG devices") | ||
} | ||
|
||
// GetDeviceHandleFromMigDeviceHandle is only supported for MIG devices | ||
func (d vfioDevice) GetDeviceHandleFromMigDeviceHandle() (Device, error) { | ||
return nil, fmt.Errorf("GetDeviceHandleFromMigDeviceHandle is not supported for non-MIG devices") | ||
} | ||
|
||
// GetName returns the device name / model. | ||
func (d vfioDevice) GetName() (string, error) { | ||
return d.nvidiaPCIDevice.DeviceName, nil | ||
} | ||
|
||
// GetTotalMemoryMB returns the total memory on a device in MB | ||
func (d vfioDevice) GetTotalMemoryMB() (uint64, error) { | ||
_, val := d.nvidiaPCIDevice.Resources.GetTotalAddressableMemory(true) | ||
return val, nil | ||
} | ||
|
||
func (d vfioDevice) IsMigEnabled() (bool, error) { | ||
return false, nil | ||
} | ||
|
||
func (d vfioDevice) IsMigCapable() (bool, error) { | ||
return false, nil | ||
} |
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,75 @@ | ||
/** | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
**/ | ||
|
||
package resource | ||
|
||
import ( | ||
"github.com/NVIDIA/go-nvlib/pkg/nvpci" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
type vfioLib struct { | ||
nvpcilib nvpci.Interface | ||
} | ||
|
||
// NewVfioManager returns an resource manger for devices with VFIO PCI driver | ||
func NewVfioManager() Manager { | ||
nvpcilib := nvpci.New() | ||
manager := vfioLib{ | ||
nvpcilib: nvpcilib, | ||
} | ||
return &manager | ||
} | ||
|
||
// Init is a no-op for the vfio manager | ||
func (l *vfioLib) Init() error { | ||
return nil | ||
} | ||
|
||
// Shutdown is a no-op for the vfio manager | ||
func (l *vfioLib) Shutdown() (err error) { | ||
return nil | ||
} | ||
|
||
// GetDevices returns the devices with VFIO PCI driver available on the system | ||
func (l *vfioLib) GetDevices() ([]Device, error) { | ||
var devices []Device | ||
nvdevices, err := l.nvpcilib.GetGPUs() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, dev := range nvdevices { | ||
if dev.Driver == "vfio-pci" { | ||
vfioDev := vfioDevice{dev} | ||
devices = append(devices, vfioDev) | ||
} else { | ||
klog.Infof("Device not bound to 'vfio-pci'; device: %s driver: '%s'", dev.Address, dev.Driver) | ||
} | ||
} | ||
return devices, nil | ||
} | ||
|
||
// GetCudaDriverVersion is not supported | ||
func (l *vfioLib) GetCudaDriverVersion() (*uint, *uint, error) { | ||
unknown := uint(0) | ||
return &unknown, &unknown, nil | ||
} | ||
|
||
// GetDriverVersion is not supported | ||
func (l *vfioLib) GetDriverVersion() (string, error) { | ||
return "unknown.unknown.unknown", nil | ||
} |
94 changes: 94 additions & 0 deletions
94
vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.