-
Notifications
You must be signed in to change notification settings - Fork 745
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
Update y_cable_simulator_client to address SFP issue. #2952
Update y_cable_simulator_client to address SFP issue. #2952
Conversation
In topo dualtor_56, a 100G interfaces are splited into two 50G interfaces. The physical port id got from spf is different with host interface index, which is used as the name of mux bridge. As a result, y_cable_simulator_client failed to toggle some interface. This PR addressed the issue by calculating the correct mapping from physical port to host interface index. Signed-off-by: bingwang <[email protected]>
else: | ||
g_physical_to_logical_port_mapping[fp_port_index].append(intf_name) | ||
|
||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that the else portion could be abstracted out as a helper function. This change can come with another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Updated. Thanks
|
||
if not g_physical_to_host_port_mapping or not g_physical_to_logical_port_mapping: | ||
_load_port_info() | ||
return g_physical_to_host_port_mapping[physical_port] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unlikely to happen, but if _load_port_info() failed, you probably should return the old (physical_port - 1) as it still works on some platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks!
1. Return physical_port - 1 if loading port_config file failed. 2. Fix typo Signed-off-by: bingwang <[email protected]>
for intf in ports.keys(): | ||
logical_list.append(intf) | ||
|
||
logical = natsorted(logical_list, key=lambda y: y.lower()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using a single line of code for the purpose of line 75-79:
logical = natsorted([intf.lower() for intf in ports.keys()])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a single line code is a good suggestion. But I'd like to keep current code here because converting all interface name into lower case can cause some issue in following code.
else: | ||
g_physical_to_logical_port_mapping[fp_port_index].append(intf_name) | ||
|
||
def _load_port_config_ini(porttabfile): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering if the sonic_py_common package already has code for reading and parsing the port_config.ini file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there is no such code. Most of the code for parsing port config file is from sfputilhelper.py
Signed-off-by: bingwang <[email protected]>
Signed-off-by: bingwang [email protected]
Description of PR
Summary:
Fixes # (issue)
In topo dualtor_56, a 100G interfaces are splited into two 50G interfaces according to
port_config.ini
.As a result, the physical port id got from SFP is different with host interface index, which is used as the name of mux bridge.
For example, the physical port id for
Ethernet4
is2
accordingport_config.ini
, but the interface is connect to mux bridgembr-vms17-8-2
. Therefore, we need to calculatehost interface index
fromphysical port id
.This PR addressed the issue by calculating
host interface index
according to port config file. Most of the logic is same withread_porttab_mappings
in sfputilhelper.pyType of change
Approach
What is the motivation for this PR?
This PR is to addressed the issue caused by port spliting.
How did you do it?
Calculate the correct mapping from physical port to host interface index.
How did you verify/test it?
Any platform specific information?
No.
Supported testbed topology if it's a new test case?
No.
Documentation