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

[switchdev 6/x] Update netlink lib and add helper functions #633

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

ykulazhenkov
Copy link
Collaborator

@ykulazhenkov ykulazhenkov commented Feb 13, 2024

This PR contains following changes:

  • update netlink library to include latest changes
  • change VDPA-related functions implementations to use netlink library instead of govdpa library. This is required support additional configuration options for VDPA devices (e.g. MaxVQP parameter)
  • add GetDevlinkDeviceParam/SetDevlinkDeviceParam functions which will be later used to configure flow steering mode for NICs in switchdev mode.

cc @adrianchiris @SchSeba @zeeke

Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@coveralls
Copy link

coveralls commented Feb 13, 2024

Pull Request Test Coverage Report for Build 8016849082

Details

  • -86 of 257 (66.54%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 34.821%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/host/internal/vdpa/vdpa.go 36 40 90.0%
pkg/host/internal/network/network.go 64 78 82.05%
pkg/host/internal/lib/netlink/netlink.go 0 15 0.0%
pkg/host/mock/mock_host.go 11 32 34.38%
pkg/helper/mock/mock_helper.go 0 32 0.0%
Totals Coverage Status
Change from base Build 8007791540: 0.4%
Covered Lines: 4213
Relevant Lines: 12099

💛 - Coveralls

@ykulazhenkov ykulazhenkov changed the title [switchdev 7/x] Update netlink lib and add helper functions [switchdev 6/x] Update netlink lib and add helper functions Feb 21, 2024
go.mod Outdated Show resolved Hide resolved
pkg/host/internal/lib/netlink/netlink.go Show resolved Hide resolved
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

Copy link
Collaborator

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

Overall looks good , left a few comments.

log.Log.V(2).Info("GetDriverByBusAndDevice(): get driver for device", "bus", bus, "device", device)
driver, err := getDriverByBusAndDevice(bus, device)
if err != nil {
log.Log.V(2).Info("GetDriverByBusAndDevice(): can't read device driver for device", "bus", bus, "device", device)
Copy link
Collaborator

Choose a reason for hiding this comment

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

given its a no on the comment above,
we are going to have roughly the same information logged in this verbosity level by getDriverByBusAndDevice

do we really want this additional logs (here and below)?

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 agree, there is no need for additional logs here.

// device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA
func (k *kernel) GetDriverByBusAndDevice(bus, device string) (string, error) {
log.Log.V(2).Info("GetDriverByBusAndDevice(): get driver for device", "bus", bus, "device", device)
driver, err := getDriverByBusAndDevice(bus, device)
Copy link
Collaborator

Choose a reason for hiding this comment

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

WDYT about just renaming this function and making it part of kernel struct ?

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 extra logging from GetDriverByBusAndDevice. I would prefer to keep getDriverByBusAndDevice as a separate function

@@ -196,3 +200,93 @@ func (n *network) GetNetDevLinkSpeed(ifaceName string) string {

return fmt.Sprintf("%s Mb/s", strings.TrimSpace(string(data)))
}

// GetDeviceParam returns devlink parameter for the device as a string, if the parameter has multiple values
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: GetDevlinkDeviceParam

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@@ -97,6 +97,13 @@ type NetworkInterface interface {
GetNetDevMac(name string) string
// GetNetDevLinkSpeed returns the network interface link speed
GetNetDevLinkSpeed(name string) string
// GetDeviceParam returns devlink parameter for the device as a string, if the parameter has multiple values
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: GetDevlinkDeviceParam

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

return "", err
}
if len(param.Values) == 0 {
funcLog.Error(fmt.Errorf("param %s has no value", paramName),
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to return here ? else code will panic if it tries to access param.Values[0]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, I lost return statement here. Good catch!

pkg/host/internal/network/network.go Show resolved Hide resolved
funcLog.V(2).Info("SetDevlinkDeviceParam(): set device parameter")
param, err := n.netlinkLib.DevlinkGetDeviceParamByName(consts.BusPci, pciAddr, paramName)
if err != nil {
funcLog.Error(err, "SetDevlinkDeviceParam(): can get existing param data")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can -> can't

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

return fmt.Errorf("parameter has unknown value type: %d", param.Type)
}
if err != nil {
err = fmt.Errorf("failed to convert value %s to the required type: %d", value, param.Type)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe use %T and print the type of typedValue ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good idea, done

Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

Signed-off-by: Yury Kulazhenkov <[email protected]>
This required to support additional configuration
options and to remove need to mount
/dev/ folder to the container (govdpa requires it)

Signed-off-by: Yury Kulazhenkov <[email protected]>
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@ykulazhenkov
Copy link
Collaborator Author

@e0ne @adrianchiris I addressed your comments and rebased the PR. Please, take another look. Thx

Copy link
Collaborator

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Member

@zeeke zeeke left a comment

Choose a reason for hiding this comment

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

LGTM

@zeeke zeeke merged commit 0d51338 into k8snetworkplumbingwg:master Feb 26, 2024
12 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.

5 participants