Skip to content

Commit

Permalink
Reuse metadata types for pna.p4
Browse files Browse the repository at this point in the history
Signed-off-by: Bili Dong <qobilidop@gmail.com>
  • Loading branch information
qobilidop committed Jun 24, 2024
1 parent 16cc2dd commit 5ad47eb
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 199 deletions.
80 changes: 1 addition & 79 deletions p4include/dpdk/pna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -554,85 +554,7 @@ enum PNA_Direction_t {
HOST_TO_NET
}

// BEGIN:Metadata_types
enum PNA_PacketPath_t {
// TBD if this type remains, whether it should be an enum or
// several separate fields representing the same cases in a
// different form.
FROM_NET_PORT,
FROM_NET_LOOPEDBACK,
FROM_NET_RECIRCULATED,
FROM_HOST,
FROM_HOST_LOOPEDBACK,
FROM_HOST_RECIRCULATED
}

struct pna_pre_input_metadata_t {
PortId_t input_port;
ParserError_t parser_error;
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
}

struct pna_pre_output_metadata_t {
bool decrypt; // TBD: or use said==0 to mean no decrypt?

// The following things are stored internally within the decrypt
// block, in a table indexed by said:

// + The decryption algorithm, e.g. AES256, etc.
// + The decryption key
// + Any read-modify-write state in the data plane used to
// implement anti-replay attack detection.

SecurityAssocId_t said;
bit<16> decrypt_start_offset; // in bytes?

// TBD whether it is important to explicitly pass information to a
// decryption extern in a way visible to a P4 program about where
// headers were parsed and found. An alternative is to assume
// that the architecture saves the pre parser results somewhere,
// in a way not visible to the P4 program.
}

struct pna_main_parser_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
// If this packet has direction NET_TO_HOST, input_port contains
// the id of the network port on which the packet arrived.
// If this packet has direction HOST_TO_NET, input_port contains
// the id of the vport from which the packet came
PortId_t input_port; // network port id
}

struct pna_main_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
Timestamp_t timestamp;
ParserError_t parser_error;
ClassOfService_t class_of_service;
// See comments for field input_port in struct
// pna_main_parser_input_metadata_t
PortId_t input_port;
}

// BEGIN:Metadata_main_output
struct pna_main_output_metadata_t {
// common fields used by the architecture to decide what to do with
// the packet next, after the main parser, control, and deparser
// have finished executing one pass, regardless of the direction.
ClassOfService_t class_of_service; // 0
}
// END:Metadata_main_output
// END:Metadata_types

#include <pna/v0_5/types_metadata.p4>

// The following extern functions are "forwarding" functions -- they
// all set the destination of the packet. Calling one of them
Expand Down
80 changes: 1 addition & 79 deletions p4include/pna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -480,85 +480,7 @@ enum PNA_Direction_t {
HOST_TO_NET
}

// BEGIN:Metadata_types
enum PNA_PacketPath_t {
// TBD if this type remains, whether it should be an enum or
// several separate fields representing the same cases in a
// different form.
FROM_NET_PORT,
FROM_NET_LOOPEDBACK,
FROM_NET_RECIRCULATED,
FROM_HOST,
FROM_HOST_LOOPEDBACK,
FROM_HOST_RECIRCULATED
}

struct pna_pre_input_metadata_t {
PortId_t input_port;
ParserError_t parser_error;
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
}

struct pna_pre_output_metadata_t {
bool decrypt; // TBD: or use said==0 to mean no decrypt?

// The following things are stored internally within the decrypt
// block, in a table indexed by said:

// + The decryption algorithm, e.g. AES256, etc.
// + The decryption key
// + Any read-modify-write state in the data plane used to
// implement anti-replay attack detection.

SecurityAssocId_t said;
bit<16> decrypt_start_offset; // in bytes?

// TBD whether it is important to explicitly pass information to a
// decryption extern in a way visible to a P4 program about where
// headers were parsed and found. An alternative is to assume
// that the architecture saves the pre parser results somewhere,
// in a way not visible to the P4 program.
}

struct pna_main_parser_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
// If this packet has direction NET_TO_HOST, input_port contains
// the id of the network port on which the packet arrived.
// If this packet has direction HOST_TO_NET, input_port contains
// the id of the vport from which the packet came
PortId_t input_port; // network port id
}

struct pna_main_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
Timestamp_t timestamp;
ParserError_t parser_error;
ClassOfService_t class_of_service;
// See comments for field input_port in struct
// pna_main_parser_input_metadata_t
PortId_t input_port;
}

// BEGIN:Metadata_main_output
struct pna_main_output_metadata_t {
// common fields used by the architecture to decide what to do with
// the packet next, after the main parser, control, and deparser
// have finished executing one pass, regardless of the direction.
ClassOfService_t class_of_service; // 0
}
// END:Metadata_main_output
// END:Metadata_types

#include <pna/v0_5/types_metadata.p4>

// The following extern functions are "forwarding" functions -- they
// all set the destination of the packet. Calling one of them
Expand Down
78 changes: 78 additions & 0 deletions p4include/pna/v0_5/types_metadata.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// BEGIN:Metadata_types
enum PNA_PacketPath_t {
// TBD if this type remains, whether it should be an enum or
// several separate fields representing the same cases in a
// different form.
FROM_NET_PORT,
FROM_NET_LOOPEDBACK,
FROM_NET_RECIRCULATED,
FROM_HOST,
FROM_HOST_LOOPEDBACK,
FROM_HOST_RECIRCULATED
}

struct pna_pre_input_metadata_t {
PortId_t input_port;
ParserError_t parser_error;
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
}

struct pna_pre_output_metadata_t {
bool decrypt; // TBD: or use said==0 to mean no decrypt?

// The following things are stored internally within the decrypt
// block, in a table indexed by said:

// + The decryption algorithm, e.g. AES256, etc.
// + The decryption key
// + Any read-modify-write state in the data plane used to
// implement anti-replay attack detection.

SecurityAssocId_t said;
bit<16> decrypt_start_offset; // in bytes?

// TBD whether it is important to explicitly pass information to a
// decryption extern in a way visible to a P4 program about where
// headers were parsed and found. An alternative is to assume
// that the architecture saves the pre parser results somewhere,
// in a way not visible to the P4 program.
}

struct pna_main_parser_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
// If this packet has direction NET_TO_HOST, input_port contains
// the id of the network port on which the packet arrived.
// If this packet has direction HOST_TO_NET, input_port contains
// the id of the vport from which the packet came
PortId_t input_port; // network port id
}

struct pna_main_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
PNA_Direction_t direction;
PassNumber_t pass;
bool loopedback;
Timestamp_t timestamp;
ParserError_t parser_error;
ClassOfService_t class_of_service;
// See comments for field input_port in struct
// pna_main_parser_input_metadata_t
PortId_t input_port;
}

// BEGIN:Metadata_main_output
struct pna_main_output_metadata_t {
// common fields used by the architecture to decide what to do with
// the packet next, after the main parser, control, and deparser
// have finished executing one pass, regardless of the direction.
ClassOfService_t class_of_service; // 0
}
// END:Metadata_main_output
// END:Metadata_types
41 changes: 41 additions & 0 deletions p4include/pna/v0_7/types_metadata.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// BEGIN:Metadata_types

struct pna_main_parser_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
bool recirculated;
// If this packet has FROM_NET source, input_port contains
// the id of the network port on which the packet arrived.
// If this packet has FROM_HOST source, input_port contains
// the id of the vport from which the packet came
PortId_t input_port; // network/host port id
}

// is_host_port(p) returns true if p is a host port, otherwise false.
extern bool is_host_port (in PortId_t p);

// is_net_port(p) returns true if p is a network port, otherwise
// false.
extern bool is_net_port (in PortId_t p);

struct pna_main_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
bool recirculated;
Timestamp_t timestamp;
ParserError_t parser_error;
ClassOfService_t class_of_service;
// See comments for field input_port in struct
// pna_main_parser_input_metadata_t
PortId_t input_port;
}

// BEGIN:Metadata_main_output
struct pna_main_output_metadata_t {
// common fields used by the architecture to decide what to do with
// the packet next, after the main parser, control, and deparser
// have finished executing one pass, regardless of the direction.
ClassOfService_t class_of_service; // 0
}
// END:Metadata_main_output
// END:Metadata_types
42 changes: 1 addition & 41 deletions p4include/tc/pna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -563,47 +563,7 @@ enum PNA_Source_t {
FROM_NET
}

// BEGIN:Metadata_types

struct pna_main_parser_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
bool recirculated;
// If this packet has FROM_NET source, input_port contains
// the id of the network port on which the packet arrived.
// If this packet has FROM_HOST source, input_port contains
// the id of the vport from which the packet came
PortId_t input_port; // network/host port id
}

// is_host_port(p) returns true if p is a host port, otherwise false.
extern bool is_host_port (in PortId_t p);

// is_net_port(p) returns true if p is a network port, otherwise
// false.
extern bool is_net_port (in PortId_t p);

struct pna_main_input_metadata_t {
// common fields initialized for all packets that are input to main
// parser, regardless of direction.
bool recirculated;
Timestamp_t timestamp;
ParserError_t parser_error;
ClassOfService_t class_of_service;
// See comments for field input_port in struct
// pna_main_parser_input_metadata_t
PortId_t input_port;
}

// BEGIN:Metadata_main_output
struct pna_main_output_metadata_t {
// common fields used by the architecture to decide what to do with
// the packet next, after the main parser, control, and deparser
// have finished executing one pass, regardless of the direction.
ClassOfService_t class_of_service; // 0
}
// END:Metadata_main_output
// END:Metadata_types
#include <pna/v0_7/types_metadata.p4>

// The following extern functions are "forwarding" functions -- they
// all set the destination of the packet. Calling one of them
Expand Down

0 comments on commit 5ad47eb

Please sign in to comment.