Esempio n. 1
0
def set_ring(devname, **kwargs):
    '''
    Changes the rx/tx ring parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_ring <devname> [rx=N] [rx_mini=N] [rx_jumbo=N] [tx=N]
    '''

    try:
        ring = ethtool.get_ringparam(devname)
    except IOError:
        log.error('Ring parameters not supported on {0}'.format(devname))
        return 'Not supported'

    changed = False
    for param, value in kwargs.items():
        if param in ethtool_ring_map:
            param = ethtool_ring_map[param]
            if param in ring:
                if ring[param] != value:
                    ring[param] = value
                    changed = True

    try:
        if changed:
            ethtool.set_ringparam(devname, ring)
        return show_ring(devname)
    except IOError:
        log.error('Invalid ring arguments on {0}: {1}'.format(devname, ring))
        return 'Invalid arguments'
Esempio n. 2
0
def set_ringparam(interface, args):
    try:
        ring = ethtool.get_ringparam(interface)
    except IOError:
        printtab("ring parameters NOT supported on %s!" % interface)
        return

    changed = False
    args = [a.lower() for a in args]
    for arg, value in [(args[i], args[i + 1]) for i in range(0, len(args), 2)]:
        if not ethtool_ringparam_map.has_key(arg):
            continue
        try:
            value = int(value)
        except:
            continue
        real_arg = ethtool_ringparam_map[arg]
        if ring[real_arg] != value:
            ring[real_arg] = value
            changed = True

    if not changed:
        return

    ethtool.set_ringparam(interface, ring)
Esempio n. 3
0
def set_ringparam(interface, args):
        try:
                ring = ethtool.get_ringparam(interface)
        except IOError:
                printtab("ring parameters NOT supported on %s!" % interface)
                return

        changed = False
        args = [a.lower() for a in args]
        for arg, value in [ ( args[i], args[i + 1] ) for i in range(0, len(args), 2) ]:
                if not ethtool_ringparam_map.has_key(arg):
                        continue
                try:
                        value = int(value)
                except:
                        continue
                real_arg = ethtool_ringparam_map[arg]
                if ring[real_arg] != value:
                        ring[real_arg] = value
                        changed = True

        if not changed:
                return

        ethtool.set_ringparam(interface, ring)
Esempio n. 4
0
def show_ring(devname):
    '''
    Queries the specified network device for rx/tx ring parameter information

    CLI Example:

    .. code-block:: bash

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

    try:
        ring = ethtool.get_ringparam(devname)
    except IOError:
        log.error(
            'Ring parameters not supported on {0}'.format(
                devname
            )
        )
        return 'Not supported'

    ret = {}
    for key, value in ring.items():
        ret[ethtool_ring_remap[key]] = ring[key]

    return ret
 def test_ring_size(self):
     command = 'lspci -s {0}'.format(self.bus)
     output,error = run_command(command)
     if '[ConnectX' not in output: self.skipTest('This is not ConnectX-5')
         
     ring_param = ethtool.get_ringparam(self.phy_int)
     self.assertEqual(ring_param['rx_pending'], 8192)
     self.assertEqual(ring_param['tx_pending'], 8192)
Esempio n. 6
0
    def test_connectx_5(cls):
        if cls.phy_int == None:
            cls.fail('No interface {}'.format(cls.interface))

        if cls.driver != 'mlx5_core':
            cls.skipTest('This is not Mellanox ConnectX-4 or X-5')

        command = 'lspci -s {0}'.format(cls.bus)
        output, error = run_command(command)

        if '[ConnectX-5' not in output: cls.skipTest('This is not ConnectX-5')

        ring_param = ethtool.get_ringparam(cls.phy_int)
        cls.assertEqual(ring_param['rx_pending'], 8192)
        cls.assertEqual(ring_param['tx_pending'], 8192)
Esempio n. 7
0
def set_ring(devname, **kwargs):
    '''
    Changes the rx/tx ring parameters of the specified network device

    CLI Example:

    .. code-block:: bash

        salt '*' ethtool.set_ring <devname> [ring=N] [rx_mini=N] [rx_jumbo=N] [tx=N]
    '''

    try:
        ring = ethtool.get_ringparam(devname)
    except IOError:
        log.error(
            'Ring parameters not supported on {0}'.format(
                devname
            )
        )
        return 'Not supported'

    changed = False
    for param, value in kwargs.items():
        if param in ethtool_ring_map:
            param = ethtool_ring_map[param]
            if param in ring:
                if ring[param] != value:
                    ring[param] = value
                    changed = True

    try:
        if changed:
            ethtool.set_ringparam(devname, ring)
        return show_ring(devname)
    except IOError:
        log.error(
            'Invalid ring arguments on {0}: {1}'.format(
                devname, ring
            )
        )
        return 'Invalid arguments'
Esempio n. 8
0
def show_ring(interface, args=None):
    printtab("Ring parameters for %s:" % interface)
    try:
        ring = ethtool.get_ringparam(interface)
    except IOError:
        printtab("  NOT supported!")
        return

    printed = []
    for tunable in ethtool_ringparam_msgs:
        if len(tunable) == 1:
            printtab("%s:" % tunable[0])
        else:
            printtab("%s %s" % (tunable[0], ring[tunable[1]]))
            printed.append(tunable[1])

    ringkeys = ring.keys()
    if len(ringkeys) != len(printed):
        print
        for tunable in ringkeys:
            if tunable not in printed:
                printtab("%s %s" % (tunable, ring[tunable]))
Esempio n. 9
0
def show_ring(devname):
    '''
    Queries the specified network device for rx/tx ring parameter information

    CLI Example:

    .. code-block:: bash

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

    try:
        ring = ethtool.get_ringparam(devname)
    except IOError:
        log.error('Ring parameters not supported on {0}'.format(devname))
        return 'Not supported'

    ret = {}
    for key, value in ring.items():
        ret[ethtool_ring_remap[key]] = ring[key]

    return ret
Esempio n. 10
0
def show_ring(interface, args = None):
        printtab("Ring parameters for %s:" % interface)
        try:
                ring = ethtool.get_ringparam(interface)
        except IOError:
                printtab("  NOT supported!")
                return

        printed = []
        for tunable in ethtool_ringparam_msgs:
                if len(tunable) == 1:
                        printtab("%s:" % tunable[0])
                else:
                        printtab("%s %s" % (tunable[0], ring[tunable[1]]))
                        printed.append(tunable[1])

        ringkeys = ring.keys()
        if len(ringkeys) != len(printed):
                print
                for tunable in ringkeys:
                        if tunable not in printed:
                                printtab("%s %s" % (tunable, ring[tunable]))
Esempio n. 11
0
def tune_ring_buf(phy_int):
    print('Tunning ring param for ConnectX-4 and 5')
    ring = ethtool.get_ringparam(phy_int)
    ring['rx_pending'] = 8192
    ring['tx_pending'] = 8192
    ethtool.set_ringparam(phy_int, ring)