Skip to content

Conversation

@vitus133
Copy link
Collaborator

@vitus133 vitus133 commented Dec 8, 2025

Assisted by Cursor AI
Add Perla2 vendor definitions
Integrate T-BC on the target

/cc @lack @nocturnalastro @josephdrichard @jzding

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Thanks for your PR,
Best regards.

Copy link
Collaborator

@greyerof greyerof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more nits plus some (strong) recommendations to avoid hidding errors.

// For T-BC mode with hardwareconfig, derive interfaces from hardwareconfig structure
// instead of analyzing ts2phc configuration file
var interfacesToUse config.IFaces
if profileClockType == TBC && dn.hardwareConfigManager != nil &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this check dn.hardwareConfigManager != nil. You're already using it without any check at line 668 right at the very beginning of this func.

Also, I've seen this check in other functions, but I don't think it's necessary. The hardwareconfig.NewHardwareConfigManager() that sets this field in the daemon's field would have probably panic'ed right at the creation of the daemon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, dn.hardwareConfigManager is never nil, as New() always allocates the manager regardless of whether any HardwareConfig objects exist. Removing it everywhere

inSyncConditionTh, inSyncConditionTimes)
glog.Infof("depending on %s", dpllDaemon.DependsOn())
// Set hardwareconfig handler if hardwareconfig manager is available
if dn.hardwareConfigManager != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


// Step 2: PERLA workaround - Check if this is an E825 device
// For E825 devices, there's no direct NIC-DPLL association, so we look for the zl3073x DPLL
lspciOutput, lspciErr := commandExecutor.Execute("lspci", "-s", busAddr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not handling here a possible error value in lspciErr. Why not just checking it first? Also (nit), you can also reuse the "err" variable name.

lspciOutput, err := commandExecutor.Execute("lspci", "-s", busAddr)
if err != nil {
    return 0, fmt.Errorf("failed to run lspci -s %s, output: %s, err: %w", busAddr, lspciOutput, err)
}

if strings.Contains(lspciOutput, "E825") {
...

Comment on lines 243 to 264
cache := pinCache
if cache == nil {
var cacheErr error
cache, cacheErr = GetDpllPins()
if cacheErr != nil {
glog.Warningf("PERLA workaround: failed to get pin cache: %v, falling back to serial number approach", cacheErr)
cache = nil
}
}

if cache != nil {
// Look for first pin with moduleName == "zl3073x"
for clockID, pins := range cache.Pins {
for _, pin := range pins {
if pin.ModuleName == "zl3073x" {
glog.Infof("PERLA workaround: Found zl3073x DPLL with clock ID %#x, associating with E825 interface %s", clockID, iface)
return clockID, nil
}
}
}
glog.Warningf("PERLA workaround: No zl3073x DPLL found in pin cache, falling back to serial number approach")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Hide all this logic in a separate func like getPERLAClockIDFromPinCache() or similar.

	if strings.Contains(lspciOutput, "E825") {
		glog.Infof("Detected E825 device on %s (interface %s), using PERLA workaround", busAddr, iface)

		clockId, err := getPERLAClockIDFromPinCache(pinCache)
		if err != nil {
			glog.Warningf("PERLA workaround: failed to get clock ID from pin cache: %v, falling back to serial number approach", err)
		} else {
			return clockId, nil
		}
	}

pluginFunc := pluginObject.OnPTPConfigChange
if pluginFunc != nil {
pluginFunc(pm.Data[pluginName], nodeProfile)
_ = pluginFunc(pm.Data[pluginName], nodeProfile)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A warning log trace is worth here instead of just hidding the error in the "_" var. Same with the others (lines 57 and 67).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this change from the set - it was unintentional. Joseph already doing something in the area of plugin failures, I don't want to create merge problems for him

@github-actions github-actions bot removed the ok-to-test ok to test label Dec 18, 2025
@vitus133 vitus133 added ok-to-test ok to test and removed ok-to-test ok to test labels Dec 18, 2025
@vitus133 vitus133 added the ok-to-test ok to test label Dec 18, 2025
Copy link
Collaborator

@greyerof greyerof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I'm not familiar enough with this new controller so I can only review basic go code. In that regards, I can see more code blocks that could be moved to separate functions to improve readability/testability.

@github-actions github-actions bot removed the ok-to-test ok to test label Dec 23, 2025
@vitus133 vitus133 force-pushed the perla-integ branch 2 times, most recently from 93ea077 to 5961889 Compare December 23, 2025 17:37
Assisted by Cursor AI
Add Perla2 vendor definitions
Integrate on the target

Signed-off-by: Vitaly Grinberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test ok to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants