@@ -79,6 +79,8 @@ var _ = Describe("DiscoverSriovDevices", func() {
7979 mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("0000:00:01.0" , nil )
8080 mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return (consts .LinkTypeEthernet , nil )
8181 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
82+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
83+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.2" ).Return (false )
8284
8385 devices , err := DiscoverSriovDevices ()
8486 Expect (err ).NotTo (HaveOccurred ())
@@ -153,7 +155,9 @@ var _ = Describe("DiscoverSriovDevices", func() {
153155 mockHost .EXPECT ().GetLinkType ("0000:02:00.0" ).Return (consts .LinkTypeInfiniband , nil )
154156
155157 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList1 , nil )
158+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
156159 mockHost .EXPECT ().GetVFList ("0000:02:00.0" ).Return (vfList2 , nil )
160+ mockHost .EXPECT ().VerifyRDMACapability ("0000:02:00.1" ).Return (false )
157161
158162 devices , err := DiscoverSriovDevices ()
159163 Expect (err ).NotTo (HaveOccurred ())
@@ -205,14 +209,15 @@ var _ = Describe("DiscoverSriovDevices", func() {
205209 mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("" , nil )
206210 mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return (consts .LinkTypeEthernet , nil )
207211 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
212+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
208213
209214 devices , err := DiscoverSriovDevices ()
210215 Expect (err ).NotTo (HaveOccurred ())
211216 Expect (devices ).To (HaveLen (1 ))
212217
213- // NUMA should default to 0
218+ // NUMA should default to -1 (not supported)
214219 dev := devices ["0000-01-00-1" ]
215- Expect (dev .Attributes [consts .AttributeNumaNode ].IntValue ).To (Equal (ptr .To (int64 (0 ))))
220+ Expect (dev .Attributes [consts .AttributeNumaNode ].IntValue ).To (Equal (ptr .To (int64 (- 1 ))))
216221 // Standard PCI address should still be set
217222 Expect (dev .Attributes [consts .AttributeStandardPciAddress ].StringValue ).To (Equal (ptr .To ("0000:01:00.1" )))
218223 })
@@ -242,6 +247,7 @@ var _ = Describe("DiscoverSriovDevices", func() {
242247 mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("" , fmt .Errorf ("parent not found" ))
243248 mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return (consts .LinkTypeEthernet , nil )
244249 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
250+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
245251
246252 devices , err := DiscoverSriovDevices ()
247253 Expect (err ).NotTo (HaveOccurred ())
@@ -279,6 +285,7 @@ var _ = Describe("DiscoverSriovDevices", func() {
279285 mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("0000:00:01.0" , nil )
280286 mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return ("" , fmt .Errorf ("lookup failed" ))
281287 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
288+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
282289
283290 devices , err := DiscoverSriovDevices ()
284291 Expect (err ).NotTo (HaveOccurred ())
@@ -292,6 +299,107 @@ var _ = Describe("DiscoverSriovDevices", func() {
292299 Expect (dev .Attributes [consts .AttributePFName ].StringValue ).To (Equal (ptr .To ("eth0" )))
293300 Expect (dev .Attributes [consts .AttributeStandardPciAddress ].StringValue ).To (Equal (ptr .To ("0000:01:00.1" )))
294301 })
302+
303+ Context ("RDMA Capability" , func () {
304+ var (
305+ pciInfo * pci.Info
306+ vfList []host.VFInfo
307+ )
308+
309+ BeforeEach (func () {
310+ pciInfo = & pci.Info {
311+ Devices : []* pci.Device {
312+ {
313+ Address : "0000:01:00.0" ,
314+ Class : & pcidb.Class {ID : "02" },
315+ Vendor : & pcidb.Vendor {ID : "15b3" }, // Mellanox
316+ Product : & pcidb.Product {ID : "1017" }, // ConnectX-5
317+ },
318+ },
319+ }
320+
321+ vfList = []host.VFInfo {
322+ {
323+ PciAddress : "0000:01:00.1" ,
324+ VFID : 0 ,
325+ DeviceID : "1018" ,
326+ },
327+ }
328+
329+ mockHost .EXPECT ().PCI ().Return (pciInfo , nil )
330+ mockHost .EXPECT ().IsSriovVF ("0000:01:00.0" ).Return (false )
331+ mockHost .EXPECT ().TryGetInterfaceName ("0000:01:00.0" ).Return ("ib0" )
332+ mockHost .EXPECT ().GetNicSriovMode ("0000:01:00.0" ).Return ("switchdev" )
333+ mockHost .EXPECT ().GetNumaNode ("0000:01:00.0" ).Return ("1" , nil )
334+ mockHost .EXPECT ().GetPCIeRoot ("0000:01:00.0" ).Return ("pci0000:00" , nil )
335+ mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("0000:00:01.0" , nil )
336+ mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return (consts .LinkTypeInfiniband , nil )
337+ })
338+
339+ It ("should discover RDMA-capable VFs with RDMA attributes" , func () {
340+ // Add a second VF to the list for this specific test
341+ localVfList := []host.VFInfo {
342+ {
343+ PciAddress : "0000:01:00.1" ,
344+ VFID : 0 ,
345+ DeviceID : "1018" ,
346+ },
347+ {
348+ PciAddress : "0000:01:00.2" ,
349+ VFID : 1 ,
350+ DeviceID : "1018" ,
351+ },
352+ }
353+ mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (localVfList , nil )
354+
355+ // First VF is RDMA-capable
356+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (true )
357+
358+ // Second VF is not RDMA-capable
359+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.2" ).Return (false )
360+
361+ devices , err := DiscoverSriovDevices ()
362+ Expect (err ).NotTo (HaveOccurred ())
363+ Expect (devices ).To (HaveLen (2 ))
364+
365+ // Check first VF (RDMA-capable)
366+ dev1 := devices ["0000-01-00-1" ]
367+ Expect (dev1 .Name ).To (Equal ("0000-01-00-1" ))
368+ Expect (dev1 .Attributes [consts .AttributeVendorID ].StringValue ).To (Equal (ptr .To ("15b3" )))
369+ Expect (dev1 .Attributes [consts .AttributeDeviceID ].StringValue ).To (Equal (ptr .To ("1018" )))
370+ Expect (dev1 .Attributes [consts .AttributePFDeviceID ].StringValue ).To (Equal (ptr .To ("1017" )))
371+ Expect (dev1 .Attributes [consts .AttributePciAddress ].StringValue ).To (Equal (ptr .To ("0000:01:00.1" )))
372+ Expect (dev1 .Attributes [consts .AttributePFName ].StringValue ).To (Equal (ptr .To ("ib0" )))
373+ Expect (dev1 .Attributes [consts .AttributeEswitchMode ].StringValue ).To (Equal (ptr .To ("switchdev" )))
374+ Expect (dev1 .Attributes [consts .AttributeVFID ].IntValue ).To (Equal (ptr .To (int64 (0 ))))
375+ Expect (dev1 .Attributes [consts .AttributeNumaNode ].IntValue ).To (Equal (ptr .To (int64 (1 ))))
376+ Expect (dev1 .Attributes [consts .AttributePCIeRoot ].StringValue ).To (Equal (ptr .To ("pci0000:00" )))
377+ Expect (dev1 .Attributes [consts .AttributeParentPciAddress ].StringValue ).To (Equal (ptr .To ("0000:00:01.0" )))
378+ Expect (dev1 .Attributes [consts .AttributeStandardPciAddress ].StringValue ).To (Equal (ptr .To ("0000:01:00.1" )))
379+ // RDMA-specific attributes
380+ Expect (dev1 .Attributes [consts .AttributeRDMACapable ].BoolValue ).To (Equal (ptr .To (true )))
381+
382+ // Check second VF (not RDMA-capable)
383+ dev2 := devices ["0000-01-00-2" ]
384+ Expect (dev2 .Name ).To (Equal ("0000-01-00-2" ))
385+ Expect (dev2 .Attributes [consts .AttributeVFID ].IntValue ).To (Equal (ptr .To (int64 (1 ))))
386+ Expect (dev2 .Attributes [consts .AttributeRDMACapable ].BoolValue ).To (Equal (ptr .To (false )))
387+ })
388+
389+ It ("should handle RDMA capability check errors gracefully" , func () {
390+ mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
391+ // RDMA capability check fails (returns false)
392+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
393+
394+ devices , err := DiscoverSriovDevices ()
395+ Expect (err ).NotTo (HaveOccurred ())
396+ Expect (devices ).To (HaveLen (1 ))
397+
398+ // Should default to not RDMA capable
399+ dev := devices ["0000-01-00-1" ]
400+ Expect (dev .Attributes [consts .AttributeRDMACapable ].BoolValue ).To (Equal (ptr .To (false )))
401+ })
402+ })
295403 })
296404
297405 Context ("Filtering Cases" , func () {
@@ -355,6 +463,7 @@ var _ = Describe("DiscoverSriovDevices", func() {
355463 mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("" , nil )
356464 mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return (consts .LinkTypeEthernet , nil )
357465 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
466+ mockHost .EXPECT ().VerifyRDMACapability ("0000:01:00.1" ).Return (false )
358467
359468 // Second device (VF) - should be skipped
360469 mockHost .EXPECT ().IsSriovVF ("0000:01:00.1" ).Return (true )
@@ -486,6 +595,7 @@ var _ = Describe("DiscoverSriovDevices", func() {
486595 mockHost .EXPECT ().GetParentPciAddress ("0000:01:00.0" ).Return ("" , nil )
487596 mockHost .EXPECT ().GetLinkType ("0000:01:00.0" ).Return (consts .LinkTypeEthernet , nil )
488597 mockHost .EXPECT ().GetVFList ("0000:01:00.0" ).Return (vfList , nil )
598+ mockHost .EXPECT ().VerifyRDMACapability ("0000:af:10.7" ).Return (false )
489599
490600 devices , err := DiscoverSriovDevices ()
491601 Expect (err ).NotTo (HaveOccurred ())
0 commit comments