2 // Copyright (c) 2010-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_cycles.h>
21 #include "thread_nop.h"
22 #include "handle_nop.h"
27 int thread_nop(struct lcore_cfg *lconf)
29 struct task_base *tasks[MAX_TASKS_PER_CORE];
30 struct rte_mbuf **mbufs;
31 uint64_t cur_tsc = rte_rdtsc();
32 uint64_t term_tsc = cur_tsc;
33 uint64_t drain_tsc = cur_tsc;
34 uint8_t n_tasks_run = 0;
37 cur_tsc = rte_rdtsc();
38 if (cur_tsc > term_tsc) {
39 term_tsc = cur_tsc + TERM_TIMEOUT;
40 if (lconf_is_req(lconf) && lconf_do_flags(lconf)) {
41 n_tasks_run = lconf->n_tasks_run;
45 for (int i = 0; i < lconf->n_tasks_run; ++i) {
46 tasks[i] = lconf->tasks_run[i];
50 if (cur_tsc > drain_tsc) {
51 drain_tsc = cur_tsc + DRAIN_TIMEOUT;
52 lconf_flush_all_queues(lconf);
55 for (uint8_t task_id = 0; task_id < n_tasks_run; ++task_id) {
56 struct task_base *t = tasks[task_id];
57 uint16_t nb_rx = t->rx_pkt(t, &mbufs);
60 handle_nop_bulk(t, mbufs, nb_rx);