2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include <rte_common.h>
19 #include <rte_malloc.h>
21 #include "pipeline_common_be.h"
24 pipeline_msg_req_ping_handler(__rte_unused struct pipeline *p,
27 struct pipeline_msg_rsp *rsp = msg;
29 rsp->status = 0; /* OK */
35 pipeline_msg_req_stats_port_in_handler(struct pipeline *p,
38 struct pipeline_stats_msg_req *req = msg;
39 struct pipeline_stats_port_in_msg_rsp *rsp = msg;
43 if (req->id >= p->n_ports_in) {
47 port_id = p->port_in_id[req->id];
50 rsp->status = rte_pipeline_port_in_stats_read(p->p,
59 pipeline_msg_req_stats_port_out_handler(struct pipeline *p,
62 struct pipeline_stats_msg_req *req = msg;
63 struct pipeline_stats_port_out_msg_rsp *rsp = msg;
67 if (req->id >= p->n_ports_out) {
71 port_id = p->port_out_id[req->id];
74 rsp->status = rte_pipeline_port_out_stats_read(p->p,
83 pipeline_msg_req_stats_table_handler(struct pipeline *p,
86 struct pipeline_stats_msg_req *req = msg;
87 struct pipeline_stats_table_msg_rsp *rsp = msg;
91 if (req->id >= p->n_tables) {
95 table_id = p->table_id[req->id];
98 rsp->status = rte_pipeline_table_stats_read(p->p,
107 pipeline_msg_req_port_in_enable_handler(struct pipeline *p,
110 struct pipeline_port_in_msg_req *req = msg;
111 struct pipeline_msg_rsp *rsp = msg;
115 if (req->port_id >= p->n_ports_in) {
119 port_id = p->port_in_id[req->port_id];
121 /* Process request */
122 rsp->status = rte_pipeline_port_in_enable(p->p,
129 pipeline_msg_req_port_in_disable_handler(struct pipeline *p,
132 struct pipeline_port_in_msg_req *req = msg;
133 struct pipeline_msg_rsp *rsp = msg;
137 if (req->port_id >= p->n_ports_in) {
141 port_id = p->port_in_id[req->port_id];
143 /* Process request */
144 rsp->status = rte_pipeline_port_in_disable(p->p,
151 pipeline_msg_req_invalid_handler(__rte_unused struct pipeline *p,
154 struct pipeline_msg_rsp *rsp = msg;
156 rsp->status = -1; /* Error */
162 pipeline_msg_req_handle(struct pipeline *p)
166 for (msgq_id = 0; msgq_id < p->n_msgq; msgq_id++) {
168 struct pipeline_msg_req *req;
169 pipeline_msg_req_handler f_handle;
171 req = pipeline_msg_recv(p, msgq_id);
175 f_handle = (req->type < PIPELINE_MSG_REQS) ?
176 p->handlers[req->type] :
177 pipeline_msg_req_invalid_handler;
179 if (f_handle == NULL)
180 f_handle = pipeline_msg_req_invalid_handler;
184 f_handle(p, (void *) req));