@@ -320,8 +320,8 @@ def read_porttab_mappings(cls, porttabfile):
320
320
logical_to_bcm = {}
321
321
logical_to_physical = {}
322
322
physical_to_logical = {}
323
- last_physical_port = 0
324
- last_logical_port = ''
323
+ last_fp_port_index = 0
324
+ last_portname = ''
325
325
first = 1
326
326
port_pos_in_file = 0
327
327
parse_fmt_port_config_ini = False
@@ -348,52 +348,55 @@ def read_porttab_mappings(cls, porttabfile):
348
348
# bcm_port is not explicitly listed in port_config.ini format
349
349
# Currently we assume ports are listed in numerical order according to bcm_port
350
350
# so we use the port's position in the file (zero-based) as bcm_port
351
- logical_port = line .split ()[0 ]
351
+ portname = line .split ()[0 ]
352
352
353
353
bcm_port = str (port_pos_in_file );
354
354
355
- physical_port = logical_port .split ('Ethernet' ).pop ()
356
- physical_port = int (physical_port .split ('s' ).pop (0 ))/ 4
355
+ if len (line .split ()) == 4 :
356
+ fp_port_index = int (line .split ()[3 ])
357
+ else :
358
+ fp_port_index = portname .split ('Ethernet' ).pop ()
359
+ fp_port_index = int (fp_port_index .split ('s' ).pop (0 ))/ 4
357
360
else : # Parsing logic for older 'portmap.ini' file
358
- (logical_port , bcm_port ) = line .split ('=' )[1 ].split (',' )[:2 ]
361
+ (portname , bcm_port ) = line .split ('=' )[1 ].split (',' )[:2 ]
359
362
360
- physical_port = logical_port .split ('Ethernet' ).pop ()
361
- physical_port = int (physical_port .split ('s' ).pop (0 ))/ 4
363
+ fp_port_index = portname .split ('Ethernet' ).pop ()
364
+ fp_port_index = int (fp_port_index .split ('s' ).pop (0 ))/ 4
362
365
363
366
if ((len (cls .sfp_ports ) > 0 ) and
364
- (physical_port not in cls .sfp_ports )):
367
+ (fp_port_index not in cls .sfp_ports )):
365
368
continue
366
369
367
370
if first == 1 :
368
371
# Initialize last_[physical|logical]_port
369
372
# to the first valid port
370
- last_physical_port = physical_port
371
- last_logical_port = logical_port
373
+ last_fp_port_index = fp_port_index
374
+ last_portname = portname
372
375
first = 0
373
376
374
- logical .append (logical_port )
377
+ logical .append (portname )
375
378
376
- logical_to_bcm [logical_port ] = 'xe' + bcm_port
377
- logical_to_physical [logical_port ] = [physical_port ]
378
- if physical_to_logical .get (physical_port ) == None :
379
- physical_to_logical [physical_port ] = [logical_port ]
379
+ logical_to_bcm [portname ] = 'xe' + bcm_port
380
+ logical_to_physical [portname ] = [fp_port_index ]
381
+ if physical_to_logical .get (fp_port_index ) == None :
382
+ physical_to_logical [fp_port_index ] = [portname ]
380
383
else :
381
- physical_to_logical [physical_port ].append (
382
- logical_port )
384
+ physical_to_logical [fp_port_index ].append (
385
+ portname )
383
386
384
- if (physical_port - last_physical_port ) > 1 :
387
+ if (fp_port_index - last_fp_port_index ) > 1 :
385
388
# last port was a gang port
386
- for p in range (last_physical_port + 1 ,
387
- physical_port ):
388
- logical_to_physical [last_logical_port ].append (p )
389
+ for p in range (last_fp_port_index + 1 ,
390
+ fp_port_index ):
391
+ logical_to_physical [last_portname ].append (p )
389
392
if physical_to_logical .get (p ) == None :
390
- physical_to_logical [p ] = [last_logical_port ]
393
+ physical_to_logical [p ] = [last_portname ]
391
394
else :
392
395
physical_to_logical [p ].append (
393
- last_logical_port )
396
+ last_portname )
394
397
395
- last_physical_port = physical_port
396
- last_logical_port = logical_port
398
+ last_fp_port_index = fp_port_index
399
+ last_portname = portname
397
400
398
401
port_pos_in_file += 1
399
402
0 commit comments