Skip to content

Commit

Permalink
[sfputil] Update loopback_mode options to individually clear each mode
Browse files Browse the repository at this point in the history
Signed-off-by: xinyu <xinyu0123@gmail.com>
  • Loading branch information
xinyulin committed Aug 18, 2024
1 parent a4362be commit 1f7112b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,9 @@ def debug():
@click.argument('port_name', required=True, default=None)
@click.argument('loopback_mode', required=True, default="none",
type=click.Choice(["none", "host-side-input", "host-side-output",
"media-side-input", "media-side-output"]))
"media-side-input", "media-side-output",
"host-side-input-none", "host-side-output-none",
"host-side-input-none", "host-side-output-none"]))
def loopback(port_name, loopback_mode):
"""Set module diagnostic loopback mode
"""
Expand Down Expand Up @@ -1998,7 +2000,7 @@ def loopback(port_name, loopback_mode):
subport = int(config_db.get(config_db.CONFIG_DB,
'PORT|{}'.format(port_name), 'subport'))

# If it is not defined (None) or if it is set to 0, assign a default value of 1
# If subport is not defined (None) or set to 0, assign a default value of 1
# to ensure valid subport configuration.
if subport is None or subport == 0:
subport = 1
Expand All @@ -2019,9 +2021,11 @@ def loopback(port_name, loopback_mode):
click.echo("Failed to connect to STATE_DB")
sys.exit(EXIT_FAIL)

if loopback_mode in ("host-side-input", "host-side-output"):
if loopback_mode in ("host-side-input", "host-side-output",
"host-side-input-none", "host-side-output-none"):
lane_mask = ((1 << host_lane_count) - 1) << ((subport - 1) * host_lane_count)
elif loopback_mode in ("media-side-input", "host-side-output"):
elif loopback_mode in ("media-side-input", "host-side-output",
"media-side-input-none", "host-side-output-none"):
lane_mask = ((1 << media_lane_count) - 1) << ((subport - 1) * media_lane_count)
else:
lane_mask = 0
Expand Down

0 comments on commit 1f7112b

Please sign in to comment.