1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2020 Intel Corporation 3 */ 4 #ifndef __INCLUDE_RTE_SWX_PIPELINE_H__ 5 #define __INCLUDE_RTE_SWX_PIPELINE_H__ 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 /** 12 * @file 13 * RTE SWX Pipeline 14 */ 15 16 #include <stddef.h> 17 #include <stdint.h> 18 19 #include <rte_compat.h> 20 21 #include "rte_swx_port.h" 22 #include "rte_swx_table.h" 23 #include "rte_swx_extern.h" 24 25 /** Name size. */ 26 #ifndef RTE_SWX_NAME_SIZE 27 #define RTE_SWX_NAME_SIZE 64 28 #endif 29 30 /** Instruction size. */ 31 #ifndef RTE_SWX_INSTRUCTION_SIZE 32 #define RTE_SWX_INSTRUCTION_SIZE 256 33 #endif 34 35 /** Instruction tokens. */ 36 #ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX 37 #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16 38 #endif 39 40 /* 41 * Pipeline setup and operation 42 */ 43 44 /** Pipeline opaque data structure. */ 45 struct rte_swx_pipeline; 46 47 /** 48 * Pipeline configure 49 * 50 * @param[out] p 51 * Pipeline handle. Must point to valid memory. Contains valid pipeline handle 52 * when the function returns successfully. 53 * @param[in] numa_node 54 * Non-Uniform Memory Access (NUMA) node. 55 * @return 56 * 0 on success or the following error codes otherwise: 57 * -EINVAL: Invalid argument; 58 * -ENOMEM: Not enough space/cannot allocate memory. 59 */ 60 __rte_experimental 61 int 62 rte_swx_pipeline_config(struct rte_swx_pipeline **p, 63 int numa_node); 64 65 /* 66 * Pipeline input ports 67 */ 68 69 /** 70 * Pipeline input port type register 71 * 72 * @param[in] p 73 * Pipeline handle. 74 * @param[in] name 75 * Input port type name. 76 * @param[in] ops 77 * Input port type operations. 78 * @return 79 * 0 on success or the following error codes otherwise: 80 * -EINVAL: Invalid argument; 81 * -ENOMEM: Not enough space/cannot allocate memory; 82 * -EEXIST: Input port type with this name already exists. 83 */ 84 __rte_experimental 85 int 86 rte_swx_pipeline_port_in_type_register(struct rte_swx_pipeline *p, 87 const char *name, 88 struct rte_swx_port_in_ops *ops); 89 90 /** 91 * Pipeline input port configure 92 * 93 * @param[in] p 94 * Pipeline handle. 95 * @param[in] port_id 96 * Input port ID. 97 * @param[in] port_type_name 98 * Existing input port type name. 99 * @param[in] args 100 * Input port creation arguments. 101 * @return 102 * 0 on success or the following error codes otherwise: 103 * -EINVAL: Invalid argument; 104 * -ENOMEM: Not enough space/cannot allocate memory; 105 * -ENODEV: Input port object creation error. 106 */ 107 __rte_experimental 108 int 109 rte_swx_pipeline_port_in_config(struct rte_swx_pipeline *p, 110 uint32_t port_id, 111 const char *port_type_name, 112 void *args); 113 114 /* 115 * Pipeline output ports 116 */ 117 118 /** 119 * Pipeline output port type register 120 * 121 * @param[in] p 122 * Pipeline handle. 123 * @param[in] name 124 * Output port type name. 125 * @param[in] ops 126 * Output port type operations. 127 * @return 128 * 0 on success or the following error codes otherwise: 129 * -EINVAL: Invalid argument; 130 * -ENOMEM: Not enough space/cannot allocate memory; 131 * -EEXIST: Output port type with this name already exists. 132 */ 133 __rte_experimental 134 int 135 rte_swx_pipeline_port_out_type_register(struct rte_swx_pipeline *p, 136 const char *name, 137 struct rte_swx_port_out_ops *ops); 138 139 /** 140 * Pipeline output port configure 141 * 142 * @param[in] p 143 * Pipeline handle. 144 * @param[in] port_id 145 * Output port ID. 146 * @param[in] port_type_name 147 * Existing output port type name. 148 * @param[in] args 149 * Output port creation arguments. 150 * @return 151 * 0 on success or the following error codes otherwise: 152 * -EINVAL: Invalid argument; 153 * -ENOMEM: Not enough space/cannot allocate memory; 154 * -ENODEV: Output port object creation error. 155 */ 156 __rte_experimental 157 int 158 rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p, 159 uint32_t port_id, 160 const char *port_type_name, 161 void *args); 162 163 /* 164 * Extern objects and functions 165 */ 166 167 /** 168 * Pipeline extern type register 169 * 170 * @param[in] p 171 * Pipeline handle. 172 * @param[in] name 173 * Extern type name. 174 * @param[in] mailbox_struct_type_name 175 * Name of existing struct type used to define the mailbox size and layout for 176 * the extern objects that are instances of this type. Each extern object gets 177 * its own mailbox, which is used to pass the input arguments to the member 178 * functions and retrieve the output results. 179 * @param[in] constructor 180 * Function used to create the extern objects that are instances of this type. 181 * @param[in] destructor 182 * Function used to free the extern objects that are instances of this type. 183 * @return 184 * 0 on success or the following error codes otherwise: 185 * -EINVAL: Invalid argument; 186 * -ENOMEM: Not enough space/cannot allocate memory; 187 * -EEXIST: Extern type with this name already exists. 188 */ 189 __rte_experimental 190 int 191 rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p, 192 const char *name, 193 const char *mailbox_struct_type_name, 194 rte_swx_extern_type_constructor_t constructor, 195 rte_swx_extern_type_destructor_t destructor); 196 197 /** 198 * Pipeline extern type member function register 199 * 200 * @param[in] p 201 * Pipeline handle. 202 * @param[in] extern_type_name 203 * Existing extern type name. 204 * @param[in] name 205 * Name for the new member function to be added to the extern type. 206 * @param[in] member_func 207 * The new member function. 208 * @return 209 * 0 on success or the following error codes otherwise: 210 * -EINVAL: Invalid argument; 211 * -ENOMEM: Not enough space/cannot allocate memory; 212 * -EEXIST: Member function with this name already exists for this type; 213 * -ENOSPC: Maximum number of member functions reached for this type. 214 */ 215 __rte_experimental 216 int 217 rte_swx_pipeline_extern_type_member_func_register(struct rte_swx_pipeline *p, 218 const char *extern_type_name, 219 const char *name, 220 rte_swx_extern_type_member_func_t member_func); 221 222 /** 223 * Pipeline extern object configure 224 * 225 * Instantiate a given extern type to create new extern object. 226 * 227 * @param[in] p 228 * Pipeline handle. 229 * @param[in] extern_type_name 230 * Existing extern type name. 231 * @param[in] name 232 * Name for the new object instantiating the extern type. 233 * @param[in] args 234 * Extern object constructor arguments. 235 * @return 236 * 0 on success or the following error codes otherwise: 237 * -EINVAL: Invalid argument; 238 * -ENOMEM: Not enough space/cannot allocate memory; 239 * -EEXIST: Extern object with this name already exists; 240 * -ENODEV: Extern object constructor error. 241 */ 242 __rte_experimental 243 int 244 rte_swx_pipeline_extern_object_config(struct rte_swx_pipeline *p, 245 const char *extern_type_name, 246 const char *name, 247 const char *args); 248 249 /** 250 * Pipeline extern function register 251 * 252 * @param[in] p 253 * Pipeline handle. 254 * @param[in] name 255 * Extern function name. 256 * @param[in] mailbox_struct_type_name 257 * Name of existing struct type used to define the mailbox size and layout for 258 * this extern function. The mailbox is used to pass the input arguments to 259 * the extern function and retrieve the output results. 260 * @param[in] func 261 * The extern function. 262 * @return 263 * 0 on success or the following error codes otherwise: 264 * -EINVAL: Invalid argument; 265 * -ENOMEM: Not enough space/cannot allocate memory; 266 * -EEXIST: Extern function with this name already exists. 267 */ 268 __rte_experimental 269 int 270 rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p, 271 const char *name, 272 const char *mailbox_struct_type_name, 273 rte_swx_extern_func_t func); 274 275 /* 276 * Packet headers and meta-data 277 */ 278 279 /** Structure (struct) field. */ 280 struct rte_swx_field_params { 281 /** Struct field name. */ 282 const char *name; 283 284 /** Struct field size (in bits). 285 * Restriction: All struct fields must be a multiple of 8 bits. 286 * Restriction: All struct fields must be no greater than 64 bits. 287 */ 288 uint32_t n_bits; 289 }; 290 291 /** 292 * Pipeline struct type register 293 * 294 * Structs are used extensively in many part of the pipeline to define the size 295 * and layout of a specific memory piece such as: headers, meta-data, action 296 * data stored in a table entry, mailboxes for extern objects and functions. 297 * Similar to C language structs, they are a well defined sequence of fields, 298 * with each field having a unique name and a constant size. 299 * 300 * @param[in] p 301 * Pipeline handle. 302 * @param[in] name 303 * Struct type name. 304 * @param[in] fields 305 * The sequence of struct fields. 306 * @param[in] n_fields 307 * The number of struct fields. 308 * @return 309 * 0 on success or the following error codes otherwise: 310 * -EINVAL: Invalid argument; 311 * -ENOMEM: Not enough space/cannot allocate memory; 312 * -EEXIST: Struct type with this name already exists. 313 */ 314 __rte_experimental 315 int 316 rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p, 317 const char *name, 318 struct rte_swx_field_params *fields, 319 uint32_t n_fields); 320 321 /** 322 * Pipeline packet header register 323 * 324 * @param[in] p 325 * Pipeline handle. 326 * @param[in] name 327 * Header name. 328 * @param[in] struct_type_name 329 * The struct type instantiated by this packet header. 330 * @return 331 * 0 on success or the following error codes otherwise: 332 * -EINVAL: Invalid argument; 333 * -ENOMEM: Not enough space/cannot allocate memory; 334 * -EEXIST: Header with this name already exists; 335 * -ENOSPC: Maximum number of headers reached for the pipeline. 336 */ 337 __rte_experimental 338 int 339 rte_swx_pipeline_packet_header_register(struct rte_swx_pipeline *p, 340 const char *name, 341 const char *struct_type_name); 342 343 /** 344 * Pipeline packet meta-data register 345 * 346 * @param[in] p 347 * Pipeline handle. 348 * @param[in] struct_type_name 349 * The struct type instantiated by the packet meta-data. 350 * @return 351 * 0 on success or the following error codes otherwise: 352 * -EINVAL: Invalid argument. 353 */ 354 __rte_experimental 355 int 356 rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p, 357 const char *struct_type_name); 358 359 /* 360 * Instructions 361 */ 362 363 /** 364 * Instruction operands: 365 * 366 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 367 *<pre>| | Description | Format | DST | SRC |</pre> 368 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 369 *<pre>| hdr | Header | h.header | | |</pre> 370 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 371 *<pre>| act | Action | ACTION | | |</pre> 372 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 373 *<pre>| tbl | Table | TABLE | | |</pre> 374 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 375 *<pre>| H | Header field | h.header.field | YES | YES |</pre> 376 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 377 *<pre>| M | Meta-data field | m.field | YES | YES |</pre> 378 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 379 *<pre>| E | Extern obj mailbox field | e.ext_obj.field | YES | YES |</pre> 380 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 381 *<pre>| F | Extern func mailbox field | f.ext_func.field | YES | YES |</pre> 382 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 383 *<pre>| T | Table action data field | t.header.field | NO | YES |</pre> 384 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 385 *<pre>| I | Immediate value (64-bit) | h.header.field | NO | YES |</pre> 386 *<pre>+-----+---------------------------+------------------+-----+-----+</pre> 387 * 388 * Instruction set: 389 * 390 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 391 *<pre>| Instr. | Instruction | Instruction | 1st | 2nd |</pre> 392 *<pre>| Name | Description | Format | opnd.| opnd. |</pre> 393 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 394 *<pre>| rx | Receive one pkt | rx m.port_in | M | |</pre> 395 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 396 *<pre>| tx | Transmit one pkt | tx m.port_out | M | |</pre> 397 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 398 *<pre>| extract | Extract one hdr | extract h.hdr | hdr | |</pre> 399 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 400 *<pre>| emit | Emit one hdr | emit h.hdr | hdr | |</pre> 401 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 402 *<pre>| validate | Validate one hdr | validate h.hdr | hdr | |</pre> 403 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 404 *<pre>| invalidate | Invalidate one hdr | invalidate h.hdr | hdr | |</pre> 405 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 406 *<pre>| mov | dst = src | mov dst src | HMEF | HMEFTI |</pre> 407 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 408 *<pre>| dma | memcpy(h.hdr, | dma h.hdr t.field | hdr | T |</pre> 409 *<pre>| | &t.field, | | | |</pre> 410 *<pre>| | sizeof(h.hdr) | | | |</pre> 411 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 412 *<pre>| add | dst += src | add dst src | HMEF | HMEFTI |</pre> 413 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 414 *<pre>| sub | dst -= src | add dst src | HMEF | HMEFTI |</pre> 415 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 416 *<pre>| ckadd | Checksum add: dst = | add dst src | HMEF | HMEFTI |</pre> 417 *<pre>| | dst '+ src[0:1] '+ | | | or hdr |</pre> 418 *<pre>| | src[2:3] '+ ... | | | |</pre> 419 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 420 *<pre>| cksub | Checksum subtract: | add dst src | HMEF | HMEFTI |</pre> 421 *<pre>| | dst = dst '- src | | | |</pre> 422 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 423 *<pre>| and | dst &= src | and dst src | HMEF | HMEFTI |</pre> 424 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 425 *<pre>| or | dst |= src | or dst src | HMEF | HMEFTI |</pre> 426 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 427 *<pre>| xor | dst ^= src | xor dst src | HMEF | HMEFTI |</pre> 428 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 429 *<pre>| shl | dst <<= src | shl dst src | HMEF | HMEFTI |</pre> 430 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 431 *<pre>| shr | dst >>= src | shr dst src | HMEF | HMEFTI |</pre> 432 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 433 *<pre>| table | Table lookup | table TABLE | tbl | |</pre> 434 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 435 *<pre>| extern | Ext obj member func | extern e.obj.mfunc| ext | |</pre> 436 *<pre>| | call or ext func call| extern f.func | | |</pre> 437 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 438 *<pre>| jmp | Unconditional jump | jmp LABEL | | |</pre> 439 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 440 *<pre>| jmpv | Jump if hdr is valid | jmpv LABEL h.hdr | hdr | |</pre> 441 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 442 *<pre>| jmpnv | Jump if hdr is inval | jmpnv LABEL h.hdr | hdr | |</pre> 443 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 444 *<pre>| jmph | Jump if tbl lkp hit | jmph LABEL | | |</pre> 445 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 446 *<pre>| jmpnh | Jump if tbl lkp miss | jmpnh LABEL | | |</pre> 447 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 448 *<pre>| jmpa | Jump if action run | jmpa LABEL ACTION | act | |</pre> 449 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 450 *<pre>| jmpna | Jump if act not run | jmpna LABEL ACTION| act | |</pre> 451 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 452 *<pre>| jmpeq | Jump if (a == b) | jmpeq LABEL a b | HMEFT| HMEFTI |</pre> 453 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 454 *<pre>| jmpneq | Jump if (a != b) | jmpneq LABEL a b | HMEFT| HMEFTI |</pre> 455 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 456 *<pre>| jmplt | Jump if (a < b) | jmplt LABEL a b | HMEFT| HMEFTI |</pre> 457 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 458 *<pre>| jmpgt | Jump if (a > b) | jmpgt LABEL a b | HMEFT| HMEFTI |</pre> 459 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 460 *<pre>| return | Return from action | return | | |</pre> 461 *<pre>+------------+----------------------+-------------------+------+--------+</pre> 462 * 463 * At initialization time, the pipeline and action instructions (including the 464 * symbolic name operands) are translated to internal data structures that are 465 * used at run-time. 466 */ 467 468 /* 469 * Pipeline action 470 */ 471 472 /** 473 * Pipeline action configure 474 * 475 * @param[in] p 476 * Pipeline handle. 477 * @param[in] name 478 * Action name. 479 * @param[in] args_struct_type_name 480 * The struct type instantiated by the action data. The action data represent 481 * the action arguments that are stored in the table entry together with the 482 * action ID. Set to NULL when the action does not have any arguments. 483 * @param[in] instructions 484 * Action instructions. 485 * @param[in] n_instructions 486 * Number of action instructions. 487 * @return 488 * 0 on success or the following error codes otherwise: 489 * -EINVAL: Invalid argument; 490 * -ENOMEM: Not enough space/cannot allocate memory; 491 * -EEXIST: Action with this name already exists. 492 */ 493 __rte_experimental 494 int 495 rte_swx_pipeline_action_config(struct rte_swx_pipeline *p, 496 const char *name, 497 const char *args_struct_type_name, 498 const char **instructions, 499 uint32_t n_instructions); 500 501 /* 502 * Pipeline table 503 */ 504 505 /** 506 * Pipeline table type register 507 * 508 * @param[in] p 509 * Pipeline handle. 510 * @param[in] name 511 * Table type name. 512 * @param[in] match_type 513 * Match type implemented by the new table type. 514 * @param[in] ops 515 * Table type operations. 516 * @return 517 * 0 on success or the following error codes otherwise: 518 * -EINVAL: Invalid argument; 519 * -ENOMEM: Not enough space/cannot allocate memory; 520 * -EEXIST: Table type with this name already exists. 521 */ 522 __rte_experimental 523 int 524 rte_swx_pipeline_table_type_register(struct rte_swx_pipeline *p, 525 const char *name, 526 enum rte_swx_table_match_type match_type, 527 struct rte_swx_table_ops *ops); 528 529 /** Match field parameters. */ 530 struct rte_swx_match_field_params { 531 /** Match field name. Must be either a field of one of the registered 532 * packet headers ("h.header.field") or a field of the registered 533 * meta-data ("m.field"). 534 */ 535 const char *name; 536 537 /** Match type of the field. */ 538 enum rte_swx_table_match_type match_type; 539 }; 540 541 /** Pipeline table parameters. */ 542 struct rte_swx_pipeline_table_params { 543 /** The set of match fields for the current table. 544 * Restriction: All the match fields of the current table need to be 545 * part of the same struct, i.e. either all the match fields are part of 546 * the same header or all the match fields are part of the meta-data. 547 */ 548 struct rte_swx_match_field_params *fields; 549 550 /** The number of match fields for the current table. If set to zero, no 551 * "regular" entries (i.e. entries other than the default entry) can be 552 * added to the current table and the match process always results in 553 * lookup miss. 554 */ 555 uint32_t n_fields; 556 557 /** The set of actions for the current table. */ 558 const char **action_names; 559 560 /** The number of actions for the current table. Must be at least one. 561 */ 562 uint32_t n_actions; 563 564 /** The default table action that gets executed on lookup miss. Must be 565 * one of the table actions included in the *action_names*. 566 */ 567 const char *default_action_name; 568 569 /** Default action data. The size of this array is the action data size 570 * of the default action. Must be NULL if the default action data size 571 * is zero. 572 */ 573 uint8_t *default_action_data; 574 575 /** If non-zero (true), then the default action of the current table 576 * cannot be changed. If zero (false), then the default action can be 577 * changed in the future with another action from the *action_names* 578 * list. 579 */ 580 int default_action_is_const; 581 }; 582 583 /** 584 * Pipeline table configure 585 * 586 * @param[out] p 587 * Pipeline handle. 588 * @param[in] name 589 * Table name. 590 * @param[in] params 591 * Table parameters. 592 * @param[in] recommended_table_type_name 593 * Recommended table type. Typically set to NULL. Useful as guidance when 594 * there are multiple table types registered for the match type of the table, 595 * as determined from the table match fields specification. Silently ignored 596 * if the recommended table type does not exist or it serves a different match 597 * type. 598 * @param[in] args 599 * Table creation arguments. 600 * @param[in] size 601 * Guideline on maximum number of table entries. 602 * @return 603 * 0 on success or the following error codes otherwise: 604 * -EINVAL: Invalid argument; 605 * -ENOMEM: Not enough space/cannot allocate memory; 606 * -EEXIST: Table with this name already exists; 607 * -ENODEV: Table creation error. 608 */ 609 __rte_experimental 610 int 611 rte_swx_pipeline_table_config(struct rte_swx_pipeline *p, 612 const char *name, 613 struct rte_swx_pipeline_table_params *params, 614 const char *recommended_table_type_name, 615 const char *args, 616 uint32_t size); 617 618 /** 619 * Pipeline instructions configure 620 * 621 * @param[in] p 622 * Pipeline handle. 623 * @param[in] instructions 624 * Pipeline instructions. 625 * @param[in] n_instructions 626 * Number of pipeline instructions. 627 * @return 628 * 0 on success or the following error codes otherwise: 629 * -EINVAL: Invalid argument; 630 * -ENOMEM: Not enough space/cannot allocate memory. 631 */ 632 __rte_experimental 633 int 634 rte_swx_pipeline_instructions_config(struct rte_swx_pipeline *p, 635 const char **instructions, 636 uint32_t n_instructions); 637 638 /** 639 * Pipeline build 640 * 641 * Once called, the pipeline build operation marks the end of pipeline 642 * configuration. At this point, all the internal data structures needed to run 643 * the pipeline are built. 644 * 645 * @param[in] p 646 * Pipeline handle. 647 * @return 648 * 0 on success or the following error codes otherwise: 649 * -EINVAL: Invalid argument; 650 * -ENOMEM: Not enough space/cannot allocate memory; 651 * -EEXIST: Pipeline was already built successfully. 652 */ 653 __rte_experimental 654 int 655 rte_swx_pipeline_build(struct rte_swx_pipeline *p); 656 657 /** 658 * Pipeline build from specification file 659 * 660 * @param[in] p 661 * Pipeline handle. 662 * @param[in] spec 663 * Pipeline specification file. 664 * @param[out] err_line 665 * In case of error and non-NULL, the line number within the *spec* file where 666 * the error occurred. The first line number in the file is 1. 667 * @param[out] err_msg 668 * In case of error and non-NULL, the error message. 669 * @return 670 * 0 on success or the following error codes otherwise: 671 * -EINVAL: Invalid argument; 672 * -ENOMEM: Not enough space/cannot allocate memory; 673 * -EEXIST: Resource with the same name already exists; 674 * -ENODEV: Extern object or table creation error. 675 */ 676 __rte_experimental 677 int 678 rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, 679 FILE *spec, 680 uint32_t *err_line, 681 const char **err_msg); 682 683 /** 684 * Pipeline run 685 * 686 * @param[in] p 687 * Pipeline handle. 688 * @param[in] n_instructions 689 * Number of instructions to execute. 690 */ 691 __rte_experimental 692 void 693 rte_swx_pipeline_run(struct rte_swx_pipeline *p, 694 uint32_t n_instructions); 695 696 /** 697 * Pipeline flush 698 * 699 * Flush all output ports of the pipeline. 700 * 701 * @param[in] p 702 * Pipeline handle. 703 */ 704 __rte_experimental 705 void 706 rte_swx_pipeline_flush(struct rte_swx_pipeline *p); 707 708 /** 709 * Pipeline free 710 * 711 * @param[in] p 712 * Pipeline handle. 713 */ 714 __rte_experimental 715 void 716 rte_swx_pipeline_free(struct rte_swx_pipeline *p); 717 718 #ifdef __cplusplus 719 } 720 #endif 721 722 #endif 723