]>
git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/src/core/dpdk_rte.cc
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 #ifdef SEASTAR_HAVE_DPDK
21 #include <seastar/net/dpdk.hh>
22 #include <seastar/core/dpdk_rte.hh>
23 #include <seastar/util/conversions.hh>
24 #include <seastar/util/std-compat.hh>
31 bool eal::initialized
= false;
33 void eal::init(cpuset cpus
, const std::string
& argv0
, const std::optional
<std::string
>& hugepages_path
, bool dpdk_pmd
)
39 std::stringstream mask
;
42 mask
<< std::hex
<< (cpus
& nibble
).to_ulong();
46 std::string mask_str
= mask
.str();
47 std::reverse(mask_str
.begin(), mask_str
.end());
49 std::vector
<std::vector
<char>> args
{
51 string2vector("-c"), string2vector(mask_str
),
52 string2vector("-n"), string2vector("1")
55 // If "hugepages" is not provided and DPDK PMD drivers mode is requested -
56 // use the default DPDK huge tables configuration.
58 args
.push_back(string2vector("--huge-dir"));
59 args
.push_back(string2vector(hugepages_path
.value()));
62 // We don't know what is going to be our networking configuration so we
63 // assume there is going to be a queue per-CPU. Plus we'll give a DPDK
64 // 64MB for "other stuff".
66 size_t size_MB
= mem_size(cpus
.count()) >> 20;
67 std::stringstream size_MB_str
;
68 size_MB_str
<< size_MB
;
70 args
.push_back(string2vector("-m"));
71 args
.push_back(string2vector(size_MB_str
.str()));
72 } else if (!dpdk_pmd
) {
73 args
.push_back(string2vector("--no-huge"));
76 args
.push_back(string2vector("--no-shconf"));
79 std::vector
<char*> cargs
;
81 for (auto&& a
: args
) {
82 cargs
.push_back(a
.data());
84 /* initialise the EAL for all */
85 int ret
= rte_eal_init(cargs
.size(), cargs
.data());
87 rte_exit(EXIT_FAILURE
, "Cannot init EAL\n");
93 uint32_t __attribute__((weak
)) qp_mempool_obj_size(bool hugetlbfs_membackend
)
98 size_t eal::mem_size(int num_cpus
, bool hugetlbfs_membackend
)
102 // PMD mempool memory:
104 // We don't know what is going to be our networking configuration so we
105 // assume there is going to be a queue per-CPU.
107 memsize
+= num_cpus
* qp_mempool_obj_size(hugetlbfs_membackend
);
109 // Plus we'll give a DPDK 64MB for "other stuff".
110 memsize
+= (64UL << 20);
119 #endif // SEASTAR_HAVE_DPDK