[parser] top-level action declarations (and out/inout write-back on action calls)

Đang mở
#279 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
compilers

Hướng nghiên cứu

Start in p4/src/parser.rs at the top-level parser arm and parse_action, then inspect codegen/rust/src/statement.rs where lvalue arguments are cloned. Trace existing action parsing and code generation tests to find how top-level declarations and parameter write-back are covered. Done means top-level actions parse and out/inout mutations are reflected at call sites.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

This issue stems from oxidecomputer/sidecar-lite#152, where the IPv4 TTL decrement plus RFC 1624 incremental checksum update had to be copy-pasted into three P4 controls (router, NAT ingress, and mcast decap). In the review, @rcgoodfellow asked for a top-level action (declared once, called from each control). However, x4c does not support this today, so I was stuck with using a control ipv4_ttl_decrement(inout ipv4_h ip) with a TODO pointing here.

Two things block this fix in sidecar-lite (at aa0d3c8):

  1. The parser has no top-level action arm. The keyword falls through _ => {}, without an error, and parse_action is only reachable from inside a control body.

  2. Even once top-level actions can be parsed, an action call wouldn't write out/inout arguments back as is. When codegen'ed, the Rust output .clone()s every lvalue argument before the call, meaning that mutations inside the action exist only on the copy. Actions mutating hdr/metadata work currently because the control's own parameters are passed through by reference first. This clone only becomes an issue for an action's declared parameters.

Ngôn ngữ chính
Rust
Star
140
Fork
14
Merge trung bình
3 ngày 18 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của oxidecomputer/p4

Tất cả issue của oxidecomputer/p4

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.