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>
36 #include <rte_malloc.h>
38 #include "pipeline_common_be.h"
41 pipeline_msg_req_ping_handler(__rte_unused struct pipeline *p,
44 struct pipeline_msg_rsp *rsp = msg;
46 rsp->status = 0; /* OK */
52 pipeline_msg_req_stats_port_in_handler(struct pipeline *p,
55 struct pipeline_stats_msg_req *req = msg;
56 struct pipeline_stats_port_in_msg_rsp *rsp = msg;
60 if (req->id >= p->n_ports_in) {
64 port_id = p->port_in_id[req->id];
67 rsp->status = rte_pipeline_port_in_stats_read(p->p,
76 pipeline_msg_req_stats_port_out_handler(struct pipeline *p,
79 struct pipeline_stats_msg_req *req = msg;
80 struct pipeline_stats_port_out_msg_rsp *rsp = msg;
84 if (req->id >= p->n_ports_out) {
88 port_id = p->port_out_id[req->id];
91 rsp->status = rte_pipeline_port_out_stats_read(p->p,
100 pipeline_msg_req_stats_table_handler(struct pipeline *p,
103 struct pipeline_stats_msg_req *req = msg;
104 struct pipeline_stats_table_msg_rsp *rsp = msg;
108 if (req->id >= p->n_tables) {
112 table_id = p->table_id[req->id];
114 /* Process request */
115 rsp->status = rte_pipeline_table_stats_read(p->p,
124 pipeline_msg_req_port_in_enable_handler(struct pipeline *p,
127 struct pipeline_port_in_msg_req *req = msg;
128 struct pipeline_msg_rsp *rsp = msg;
132 if (req->port_id >= p->n_ports_in) {
136 port_id = p->port_in_id[req->port_id];
138 /* Process request */
139 rsp->status = rte_pipeline_port_in_enable(p->p,
146 pipeline_msg_req_port_in_disable_handler(struct pipeline *p,
149 struct pipeline_port_in_msg_req *req = msg;
150 struct pipeline_msg_rsp *rsp = msg;
154 if (req->port_id >= p->n_ports_in) {
158 port_id = p->port_in_id[req->port_id];
160 /* Process request */
161 rsp->status = rte_pipeline_port_in_disable(p->p,
168 pipeline_msg_req_invalid_handler(__rte_unused struct pipeline *p,
171 struct pipeline_msg_rsp *rsp = msg;
173 rsp->status = -1; /* Error */
179 pipeline_msg_req_handle(struct pipeline *p)
183 for (msgq_id = 0; msgq_id < p->n_msgq; msgq_id++) {
185 struct pipeline_msg_req *req;
186 pipeline_msg_req_handler f_handle;
188 req = pipeline_msg_recv(p, msgq_id);
192 f_handle = (req->type < PIPELINE_MSG_REQS) ?
193 p->handlers[req->type] :
194 pipeline_msg_req_invalid_handler;
196 if (f_handle == NULL)
197 f_handle = pipeline_msg_req_invalid_handler;
201 f_handle(p, (void *) req));