mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-05 08:17:04 +00:00
Re-factor cpuid functionality out of source/rdt
Move the cpuid functionality into a separate library package so that it can be easily re-used by other sources.
This commit is contained in:
parent
c54551f599
commit
86382afe56
3 changed files with 36 additions and 15 deletions
29
pkg/cpuid/cpuid_amd64.go
Normal file
29
pkg/cpuid/cpuid_amd64.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
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 cpuid
|
||||
|
||||
type CpuidRet struct {
|
||||
EAX, EBX, ECX, EDX uint32
|
||||
}
|
||||
|
||||
func Cpuid(eax, ecx uint32) *CpuidRet {
|
||||
r := &CpuidRet{}
|
||||
r.EAX, r.EBX, r.ECX, r.EDX = cpuidAsm(eax, ecx)
|
||||
return r
|
||||
}
|
||||
|
||||
func cpuidAsm(eax_arg, ecx_arg uint32) (eax, ebx, ecx, edx uint32)
|
|
@ -18,9 +18,9 @@ limitations under the License.
|
|||
|
||||
package rdt
|
||||
|
||||
type CpuidRet struct {
|
||||
EAX, EBX, ECX, EDX uint32
|
||||
}
|
||||
import (
|
||||
"sigs.k8s.io/node-feature-discovery/pkg/cpuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// CPUID EAX input values
|
||||
|
@ -47,10 +47,10 @@ func discoverRDT() []string {
|
|||
features := []string{}
|
||||
|
||||
// Read cpuid information
|
||||
extFeatures := cpuid(LEAF_EXT_FEATURE_FLAGS, 0)
|
||||
rdtMonitoring := cpuid(LEAF_RDT_MONITORING, 0)
|
||||
rdtL3Monitoring := cpuid(LEAF_RDT_MONITORING, RDT_MONITORING_SUBLEAF_L3)
|
||||
rdtAllocation := cpuid(LEAF_RDT_ALLOCATION, 0)
|
||||
extFeatures := cpuid.Cpuid(LEAF_EXT_FEATURE_FLAGS, 0)
|
||||
rdtMonitoring := cpuid.Cpuid(LEAF_RDT_MONITORING, 0)
|
||||
rdtL3Monitoring := cpuid.Cpuid(LEAF_RDT_MONITORING, RDT_MONITORING_SUBLEAF_L3)
|
||||
rdtAllocation := cpuid.Cpuid(LEAF_RDT_ALLOCATION, 0)
|
||||
|
||||
// Detect RDT monitoring capabilities
|
||||
if extFeatures.EBX&EXT_FEATURE_FLAGS_EBX_RDT_M != 0 {
|
||||
|
@ -88,11 +88,3 @@ func discoverRDT() []string {
|
|||
|
||||
return features
|
||||
}
|
||||
|
||||
func cpuid(eax, ecx uint32) CpuidRet {
|
||||
r := CpuidRet{}
|
||||
r.EAX, r.EBX, r.ECX, r.EDX = cpuidAsm(eax, ecx)
|
||||
return r
|
||||
}
|
||||
|
||||
func cpuidAsm(eax_arg, ecx_arg uint32) (eax, ebx, ecx, edx uint32)
|
||||
|
|
Loading…
Add table
Reference in a new issue