Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config][show] cli support for retrieving ber, eye-info and configuring prbs, loopback on Y-cable #1386

Merged
merged 16 commits into from
Feb 4, 2021
Merged
74 changes: 72 additions & 2 deletions config/muxcable.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def lookup_statedb_and_update_configdb(per_npu_statedb, config_db, port, state_c
ipv6_value = get_value_for_key_in_config_tbl(config_db, port, "server_ipv6", "MUX_CABLE")

state = get_value_for_key_in_dict(muxcable_statedb_dict, port, "state", "MUX_CABLE_TABLE")
if (state == "active" and configdb_state == "active") or (state == "standby" and configdb_state == "active") or (state == "unknown" and configdb_state == "active") :
if (state == "active" and configdb_state == "active") or (state == "standby" and configdb_state == "active") or (state == "unknown" and configdb_state == "active"):
if state_cfg_val == "active":
# status is already active, so right back error
port_status_dict[port] = 'OK'
Expand All @@ -90,7 +90,7 @@ def lookup_statedb_and_update_configdb(per_npu_statedb, config_db, port, state_c
# dont write anything to db, write OK to user
port_status_dict[port] = 'OK'

elif (state == "standby" and configdb_state == "auto") or (state == "unknown" and configdb_state == "auto"):
elif (state == "standby" and configdb_state == "auto") or (state == "unknown" and configdb_state == "auto"):
if state_cfg_val == "active":
# make the state active
config_db.set_entry("MUX_CABLE", port, {"state": "active",
Expand Down Expand Up @@ -188,3 +188,73 @@ def mode(state, port, json_output):
click.echo(tabulate(data, headers=headers))

sys.exit(CONFIG_SUCCESSFUL)

@muxcable.group(cls=clicommon.AbbreviationGroup)
def prbs():
"""Enable/disable PRBS mode on a port"""
pass

@prbs.command()
@click.argument('port', required=True, default=None, type=click.INT)
@click.argument('target', required=True, default=None, type=click.INT)
@click.argument('mode_value', required=True, default=None, type=click.INT)
@click.argument('lane_map', required=True, default=None, type=click.INT)
def enable(port, target, mode_value, lane_map):
"""Enable PRBS mode on a port"""

import sonic_y_cable.y_cable
res = sonic_y_cable.y_cable.enable_prbs_mode(port, target, mode_value, lane_map)
if res != True:
click.echo("PRBS config unsuccesful")
sys.exit(CONFIG_FAIL)
click.echo("PRBS config sucessful")
sys.exit(CONFIG_SUCCESSFUL)

@prbs.command()
@click.argument('port', required=True, default=None, type=click.INT)
@click.argument('target', required=True, default=None, type=click.INT)
def disable(port, target):
"""Disable PRBS mode on a port"""

import sonic_y_cable.y_cable
res = sonic_y_cable.y_cable.disable_prbs_mode(port, target)
if res != True:
click.echo("PRBS disable unsuccesful")
sys.exit(CONFIG_FAIL)
click.echo("PRBS disable sucessful")
sys.exit(CONFIG_SUCCESSFUL)

@muxcable.group(cls=clicommon.AbbreviationGroup)
def loopback():
"""Enable/disable loopback mode on a port"""
pass


@loopback.command()
@click.argument('port', required=True, default=None, type=click.INT)
@click.argument('target', required=True, default=None, type=click.INT)
@click.argument('lane_map', required=True, default=None, type=click.INT)
def enable(port, target, lane_map):
"""Enable loopback mode on a port"""

import sonic_y_cable.y_cable
res = sonic_y_cable.y_cable.enable_loopback_mode(port, target, lane_map)
if res != True:
click.echo("loopback config unsuccesful")
sys.exit(CONFIG_FAIL)
click.echo("loopback config sucessful")
sys.exit(CONFIG_SUCCESSFUL)

@loopback.command()
@click.argument('port', required=True, default=None, type=click.INT)
@click.argument('target', required=True, default=None, type=click.INT)
def disable(port, target):
"""Disable loopback mode on a port"""

import sonic_y_cable.y_cable
res = sonic_y_cable.y_cable.disable_loopback_mode(port, target)
if res != True:
click.echo("loopback disable unsuccesful")
sys.exit(CONFIG_FAIL)
click.echo("loopback disable sucessful")
sys.exit(CONFIG_SUCCESSFUL)
111 changes: 109 additions & 2 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4734,6 +4734,54 @@ While displaying the muxcable configuration, users can configure the following f
}
```

**show muxcable ber-info**

This command displays the ber(Bit error rate) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as.
0 -> local
1 -> tor 1
2 -> tor 2
3 -> nic

- Usage:
```
Usage: show muxcable ber-info [OPTIONS] PORT TARGET
```


- PORT required - Port number should be a valid port
- TARGET required - the actual target to get the ber info of.

- Example:
```
admin@sonic:~$ show muxcable ber-info 1 1
Lane1 Lane2
------- -------
0 0
```

**show muxcable ber-info**

This command displays the eye info in mv(milli volts) of the port user provides on the target user provides. The target provided as an integer corresponds to actual target as.
0 -> local
1 -> tor 1
2 -> tor 2
3 -> nic

- Usage:
```
Usage: show muxcable eye-info [OPTIONS] PORT TARGET
```

- PORT required - Port number should be a valid port
- TARGET required - the actual target to get the eye info of.

- Example:
```
admin@sonic:~$ show muxcable ber-info 1 1
Lane1 Lane2
------- -------
632 622
```

### Muxcable Config commands

Expand Down Expand Up @@ -4769,7 +4817,6 @@ While configuring the muxcable, users needs to configure the following fields fo
"Ethernet0": "OK"
}
```

```
admin@sonic:~$ sudo config muxcable mode active all
port state
Expand All @@ -4785,7 +4832,67 @@ While configuring the muxcable, users needs to configure the following fields fo
"Ethernet32": "INPROGRESS",
"Ethernet0": "OK"
}
```
```
**config muxcable prbs enable/disable**

This command is used for setting the configuration and enable/diable of prbs on a port user provides. While enabling in addition to port the user also needs to provides the target, prbs mode and lane map on which the user intends to run prbs on. The target reflects where the enable/dsiable will happen.

- Usage:
```
config muxcable prbs enable [OPTIONS] PORT TARGET MODE_VALUE LANE_MAP
config muxcable prbs disable [OPTIONS] PORT TARGET
```

While configuring the muxcable, users needs to configure the following fields for the operation

- PORT required - Port number should be a valid port
- TARGET required - the actual target to run the prbs on
0 -> local side,
1 -> TOR 1
2 -> TOR 2
3 -> NIC
- MODE_VALUE required - the mode/type for configuring the PRBS mode.
0x00 = PRBS 9, 0x01 = PRBS 15, 0x02 = PRBS 23, 0x03 = PRBS 31
- LANE_MAP required - an integer representing the lane_map to be run PRBS on
0bit for lane 0, 1bit for lane1 and so on.
for example 3 -> 0b'0011 , means running on lane0 and lane1
- Example:
```
admin@sonic:~$ sudo config muxcable prbs enable 1 1 3 3
PRBS config sucessful
admin@sonic:~$ sudo config muxcable prbs disable 1 0
PRBS disable sucessful
```

**config muxcable loopback enable/disable**

This command is used for setting the configuration and enable/disable of loopback on a port user provides. While enabling in addition to port the user also needs to provides the target and lane map on which the user intends to run loopback on. The target reflects where the enable/dsiable will happen.

- Usage:
```
config muxcable loopback enable [OPTIONS] PORT TARGET LANE_MAP
config muxcable loopback disable [OPTIONS] PORT TARGET
```

While configuring the muxcable, users needs to configure the following fields for the operation

- PORT required - Port number should be a valid port
- TARGET required - the actual target to run the loopback on
0 -> local side,
1 -> TOR 1
2 -> TOR 2
3 -> NIC
- LANE_MAP required - an integer representing the lane_map to be run loopback on
0bit for lane 0, 1bit for lane1 and so on.
for example 3 -> 0b'0011 , means running on lane0 and lane1

- Example:
```
admin@sonic:~$ sudo config muxcable loopback enable 1 1 3
loopback config sucessful
admin@sonic:~$ sudo config muxcable loopback disable 1 0
loopback disable sucessfull
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#muxcable)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
'netifaces==0.10.7',
'pexpect==4.8.0',
'requests==2.25.0',
'sonic-platform-common',
'sonic-py-common',
'sonic-yang-mgmt',
'swsssdk>=2.0.1',
Expand Down
45 changes: 45 additions & 0 deletions show/muxcable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import sys

import click
Expand All @@ -15,6 +16,8 @@

CONFIG_SUCCESSFUL = 101
CONFIG_FAIL = 1
EXIT_FAIL = 1
EXIT_SUCCESS = 0
STATUS_FAIL = 1
STATUS_SUCCESSFUL = 102

Expand Down Expand Up @@ -336,3 +339,45 @@ def config(port, json_output):
click.echo(tabulate(print_data, headers=headers))

sys.exit(CONFIG_SUCCESSFUL)


@muxcable.command()
@click.argument('port', required=True, default=None, type=click.INT)
@click.argument('target', required=True, default=None, type=click.INT)
def berinfo(port, target):
"""Show muxcable BER (bit error rate) information"""

if os.geteuid() != 0:
click.echo("Root privileges are required for this operation")
sys.exit(EXIT_FAIL)
import sonic_y_cable.y_cable
res = sonic_y_cable.y_cable.get_ber_info(port, target)
if res == False or res == -1:
click.echo("Unable to fetch ber info")
sys.exit(EXIT_FAIL)
headers = ['Lane1', 'Lane2', 'Lane3', 'Lane4']
lane_data = []
lane_data.append(res)
click.echo(tabulate(lane_data, headers=headers))
sys.exit(EXIT_SUCCESS)


@muxcable.command()
@click.argument('port', required=True, default=None, type=click.INT)
@click.argument('target', required=True, default=None, type=click.INT)
def eyeinfo(port, target):
"""Show muxcable eye information in mv"""

if os.geteuid() != 0:
click.echo("Root privileges are required for this operation")
sys.exit(EXIT_FAIL)
import sonic_y_cable.y_cable
res = sonic_y_cable.y_cable.get_eye_info(port, target)
if res == False or res == -1:
click.echo("Unable to fetch eye info")
sys.exit(EXIT_FAIL)
headers = ['Lane1', 'Lane2', 'Lane3', 'Lane4']
lane_data = []
lane_data.append(res)
click.echo(tabulate(lane_data, headers=headers))
sys.exit(EXIT_SUCCESS)
Loading