1 .. _p4plugin-dev-guide:
3 P4 Plugin Developer Guide
4 =========================
11 - Responsible for device connection, interface resource collection, and
12 providing gRPC server information to P4Runtime client.
16 - Implements a gRPC client, more precisely a P4Runtime client, that provides
17 several RPCs for users at runtime.
18 - Supports setting and retrieving forwarding pipeline configuration
19 dynamically; adding or removing multiple devices; setting up a controller
20 cluster; adding, modifying, or deleting table entries; adding, modifying,
21 or deleting action profile members, adding, modifying, or deleting action
22 profile groups, and setting packet-in/packet-out.
28 The sections below give details about the configuration settings for
29 the components that can be configured.
37 - p4plugin/adapter/netconf-adapter/api/src/main/yang/p4plugin-netconf-adapter-api.yang
41 - Write the collecting interface resource to inventory data store.
45 - Acquire the interface resource from inventory data store.
54 - p4plugin/runtime/api/src/main/yang/p4plugin-device.yang
58 - Add a P4 device. Users need to provide node ID, device ID, gRPC server
59 address, configuration file path, and runtime file path as input.
61 In the following scenario, users must catch and handle the exception:
62 If node ID or P4 target address (device ID and gRPC server address)
63 already exists, parsing the configuration file and runtime file causes
64 an exception, such as IOException.
68 - Remove a P4 device from local list.
72 - Query how many devices are there currently, and return a list that
75 - **connect-to-device**
77 - Open the stream channel, which is for packet-in and packet-out, and
78 send master arbitration update message right after the stream
79 channel is created. The returned value is the connection state.
81 - **set-pipeline-config**
83 - Set forwarding pipeline configuration to a specific device through the
84 gRPC channel, and input the node ID associated with the device.
86 - **get-pipeline-config**
88 - Get forwarding pipeline configuration, input the node ID associated,
89 and return a string that is the content of the runtime file.
92 - p4plugin/core/api/src/main/yang/p4plugin-runtime.yang
96 - Add entry to a specific device. Users must provide parameters such as
97 table name; action name and action parameters; match field name and
98 match field value; and so on. The node ID must also be provided.
100 - **modify-table-entry**
102 - Modify an existing entry to a specific device. The parameters are
103 the same as the ``add-table-entry`` method.
105 - **delete-table-entry**
107 - Delete an existing entry from a specific device. When deleting entries,
108 users only need to provide table name and match field information;
109 no action information is required.
111 - **add-action-profile-member**
113 - Add a member to a profile. User must provide member ID.
115 - **modify-action-profile-member**
117 - Modify a member that already exists in a profile.
119 - **delete-action-profile-member**
121 - Delete a member that already exists in a profile.
123 - **add-action-profile-group**
125 - Add a group to a profile.
127 - **modify-action-profile-group**
129 - Modify a group that already exists in a profile.
131 - **delete-action-profile-group**
133 - Delete a group that already exists in a profile.
135 - **read-table-entry**
137 - Read an entry from a specific device, input node ID, and table name;
138 and output a JSON string. The returned value is Base64 encoded.
140 - **read-action-profile-member**
142 - Read the members of an action profile, input node ID, and action
143 profile name; and output a JSON string. The returned value is Base64
146 - **read-action-profile-group**
148 - Read the action profile groups of an action profile, input node ID
149 and action profile name; and output a JSON string. The returned value
153 - p4plugin/core/api/src/main/yang/p4plugin-packet.yang
155 - **p4-transmit-packet**
157 - Transmit a packet to a specific P4 device.
159 - **p4-packet-received**
161 - Receive a packet from P4 device.
164 - p4plugin/core/api/src/main/yang/p4plugin-cluster.yang
166 - **set-election-id**
168 - Set the election ID. For more information about the election IDs and
169 and their meaning, refer to the following URL:
170 https://github.com/p4lang/PI/blob/dc2f4c6cce86e310055677c8b18831fd8f6d1f2c/proto/docs/arbitration.md
172 When a new election ID is set, it sends master arbitration update
173 messages to all devices it connected.
175 - **get-election-id**
177 - Get current election ID.
180 Sample Configurations
181 ---------------------
186 **REST API** : *POST /restconf/operations/p4plugin-netconf-adapter-api:write-inventory*
202 **REST API** : *POST /restconf/operations/p4plugin-device:add-device*
211 "config-file-path": "/home/opendaylight/p4lang/behavioral-model/mininet/simple_router.json",
212 "runtime-file-path": "/home/opendaylight/p4lang/behavioral-model/mininet/simple_router.proto.txt",
214 "ip": "10.42.94.144",
223 **REST API** : *POST /restconf/operations/p4plugin-device:connect-to-device*
236 4. Set pipeline config
237 ~~~~~~~~~~~~~~~~~~~~~~
239 **REST API** : *POST /restconf/operations/p4plugin-device:set-pipeline-config*
254 **REST API** : *POST /restconf/operations/p4plugin-runtime:add-table-entry*
262 "action-name": "set_nhop",
265 "param-name": "nhop_ipv4",
266 "param-value": "10.0.0.10"
269 "param-name": "port",
274 "controller-metadata": "0",
275 "table-name": "ipv4_lpm",
278 "field-name": "ipv4.dstAddr",
279 "lpm-value": "10.0.0.0",
290 **REST API** : *POST /restconf/operations/p4plugin-runtime:read-table-entry*
298 "table-name": "ipv4_lpm",