Skip to content

Commit

Permalink
Added support for front panel port prefix regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Itamar Talmon committed May 31, 2022
1 parent 573717a commit 92de853
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sonic_platform_base/sonic_sfp/sfputilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from portconfig import get_port_config
from sonic_py_common import device_info
from sonic_py_common.interface import backplane_prefix, inband_prefix, recirc_prefix
from swsscommon.swsscommon import FRONT_PANEL_PORT_PREFIX_REGEX

from sonic_eeprom import eeprom_dts
from .sff8472 import sff8472InterfaceId # Dot module supports both Python 2 and Python 3 using explicit relative import methods
Expand Down Expand Up @@ -510,12 +511,19 @@ def read_porttab_mappings(self, porttabfile, asic_inst=0):
elif "asic_port_name" not in title and len(line.split()) >= 4:
fp_port_index = int(line.split()[3])
else:
fp_port_index = portname.split("Ethernet").pop()
front_panel_prefix = re.match(FRONT_PANEL_PORT_PREFIX_REGEX, portname)
if not front_panel_prefix:
continue
front_panel_prefix = front_panel_prefix.group(1)
fp_port_index = portname.split(front_panel_prefix).pop()
fp_port_index = int(fp_port_index.split("s").pop(0))/4
else: # Parsing logic for older 'portmap.ini' file
(portname, bcm_port) = line.split("=")[1].split(",")[:2]

fp_port_index = portname.split("Ethernet").pop()
front_panel_prefix = re.match(FRONT_PANEL_PORT_PREFIX_REGEX, portname)
if not front_panel_prefix:
continue
front_panel_prefix = front_panel_prefix.group(1)
fp_port_index = portname.split(front_panel_prefix).pop()
fp_port_index = int(fp_port_index.split("s").pop(0))/4

if ((len(self.sfp_ports) > 0) and (fp_port_index not in self.sfp_ports)):
Expand Down

0 comments on commit 92de853

Please sign in to comment.