Example #1
0
def show_driver(devname):
    '''
    Queries the specified network device for associated driver information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_driver <devname>
    '''

    try:
        module = ethtool.get_module(devname)
    except IOError:
        log.error('Driver information not implemented on {0}'.format(devname))
        return 'Not implemented'

    try:
        businfo = ethtool.get_businfo(devname)
    except IOError:
        log.error('Bus information no available on {0}'.format(devname))
        return 'Not available'

    ret = {
        'driver': module,
        'bus_info': businfo,
    }

    return ret
 def __init__(self, testname, interface):
     super(TuningTest, self).__init__(testname)
     self.interface = interface
     self.phy_int = get_phy_int(self.interface) 
     if self.phy_int == None: raise Exception("There is no interface {0}".format(interface))
     #self.driver = ethtool.get_module(self.phy_int)
     self.bus = ethtool.get_businfo(self.phy_int)
Example #3
0
 def setUpClass(cls):
     cls.interface = interface
     cls.phy_int = get_phy_int(cls.interface)
     if cls.phy_int == None:
         raise Exception("There is no interface {0}".format(interface))
     cls.driver = ethtool.get_module(cls.phy_int)
     cls.bus = ethtool.get_businfo(cls.phy_int)
Example #4
0
def show_driver(devname):
    """
    Queries the specified network device for associated driver information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_driver <devname>
    """

    try:
        module = ethtool.get_module(devname)
    except IOError:
        log.error("Driver information not implemented on %s", devname)
        return "Not implemented"

    try:
        businfo = ethtool.get_businfo(devname)
    except IOError:
        log.error("Bus information no available on %s", devname)
        return "Not available"

    ret = {
        "driver": module,
        "bus_info": businfo,
    }

    return ret
Example #5
0
def show_driver(interface, args=None):
    try:
        driver = ethtool.get_module(interface)
    except IOError:
        driver = "not implemented"

    try:
        bus = ethtool.get_businfo(interface)
    except IOError:
        bus = "not available"

    printtab("driver: %s" % driver)
    printtab("bus-info: %s" % bus)
Example #6
0
def show_driver(interface, args = None):
        try:
                driver = ethtool.get_module(interface)
        except IOError:
                driver = "not implemented"

        try:
                bus = ethtool.get_businfo(interface)
        except IOError:
                bus = "not available"

        printtab("driver: %s" % driver)
        printtab("bus-info: %s" % bus)
Example #7
0
def get_host_pci_addr(ifname):
	businfo = ethtool.get_businfo(ifname)	
	l = businfo.split(':')
	s = l[2].split('.')
	del l[2]
	l.extend(s)	
	l = map(lambda x:'0x'+x, l)
	addr = {}
	addr['domain'] = l[0]
	addr['bus'] = l[1]
	addr['slot'] = l[2]
	addr['function'] = l[3]
	return addr
Example #8
0
def tune_mellanox(phy_int):
    print('Tunning Mellanox card')
    bus = ethtool.get_businfo(phy_int)
    numa = get_numa(phy_int)
    # print(numa)
    command = 'setpci -s {0} 68.w'.format(bus)
    output, error = run_command(command)

    tempstr = list(output)
    tempstr[0] = '5'
    maxredreq = ''.join(tempstr)

    command = 'setpci -s {0} 68.w={1}'.format(bus, maxredreq)
    output, error = run_command(command)

    if error != '':
        print(error)
Example #9
0
def show_driver(devname):
    '''
    Queries the specified network device for associated driver information

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.show_driver <devname>
    '''

    try:
        module = ethtool.get_module(devname)
    except IOError:
        log.error(
            'Driver information not implemented on {0}'.format(
                devname
            )
        )
        return 'Not implemented'

    try:
        businfo = ethtool.get_businfo(devname)
    except IOError:
        log.error(
            'Bus information no available on {0}'.format(
                devname
            )
        )
        return 'Not available'

    ret = {
        'driver': module,
        'bus_info': businfo,
    }

    return ret
Example #10
0
def tune_mellanox(interface):
    print('Tunning Mellanox card')
    phy_int = get_phy_int(interface)
    bus = ethtool.get_businfo(phy_int)

    command = 'sudo setpci -s {0} 68.w'.format(bus)
    output, error = run_command(command)

    tempstr = list(output)
    tempstr[0] = '5'
    maxredreq = ''.join(tempstr)

    command = 'sudo setpci -s {0} 68.w={1}'.format(bus, maxredreq)
    output, error = run_command(command)

    if error != '':
        print(error)

    command = 'sudo mlnx_tune -p HIGH_THROUGHPUT'
    output, error = run_command(command, ignore_stderr=True)

    if error != '':
        print(error)
    print(output)
Example #11
0
 def bus_info(self):
     try:
         return ethtool.get_businfo(self.name)
     except IOError as e:
         log_exc_traceback()
         return ""
Example #12
0
excluded = {}
debug = []

if debug_out:
    debug.append("EXCLUDES: '%s', '%s', '%s'" %
                 (exclude_names, exclude_module_types, exclude_bus_types))
    debug.append("INCLUDE: '%s', '%s', '%s'" %
                 (include_names, include_module_types, include_bus_types))
    debug.append("IGNORE: '%s', '%s', '%s'" %
                 (ignore_names, ignore_module_types, ignore_bus_types))

for i in ethtool.get_devices():
    o = {"name": i}
    try:
        module = ethtool.get_module(i)
        businfo = ethtool.get_businfo(i)

        # If it matches an ignore pattern then just ignore it.
        if has_match(i, module, businfo, ignore_names, ignore_module_types,
                     ignore_bus_types):
            if debug_out: debug.append("IGNORE '%s' on ignore match" % i)
            ignored[i] = {
                "name": i,
                "module": module,
            }
            continue

        # If no include specifications have been set and the interface is not ignored
        # it needs to be considered for inclusion
        if len(include_names) + len(include_module_types) + len(
                include_bus_types) == 0:
Example #13
0
 def get_bus_from_name(self, name):
     if name:
         return ethtool.get_businfo(name)
     else:
         return ""
 def __init__(self, testname, interface):
     super(CxTest, self).__init__(testname)
     self.interface = interface
     self.phy_int = get_phy_int(self.interface) 
     self.driver = ethtool.get_module(self.phy_int)
     self.bus = ethtool.get_businfo(self.phy_int)
Example #15
0
included = {}
ignored = {}
excluded = {}
debug = []

if debug_out:
    debug.append("EXCLUDES: '%s', '%s', '%s'" % (exclude_names, exclude_module_types, exclude_bus_types))
    debug.append("INCLUDE: '%s', '%s', '%s'" % (include_names, include_module_types, include_bus_types))
    debug.append("IGNORE: '%s', '%s', '%s'" % (ignore_names, ignore_module_types, ignore_bus_types))

for i in ethtool.get_devices():
    o = { "name": i }
    try:
        module = ethtool.get_module(i)
        businfo = ethtool.get_businfo(i)

        # If it matches an ignore pattern then just ignore it.
        if has_match(i, module, businfo, ignore_names, ignore_module_types, ignore_bus_types):
            if debug_out: debug.append("IGNORE '%s' on ignore match" % i)
            ignored[i] = {
                "name": i,
                "module": module,
            }
            continue

        # If no include specifications have been set and the interface is not ignored
        # it needs to be considered for inclusion
        if len(include_names) + len(include_module_types) + len(include_bus_types) == 0:
            # If it matches exclude list then exclude it, else include it
            if has_match(i, module, businfo, exclude_names, exclude_module_types, exclude_bus_types):
Example #16
0
def device_id(if_name):
    devid = ethtool.get_businfo(if_name)
    if devid == '':
        devid = os.path.basename(
            os.readlink("/sys/class/net/" + if_name + "/device"))
    return devid