def dump_to_p4_P4Table(self, hlir, program_version=0, config_dir=None): # for read in self.reads: # print 'DBG|DUMPER|P4Table: self.reads:', read match_fields = [read.dump_to_p4(hlir) for read in self.reads] if self.action_spec: print 'DBG|HLIR|frontend|rename action call:', self.action_spec for action in self.action_spec: print ' type:', type(action) actions = [ action.dump_to_p4(hlir, program_version=program_version) for action in self.action_spec ] else: actions = None if self.action_profile: print '============================006 program_version=', program_version action_profile = self.action_profile.dump_to_p4( hlir, program_version=program_version) else: action_profile = None optional_attributes = {} if self.size is not None: optional_attributes["size"] = self.size.dump_to_p4(hlir) # TODO optional_attributes["min_size"] = optional_attributes["size"] optional_attributes["max_size"] = optional_attributes["size"] else: if self.min_size is not None: optional_attributes["min_size"] = self.min_size.dump_to_p4(hlir) else: optional_attributes["min_size"] = None if self.max_size is not None: optional_attributes["max_size"] = self.max_size.dump_to_p4(hlir) else: optional_attributes["max_size"] = None if self.support_timeout is not None: optional_attributes[ "support_timeout"] = self.support_timeout.dump_to_p4(hlir) if self.default_action: optional_attributes["default_action"] = self.default_action.dump_to_p4( hlir) if program_version == TestingVersion: rename_str = self.name + " " + self.name + _ShadowFlag_ + "\n" if config_dir == None: config_dir = "." filename = os.path.join(config_dir, ShadowP4Configure) with open(filename, 'a+') as fp: fp.write(rename_str) print 'LOG|Build SHADOW HLIR|dump to p4 tables|Rename:', self.name, '-->', self.name + _ShadowFlag_ self.name = self.name + _ShadowFlag_ g_table = p4_table(hlir, self.name, filename=self.filename, lineno=self.lineno, match_fields=match_fields, actions=actions, action_profile=action_profile, **optional_attributes) g_table._pragmas = self._pragmas.copy()
def dump_to_p4_P4Table(self, hlir): match_fields = [read.dump_to_p4(hlir) for read in self.reads] if self.action_spec: actions = [action.dump_to_p4(hlir) for action in self.action_spec] else: actions = None if self.action_profile: action_profile = self.action_profile.dump_to_p4(hlir) else: action_profile = None optional_attributes = {} if self.size is not None: optional_attributes["size"] = self.size.dump_to_p4(hlir) # TODO optional_attributes["min_size"] = optional_attributes["size"] optional_attributes["max_size"] = optional_attributes["size"] else: if self.min_size is not None: optional_attributes["min_size"] = self.min_size.dump_to_p4(hlir) else: optional_attributes["min_size"] = None if self.max_size is not None: optional_attributes["max_size"] = self.max_size.dump_to_p4(hlir) else: optional_attributes["max_size"] = None if self.support_timeout is not None: optional_attributes[ "support_timeout"] = self.support_timeout.dump_to_p4(hlir) if self.default_action: optional_attributes["default_action"] = self.default_action.dump_to_p4( hlir) g_table = p4_table(hlir, self.name, filename=self.filename, lineno=self.lineno, match_fields=match_fields, actions=actions, action_profile=action_profile, **optional_attributes) g_table._pragmas = self._pragmas.copy()
def dump_to_p4_P4Table(self, hlir): match_fields = [read.dump_to_p4(hlir) for read in self.reads] if self.action_spec: actions = [action.dump_to_p4(hlir) for action in self.action_spec] else: actions = None if self.action_profile: action_profile = self.action_profile.dump_to_p4(hlir) else: action_profile = None optional_attributes = {} if self.size is not None: optional_attributes["size"] = self.size.dump_to_p4(hlir) # TODO optional_attributes["min_size"] = optional_attributes["size"] optional_attributes["max_size"] = optional_attributes["size"] else: if self.min_size is not None: optional_attributes["min_size"] = self.min_size.dump_to_p4(hlir) else: optional_attributes["min_size"] = None if self.max_size is not None: optional_attributes["max_size"] = self.max_size.dump_to_p4(hlir) else: optional_attributes["max_size"] = None if self.support_timeout is not None: optional_attributes["support_timeout"] = self.support_timeout.dump_to_p4(hlir) g_table = p4_table( hlir, self.name, filename=self.filename, lineno=self.lineno, match_fields=match_fields, actions=actions, action_profile=action_profile, **optional_attributes ) g_table._pragmas = self._pragmas.copy()