File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 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) {
8080
8181 // Iterate over devices
8282 devInfo := make ([]nfdv1alpha1.InstanceFeature , 0 , len (devices ))
83+ devGrouped := make (map [string ]map [string ]int )
8384 for _ , device := range devices {
8485 info , err := readPciDevInfo (filepath .Join (sysfsBasePath , device .Name ()))
8586 if err != nil {
8687 klog .ErrorS (err , "failed to read PCI device info" )
8788 continue
8889 }
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 )
90102 }
91103
92104 return devInfo , nil
You can’t perform that action at this time.
0 commit comments