Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgheorghe committed Dec 9, 2024
1 parent f1d438b commit bd15712
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 55 deletions.
32 changes: 26 additions & 6 deletions dpugen/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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)
72 changes: 36 additions & 36 deletions dpugen/dashgen/dash_route_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): {
Expand Down
9 changes: 5 additions & 4 deletions dpugen/dashgen/dash_vnet_mapping_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions dpugen/dflt_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
}
11 changes: 6 additions & 5 deletions dpugen/saigen/outbound_ca_to_pa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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

Expand Down

0 comments on commit bd15712

Please sign in to comment.