Moving is_mellanox_interface to common
This will allow us to use it inside sriov_config as well. Change-Id: I910eac9b0c5d20a5875b7e6c3469a6feeb1d62fd
This commit is contained in:
parent
aa4ba26cf1
commit
ca522c25ed
|
@ -26,6 +26,7 @@ import sys
|
|||
|
||||
SYS_CLASS_NET = '/sys/class/net'
|
||||
_LOG_FILE = '/var/log/os-net-config.log'
|
||||
MLNX_VENDOR_ID = "0x15b3"
|
||||
|
||||
|
||||
def configure_logger(log_file=False, verbose=False, debug=False):
|
||||
|
@ -84,3 +85,8 @@ def get_device_id(ifname):
|
|||
return out
|
||||
except IOError:
|
||||
return
|
||||
|
||||
|
||||
def is_mellanox_interface(ifname):
|
||||
vendor_id = get_vendor_id(ifname)
|
||||
return vendor_id == MLNX_VENDOR_ID
|
||||
|
|
|
@ -22,6 +22,7 @@ import os
|
|||
import re
|
||||
|
||||
import os_net_config
|
||||
from os_net_config import common
|
||||
from os_net_config import objects
|
||||
from os_net_config import utils
|
||||
|
||||
|
@ -983,7 +984,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
|
|||
for the interface which is a member of ovs_dpdk_port
|
||||
with NM and DHCP disabled
|
||||
"""
|
||||
if utils.is_mellanox_interface(ifname):
|
||||
if common.is_mellanox_interface(ifname):
|
||||
self.nm_controlled = False
|
||||
self.use_dhcp = False
|
||||
dpdk_if_name = objects.Interface(ifname)
|
||||
|
@ -1019,7 +1020,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
|
|||
"""
|
||||
for dpdk_port in ovs_dpdk_bond.members:
|
||||
ifname = dpdk_port.members[0].name
|
||||
if utils.is_mellanox_interface(ifname):
|
||||
if common.is_mellanox_interface(ifname):
|
||||
self.nm_controlled = False
|
||||
self.use_dhcp = False
|
||||
dpdk_if_name = objects.Interface(ifname)
|
||||
|
|
|
@ -42,7 +42,6 @@ _IFUP_LOCAL_FILE = '/sbin/ifup-local'
|
|||
_RESET_SRIOV_RULES_FILE = '/etc/udev/rules.d/70-tripleo-reset-sriov.rules'
|
||||
_ALLOCATE_VFS_FILE = '/etc/sysconfig/allocate_vfs'
|
||||
_MLNX_DRIVER = "mlx5_core"
|
||||
MLNX_VENDOR_ID = "0x15b3"
|
||||
MLNX_UNBIND_FILE_PATH = "/sys/bus/pci/drivers/mlx5_core/unbind"
|
||||
|
||||
MAX_RETRIES = 10
|
||||
|
@ -300,8 +299,7 @@ def configure_sriov_pf(execution_from_cli=False, restart_openvswitch=False):
|
|||
item['numvfs'])
|
||||
# When configuring vdpa, we need to configure switchdev before
|
||||
# we create the VFs
|
||||
vendor_id = common.get_vendor_id(item['name'])
|
||||
is_mlnx = vendor_id == MLNX_VENDOR_ID
|
||||
is_mlnx = common.is_mellanox_interface(item['name'])
|
||||
# Configure switchdev mode when vdpa
|
||||
if item.get('vdpa') and is_mlnx:
|
||||
configure_switchdev(item['name'])
|
||||
|
|
|
@ -1775,7 +1775,7 @@ OVS_EXTRA="set Interface $DEVICE options:dpdk-devargs=0000:00:09.0"
|
|||
|
||||
def stub_vendor_id_mellanox(ifname):
|
||||
return True
|
||||
self.stub_out('os_net_config.utils.is_mellanox_interface',
|
||||
self.stub_out('os_net_config.common.is_mellanox_interface',
|
||||
stub_vendor_id_mellanox)
|
||||
|
||||
interface = objects.Interface(name='nic1')
|
||||
|
@ -1921,7 +1921,7 @@ OVS_EXTRA="set Interface dpdk0 options:dpdk-devargs=0000:00:08.0 \
|
|||
|
||||
def stub_vendor_id_mellanox(ifname):
|
||||
return True
|
||||
self.stub_out('os_net_config.utils.is_mellanox_interface',
|
||||
self.stub_out('os_net_config.common.is_mellanox_interface',
|
||||
stub_vendor_id_mellanox)
|
||||
|
||||
iface0 = objects.Interface(name='nic1')
|
||||
|
|
|
@ -420,7 +420,7 @@ class TestSriovConfig(base.TestCase):
|
|||
|
||||
"""
|
||||
|
||||
self.setUp_pf_stubs(sriov_config.MLNX_VENDOR_ID)
|
||||
self.setUp_pf_stubs(common.MLNX_VENDOR_ID)
|
||||
|
||||
exp_actions = [
|
||||
'udev_monitor_setup',
|
||||
|
|
|
@ -383,14 +383,6 @@ def translate_ifname_to_pci_address(ifname, noop):
|
|||
return pci_address
|
||||
|
||||
|
||||
def is_mellanox_interface(ifname):
|
||||
MLNX_VENDOR_ID = "0x15b3"
|
||||
vendor_id = common.get_vendor_id(ifname)
|
||||
if vendor_id == MLNX_VENDOR_ID:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_interface_driver(ifname):
|
||||
try:
|
||||
uevent = common.get_dev_path(ifname, 'device/uevent')
|
||||
|
|
Loading…
Reference in New Issue