4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef __INCLUDE_PIPELINE_COMMON_BE_H__
35 #define __INCLUDE_PIPELINE_COMMON_BE_H__
37 #include <rte_common.h>
39 #include <rte_pipeline.h>
41 #include "pipeline_be.h"
45 enum pipeline_msg_req_type
{
46 PIPELINE_MSG_REQ_PING
= 0,
47 PIPELINE_MSG_REQ_STATS_PORT_IN
,
48 PIPELINE_MSG_REQ_STATS_PORT_OUT
,
49 PIPELINE_MSG_REQ_STATS_TABLE
,
50 PIPELINE_MSG_REQ_PORT_IN_ENABLE
,
51 PIPELINE_MSG_REQ_PORT_IN_DISABLE
,
52 PIPELINE_MSG_REQ_CUSTOM
,
56 typedef void *(*pipeline_msg_req_handler
)(struct pipeline
*p
, void *msg
);
59 struct rte_pipeline
*p
;
60 uint32_t port_in_id
[PIPELINE_MAX_PORT_IN
];
61 uint32_t port_out_id
[PIPELINE_MAX_PORT_OUT
];
62 uint32_t table_id
[PIPELINE_MAX_TABLES
];
63 struct rte_ring
*msgq_in
[PIPELINE_MAX_MSGQ_IN
];
64 struct rte_ring
*msgq_out
[PIPELINE_MAX_MSGQ_OUT
];
71 pipeline_msg_req_handler handlers
[PIPELINE_MSG_REQS
];
72 char name
[PIPELINE_NAME_SIZE
];
76 enum pipeline_log_level
{
77 PIPELINE_LOG_LEVEL_HIGH
= 1,
78 PIPELINE_LOG_LEVEL_LOW
,
82 #define PLOG(p, level, fmt, ...) \
84 if (p->log_level >= PIPELINE_LOG_LEVEL_ ## level) \
85 fprintf(stdout, "[%s] " fmt "\n", p->name, ## __VA_ARGS__);\
89 pipeline_msg_recv(struct pipeline
*p
,
92 struct rte_ring
*r
= p
->msgq_in
[msgq_id
];
94 int status
= rte_ring_sc_dequeue(r
, &msg
);
103 pipeline_msg_send(struct pipeline
*p
,
107 struct rte_ring
*r
= p
->msgq_out
[msgq_id
];
111 status
= rte_ring_sp_enqueue(r
, msg
);
112 } while (status
== -ENOBUFS
);
115 struct pipeline_msg_req
{
116 enum pipeline_msg_req_type type
;
119 struct pipeline_stats_msg_req
{
120 enum pipeline_msg_req_type type
;
124 struct pipeline_port_in_msg_req
{
125 enum pipeline_msg_req_type type
;
129 struct pipeline_custom_msg_req
{
130 enum pipeline_msg_req_type type
;
134 struct pipeline_msg_rsp
{
138 struct pipeline_stats_port_in_msg_rsp
{
140 struct rte_pipeline_port_in_stats stats
;
143 struct pipeline_stats_port_out_msg_rsp
{
145 struct rte_pipeline_port_out_stats stats
;
148 struct pipeline_stats_table_msg_rsp
{
150 struct rte_pipeline_table_stats stats
;
153 void *pipeline_msg_req_ping_handler(struct pipeline
*p
, void *msg
);
154 void *pipeline_msg_req_stats_port_in_handler(struct pipeline
*p
, void *msg
);
155 void *pipeline_msg_req_stats_port_out_handler(struct pipeline
*p
, void *msg
);
156 void *pipeline_msg_req_stats_table_handler(struct pipeline
*p
, void *msg
);
157 void *pipeline_msg_req_port_in_enable_handler(struct pipeline
*p
, void *msg
);
158 void *pipeline_msg_req_port_in_disable_handler(struct pipeline
*p
, void *msg
);
159 void *pipeline_msg_req_invalid_handler(struct pipeline
*p
, void *msg
);
161 int pipeline_msg_req_handle(struct pipeline
*p
);