-
Notifications
You must be signed in to change notification settings - Fork 4
/
makefile.esnet
167 lines (141 loc) · 8.04 KB
/
makefile.esnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Configure project paths
PROJ_ROOT := $(CURDIR)
include $(PROJ_ROOT)/config.mk
BOARD ?= au280
BUILD_NAME ?= open-nic-ci
vanilla_build_name = vanilla
open_nic_build = $(ONS_ROOT)/build/$(BOARD)_$(BUILD_NAME)
plugin_dir = ../../src/open-nic-plugin
APP_ROOT ?= $(PROJ_ROOT)/src/p4_app
ARTIFACTS_DIR ?= $(APP_ROOT)/artifacts
ARTIFACTS_BUILD_DIR ?= $(ARTIFACTS_DIR)/$(BUILD_NAME)
vanilla_build_dir = $(ONS_ROOT)/build/$(BOARD)_$(vanilla_build_name)
artifact_dir = $(open_nic_build)/$(BUILD_NAME)/esnet-smartnic-hwapi
bitfile_dir = $(artifact_dir)/bitfiles
CI_PIPELINE_ID ?= $(shell date +"%s")
bitstream_userid ?= $(shell printf "0x%08x" $(CI_PIPELINE_ID))
bitstream_usr_access ?= $(bitstream_userid)
IMPL_STRATEGY ?= "Vivado Implementation Defaults"
jobs ?= 32
max_pkt_len ?= 9100
vivado_tclargs = -board $(BOARD) -jobs $(jobs) -tag $(BUILD_NAME) -num_phys_func 2 -num_cmac_port 2 -num_queue 512 \
-bitstream_userid $(bitstream_userid) -bitstream_usr_access $(bitstream_usr_access) -max_pkt_len $(max_pkt_len) \
-impl_strategy {$(IMPL_STRATEGY)}
VALIDATE_WNS_MIN ?= 0
VALIDATE_TNS_MIN ?= 0
help :
@echo "make init_open_nic_build -- Invoke this to create a shell build with build_name = $(open_nic_build)"
echo_vars:
@echo " PROJ_ROOT: $(PROJ_ROOT)"
@echo " APP_ROOT: $(APP_ROOT)"
@echo " BOARD: $(BOARD)"
@echo " BUILD_NAME: $(BUILD_NAME)"
@echo "ARTIFACTS_BUILD_DIR: $(ARTIFACTS_BUILD_DIR)"
@echo " max_pkt_len: $(max_pkt_len)"
@echo " jobs: $(jobs)"
# Include targets for config validation
# - checks Vivado version
# - checks that licenses are available for IP, where required
# - checks that required command-line utilities are available in path
include $(SCRIPTS_ROOT)/Makefiles/config.mk
# ------------------------------------------------
# This set of commands are dedicated to CI builds
# ------------------------------------------------
ci_build : ci_build_vanilla unpackage_vanilla bitfile package
@echo "Final artifact is ready"
ci_build_vanilla : $(vanilla_artifact)
@echo "Vanilla artifact is ready"
$(vanilla_artifact) : vanilla_bitfile package_vanilla
# -------------------------------------------------------------------
# These commands can be used selectively outside the CI environment
# -------------------------------------------------------------------
package_vanilla :
@echo "Packaging artifact from vanilla build"
@( cd $(vanilla_build_dir) && \
tar czf vanilla_artifact.tar.gz vivado_ip \
)
unpackage_vanilla :
@echo "Unpacking artifact from vanilla build"
@mkdir -p $(open_nic_build)
@tar xzf $(vanilla_build_dir)/vanilla_artifact.tar.gz -C $(open_nic_build)
package :
@echo "Packaging artifact from top level build"
@echo $(artifact_dir)
@mkdir -p $(artifact_dir)
@mkdir -p $(artifact_dir)/firmware
@mkdir -p $(artifact_dir)/libvitisnetp4drv
@mkdir -p $(artifact_dir)/regmap/spec
@mkdir -p $(artifact_dir)/wireshark/plugins
if [ -e $(APP_ROOT)/app_if/smartnic_app_drv.tar ]; then \
mkdir -p $(artifact_dir)/libvitisnetp4drv/vitisnetp4_igr; \
tar xf $(APP_ROOT)/app_if/smartnic_app_drv.tar -C $(artifact_dir)/libvitisnetp4drv/vitisnetp4_igr; \
cp $(APP_ROOT)/app_if/smartnic_app.p4 $(artifact_dir)/firmware/esnet-smartnic-igr.p4; \
fi
if [ -e $(APP_ROOT)/app_if/smartnic_app_igr_drv.tar ]; then \
mkdir -p $(artifact_dir)/libvitisnetp4drv/vitisnetp4_igr; \
tar xf $(APP_ROOT)/app_if/smartnic_app_igr_drv.tar -C $(artifact_dir)/libvitisnetp4drv/vitisnetp4_igr; \
cp $(APP_ROOT)/app_if/smartnic_app_igr.p4 $(artifact_dir)/firmware/esnet-smartnic-igr.p4; \
fi
if [ -e $(APP_ROOT)/app_if/smartnic_app_egr_drv.tar ]; then \
mkdir -p $(artifact_dir)/libvitisnetp4drv/vitisnetp4_egr; \
tar xf $(APP_ROOT)/app_if/smartnic_app_egr_drv.tar -C $(artifact_dir)/libvitisnetp4drv/vitisnetp4_egr; \
cp $(APP_ROOT)/app_if/smartnic_app_egr.p4 $(artifact_dir)/firmware/esnet-smartnic-egr.p4; \
fi
-@cp $(APP_ROOT)/app_if/*.lua $(artifact_dir)/wireshark/plugins
@echo "The wireshark/plugins directory is a placeholder for wireshark .lua files," > $(artifact_dir)/wireshark/plugins/README.md
@echo "which can be used to decode custom protocol headers defined in the .p4 file." >> $(artifact_dir)/wireshark/plugins/README.md
@cp -r $(ONS_ROOT)/regmap/spec/* $(artifact_dir)/regmap/spec
@cp .out/$(BOARD)/smartnic/regio/ir/smartnic_decoder-ir.yaml $(artifact_dir)/regmap/spec/box1_322mhz_decoder.yaml
@cp .out/$(BOARD)/smartnic_250mhz/regio/ir/smartnic_250mhz_decoder-ir.yaml $(artifact_dir)/regmap/spec/box0_250mhz_decoder.yaml
@$(REGIO_ROOT)/regio-elaborate \
--file-type top \
--include-dir $(artifact_dir)/regmap/spec \
--output-file $(artifact_dir)/regmap/esnet-smartnic-top-ir.yaml \
$(artifact_dir)/regmap/spec/esnet-smartnic-top.yaml
@cp $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell.bit $(artifact_dir)/firmware/esnet-smartnic.bit
@cp $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell.mcs $(artifact_dir)/firmware/esnet-smartnic.mcs
-@cp $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/*.ltx $(artifact_dir)/firmware
-@cp $(open_nic_build)/build_summary.json $(artifact_dir)/firmware
@mkdir -p $(ARTIFACTS_BUILD_DIR)
@( cd $(artifact_dir)/.. && \
echo "packing artifact zip file artifacts.$(BOARD).$(BUILD_NAME).0.zip" && \
zip -r $(ARTIFACTS_BUILD_DIR)/artifacts.$(BOARD).$(BUILD_NAME).0.zip esnet-smartnic-hwapi \
)
project : config_check
@echo "Creating top level project with no compiles ( fast compile )"
( cd $(ONS_ROOT)/script && \
vivado -mode batch -source build.tcl -tclargs -synth_ip 0 -impl 0 -sim 0 -user_plugin $(plugin_dir) $(vivado_tclargs) \
)
project_ip : config_check
@echo "Creating top level project with compiled IP ( medium fast compile )"
( cd $(ONS_ROOT)/script && \
vivado -mode batch -source build.tcl -tclargs -synth_ip 1 -impl 0 -sim 0 $(vivado_tclargs) \
)
bitfile : config_check
@echo "Creating top level project with bitfile ( slow compile )"
( cd $(ONS_ROOT)/script && \
vivado -mode batch -source build.tcl -tclargs -synth_ip 1 -impl 1 -post_impl 1 -sim 0 -user_plugin $(plugin_dir) $(vivado_tclargs) -rebuild 1 \
)
@ test -e $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell.bit || (echo ERROR: bitfile not produced. && false)
vanilla_bitfile : config_check
@echo "Creating vanilla bitfile"
( cd $(ONS_ROOT)/script && \
vivado -mode batch -source build.tcl -tclargs -synth_ip 1 -impl 1 -post_impl 1 -sim 0 -rebuild 1 -board $(BOARD) -num_phys_func 2 -num_cmac_port 2 -num_queue 512 \
-bitstream_userid $(bitstream_userid) -bitstream_usr_access $(bitstream_usr_access) -tag $(BUILD_NAME) \
)
@ test -e $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell.bit || (echo ERROR: bitfile not produced. && false)
mkdir vanilla_artifact
cp $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell.mcs vanilla_artifact
cp $(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell.bit vanilla_artifact
validate_build:
@# Summarize timing report (use post-route phys-opted report if available)
@PHYS_OPT_REPORT=$(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell_timing_summary_postroute_physopted.rpt; \
ROUTE_REPORT=$(open_nic_build)/open_nic_shell/open_nic_shell.runs/impl_1/open_nic_shell_timing_summary_routed.rpt; \
if [ -e $$PHYS_OPT_REPORT ]; then REPORT=$$PHYS_OPT_REPORT; else REPORT=$$ROUTE_REPORT; fi; \
$(SCRIPTS_ROOT)/vivado/gen_summary.py $$REPORT --build-name $(BOARD)_$(BUILD_NAME) --summary-json-file $(open_nic_build)/build_summary.json
@# Check timing against specified thresholds; generate JUnit XML file as output
@$(SCRIPTS_ROOT)/vivado/check_timing.py $(open_nic_build)/build_summary.json --junit-xml-file $(open_nic_build)/build_summary.xml \
--wns-min $(VALIDATE_WNS_MIN) --tns-min $(VALIDATE_TNS_MIN)
clean_build:
@rm -rf $(open_nic_build)
.PHONY : ci_build_vanilla ci_build_bitfile vanilla_bitfile package_vanilla unpackage_vanilla bitfile package clean_build