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

[autoneg] add support for remote speed advertisement #2124

Merged
merged 5 commits into from
May 10, 2022

Conversation

ds952811
Copy link
Contributor

@ds952811 ds952811 commented Apr 1, 2022

Add support for remote speed advertisement, such that users could easily
identify the connection issues when autoneg is enabled.

HLD: sonic-net/SONiC#924

Signed-off-by: Dante Su dante.su@broadcom.com

What I did

Add support for remote speed advertisement

How I did it

Implementation is done according to the AutoNeg HLD

How to verify it

  1. Built-in unit tests
  2. Manual tests

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

  Interface    Auto-Neg Mode    Speed    Adv Speeds    Type    Adv Types    Oper    Admin
-----------  ---------------  -------  ------------  ------  -----------  ------  -------
  Ethernet0          enabled      25G       10G,50G     CR4      CR4,CR2    down       up
 Ethernet16              N/A     100M           N/A     N/A          N/A      up       up
 Ethernet24              N/A       1G           N/A     N/A          N/A      up       up
 Ethernet28              N/A    1000M           N/A     N/A          N/A      up       up
 Ethernet32         disabled      40G           all     N/A          all      up       up
 Ethernet36              N/A      10M           N/A     N/A          N/A      up       up

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

  Interface    Auto-Neg Mode    Speed    Adv Speeds    Rmt Adv Speeds    Type    Adv Types    Oper    Admin
-----------  ---------------  -------  ------------  ----------------  ------  -----------  ------  -------
  Ethernet0          enabled      25G       10G,50G       10M,100M,1G     CR4      CR4,CR2    down       up
 Ethernet16              N/A     100M           N/A               N/A     N/A          N/A      up       up
 Ethernet24              N/A       1G           N/A               N/A     N/A          N/A      up       up
 Ethernet28              N/A    1000M           N/A               N/A     N/A          N/A      up       up
 Ethernet32         disabled      40G           all               N/A     N/A          all      up       up
 Ethernet36              N/A      10M           N/A               N/A     N/A          N/A      up       up

Copy link
Collaborator

@dgsudharsan dgsudharsan left a comment

Choose a reason for hiding this comment

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

Please update the description with old CLI output and new CLI output.
The CLI output change will impact existing systems in production and automation frameworks that rely on a specific output pattern. Has this been considered?

@@ -281,7 +281,7 @@ def test_show_interfaces_autoneg_status_Ethernet0(self):
assert result.exit_code == 0
assert result.output == show_interface_auto_neg_status_Ethernet0_output

def test_show_interfaces_autoneg_status_etp9_in_alias_mode(self):
def test_show_interfaces_autoneg_status_eth9_in_alias_mode(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need to change the test case name to eth9 when it is using etp9?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it's a typo, and now it's reverted

scripts/intfutil Outdated
@@ -149,6 +150,24 @@ def appl_db_port_status_get(appl_db, intf_name, status_type):
status = ','.join(new_speed_list)
return status

def state_db_port_status_get(db, intf_name, type):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rename 'type' to 'field'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

scripts/intfutil Outdated
speed_list = status.split(',')
new_speed_list = []
for s in natsorted(speed_list):
new_speed_list.append('{}G'.format(s[:-3]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic will not work for switches that have less than 1G speed (e.g mgmt switches which run sonic) Please consider the use case as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

scripts/intfutil Outdated
"""
full_table_id = PORT_STATE_TABLE_PREFIX + intf_name
status = db.get(db.STATE_DB, full_table_id, type)
if status in [None, ""]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

"if not status" should do the job

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -120,7 +121,7 @@ def test_identifier_single(self):
expected = {'Ethernet0': {'CONFIG_DB': {'keys': [{'PORT|Ethernet0': {'alias': 'etp1', 'description': 'etp1', 'index': '0', 'lanes': '25,26,27,28', 'mtu': '9100', 'pfc_asym': 'off', 'speed': '40000'}}], 'tables_not_found': []},
'APPL_DB': {'keys': [{'PORT_TABLE:Ethernet0': {'index': '0', 'lanes': '0', 'alias': 'Ethernet0', 'description': 'ARISTA01T2:Ethernet1', 'speed': '25000', 'oper_status': 'down', 'pfc_asym': 'off', 'mtu': '9100', 'fec': 'rs', 'admin_status': 'up'}}], 'tables_not_found': []},
'ASIC_DB': {'keys': [{'ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd00000000056d': {'SAI_HOSTIF_ATTR_NAME': 'Ethernet0', 'SAI_HOSTIF_ATTR_OBJ_ID': 'oid:0x10000000004a4', 'SAI_HOSTIF_ATTR_OPER_STATUS': 'true', 'SAI_HOSTIF_ATTR_TYPE': 'SAI_HOSTIF_TYPE_NETDEV', 'SAI_HOSTIF_ATTR_VLAN_TAG': 'SAI_HOSTIF_VLAN_TAG_STRIP'}}, {'ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x10000000004a4': {'NULL': 'NULL', 'SAI_PORT_ATTR_ADMIN_STATE': 'true', 'SAI_PORT_ATTR_MTU': '9122', 'SAI_PORT_ATTR_SPEED': '100000'}}], 'tables_not_found': [], 'vidtorid': {'oid:0xd00000000056d': 'oid:0xd', 'oid:0x10000000004a4': 'oid:0x1690000000001'}},
'STATE_DB': {'keys': [{'PORT_TABLE|Ethernet0': {'speed': '100000', 'supported_speeds': '10000,25000,40000,100000'}}], 'tables_not_found': []}}}
'STATE_DB': {'keys': [{'PORT_TABLE|Ethernet0': {'rmt_adv_speeds': '40000', 'speed': '100000', 'supported_speeds': '10000,25000,40000,100000'}}], 'tables_not_found': []}}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should cover case that 'rmt_adv_speeds' has multiple values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

scripts/intfutil Outdated
status = '{}G'.format(int(speed / 1000))
else:
status = '{}M'.format(speed)
elif field in [PORT_ADV_SPEEDS, PORT_RMT_ADV_SPEEDS] and status not in ["N/A", "all"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we have PORT_ADV_SPEEDS field in STATE_DB. Why are we adding check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right, it's removed now

@dgsudharsan
Copy link
Collaborator

Please resolve the conflicts

dgsudharsan
dgsudharsan previously approved these changes Apr 29, 2022
@dgsudharsan
Copy link
Collaborator

Please update the PR description with old command output and new command output as requested.

@adyeung
Copy link

adyeung commented May 5, 2022

@zhangyanzhao @yxieca pls help signoff and merge

scripts/intfutil Outdated
status = db.get(db.STATE_DB, full_table_id, field)
if not status:
return "N/A"
if field == PORT_SPEED and status != "N/A":
Copy link
Contributor

Choose a reason for hiding this comment

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

there is already port_oper_speed_get() to get the speed, so why is this if check required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Add support for remote speed advertisement, such that users could easily
identify the connection issues when autoneg is enabled.

HLD: sonic-net/SONiC#924

- What I did
Add support for remote speed advertisement

- How I did it
Implementation is done according to the AutoNeg HLD

Signed-off-by: Dante Su <dante.su@broadcom.com>
Signed-off-by: Dante Su <dante.su@broadcom.com>
Signed-off-by: Dante Su <dante.su@broadcom.com>
Signed-off-by: Dante Su <dante.su@broadcom.com>
Signed-off-by: Dante Su <dante.su@broadcom.com>
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.

5 participants