From 95743d510e222fadf6394bd2efd1cc1153de65c8 Mon Sep 17 00:00:00 2001 From: Chunsong Feng Date: Fri, 10 Dec 2021 02:27:58 +0000 Subject: [PATCH] msg/async/dpdk: add NIC whitelist configuration Each DPDK process uses some exclusive network adapters.The network adapters to be used are specified in the whitelist to prevent data sharing between multiple DPDK process.The following is an example: 1)Configure a single NIC. -a 0000:7d:010 or --allow=0000:7d:010 2)Configure the Bond Network Adapter ms_dpdk_port_options=--allow=0000:7d:01.0 --allow=0000:7d:02.6 --vdev=net_bonding0,mode=2,slave=0000:7d:01.0,slave=0000:7d:02.6 Signed-off-by: Chunsong Feng Reviewed-by: luo rixin Reviewed-by: Han Fengzhe --- src/common/options/global.yaml.in | 7 +++++++ src/msg/async/dpdk/dpdk_rte.cc | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index 80e7b9dc34a5c..1c81c3a1701cb 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -1441,6 +1441,13 @@ options: type: str level: advanced with_legacy: true +- name: ms_dpdk_devs_allowlist + type: str + level: advanced + desc: NIC's PCIe address are allowed to use + long_desc: for a single NIC use ms_dpdk_devs_allowlist=-a 0000:7d:010 or --allow=0000:7d:010; + for a bond nics use ms_dpdk_devs_allowlist=--allow=0000:7d:01.0 --allow=0000:7d:02.6 + --vdev=net_bonding0,mode=2,slave=0000:7d:01.0,slave=0000:7d:02.6. - name: ms_dpdk_host_ipv4_addr type: str level: advanced diff --git a/src/msg/async/dpdk/dpdk_rte.cc b/src/msg/async/dpdk/dpdk_rte.cc index 3ebb64360b04a..9b0c43329cb5b 100644 --- a/src/msg/async/dpdk/dpdk_rte.cc +++ b/src/msg/async/dpdk/dpdk_rte.cc @@ -23,6 +23,8 @@ #include #include +#include "include/str_map.h" + #include "DPDK.h" #include "dpdk_rte.h" @@ -123,6 +125,14 @@ namespace dpdk { args.push_back(string2vector("--no-huge")); } + for_each_pair(cct->_conf.get_val("ms_dpdk_devs_allowlist"), " ", + [&args] (std::string_view key, std::string_view val) { + args.push_back(string2vector(std::string(key))); + if (!val.empty()) { + args.push_back(string2vector(std::string(val))); + } + }); + std::string rte_file_prefix; rte_file_prefix = "rte_"; rte_file_prefix += cct->_conf->name.to_str(); -- 2.39.5