Skip to content

Commit

Permalink
[Multiasic]: Add calculation of interface index for backplane interfa…
Browse files Browse the repository at this point in the history
…ces (sonic-net#68)

* [Multiasic]: Add calculation of infterface index for backplane
interfaces in multi asic platform. Multiasic platform will have
backplane interface names of the format Ethernet-BP<x>.

Signed-off-by: SuvarnaMeenakshi <[email protected]>

* Added comment.

Signed-off-by: SuvarnaMeenakshi <[email protected]>
  • Loading branch information
SuvarnaMeenakshi authored May 5, 2020
1 parent b9cee36 commit 581add1
Showing 1 changed file with 9 additions and 0 deletions.
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+)$"
SONIC_PORTCHANNEL_RE_PATTERN = "^PortChannel(\d+)$"
SONIC_MGMT_PORT_RE_PATTERN = "^eth(\d+)$"


class BaseIdx:
ethernet_base_idx = 1
ethernet_bp_base_idx = 9000
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

0 comments on commit 581add1

Please sign in to comment.