FD.io VPP  v19.04-6-g6f05f72
Vector Packet Processing
thread.c
Go to the documentation of this file.
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 <dpdk/device/dpdk.h>
46 #include <dpdk/device/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 *
60 {
61  return 0;
62 }
63 
64 static vlib_thread_callbacks_t callbacks = {
66  .vlib_thread_set_lcore_cb = &dpdk_thread_set_lcore,
67 };
68 
69 static clib_error_t *
71 {
72  vlib_thread_cb_register (vm, &callbacks);
73  return 0;
74 }
75 
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  */
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
static clib_error_t * dpdk_thread_init(vlib_main_t *vm)
Definition: thread.c:70
#define clib_error_return(e, args...)
Definition: error.h:99
pthread_t thread[MAX_CONNS]
Definition: main.c:142
unsigned int u32
Definition: types.h:88
static clib_error_t * dpdk_thread_set_lcore(u32 thread, u16 lcore)
Definition: thread.c:59
int vlib_thread_cb_register(struct vlib_main_t *vm, vlib_thread_callbacks_t *cb)
Definition: threads.c:1799
unsigned short u16
Definition: types.h:57
vlib_main_t * vm
Definition: buffer.c:312
clib_error_t *(* vlib_launch_thread_cb)(void *fp, vlib_worker_thread_t *w, unsigned cpu_id)
Definition: threads.h:275
static clib_error_t * dpdk_launch_thread(void *fp, vlib_worker_thread_t *w, unsigned lcore_id)
Definition: thread.c:49