From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 787CEA0471 for ; Mon, 12 Aug 2019 09:12:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7121A2629; Mon, 12 Aug 2019 09:12:58 +0200 (CEST) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by dpdk.org (Postfix) with ESMTP id DB9CF2629 for ; Mon, 12 Aug 2019 09:12:56 +0200 (CEST) Received: by mail-pg1-f170.google.com with SMTP id t132so49017932pgb.9 for ; Mon, 12 Aug 2019 00:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=f4zVNqtUf7i/YMeobOlhM2G2+J4MGh764egDzFhyVwk=; b=m6Yhh0Cb7h4EaW3xG7Bh5jhL9ysyIc6bp7fcVK0xkuerT3XkwZtOV78GfjQm+LEWFX E2nDNfXiChDfuz6QQKa6grKPyZx7iD2n30+N2C4DVzoIW87lyq9EJsP/UmSjjG+rzN5X t8bEdsjdOt0Ptc5iIou3OTR3Jk9B/PTEAjvRdULgOyicSfTXAphpt3zGg43hICGJ474H jEHz82omWLut/V0oQh54N627GAZ9duU+V704b3HI1dcZI2TNWUVlze0nT28VgGrQduGV kD60jYqt6LDnInYtype6YMFPwVmhRon7bknBfNyC0hDFfI7AEiO3Smnbbm0dzo9iozqV 811g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=f4zVNqtUf7i/YMeobOlhM2G2+J4MGh764egDzFhyVwk=; b=kol+1SnSXx58LPt4vWnUqeiU+yBgLyJ/O+b/ckM96p4wND7FieEoL7Hx+tIWOzsydD FDG/BNxUeSRTWY5CazPK+65zrHZL09atANlETuSYLywLonAN37kslhnq3YMzggF7Geeb G+3PkUw2jjH/M8kLFKbIJtB2jF3wZeE53+FB9qgCHNZy5EAI068KVvj3SUlo4T+qhUVK rV6GnYp9F2YaD8kBs4qqv1sxbsIXdqILrfWu0HLWpQNgEyBs2Jqhth3ZobCF3+bE7ut/ VqTS9W6T140ohTu82RxEzFpTk5iY0tz8ulhxfdOB0/pOnbl8/BVz2fYJh5Gx1OekSzNY pSvA== X-Gm-Message-State: APjAAAXu989cnlNpxn4gSD0HjjMebvy1bjScvDfQO9OSMzP3U3A183Ts QXH4l/iznnU+RjjYfyymi9FKNRVc X-Google-Smtp-Source: APXvYqzZJNEgA8Tk59mH5LN7dUJyc4WAlJcH06cAWmOdGgn4HQ5LSjISnG9yWisHQGvlSv/SuuhIdA== X-Received: by 2002:a17:90a:898e:: with SMTP id v14mr22136724pjn.119.1565593975955; Mon, 12 Aug 2019 00:12:55 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c8c2:de00:8000:cb51:dfcb:76c]) by smtp.gmail.com with ESMTPSA id h9sm94675326pgh.51.2019.08.12.00.12.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 00:12:55 -0700 (PDT) From: Yasufumi Ogawa To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 12 Aug 2019 16:12:40 +0900 Message-Id: <20190812071242.18934-7-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190812071242.18934-1-yasufum.o@gmail.com> References: <20190812071242.18934-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 6/8] cli: add port types for topo command X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" To depict spp_pcap's output file and tap device as a port, add these types to port type list. This update is also to fix wrong coding style. Signed-off-by: Yasufumi Ogawa --- src/cli/commands/topo.py | 66 +++++++++++++++++++++++----------------- src/cli/shell.py | 3 +- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/cli/commands/topo.py b/src/cli/commands/topo.py index bfd92f0..2e1bc3d 100644 --- a/src/cli/commands/topo.py +++ b/src/cli/commands/topo.py @@ -108,9 +108,9 @@ class SppTopo(object): """Output dot script.""" node_attrs = 'node[shape="rectangle", style="filled"];' - node_template = '{}' + self.delim_node + '{}' + node_temp = '{}' + self.delim_node + '{}' - ports, links = self._get_dot_elements(node_template) + ports, links = self._get_dot_elements(node_temp) # Remove duplicated entries. for ptype in spp_common.PORT_TYPES: @@ -120,15 +120,18 @@ class SppTopo(object): output.append("newrank=true;") output.append(node_attrs) + # topo should support spp_pcap's file and tap port + all_port_types = spp_common.PORT_TYPES + [ + self.SPP_PCAP_LABEL, 'tap'] + # Setup node entries - all_port_types = spp_common.PORT_TYPES + [self.SPP_PCAP_LABEL] nodes = {} for ptype in all_port_types: nodes[ptype] = [] for node in ports[ptype]: r_type, r_id = node.split(':') nodes[ptype].append( - node_template.format(r_type, r_id)) + node_temp.format(r_type, r_id)) nodes[ptype] = list(set(nodes[ptype])) for node in nodes[ptype]: label = re.sub(r'{}'.format(self.delim_node), ':', node) @@ -144,7 +147,7 @@ class SppTopo(object): # Decide the bottom, phy or vhost # TODO(yasufum) revise how to decide bottom - rank_style = '{{rank=max; ' + node_template + '}}' + rank_style = '{{rank=max; ' + node_temp + '}}' if len(ports['phy']) > 0: r_type, r_id = ports['phy'][0].split(':') elif len(ports['vhost']) > 0: @@ -406,7 +409,7 @@ class SppTopo(object): pass return True - def _get_dot_elements(self, node_template): + def _get_dot_elements(self, node_temp): """Get entries of nodes and links. To generate dot script, this method returns ports as nodes and links @@ -416,8 +419,10 @@ class SppTopo(object): ports = {} links = [] + # topo should support spp_pcap's file and tap port + all_port_types = spp_common.PORT_TYPES + [self.SPP_PCAP_LABEL, 'tap'] + # Initialize ports - all_port_types = spp_common.PORT_TYPES + [self.SPP_PCAP_LABEL] for ptype in all_port_types: ports[ptype] = [] @@ -434,7 +439,7 @@ class SppTopo(object): # TODO make it to a method if self._is_valid_port(port): r_type = port.split(':')[0] - if r_type in spp_common.PORT_TYPES: + if r_type in all_port_types: ports[r_type].append(port) else: raise ValueError( @@ -446,7 +451,7 @@ class SppTopo(object): port = c['rx_port'][0]['port'] if self._is_valid_port(port): r_type = port.split(':')[0] - if r_type in spp_common.PORT_TYPES: + if r_type in all_port_types: ports[r_type].append(port) else: raise ValueError( @@ -454,7 +459,7 @@ class SppTopo(object): r_type)) ports[self.SPP_PCAP_LABEL].append( '{}:{}'.format(self.SPP_PCAP_LABEL, - sec['client-id'])) + sec['client-id'])) # Get links if proc_t == 'nfv': @@ -467,14 +472,15 @@ class SppTopo(object): "nfv:{}".format(sec["client-id"]), self.SEC_COLORS[sec["client-id"]], l_style) - link_style = node_template + ' {} ' + node_template + '{};' + link_style = node_temp + ' {} ' + node_temp + '{};' if self._is_valid_port(patch['src']): src_type, src_id = patch['src'].split(':') if self._is_valid_port(patch['dst']): dst_type, dst_id = patch['dst'].split(':') - tmp = link_style.format(src_type, src_id, self.LINK_TYPE, + tmp = link_style.format(src_type, src_id, + self.LINK_TYPE, dst_type, dst_id, attrs) links.append(tmp) @@ -489,10 +495,9 @@ class SppTopo(object): sec["client-id"], comp['type'][0]), self.SEC_COLORS[sec["client-id"]], l_style) - link_style = node_template + ' {} ' + \ - node_template + '{};' + link_style = node_temp + ' {} ' + node_temp + '{};' - if comp['type'] == 'forward': # TODO change to forwarder + if comp['type'] == 'forward': rxport = comp['rx_port'][0]['port'] if self._is_valid_port(rxport): src_type, src_id = rxport.split(':') @@ -500,8 +505,9 @@ class SppTopo(object): if self._is_valid_port(txport): dst_type, dst_id = txport.split(':') - tmp = link_style.format(src_type, src_id, self.LINK_TYPE, - dst_type, dst_id, attrs) + tmp = link_style.format(src_type, src_id, + self.LINK_TYPE, + dst_type, dst_id, attrs) links.append(tmp) elif comp['type'] == 'classifier': @@ -512,8 +518,10 @@ class SppTopo(object): if self._is_valid_port(txp['port']): dst_type, dst_id = txp['port'].split(':') - tmp = link_style.format(src_type, src_id, self.LINK_TYPE, - dst_type, dst_id, attrs) + tmp = link_style.format(src_type, src_id, + self.LINK_TYPE, + dst_type, dst_id, + attrs) links.append(tmp) elif comp['type'] == 'merge': # TODO change to merger txport = comp['tx_port'][0]['port'] @@ -523,8 +531,10 @@ class SppTopo(object): if self._is_valid_port(rxp['port']): src_type, src_id = rxp['port'].split(':') - tmp = link_style.format(src_type, src_id, self.LINK_TYPE, - dst_type, dst_id, attrs) + tmp = link_style.format(src_type, src_id, + self.LINK_TYPE, + dst_type, dst_id, + attrs) links.append(tmp) elif proc_t == 'mirror': @@ -537,8 +547,7 @@ class SppTopo(object): "vf:{}".format(sec["client-id"]), self.SEC_COLORS[sec["client-id"]], l_style) - link_style = node_template + ' {} ' + \ - node_template + '{};' + link_style = node_temp + ' {} ' + node_temp + '{};' rxport = comp['rx_port'][0]['port'] if self._is_valid_port(rxport): @@ -547,8 +556,9 @@ class SppTopo(object): if self._is_valid_port(txp['port']): dst_type, dst_id = txp['port'].split(':') - tmp = link_style.format(src_type, src_id, self.LINK_TYPE, - dst_type, dst_id, attrs) + tmp = link_style.format(src_type, src_id, + self.LINK_TYPE, + dst_type, dst_id, attrs) links.append(tmp) elif proc_t == 'pcap': @@ -560,15 +570,15 @@ class SppTopo(object): "pcap:{}".format(sec["client-id"]), self.SEC_COLORS[sec["client-id"]], l_style) - link_style = node_template + ' {} ' + node_template + '{};' + link_style = node_temp + ' {} ' + node_temp + '{};' for c in sec['core']: # TODO consider change to component if c['role'] == 'receive': # TODO change to receiver rxport = c['rx_port'][0]['port'] if self._is_valid_port(rxport): src_type, src_id = rxport.split(':') - dst_type, dst_id = self.SPP_PCAP_LABEL, sec['client-id'] - + dst_type = self.SPP_PCAP_LABEL + dst_id = sec['client-id'] tmp = link_style.format(src_type, src_id, self.LINK_TYPE, dst_type, dst_id, attrs) links.append(tmp) diff --git a/src/cli/shell.py b/src/cli/shell.py index ebea911..925c231 100644 --- a/src/cli/shell.py +++ b/src/cli/shell.py @@ -614,7 +614,8 @@ class Shell(cmd.Cmd, object): if key == 'prompt': self.prompt = self.cli_config['prompt']['val'] elif key == 'topo_size': - self.spp_topo.resize(self.cli_config['topo_size']['val']) + self.spp_topo.resize( + self.cli_config['topo_size']['val']) def help_config(self): """Print help message of config command.""" -- 2.17.1