Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutoNegotiation and PauseFrameUse NICCapabilities #338

Merged
merged 4 commits into from
May 4, 2023

Conversation

jak3kaj
Copy link
Contributor

@jak3kaj jak3kaj commented Apr 27, 2023

Make AutoNegotiation and PauseFrameUse NICCapability objects:

  • AutoNegotiation (string value of auto-negotiation)
  • PauseFrameUse (string value of pause-frame-use)

Refactoring PR #335

Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Thanks @jak3kaj! Few suggestions inline for you but this is on a good track!

pkg/net/net_linux.go Outdated Show resolved Hide resolved
pkg/net/net_linux.go Outdated Show resolved Hide resolved
@jak3kaj
Copy link
Contributor Author

jak3kaj commented Apr 27, 2023

By moving setNicAttrEthtool() into netDeviceCapabilities() I should have resolved the concerns you shared.

I made some more changes as the logic made less sense after moving the code. I split up the updateNicAttrEthtool() method and created autoNegCap() and pauseFrameUseCap() so they behaved more like the other code in netDeviceCapabilities() (returning *NICCapabilties objects).

I put the logic to parse ethtool before parsing ethtool -k so there is a sort of logical order (ASCII-betical).

If I were to replace running ethtool with an ethtool-like go library, hopefully this function (and functions it calls) are all that would need to be modified. In the back of my mind I imagine that calling a go library can return the same map that parseNicAttrEthtool() is returning, so we can use autoNegCap() and pauseFrameUseCap() in the same way.

Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Great work on this @jak3kaj thank you! :) Welcome to the ghw contributor club!

@jaypipes
Copy link
Owner

@jak3kaj can you run gofmt -w . on your source tree checkout please? the formatting check is complaining...

@jak3kaj
Copy link
Contributor Author

jak3kaj commented May 1, 2023

The thing it's flagging is not flagged by gofmt or go fmt.

It wants this:

            expected: []*NICCapability{
                {
                    Name:      "auto-negotiation",
                    IsEnabled: true,
                    CanEnable: true,
                },
                {
                    Name:      "pause-frame-use",
                    IsEnabled: false,
                    CanEnable: false,
                },
            },

instead of this:

            expected: []*NICCapability{
                &NICCapability{
                    Name:      "auto-negotiation",
                    IsEnabled: true,
                    CanEnable: true,
                },
                &NICCapability{
                    Name:      "pause-frame-use",
                    IsEnabled: false,
                    CanEnable: false,
                },
            },

🤷 I will bow to the formatter script

Jacob Young added 4 commits May 4, 2023 12:52
Create test case for new functions that parse ethtool.
Add Stringer() for NICCapabilities so `fmt.Printf("%+v", NIC)` on NIC
objects will print the data in a NICCapability object, and not just the
pointer ids.

Signed-off-by: Jacob Young <jacoby@nvidia.com>
Updated net_linux.go to use the `util.ParseBool()` utility.

Signed-off-by: Jacob Young <jacoby@nvidia.com>
Moved setNicAttrEthtool() into netDeviceCapabilities()

Split updateNicAttrEthtool() into functions specific for each field that
is being checked.

Signed-off-by: Jacob Young <jacoby@nvidia.com>
Signed-off-by: Jacob Young <jacoby@nvidia.com>
@jak3kaj
Copy link
Contributor Author

jak3kaj commented May 4, 2023

oops, I just fixed the commit that wasn't signed off and rebased with main. This should be ready to merge now.

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.

2 participants