def valve_flowdel(self, table_id, match=None, priority=None, out_port=ofp.OFPP_ANY): """Delete matching flows from a table.""" return [ self.valve_flowmod( table_id, match=match, priority=priority, command=ofp.OFPFC_DELETE, out_port=out_port, out_group=ofp.OFPG_ANY), valve_of.barrier()]
def valve_flowreorder(self, input_ofmsgs): """Reorder flows for better OFA performance.""" # Move all deletes to be first, and add one barrier, # while preserving order. Platforms that do parallel delete # will perform better and platforms that don't will have # at most only one barrier to deal with. # TODO: further optimizations may be possible - for example, # reorder adds to be in priority order. delete_ofmsgs = [] nondelete_ofmsgs = [] for ofmsg in input_ofmsgs: if valve_of.is_flowdel(ofmsg): delete_ofmsgs.append(ofmsg) else: nondelete_ofmsgs.append(ofmsg) output_ofmsgs = [] if delete_ofmsgs: output_ofmsgs.extend(delete_ofmsgs) output_ofmsgs.append(valve_of.barrier()) output_ofmsgs.extend(nondelete_ofmsgs) return output_ofmsgs