Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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'
Expand All @@ -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)
38 changes: 19 additions & 19 deletions tests/test_pfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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)

Expand All @@ -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]
Expand All @@ -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