Skip to content

Commit

Permalink
refactor bcm attribute checker (#1974)
Browse files Browse the repository at this point in the history
* refactor bcm attribute checker

* exclude phy_84752 and phy_84328

Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan committed Apr 19, 2019
1 parent 04debfa commit 35e8329
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
43 changes: 19 additions & 24 deletions src/sonic-device-data/tests/config_checker
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,9 @@ def usage():
sys.exit(1)

def check_property(p):

if p in permitted_properties:
return True
# Try to remove trailing .<digits>
if re.sub(r".\d+$", "", p) in permitted_properties:
return True
# Try to remove trailing _<digits>.<digits>
if re.sub(r"_\d+.\d+$", "", p) in permitted_properties:
return True
# Try to remove trailing _hg.<digits>
if re.sub(r"_hg.0$", "", p) in permitted_properties:
return True
# Try to remove trailing _[cx]e<digits>
if re.sub(r"_[cx]e\d*$", "", p) in permitted_properties:
return True
# Try to remove trailing _lane<digit>_<digits>
if re.sub(r"_lane\d_\d+$", "", p) in permitted_properties:
return True
# Try to remove trailing _lane<digit>_<digits>.<digits>
if re.sub(r"_lane\d_\d+.\d+$", "", p) in permitted_properties:
return True
# Try to remove trailing _lane<digit>_[cx]e<digits>
if re.sub(r"_lane\d_[cx]e\d+$", "", p) in permitted_properties:
return True
return False

def check_file(file_name):
Expand All @@ -45,12 +25,27 @@ def check_file(file_name):
lineno = lineno + 1
# Check both commented and uncommented lines
line = line.strip().lstrip('#').strip().lower()
# Check if = in the line
if line.find("=") == -1:
continue
p = line.split("=", 1)[0]
# Remove trailing "{<number>.<number>}"
p = re.sub('{[0-9]+\.[0-9]+}', '', p)
# Check if = in the line

# Remove trailing unit ".<number>$"
p = re.sub(r"\.[0-9]+$", '', p)
# Remove trailing port name
p = re.sub(r"_[cxg]e(\d+)?$", '', p)
# Remove trailing port name example
p = re.sub(r"_<port>$", '', p)
# Remove trailing port number
if p != "phy_84752" and p != "phy_84328":
p = re.sub(r"_(port)?\d+$", '', p)
# Remove trailing higig port
p = re.sub(r"_hg$", '', p)
# Remove trailing lane number
p = re.sub(r"_lane\d+$", '', p)
# Remove trailing "{<number>.<number>}$"
p = re.sub(r"{[0-9]+\.[0-9]+}$", '', p)

if not check_property(p):
file_ok = False
print("[line %d] Error: %s is not permitted" % (lineno, p))
Expand Down
17 changes: 12 additions & 5 deletions src/sonic-device-data/tests/permitted_list
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ bcm_stat_interval
bcm_stat_jumbo
bcm_tunnel_term_compatible_mode
bcm_xlate_port_enable
bcm56340_4x10
bcm56340_2x10
bcm56340_config
cdma_timeout_usec
core_clock_frequency
ctr_evict_enable
Expand Down Expand Up @@ -59,7 +62,7 @@ oversubscribe_mode
parity_correction
parity_enable
pbmp_oversubscribe
pbmp_xport_xe
pbmp_xport
pci2eb_overrid
pfc_deadlock_seq_control
phy_84328
Expand All @@ -69,31 +72,35 @@ phy_an_allow_pll_change_hg
phy_an_c37
phy_an_c73
phy_an_fec
phy_automedium
phy_aux_voltage_enable
phy_chain_rx_lane_map_physical
phy_chain_rx_polarity_flip_physical
phy_chain_tx_lane_map_physical
phy_chain_tx_polarity_flip_physical
phy_ext_rom_boot
phy_fiber_pref
phy_gearbox_enable
phy_null
phy_line_tx_mode
phy_pcs_rx_polarity_flip
phy_pcs_tx_polarity_flip
phy_port_primary_and_offset
phy_rx_polarity_flip
phy_system_tx_mode
phy_sgmii_autoneg
phy_tx_polarity_flip
phy_xaui_rx_polarity_flip
phy_xaui_tx_polarity_flip
physical_ports
port_init_autoneg
port_init_cl72
port_init_cl72_hg
port_init_speed_xe
port_init_speed
port_phy_addr
port_phy_clause
port_phy_id0
port_phy_id1
portgroup
portmap
prbs_polynomial
ptp_bs_fref
Expand All @@ -113,7 +120,7 @@ serdes_firmware_mode
serdes_if_type
serdes_pre_driver_current
serdes_preemphasis
serdes_rx_los_xe
serdes_rx_los
serdes_sgmii_m
skip_L2_USER_ENTRY
sram_scan_enable
Expand All @@ -129,6 +136,6 @@ tslam_intr_enable
tslam_timeout_usec
uplink_ports
xgxs_lcpll_xtal_refclk
xgxs_pdetect_1
xgxs_pdetect
xgxs_rx_lane_map
xgxs_tx_lane_map

0 comments on commit 35e8329

Please sign in to comment.