diff --git a/dpugen/dash.py b/dpugen/dash.py index 07c20f7..c3107a2 100644 --- a/dpugen/dash.py +++ b/dpugen/dash.py @@ -10,6 +10,9 @@ import dpugen.dashgen.dash_appliance_table import dpugen.dashgen.dash_eni_table import dpugen.dashgen.dash_route_rule_table +import dpugen.dashgen.dash_route_group_table +import dpugen.dashgen.dash_eni_route_table +import dpugen.dashgen.dash_qos_table import dpugen.dashgen.dash_route_table import dpugen.dashgen.dash_vnet_mapping_table import dpugen.dashgen.dash_vnet_table @@ -36,14 +39,23 @@ def generate_asic(self): dpugen.dashgen.dash_appliance_table.Appliance(self.params_dict) ] + def generate_maps(self): + # Pass top-level params to sub-generators. + self.configs = [ + dpugen.dashgen.dash_vnet_mapping_table.Mappings(self.params_dict), + dpugen.dashgen.dash_eni_route_table.EniRoute(self.params_dict) + ] + def generate_eni(self): # Pass top-level params to sub-generators. self.configs = [ dpugen.dashgen.dash_vnet_table.Vnets(self.params_dict), + dpugen.dashgen.dash_qos_table.Qos(self.params_dict), dpugen.dashgen.dash_eni_table.Enis(self.params_dict), dpugen.dashgen.acl_group.AclGroups(self.params_dict), - dpugen.dashgen.acl_rule.AclRules(self.params_dict), - dpugen.dashgen.dash_vnet_mapping_table.Mappings(self.params_dict), + #dpugen.dashgen.acl_rule.AclRules(self.params_dict), + #dpugen.dashgen.dash_vnet_mapping_table.Mappings(self.params_dict), + dpugen.dashgen.dash_route_group_table.RouteGroup(self.params_dict), dpugen.dashgen.dash_route_table.OutRouteRules(self.params_dict), dpugen.dashgen.dash_route_rule_table.InRouteRules(self.params_dict), ] @@ -66,6 +78,12 @@ def create_eni_config(dpu_conf, dpu_params, eni_id): dpu_conf.generate_eni() common_output(dpu_conf, eni_id) +def create_map_config(dpu_conf, dpu_params, eni_id): + common_parse_args(dpu_conf) + dpu_conf.merge_params(dpu_params) + dpu_conf.generate_maps() + common_output(dpu_conf, eni_id) + if __name__ == '__main__': print('generating config', file=sys.stderr) @@ -98,7 +116,7 @@ def create_eni_config(dpu_conf, dpu_params, eni_id): dpu_params['TOTAL_OUTBOUND_ROUTES'] = conf.params_dict['TOTAL_OUTBOUND_ROUTES'] // DPUS - threads.append(multiprocessing.Process(target=create_asic_config, args=(dpu_conf, dpu_params, 'dpu%d' % dpu_id))) + threads.append(multiprocessing.Process(target=create_asic_config, args=(dpu_conf, dpu_params, 'dpu%d.apl' % dpu_id))) for eni_index in range(ENI_COUNT): eni_conf = copy.deepcopy(dpu_conf) @@ -119,6 +137,7 @@ def create_eni_config(dpu_conf, dpu_params, eni_id): eni_params['TOTAL_OUTBOUND_ROUTES'] = dpu_params['TOTAL_OUTBOUND_ROUTES'] // ENI_COUNT threads.append(multiprocessing.Process(target=create_eni_config, args=(eni_conf, eni_params, 'dpu%d.eni%03d' % (dpu_id, eni_id)))) + threads.append(multiprocessing.Process(target=create_map_config, args=(eni_conf, eni_params, 'dpu%d.map%03d' % (dpu_id, eni_id)))) for p in threads: p.start() diff --git a/dpugen/dashgen/dash_appliance_table.py b/dpugen/dashgen/dash_appliance_table.py index 4b7b31a..0075be4 100644 --- a/dpugen/dashgen/dash_appliance_table.py +++ b/dpugen/dashgen/dash_appliance_table.py @@ -27,11 +27,48 @@ def items(self): # } self.num_yields += 1 yield { - 'DASH_APPLIANCE_TABLE:appliance-%d' % p.ENI_START: { - 'sip': f'{p.LOOPBACK}', - 'vm_vni': f'{p.ENI_START}' - }, - 'OP': 'SET' + 'DASH_APPLIANCE_TABLE:appliance-%d' % p.ENI_START: { + 'sip': f'{p.LOOPBACK}', + 'vm_vni': f'{p.ENI_START}' + }, + 'OP': 'SET' + } + yield { + "DASH_ROUTING_TYPE_TABLE:vnet": { + "action_name": 'action-%d' % p.ENI_START, + "action_type": "maprouting" + }, + "OP": "SET" + } + yield { + "DASH_ROUTING_TYPE_TABLE:vnet_direct": { + "action_name": 'action-%d' % p.ENI_START, + "action_type": "maprouting" + }, + "OP": "SET" + } + yield { + "DASH_ROUTING_TYPE_TABLE:vnet_encap": { + "action_name": 'action-%d' % p.ENI_START, + "action_type": "staticencap", + "encap_type": "vxlan" + }, + "OP": "SET" + } + yield { + "DASH_ROUTING_TYPE_TABLE:privatelink": [ + { + "action_name": 'action-%d' % p.ENI_START, + "action_type": "4to6" + }, + { + "action_name": 'action-%d' % (p.ENI_START + 1), + "action_type": "staticencap", + "encap_type": "nvgre", + "vni":"%d" % (500 + p.ENI_START) + } + ], + "OP": "SET" } diff --git a/dpugen/dashgen/dash_eni_route_table.py b/dpugen/dashgen/dash_eni_route_table.py new file mode 100644 index 0000000..04e0404 --- /dev/null +++ b/dpugen/dashgen/dash_eni_route_table.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 +"""DASH generator for ENI ROUTE""" + +import os +import sys + +from dpugen.confbase import ConfBase +from dpugen.confutils import common_main + + +class EniRoute(ConfBase): + + def __init__(self, params={}): + super().__init__(params) + self.num_yields = 0 + + def items(self): + print(' Generating %s ...' % os.path.basename(__file__), file=sys.stderr) + p = self.params + ip_int = self.cooked_params + + for eni_index, eni in enumerate(range(p.ENI_START, p.ENI_START + p.ENI_COUNT * p.ENI_STEP, p.ENI_STEP)): # Per ENI + self.num_yields += 1 + yield { + 'DASH_ENI_ROUTE_TABLE:eni-%d' % eni: { + "group_id": 'route-group-%d' % eni + }, + "OP": "SET" + } + + +if __name__ == '__main__': + conf = EniRoute() + common_main(conf) diff --git a/dpugen/dashgen/dash_qos_table.py b/dpugen/dashgen/dash_qos_table.py new file mode 100644 index 0000000..fa67c89 --- /dev/null +++ b/dpugen/dashgen/dash_qos_table.py @@ -0,0 +1,36 @@ +#!/usr/bin/python3 +"""DASH generator for QOS""" + +import os +import sys + +from dpugen.confbase import ConfBase +from dpugen.confutils import common_main + + +class Qos(ConfBase): + + def __init__(self, params={}): + super().__init__(params) + self.num_yields = 0 + + def items(self): + print(' Generating %s ...' % os.path.basename(__file__), file=sys.stderr) + p = self.params + ip_int = self.cooked_params + + for eni_index, eni in enumerate(range(p.ENI_START, p.ENI_START + p.ENI_COUNT * p.ENI_STEP, p.ENI_STEP)): # Per ENI + self.num_yields += 1 + yield { + 'DASH_QOS_TABLE:qos-%d' % eni: { + 'qos_id': 'qos-%d' % eni, + "bw": 0, + "cps": 0, + "flows": 0 + }, + 'OP': 'SET' + } + +if __name__ == '__main__': + conf = Qos() + common_main(conf) diff --git a/dpugen/dashgen/dash_route_group_table.py b/dpugen/dashgen/dash_route_group_table.py new file mode 100644 index 0000000..d2b8149 --- /dev/null +++ b/dpugen/dashgen/dash_route_group_table.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +"""DASH generator for ROUTE GROUP""" + +import os +import sys + +from dpugen.confbase import ConfBase +from dpugen.confutils import common_main +from dpugen.confutils import create_uuid_from_string + + +class RouteGroup(ConfBase): + + def __init__(self, params={}): + super().__init__(params) + self.num_yields = 0 + + def items(self): + print(' Generating %s ...' % os.path.basename(__file__), file=sys.stderr) + p = self.params + ip_int = self.cooked_params + + for eni_index, eni in enumerate(range(p.ENI_START, p.ENI_START + p.ENI_COUNT * p.ENI_STEP, p.ENI_STEP)): # Per ENI + route_group_name = 'route-group-%d' % eni + self.num_yields += 1 + yield { + "DASH_ROUTE_GROUP_TABLE:%s" % route_group_name : { + "guid": create_uuid_from_string(route_group_name), + "version":"1" + }, + "OP": "SET" + } + + +if __name__ == '__main__': + conf = RouteGroup() + common_main(conf) diff --git a/dpugen/dashgen/dash_route_table.py b/dpugen/dashgen/dash_route_table.py index 356abb5..55f6a13 100644 --- a/dpugen/dashgen/dash_route_table.py +++ b/dpugen/dashgen/dash_route_table.py @@ -119,7 +119,7 @@ def items(self): # routes that have a mac mapping self.num_yields += 1 yield { - 'DASH_ROUTE_TABLE:eni-%d:%s/%d' % (eni, ip, route['mask']): { + 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, ip, route['mask']): { 'action_type': 'vnet', 'vnet': 'vnet-%d' % (eni + p.ENI_L2R_STEP) }, @@ -129,7 +129,7 @@ def items(self): # routes that do not have a mac mapping self.num_yields += 1 yield { - 'DASH_ROUTE_TABLE:eni-%d:%s/%d' % (eni, ip, route['mask']): { + 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, ip, route['mask']): { 'action_type': 'vnet_direct', 'vnet': 'vnet-%d' % (eni + p.ENI_L2R_STEP), 'overlay_ip': gateway_ip @@ -144,7 +144,7 @@ def items(self): if p.MAPPED_ACL_PER_NSG > 0: self.num_yields += 1 yield { - 'DASH_ROUTE_TABLE:eni-%d:%s/%d' % (eni, remote_ip_prefix, 10): { + 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, remote_ip_prefix, 10): { 'action_type': 'vnet', 'vnet': 'vnet-%d' % (eni + p.ENI_L2R_STEP) }, @@ -154,7 +154,7 @@ def items(self): elif p.ACL_MAPPED_PER_NSG == 0: self.num_yields += 1 yield { - 'DASH_ROUTE_TABLE:eni-%d:%s/%d' % (eni, remote_ip_prefix, 10): { + 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, remote_ip_prefix, 10): { 'action_type': 'vnet_direct', 'vnet': 'vnet-%d' % (eni + p.ENI_L2R_STEP), 'overlay_ip': gateway_ip