@@ -213,6 +213,15 @@ def get_child_ports(interface, breakout_mode, platform_json_file):
213
213
alias_at_lanes = port_dict [INTF_KEY ][interface ]['alias_at_lanes' ]
214
214
lanes = port_dict [INTF_KEY ][interface ]['lanes' ]
215
215
216
+ """
217
+ Example of match_list for some breakout_mode using regex
218
+ Breakout Mode -------> Match_list
219
+ -----------------------------
220
+ 2x25G(2)+1x50G(2) ---> [('2', '25G', None, '(2)', '2'), ('1', '50G', None, '(2)', '2')]
221
+ 1x50G(2)+2x25G(2) ---> [('1', '50G', None, '(2)', '2'), ('2', '25G', None, '(2)', '2')]
222
+ 1x100G[40G] ---------> [('1', '100G', '[40G]', None, None)]
223
+ 2x50G ---------------> [('2', '50G', None, None, None)]
224
+ """
216
225
# Asymmetric breakout mode
217
226
if re .search ("\+" ,breakout_mode ) is not None :
218
227
breakout_parts = breakout_mode .split ("+" )
@@ -228,11 +237,11 @@ def get_child_ports(interface, breakout_mode, platform_json_file):
228
237
offset = gen_port_config (child_ports , parent_intf_id , index , alias_at_lanes , lanes , k , offset )
229
238
return child_ports
230
239
231
- def parse_platform_json_file (hwsku_json_file , port_config_file , interface_name = None , target_brkout_mode = None ):
240
+ def parse_platform_json_file (hwsku_json_file , platform_json_file ):
232
241
ports = {}
233
242
port_alias_map = {}
234
243
235
- port_dict = readJson (port_config_file )
244
+ port_dict = readJson (platform_json_file )
236
245
hwsku_dict = readJson (hwsku_json_file )
237
246
238
247
if not port_dict :
@@ -246,53 +255,13 @@ def parse_platform_json_file(hwsku_json_file, port_config_file, interface_name=N
246
255
for intf in port_dict [INTF_KEY ]:
247
256
if intf not in hwsku_dict [INTF_KEY ]:
248
257
raise Exception ("{} is not available in hwsku_dict" .format (intf ))
249
- if str (interface_name ) == intf :
250
- brkout_mode = target_brkout_mode
251
- else :
252
- brkout_mode = hwsku_dict [INTF_KEY ][intf ][BRKOUT_MODE ]
253
258
254
- index = port_dict [INTF_KEY ][intf ]['index' ]
255
- alias_at_lanes = port_dict [INTF_KEY ][intf ]['alias_at_lanes' ]
256
- lanes = port_dict [INTF_KEY ][intf ]['lanes' ]
259
+ # take default_brkout_mode from hwsku.json
260
+ brkout_mode = hwsku_dict [INTF_KEY ][intf ][BRKOUT_MODE ]
257
261
258
- # if User does not specify brkout_mode, take default_brkout_mode from hwsku.json
259
- if brkout_mode is None :
260
- brkout_mode = hwsku_dict [INTF_KEY ][intf ][BRKOUT_MODE ]
262
+ child_ports = get_child_ports (intf , brkout_mode , platform_json_file )
263
+ ports .update (child_ports )
261
264
262
- # Get match_list for Asymmetric breakout mode
263
- if re .search ("\+" ,brkout_mode ) is not None :
264
- brkout_parts = brkout_mode .split ("+" )
265
- match_list = [re .match (BRKOUT_PATTERN , i ).groups () for i in brkout_parts ]
266
-
267
- # Get match_list for Symmetric breakout mode
268
- else :
269
- match_list = [re .match (BRKOUT_PATTERN , brkout_mode ).groups ()]
270
-
271
- """
272
- Example of match_list for some breakout_mode using regex
273
- Breakout Mode -------> Match_list
274
- -----------------------------
275
- 2x25G(2)+1x50G(2) ---> [('2', '25G', None, '(2)', '2'), ('1', '50G', None, '(2)', '2')]
276
- 1x50G(2)+2x25G(2) ---> [('1', '50G', None, '(2)', '2'), ('2', '25G', None, '(2)', '2')]
277
- 1x100G[40G] ---------> [('1', '100G', '[40G]', None, None)]
278
- 2x50G ---------------> [('2', '50G', None, None, None)]
279
- """
280
- if match_list is not None :
281
- offset = 0
282
- parent_intf_id = int (re .search ("Ethernet(\d+)" , intf ).group (1 ))
283
-
284
- if interface_name is not None and interface_name == intf :
285
- ports = {}
286
-
287
- for k in match_list :
288
- # k is a tuple in "match_list"
289
- offset = gen_port_config (ports , parent_intf_id , index , alias_at_lanes , lanes , k , offset )
290
- brkout_mode = None
291
-
292
- if interface_name is not None and interface_name == intf :
293
- return ports
294
- else :
295
- raise Exception ("match_list should not be None." )
296
265
if not ports :
297
266
raise Exception ("Ports dictionary is empty" )
298
267
@@ -323,7 +292,7 @@ def parse_breakout_mode(hwsku_json_file):
323
292
if INTF_KEY not in hwsku_dict :
324
293
raise Exception ("INTF_KEY is not present in hwsku_dict" )
325
294
326
- for intf in hwsku_dict :
295
+ for intf in hwsku_dict [ INTF_KEY ] :
327
296
brkout_table [intf ] = {}
328
297
brkout_table [intf ][CUR_BRKOUT_MODE ] = hwsku_dict [INTF_KEY ][intf ][BRKOUT_MODE ]
329
298
return brkout_table
0 commit comments