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'
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)
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)
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)
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)
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'
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]))
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 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]))
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)