Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience functions to generated p4info code #508

Merged
merged 34 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
513b0ae
* make consts private
Feb 21, 2022
7791972
Refactor
Feb 21, 2022
3480521
Merge branch 'master' of github.com:omec-project/upf-epc into improve…
Feb 21, 2022
20d29bd
Refactor
Feb 21, 2022
bb18deb
Refactor
Feb 21, 2022
c24ac19
Refactor
Feb 21, 2022
2fe9a22
Refactor. Make list builder and map builder independent using differe…
Feb 21, 2022
e8d7cf1
Add CI verification step
Feb 21, 2022
295e7ce
Refactor workflow
Feb 22, 2022
793f29c
Make maps and slices immutable
Feb 22, 2022
28d8850
Refactor workflow
Feb 22, 2022
9bf4dfd
Merge branch 'master' into improve-gen-p4
Feb 23, 2022
bc1db35
Refactor. Fix case in autogenerated const names
Feb 23, 2022
fadbc9b
Merge branch 'improve-gen-p4' of github.com:EmanueleGallone/upf-epc i…
Feb 23, 2022
0f4509f
Merge branch 'master' into improve-gen-p4
EmanueleGallone Feb 24, 2022
0e53516
Add interpreter to evaluate script output
Feb 24, 2022
3c9cec0
Split generator in multiple functions
Feb 24, 2022
aa536e9
Add test for constants and table generation
Feb 24, 2022
10c76c3
Refactor
Feb 24, 2022
8c2c393
Refactor
Feb 24, 2022
0dbebe1
Add generate Tables test
Feb 24, 2022
66bd763
Refactor
Feb 24, 2022
598219a
Add dummy action
Feb 24, 2022
e31c2f7
Refactor. One big table driven test
Feb 24, 2022
16c4da6
Refactor
Feb 24, 2022
d25c1aa
Add direct and indirect counters
Feb 25, 2022
f14adcd
Merge branch 'master' of github.com:omec-project/upf-epc into improve…
Feb 25, 2022
dc262e4
Add scripts folder when running tests and sync with latest changes
Feb 25, 2022
c6d5bf2
Merge branch 'master' into improve-gen-p4
EmanueleGallone Feb 25, 2022
393ba4a
Cleanup
pudelkoM Feb 25, 2022
4fd1181
Merge branch 'improve-gen-p4' of https://github.com/EmanueleGallone/u…
pudelkoM Feb 25, 2022
92cdb77
Merge branch 'master' into improve-gen-p4
Feb 26, 2022
2da4ab3
Add copyright header
Feb 28, 2022
332f252
Merge branch 'master' of github.com:omec-project/upf-epc into improve…
Feb 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ jobs:
- name: Show all CI changes
run: |
git --no-pager diff
# Verify P4 constants
- name: Build P4 constants
id: check
run: |
make p4-constants
git update-index --refresh

# Build again and commit
- name: Build the BESS-UPF Docker image (after format)
Expand Down
170 changes: 164 additions & 6 deletions internal/p4constants/p4constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package p4constants

//noinspection GoSnakeCaseUsage
const (

// HeaderFields
HdrPreQosPipeRoutingRoutesV4dstPrefix uint32 = 1
HdrPreQosPipeAclAclsinport uint32 = 1
Expand Down Expand Up @@ -101,8 +99,10 @@ const (
ActionParamPreQosPipeLoadTunnelParamdstAddr uint32 = 2
ActionParamPreQosPipeLoadTunnelParamsport uint32 = 3
pudelkoM marked this conversation as resolved.
Show resolved Hide resolved
// IndirectCounters
CounterPreQosPipePreQosCounter uint32 = 315693181
CounterPostQosPipePostQosCounter uint32 = 302958180
CounterPreQosPipePreQosCounter uint32 = 315693181
CounterSizePreQosPipePreQosCounter uint64 = 1024
CounterPostQosPipePostQosCounter uint32 = 302958180
CounterSizePostQosPipePostQosCounter uint64 = 1024
// DirectCounters
DirectCounterAcls uint32 = 325583051
// ActionProfiles
Expand All @@ -111,6 +111,164 @@ const (
PacketMetaPacketOut uint32 = 75327753
PacketMetaPacketIn uint32 = 80671331
// Meters
MeterPreQosPipeAppMeter uint32 = 338231090
MeterPreQosPipeSessionMeter uint32 = 347593234
MeterPreQosPipeAppMeter uint32 = 338231090
MeterSizePreQosPipeAppMeter uint64 = 1024
MeterPreQosPipeSessionMeter uint32 = 347593234
MeterSizePreQosPipeSessionMeter uint64 = 1024
)

func GetTableIDToNameMap() map[uint32]string {
return map[uint32]string{
39015874: "PreQosPipe.Routing.routes_v4",
47204971: "PreQosPipe.Acl.acls",
40931612: "PreQosPipe.my_station",
33923840: "PreQosPipe.interfaces",
44976597: "PreQosPipe.sessions_uplink",
34742049: "PreQosPipe.sessions_downlink",
37595532: "PreQosPipe.terminations_uplink",
34778590: "PreQosPipe.terminations_downlink",
46868458: "PreQosPipe.applications",
49497304: "PreQosPipe.tunnel_peers",
}
}

func GetActionIDToNameMap() map[uint32]string {
return map[uint32]string{
21257015: "NoAction",
31448256: "PreQosPipe.Routing.drop",
23965128: "PreQosPipe.Routing.route",
30494847: "PreQosPipe.Acl.set_port",
26495283: "PreQosPipe.Acl.punt",
21596798: "PreQosPipe.Acl.clone_to_cpu",
18812293: "PreQosPipe.Acl.drop",
23766285: "PreQosPipe._initialize_metadata",
26090030: "PreQosPipe.set_source_iface",
28401267: "PreQosPipe.do_drop",
19461580: "PreQosPipe.set_session_uplink",
22196934: "PreQosPipe.set_session_uplink_drop",
21848329: "PreQosPipe.set_session_downlink",
20229579: "PreQosPipe.set_session_downlink_drop",
20249483: "PreQosPipe.set_session_downlink_buff",
21760615: "PreQosPipe.uplink_term_fwd_no_tc",
28305359: "PreQosPipe.uplink_term_fwd",
20977365: "PreQosPipe.uplink_term_drop",
26185804: "PreQosPipe.downlink_term_fwd_no_tc",
32699713: "PreQosPipe.downlink_term_fwd",
31264233: "PreQosPipe.downlink_term_drop",
23010411: "PreQosPipe.set_app_id",
32742981: "PreQosPipe.load_tunnel_param",
29247910: "PreQosPipe.do_gtpu_tunnel",
31713420: "PreQosPipe.do_gtpu_tunnel_with_psc",
}
}

func GetCounterIDToNameMap() map[uint32]string {
return map[uint32]string{
315693181: "PreQosPipe.pre_qos_counter",
302958180: "PostQosPipe.post_qos_counter",
}
}

func GetDirectCounterIDToNameMap() map[uint32]string {
return map[uint32]string{
325583051: "acls",
}
}

func GetActionProfileIDToNameMap() map[uint32]string {
return map[uint32]string{
297808402: "hashed_selector",
}
}

func GetPacketMetadataIDToNameMap() map[uint32]string {
return map[uint32]string{
75327753: "packet_out",
80671331: "packet_in",
}
}

func GetMeterIDToNameMap() map[uint32]string {
return map[uint32]string{
338231090: "PreQosPipe.app_meter",
347593234: "PreQosPipe.session_meter",
}
}

func GetTableIDList() []uint32 {
return []uint32{
39015874,
47204971,
40931612,
33923840,
44976597,
34742049,
37595532,
34778590,
46868458,
49497304,
}
}

func GetActionIDList() []uint32 {
return []uint32{
21257015,
31448256,
23965128,
30494847,
26495283,
21596798,
18812293,
23766285,
26090030,
28401267,
19461580,
22196934,
21848329,
20229579,
20249483,
21760615,
28305359,
20977365,
26185804,
32699713,
31264233,
23010411,
32742981,
29247910,
31713420,
}
}

func GetCounterIDList() []uint32 {
return []uint32{
315693181,
302958180,
}
}

func GetDirectCounterIDList() []uint32 {
return []uint32{
325583051,
}
}

func GetActionProfileIDList() []uint32 {
return []uint32{
297808402,
}
}

func GetPacketMetadataIDList() []uint32 {
return []uint32{
75327753,
80671331,
}
}

func GetMeterIDList() []uint32 {
return []uint32{
338231090,
347593234,
}
}