Report failure when tap port is not mapped to real dpdk port.
[samplevnf.git] / VNFs / DPPD-PROX / handle_tsc.c
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 */
16
17 #include <rte_mbuf.h>
18 #include <rte_cycles.h>
19
20 #include "task_base.h"
21 #include "task_init.h"
22 #include "thread_generic.h"
23
24 struct task_tsc {
25         struct task_base base;
26 };
27
28 static int handle_bulk_tsc(struct task_base *tbase, struct rte_mbuf **mbufs, uint16_t n_pkts)
29 {
30         struct task_tsc *task = (struct task_tsc *)tbase;
31         const uint64_t rx_tsc = rte_rdtsc();
32
33         for (uint16_t j = 0; j < n_pkts; ++j)
34                 mbufs[j]->udata64 = rx_tsc;
35
36         return task->base.tx_pkt(&task->base, mbufs, n_pkts, NULL);
37 }
38
39 static struct task_init task_init = {
40         .mode_str = "tsc",
41         .init = NULL,
42         .handle = handle_bulk_tsc,
43         .flag_features = TASK_FEATURE_NEVER_DISCARDS|TASK_FEATURE_TXQ_FLAGS_NOOFFLOADS|TASK_FEATURE_THROUGHPUT_OPT,
44         .size = sizeof(struct task_tsc),
45 };
46
47 __attribute__((constructor)) static void reg_task_nop(void)
48 {
49         reg_task(&task_init);
50 }