* Control plane (CP) thread. */
| 61 | * Control plane (CP) thread. |
| 62 | */ |
| 63 | int |
| 64 | thread_init(void) |
| 65 | { |
| 66 | uint32_t thread_id; |
| 67 | int status = 0; |
| 68 | |
| 69 | RTE_LCORE_FOREACH_WORKER(thread_id) { |
| 70 | struct thread *t = &threads[thread_id]; |
| 71 | uint32_t i; |
| 72 | |
| 73 | t->enabled = 1; |
| 74 | |
| 75 | for (i = 0; i < THREAD_BLOCKS_MAX; i++) { |
| 76 | struct block *b; |
| 77 | |
| 78 | b = calloc(1, sizeof(struct block)); |
| 79 | if (!b) { |
| 80 | status = -ENOMEM; |
| 81 | goto error; |
| 82 | } |
| 83 | |
| 84 | t->blocks[i] = b; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | return 0; |
| 89 | |
| 90 | error: |
| 91 | RTE_LCORE_FOREACH_WORKER(thread_id) { |
| 92 | struct thread *t = &threads[thread_id]; |
| 93 | uint32_t i; |
| 94 | |
| 95 | t->enabled = 0; |
| 96 | |
| 97 | for (i = 0; i < THREAD_BLOCKS_MAX; i++) { |
| 98 | free(t->blocks[i]); |
| 99 | t->blocks[i] = NULL; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return status; |
| 104 | } |
| 105 | |
| 106 | static uint32_t |
| 107 | pipeline_find(struct rte_swx_pipeline *p) |