Skip to content

Commit e9628b6

Browse files
authored
Merge pull request sonic-net#64 from judyjoseph/multi_asic_ledd_xcvr
* platform daemon (Xcvrd, Ledd) changes for multi asic platform * Updates in ledd daemon to use namespaces and get the namespace from selector object. * Updates to xcvrd daemon to use the asic_id in talking to the right DB. * Updated based on new sonic-py-common API's * Invoke initializeGlobalConfig() in the SfpUpdate/DomInfoUpdate processes as well.
2 parents 415b8c4 + 710689f commit e9628b6

File tree

2 files changed

+172
-71
lines changed
  • sonic-ledd/scripts
  • sonic-xcvrd/scripts

2 files changed

+172
-71
lines changed

sonic-ledd/scripts/ledd

+31-14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ try:
1010
import sys
1111

1212
from sonic_py_common import daemon_base
13+
from sonic_py_common import multi_asic
14+
from sonic_py_common.interface import backplane_prefix
1315
from swsscommon import swsscommon
1416
except ImportError as e:
1517
raise ImportError (str(e) + " - required module not found")
@@ -35,6 +37,9 @@ SELECT_TIMEOUT = 1000
3537

3638
LEDUTIL_LOAD_ERROR = 1
3739

40+
# The empty namespace refers to linux host namespace.
41+
EMPTY_NAMESPACE = ''
42+
3843
class DaemonLedd(daemon_base.DaemonBase):
3944

4045
# Run daemon
@@ -65,15 +70,24 @@ class DaemonLedd(daemon_base.DaemonBase):
6570
self.log_error("Failed to load ledutil: %s" % (str(e)), True)
6671
sys.exit(LEDUTIL_LOAD_ERROR)
6772

68-
# Open a handle to the Application database
69-
appl_db = daemon_base.db_connect("APPL_DB")
73+
# Load the namespace details first from the database_global.json file.
74+
swsscommon.SonicDBConfig.initializeGlobalConfig()
75+
76+
# Get the namespaces in the platform. For multi-asic devices we get the namespaces
77+
# of front-end ascis which have front-panel interfaces.
78+
namespaces = multi_asic.get_front_end_namespaces()
7079

7180
# Subscribe to PORT table notifications in the Application DB
81+
appl_db, sst = {}, {}
7282
sel = swsscommon.Select()
73-
sst = swsscommon.SubscriberStateTable(appl_db, swsscommon.APP_PORT_TABLE_NAME)
74-
sel.addSelectable(sst)
7583

76-
# Listen indefinitely for changes to the PORT table in the Application DB
84+
for namespace in namespaces:
85+
# Open a handle to the Application database, in all namespaces
86+
appl_db[namespace] = daemon_base.db_connect("APPL_DB", namespace=namespace)
87+
sst[namespace] = swsscommon.SubscriberStateTable(appl_db[namespace], swsscommon.APP_PORT_TABLE_NAME)
88+
sel.addSelectable(sst[namespace])
89+
90+
# Listen indefinitely for changes to the PORT table in the Application DB's
7791
while True:
7892
# Use timeout to prevent ignoring the signals we want to handle
7993
# in signal_handler() (e.g. SIGTERM for graceful shutdown)
@@ -86,17 +100,20 @@ class DaemonLedd(daemon_base.DaemonBase):
86100
self.log_warning("sel.select() did not return swsscommon.Select.OBJECT")
87101
continue
88102

89-
(key, op, fvp) = sst.pop()
90-
91-
# TODO: Once these flag entries have been removed from the DB,
92-
# we can remove this check
93-
if key in ["PortConfigDone", "PortInitDone"]:
94-
continue
103+
# Get the namespace from the selectable object and use it to index the SubscriberStateTable handle.
104+
ns=c.getDbNamespace()
105+
(key, op, fvp) = sst[ns].pop()
106+
if fvp:
107+
# TODO: Once these flag entries have been removed from the DB,
108+
# we can remove this check
109+
if key in ["PortConfigDone", "PortInitDone"]:
110+
continue
95111

96-
fvp_dict = dict(fvp)
112+
fvp_dict = dict(fvp)
97113

98-
if op == "SET" and "oper_status" in fvp_dict:
99-
led_control.port_link_state_change(key, fvp_dict["oper_status"])
114+
if op == "SET" and "oper_status" in fvp_dict:
115+
if not key.startswith(backplane_prefix()):
116+
led_control.port_link_state_change(key, fvp_dict["oper_status"])
100117

101118
return 1
102119

0 commit comments

Comments
 (0)