Skip to content

Commit

Permalink
dash config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mgheorghe committed Oct 9, 2024
1 parent 7b88edb commit 8a7f293
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 12 deletions.
25 changes: 22 additions & 3 deletions dpugen/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
]
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
47 changes: 42 additions & 5 deletions dpugen/dashgen/dash_appliance_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand Down
34 changes: 34 additions & 0 deletions dpugen/dashgen/dash_eni_route_table.py
Original file line number Diff line number Diff line change
@@ -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)
36 changes: 36 additions & 0 deletions dpugen/dashgen/dash_qos_table.py
Original file line number Diff line number Diff line change
@@ -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)
37 changes: 37 additions & 0 deletions dpugen/dashgen/dash_route_group_table.py
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 4 additions & 4 deletions dpugen/dashgen/dash_route_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand All @@ -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
Expand All @@ -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)
},
Expand All @@ -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
Expand Down

0 comments on commit 8a7f293

Please sign in to comment.