2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
18 #ifndef CEPH_DPDK_RTE_H_
19 #define CEPH_DPDK_RTE_H_
22 #include <condition_variable>
27 #include <rte_config.h>
28 #include <rte_version.h>
29 #include <boost/program_options.hpp>
31 /*********************** Compat section ***************************************/
32 // We currently support only versions 2.0 and above.
33 #if (RTE_VERSION < RTE_VERSION_NUM(2,0,0,0))
34 #error "DPDK version above 2.0.0 is required"
37 #if defined(RTE_MBUF_REFCNT_ATOMIC)
38 #warning "CONFIG_RTE_MBUF_REFCNT_ATOMIC should be disabled in DPDK's " \
39 "config/common_linuxapp"
41 /******************************************************************************/
45 // DPDK Environment Abstraction Layer
48 using cpuset = std::bitset<RTE_MAX_LCORE>;
50 static std::mutex lock;
51 static std::condition_variable cond;
52 static std::list<std::function<void()>> funcs;
53 static int init(CephContext *c);
54 static void execute_on_master(std::function<void()> &&f) {
56 std::unique_lock<std::mutex> l(lock);
57 funcs.emplace_back([&]() { f(); done = true; });
63 * Returns the amount of memory needed for DPDK
64 * @param num_cpus Number of CPUs the application is going to use
68 static size_t mem_size(int num_cpus);
69 static bool initialized;
74 #endif // CEPH_DPDK_RTE_H_