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

Intel switchdev #757

Merged
merged 2 commits into from
Sep 17, 2024
Merged

Intel switchdev #757

merged 2 commits into from
Sep 17, 2024

Conversation

zeeke
Copy link
Member

@zeeke zeeke commented Aug 20, 2024

Ice driver supports creating VFs after the eSwitcMode is
set to switchdev. This is different than the preferred way
for mlx5 driver.

Add specific functions to configure eSwitchMode and SriovNumVFs
for each driver.

Add a basic test to loop over all available
devices and test if setting eSwitchMode: switchdev works.

Copy link

Thanks for your PR,
To run vendors CIs, Maintainers can 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, Maintainers can 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.

@zeeke zeeke force-pushed the intel-switchdev branch 4 times, most recently from 44b682b to 9486f37 Compare August 20, 2024 17:00
@coveralls
Copy link

coveralls commented Aug 20, 2024

Pull Request Test Coverage Report for Build 10612389872

Details

  • 32 of 56 (57.14%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 45.055%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/host/internal/sriov/sriov.go 32 56 57.14%
Totals Coverage Status
Change from base Build 10594418576: 0.03%
Covered Lines: 6628
Relevant Lines: 14711

💛 - Coveralls

ykulazhenkov
ykulazhenkov previously approved these changes Aug 22, 2024
Copy link
Collaborator

@ykulazhenkov ykulazhenkov left a comment

Choose a reason for hiding this comment

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

LGTM

@Eoghan1232
Copy link
Collaborator

I will do a test of this

@Eoghan1232
Copy link
Collaborator

worked like a charm @zeeke ;)

let me give the PR a review now then we should be good to merge

Copy link
Collaborator

@Eoghan1232 Eoghan1232 left a comment

Choose a reason for hiding this comment

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

Changes LGTM!

once this is merged, we should also update the support HW list.
I will do this

log.Log.Error(err, "setEswitchMode(): failed to set mode", "device", pciAddr, "mode", eswitchMode)
return err

type setEswitchModeAndNumVFsFn func(string, string, int) error
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 we move this one outside the function?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, moving. though that type is not supposed to be used out of this function


type setEswitchModeAndNumVFsFn func(string, string, int) error

var setEswitchModeAndNumVFsByDriverName map[string]setEswitchModeAndNumVFsFn = map[string]setEswitchModeAndNumVFsFn{
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 we do something like

setEswitchModeAndNumVFsByDriverName map[string]setEswitchModeAndNumVFsFn := map[string]setEswitchModeAndNumVFsFn{...}

pkg/host/internal/sriov/sriov.go Show resolved Hide resolved
pkg/host/internal/sriov/sriov.go Show resolved Hide resolved
}

func (s *sriov) setEswitchModeAndNumVFs(pciAddr string, desiredEswitchMode string, numVFs int) error {
log.Log.V(2).Info("setEswitchModeAndNumVFs(): configure VFs for device",
func (s *sriov) setEswitchModeAndNumVFsMlx(pciAddr string, desiredEswitchMode string, numVFs int) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add a function comment to explain the process of how we configure switchDev virtual functions for this case

Copy link
Collaborator

@adrianchiris adrianchiris Aug 28, 2024

Choose a reason for hiding this comment

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

nit: between b. and c. we also unbind all VFs on PF.
can you add this to the comment ?

note: rebind happens after part of configSriovVFDevices

also what about configureHWOptionsForSwitchdev ? is it the same for intel ice ?

if we need to split that as well, maybe its worth moving switchdev related things to switchdev to switchdev pkg under host folder to avoid bloating sriov pkg.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding the comment about "driver unbinding".

Regarding configureHWOptionsForSwitchdev, current implementation is about setting flow_steering_mode=smfs, which is Mellanox only (IIUC).

Ice driver doesn't need this step [1] . @Eoghan1232 Can you confirm that?

[1] https://edc.intel.com/content/www/us/en/design/products/ethernet/appnote-e810-eswitch-switchdev-mode-config-guide/script-a-switchdev-mode-with-linux-bridge-configuration/

switchdev and sriov general configurations are tightly coupled. I don't know if moving the switchdev part in a specific package simplifies the code

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 we need to unbind driver, since we need to reset back to 0 vf's anyways

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it. Then better move the unbindAllVFsOnPF(...) call outside of setEswitchMode(...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Regarding configureHWOptionsForSwitchdev, current implementation is about setting flow_steering_mode=smfs, which is Mellanox only (IIUC).

this also enables hw-tc-offload via ethtool.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding configureHWOptionsForSwitchdev, current implementation is about setting flow_steering_mode=smfs, which is Mellanox only (IIUC).

this also enables hw-tc-offload via ethtool.

right! I miss that. I checked and it should not be a problem for the ice driver:

from a local test:

2024-08-29T08:21:49.27421628Z   LEVEL(-2)       sriov/sriov.go:365      EnableHwTcOffload(): enable offloading  {"device": "eno12409"}
2024-08-29T08:21:49.274526639Z  LEVEL(-2)       sriov/sriov.go:365      EnableHwTcOffload(): already enabled    {"device": "eno12409"}

and flow_steering_mode setting is guarded: if it's not supported, it doesn't hurt.

pkg/host/internal/sriov/sriov.go Show resolved Hide resolved

BeforeAll(func() {
if cluster.VirtualCluster() {
Skip("IGB driver does not support VF statistics")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: please update the skip message here :)


By(fmt.Sprintf("Testing on node %s, %d devices found", testNode, len(interfaces)))

mainDevice := findMainSriovDevice(getConfigDaemonPod(testNode), interfaces)
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use findUnusedSriovDevices to have the list of non main device :)

Copy link
Member Author

Choose a reason for hiding this comment

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

cool! thnks

@zeeke zeeke force-pushed the intel-switchdev branch 3 times, most recently from bbad045 to ea50542 Compare August 28, 2024 09:56
@adrianchiris
Copy link
Collaborator

Please hold off with merging this one id like to go over this pr by end of week

@@ -1029,6 +1047,40 @@ func (s *sriov) setEswitchModeAndNumVFs(pciAddr string, desiredEswitchMode strin
return nil
}

// setEswitchModeAndNumVFsIce configures PF eSwitch and sriov_numvfs in the following order:
// a. set eSwitchMode to `switchdev` if requested
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to reset vf's to 0 before setting switchdev mode, is this handled?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I'll fix it.
sriov_numvfs needs to be set to 0 every time we change between eSwitchMode, right?
Both legacy -> switchdev and switchdev -> legacy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe so, otherwise driver will throw an error I believe.
I can double check this tomorrow to confirm

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can see in some docs that we must have 0 VF's before switching to switchdev mode.

@ykulazhenkov ykulazhenkov self-requested a review August 28, 2024 10:16
@ykulazhenkov ykulazhenkov dismissed their stale review August 28, 2024 10:18

some changes were pushed to the PR, need to take another look on it

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 lgtm, left one small comment

Add a basic test to loop over all available
devices and test if setting `eSwitchMode: switchdev` works.

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
@zeeke zeeke force-pushed the intel-switchdev branch 2 times, most recently from a6508fe to 06d6c52 Compare August 29, 2024 08:33
Ice driver supports creating VFs after the eSwitcMode is
set to switchdev. This is different than the preferred way
for `mlx5` driver.

Add specific functions to configure eSwitchMode and SriovNumVFs
for each driver.

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

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

LGTM

nice work!

@zeeke
Copy link
Member Author

zeeke commented Sep 17, 2024

Got approval from multiple sides, merging.

@zeeke zeeke merged commit e812d35 into k8snetworkplumbingwg:master Sep 17, 2024
13 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.

7 participants