| 252 | } |
| 253 | |
| 254 | int |
| 255 | thread_pipeline_enable(uint32_t thread_id, |
| 256 | const char *pipeline_name) |
| 257 | { |
| 258 | struct pipeline *p = pipeline_find(pipeline_name); |
| 259 | struct thread *t; |
| 260 | struct thread_msg_req *req; |
| 261 | struct thread_msg_rsp *rsp; |
| 262 | uint32_t i; |
| 263 | int status; |
| 264 | |
| 265 | /* Check input params */ |
| 266 | if ((thread_id >= RTE_MAX_LCORE) || |
| 267 | (p == NULL) || |
| 268 | (p->n_ports_in == 0) || |
| 269 | (p->n_ports_out == 0) || |
| 270 | (p->n_tables == 0)) |
| 271 | return -1; |
| 272 | |
| 273 | t = &thread[thread_id]; |
| 274 | if ((t->enabled == 0) || |
| 275 | p->enabled) |
| 276 | return -1; |
| 277 | |
| 278 | if (!thread_is_running(thread_id)) { |
| 279 | struct thread_data *td = &thread_data[thread_id]; |
| 280 | struct pipeline_data *tdp = &td->pipeline_data[td->n_pipelines]; |
| 281 | |
| 282 | if (td->n_pipelines >= THREAD_PIPELINES_MAX) |
| 283 | return -1; |
| 284 | |
| 285 | /* Data plane thread */ |
| 286 | td->p[td->n_pipelines] = p->p; |
| 287 | |
| 288 | tdp->p = p->p; |
| 289 | for (i = 0; i < p->n_tables; i++) |
| 290 | tdp->table_data[i].a = p->table[i].a; |
| 291 | |
| 292 | tdp->n_tables = p->n_tables; |
| 293 | |
| 294 | tdp->msgq_req = p->msgq_req; |
| 295 | tdp->msgq_rsp = p->msgq_rsp; |
| 296 | tdp->timer_period = (rte_get_tsc_hz() * p->timer_period_ms) / 1000; |
| 297 | tdp->time_next = rte_get_tsc_cycles() + tdp->timer_period; |
| 298 | |
| 299 | td->n_pipelines++; |
| 300 | |
| 301 | /* Pipeline */ |
| 302 | p->thread_id = thread_id; |
| 303 | p->enabled = 1; |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /* Allocate request */ |
| 309 | req = thread_msg_alloc(); |
| 310 | if (req == NULL) |
| 311 | return -1; |
no test coverage detected