net/ice/base: increase maximum TCAM/PTG per profile
[dpdk.git] / examples / pipeline / examples / selector.spec
1 ; SPDX-License-Identifier: BSD-3-Clause
2 ; Copyright(c) 2020 Intel Corporation
3
4 ; A selector table is made out of groups of weighted members, with a given member potentially part
5 ; of several groups. The select operation returns a member ID by first selecting a group based on an
6 ; input group ID and then selecting a member within that group by hashing one or several input
7 ; header or meta-data fields. It is very useful for implementing an Equal-Cost Multi-Path (ECMP) or
8 ; Weighted-Cost Multi-Path (WCMP) enabled FIB or a load balancer. It is part of the action selector
9 ; construct described by the P4 Portable Switch Architecture (PSA) specification.
10 ;
11 ; Normally, an action selector FIB is built with a routing table (the base table), a selector table
12 ; (the group table) and a next hop table (the member table). One of the routing table actions sets
13 ; up the group ID meta-data field used as the index into the group table, which produces the member
14 ; ID meta-data field, i.e. the next hop ID that is used as the index into the next hop table. The
15 ; next hop action prepares the output packet for being sent next hop in the network by prepending
16 ; one or several headers to the packet (Ethernet at the very least), decrementing the TTL and
17 ; recomputing the IPv4 checksum, etc. The selector allows for multiple next hops to be specified
18 ; for any given route as opposed to a single next hop per route; for every packet, its next hop is
19 ; picked out of the set of next hops defined for the route while preserving the packet ordering
20 ; within the flow, with the flow defined by the selector n-tuple fields.
21 ;
22 ; In this simple example, the base table and the member table are striped out in order to focus
23 ; exclusively on illustrating the selector table. The group_id is read from the destination MAC
24 ; address and the selector n-tuple is represented by the Protocol, the source IP address and the
25 ; destination IP address fields. The member_id produced by the selector table is used to identify
26 ; the output port which facilitates the testing of different member weights by simply comparing the
27 ; rates of output packets sent on different ports.
28
29 //
30 // Headers
31 //
32 struct ethernet_h {
33         bit<48> dst_addr
34         bit<48> src_addr
35         bit<16> ethertype
36 }
37
38 struct ipv4_h {
39         bit<8> ver_ihl
40         bit<8> diffserv
41         bit<16> total_len
42         bit<16> identification
43         bit<16> flags_offset
44         bit<8> ttl
45         bit<8> protocol
46         bit<16> hdr_checksum
47         bit<32> src_addr
48         bit<32> dst_addr
49 }
50
51 header ethernet instanceof ethernet_h
52 header ipv4 instanceof ipv4_h
53
54 //
55 // Meta-data
56 //
57 struct metadata_t {
58         bit<32> port_in
59         bit<32> port_out
60         bit<32> group_id
61 }
62
63 metadata instanceof metadata_t
64
65 //
66 // Selectors.
67 //
68 selector s {
69         group_id m.group_id
70
71         selector {
72                 h.ipv4.protocol
73                 h.ipv4.src_addr
74                 h.ipv4.dst_addr
75         }
76
77         member_id m.port_out
78
79         n_groups_max 64
80         n_members_per_group_max 16
81 }
82
83 //
84 // Pipeline.
85 //
86 apply {
87         rx m.port_in
88         extract h.ethernet
89         extract h.ipv4
90         mov m.group_id h.ethernet.dst_addr
91         table s
92         emit h.ethernet
93         emit h.ipv4
94         tx m.port_out
95 }