From d10f2d3631baf4381057bfece8cd491493c94ad0 Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Sun, 17 Dec 2023 18:57:30 +0200 Subject: [PATCH] update mlxutils package Signed-off-by: Sebastian Sch --- pkg/platforms/mock/mock_platforms.go | 64 +++++++++++----------- pkg/plugins/mellanox/mellanox_plugin.go | 14 ++--- pkg/plugins/mock/mock_plugin.go | 34 ++++++------ pkg/plugins/plugin.go | 2 +- pkg/vendors/mellanox/mellanox.go | 32 +++++------ pkg/vendors/mellanox/mock/mock_mellanox.go | 38 ++++++------- 6 files changed, 92 insertions(+), 92 deletions(-) diff --git a/pkg/platforms/mock/mock_platforms.go b/pkg/platforms/mock/mock_platforms.go index a8a1ee1f15..40eb5dc4c1 100644 --- a/pkg/platforms/mock/mock_platforms.go +++ b/pkg/platforms/mock/mock_platforms.go @@ -13,31 +13,31 @@ import ( versioned "github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned" ) -// MockPlatformHelperInterface is a mock of PlatformHelperInterface interface. -type MockPlatformHelperInterface struct { +// MockInterface is a mock of Interface interface. +type MockInterface struct { ctrl *gomock.Controller - recorder *MockPlatformHelperInterfaceMockRecorder + recorder *MockInterfaceMockRecorder } -// MockPlatformHelperInterfaceMockRecorder is the mock recorder for MockPlatformHelperInterface. -type MockPlatformHelperInterfaceMockRecorder struct { - mock *MockPlatformHelperInterface +// MockInterfaceMockRecorder is the mock recorder for MockInterface. +type MockInterfaceMockRecorder struct { + mock *MockInterface } -// NewMockPlatformHelperInterface creates a new mock instance. -func NewMockPlatformHelperInterface(ctrl *gomock.Controller) *MockPlatformHelperInterface { - mock := &MockPlatformHelperInterface{ctrl: ctrl} - mock.recorder = &MockPlatformHelperInterfaceMockRecorder{mock} +// NewMockInterface creates a new mock instance. +func NewMockInterface(ctrl *gomock.Controller) *MockInterface { + mock := &MockInterface{ctrl: ctrl} + mock.recorder = &MockInterfaceMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockPlatformHelperInterface) EXPECT() *MockPlatformHelperInterfaceMockRecorder { +func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { return m.recorder } // CreateOpenstackDevicesInfo mocks base method. -func (m *MockPlatformHelperInterface) CreateOpenstackDevicesInfo() error { +func (m *MockInterface) CreateOpenstackDevicesInfo() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateOpenstackDevicesInfo") ret0, _ := ret[0].(error) @@ -45,25 +45,25 @@ func (m *MockPlatformHelperInterface) CreateOpenstackDevicesInfo() error { } // CreateOpenstackDevicesInfo indicates an expected call of CreateOpenstackDevicesInfo. -func (mr *MockPlatformHelperInterfaceMockRecorder) CreateOpenstackDevicesInfo() *gomock.Call { +func (mr *MockInterfaceMockRecorder) CreateOpenstackDevicesInfo() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOpenstackDevicesInfo", reflect.TypeOf((*MockPlatformHelperInterface)(nil).CreateOpenstackDevicesInfo)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOpenstackDevicesInfo", reflect.TypeOf((*MockInterface)(nil).CreateOpenstackDevicesInfo)) } // CreateOpenstackDevicesInfoFromNodeStatus mocks base method. -func (m *MockPlatformHelperInterface) CreateOpenstackDevicesInfoFromNodeStatus(arg0 *v1.SriovNetworkNodeState) { +func (m *MockInterface) CreateOpenstackDevicesInfoFromNodeStatus(arg0 *v1.SriovNetworkNodeState) { m.ctrl.T.Helper() m.ctrl.Call(m, "CreateOpenstackDevicesInfoFromNodeStatus", arg0) } // CreateOpenstackDevicesInfoFromNodeStatus indicates an expected call of CreateOpenstackDevicesInfoFromNodeStatus. -func (mr *MockPlatformHelperInterfaceMockRecorder) CreateOpenstackDevicesInfoFromNodeStatus(arg0 interface{}) *gomock.Call { +func (mr *MockInterfaceMockRecorder) CreateOpenstackDevicesInfoFromNodeStatus(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOpenstackDevicesInfoFromNodeStatus", reflect.TypeOf((*MockPlatformHelperInterface)(nil).CreateOpenstackDevicesInfoFromNodeStatus), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOpenstackDevicesInfoFromNodeStatus", reflect.TypeOf((*MockInterface)(nil).CreateOpenstackDevicesInfoFromNodeStatus), arg0) } // DiscoverSriovDevicesVirtual mocks base method. -func (m *MockPlatformHelperInterface) DiscoverSriovDevicesVirtual() ([]v1.InterfaceExt, error) { +func (m *MockInterface) DiscoverSriovDevicesVirtual() ([]v1.InterfaceExt, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DiscoverSriovDevicesVirtual") ret0, _ := ret[0].([]v1.InterfaceExt) @@ -72,13 +72,13 @@ func (m *MockPlatformHelperInterface) DiscoverSriovDevicesVirtual() ([]v1.Interf } // DiscoverSriovDevicesVirtual indicates an expected call of DiscoverSriovDevicesVirtual. -func (mr *MockPlatformHelperInterfaceMockRecorder) DiscoverSriovDevicesVirtual() *gomock.Call { +func (mr *MockInterfaceMockRecorder) DiscoverSriovDevicesVirtual() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DiscoverSriovDevicesVirtual", reflect.TypeOf((*MockPlatformHelperInterface)(nil).DiscoverSriovDevicesVirtual)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DiscoverSriovDevicesVirtual", reflect.TypeOf((*MockInterface)(nil).DiscoverSriovDevicesVirtual)) } // GetFlavor mocks base method. -func (m *MockPlatformHelperInterface) GetFlavor() openshift.OpenshiftFlavor { +func (m *MockInterface) GetFlavor() openshift.OpenshiftFlavor { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetFlavor") ret0, _ := ret[0].(openshift.OpenshiftFlavor) @@ -86,13 +86,13 @@ func (m *MockPlatformHelperInterface) GetFlavor() openshift.OpenshiftFlavor { } // GetFlavor indicates an expected call of GetFlavor. -func (mr *MockPlatformHelperInterfaceMockRecorder) GetFlavor() *gomock.Call { +func (mr *MockInterfaceMockRecorder) GetFlavor() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFlavor", reflect.TypeOf((*MockPlatformHelperInterface)(nil).GetFlavor)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFlavor", reflect.TypeOf((*MockInterface)(nil).GetFlavor)) } // GetMcClient mocks base method. -func (m *MockPlatformHelperInterface) GetMcClient() versioned.Interface { +func (m *MockInterface) GetMcClient() versioned.Interface { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMcClient") ret0, _ := ret[0].(versioned.Interface) @@ -100,13 +100,13 @@ func (m *MockPlatformHelperInterface) GetMcClient() versioned.Interface { } // GetMcClient indicates an expected call of GetMcClient. -func (mr *MockPlatformHelperInterfaceMockRecorder) GetMcClient() *gomock.Call { +func (mr *MockInterfaceMockRecorder) GetMcClient() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMcClient", reflect.TypeOf((*MockPlatformHelperInterface)(nil).GetMcClient)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMcClient", reflect.TypeOf((*MockInterface)(nil).GetMcClient)) } // IsHypershift mocks base method. -func (m *MockPlatformHelperInterface) IsHypershift() bool { +func (m *MockInterface) IsHypershift() bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsHypershift") ret0, _ := ret[0].(bool) @@ -114,13 +114,13 @@ func (m *MockPlatformHelperInterface) IsHypershift() bool { } // IsHypershift indicates an expected call of IsHypershift. -func (mr *MockPlatformHelperInterfaceMockRecorder) IsHypershift() *gomock.Call { +func (mr *MockInterfaceMockRecorder) IsHypershift() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsHypershift", reflect.TypeOf((*MockPlatformHelperInterface)(nil).IsHypershift)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsHypershift", reflect.TypeOf((*MockInterface)(nil).IsHypershift)) } // IsOpenshiftCluster mocks base method. -func (m *MockPlatformHelperInterface) IsOpenshiftCluster() bool { +func (m *MockInterface) IsOpenshiftCluster() bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsOpenshiftCluster") ret0, _ := ret[0].(bool) @@ -128,7 +128,7 @@ func (m *MockPlatformHelperInterface) IsOpenshiftCluster() bool { } // IsOpenshiftCluster indicates an expected call of IsOpenshiftCluster. -func (mr *MockPlatformHelperInterfaceMockRecorder) IsOpenshiftCluster() *gomock.Call { +func (mr *MockInterfaceMockRecorder) IsOpenshiftCluster() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOpenshiftCluster", reflect.TypeOf((*MockPlatformHelperInterface)(nil).IsOpenshiftCluster)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOpenshiftCluster", reflect.TypeOf((*MockInterface)(nil).IsOpenshiftCluster)) } diff --git a/pkg/plugins/mellanox/mellanox_plugin.go b/pkg/plugins/mellanox/mellanox_plugin.go index be1fad7509..83137189bc 100644 --- a/pkg/plugins/mellanox/mellanox_plugin.go +++ b/pkg/plugins/mellanox/mellanox_plugin.go @@ -18,7 +18,7 @@ type MellanoxPlugin struct { helpers plugin.HostHelpersInterface } -var attributesToChange map[string]mlx.MLXNic +var attributesToChange map[string]mlx.MlxNic var mellanoxNicsStatus map[string]map[string]sriovnetworkv1.InterfaceExt var mellanoxNicsSpec map[string]sriovnetworkv1.Interface @@ -50,7 +50,7 @@ func (p *MellanoxPlugin) OnNodeStateChange(new *sriovnetworkv1.SriovNetworkNodeS needDrain = false needReboot = false err = nil - attributesToChange = map[string]mlx.MLXNic{} + attributesToChange = map[string]mlx.MlxNic{} mellanoxNicsSpec = map[string]sriovnetworkv1.Interface{} processedNics := map[string]bool{} @@ -95,14 +95,14 @@ func (p *MellanoxPlugin) OnNodeStateChange(new *sriovnetworkv1.SriovNetworkNodeS continue } processedNics[pciPrefix] = true - fwCurrent, fwNext, err := p.helpers.GetMlnxNicFwData(ifaceSpec.PciAddress) + fwCurrent, fwNext, err := p.helpers.GetMlxNicFwData(ifaceSpec.PciAddress) if err != nil { return false, false, err } isDualPort := mlx.IsDualPort(ifaceSpec.PciAddress, mellanoxNicsStatus) // Attributes to change - attrs := &mlx.MLXNic{TotalVfs: -1} + attrs := &mlx.MlxNic{TotalVfs: -1} var changeWithoutReboot bool var totalVfs int @@ -144,13 +144,13 @@ func (p *MellanoxPlugin) OnNodeStateChange(new *sriovnetworkv1.SriovNetworkNodeS continue } - _, fwNext, err := p.helpers.GetMlnxNicFwData(pciAddress) + _, fwNext, err := p.helpers.GetMlxNicFwData(pciAddress) if err != nil { return false, false, err } if fwNext.TotalVfs > 0 || fwNext.EnableSriov { - attributesToChange[pciAddress] = mlx.MLXNic{TotalVfs: 0} + attributesToChange[pciAddress] = mlx.MlxNic{TotalVfs: 0} log.Log.V(2).Info("Changing TotalVfs to 0, doesn't require rebooting", "fwNext.totalVfs", fwNext.TotalVfs) } } @@ -169,5 +169,5 @@ func (p *MellanoxPlugin) Apply() error { return nil } log.Log.Info("mellanox-plugin Apply()") - return p.helpers.MLXConfigFW(attributesToChange) + return p.helpers.MlxConfigFW(attributesToChange) } diff --git a/pkg/plugins/mock/mock_plugin.go b/pkg/plugins/mock/mock_plugin.go index 06cb3e3bc0..daee66f603 100644 --- a/pkg/plugins/mock/mock_plugin.go +++ b/pkg/plugins/mock/mock_plugin.go @@ -12,7 +12,7 @@ import ( ghw "github.com/jaypipes/ghw" v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" host "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host" - mellanox "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" + mlxutils "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" netlink "github.com/vishvananda/netlink" ) @@ -352,10 +352,10 @@ func (mr *MockHostHelpersInterfaceMockRecorder) GetLinkType(arg0 interface{}) *g } // GetMellanoxBlueFieldMode mocks base method. -func (m *MockHostHelpersInterface) GetMellanoxBlueFieldMode(arg0 string) (mellanox.BlueFieldMode, error) { +func (m *MockHostHelpersInterface) GetMellanoxBlueFieldMode(arg0 string) (mlxutils.BlueFieldMode, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMellanoxBlueFieldMode", arg0) - ret0, _ := ret[0].(mellanox.BlueFieldMode) + ret0, _ := ret[0].(mlxutils.BlueFieldMode) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -366,20 +366,20 @@ func (mr *MockHostHelpersInterfaceMockRecorder) GetMellanoxBlueFieldMode(arg0 in return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMellanoxBlueFieldMode", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetMellanoxBlueFieldMode), arg0) } -// GetMlnxNicFwData mocks base method. -func (m *MockHostHelpersInterface) GetMlnxNicFwData(pciAddress string) (*mellanox.MLXNic, *mellanox.MLXNic, error) { +// GetMlxNicFwData mocks base method. +func (m *MockHostHelpersInterface) GetMlxNicFwData(pciAddress string) (*mlxutils.MlxNic, *mlxutils.MlxNic, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetMlnxNicFwData", pciAddress) - ret0, _ := ret[0].(*mellanox.MLXNic) - ret1, _ := ret[1].(*mellanox.MLXNic) + ret := m.ctrl.Call(m, "GetMlxNicFwData", pciAddress) + ret0, _ := ret[0].(*mlxutils.MlxNic) + ret1, _ := ret[1].(*mlxutils.MlxNic) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetMlnxNicFwData indicates an expected call of GetMlnxNicFwData. -func (mr *MockHostHelpersInterfaceMockRecorder) GetMlnxNicFwData(pciAddress interface{}) *gomock.Call { +// GetMlxNicFwData indicates an expected call of GetMlxNicFwData. +func (mr *MockHostHelpersInterfaceMockRecorder) GetMlxNicFwData(pciAddress interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMlnxNicFwData", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetMlnxNicFwData), pciAddress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMlxNicFwData", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetMlxNicFwData), pciAddress) } // GetNetDevLinkSpeed mocks base method. @@ -694,18 +694,18 @@ func (mr *MockHostHelpersInterfaceMockRecorder) LoadPfsStatus(pciAddress interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPfsStatus", reflect.TypeOf((*MockHostHelpersInterface)(nil).LoadPfsStatus), pciAddress) } -// MLXConfigFW mocks base method. -func (m *MockHostHelpersInterface) MLXConfigFW(attributesToChange map[string]mellanox.MLXNic) error { +// MlxConfigFW mocks base method. +func (m *MockHostHelpersInterface) MlxConfigFW(attributesToChange map[string]mlxutils.MlxNic) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MLXConfigFW", attributesToChange) + ret := m.ctrl.Call(m, "MlxConfigFW", attributesToChange) ret0, _ := ret[0].(error) return ret0 } -// MLXConfigFW indicates an expected call of MLXConfigFW. -func (mr *MockHostHelpersInterfaceMockRecorder) MLXConfigFW(attributesToChange interface{}) *gomock.Call { +// MlxConfigFW indicates an expected call of MlxConfigFW. +func (mr *MockHostHelpersInterfaceMockRecorder) MlxConfigFW(attributesToChange interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MLXConfigFW", reflect.TypeOf((*MockHostHelpersInterface)(nil).MLXConfigFW), attributesToChange) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MlxConfigFW", reflect.TypeOf((*MockHostHelpersInterface)(nil).MlxConfigFW), attributesToChange) } // MstConfigReadData mocks base method. diff --git a/pkg/plugins/plugin.go b/pkg/plugins/plugin.go index ac114bb744..a64cb8ddb9 100644 --- a/pkg/plugins/plugin.go +++ b/pkg/plugins/plugin.go @@ -45,7 +45,7 @@ func NewVendorPluginHelpers(utilsHelper utils.UtilsInterface, func NewDefaultVendorPluginHelpers() (*HostHelpers, error) { utilsHelper := utils.NewUtilsHelper() - mlxHelper := mlx.NewMellanoxHelper(utilsHelper) + mlxHelper := mlx.New(utilsHelper) hostManager := host.NewHostManager(utilsHelper) storeManager, err := host.NewStoreManager() if err != nil { diff --git a/pkg/vendors/mellanox/mellanox.go b/pkg/vendors/mellanox/mellanox.go index 16ec8d886c..e5723518a6 100644 --- a/pkg/vendors/mellanox/mellanox.go +++ b/pkg/vendors/mellanox/mellanox.go @@ -1,4 +1,4 @@ -package mellanox +package mlxutils import ( "fmt" @@ -46,7 +46,7 @@ const ( MellanoxVendorID = "15b3" ) -type MLXNic struct { +type MlxNic struct { EnableSriov bool TotalVfs int LinkTypeP1 string @@ -57,29 +57,29 @@ type MLXNic struct { type MellanoxInterface interface { MstConfigReadData(string) (string, string, error) GetMellanoxBlueFieldMode(string) (BlueFieldMode, error) - GetMlnxNicFwData(pciAddress string) (current, next *MLXNic, err error) + GetMlxNicFwData(pciAddress string) (current, next *MlxNic, err error) - MLXConfigFW(attributesToChange map[string]MLXNic) error + MlxConfigFW(attributesToChange map[string]MlxNic) error } -type MellanoxHelper struct { +type mellanoxHelper struct { utils utils.UtilsInterface } -func NewMellanoxHelper(utilsHelper utils.UtilsInterface) MellanoxInterface { - return &MellanoxHelper{ +func New(utilsHelper utils.UtilsInterface) MellanoxInterface { + return &mellanoxHelper{ utils: utilsHelper, } } -func (m *MellanoxHelper) MstConfigReadData(pciAddress string) (string, string, error) { +func (m *mellanoxHelper) MstConfigReadData(pciAddress string) (string, string, error) { log.Log.Info("MstConfigReadData()", "device", pciAddress) args := []string{"-e", "-d", pciAddress, "q"} stdout, stderr, err := m.utils.RunCommand("mstconfig", args...) return stdout, stderr, err } -func (m *MellanoxHelper) GetMellanoxBlueFieldMode(PciAddress string) (BlueFieldMode, error) { +func (m *mellanoxHelper) GetMellanoxBlueFieldMode(PciAddress string) (BlueFieldMode, error) { log.Log.V(2).Info("MellanoxBlueFieldMode(): checking mode for device", "device", PciAddress) stdout, stderr, err := m.MstConfigReadData(PciAddress) if err != nil { @@ -141,7 +141,7 @@ func (m *MellanoxHelper) GetMellanoxBlueFieldMode(PciAddress string) (BlueFieldM return -1, fmt.Errorf("MellanoxBlueFieldMode(): unknown device status for %s", PciAddress) } -func (m *MellanoxHelper) MLXConfigFW(attributesToChange map[string]MLXNic) error { +func (m *mellanoxHelper) MlxConfigFW(attributesToChange map[string]MlxNic) error { log.Log.Info("mellanox-plugin configFW()") for pciAddr, fwArgs := range attributesToChange { cmdArgs := []string{"-d", pciAddr, "-y", "set"} @@ -173,7 +173,7 @@ func (m *MellanoxHelper) MLXConfigFW(attributesToChange map[string]MLXNic) error return nil } -func (m *MellanoxHelper) GetMlnxNicFwData(pciAddress string) (current, next *MLXNic, err error) { +func (m *mellanoxHelper) GetMlxNicFwData(pciAddress string) (current, next *MlxNic, err error) { log.Log.Info("mellanox-plugin getMlnxNicFwData()", "device", pciAddress) attrs := []string{TotalVfs, EnableSriov, LinkTypeP1, LinkTypeP2} @@ -241,7 +241,7 @@ func IsDualPort(pciAddress string, mellanoxNicsStatus map[string]map[string]srio } // handleTotalVfs return required total VFs or max (required VFs for dual port NIC) and needReboot if totalVfs will change -func HandleTotalVfs(fwCurrent, fwNext, attrs *MLXNic, ifaceSpec sriovnetworkv1.Interface, isDualPort bool, mellanoxNicsSpec map[string]sriovnetworkv1.Interface) ( +func HandleTotalVfs(fwCurrent, fwNext, attrs *MlxNic, ifaceSpec sriovnetworkv1.Interface, isDualPort bool, mellanoxNicsSpec map[string]sriovnetworkv1.Interface) ( totalVfs int, needReboot, changeWithoutReboot bool) { totalVfs = ifaceSpec.NumVfs // Check if the other port is changing theGetMlnxNicFwData number of VF @@ -286,7 +286,7 @@ func HandleTotalVfs(fwCurrent, fwNext, attrs *MLXNic, ifaceSpec sriovnetworkv1.I // handleEnableSriov based on totalVfs it decide to disable (totalVfs=0) or enable (totalVfs changed from 0) sriov // and need reboot if enableSriov will change -func HandleEnableSriov(totalVfs int, fwCurrent, fwNext, attrs *MLXNic) (needReboot, changeWithoutReboot bool) { +func HandleEnableSriov(totalVfs int, fwCurrent, fwNext, attrs *MlxNic) (needReboot, changeWithoutReboot bool) { if totalVfs == 0 && fwCurrent.EnableSriov { log.Log.V(2).Info("disabling Sriov, needs reboot") attrs.EnableSriov = false @@ -304,7 +304,7 @@ func HandleEnableSriov(totalVfs int, fwCurrent, fwNext, attrs *MLXNic) (needRebo } // handleLinkType based on existing linkType and requested link -func HandleLinkType(pciPrefix string, fwData, attr *MLXNic, +func HandleLinkType(pciPrefix string, fwData, attr *MlxNic, mellanoxNicsSpec map[string]sriovnetworkv1.Interface, mellanoxNicsStatus map[string]map[string]sriovnetworkv1.InterfaceExt) (bool, error) { needReboot := false @@ -344,9 +344,9 @@ func HandleLinkType(pciPrefix string, fwData, attr *MLXNic, return needReboot, nil } -func mlnxNicFromMap(mstData map[string]string) (*MLXNic, error) { +func mlnxNicFromMap(mstData map[string]string) (*MlxNic, error) { log.Log.Info("mellanox-plugin mlnxNicFromMap()", "data", mstData) - fwData := &MLXNic{} + fwData := &MlxNic{} if strings.Contains(mstData[EnableSriov], "True") { fwData.EnableSriov = true } diff --git a/pkg/vendors/mellanox/mock/mock_mellanox.go b/pkg/vendors/mellanox/mock/mock_mellanox.go index 6786c8b949..78c1d4903c 100644 --- a/pkg/vendors/mellanox/mock/mock_mellanox.go +++ b/pkg/vendors/mellanox/mock/mock_mellanox.go @@ -1,14 +1,14 @@ // Code generated by MockGen. DO NOT EDIT. // Source: mellanox.go -// Package mock_mellanox is a generated GoMock package. -package mock_mellanox +// Package mock_mlxutils is a generated GoMock package. +package mock_mlxutils import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - mellanox "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" + mlxutils "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" ) // MockMellanoxInterface is a mock of MellanoxInterface interface. @@ -35,10 +35,10 @@ func (m *MockMellanoxInterface) EXPECT() *MockMellanoxInterfaceMockRecorder { } // GetMellanoxBlueFieldMode mocks base method. -func (m *MockMellanoxInterface) GetMellanoxBlueFieldMode(arg0 string) (mellanox.BlueFieldMode, error) { +func (m *MockMellanoxInterface) GetMellanoxBlueFieldMode(arg0 string) (mlxutils.BlueFieldMode, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMellanoxBlueFieldMode", arg0) - ret0, _ := ret[0].(mellanox.BlueFieldMode) + ret0, _ := ret[0].(mlxutils.BlueFieldMode) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -49,34 +49,34 @@ func (mr *MockMellanoxInterfaceMockRecorder) GetMellanoxBlueFieldMode(arg0 inter return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMellanoxBlueFieldMode", reflect.TypeOf((*MockMellanoxInterface)(nil).GetMellanoxBlueFieldMode), arg0) } -// GetMlnxNicFwData mocks base method. -func (m *MockMellanoxInterface) GetMlnxNicFwData(pciAddress string) (*mellanox.MLXNic, *mellanox.MLXNic, error) { +// GetMlxNicFwData mocks base method. +func (m *MockMellanoxInterface) GetMlxNicFwData(pciAddress string) (*mlxutils.MlxNic, *mlxutils.MlxNic, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetMlnxNicFwData", pciAddress) - ret0, _ := ret[0].(*mellanox.MLXNic) - ret1, _ := ret[1].(*mellanox.MLXNic) + ret := m.ctrl.Call(m, "GetMlxNicFwData", pciAddress) + ret0, _ := ret[0].(*mlxutils.MlxNic) + ret1, _ := ret[1].(*mlxutils.MlxNic) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetMlnxNicFwData indicates an expected call of GetMlnxNicFwData. -func (mr *MockMellanoxInterfaceMockRecorder) GetMlnxNicFwData(pciAddress interface{}) *gomock.Call { +// GetMlxNicFwData indicates an expected call of GetMlxNicFwData. +func (mr *MockMellanoxInterfaceMockRecorder) GetMlxNicFwData(pciAddress interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMlnxNicFwData", reflect.TypeOf((*MockMellanoxInterface)(nil).GetMlnxNicFwData), pciAddress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMlxNicFwData", reflect.TypeOf((*MockMellanoxInterface)(nil).GetMlxNicFwData), pciAddress) } -// MLXConfigFW mocks base method. -func (m *MockMellanoxInterface) MLXConfigFW(attributesToChange map[string]mellanox.MLXNic) error { +// MlxConfigFW mocks base method. +func (m *MockMellanoxInterface) MlxConfigFW(attributesToChange map[string]mlxutils.MlxNic) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MLXConfigFW", attributesToChange) + ret := m.ctrl.Call(m, "MlxConfigFW", attributesToChange) ret0, _ := ret[0].(error) return ret0 } -// MLXConfigFW indicates an expected call of MLXConfigFW. -func (mr *MockMellanoxInterfaceMockRecorder) MLXConfigFW(attributesToChange interface{}) *gomock.Call { +// MlxConfigFW indicates an expected call of MlxConfigFW. +func (mr *MockMellanoxInterfaceMockRecorder) MlxConfigFW(attributesToChange interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MLXConfigFW", reflect.TypeOf((*MockMellanoxInterface)(nil).MLXConfigFW), attributesToChange) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MlxConfigFW", reflect.TypeOf((*MockMellanoxInterface)(nil).MlxConfigFW), attributesToChange) } // MstConfigReadData mocks base method.