File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -80,13 +80,25 @@ func detectPci() ([]nfdv1alpha1.InstanceFeature, error) {
80
80
81
81
// Iterate over devices
82
82
devInfo := make ([]nfdv1alpha1.InstanceFeature , 0 , len (devices ))
83
+ devGrouped := make (map [string ]map [string ]int )
83
84
for _ , device := range devices {
84
85
info , err := readPciDevInfo (filepath .Join (sysfsBasePath , device .Name ()))
85
86
if err != nil {
86
87
klog .ErrorS (err , "failed to read PCI device info" )
87
88
continue
88
89
}
89
- devInfo = append (devInfo , * info )
90
+ if _ , ok := devGrouped [info .Attributes ["vendor" ]][info .Attributes ["device" ]]; ! ok {
91
+ devGrouped [info .Attributes ["vendor" ]] = make (map [string ]int )
92
+ devGrouped [info .Attributes ["vendor" ]][info .Attributes ["device" ]] = 1
93
+ devInfo = append (devInfo , * info )
94
+ } else {
95
+ devGrouped [info .Attributes ["vendor" ]][info .Attributes ["device" ]] += 1
96
+ }
97
+ }
98
+
99
+ for _ , dev := range devInfo {
100
+ count := devGrouped [dev .Attributes ["vendor" ]][dev .Attributes ["device" ]]
101
+ dev .Attributes ["count" ] = string (count )
90
102
}
91
103
92
104
return devInfo , nil
You can’t perform that action at this time.
0 commit comments