X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVppConfigGenerator.py;h=d6afd1f5c758b30c09e7ec582d98b69b7c3650cf;hb=b2f75ec0f52110c267b90372e657b664417c1f4b;hp=a9c7618c92947dd3f539966136ac485758f5a05b;hpb=807afe3f73ef9f6170e72f922338d0a726028ec6;p=csit.git diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py index a9c7618c92..d6afd1f5c7 100644 --- a/resources/libraries/python/VppConfigGenerator.py +++ b/resources/libraries/python/VppConfigGenerator.py @@ -52,10 +52,20 @@ cpu {{ dpdk {{ socket-mem {socketmemconfig} -{txqueuesconfig} + dev default {{ + {rxqueuesconfig} + {txqueuesconfig} + }} {pciconfig} -{rssconfig} +{nomultiseg} +{enablevhostuser} }} + +ip6 {{ + hash-buckets 2000000 + heap-size 3G +}} + """ # End VPP configuration template. @@ -66,33 +76,37 @@ class VppConfigGenerator(object): def __init__(self): self._nodeconfig = {} - def add_pci_device(self, node, pci_device=None): + def add_pci_all_devices(self, node): + """Add all PCI devices from topology file to startup config + + :param node: DUT node + :type node: dict + :return: nothing + """ + for port in node['interfaces'].keys(): + pci_addr = Topology.get_interface_pci_addr(node, port) + if pci_addr: + self.add_pci_device(node, pci_addr) + + + def add_pci_device(self, node, *pci_devices): """Add PCI device configuration for node. :param node: DUT node. - :param pci_device: PCI device (format 0000:00:00.0 or 00:00.0). - If none given, all PCI devices for this node as per topology will be - added. + :param pci_device: PCI devices (format 0000:00:00.0 or 00:00.0) :type node: dict - :type pci_device: str + :type pci_devices: tuple :return: nothing """ if node['type'] != NodeType.DUT: raise ValueError('Node type is not a DUT') - if pci_device is None: - # No PCI device was given. Add all device from topology. - for port in node['interfaces'].values(): - port_name = port.get('name') - pci_addr = Topology.get_interface_pci_addr(node, port_name) - if pci_addr: - self.add_pci_device(node, pci_addr) - else: - # Specific device was given. - hostname = Topology.get_node_hostname(node) - - pattern = re.compile("^[0-9A-Fa-f]{4}:[0-9A-Fa-f]{2}:" - "[0-9A-Fa-f]{2}\\.[0-9A-Fa-f]$") + # Specific device was given. + hostname = Topology.get_node_hostname(node) + + pattern = re.compile("^[0-9A-Fa-f]{4}:[0-9A-Fa-f]{2}:" + "[0-9A-Fa-f]{2}\\.[0-9A-Fa-f]$") + for pci_device in pci_devices: if not pattern.match(pci_device): raise ValueError('PCI address {} to be added to host {} ' 'is not in valid format xxxx:xx:xx.x'. @@ -163,13 +177,31 @@ class VppConfigGenerator(object): logger.debug('Setting hostname {} Heap Size config to {}'. format(hostname, heapsize_config)) - def add_rss_config(self, node, rss_config): - """Add RSS configuration for node. + def add_rxqueues_config(self, node, rxqueues_config): + """Add Rx Queues configuration for node. + + :param node: DUT node. + :param rxqueues_config: Rxqueues configuration, as a string. + :type node: dict + :type rxqueues_config: str + :return: nothing + """ + if node['type'] != NodeType.DUT: + raise ValueError('Node type is not a DUT') + hostname = Topology.get_node_hostname(node) + if not hostname in self._nodeconfig: + self._nodeconfig[hostname] = {} + if not 'rxqueues_config' in self._nodeconfig[hostname]: + self._nodeconfig[hostname]['rxqueues_config'] = [] + self._nodeconfig[hostname]['rxqueues_config'].append(rxqueues_config) + logger.debug('Setting hostname {} rxqueues config to {}'.\ + format(hostname, rxqueues_config)) + + def add_no_multi_seg_config(self, node): + """Add No Multi Seg configuration for node. :param node: DUT node. - :param rss_config: RSS configuration, as a string. :type node: dict - :type rss_config: str :return: nothing """ if node['type'] != NodeType.DUT: @@ -177,19 +209,18 @@ class VppConfigGenerator(object): hostname = Topology.get_node_hostname(node) if not hostname in self._nodeconfig: self._nodeconfig[hostname] = {} - if not 'rss_config' in self._nodeconfig[hostname]: - self._nodeconfig[hostname]['rss_config'] = [] - self._nodeconfig[hostname]['rss_config'].append(rss_config) - logger.debug('Setting hostname {} RSS config to {}'.\ - format(hostname, rss_config)) + if not 'no_multi_seg_config' in self._nodeconfig[hostname]: + self._nodeconfig[hostname]['no_multi_seg_config'] = [] + self._nodeconfig[hostname]['no_multi_seg_config'].append( + "no-multi-seg") + logger.debug('Setting hostname {} config with {}'.\ + format(hostname, "no-multi-seg")) - def add_max_tx_queues_config(self, node, max_tx_queues_config): - """Add Max TX Queues configuration for node. + def add_enable_vhost_user_config(self, node): + """Add enable-vhost-user configuration for node. :param node: DUT node. - :param max_tx_queues_config: Max TX Queues configuration, as a string. :type node: dict - :type max_tx_queues_config: str :return: nothing """ if node['type'] != NodeType.DUT: @@ -197,12 +228,12 @@ class VppConfigGenerator(object): hostname = Topology.get_node_hostname(node) if not hostname in self._nodeconfig: self._nodeconfig[hostname] = {} - if not 'max_tx_queues_config' in self._nodeconfig[hostname]: - self._nodeconfig[hostname]['max_tx_queues_config'] = [] - self._nodeconfig[hostname]['max_tx_queues_config'].append( - max_tx_queues_config) - logger.debug('Setting hostname {} max_tx_queues config to {}'.\ - format(hostname, max_tx_queues_config)) + if not 'enable_vhost_user' in self._nodeconfig[hostname]: + self._nodeconfig[hostname]['enable_vhost_user'] = [] + self._nodeconfig[hostname]['enable_vhost_user'].append( + "enable-vhost-user") + logger.debug('Setting hostname {} config with {}'.\ + format(hostname, "enable-vhost-user")) def remove_all_pci_devices(self, node): """Remove PCI device configuration from node. @@ -264,8 +295,8 @@ class VppConfigGenerator(object): logger.debug('Clearing Heap Size config for hostname {}.'. format(hostname)) - def remove_rss_config(self, node): - """Remove RSS configuration from node. + def remove_rxqueues_config(self, node): + """Remove Rxqueues configuration from node. :param node: DUT node. :type node: dict @@ -275,12 +306,12 @@ class VppConfigGenerator(object): raise ValueError('Node type is not a DUT') hostname = Topology.get_node_hostname(node) if hostname in self._nodeconfig: - self._nodeconfig[hostname]['rss_config'] = [] - logger.debug('Clearing RSS config for hostname {}.'.\ + self._nodeconfig[hostname]['rxqueues_config'] = [] + logger.debug('Clearing rxqueues config for hostname {}.'.\ format(hostname)) - def remove_max_tx_queues_config(self, node): - """Remove Max TX Queues configuration from node. + def remove_no_multi_seg_config(self, node): + """Remove No Multi Seg configuration from node. :param node: DUT node. :type node: dict @@ -290,8 +321,23 @@ class VppConfigGenerator(object): raise ValueError('Node type is not a DUT') hostname = Topology.get_node_hostname(node) if hostname in self._nodeconfig: - self._nodeconfig[hostname]['max_tx_queues_config'] = [] - logger.debug('Clearing Max TX Queues config for hostname {}.'.\ + self._nodeconfig[hostname]['no_multi_seg_config'] = [] + logger.debug('Clearing No Multi Seg config for hostname {}.'.\ + format(hostname)) + + def remove_enable_vhost_user_config(self, node): + """Remove enable-vhost-user configuration from node. + + :param node: DUT node. + :type node: dict + :return: nothing + """ + if node['type'] != NodeType.DUT: + raise ValueError('Node type is not a DUT') + hostname = Topology.get_node_hostname(node) + if hostname in self._nodeconfig: + self._nodeconfig[hostname]['enable_vhost_user'] = [] + logger.debug('Clearing enable-vhost-user config for hostname {}.'.\ format(hostname)) def apply_config(self, node, waittime=5, retries=12): @@ -316,8 +362,10 @@ class VppConfigGenerator(object): pciconfig = "" socketmemconfig = DEFAULT_SOCKETMEM_CONFIG heapsizeconfig = "" - rssconfig = "" + rxqueuesconfig = "" txqueuesconfig = "" + nomultiseg = "" + enablevhostuser = "" if hostname in self._nodeconfig: cfg = self._nodeconfig[hostname] @@ -334,19 +382,23 @@ class VppConfigGenerator(object): heapsizeconfig = "\nheapsize {}\n".\ format(cfg['heapsize_config']) - if 'rss_config' in cfg: - rssconfig = " " + "\n ".join(cfg['rss_config']) + if 'rxqueues_config' in cfg: + rxqueuesconfig = " " + "\n ".join(cfg['rxqueues_config']) + + if 'no_multi_seg_config' in cfg: + nomultiseg = " " + "\n ".join(cfg['no_multi_seg_config']) - if 'max_tx_queues_config' in cfg: - txqueuesconfig = " " + "\n ".join( - cfg['max_tx_queues_config']) + if 'enable_vhost_user' in cfg: + enablevhostuser = " " + "\n ".join(cfg['enable_vhost_user']) vppconfig = VPP_CONFIG_TEMPLATE.format(cpuconfig=cpuconfig, pciconfig=pciconfig, socketmemconfig=socketmemconfig, heapsizeconfig=heapsizeconfig, - rssconfig=rssconfig, - txqueuesconfig=txqueuesconfig) + rxqueuesconfig=rxqueuesconfig, + txqueuesconfig=txqueuesconfig, + nomultiseg=nomultiseg, + enablevhostuser=enablevhostuser) logger.debug('Writing VPP config to host {}: "{}"'.format(hostname, vppconfig)) @@ -372,9 +424,9 @@ class VppConfigGenerator(object): # Instead of restarting, we'll do separate start and stop # actions. This way we don't care whether VPP was running # to begin with. - ssh.exec_command('sudo initctl stop {}'.format(VPP_SERVICE_NAME)) + ssh.exec_command('sudo service {} stop'.format(VPP_SERVICE_NAME)) (ret, stdout, stderr) = \ - ssh.exec_command('sudo initctl start {}'.format(VPP_SERVICE_NAME)) + ssh.exec_command('sudo service {} start'.format(VPP_SERVICE_NAME)) if ret != 0: logger.debug('Restarting VPP failed on node {}'. format(hostname))