Skip to content

Commit 981107a

Browse files
ysmanmanjudyjoseph
authored andcommitted
Add VoQ Recirc interface (i.e., Ethernet-Rec) to interface maps for S… (#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.
1 parent 004b9a4 commit 981107a

5 files changed

Lines changed: 45 additions & 3 deletions

File tree

src/sonic_ax_impl/mibs/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ def init_sync_d_interface_tables(db_conn):
276276
if_name_str = if_name
277277
if (re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name_str) or \
278278
re.match(port_util.SONIC_ETHERNET_BP_RE_PATTERN, if_name_str) or \
279-
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name_str)):
279+
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name_str) or \
280+
re.match(port_util.SONIC_ETHERNET_REC_RE_PATTERN, if_name_str)):
280281
if_name_map[if_name] = sai_id
281282
# As sai_id is not unique in multi-asic platform, concatenate it with
282283
# namespace to get a unique key. Assuming that ':' is not present in namespace
@@ -285,7 +286,8 @@ def init_sync_d_interface_tables(db_conn):
285286
for sai_id, if_name in if_id_map_util.items():
286287
if (re.match(port_util.SONIC_ETHERNET_RE_PATTERN, if_name) or \
287288
re.match(port_util.SONIC_ETHERNET_BP_RE_PATTERN, if_name) or \
288-
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name)):
289+
re.match(port_util.SONIC_ETHERNET_IB_RE_PATTERN, if_name) or \
290+
re.match(port_util.SONIC_ETHERNET_REC_RE_PATTERN, if_name)):
289291
if_id_map[get_sai_id_key(db_conn.namespace, sai_id)] = if_name
290292
logger.debug("Port name map:\n" + pprint.pformat(if_name_map, indent=2))
291293
logger.debug("Interface name map:\n" + pprint.pformat(if_id_map, indent=2))

tests/mock_tables/asic0/appl_db.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
"alias": "etp4",
5757
"speed": 100000
5858
},
59+
"PORT_TABLE:Ethernet-IB0": {
60+
"description": "inband",
61+
"alias": "rec0",
62+
"speed": 100000
63+
},
64+
"PORT_TABLE:Ethernet-Rec0": {
65+
"description": "recirc",
66+
"alias": "rec1",
67+
"speed": 100000
68+
},
5969
"ROUTE_TABLE:0.0.0.0/0": {
6070
"ifname": "Ethernet0,Ethernet4",
6171
"nexthop": "10.0.0.1,10.0.0.3"

tests/mock_tables/asic0/config_db.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
"role": "Int",
2828
"speed": 100000
2929
},
30+
"PORT_TABLE:Ethernet-IB0": {
31+
"description": "inband",
32+
"alias": "rec0",
33+
"role": "Inb",
34+
"speed": 100000
35+
},
36+
"PORT_TABLE:Ethernet-Rec0": {
37+
"description": "recirc",
38+
"alias": "rec1",
39+
"role": "Rec",
40+
"speed": 100000
41+
},
3042
"LAG_MEMBER_TABLE:PortChannel01:Ethernet-BP0": {
3143
"status": "enabled"
3244
},

tests/mock_tables/asic0/counters_db.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@
309309
"Ethernet0": "oid:0x1000000000003",
310310
"Ethernet4": "oid:0x1000000000004",
311311
"Ethernet-BP0": "oid:0x1000000000005",
312-
"Ethernet-BP4": "oid:0x1000000000006"
312+
"Ethernet-BP4": "oid:0x1000000000006",
313+
"Ethernet-IB0": "oid:0x1000000000080",
314+
"Ethernet-Rec0": "oid:0x1000000000081"
313315
},
314316
"COUNTERS_LAG_NAME_MAP": {
315317
"PortChannel01": "oid:0x1000000000007"

tests/namespace/test_mibs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
sys.path.insert(0, os.path.join(modules_path, 'src'))
1111

1212
from sonic_ax_impl import mibs
13+
from swsssdk.port_util import BaseIdx
1314

1415
class TestGetNextPDU(TestCase):
1516
@classmethod
@@ -36,6 +37,21 @@ def test_init_namespace_sync_d_lag_tables(self):
3637
self.assertTrue("PortChannel_Temp" in lag_name_if_name_map)
3738
self.assertTrue(lag_name_if_name_map["PortChannel_Temp"] == [])
3839

40+
def test_init_sync_d_interface_tables_for_recirc_ports(self):
41+
db_conn = Namespace.init_namespace_dbs()
42+
43+
if_name_map, \
44+
if_alias_map, \
45+
if_id_map, \
46+
oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, db_conn)
47+
for recirc_port_name, sai_id, intf_alias, intf_id_key, intf_index in [
48+
('Ethernet-IB0', '1000000000080', 'rec0', 'asic0:1000000000080', BaseIdx.ethernet_ib_base_idx),
49+
('Ethernet-Rec0', '1000000000081', 'rec1', 'asic0:1000000000081', BaseIdx.ethernet_rec_base_idx)]:
50+
self.assertTrue(if_name_map[recirc_port_name] == sai_id)
51+
self.assertTrue(if_alias_map[recirc_port_name] == intf_alias)
52+
self.assertTrue(oid_name_map[intf_index] == recirc_port_name)
53+
self.assertTrue(if_id_map[intf_id_key] == recirc_port_name)
54+
3955
@classmethod
4056
def tearDownClass(cls):
4157
tests.mock_tables.dbconnector.clean_up_config()

0 commit comments

Comments
 (0)