1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
5 #ifndef __INCLUDE_PIPELINE_COMMON_BE_H__
6 #define __INCLUDE_PIPELINE_COMMON_BE_H__
8 #include <rte_common.h>
10 #include <rte_pipeline.h>
12 #include "pipeline_be.h"
16 enum pipeline_msg_req_type {
17 PIPELINE_MSG_REQ_PING = 0,
18 PIPELINE_MSG_REQ_STATS_PORT_IN,
19 PIPELINE_MSG_REQ_STATS_PORT_OUT,
20 PIPELINE_MSG_REQ_STATS_TABLE,
21 PIPELINE_MSG_REQ_PORT_IN_ENABLE,
22 PIPELINE_MSG_REQ_PORT_IN_DISABLE,
23 PIPELINE_MSG_REQ_CUSTOM,
27 typedef void *(*pipeline_msg_req_handler)(struct pipeline *p, void *msg);
30 struct rte_pipeline *p;
31 uint32_t port_in_id[PIPELINE_MAX_PORT_IN];
32 uint32_t port_out_id[PIPELINE_MAX_PORT_OUT];
33 uint32_t table_id[PIPELINE_MAX_TABLES];
34 struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
35 struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
42 pipeline_msg_req_handler handlers[PIPELINE_MSG_REQS];
43 char name[PIPELINE_NAME_SIZE];
47 enum pipeline_log_level {
48 PIPELINE_LOG_LEVEL_HIGH = 1,
49 PIPELINE_LOG_LEVEL_LOW,
53 #define PLOG(p, level, fmt, ...) \
55 if (p->log_level >= PIPELINE_LOG_LEVEL_ ## level) \
56 fprintf(stdout, "[%s] " fmt "\n", p->name, ## __VA_ARGS__);\
60 pipeline_msg_recv(struct pipeline *p,
63 struct rte_ring *r = p->msgq_in[msgq_id];
65 int status = rte_ring_sc_dequeue(r, &msg);
74 pipeline_msg_send(struct pipeline *p,
78 struct rte_ring *r = p->msgq_out[msgq_id];
82 status = rte_ring_sp_enqueue(r, msg);
83 } while (status == -ENOBUFS);
86 struct pipeline_msg_req {
87 enum pipeline_msg_req_type type;
90 struct pipeline_stats_msg_req {
91 enum pipeline_msg_req_type type;
95 struct pipeline_port_in_msg_req {
96 enum pipeline_msg_req_type type;
100 struct pipeline_custom_msg_req {
101 enum pipeline_msg_req_type type;
105 struct pipeline_msg_rsp {
109 struct pipeline_stats_port_in_msg_rsp {
111 struct rte_pipeline_port_in_stats stats;
114 struct pipeline_stats_port_out_msg_rsp {
116 struct rte_pipeline_port_out_stats stats;
119 struct pipeline_stats_table_msg_rsp {
121 struct rte_pipeline_table_stats stats;
124 void *pipeline_msg_req_ping_handler(struct pipeline *p, void *msg);
125 void *pipeline_msg_req_stats_port_in_handler(struct pipeline *p, void *msg);
126 void *pipeline_msg_req_stats_port_out_handler(struct pipeline *p, void *msg);
127 void *pipeline_msg_req_stats_table_handler(struct pipeline *p, void *msg);
128 void *pipeline_msg_req_port_in_enable_handler(struct pipeline *p, void *msg);
129 void *pipeline_msg_req_port_in_disable_handler(struct pipeline *p, void *msg);
130 void *pipeline_msg_req_invalid_handler(struct pipeline *p, void *msg);
132 int pipeline_msg_req_handle(struct pipeline *p);