Skip to content

Commit

Permalink
Use AsciiDoc include directive, and fix up some cross-references Also…
Browse files Browse the repository at this point in the history
… use [appendix] marker on all appendices.

Signed-off-by: Andy Fingerhut <[email protected]>
  • Loading branch information
jafingerhut committed Nov 5, 2024
1 parent bed5dab commit 4c5dfed
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 1,084 deletions.
991 changes: 67 additions & 924 deletions p4-16/psa/PSA.adoc

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions p4-16/psa/examples/psa-example-clone-to-port.p4
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ struct fwd_metadata_t {
bit<32> outport;
}

// BEGIN:Clone_Example_Part1
// tag::Clone_Example_Part1[]
header clone_i2e_metadata_t {
bit<8> custom_tag;
EthernetAddress srcAddr;
}
// END:Clone_Example_Part1
// end::Clone_Example_Part1[]

struct empty_metadata_t {
}
Expand Down Expand Up @@ -108,7 +108,7 @@ parser IngressParserImpl(
}
}

// BEGIN:Clone_Example_Part2
// tag::Clone_Example_Part2[]
control ingress(inout headers hdr,
inout metadata user_meta,
in psa_ingress_input_metadata_t istd,
Expand All @@ -130,7 +130,7 @@ control ingress(inout headers hdr,
t.apply();
}
}
// END:Clone_Example_Part2
// end::Clone_Example_Part2[]

parser EgressParserImpl(
packet_in buffer,
Expand Down Expand Up @@ -176,7 +176,7 @@ control DeparserImpl(packet_out packet, inout headers hdr) {
}
}

// BEGIN:Clone_Example_Part3
// tag::Clone_Example_Part3[]
control IngressDeparserImpl(
packet_out packet,
out clone_i2e_metadata_t clone_i2e_meta,
Expand All @@ -199,7 +199,7 @@ control IngressDeparserImpl(
common_deparser.apply(packet, hdr);
}
}
// END:Clone_Example_Part3
// end::Clone_Example_Part3[]

control EgressDeparserImpl(
packet_out packet,
Expand Down
12 changes: 6 additions & 6 deletions p4-16/psa/examples/psa-example-counters.p4
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct metadata {
fwd_metadata_t fwd_metadata;
}

// BEGIN:Counter_Example_Part1
// tag::Counter_Example_Part1[]
typedef bit<48> ByteCounter_t;
typedef bit<32> PacketCounter_t;
typedef bit<80> PacketByteCounter_t;
Expand All @@ -69,7 +69,7 @@ struct headers {
ethernet_t ethernet;
ipv4_t ipv4;
}
// END:Counter_Example_Part1
// end::Counter_Example_Part1[]

parser CommonParser(packet_in buffer,
out headers parsed_hdr,
Expand Down Expand Up @@ -124,7 +124,7 @@ parser EgressParserImpl(
}
}

// BEGIN:Counter_Example_Part2
// tag::Counter_Example_Part2[]
control ingress(inout headers hdr,
inout metadata user_meta,
in psa_ingress_input_metadata_t istd,
Expand Down Expand Up @@ -176,7 +176,7 @@ control egress(inout headers hdr,
port_bytes_out.count(istd.egress_port);
}
}
// END:Counter_Example_Part2
// end::Counter_Example_Part2[]

control CommonDeparserImpl(packet_out packet,
inout headers hdr)
Expand Down Expand Up @@ -217,7 +217,7 @@ control EgressDeparserImpl(
}
}

// BEGIN:Package_Instantiation_Example
// tag::Package_Instantiation_Example[]
IngressPipeline(IngressParserImpl(),
ingress(),
IngressDeparserImpl()) ip;
Expand All @@ -227,4 +227,4 @@ EgressPipeline(EgressParserImpl(),
EgressDeparserImpl()) ep;

PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main;
// END:Package_Instantiation_Example
// end::Package_Instantiation_Example[]
12 changes: 6 additions & 6 deletions p4-16/psa/examples/psa-example-digest.p4
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct headers {
struct empty_metadata_t {
}

// BEGIN:Digest_Example_Part1
// tag::Digest_Example_Part1[]
struct mac_learn_digest_t {
EthernetAddress srcAddr;
PortId_t ingress_port;
Expand All @@ -73,7 +73,7 @@ struct metadata {
bool send_mac_learn_msg;
mac_learn_digest_t mac_learn_msg;
}
// END:Digest_Example_Part1
// end::Digest_Example_Part1[]

parser CommonParser(
packet_in buffer,
Expand Down Expand Up @@ -135,7 +135,7 @@ parser EgressParserImpl(packet_in buffer,
}
}

// BEGIN:Digest_Example_Part2
// tag::Digest_Example_Part2[]
// This is part of the functionality of a typical Ethernet learning bridge.

// The control plane will typically enter the _same_ keys into the
Expand Down Expand Up @@ -187,7 +187,7 @@ control ingress(inout headers hdr,
l2_tbl.apply();
}
}
// END:Digest_Example_Part2
// end::Digest_Example_Part2[]

control egress(inout headers hdr,
inout metadata meta,
Expand All @@ -207,7 +207,7 @@ control CommonDeparserImpl(packet_out packet,
}
}

// BEGIN:Digest_Example_Part3
// tag::Digest_Example_Part3[]
control IngressDeparserImpl(packet_out packet,
out empty_metadata_t clone_i2e_meta,
out empty_metadata_t resubmit_meta,
Expand All @@ -225,7 +225,7 @@ control IngressDeparserImpl(packet_out packet,
common_deparser.apply(packet, hdr);
}
}
// END:Digest_Example_Part3
// end::Digest_Example_Part3[]

control EgressDeparserImpl(packet_out packet,
out empty_metadata_t clone_e2e_meta,
Expand Down
8 changes: 4 additions & 4 deletions p4-16/psa/examples/psa-example-incremental-checksum.p4
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ parser IngressParserImpl(packet_in buffer,
}
}

// BEGIN:Incremental_Checksum_Table
// tag::Incremental_Checksum_Table[]
control ingress(inout headers hdr,
inout metadata user_meta,
in psa_ingress_input_metadata_t istd,
Expand All @@ -142,7 +142,7 @@ control ingress(inout headers hdr,
}
}
}
// END:Incremental_Checksum_Table
// end::Incremental_Checksum_Table[]

parser EgressParserImpl(packet_in buffer,
out headers parsed_hdr,
Expand Down Expand Up @@ -180,7 +180,7 @@ control IngressDeparserImpl(packet_out packet,
}
}

// BEGIN:Incremental_Checksum_Example
// tag::Incremental_Checksum_Example[]
control EgressDeparserImpl(packet_out packet,
out empty_metadata_t clone_e2e_meta,
out empty_metadata_t recirculate_meta,
Expand Down Expand Up @@ -228,7 +228,7 @@ control EgressDeparserImpl(packet_out packet,
packet.emit(hdr.tcp);
}
}
// END:Incremental_Checksum_Example
// end::Incremental_Checksum_Example[]

IngressPipeline(IngressParserImpl(),
ingress(),
Expand Down
12 changes: 6 additions & 6 deletions p4-16/psa/examples/psa-example-incremental-checksum2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ error {
BadIPv4HeaderChecksum
}

// BEGIN:Incremental_Checksum_Parser
// tag::Incremental_Checksum_Parser[]
parser IngressParserImpl(packet_in buffer,
out headers hdr,
inout metadata user_meta,
Expand Down Expand Up @@ -203,7 +203,7 @@ parser IngressParserImpl(packet_in buffer,
transition accept;
}
}
// END:Incremental_Checksum_Parser
// end::Incremental_Checksum_Parser[]

// Note 1: regarding parser state parse_ipv4

Expand Down Expand Up @@ -286,7 +286,7 @@ parser IngressParserImpl(packet_in buffer,
// deparser code to recognize and handle this case.


// BEGIN:Incremental_Checksum_Table
// tag::Incremental_Checksum_Table[]
control ingress(inout headers hdr,
inout metadata user_meta,
in psa_ingress_input_metadata_t istd,
Expand Down Expand Up @@ -324,7 +324,7 @@ control ingress(inout headers hdr,
}
}
}
// END:Incremental_Checksum_Table
// end::Incremental_Checksum_Table[]

parser EgressParserImpl(packet_in buffer,
out headers parsed_hdr,
Expand Down Expand Up @@ -364,7 +364,7 @@ control IngressDeparserImpl(packet_out packet,
}
}

// BEGIN:Incremental_Checksum_Example
// tag::Incremental_Checksum_Example[]
control EgressDeparserImpl(packet_out packet,
out empty_metadata_t clone_e2e_meta,
out empty_metadata_t recirculate_meta,
Expand Down Expand Up @@ -450,7 +450,7 @@ control EgressDeparserImpl(packet_out packet,
packet.emit(hdr.udp);
}
}
// END:Incremental_Checksum_Example
// end::Incremental_Checksum_Example[]

IngressPipeline(IngressParserImpl(),
ingress(),
Expand Down
8 changes: 4 additions & 4 deletions p4-16/psa/examples/psa-example-parser-checksum.p4
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct headers {
}


// BEGIN:Parse_Error_Example
// tag::Parse_Error_Example[]
// Define additional error values, one of them for packets with
// incorrect IPv4 header checksums.
error {
Expand Down Expand Up @@ -194,7 +194,7 @@ control ingress(inout headers hdr,
// Do normal packet processing here.
}
}
// END:Parse_Error_Example
// end::Parse_Error_Example[]

parser EgressParserImpl(packet_in buffer,
out headers hdr,
Expand Down Expand Up @@ -232,7 +232,7 @@ control IngressDeparserImpl(packet_out packet,
}
}

// BEGIN:Compute_New_IPv4_Checksum_Example
// tag::Compute_New_IPv4_Checksum_Example[]
control EgressDeparserImpl(packet_out packet,
out empty_metadata_t clone_e2e_meta,
out empty_metadata_t recirculate_meta,
Expand Down Expand Up @@ -260,7 +260,7 @@ control EgressDeparserImpl(packet_out packet,
packet.emit(hdr.tcp);
}
}
// END:Compute_New_IPv4_Checksum_Example
// end::Compute_New_IPv4_Checksum_Example[]

IngressPipeline(IngressParserImpl(),
ingress(),
Expand Down
4 changes: 2 additions & 2 deletions p4-16/psa/examples/psa-example-parser-error-handling.p4
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct empty_metadata_t {
struct fwd_metadata_t {
}

// BEGIN:PortId_Annotation_Example
// tag::PortId_Annotation_Example[]
header to_cpu_error_header_t {
bit<8> error_idx;
bit<1> ingress;
Expand All @@ -187,7 +187,7 @@ header to_cpu_error_header_t {
// propagate to all variables of these types.
PortIdInHeader_t port;
}
// END:PortId_Annotation_Example
// end::PortId_Annotation_Example[]

enum CloneReason_t {
NONE,
Expand Down
4 changes: 2 additions & 2 deletions p4-16/psa/examples/psa-example-parser-error-handling2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct empty_metadata_t {
struct fwd_metadata_t {
}

// BEGIN:PortId_Annotation_Example
// tag::PortId_Annotation_Example[]
header to_cpu_error_header_t {
bit<8> error_idx;
bit<1> ingress;
Expand All @@ -187,7 +187,7 @@ header to_cpu_error_header_t {
// propagate to all variables of these types.
PortIdInHeader_t port;
}
// END:PortId_Annotation_Example
// end::PortId_Annotation_Example[]

enum CloneReason_t {
NONE,
Expand Down
8 changes: 4 additions & 4 deletions p4-16/psa/examples/psa-example-register1.p4
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct headers {
ipv4_t ipv4;
}

// BEGIN:Register_Example1_Part1
// tag::Register_Example1_Part1[]
const bit<32> NUM_PORTS = 512;

typedef bit<48> ByteCounter_t;
Expand All @@ -80,7 +80,7 @@ action update_pkt_ip_byte_count (inout PacketByteCountState_t s,
s.pkt_count = s.pkt_count + 1;
s.byte_count = s.byte_count + (ByteCounter_t) ip_length_bytes;
}
// END:Register_Example1_Part1
// end::Register_Example1_Part1[]

parser IngressParserImpl(packet_in buffer,
out headers parsed_hdr,
Expand All @@ -105,7 +105,7 @@ parser IngressParserImpl(packet_in buffer,
}
}

// BEGIN:Register_Example1_Part2
// tag::Register_Example1_Part2[]
control ingress(inout headers hdr,
inout metadata user_meta,
in psa_ingress_input_metadata_t istd,
Expand All @@ -126,7 +126,7 @@ control ingress(inout headers hdr,
}
}
}
// END:Register_Example1_Part2
// end::Register_Example1_Part2[]

parser EgressParserImpl(packet_in buffer,
out headers parsed_hdr,
Expand Down
8 changes: 4 additions & 4 deletions p4-16/psa/examples/psa-example-register2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct headers {
ipv4_t ipv4;
}

// BEGIN:Register_Example2_Part1
// tag::Register_Example2_Part1[]
const bit<32> NUM_PORTS = 512;

// It would be more convenient to use a struct type to represent the
Expand Down Expand Up @@ -92,7 +92,7 @@ action update_pkt_ip_byte_count (inout PacketByteCountState_t s,
s[BYTE_COUNT_RANGE] = (s[BYTE_COUNT_RANGE] +
(bit<BYTE_COUNT_WIDTH>) ip_length_bytes);
}
// END:Register_Example2_Part1
// end::Register_Example2_Part1[]

parser IngressParserImpl(packet_in buffer,
out headers parsed_hdr,
Expand All @@ -117,7 +117,7 @@ parser IngressParserImpl(packet_in buffer,
}
}

// BEGIN:Register_Example2_Part2
// tag::Register_Example2_Part2[]
control ingress(inout headers hdr,
inout metadata user_meta,
in psa_ingress_input_metadata_t istd,
Expand All @@ -138,7 +138,7 @@ control ingress(inout headers hdr,
}
}
}
// END:Register_Example2_Part2
// end::Register_Example2_Part2[]

parser EgressParserImpl(packet_in buffer,
out headers parsed_hdr,
Expand Down
Loading

0 comments on commit 4c5dfed

Please sign in to comment.