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

[dpu_tty]: Add a DPU TTY console utility #3535

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

wenchungw
Copy link

@wenchungw wenchungw commented Sep 7, 2024

  • Add dpu_tty.py
  • Add dpu_tty.py to scripts

Signed-off-by: Wenchung Wang vincwang@cisco.com

What I did

Add DPU TTY console utility.

How I did it

  • Read platform.json to retrieve TTY settings in DPUS section. Set up TTY console according to TTY device name and baud rate.
  • Also provide options to overwrite default TTY device and baud rate.
"DPUS": {
    "dpu0": {
        "serial-console": {
            "device": "ttyS4",
            "baud-rate": "115200"
        }
    },
    "dpu1": {
        "serial-console": {
            "device": "ttyS5",
            "baud-rate": "115200"
        }
    }
},

How to verify it

Run the utility on a smart switch that provides DPU UART console via ttyS device. The test plan is at
https://github.com/sonic-net/sonic-mgmt/pull/12701/files section 1.4.

The utility works only on smart switch that provides DPU serial console connections through TTY /dev/ttyS* devices, for example Mt Fuji. Here is a test log.

root@MtFuji:/home/cisco# dpu-tty.py -n dpu0
picocom v3.1

port is        : /dev/ttyS4
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

sonic login: admin
Password: 
Linux sonic 6.1.0-11-2-arm64 #1 SMP Debian 6.1.38-4 (2023-08-08) aarch64
You are on
  ____   ___  _   _ _  ____
 / ___| / _ \| \ | (_)/ ___|
 \___ \| | | |  \| | | |
  ___) | |_| | |\  | | |___
 |____/ \___/|_| \_|_|\____|

-- Software for Open Networking in the Cloud --

Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.

Help:    https://sonic-net.github.io/SONiC/

Last login: Thu Sep 19 18:40:28 UTC 2024 on ttyS0
admin@sonic:~$ show ip int
Interface    Master    IPv4 address/mask    Admin/Oper    BGP Neighbor    Neighbor IP
-----------  --------  -------------------  ------------  --------------  -------------
Ethernet0              18.0.202.1/31        up/up         N/A             N/A
docker0                240.127.1.1/24       up/down       N/A             N/A
int_mnic0              169.254.200.0/24     up/up         N/A             N/A
lo                     127.0.0.1/16         up/up         N/A             N/A
admin@sonic:~$ 
Terminating...
Thanks for using picocom
root@MtFuji:/home/cisco# dpu-tty.py -n dpu7
picocom v3.1

port is        : /dev/ttyS11
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

sonic login: 
Terminating...
Thanks for using picocom
root@MtFuji:/home/cisco# dpu-tty.py -n dpu7
picocom v3.1

port is        : /dev/ttyS11
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

sonic login: admin
Password: 
Linux sonic 6.1.0-11-2-arm64 #1 SMP Debian 6.1.38-4 (2023-08-08) aarch64
You are on
  ____   ___  _   _ _  ____
 / ___| / _ \| \ | (_)/ ___|
 \___ \| | | |  \| | | |
  ___) | |_| | |\  | | |___
 |____/ \___/|_| \_|_|\____|

-- Software for Open Networking in the Cloud --

Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.

Help:    https://sonic-net.github.io/SONiC/

admin@sonic:~$ sudo su
root@sonic:/home/admin# show ip int
Interface    Master    IPv4 address/mask    Admin/Oper    BGP Neighbor    Neighbor IP
-----------  --------  -------------------  ------------  --------------  -------------
Ethernet0              18.7.202.1/31        up/up         N/A             N/A
docker0                240.127.1.1/24       up/down       N/A             N/A
int_mnic0              169.254.200.7/24     up/up         N/A             N/A
lo                     127.0.0.1/16         up/up         N/A             N/A
root@sonic:/home/admin# 
Terminating...
Thanks for using picocom
root@MtFuji:/home/cisco# 

Previous command output (if the output of a command-line utility has changed)

N/A

New command output (if the output of a command-line utility has changed)

N/A

* Add dpu_tty.py
* Add dpu_tty.py to scripts

Signed-off-by: Wenchung Wang vincwang@cisco.com

What I did

Add DPU TTY console utility.

How I did it

* Read platform.json to retrieve TTY settings in DPUS section. Set up TTY
console according to TTY device name and baud rate.
* Also provide options to overwrite default TTY device and baud rate.

'''
"DPUS": {
    "dpu0": {
        "serial-console": {
            "device": "ttyS4",
            "baud-rate": "115200"
        }
    },
    "dpu1": {
        "serial-console": {
            "device": "ttyS5",
            "baud-rate": "115200"
        }
    }
},
'''

How to verify it

Run the utility on a smart switch that provides DPU UART console via
ttyS device. The test plan is at
https://github.com/sonic-net/sonic-mgmt/pull/12701/files section 1.4.
Copy link

linux-foundation-easycla bot commented Sep 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

setup.py Outdated
@@ -120,6 +120,7 @@
'scripts/decode-syseeprom',
'scripts/dropcheck',
'scripts/disk_check.py',
'scripts/dpu_tty.py',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please rename the application to dpu-tty? To make the user experience more convenient

Copy link
Author

Choose a reason for hiding this comment

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

Changed

def main():

parser = argparse.ArgumentParser(description='DPU TTY Console Utility')
parser.add_argument('-s', '--slot', type=int, required=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the slot used instead of the DPU name?
I suggest using the DPU name (dpu0, dpu1, dpuX) in all places to refer to the DPU. This will remove any future confusion.

    parser.add_argument('-n', '--name', type=str, required=True)

Copy link
Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Collaborator

@oleksandrivantsiv oleksandrivantsiv left a comment

Choose a reason for hiding this comment

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

As commented. Please also cover the application with the tests

Copy link
Contributor

@prgeor prgeor left a comment

Choose a reason for hiding this comment

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

@wenchungw could you update this document to explain the new CLI being proposed?

https://github.com/sonic-net/sonic-utilities/blob/master/doc/Command-Reference.md

Please add a new section "Console"

@wenchungw
Copy link
Author

@wenchungw could you update this document to explain the new CLI being proposed?

https://github.com/sonic-net/sonic-utilities/blob/master/doc/Command-Reference.md

Please add a new section "Console"

Added.

@wenchungw
Copy link
Author

As commented. Please also cover the application with the tests

Added a test log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants