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

[Multiasic]: Add calculation of interface index for backplane interfaces #68

Merged
Merged
Changes from all 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
9 changes: 9 additions & 0 deletions src/swsssdk/port_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@


SONIC_ETHERNET_RE_PATTERN = "^Ethernet(\d+)$"
"""
Ethernet-BP refers to BackPlane interfaces
in multi-asic platform.
"""
SONIC_ETHERNET_BP_RE_PATTERN = "^Ethernet-BP(\d+)$"
Copy link
Contributor

@qiluo-msft qiluo-msft Apr 28, 2020

Choose a reason for hiding this comment

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

BP [](start = 42, length = 2)

Explain in comment what is BP? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added as per comment

SONIC_PORTCHANNEL_RE_PATTERN = "^PortChannel(\d+)$"
SONIC_MGMT_PORT_RE_PATTERN = "^eth(\d+)$"


class BaseIdx:
ethernet_base_idx = 1
ethernet_bp_base_idx = 9000
Copy link
Contributor

@qiluo-msft qiluo-msft Apr 28, 2020

Choose a reason for hiding this comment

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

9000 [](start = 27, length = 4)

How do you choose this value? Is 2000 working? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the range used by a realistic SKU?


In reply to: 416935612 [](ancestors = 416935612)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chose 9000 as the offset will be large enough and Index does not overlap.
With 2000 as offset, it might overlap with PortChannel interface index.

Copy link
Contributor

Choose a reason for hiding this comment

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

@qiluo-msft , i think 9000 should be a good safe offset value for back-plane instead of a lower value

portchannel_base_idx = 1000
mgmt_port_base_idx = 10000

def get_index(if_name):
"""
OIDs are 1-based, interfaces are 0-based, return the 1-based index
Ethernet N = N + 1
Ethernet_BP N = N + 9000
PortChannel N = N + 1000
eth N = N + 10000
"""
Expand All @@ -29,11 +36,13 @@ def get_index_from_str(if_name):
"""
OIDs are 1-based, interfaces are 0-based, return the 1-based index
Ethernet N = N + 1
Ethernet_BP N = N + 9000
PortChannel N = N + 1000
eth N = N + 10000
"""
patterns = {
SONIC_ETHERNET_RE_PATTERN: BaseIdx.ethernet_base_idx,
SONIC_ETHERNET_BP_RE_PATTERN: BaseIdx.ethernet_bp_base_idx,
SONIC_PORTCHANNEL_RE_PATTERN: BaseIdx.portchannel_base_idx,
SONIC_MGMT_PORT_RE_PATTERN: BaseIdx.mgmt_port_base_idx
}
Expand Down