X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_pipeline%2Frte_swx_pipeline.h;h=d0a3439edf82f27f7a0404f10e4d632132d87629;hb=5b38d8cd4663;hp=ec76294b02aad21c4ebd618fc5cc4becb2548891;hpb=7d666cfa9665760f8a6e85297a88fdfe9c331771;p=dpdk.git diff --git a/lib/librte_pipeline/rte_swx_pipeline.h b/lib/librte_pipeline/rte_swx_pipeline.h index ec76294b02..d0a3439edf 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.h +++ b/lib/librte_pipeline/rte_swx_pipeline.h @@ -26,6 +26,17 @@ extern "C" { #ifndef RTE_SWX_NAME_SIZE #define RTE_SWX_NAME_SIZE 64 #endif + +/** Instruction size. */ +#ifndef RTE_SWX_INSTRUCTION_SIZE +#define RTE_SWX_INSTRUCTION_SIZE 256 +#endif + +/** Instruction tokens. */ +#ifndef RTE_SWX_INSTRUCTION_TOKENS_MAX +#define RTE_SWX_INSTRUCTION_TOKENS_MAX 16 +#endif + /* * Pipeline setup and operation */ @@ -345,6 +356,115 @@ int rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p, const char *struct_type_name); +/* + * Instructions + */ + +/** + * Instruction operands: + * + *
+-----+---------------------------+------------------+-----+-----++ *
| | Description | Format | DST | SRC |+ *
+-----+---------------------------+------------------+-----+-----++ *
| hdr | Header | h.header | | |+ *
+-----+---------------------------+------------------+-----+-----++ *
| act | Action | ACTION | | |+ *
+-----+---------------------------+------------------+-----+-----++ *
| tbl | Table | TABLE | | |+ *
+-----+---------------------------+------------------+-----+-----++ *
| H | Header field | h.header.field | YES | YES |+ *
+-----+---------------------------+------------------+-----+-----++ *
| M | Meta-data field | m.field | YES | YES |+ *
+-----+---------------------------+------------------+-----+-----++ *
| E | Extern obj mailbox field | e.ext_obj.field | YES | YES |+ *
+-----+---------------------------+------------------+-----+-----++ *
| F | Extern func mailbox field | f.ext_func.field | YES | YES |+ *
+-----+---------------------------+------------------+-----+-----++ *
| T | Table action data field | t.header.field | NO | YES |+ *
+-----+---------------------------+------------------+-----+-----++ *
| I | Immediate value (64-bit) | h.header.field | NO | YES |+ *
+-----+---------------------------+------------------+-----+-----++ * + * Instruction set: + * + *
+------------+----------------------+-------------------+------+--------++ *
| Instr. | Instruction | Instruction | 1st | 2nd |+ *
| Name | Description | Format | opnd.| opnd. |+ *
+------------+----------------------+-------------------+------+--------++ *
| rx | Receive one pkt | rx m.port_in | M | |+ *
+------------+----------------------+-------------------+------+--------++ *
| tx | Transmit one pkt | tx m.port_out | M | |+ *
+------------+----------------------+-------------------+------+--------++ *
| extract | Extract one hdr | extract h.hdr | hdr | |+ *
+------------+----------------------+-------------------+------+--------++ *
| emit | Emit one hdr | emit h.hdr | hdr | |+ *
+------------+----------------------+-------------------+------+--------++ *
| validate | Validate one hdr | validate h.hdr | hdr | |+ *
+------------+----------------------+-------------------+------+--------++ *
| invalidate | Invalidate one hdr | invalidate h.hdr | hdr | |+ *
+------------+----------------------+-------------------+------+--------++ *
| mov | dst = src | mov dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| dma | memcpy(h.hdr, | dma h.hdr t.field | hdr | T |+ *
| | &t.field, | | | |+ *
| | sizeof(h.hdr) | | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| add | dst += src | add dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| sub | dst -= src | add dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| ckadd | Checksum add: dst = | add dst src | HMEF | HMEFTI |+ *
| | dst '+ src[0:1] '+ | | | or hdr |+ *
| | src[2:3] '+ ... | | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| cksub | Checksum subtract: | add dst src | HMEF | HMEFTI |+ *
| | dst = dst '- src | | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| and | dst &= src | and dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| or | dst |= src | or dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| xor | dst ^= src | xor dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| shl | dst <<= src | shl dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| shr | dst >>= src | shr dst src | HMEF | HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| table | Table lookup | table TABLE | tbl | |+ *
+------------+----------------------+-------------------+------+--------++ *
| extern | Ext obj member func | extern e.obj.mfunc| ext | |+ *
| | call or ext func call| extern f.func | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmp | Unconditional jump | jmp LABEL | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpv | Jump if hdr is valid | jmpv LABEL h.hdr | hdr | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpnv | Jump if hdr is inval | jmpnv LABEL h.hdr | hdr | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmph | Jump if tbl lkp hit | jmph LABEL | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpnh | Jump if tbl lkp miss | jmpnh LABEL | | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpa | Jump if action run | jmpa LABEL ACTION | act | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpna | Jump if act not run | jmpna LABEL ACTION| act | |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpeq | Jump if (a == b) | jmpeq LABEL a b | HMEFT| HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpneq | Jump if (a != b) | jmpneq LABEL a b | HMEFT| HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmplt | Jump if (a < b) | jmplt LABEL a b | HMEFT| HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| jmpgt | Jump if (a > b) | jmpgt LABEL a b | HMEFT| HMEFTI |+ *
+------------+----------------------+-------------------+------+--------++ *
| return | Return from action | return | | |+ *
+------------+----------------------+-------------------+------+--------++ * + * At initialization time, the pipeline and action instructions (including the + * symbolic name operands) are translated to internal data structures that are + * used at run-time. + */ + /* * Pipeline action */ @@ -534,6 +654,57 @@ __rte_experimental int rte_swx_pipeline_build(struct rte_swx_pipeline *p); +/** + * Pipeline build from specification file + * + * @param[in] p + * Pipeline handle. + * @param[in] spec + * Pipeline specification file. + * @param[out] err_line + * In case of error and non-NULL, the line number within the *spec* file where + * the error occurred. The first line number in the file is 1. + * @param[out] err_msg + * In case of error and non-NULL, the error message. + * @return + * 0 on success or the following error codes otherwise: + * -EINVAL: Invalid argument; + * -ENOMEM: Not enough space/cannot allocate memory; + * -EEXIST: Resource with the same name already exists; + * -ENODEV: Extern object or table creation error. + */ +__rte_experimental +int +rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, + FILE *spec, + uint32_t *err_line, + const char **err_msg); + +/** + * Pipeline run + * + * @param[in] p + * Pipeline handle. + * @param[in] n_instructions + * Number of instructions to execute. + */ +__rte_experimental +void +rte_swx_pipeline_run(struct rte_swx_pipeline *p, + uint32_t n_instructions); + +/** + * Pipeline flush + * + * Flush all output ports of the pipeline. + * + * @param[in] p + * Pipeline handle. + */ +__rte_experimental +void +rte_swx_pipeline_flush(struct rte_swx_pipeline *p); + /** * Pipeline free *