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 #include <rte_common.h>
35 #include <rte_malloc.h>
37 #include "pipeline_common_be.h"
40 pipeline_msg_req_ping_handler(__rte_unused struct pipeline *p,
43 struct pipeline_msg_rsp *rsp = msg;
45 rsp->status = 0; /* OK */
51 pipeline_msg_req_stats_port_in_handler(struct pipeline *p,
54 struct pipeline_stats_msg_req *req = msg;
55 struct pipeline_stats_port_in_msg_rsp *rsp = msg;
59 if (req->id >= p->n_ports_in) {
63 port_id = p->port_in_id[req->id];
66 rsp->status = rte_pipeline_port_in_stats_read(p->p,
75 pipeline_msg_req_stats_port_out_handler(struct pipeline *p,
78 struct pipeline_stats_msg_req *req = msg;
79 struct pipeline_stats_port_out_msg_rsp *rsp = msg;
83 if (req->id >= p->n_ports_out) {
87 port_id = p->port_out_id[req->id];
90 rsp->status = rte_pipeline_port_out_stats_read(p->p,
99 pipeline_msg_req_stats_table_handler(struct pipeline *p,
102 struct pipeline_stats_msg_req *req = msg;
103 struct pipeline_stats_table_msg_rsp *rsp = msg;
107 if (req->id >= p->n_tables) {
111 table_id = p->table_id[req->id];
113 /* Process request */
114 rsp->status = rte_pipeline_table_stats_read(p->p,
123 pipeline_msg_req_port_in_enable_handler(struct pipeline *p,
126 struct pipeline_port_in_msg_req *req = msg;
127 struct pipeline_msg_rsp *rsp = msg;
131 if (req->port_id >= p->n_ports_in) {
135 port_id = p->port_in_id[req->port_id];
137 /* Process request */
138 rsp->status = rte_pipeline_port_in_enable(p->p,
145 pipeline_msg_req_port_in_disable_handler(struct pipeline *p,
148 struct pipeline_port_in_msg_req *req = msg;
149 struct pipeline_msg_rsp *rsp = msg;
153 if (req->port_id >= p->n_ports_in) {
157 port_id = p->port_in_id[req->port_id];
159 /* Process request */
160 rsp->status = rte_pipeline_port_in_disable(p->p,
167 pipeline_msg_req_invalid_handler(__rte_unused struct pipeline *p,
170 struct pipeline_msg_rsp *rsp = msg;
172 rsp->status = -1; /* Error */
178 pipeline_msg_req_handle(struct pipeline *p)
182 for (msgq_id = 0; msgq_id < p->n_msgq; msgq_id++) {
184 struct pipeline_msg_req *req;
185 pipeline_msg_req_handler f_handle;
187 req = pipeline_msg_recv(p, msgq_id);
191 f_handle = (req->type < PIPELINE_MSG_REQS) ?
192 p->handlers[req->type] :
193 pipeline_msg_req_invalid_handler;
195 if (f_handle == NULL)
196 f_handle = pipeline_msg_req_invalid_handler;
200 f_handle(p, (void *) req));