Skip to content

Commit

Permalink
Expose RDMA device name in the devicespec if available
Browse files Browse the repository at this point in the history
Signed-off-by: amaslennikov <amaslennikov@nvidia.com>
  • Loading branch information
almaslennikov committed Feb 8, 2024
1 parent 7720052 commit 17b9eaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions pkg/netdevice/netResourcePool.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/resources"
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types"
"github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils"
)

type netResourcePool struct {
Expand Down Expand Up @@ -113,6 +114,15 @@ func (rp *netResourcePool) StoreDeviceInfoFile(resourceNamePrefix string) error
PciAddress: netDev.GetPciAddr(),
},
}

if netDev.IsRdma() {
rdmaDevices := utils.GetRdmaProvider().GetRdmaDevicesForPcidev(devInfo.Pci.PciAddress)
if len(rdmaDevices) == 0 {
glog.Errorf("No RDMA devices available for RDMA capable device: %s", devInfo.Pci.PciAddress)
} else {
devInfo.Pci.RdmaDevice = strings.Join(rdmaDevices, ",")
}
}
}
resource := fmt.Sprintf("%s/%s", resourceNamePrefix, rp.GetConfig().ResourceName)
if err := rp.nadutils.SaveDeviceInfoFile(resource, id, &devInfo); err != nil {
Expand Down
6 changes: 4 additions & 2 deletions pkg/netdevice/netResourcePool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ var _ = Describe("NetResourcePool", func() {

fake1 := &mocks.PciNetDevice{}
fake1.On("GetPciAddr").Return("0000:01:00.1").
On("GetVdpaDevice").Return(nil)
On("GetVdpaDevice").Return(nil).
On("IsRdma").Return(true)
fake2 := &mocks.PciNetDevice{}
fake2.On("GetPciAddr").Return("0000:01:00.2").
On("GetVdpaDevice").Return(nil)
On("GetVdpaDevice").Return(nil).
On("IsRdma").Return(true)
pcis := map[string]types.HostDevice{"fake1": fake1, "fake2": fake2}

It("should call nadutils to create a well formatted DeviceInfo object", func() {
Expand Down

0 comments on commit 17b9eaf

Please sign in to comment.