Skip to content

Commit

Permalink
GetRepresentorPortFlavour: support PORT_FLAVOUR_PCI_SF
Browse files Browse the repository at this point in the history
Return the proper flavor instead of unknown.

Signed-off-by: Gaetan Rivet <gaetanr@nvidia.com>
  • Loading branch information
grivet committed Jul 29, 2022
1 parent e360783 commit a163df7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions sriovnet_switchdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func GetRepresentorPortFlavour(netdev string) (PortFlavour, error) {
PORT_FLAVOUR_PHYSICAL: physPortRepRegex,
PORT_FLAVOUR_PCI_PF: pfPortRepRegex,
PORT_FLAVOUR_PCI_VF: vfPortRepRegex,
PORT_FLAVOUR_PCI_SF: sfPortRepRegex,
}
for flavour, regex := range typeToRegex {
if regex.MatchString(portName) {
Expand Down
8 changes: 7 additions & 1 deletion sriovnet_switchdev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ func TestGetVfRepresentorPortFlavour(t *testing.T) {
PhysPortName: "pf0sf44",
PhysSwitchID: "c2cfc60003a1420c",
},
{
Name: "eth10",
PhysPortName: "unknown",
PhysSwitchID: "c2cfc60003a1420c",
},
}
teardown := setupRepresentorEnv(t, "", vfReps)
defer teardown()
Expand All @@ -419,7 +424,8 @@ func TestGetVfRepresentorPortFlavour(t *testing.T) {
{netdev: "eth0", expected: PORT_FLAVOUR_PHYSICAL, shouldFail: false},
{netdev: "eth1", expected: PORT_FLAVOUR_PCI_PF, shouldFail: false},
{netdev: "eth2", expected: PORT_FLAVOUR_PCI_VF, shouldFail: false},
{netdev: "eth44", expected: PORT_FLAVOUR_UNKNOWN, shouldFail: false},
{netdev: "eth44", expected: PORT_FLAVOUR_PCI_SF, shouldFail: false},
{netdev: "eth10", expected: PORT_FLAVOUR_UNKNOWN, shouldFail: false},
{netdev: "foobar", expected: PORT_FLAVOUR_UNKNOWN, shouldFail: true},
}

Expand Down

0 comments on commit a163df7

Please sign in to comment.