Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5953,6 +5953,137 @@ This command displays the eye info in mv(milli volts) of the port user provides
632 622
```


**show muxcable health <port>**

This command displays the hardware health of the Y-cable which are connected to muxcable. The resultant table or json output will show the current hadrware health of the cable as Ok, Not Ok, Unknown.

- Usage:
```
show muxcable health [OPTIONS] [PORT]
```

While displaying the muxcable health, users need to provide the following fields

- PORT required - Port name should be a valid port
- --json optional - -- option to display the result in json format. By default output will be in tabular format.


- Example:
```
admin@sonic:~$ show muxcable health Ethernet4
PORT ATTR HEALTH
--------- ------ --------
Ethernet4 health Ok
```
```
admin@sonic:~$ show muxcable health Ethernet4 --json
```
```json
{
"health": "Ok"
}

```


**show muxcable queueinfo <port>**

This command displays the queue info of the Y-cable which are connected to muxcable. The resultant table or json output will show the queue info in terms transactions for the UART stats in particular currently relevant to the MCU of the cable.

- Usage:
```
show muxcable queueinfo [OPTIONS] [PORT]
```

While displaying the muxcable queueinfo, users need to provide the following fields

- PORT required - Port name should be a valid port
- --json optional - -- option to display the result in json format. By default output will be in tabular format.


- Example:
```
admin@sonic:~$ show muxcable queueinfo Ethernet0
PORT ATTR VALUE
--------- ---------- -------
Ethernet0 uart_stat1 2
Ethernet0 uart_stat2 1
```
```
admin@sonic:~$ show muxcable health Ethernet4 --json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this output for health correct? seems you are listing the stats

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

```
```json
{
"uart_stat1": "2",
"uart_stat2": "1",

}
```

**show muxcable operationtime <port>**

This command displays the operationtime of the Y-cable which are connected to muxcable. The resultant table or json output will show the current operation time of the cable as `hh:mm:ss` format.

- Usage:
```
show muxcable operationtime [OPTIONS] [PORT]
```

While displaying the muxcable operationtime, users need to provide the following fields

- PORT required - Port name should be a valid port
- --json optional - -- option to display the result in json format. By default output will be in tabular format.


- Example:
```
admin@sonic:~$ show muxcable operationtime Ethernet4
PORT ATTR OPERATION_TIME
--------- -------------- ----------------
Ethernet4 operation_time 22.22
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the operation time does not seem to be in the format hh:mm:ss ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

```
```
admin@sonic:~$ show muxcable operationtime Ethernet4 --json
```
```json
{
"operation_time": "22.22"
}
```

**show muxcable resetcause <port>**

This command displays the resetcause of the Y-cable which are connected to muxcable. The resultant table or json output will show the most recent reset cause of the cable as string format.

- Usage:
```
show muxcable resetcause [OPTIONS] [PORT]
```

While displaying the muxcable resetcause, users need to provide the following fields

- PORT required - Port name should be a valid port
- --json optional - -- option to display the result in json format. By default output will be in tabular format.


- Example:
```
admin@sonic:~$ show muxcable resetcause Ethernet4
PORT ATTR RESETCAUSE
--------- ----------- ------------
Ethernet4 reset_cause 0
```
```
admin@sonic:~$ show muxcable resetcause Ethernet4 --json
```
```json
{
"reset_cause": "0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add the text for reset cause as numbers don't make any sense to user

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vdahiya12 its not fixed

}
```


### Muxcable Config commands


Expand Down
202 changes: 202 additions & 0 deletions show/muxcable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
VENDOR_NAME = "Credo"
VENDOR_MODEL_REGEX = re.compile(r"CAC\w{3}321P2P\w{2}MS")

#define table names that interact with Cli
XCVRD_GET_BER_CMD_TABLE = "XCVRD_GET_BER_CMD"
XCVRD_GET_BER_RSP_TABLE = "XCVRD_GET_BER_RSP"
XCVRD_GET_BER_RES_TABLE = "XCVRD_GET_BER_RES"
XCVRD_GET_BER_CMD_ARG_TABLE = "XCVRD_GET_BER_CMD_ARG"

def get_asic_index_for_port(port):
asic_index = None
Expand Down Expand Up @@ -410,6 +415,17 @@ def update_and_get_response_for_xcvr_cmd(cmd_name, rsp_name, exp_rsp, cmd_table_
return res_dict


def delete_all_keys_in_db_tables_helper():

delete_all_keys_in_db_table("APPL_DB", XCVRD_GET_BER_CMD_TABLE)
delete_all_keys_in_db_table("STATE_DB", XCVRD_GET_BER_RSP_TABLE)
delete_all_keys_in_db_table("STATE_DB", XCVRD_GET_BER_RES_TABLE)
delete_all_keys_in_db_table("APPL_DB", XCVRD_GET_BER_CMD_ARG_TABLE)

return 0



# 'muxcable' command ("show muxcable")
#

Expand Down Expand Up @@ -2255,4 +2271,190 @@ def muxdirection(db, port, json_output):
if rc_exit == False:
sys.exit(EXIT_FAIL)

@muxcable.command()
@click.argument('port', metavar='<port_name>', required=True, default=None)
@click.argument('option', required=False, default=None)
@click.option('--json', 'json_output', required=False, is_flag=True, type=click.BOOL, help="display the output in json format")
@clicommon.pass_db
def queueinfo(db, port, option, json_output):
"""Show muxcable queue info information, preagreed by vendors"""

port = platform_sfputil_helper.get_interface_name(port, db)
delete_all_keys_in_db_tables_helper()

if port is not None:

res_dict = {}
result = {}
param_dict = {}
param_dict["option"] = option


res_dict[0] = CONFIG_FAIL
res_dict[1] = "unknown"

res_dict = update_and_get_response_for_xcvr_cmd(
"get_ber", "status", "True", "XCVRD_GET_BER_CMD", "XCVRD_GET_BER_CMD_ARG", "XCVRD_GET_BER_RSP", port, 100, param_dict, "queue_info")

if res_dict[1] == "True":
result = get_result(port, res_dict, "fec" , result, "XCVRD_GET_BER_RES")


delete_all_keys_in_db_tables_helper()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add it as decorator? do we need in destructor call? I don't see this needed here after command response is completed. if ycabled response failed...I am afraid if you are clearing this for commands from other CLI/shell context

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, called in subroutine now

port = platform_sfputil_helper.get_interface_alias(port, db)

if json_output:
click.echo("{}".format(json.dumps(result, indent=4)))
else:
headers = ['PORT', 'ATTR', 'VALUE']
res = [[port]+[key] + [val] for key, val in result.items()]
click.echo(tabulate(res, headers=headers))
else:
click.echo("Did not get a valid Port for queue info information".format(port))
sys.exit(CONFIG_FAIL)


@muxcable.command()
@click.argument('port', metavar='<port_name>', required=True, default=None)
@click.option('--json', 'json_output', required=False, is_flag=True, type=click.BOOL, help="display the output in json format")
@clicommon.pass_db
def health(db, port, json_output):
"""Show muxcable health information as Ok or Not Ok"""

"""
in order to detemine whether the health of the cable is Ok
the following are checked
- the vendor name is correct able to be read
- the FW is correctly loaded for SerDes by reading the appropriate register val
- the Counters for UART are displaying healthy status
i.e Error Counters , retry Counters for UART or internal xfer protocols are below a threshold
"""

port = platform_sfputil_helper.get_interface_name(port, db)
delete_all_keys_in_db_tables_helper()

if port is not None:

res_dict = {}
result = {}


res_dict[0] = CONFIG_FAIL
res_dict[1] = "unknown"

res_dict = update_and_get_response_for_xcvr_cmd(
"get_ber", "status", "True", "XCVRD_GET_BER_CMD", None, "XCVRD_GET_BER_RSP", port, 10, None, "health_check")

if res_dict[1] == "True":
result = get_result(port, res_dict, "fec" , result, "XCVRD_GET_BER_RES")


delete_all_keys_in_db_tables_helper()

port = platform_sfputil_helper.get_interface_alias(port, db)

cable_health = result.get("health_check", None)

if cable_health == "False":
result["health_check"] = "Not Ok"
elif cable_health == "True":
result["health_check"] = "Ok"
else:
result["health_check"] = "Unknown"



if json_output:
click.echo("{}".format(json.dumps(result, indent=4)))
else:
headers = ['PORT', 'ATTR', 'HEALTH']
res = [[port]+[key] + [val] for key, val in result.items()]
click.echo(tabulate(res, headers=headers))
else:
click.echo("Did not get a valid Port for cable health status".format(port))
sys.exit(CONFIG_FAIL)

@muxcable.command()
@click.argument('port', metavar='<port_name>', required=True, default=None)
@click.option('--json', 'json_output', required=False, is_flag=True, type=click.BOOL, help="display the output in json format")
@clicommon.pass_db
def resetcause(db, port, json_output):
"""Show muxcable resetcause information """

port = platform_sfputil_helper.get_interface_name(port, db)
delete_all_keys_in_db_tables_helper()

if port is not None:

res_dict = {}
result = {}


res_dict[0] = CONFIG_FAIL
res_dict[1] = "unknown"

res_dict = update_and_get_response_for_xcvr_cmd(
"get_ber", "status", "True", "XCVRD_GET_BER_CMD", None, "XCVRD_GET_BER_RSP", port, 10, None, "reset_cause")

if res_dict[1] == "True":
result = get_result(port, res_dict, "fec" , result, "XCVRD_GET_BER_RES")


delete_all_keys_in_db_tables_helper()

port = platform_sfputil_helper.get_interface_alias(port, db)

if json_output:
click.echo("{}".format(json.dumps(result, indent=4)))
else:
headers = ['PORT', 'ATTR', 'RESETCAUSE']
res = [[port]+[key] + [val] for key, val in result.items()]
click.echo(tabulate(res, headers=headers))
else:
click.echo("Did not get a valid Port for cable resetcause information".format(port))
sys.exit(CONFIG_FAIL)

@muxcable.command()
@click.argument('port', metavar='<port_name>', required=True, default=None)
@click.option('--json', 'json_output', required=False, is_flag=True, type=click.BOOL, help="display the output in json format")
@clicommon.pass_db
def operationtime(db, port, json_output):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you specify time unit and also what is operation time in the description of this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"""Show muxcable operation time hh:mm:ss forrmat"""

port = platform_sfputil_helper.get_interface_name(port, db)
delete_all_keys_in_db_tables_helper()

if port is not None:

res_dict = {}
result = {}


res_dict[0] = CONFIG_FAIL
res_dict[1] = "unknown"

res_dict = update_and_get_response_for_xcvr_cmd(
"get_ber", "status", "True", "XCVRD_GET_BER_CMD", None, "XCVRD_GET_BER_RSP", port, 10, None, "operation_time")

if res_dict[1] == "True":
result = get_result(port, res_dict, "fec" , result, "XCVRD_GET_BER_RES")


delete_all_keys_in_db_tables_helper()

port = platform_sfputil_helper.get_interface_alias(port, db)

actual_time = result.get("operation_time", 0)
if actual_time is not None:
time = '{0:02.0f}:{1:02.0f}'.format(*divmod(int(actual_time) * 60, 60))
result['operation_time'] = time

if json_output:
click.echo("{}".format(json.dumps(result, indent=4)))
else:
headers = ['PORT', 'ATTR', 'OPERATION_TIME']
res = [[port]+[key] + [val] for key, val in result.items()]
click.echo(tabulate(res, headers=headers))
else:
click.echo("Did not get a valid Port for operation time".format(port))
sys.exit(CONFIG_FAIL)
Loading