From bd15712551cb6d18ff7c1eb23c0a918043c6b1c6 Mon Sep 17 00:00:00 2001 From: Mircea Dan Date: Mon, 9 Dec 2024 14:45:00 -0800 Subject: [PATCH] changes --- dpugen/dash.py | 32 ++++++++-- dpugen/dashgen/dash_route_table.py | 72 +++++++++++------------ dpugen/dashgen/dash_vnet_mapping_table.py | 9 +-- dpugen/dflt_params.py | 8 +-- dpugen/saigen/outbound_ca_to_pa.py | 11 ++-- 5 files changed, 77 insertions(+), 55 deletions(-) diff --git a/dpugen/dash.py b/dpugen/dash.py index c3107a2..cfd259d 100644 --- a/dpugen/dash.py +++ b/dpugen/dash.py @@ -5,6 +5,8 @@ import multiprocessing import sys +import multiprocessing.pool as mpool + import dpugen.dashgen.acl_group import dpugen.dashgen.acl_rule import dpugen.dashgen.dash_appliance_table @@ -57,7 +59,7 @@ def generate_eni(self): #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), + #dpugen.dashgen.dash_route_rule_table.InRouteRules(self.params_dict), ] def items(self): @@ -116,7 +118,7 @@ def create_map_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.apl' % dpu_id))) + threads.append(multiprocessing.Process(target=create_asic_config, args=(dpu_conf, dpu_params, 'dpu%d.000apl' % dpu_id))) for eni_index in range(ENI_COUNT): eni_conf = copy.deepcopy(dpu_conf) @@ -136,12 +138,30 @@ def create_map_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)))) + threads.append(multiprocessing.Process(target=create_eni_config, args=(eni_conf, eni_params, 'dpu%d.%03deni' % (dpu_id, eni_id)))) + threads.append(multiprocessing.Process(target=create_map_config, args=(eni_conf, eni_params, 'dpu%d.%03dmap' % (dpu_id, eni_id)))) + + + + # pool = mpool.ThreadPool(10) + # for p in threads: + # pool.apply_async(p) + # for p in threads: + # p.start() + # for p in threads: + # p.join() + + started_threads = [] for p in threads: p.start() - for p in threads: - p.join() + started_threads.append(p) + if len(started_threads) > 10: + for st in started_threads: + st.join() + started_threads = [] + for st in started_threads: + st.join() + print('done', file=sys.stderr) diff --git a/dpugen/dashgen/dash_route_table.py b/dpugen/dashgen/dash_route_table.py index 55f6a13..6c60c1f 100644 --- a/dpugen/dashgen/dash_route_table.py +++ b/dpugen/dashgen/dash_route_table.py @@ -102,46 +102,46 @@ def items(self): raise Exception('ACL_MAPPED_PER_NSG <%d> cannot be < 0' % p.ACL_MAPPED_PER_NSG) added_route_count = 0 - for table_index in range(p.ACL_NSG_COUNT * 2): # Per outbound group (5) - IP_R_START_nsg = IP_R_START_eni + ip_int.IP_STEP_NSG * table_index - for acl_index in range(0, p.ACL_RULES_NSG, 2): # Per even rule (1000 / 2) - - IP_RANGE_START = IP_R_START_nsg + p.IP_PER_ACL_RULE * acl_index - 1 - - routes = self.create_routes(IP_RANGE_START, p.IP_PER_ACL_RULE * 2) - routes = self.make_more_routes(routes, OUTBOUND_ROUTES_PER_ACL * 2) - routes = self.make_more_routes(routes, OUTBOUND_ROUTES_PER_ACL * 2) - - for route in routes: - ip = socket_inet_ntoa(struct_pack('>L', route['ip'])) - if acl_index < p.ACL_MAPPED_PER_NSG: - - # routes that have a mac mapping - self.num_yields += 1 - yield { - 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, ip, route['mask']): { - 'action_type': 'vnet', - 'vnet': 'vnet-%d' % (eni + p.ENI_L2R_STEP) - }, - 'OP': 'SET' - } - else: - # routes that do not have a mac mapping - self.num_yields += 1 - yield { - '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 - }, - 'OP': 'SET' - } - added_route_count += len(routes) + # for table_index in range(p.ACL_NSG_COUNT * 2): # Per outbound group (5) + # IP_R_START_nsg = IP_R_START_eni + ip_int.IP_STEP_NSG * table_index + # for acl_index in range(0, p.ACL_RULES_NSG, 2): # Per even rule (1000 / 2) + + # IP_RANGE_START = IP_R_START_nsg + p.IP_PER_ACL_RULE * acl_index - 1 + + # routes = self.create_routes(IP_RANGE_START, p.IP_PER_ACL_RULE * 2) + # routes = self.make_more_routes(routes, OUTBOUND_ROUTES_PER_ACL * 2) + # routes = self.make_more_routes(routes, OUTBOUND_ROUTES_PER_ACL * 2) + + # for route in routes: + # ip = socket_inet_ntoa(struct_pack('>L', route['ip'])) + # if acl_index < p.ACL_MAPPED_PER_NSG: + + # # routes that have a mac mapping + # self.num_yields += 1 + # yield { + # 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, ip, route['mask']): { + # 'action_type': 'vnet', + # 'vnet': 'vnet-%d' % (eni + p.ENI_L2R_STEP) + # }, + # 'OP': 'SET' + # } + # else: + # # routes that do not have a mac mapping + # self.num_yields += 1 + # yield { + # '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 + # }, + # 'OP': 'SET' + # } + # added_route_count += len(routes) # add a default route if no route was added to current ENI' if added_route_count == 0: remote_ip_prefix = socket_inet_ntoa(struct_pack('>L', ip_int.IP_R_START + eni_index * ip_int.IP_STEP_ENI)) - if p.MAPPED_ACL_PER_NSG > 0: + if p.ACL_MAPPED_PER_NSG > 0: self.num_yields += 1 yield { 'DASH_ROUTE_TABLE:route-group-%d:%s/%d' % (eni, remote_ip_prefix, 10): { diff --git a/dpugen/dashgen/dash_vnet_mapping_table.py b/dpugen/dashgen/dash_vnet_mapping_table.py index 06640f8..2407842 100644 --- a/dpugen/dashgen/dash_vnet_mapping_table.py +++ b/dpugen/dashgen/dash_vnet_mapping_table.py @@ -52,30 +52,31 @@ def items(self): print(f' mapped:eni:{eni}', file=sys.stderr) for nsg_index in range(p.ACL_NSG_COUNT * 2): # Per outbound stage remote_ip_a_nsg = remote_ip_a_eni + nsg_index * ip_int.IP_STEP_NSG - remote_mac_a_nsg = remote_mac_a_eni + nsg_index * ip_int.MAC_STEP_NSG + #remote_mac_a_nsg = remote_mac_a_eni + nsg_index * ip_int.MAC_STEP_NSG # Per half of the rules for acl_index in range(p.ACL_RULES_NSG): remote_ip_a = remote_ip_a_nsg + acl_index * p.IP_PER_ACL_RULE - remote_mac_a = remote_mac_a_nsg + acl_index * p.IP_PER_ACL_RULE + #remote_mac_a = remote_mac_a_nsg + acl_index * p.IP_PER_ACL_RULE if (acl_index % 2) == 0: # Allow if acl_index <= p.ACL_MAPPED_PER_NSG: for i in range(p.IP_PER_ACL_RULE): # Per rule prefix remote_expanded_ip = socket_inet_ntoa(struct_pack('>L', remote_ip_a + i * 2)) - remote_expanded_mac = str(maca(remote_mac_a + i * 2)) + #remote_expanded_mac = str(maca(remote_mac_a + i * 2)) self.num_yields += 1 yield { 'DASH_VNET_MAPPING_TABLE:vnet-%d:%s' % (r_vni_id, remote_expanded_ip): { 'routing_type': 'vnet_encap', 'underlay_ip': vtep_remote, - 'mac_address': remote_expanded_mac, + 'mac_address': str(maca(remote_mac_a_eni)), 'use_dst_vni': 'true' }, 'OP': 'SET' } + remote_mac_a_eni = remote_mac_a_eni + 2 else: pass diff --git a/dpugen/dflt_params.py b/dpugen/dflt_params.py index ac0b282..e5b2141 100644 --- a/dpugen/dflt_params.py +++ b/dpugen/dflt_params.py @@ -16,12 +16,12 @@ 'ENI_STEP': 1, # 1 'ENI_L2R_STEP': 1000, # 1000 - 'VNET_PER_ENI': 1, # 16 TODO: partialy implemented + 'VNET_PER_ENI': 1, # 16 TODO: partially implemented 'ACL_NSG_COUNT': 5, # 5 (per direction per ENI) 'ACL_RULES_NSG': 1000, # 1000 - 'IP_PER_ACL_RULE': 100, # 100 - 'ACL_MAPPED_PER_NSG': 500, # 500, efective is 250 because denny are skiped + 'IP_PER_ACL_RULE': 1, # 100 + 'ACL_MAPPED_PER_NSG': 500, # 500, effective is 250 because denny are skipped 'MAC_L_START': '00:1A:C5:00:00:01', 'MAC_R_START': '00:1B:6E:00:00:01', @@ -39,5 +39,5 @@ 'IP_STEP_ACL': '0.0.1.0', 'IP_STEPE': '0.0.0.2', - 'TOTAL_OUTBOUND_ROUTES': 25600000 # ENI_COUNT * 100K + 'TOTAL_OUTBOUND_ROUTES': 256000 # ENI_COUNT * 100K } diff --git a/dpugen/saigen/outbound_ca_to_pa.py b/dpugen/saigen/outbound_ca_to_pa.py index 2e5ab58..08dc872 100644 --- a/dpugen/saigen/outbound_ca_to_pa.py +++ b/dpugen/saigen/outbound_ca_to_pa.py @@ -36,19 +36,19 @@ def items(self): print(f' mapped:eni:{eni}', file=sys.stderr) for nsg_index in range(p.ACL_NSG_COUNT * 2): # Per outbound stage remote_ip_a_nsg = remote_ip_a_eni + nsg_index * ip_int.IP_STEP_NSG - remote_mac_a_nsg = remote_mac_a_eni + nsg_index * ip_int.MAC_STEP_NSG + #remote_mac_a_nsg = remote_mac_a_eni + nsg_index * ip_int.MAC_STEP_NSG # Per half of the rules for acl_index in range(p.ACL_RULES_NSG): remote_ip_a = remote_ip_a_nsg + acl_index * p.IP_PER_ACL_RULE - remote_mac_a = remote_mac_a_nsg + acl_index * p.IP_PER_ACL_RULE + #remote_mac_a = remote_mac_a_nsg + acl_index * p.IP_PER_ACL_RULE if (acl_index % 2) == 0: # Allow - if acl_index <= p.ACL_MAPPED_PER_NSG: + if acl_index < p.ACL_MAPPED_PER_NSG: for i in range(p.IP_PER_ACL_RULE): # Per rule prefix remote_expanded_ip = socket_inet_ntoa(struct_pack('>L', remote_ip_a + i * 2)) - remote_expanded_mac = str(maca(remote_mac_a + i * 2)) + #remote_expanded_mac = str(maca(remote_mac_a + i * 2)) self.num_yields += 1 yield { @@ -62,10 +62,11 @@ def items(self): }, 'attributes': [ 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP', vtep_remote, - 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC', remote_expanded_mac, + 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC', str(maca(remote_mac_a_eni)), 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI', 'True' ] } + remote_mac_a_eni = remote_mac_a_eni + 2 else: pass