Skip to content

Commit

Permalink
Add a flag to enable bf-asm for open-p4studio (#5056)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkotikal authored Dec 9, 2024
1 parent 9d97cb5 commit 650af7e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
18 changes: 11 additions & 7 deletions backends/tofino/bf-p4c/driver/barefoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ def checkEnv():


# Search the environment for assets
# if os.environ['P4C_BUILD_TYPE'] == "DEVELOPER":
# bfas = find_file('bf-asm', 'bfas')
# else:
# bfas = find_file(os.environ['P4C_BIN_DIR'], 'bfas')
enable_bf_asm = os.getenv("ENABLE_BF_ASM")

bfrt_schema = find_file(os.environ['P4C_BIN_DIR'], 'bfrt_schema.py')
p4c_gen_conf = find_file(os.environ['P4C_BIN_DIR'], 'p4c-gen-conf')
if enable_bf_asm:
if os.environ['P4C_BUILD_TYPE'] == "DEVELOPER":
bfas = find_file('bf-asm', 'bfas')
else:
bfas = find_file(os.environ['P4C_BIN_DIR'], 'bfas')

bfrt_schema = find_file(os.environ['P4C_BIN_DIR'], 'bfrt_schema.py')
p4c_gen_conf = find_file(os.environ['P4C_BIN_DIR'], 'p4c-gen-conf')


class BarefootBackend(BackendDriver):
Expand Down Expand Up @@ -112,7 +115,8 @@ def __init__(self, target, arch, argParser):
self.add_command('preclean-runtime', 'rm')
self.add_command('preprocessor', 'cc')
self.add_command('compiler', os.path.join(os.environ['P4C_BIN_DIR'], 'p4c-barefoot'))
# self.add_command('assembler', bfas)
if enable_bf_asm:
self.add_command('assembler', bfas)
self.add_command('bf-rt-verifier', bfrt_schema)
self.add_command('p4c-gen-conf', p4c_gen_conf)
self.add_command('cleaner', 'rm')
Expand Down
4 changes: 3 additions & 1 deletion backends/tofino/bf-p4c/driver/p4c.tofino.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from p4c_src.driver import BackendDriver
import p4c_src.barefoot as bfn

enable_bf_asm = os.getenv("ENABLE_BF_ASM")

class TofinoBackend(bfn.BarefootBackend):
def __init__(self, target, arch, argParser):
Expand All @@ -26,7 +27,8 @@ class TofinoBackend(bfn.BarefootBackend):
# command options
self.config_preprocessor("__TARGET_TOFINO__=1")
self.config_compiler("__TARGET_TOFINO__=1")
# self.config_assembler("tofino")
if enable_bf_asm:
self.config_assembler("tofino")

# Tofino Native Architecture
tna_target = TofinoBackend('tofino', 'tna', argParser)
Expand Down
5 changes: 4 additions & 1 deletion backends/tofino/bf-p4c/driver/p4c.tofino2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Tofino2Variants = {
'tofino2' : 1
}

enable_bf_asm = os.getenv("ENABLE_BF_ASM")

class Tofino2Backend(bfn.BarefootBackend):
def __init__(self, target, arch, argParser):
bfn.BarefootBackend.__init__(self, target, arch, argParser)
Expand All @@ -35,7 +37,8 @@ class Tofino2Backend(bfn.BarefootBackend):
self.config_preprocessor("__TOFINO2_VARIANT__={}".format(Tofino2Variants[target]))
self.config_compiler("__TARGET_TOFINO__=2")
self.config_compiler("__TOFINO2_VARIANT__={}".format(Tofino2Variants[target]))
# self.config_assembler(target)
if enable_bf_asm:
self.config_assembler(target)

for t in Tofino2Variants.keys():
config.target.append(Tofino2Backend(t, 't2na', argParser))
Expand Down

0 comments on commit 650af7e

Please sign in to comment.