DPDK  17.02.1
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 #include <rte_common.h>
91 
92 struct rte_mbuf;
93 
94 /*
95  * Pipeline
96  *
97  */
99 struct rte_pipeline;
100 
104  const char *name;
105 
109 
113  uint32_t offset_port_id;
114 };
115 
120 
123 
124 };
125 
130 
133 };
134 
139 
142 
145 
149 
153 };
154 
163 struct rte_pipeline *rte_pipeline_create(struct rte_pipeline_params *params);
164 
173 int rte_pipeline_free(struct rte_pipeline *p);
174 
183 int rte_pipeline_check(struct rte_pipeline *p);
184 
193 int rte_pipeline_run(struct rte_pipeline *p);
194 
203 int rte_pipeline_flush(struct rte_pipeline *p);
204 
205 /*
206  * Actions
207  *
208  */
213 
216 
219 
222 
225 };
226 
227 /*
228  * Table
229  *
230  */
233 #define RTE_PIPELINE_TABLE_MAX 64
234 
247 
249  union {
252  uint32_t port_id;
254  uint32_t table_id;
255  };
257  __extension__ uint8_t action_data[0];
258 };
259 
290  struct rte_pipeline *p,
291  struct rte_mbuf **pkts,
292  uint64_t pkts_mask,
293  struct rte_pipeline_table_entry **entries,
294  void *arg);
295 
326  struct rte_pipeline *p,
327  struct rte_mbuf **pkts,
328  uint64_t pkts_mask,
329  struct rte_pipeline_table_entry *entry,
330  void *arg);
331 
340  void *arg_create;
347 
350  void *arg_ah;
354 };
355 
369 int rte_pipeline_table_create(struct rte_pipeline *p,
370  struct rte_pipeline_table_params *params,
371  uint32_t *table_id);
372 
394 int rte_pipeline_table_default_entry_add(struct rte_pipeline *p,
395  uint32_t table_id,
396  struct rte_pipeline_table_entry *default_entry,
397  struct rte_pipeline_table_entry **default_entry_ptr);
398 
416 int rte_pipeline_table_default_entry_delete(struct rte_pipeline *p,
417  uint32_t table_id,
418  struct rte_pipeline_table_entry *entry);
419 
443 int rte_pipeline_table_entry_add(struct rte_pipeline *p,
444  uint32_t table_id,
445  void *key,
446  struct rte_pipeline_table_entry *entry,
447  int *key_found,
448  struct rte_pipeline_table_entry **entry_ptr);
449 
470 int rte_pipeline_table_entry_delete(struct rte_pipeline *p,
471  uint32_t table_id,
472  void *key,
473  int *key_found,
474  struct rte_pipeline_table_entry *entry);
475 
502 int rte_pipeline_table_entry_add_bulk(struct rte_pipeline *p,
503  uint32_t table_id,
504  void **keys,
505  struct rte_pipeline_table_entry **entries,
506  uint32_t n_keys,
507  int *key_found,
508  struct rte_pipeline_table_entry **entries_ptr);
509 
533 int rte_pipeline_table_entry_delete_bulk(struct rte_pipeline *p,
534  uint32_t table_id,
535  void **keys,
536  uint32_t n_keys,
537  int *key_found,
538  struct rte_pipeline_table_entry **entries);
539 
557 int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table_id,
558  struct rte_pipeline_table_stats *stats, int clear);
559 
560 /*
561  * Port IN
562  *
563  */
566 #define RTE_PIPELINE_PORT_IN_MAX 64
567 
591  struct rte_pipeline *p,
592  struct rte_mbuf **pkts,
593  uint32_t n,
594  void *arg);
595 
601  void *arg_create;
602 
607  void *arg_ah;
608 
610  uint32_t burst_size;
611 };
612 
626 int rte_pipeline_port_in_create(struct rte_pipeline *p,
627  struct rte_pipeline_port_in_params *params,
628  uint32_t *port_id);
629 
642 int rte_pipeline_port_in_connect_to_table(struct rte_pipeline *p,
643  uint32_t port_id,
644  uint32_t table_id);
645 
656 int rte_pipeline_port_in_enable(struct rte_pipeline *p,
657  uint32_t port_id);
658 
669 int rte_pipeline_port_in_disable(struct rte_pipeline *p,
670  uint32_t port_id);
671 
689 int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t port_id,
690  struct rte_pipeline_port_in_stats *stats, int clear);
691 
692 /*
693  * Port OUT
694  *
695  */
698 #define RTE_PIPELINE_PORT_OUT_MAX 64
699 
724  struct rte_pipeline *p,
725  struct rte_mbuf **pkts,
726  uint64_t pkts_mask,
727  void *arg);
728 
737  void *arg_create;
738 
743  void *arg_ah;
744 };
745 
759 int rte_pipeline_port_out_create(struct rte_pipeline *p,
760  struct rte_pipeline_port_out_params *params,
761  uint32_t *port_id);
762 
780 int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t port_id,
781  struct rte_pipeline_port_out_stats *stats, int clear);
782 
783 /*
784  * Functions to be called as part of the port IN/OUT or table action handlers
785  *
786  */
807 int rte_pipeline_port_out_packet_insert(struct rte_pipeline *p,
808  uint32_t port_id,
809  struct rte_mbuf *pkt);
810 
811 #define rte_pipeline_ah_port_out_packet_insert \
812  rte_pipeline_port_out_packet_insert
813 
839 int rte_pipeline_ah_packet_hijack(struct rte_pipeline *p,
840  uint64_t pkts_mask);
841 
870 int rte_pipeline_ah_packet_drop(struct rte_pipeline *p,
871  uint64_t pkts_mask);
872 
873 #ifdef __cplusplus
874 }
875 #endif
876 
877 #endif