diff --git a/dpugen/confutils.py b/dpugen/confutils.py index 609cb53..1b5ded5 100644 --- a/dpugen/confutils.py +++ b/dpugen/confutils.py @@ -17,6 +17,13 @@ # https://pythonspeed.com/articles/json-memory-streaming/ +import uuid +import hashlib + +def create_uuid_from_string(val: str): + hex_string = hashlib.md5(val.encode("UTF-8")).hexdigest() + return uuid.UUID(hex=hex_string) + def dumps_json(data, indent=2, depth=1): assert depth > 0 space = ' ' * indent diff --git a/dpugen/dash.py b/dpugen/dash.py index 63b6664..07c20f7 100644 --- a/dpugen/dash.py +++ b/dpugen/dash.py @@ -107,7 +107,7 @@ def create_eni_config(dpu_conf, dpu_params, eni_id): eni_id = dpu_id * ENI_COUNT + eni_index eni_params['ENI_COUNT'] = 1 eni_params['ENI_START'] = dpu_params['ENI_START'] + eni_index * conf.params_dict['ENI_STEP'] - eni_params['LOOPBACK'] = str(ipaddress.ip_address(conf.params_dict['LOOPBACK']) + (eni_id % DPUS) * int(ipaddress.ip_address(conf.params_dict['IP_STEP1']))) + eni_params['LOOPBACK'] = dpu_params['LOOPBACK'] eni_params['PAL'] = str(ipaddress.ip_address(dpu_params['PAL']) + eni_index * int(ipaddress.ip_address(conf.params_dict['IP_STEP1']))) eni_params['PAR'] = str(ipaddress.ip_address(dpu_params['PAR']) + eni_index * int(ipaddress.ip_address(conf.params_dict['IP_STEP1']))) eni_params['GATEWAY'] = str(ipaddress.ip_address(dpu_params['GATEWAY']) + eni_index * int(ipaddress.ip_address(conf.params_dict['IP_STEP1']))) @@ -118,12 +118,11 @@ 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' % ((eni_id % DPUS), eni_id)))) + threads.append(multiprocessing.Process(target=create_eni_config, args=(eni_conf, eni_params, 'dpu%d.eni%03d' % (dpu_id, eni_id)))) - for p in threads: - p.start() - - for p in threads: - p.join() + for p in threads: + p.start() + for p in threads: + p.join() print('done', file=sys.stderr) diff --git a/dpugen/dashgen/acl_group.py b/dpugen/dashgen/acl_group.py index e2f7cbf..4c893b5 100644 --- a/dpugen/dashgen/acl_group.py +++ b/dpugen/dashgen/acl_group.py @@ -6,6 +6,7 @@ from dpugen.confbase import ConfBase from dpugen.confutils import common_main +from dpugen.confutils import create_uuid_from_string class AclGroups(ConfBase): @@ -27,6 +28,7 @@ def items(self): yield { 'DASH_ACL_GROUP_TABLE:%d' % table_id: { 'ip_version': 'ipv4', + 'guid': create_uuid_from_string('DASH_ACL_GROUP_TABLE:%d' % table_id) }, 'OP': 'SET' } @@ -38,6 +40,7 @@ def items(self): yield { 'DASH_ACL_GROUP_TABLE:%d' % table_id: { 'ip_version': 'ipv4', + 'guid': create_uuid_from_string('DASH_ACL_GROUP_TABLE:%d' % table_id) }, 'OP': 'SET' } diff --git a/dpugen/dashgen/dash_eni_table.py b/dpugen/dashgen/dash_eni_table.py index 63f0638..1369431 100644 --- a/dpugen/dashgen/dash_eni_table.py +++ b/dpugen/dashgen/dash_eni_table.py @@ -50,10 +50,22 @@ def items(self): 'OP': 'SET' } + self.num_yields += 1 + yield { + 'DASH_QOS_TABLE:qos-%d' % eni: { + 'qos_id': 'qos-%d' % eni, + "bw": 0, + "cps": 0, + "flows": 0 + }, + 'OP': 'SET' + } + self.num_yields += 1 yield { 'DASH_ENI_TABLE:eni-%d' % eni: { 'eni_id': 'eni-%d' % eni, + "qos": 'qos-%d' % eni, 'mac_address': local_mac, 'underlay_ip': vm_underlay_dip, 'admin_state': 'enabled', diff --git a/dpugen/dashgen/dash_vnet_table.py b/dpugen/dashgen/dash_vnet_table.py index 141436e..e7e5599 100644 --- a/dpugen/dashgen/dash_vnet_table.py +++ b/dpugen/dashgen/dash_vnet_table.py @@ -5,6 +5,7 @@ from dpugen.confbase import ConfBase from dpugen.confutils import common_main +from dpugen.confutils import create_uuid_from_string class Vnets(ConfBase): @@ -23,6 +24,7 @@ def items(self): yield { 'DASH_VNET_TABLE:vnet-%d' % r_vni_id: { 'vni': r_vni_id, + 'guid': create_uuid_from_string('DASH_VNET_TABLE:vnet-%d' % r_vni_id) }, 'OP': 'SET' } diff --git a/dpugen/dflt_params.py b/dpugen/dflt_params.py index 5d84820..ac0b282 100644 --- a/dpugen/dflt_params.py +++ b/dpugen/dflt_params.py @@ -5,14 +5,14 @@ 'DC_STEP': '0.0.1.0', # '0.0.1.0' 'LOOPBACK': '221.0.0.1', # '221.0.0.1' - 'PAL': '221.1.0.1', # '221.1.0.1' - 'PAR': '221.2.0.1', # '221.2.0.1' + 'PAL': '221.1.0.0', # '221.1.0.0' + 'PAR': '221.2.0.0', # '221.2.0.0' 'GATEWAY': '222.0.0.1', # '222.0.0.1' - 'DPUS': 8, # 1 + 'DPUS': 8, # 8 'ENI_START': 1, # 1 - 'ENI_COUNT': 256, # 32 + 'ENI_COUNT': 256, # 256 'ENI_STEP': 1, # 1 'ENI_L2R_STEP': 1000, # 1000 diff --git a/dpugen/sai.py b/dpugen/sai.py index 3a4b0be..7d15b2f 100755 --- a/dpugen/sai.py +++ b/dpugen/sai.py @@ -14,6 +14,7 @@ import dpugen.saigen.outbound_ca_to_pa import dpugen.saigen.outbound_routing import dpugen.saigen.pa_validation +import dpugen.saigen.routing_group import dpugen.saigen.vips import dpugen.saigen.vnets @@ -41,6 +42,7 @@ def generate(self): dpugen.saigen.vnets.Vnets(self.params_dict), dpugen.saigen.acl_group.AclGroups(self.params_dict), dpugen.saigen.acl_rule.AclRules(self.params_dict), + dpugen.saigen.routing_group.RoutingGroup(self.params_dict), dpugen.saigen.enis.Enis(self.params_dict), dpugen.saigen.address_maps.Mappings(self.params_dict), dpugen.saigen.inbound_routing.InboundRouting(self.params_dict), diff --git a/dpugen/saigen/enis.py b/dpugen/saigen/enis.py index fa7ddec..addfcbb 100644 --- a/dpugen/saigen/enis.py +++ b/dpugen/saigen/enis.py @@ -32,13 +32,15 @@ def items(self): 'op': 'create', 'type': 'SAI_OBJECT_TYPE_ENI', 'attributes': [ - 'SAI_ENI_ATTR_CPS', '10000', - 'SAI_ENI_ATTR_PPS', '100000', - 'SAI_ENI_ATTR_FLOWS', '100000', + 'SAI_ENI_ATTR_CPS', '0', + 'SAI_ENI_ATTR_PPS', '0', + 'SAI_ENI_ATTR_FLOWS', '0', 'SAI_ENI_ATTR_ADMIN_STATE', 'True', + "SAI_ENI_ATTR_HA_SCOPE_ID", "0", 'SAI_ENI_ATTR_VM_UNDERLAY_DIP', vm_underlay_dip, 'SAI_ENI_ATTR_VM_VNI', f'{eni}', 'SAI_ENI_ATTR_VNET_ID', f'$vnet_#eni{eni}', + 'SAI_ENI_ATTR_ROUTING_GROUP_ID', f'$routinggid_#{eni}', 'SAI_ENI_ATTR_INBOUND_V4_STAGE1_DASH_ACL_GROUP_ID', '0', 'SAI_ENI_ATTR_INBOUND_V4_STAGE2_DASH_ACL_GROUP_ID', '0', 'SAI_ENI_ATTR_INBOUND_V4_STAGE3_DASH_ACL_GROUP_ID', '0', @@ -59,6 +61,8 @@ def items(self): 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE3_DASH_ACL_GROUP_ID', '0', 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID', '0', 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID', '0', + "SAI_ENI_ATTR_V4_METER_POLICY_ID", "0", + "SAI_ENI_ATTR_V6_METER_POLICY_ID", "0", ] } for nsg_index in range(p.ACL_NSG_COUNT * 2): diff --git a/dpugen/saigen/outbound_routing.py b/dpugen/saigen/outbound_routing.py index 0be839f..447b09b 100644 --- a/dpugen/saigen/outbound_routing.py +++ b/dpugen/saigen/outbound_routing.py @@ -124,7 +124,7 @@ def items(self): 'type': 'SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY', 'key': { 'switch_id': '$SWITCH_ID', - 'eni_id': f'$eni_#{eni}', + 'routing_group_id': f'$routinggid_#{eni}', 'destination': f'{ip}/{route["mask"]}' }, 'attributes': [ @@ -141,7 +141,7 @@ def items(self): 'type': 'SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY', 'key': { 'switch_id': '$SWITCH_ID', - 'eni_id': f'$eni_#{eni}', + 'routing_group_id': f'$routinggid_#{eni}', 'destination': f'{ip}/{route["mask"]}' }, 'attributes': [ @@ -163,7 +163,7 @@ def items(self): 'type': 'SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY', 'key': { 'switch_id': '$SWITCH_ID', - 'eni_id': f'$eni_#{eni}', + 'routing_group_id': f'$routinggid_#{eni}', 'destination': f'{remote_ip_prefix}/10' }, 'attributes': [ @@ -179,7 +179,7 @@ def items(self): 'type': 'SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY', 'key': { 'switch_id': '$SWITCH_ID', - 'eni_id': f'$eni_#{eni}', + 'routing_group_id': f'$routinggid_#{eni}', 'destination': f'{remote_ip_prefix}/10' }, 'attributes': [ diff --git a/dpugen/saigen/routing_group.py b/dpugen/saigen/routing_group.py new file mode 100644 index 0000000..9d63150 --- /dev/null +++ b/dpugen/saigen/routing_group.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 +"""SAI generator for ENI""" + +import os +import sys + +from dpugen.confbase import ( + ConfBase, + maca, + socket_inet_ntoa, + struct_pack +) +from dpugen.confutils import common_main + + +class RoutingGroup(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 + + routing_group_data = { + 'name': f'routinggid_#{eni}', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ROUTING_GROUP', + 'attributes': [ + 'SAI_ROUTING_GROUP_ATTR_ADMIN_STATE', 'True', + ] + } + + self.num_yields += 1 + yield routing_group_data + + +if __name__ == '__main__': + conf = RoutingGroup() + common_main(conf)