Skip to content

Commit

Permalink
fix array index bug in python control mgr
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonch committed Jun 27, 2024
1 parent 07dd60f commit f3828d0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/tofino/controldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# 3/20/23: all keys are strings, get entry method, array set and get functions in Controller
# 3/21/23: table_install and table_get functions in Controller
# 4/26/23: added pktgen support, boolean fields
# 6/27/24: fixed array get index bug

# helper for globals.json: given a node from globals.json, resolve
# name of a lucid global to a P4 object
Expand Down Expand Up @@ -130,17 +131,19 @@ def array_set(self, array_id, idx, val):
be the fully qualified array name, i.e., as defined in the
bfrt.json file. """
dprint ("[array_set] %s[%s] = %s"%(array_id, idx, val))
key = {"$REGISTER_INDEX":idx}
arr = self.tables[array_id]
arr.add_entry(idx, None, val)
arr.add_entry(key, None, val)

def array_get(self, array_id, idx):
""" get array_id[idx] from all pipes. array_id must
be the fully qualified array name, i.e., as defined in the
bfrt.json file. Return value is a list, with one value
from each pipeline """
arr = self.tables[array_id]
key = {"$REGISTER_INDEX":idx}
# output will be (None [because no action], {"f1"=[...]})
_, vals = arr.get_entry(idx)
_, vals = arr.get_entry(key)
vals = list(vals.values())
return vals

Expand Down

0 comments on commit f3828d0

Please sign in to comment.