DPDK  16.04.0
rte_pipeline.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __INCLUDE_RTE_PIPELINE_H__
35 #define __INCLUDE_RTE_PIPELINE_H__
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
86 #include <stdint.h>
87 
88 #include <rte_port.h>
89 #include <rte_table.h>
90 
91 struct rte_mbuf;
92 
93 /*
94  * Pipeline
95  *
96  */
98 struct rte_pipeline;
99 
103  const char *name;
104 
108 
112  uint32_t offset_port_id;
113 };
114 
119 
122 
123 };
124 
129 
132 };
133 
138 
141 
144 
148 
152 };
153 
162 struct rte_pipeline *rte_pipeline_create(struct rte_pipeline_params *params);
163 
172 int rte_pipeline_free(struct rte_pipeline *p);
173 
182 int rte_pipeline_check(struct rte_pipeline *p);
183 
192 int rte_pipeline_run(struct rte_pipeline *p);
193 
202 int rte_pipeline_flush(struct rte_pipeline *p);
203 
204 /*
205  * Actions
206  *
207  */
212 
215 
218 
221 
224 };
225 
226 /*
227  * Table
228  *
229  */
232 #define RTE_PIPELINE_TABLE_MAX 64
233 
246 
247  union {
250  uint32_t port_id;
252  uint32_t table_id;
253  };
255  uint8_t action_data[0];
256 };
257 
288  struct rte_pipeline *p,
289  struct rte_mbuf **pkts,
290  uint64_t pkts_mask,
291  struct rte_pipeline_table_entry **entries,
292  void *arg);
293 
324  struct rte_pipeline *p,
325  struct rte_mbuf **pkts,
326  uint64_t pkts_mask,
327  struct rte_pipeline_table_entry *entry,
328  void *arg);
329 
338  void *arg_create;
345 
348  void *arg_ah;
352 };
353 
367 int rte_pipeline_table_create(struct rte_pipeline *p,
368  struct rte_pipeline_table_params *params,
369  uint32_t *table_id);
370 
392 int rte_pipeline_table_default_entry_add(struct rte_pipeline *p,
393  uint32_t table_id,
394  struct rte_pipeline_table_entry *default_entry,
395  struct rte_pipeline_table_entry **default_entry_ptr);
396 
414 int rte_pipeline_table_default_entry_delete(struct rte_pipeline *p,
415  uint32_t table_id,
416  struct rte_pipeline_table_entry *entry);
417 
441 int rte_pipeline_table_entry_add(struct rte_pipeline *p,
442  uint32_t table_id,
443  void *key,
444  struct rte_pipeline_table_entry *entry,
445  int *key_found,
446  struct rte_pipeline_table_entry **entry_ptr);
447 
468 int rte_pipeline_table_entry_delete(struct rte_pipeline *p,
469  uint32_t table_id,
470  void *key,
471  int *key_found,
472  struct rte_pipeline_table_entry *entry);
473 
500 int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p,
501  uint32_t table_id,
502  void **keys,
503  struct rte_pipeline_table_entry **entries,
504  uint32_t n_keys,
505  int *key_found,
506  struct rte_pipeline_table_entry **entries_ptr);
507 
531 int rte_pipeline_table_entry_delete_bulk(struct rte_pipeline *p,
532  uint32_t table_id,
533  void **keys,
534  uint32_t n_keys,
535  int *key_found,
536  struct rte_pipeline_table_entry **entries);
537 
555 int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id,
556  struct rte_pipeline_table_stats *stats, int clear);
557 
558 /*
559  * Port IN
560  *
561  */
564 #define RTE_PIPELINE_PORT_IN_MAX 64
565 
589  struct rte_pipeline *p,
590  struct rte_mbuf **pkts,
591  uint32_t n,
592  void *arg);
593 
599  void *arg_create;
600 
605  void *arg_ah;
606 
608  uint32_t burst_size;
609 };
610 
624 int rte_pipeline_port_in_create(struct rte_pipeline *p,
625  struct rte_pipeline_port_in_params *params,
626  uint32_t *port_id);
627 
640 int rte_pipeline_port_in_connect_to_table(struct rte_pipeline *p,
641  uint32_t port_id,
642  uint32_t table_id);
643 
654 int rte_pipeline_port_in_enable(struct rte_pipeline *p,
655  uint32_t port_id);
656 
667 int rte_pipeline_port_in_disable(struct rte_pipeline *p,
668  uint32_t port_id);
669 
687 int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id,
688  struct rte_pipeline_port_in_stats *stats, int clear);
689 
690 /*
691  * Port OUT
692  *
693  */
696 #define RTE_PIPELINE_PORT_OUT_MAX 64
697 
722  struct rte_pipeline *p,
723  struct rte_mbuf **pkts,
724  uint64_t pkts_mask,
725  void *arg);
726 
735  void *arg_create;
736 
741  void *arg_ah;
742 };
743 
757 int rte_pipeline_port_out_create(struct rte_pipeline *p,
758  struct rte_pipeline_port_out_params *params,
759  uint32_t *port_id);
760 
778 int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id,
779  struct rte_pipeline_port_out_stats *stats, int clear);
780 
781 /*
782  * Functions to be called as part of the port IN/OUT or table action handlers
783  *
784  */
805 int rte_pipeline_port_out_packet_insert(struct rte_pipeline *p,
806  uint32_t port_id,
807  struct rte_mbuf *pkt);
808 
809 #define rte_pipeline_ah_port_out_packet_insert \
810  rte_pipeline_port_out_packet_insert
811 
837 int rte_pipeline_ah_packet_hijack(struct rte_pipeline *p,
838  uint64_t pkts_mask);
839 
868 int rte_pipeline_ah_packet_drop(struct rte_pipeline *p,
869  uint64_t pkts_mask);
870 
871 #ifdef __cplusplus
872 }
873 #endif
874 
875 #endif