Skip to content

Commit

Permalink
Adding NX Gzip support for power. PR 956
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Abhyankar <[email protected]>
  • Loading branch information
Chandan-Abhyankar committed Dec 13, 2022
1 parent add6f18 commit 84406a7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
SgxFeature = "sgx" // DEPRECATED in v0.12: will be removed in the future
SstFeature = "sst"
TopologyFeature = "topology"
NXFeature = "nx"
)

// Configuration file options
Expand Down Expand Up @@ -192,6 +193,11 @@ func (s *cpuSource) GetLabels() (source.FeatureLabels, error) {
labels["hardware_multithreading"] = v
}

// NX
if v, ok := features.Attributes[NXFeature].Elements["nx_gzip"]; ok {
labels["nx_gzip"] = v
}

return labels, nil
}

Expand Down Expand Up @@ -246,6 +252,9 @@ func (s *cpuSource) Discover() error {
// Detect hyper-threading
s.features.Attributes[TopologyFeature] = nfdv1alpha1.NewAttributeFeatures(discoverTopology())

// Detect nx-gzip
s.features.Attributes[NXFeature] = nfdv1alpha1.NewAttributeFeatures(discoverNxGzip())

utils.KlogDump(3, "discovered cpu features:", " ", s.features)

return nil
Expand Down
43 changes: 43 additions & 0 deletions source/cpu/nx_ppc64le.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//go:build ppc64le
// +build ppc64le

/*
Copyright 2018 The Kubernetes Authors.
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 cpu

import (
"k8s.io/klog/v2"
"os"
"strconv"
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
)

/* Detect NX_GZIP */
func discoverNxGzip() map[string]string {
features := make(map[string]string)

nxGzipPath := hostpath.SysfsDir.Path("devices/vio/ibm,compression-v1/nx_gzip_caps")

_, err := os.Stat(nxGzipPath)
if err != nil {
klog.V(5).Infof("Failed to detect nx_gzip for Nest Accelerator: %v", err)
} else {
features["nx_gzip"] = strconv.FormatBool(true)
}

return features
}
24 changes: 24 additions & 0 deletions source/cpu/nx_stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build !ppc64le
// +build !ppc64le

/*
Copyright 2018 The Kubernetes Authors.
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 cpu

func discoverNxGzip() map[string]string {
return nil
}

0 comments on commit 84406a7

Please sign in to comment.