Skip to content

Added Link Settings (GLINKSETTINGS/SLINKSETTINGS) Support#102

Merged
safchain merged 2 commits intosafchain:masterfrom
halfcrazy:glinksettings1
May 7, 2025
Merged

Added Link Settings (GLINKSETTINGS/SLINKSETTINGS) Support#102
safchain merged 2 commits intosafchain:masterfrom
halfcrazy:glinksettings1

Conversation

@halfcrazy
Copy link
Copy Markdown
Contributor

@halfcrazy halfcrazy commented May 3, 2025

fix #82 #33

Added Link Settings (GLINKSETTINGS/SLINKSETTINGS) Support

This change introduces support for the ETHTOOL_GLINKSETTINGS and ETHTOOL_SLINKSETTINGS ioctls, providing a more modern and comprehensive way to configure network interface Link Settings compared to the older ETHTOOL_GSET/SSET.

Main Functions

  • GetLinkSettings(intfName string) (*LinkSettings, error):

    • Retrieves the Link Settings for the specified network interface (intfName).
    • Attempts first to use the ETHTOOL_GLINKSETTINGS ioctl to get extended Link Settings.
    • If the kernel or driver does not support GLINKSETTINGS (returns an EOPNOTSUPP error), it automatically falls back to calling the older CmdGet() (using ETHTOOL_GSET) and converts the result to the new LinkSettings struct before returning.
    • Returns a pointer to a LinkSettings struct containing the detailed Link Settings.
  • SetLinkSettings(intfName string, settings LinkSettings) error:

    • Sets the Link Settings for the specified network interface (intfName) using the provided settings struct.
    • First checks if the device supports the GLINKSETTINGS interface.
    • If supported, it uses the ETHTOOL_SLINKSETTINGS ioctl to apply the settings.
    • If not supported (returns an EOPNOTSUPP error), it attempts to fall back to calling the older CmdSet() (using ETHTOOL_SSET).
    • Important: When falling back to SSET, it checks if the requested Link Modes in settings exceed the capabilities of the old interface (e.g., setting modes beyond bit 31). If they do, an error is returned because the old interface cannot fulfill the request.

@halfcrazy halfcrazy changed the title add support ETHTOOL_GLINKSETTINGS ETHTOOL_SLINKSETTINGS Added Link Settings (GLINKSETTINGS/SLINKSETTINGS) Support May 4, 2025
@halfcrazy halfcrazy force-pushed the glinksettings1 branch 2 times, most recently from 9493add to 0281baa Compare May 6, 2025 02:01
@safchain safchain merged commit 6d66090 into safchain:master May 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to get the rate of network port support without plugging in the network cable

2 participants