diff --git a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py index 0600c55aa8..ffab68bde2 100644 --- a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py +++ b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py @@ -94,7 +94,7 @@ def _get_counter(self, oid, counter_name): try: counter_value = self.if_counters[sai_id][_counter_name] - counter_value = int(counter_value) & 0x00000000ffffffff + counter_value = int(counter_value) & 0xffffffffffffffff # done! return counter_value except KeyError as e: @@ -146,16 +146,16 @@ def cpfc_if_indications(self, sub_id): class PfcPrioUpdater(PfcUpdater): def __init__(self): super().__init__() - self.min_prio = 1 - self.max_prio = 8 + self.min_prio = 0 + self.max_prio = 7 def queue_index(self, sub_id): """ - :param sub_id: The 1-based sub-identifier query. + :param sub_id: The 0-based sub-identifier query. :return: the 0-based interface ID. """ if len(sub_id) >= 2: - return sub_id[1] - 1 + return sub_id[1] return None def get_next(self, sub_id): @@ -186,7 +186,7 @@ def get_next(self, sub_id): def requests_per_priority(self, sub_id): """ - :param sub_id: The 1-based sub-identifier query. + :param sub_id: The 0-based sub-identifier query. :return: the counter for the respective sub_id/table. """ port_oid = '' @@ -216,7 +216,7 @@ def requests_per_priority(self, sub_id): def indications_per_priority(self, sub_id): """ - :param sub_id: The 1-based sub-identifier query. + :param sub_id: The 0-based sub-identifier query. :return: the counter for the respective sub_id/table. """ port_oid = '' @@ -254,10 +254,10 @@ class cpfcIfTable(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.813.1.1'): pfc_updater = PfcUpdater() ifRequests = \ - SubtreeMIBEntry('1.1', pfc_updater, ValueType.INTEGER, pfc_updater.cpfc_if_requests) + SubtreeMIBEntry('1.1', pfc_updater, ValueType.COUNTER_64, pfc_updater.cpfc_if_requests) ifIndications = \ - SubtreeMIBEntry('1.2', pfc_updater, ValueType.INTEGER, pfc_updater.cpfc_if_indications) + SubtreeMIBEntry('1.2', pfc_updater, ValueType.COUNTER_64, pfc_updater.cpfc_if_indications) # cpfcIfPriorityTable = '1.2' @@ -269,7 +269,7 @@ class cpfcIfPriorityTable(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.813.1.2'): pfc_updater = PfcPrioUpdater() prioRequests = \ - SubtreeMIBEntry('1.2', pfc_updater, ValueType.INTEGER, pfc_updater.requests_per_priority) + SubtreeMIBEntry('1.2', pfc_updater, ValueType.COUNTER_64, pfc_updater.requests_per_priority) prioIndications = \ - SubtreeMIBEntry('1.3', pfc_updater, ValueType.INTEGER, pfc_updater.indications_per_priority) + SubtreeMIBEntry('1.3', pfc_updater, ValueType.COUNTER_64, pfc_updater.indications_per_priority) diff --git a/tests/test_pfc.py b/tests/test_pfc.py index 6b617e74e6..bac7c2921f 100644 --- a/tests/test_pfc.py +++ b/tests/test_pfc.py @@ -43,7 +43,7 @@ def test_getPduRequestForPort(self): print(response) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(oid)) self.assertEqual(value0.data, 4) @@ -62,7 +62,7 @@ def test_getNextPduRequestForPort(self): n = len(response.values) print('values = ' + str(n)) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(expected_oid)) self.assertEqual(value0.data, 4) @@ -78,7 +78,7 @@ def test_getPduIndicationForPort(self): print(response) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(oid)) self.assertEqual(value0.data, 4) @@ -97,12 +97,12 @@ def test_getNextPduindicationForPort(self): n = len(response.values) print('values = ' + str(n)) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(expected_oid)) self.assertEqual(value0.data, 4) def test_getPduRequestForPriority(self): - oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 1)) + oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 0)) get_pdu = GetPDU( header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), oids=[oid] @@ -113,13 +113,13 @@ def test_getPduRequestForPriority(self): print(response) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(oid)) - self.assertEqual(value0.data, 209347219842134092490 % pow(2, 32)) # Test integer truncation + self.assertEqual(value0.data, 209347219842134092490 % pow(2, 64)) # Test integer truncation def test_getNextPduRequestForPriority(self): - oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 2)) - expected_oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 3)) + oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 1)) + expected_oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 2)) get_pdu = GetNextPDU( header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), oids=[oid] @@ -132,12 +132,12 @@ def test_getNextPduRequestForPriority(self): n = len(response.values) print('values = ' + str(n)) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(expected_oid)) self.assertEqual(value0.data, 3) def test_getPduIndicationForPriority(self): - oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 3, 5, 1)) + oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 3, 5, 0)) get_pdu = GetPDU( header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), oids=[oid] @@ -148,13 +148,13 @@ def test_getPduIndicationForPriority(self): print(response) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(oid)) self.assertEqual(value0.data, 1) def test_getNextPduindicationForPriority(self): - oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 3, 1, 1)) - expected_oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 3, 1, 2)) + oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 3, 1, 0)) + expected_oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 3, 1, 1)) get_pdu = GetNextPDU( header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), oids=[oid] @@ -167,7 +167,7 @@ def test_getNextPduindicationForPriority(self): n = len(response.values) print('values = ' + str(n)) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(expected_oid)) self.assertEqual(value0.data, 2) @@ -184,13 +184,13 @@ def test_getPfcSubtree(self): response = get_pdu.make_response(self.lut_port) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(expected_oid)) self.assertEqual(value0.data, 4) # Subtree for Priority oid = ObjectIdentifier(33, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2)) - expected_oid = ObjectIdentifier(33, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 1)) + expected_oid = ObjectIdentifier(33, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1, 2, 1, 2, 1, 0)) get_pdu = GetNextPDU( header=PDUHeader(1, PduTypes.GET_NEXT, 16, 0, 42, 0, 0, 0), oids=[oid] @@ -200,6 +200,6 @@ def test_getPfcSubtree(self): response = get_pdu.make_response(self.lut_prio) value0 = response.values[0] - self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.type_, ValueType.COUNTER_64) self.assertEqual(str(value0.name), str(expected_oid)) - self.assertEqual(value0.data, 209347219842134092490 % pow(2, 32)) # Test integer truncation + self.assertEqual(value0.data, 209347219842134092490 % pow(2, 64)) # Test integer truncation