]>
git.proxmox.com Git - ceph.git/blob - ceph/src/msg/async/dpdk/dpdk_rte.h
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
>;
49 explicit eal(CephContext
*cct
) : cct(cct
) {}
52 void execute_on_master(std::function
<void()> &&f
) {
54 std::unique_lock
<std::mutex
> l(lock
);
55 funcs
.emplace_back([&]() { f(); done
= true; });
61 * Returns the amount of memory needed for DPDK
62 * @param num_cpus Number of CPUs the application is going to use
66 size_t mem_size(int num_cpus
);
67 static bool rte_initialized
;
70 bool initialized
= false;
74 std::condition_variable cond
;
75 std::list
<std::function
<void()>> funcs
;
79 #endif // CEPH_DPDK_RTE_H_