-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dataplane: add simple cmd line parser ..
.. so that the GW dataplane can accept also non-EAL related params. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
- Loading branch information
1 parent
5d85763
commit 6c339d9
Showing
4 changed files
with
181 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Open Network Fabric Authors | ||
|
||
pub(crate) use clap::Parser; | ||
|
||
#[derive(Parser)] | ||
#[command(name = "Hedgehog Fabric Gateway dataplane")] | ||
#[command(version = "1.0")] // FIXME | ||
#[command(about = "A next-gen dataplane for next-gen fabric gateway", long_about = None)] | ||
pub(crate) struct CmdArgs { | ||
#[arg(long, value_name = "main-lcore", default_value_t = 2)] | ||
main_lcore: u8, | ||
#[arg(long, value_name = "lcores")] | ||
lcores: String, | ||
#[arg(long)] | ||
in_memory: Option<bool>, | ||
#[arg(long)] | ||
allow: Vec<String>, | ||
#[arg(long, value_name = "huge pages", default_value_t = 8192)] | ||
huge_worker_stack: u32, | ||
#[arg(long, value_name = "socket memory")] | ||
socket_mem: Option<String>, | ||
#[arg(long)] | ||
no_telemetry: Option<bool>, | ||
#[arg(long, value_name = "iova mode")] | ||
iova_mode: Option<String>, | ||
// other non-EAL params (NAT, routing, etc.) | ||
} | ||
impl CmdArgs { | ||
pub fn eal_params(&self) -> Vec<String> { | ||
let mut out = Vec::new(); | ||
|
||
out.push("--main-lcore".to_owned()); | ||
out.push(self.main_lcore.to_string()); | ||
|
||
out.push("--lcores".to_string()); | ||
out.push(self.lcores.to_string()); | ||
|
||
if self.in_memory.is_some() { | ||
out.push("--in-memory".to_string()); | ||
} | ||
if self.no_telemetry.is_some() { | ||
out.push("--no-telemetry".to_string()); | ||
} | ||
out.push(format!( | ||
"--iova-mode={}", | ||
&self | ||
.iova_mode | ||
.clone() | ||
.map_or_else(|| { "va".to_owned() }, |mode| mode.to_owned()) | ||
)); | ||
out.push(format!("--huge-worker-stack={}", self.huge_worker_stack)); | ||
|
||
for a in self.allow.iter() { | ||
out.push("--allow".to_string()); | ||
out.push(a.to_owned()); | ||
} | ||
out | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters