44from bisect import bisect_right
55
66from sonic_ax_impl import mibs
7- from sonic_ax_impl import logger
87from sonic_ax_impl .mibs import Namespace
98from ax_interface .mib import MIBMeta , ValueType , MIBUpdater , MIBEntry , SubtreeMIBEntry , OverlayAdpaterMIBEntry , OidMIBEntry
109from ax_interface .encodings import ObjectIdentifier
@@ -50,8 +49,7 @@ class DbTables(int, Enum):
5049class IfTypes (int , Enum ):
5150 """ IANA ifTypes """
5251 ethernetCsmacd = 6
53- l3ipvlan = 136
54- ieee8023adLag = 161
52+ ieee8023adLag = 161
5553
5654class ArpUpdater (MIBUpdater ):
5755 def __init__ (self ):
@@ -159,13 +157,8 @@ def __init__(self):
159157 self .lag_name_if_name_map = {}
160158 self .if_name_lag_name_map = {}
161159 self .oid_lag_name_map = {}
162- self .lag_sai_map = {}
163160 self .mgmt_oid_name_map = {}
164161 self .mgmt_alias_map = {}
165- self .vlan_oid_name_map = {}
166- self .vlan_name_map = {}
167- self .rif_port_map = {}
168- self .port_rif_map = {}
169162
170163 # cache of interface counters
171164 self .if_counters = {}
@@ -175,7 +168,6 @@ def __init__(self):
175168 self .if_id_map = {}
176169 self .oid_sai_map = {}
177170 self .oid_name_map = {}
178- self .rif_counters = {}
179171
180172 def reinit_data (self ):
181173 """
@@ -194,13 +186,6 @@ def reinit_data(self):
194186 self .mgmt_oid_name_map , \
195187 self .mgmt_alias_map = mibs .init_mgmt_interface_tables (self .db_conn [0 ])
196188
197- self .vlan_name_map , \
198- self .vlan_oid_sai_map , \
199- self .vlan_oid_name_map = Namespace .init_namespace_sync_d_vlan_tables (self .db_conn )
200-
201- self .rif_port_map , \
202- self .port_rif_map = Namespace .init_namespace_sync_d_rif_tables (self .db_conn )
203-
204189 def update_data (self ):
205190 """
206191 Update redis (caches config)
@@ -210,24 +195,13 @@ def update_data(self):
210195 {sai_id : Namespace .dbs_get_all (self .db_conn , mibs .COUNTERS_DB , mibs .counter_table (sai_id ), blocking = True )
211196 for sai_id in self .if_id_map }
212197
213- rif_sai_ids = list (self .rif_port_map ) + list (self .vlan_name_map )
214-
215- self .rif_counters = \
216- {sai_id : Namespace .dbs_get_all (self .db_conn , mibs .COUNTERS_DB , mibs .counter_table (sai_id ), blocking = True )
217- for sai_id in rif_sai_ids }
218-
219- if self .rif_counters :
220- self .aggregate_counters ()
221-
222198 self .lag_name_if_name_map , \
223199 self .if_name_lag_name_map , \
224- self .oid_lag_name_map , \
225- self .lag_sai_map = Namespace .init_namespace_sync_d_lag_tables (self .db_conn )
200+ self .oid_lag_name_map = Namespace .init_namespace_sync_d_lag_tables (self .db_conn )
226201
227202 self .if_range = sorted (list (self .oid_sai_map .keys ()) +
228203 list (self .oid_lag_name_map .keys ()) +
229- list (self .mgmt_oid_name_map .keys ()) +
230- list (self .vlan_oid_name_map .keys ()))
204+ list (self .mgmt_oid_name_map .keys ()))
231205 self .if_range = [(i ,) for i in self .if_range ]
232206
233207 def get_next (self , sub_id ):
@@ -271,8 +245,6 @@ def interface_description(self, sub_id):
271245 return self .oid_lag_name_map [oid ]
272246 elif oid in self .mgmt_oid_name_map :
273247 return self .mgmt_alias_map [self .mgmt_oid_name_map [oid ]]
274- elif oid in self .vlan_oid_name_map :
275- return self .vlan_oid_name_map [oid ]
276248
277249 return self .if_alias_map [self .oid_name_map [oid ]]
278250
@@ -282,13 +254,7 @@ def _get_counter(self, oid, table_name):
282254 :param table_name: the redis table (either IntEnum or string literal) to query.
283255 :return: the counter for the respective sub_id/table.
284256 """
285- sai_id = ''
286- if oid in self .oid_sai_map :
287- sai_id = self .oid_sai_map [oid ]
288- elif oid in self .vlan_oid_sai_map :
289- sai_id = self .vlan_oid_sai_map [oid ]
290- else :
291- logger .warning ("Unexpected oid {}" .format (oid ))
257+ sai_id = self .oid_sai_map [oid ]
292258 # Enum.name or table_name = 'name_of_the_table'
293259 _table_name = bytes (getattr (table_name , 'name' , table_name ), 'utf-8' )
294260
@@ -302,29 +268,6 @@ def _get_counter(self, oid, table_name):
302268 mibs .logger .warning ("SyncD 'COUNTERS_DB' missing attribute '{}'." .format (e ))
303269 return None
304270
305- def aggregate_counters (self ):
306- """
307- For ports with l3 router interfaces l3 drops may be counted separately (RIF counters)
308- add l3 drops to l2 drop counters cache according to mapping
309-
310- For l3vlan map l3 counters to l2 counters
311- """
312- for rif_sai_id , port_sai_id in self .rif_port_map .items ():
313- if port_sai_id in self .if_id_map :
314- for port_counter_name , rif_counter_name in mibs .RIF_DROPS_AGGR_MAP .items ():
315- self .if_counters [port_sai_id ][port_counter_name ] = \
316- int (self .if_counters [port_sai_id ][port_counter_name ]) + \
317- int (self .rif_counters [rif_sai_id ][rif_counter_name ])
318-
319- for vlan_sai_id in self .vlan_name_map :
320- for port_counter_name , rif_counter_name in mibs .RIF_COUNTERS_AGGR_MAP .items ():
321- try :
322- self .if_counters .setdefault (vlan_sai_id , {})
323- self .if_counters [vlan_sai_id ][port_counter_name ] = \
324- int (self .rif_counters [vlan_sai_id ][rif_counter_name ])
325- except KeyError as e :
326- logger .warning ("Not able to aggregate counters for {}: {}\n {}" .format (vlan_sai_id , rif_counter_name , e ))
327-
328271 def get_counter (self , sub_id , table_name ):
329272 """
330273 :param sub_id: The 1-based sub-identifier query.
@@ -344,13 +287,7 @@ def get_counter(self, sub_id, table_name):
344287 counter_value = 0
345288 for lag_member in self .lag_name_if_name_map [self .oid_lag_name_map [oid ]]:
346289 counter_value += self ._get_counter (mibs .get_index (lag_member ), table_name )
347- sai_lag_id = self .lag_sai_map [self .oid_lag_name_map [oid ]]
348- sai_lag_rif_id = self .port_rif_map [sai_lag_id ]
349- if sai_lag_rif_id in self .rif_port_map :
350- table_name = bytes (getattr (table_name , 'name' , table_name ), 'utf-8' )
351- if table_name in mibs .RIF_DROPS_AGGR_MAP :
352- rif_table_name = mibs .RIF_DROPS_AGGR_MAP [table_name ]
353- counter_value += int (self .rif_counters [sai_lag_rif_id ][rif_table_name ])
290+
354291 # truncate to 32-bit counter
355292 return counter_value & 0x00000000ffffffff
356293 else :
@@ -380,8 +317,6 @@ def _get_if_entry(self, sub_id):
380317 elif oid in self .mgmt_oid_name_map :
381318 if_table = mibs .mgmt_if_entry_table (self .mgmt_oid_name_map [oid ])
382319 db = mibs .CONFIG_DB
383- elif oid in self .vlan_oid_name_map :
384- if_table = mibs .vlan_entry_table (self .vlan_oid_name_map [oid ])
385320 elif oid in self .oid_name_map :
386321 if_table = mibs .if_entry_table (self .oid_name_map [oid ])
387322 else :
@@ -486,7 +421,6 @@ def get_if_type(self, sub_id):
486421
487422 ethernetCsmacd(6), -- for all ethernet-like interfaces,
488423 -- regardless of speed, as per RFC3635
489- l3ipvlan(136) -- Layer 3 Virtual LAN using IP
490424 ieee8023adLag(161) -- IEEE 802.3ad Link Aggregate
491425 """
492426 oid = self .get_oid (sub_id )
@@ -495,8 +429,6 @@ def get_if_type(self, sub_id):
495429
496430 if oid in self .oid_lag_name_map :
497431 return IfTypes .ieee8023adLag
498- elif oid in self .vlan_oid_name_map :
499- return IfTypes .l3ipvlan
500432 else :
501433 return IfTypes .ethernetCsmacd
502434
0 commit comments