475dd142157af67ff4e1839577b87a74f578275e
[vpp.git] / src / vnet / devices / dpdk / thread.c
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <rte_config.h>
17
18 #include <rte_common.h>
19 #include <rte_log.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_tailq.h>
23 #include <rte_eal.h>
24 #include <rte_per_lcore.h>
25 #include <rte_launch.h>
26 #include <rte_atomic.h>
27 #include <rte_cycles.h>
28 #include <rte_prefetch.h>
29 #include <rte_lcore.h>
30 #include <rte_per_lcore.h>
31 #include <rte_branch_prediction.h>
32 #include <rte_interrupts.h>
33 #include <rte_pci.h>
34 #include <rte_random.h>
35 #include <rte_debug.h>
36 #include <rte_ether.h>
37 #include <rte_ethdev.h>
38 #include <rte_ring.h>
39 #include <rte_mempool.h>
40 #include <rte_mbuf.h>
41 #include <rte_version.h>
42
43 #include <vlib/vlib.h>
44 #include <vnet/vnet.h>
45 #include <vnet/devices/dpdk/dpdk.h>
46 #include <vnet/devices/dpdk/dpdk_priv.h>
47
48 static clib_error_t *
49 dpdk_launch_thread (void *fp, vlib_worker_thread_t * w, unsigned lcore_id)
50 {
51   int r;
52   r = rte_eal_remote_launch (fp, (void *) w, lcore_id);
53   if (r)
54     return clib_error_return (0, "Failed to launch thread %u", lcore_id);
55   return 0;
56 }
57
58 static clib_error_t *
59 dpdk_thread_set_lcore (u32 thread, u16 lcore)
60 {
61   return 0;
62 }
63
64 static vlib_thread_callbacks_t callbacks = {
65   .vlib_launch_thread_cb = &dpdk_launch_thread,
66   .vlib_thread_set_lcore_cb = &dpdk_thread_set_lcore,
67 };
68
69 static clib_error_t *
70 dpdk_thread_init (vlib_main_t * vm)
71 {
72   vlib_thread_cb_register (vm, &callbacks);
73   return 0;
74 }
75
76 VLIB_INIT_FUNCTION (dpdk_thread_init);
77
78 /** @endcond */
79 /*
80  * fd.io coding-style-patch-verification: ON
81  *
82  * Local Variables:
83  * eval: (c-set-style "gnu")
84  * End:
85  */