Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions addons/intel/e830.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,11 @@ func OnPTPConfigChangeE830(_ *interface{}, nodeProfile *ptpv1.PtpProfile) error
glog.Infof("Initializing e830 plugin for profile %s and devices %v", *nodeProfile.Name, allDevices)

// Setup clockID (prefer ice modue clock ID for e830)
iceClockID, iceErr := getClockIDByModule("ice")
if iceErr != nil {
glog.Errorf("e830: failed to resolve ICE DPLL clock ID via netlink: %v", iceErr)
}
for _, device := range allDevices {
clockID := getClockIDE810(device)
dpllClockIDStr := fmt.Sprintf("%s[%s]", dpll.ClockIdStr, device)
if iceErr == nil {
(*nodeProfile).PtpSettings[dpllClockIDStr] = strconv.FormatUint(iceClockID, 10)
glog.Infof("Detected %s=%d (%x)", dpllClockIDStr, iceClockID, iceClockID)
} else {
glog.Errorf("No clockID detected for %s", device)
}
nodeProfile.PtpSettings[dpllClockIDStr] = strconv.FormatUint(clockID, 10)
glog.Infof("e830: Detected %s=%d (%x)", dpllClockIDStr, clockID, clockID)
}

// Initialize all user-specified PGT pins and frequencies
Expand All @@ -99,12 +92,10 @@ func OnPTPConfigChangeE830(_ *interface{}, nodeProfile *ptpv1.PtpProfile) error

// Copy PhaseOffsetPins settings from plugin config to PtpSettings
for iface, properties := range opts.PhaseOffsetPins {
dpllClockIDStr := fmt.Sprintf("%s[%s]", dpll.ClockIdStr, iface)
clockIDStr := nodeProfile.PtpSettings[dpllClockIDStr]
for pinProperty, value := range properties {
var clockIDUsed uint64
if iceErr == nil {
clockIDUsed = iceClockID
}
key := strings.Join([]string{iface, "phaseOffsetFilter", strconv.FormatUint(clockIDUsed, 10), pinProperty}, ".")
key := strings.Join([]string{iface, "phaseOffsetFilter", clockIDStr, pinProperty}, ".")
(*nodeProfile).PtpSettings[key] = value
}
}
Expand All @@ -118,16 +109,17 @@ func OnPTPConfigChangeE830(_ *interface{}, nodeProfile *ptpv1.PtpProfile) error
// TODO: We could actually figure this out based on upstreamPort... And the fact that there's only one NAC per GNR-D
return errors.New("GNR-D T-BC must set leadingInterface")
}
// e830 DPLL is inaccessible to software, so ensure the daemon ignores all e830 DPLLs for now:
for _, device := range allDevices {
// Note: Only set to "true" if it's unset; This allows overriding this by explicitly setting dpll.$iface.ignore = "false" in the PtpConfig section
key := dpll.PtpSettingsDpllIgnoreKey(device)
if value, ok := nodeProfile.PtpSettings[key]; ok {
glog.Infof("Not setting %s (already \"%s\")", key, value)
} else {
nodeProfile.PtpSettings[key] = "true"
glog.Infof("Setting %s = \"true\"", key)
}
}

// e830 DPLL is inaccessible to software, so ensure the daemon ignores all e830 DPLLs for now:
for _, device := range allDevices {
// Note: Only set to "true" if it's unset; This allows overriding this by explicitly setting dpll.$iface.ignore = "false" in the PtpConfig section
key := dpll.PtpSettingsDpllIgnoreKey(device)
if value, ok := nodeProfile.PtpSettings[key]; ok {
glog.Infof("Not setting %s (already \"%s\")", key, value)
} else {
nodeProfile.PtpSettings[key] = "true"
glog.Infof("Setting %s = \"true\"", key)
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions addons/intel/e830_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package intel

import (
"fmt"
"testing"

ptpv1 "github.com/k8snetworkplumbingwg/ptp-operator/api/v1"
Expand Down Expand Up @@ -31,14 +32,16 @@ func Test_OnPTPConfigChangeE830(t *testing.T) {
name: "TGM Profile",
profile: "./testdata/e825-tgm.yaml",
expectedPtpSettings: map[string]string{
"dpll.enp108s0f0.ignore": "",
"dpll.enp108s0f0.ignore": "true",
"clockId[enp108s0f0]": "0",
},
},
{
name: "TBC Profile",
profile: "./testdata/e825-tbc.yaml",
expectedPtpSettings: map[string]string{
"dpll.enp108s0f0.ignore": "true",
"clockId[enp108s0f0]": "0",
},
},
{
Expand All @@ -50,6 +53,7 @@ func Test_OnPTPConfigChangeE830(t *testing.T) {
},
expectedPtpSettings: map[string]string{
"dpll.enp108s0f0.ignore": "false",
"clockId[enp108s0f0]": "0",
},
},
{
Expand Down Expand Up @@ -88,7 +92,7 @@ func Test_OnPTPConfigChangeE830(t *testing.T) {
assert.Equal(tt, tc.expectedPinSets, mockPins.actualPinSetCount)
assert.Equal(tt, tc.expectedPinFrqs, mockPins.actualPinFrqCount)
for key, value := range tc.expectedPtpSettings {
assert.Equal(tt, value, profile.PtpSettings[key])
assert.Equal(tt, value, profile.PtpSettings[key], fmt.Sprintf("PtpSettings[%s]", key))
}
}
})
Expand Down