Skip to content

Commit

Permalink
Add VoQ Recirc interface (i.e., Ethernet-Rec) to interface maps for S… (
Browse files Browse the repository at this point in the history
#244)

- What I did

VoQ inband port support was added in #228. This PR is to add support for VoQ recirc port.

This PR depends sonic-net/sonic-py-swsssdk#118, which defines index for VoQ recirc port.
  • Loading branch information
ysmanman authored and judyjoseph committed May 8, 2022
1 parent 004b9a4 commit 981107a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ def init_sync_d_interface_tables(db_conn):
if_name_str = if_name
if (re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name_str) or \
re.match(port_util.SONIC_ETHERNET_BP_RE_PATTERN, if_name_str) or \
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name_str)):
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name_str) or \
re.match(port_util.SONIC_ETHERNET_REC_RE_PATTERN, if_name_str)):
if_name_map[if_name] = sai_id
# As sai_id is not unique in multi-asic platform, concatenate it with
# namespace to get a unique key. Assuming that ':' is not present in namespace
Expand All @@ -285,7 +286,8 @@ def init_sync_d_interface_tables(db_conn):
for sai_id, if_name in if_id_map_util.items():
if (re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name) or \
re.match(port_util.SONIC_ETHERNET_BP_RE_PATTERN, if_name) or \
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name)):
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name) or \
re.match(port_util.SONIC_ETHERNET_REC_RE_PATTERN, if_name)):
if_id_map[get_sai_id_key(db_conn.namespace, sai_id)] = if_name
logger.debug("Port name map:\n" + pprint.pformat(if_name_map, indent=2))
logger.debug("Interface name map:\n" + pprint.pformat(if_id_map, indent=2))
Expand Down
10 changes: 10 additions & 0 deletions tests/mock_tables/asic0/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
"alias": "etp4",
"speed": 100000
},
"PORT_TABLE:Ethernet-IB0": {
"description": "inband",
"alias": "rec0",
"speed": 100000
},
"PORT_TABLE:Ethernet-Rec0": {
"description": "recirc",
"alias": "rec1",
"speed": 100000
},
"ROUTE_TABLE:0.0.0.0/0": {
"ifname": "Ethernet0,Ethernet4",
"nexthop": "10.0.0.1,10.0.0.3"
Expand Down
12 changes: 12 additions & 0 deletions tests/mock_tables/asic0/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
"role": "Int",
"speed": 100000
},
"PORT_TABLE:Ethernet-IB0": {
"description": "inband",
"alias": "rec0",
"role": "Inb",
"speed": 100000
},
"PORT_TABLE:Ethernet-Rec0": {
"description": "recirc",
"alias": "rec1",
"role": "Rec",
"speed": 100000
},
"LAG_MEMBER_TABLE:PortChannel01:Ethernet-BP0": {
"status": "enabled"
},
Expand Down
4 changes: 3 additions & 1 deletion tests/mock_tables/asic0/counters_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@
"Ethernet0": "oid:0x1000000000003",
"Ethernet4": "oid:0x1000000000004",
"Ethernet-BP0": "oid:0x1000000000005",
"Ethernet-BP4": "oid:0x1000000000006"
"Ethernet-BP4": "oid:0x1000000000006",
"Ethernet-IB0": "oid:0x1000000000080",
"Ethernet-Rec0": "oid:0x1000000000081"
},
"COUNTERS_LAG_NAME_MAP": {
"PortChannel01": "oid:0x1000000000007"
Expand Down
16 changes: 16 additions & 0 deletions tests/namespace/test_mibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
sys.path.insert(0, os.path.join(modules_path, 'src'))

from sonic_ax_impl import mibs
from swsssdk.port_util import BaseIdx

class TestGetNextPDU(TestCase):
@classmethod
Expand All @@ -36,6 +37,21 @@ def test_init_namespace_sync_d_lag_tables(self):
self.assertTrue("PortChannel_Temp" in lag_name_if_name_map)
self.assertTrue(lag_name_if_name_map["PortChannel_Temp"] == [])

def test_init_sync_d_interface_tables_for_recirc_ports(self):
db_conn = Namespace.init_namespace_dbs()

if_name_map, \
if_alias_map, \
if_id_map, \
oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, db_conn)
for recirc_port_name, sai_id, intf_alias, intf_id_key, intf_index in [
('Ethernet-IB0', '1000000000080', 'rec0', 'asic0:1000000000080', BaseIdx.ethernet_ib_base_idx),
('Ethernet-Rec0', '1000000000081', 'rec1', 'asic0:1000000000081', BaseIdx.ethernet_rec_base_idx)]:
self.assertTrue(if_name_map[recirc_port_name] == sai_id)
self.assertTrue(if_alias_map[recirc_port_name] == intf_alias)
self.assertTrue(oid_name_map[intf_index] == recirc_port_name)
self.assertTrue(if_id_map[intf_id_key] == recirc_port_name)

@classmethod
def tearDownClass(cls):
tests.mock_tables.dbconnector.clean_up_config()

0 comments on commit 981107a

Please sign in to comment.