-
Notifications
You must be signed in to change notification settings - Fork 819
[show][muxcable] add some new commands health, reset-cause, queue_info support for muxcable #2414
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
Changes from 10 commits
fcd107f
e4cc431
006451c
db8b12f
bfbebf1
593abbe
579e8d0
9c85ea5
d265234
58daec7
fb61e87
ba1dec1
4c1982c
a512b42
64d79fc
275e670
b526d6d
3f4675b
e66e8b3
aa6b16b
8bacea5
e072599
24eb58a
2831060
c35cab8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
|
||
vdahiya12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - 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 | ||
|
||
| ``` | ||
| ```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] | ||
vdahiya12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 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 | ||
|
||
| ``` | ||
| ``` | ||
| 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. | ||
|
|
||
vdahiya12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - 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" | ||
|
||
| } | ||
| ``` | ||
|
|
||
|
|
||
| ### Muxcable Config commands | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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") | ||
| # | ||
|
|
||
|
|
@@ -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) | ||
vdahiya12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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() | ||
|
||
| 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): | ||
vdahiya12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """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'] | ||
vdahiya12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you specify time unit and also what is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
Uh oh!
There was an error while loading. Please reload this page.