-
Notifications
You must be signed in to change notification settings - Fork 5
Add cmd line parser #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add cmd line parser #219
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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 hidden or 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,77 @@ | ||
// 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 = "core-id used as main", default_value_t = 2)] | ||
main_lcore: u8, | ||
#[arg(long, value_name = "map lcore set to cpu set")] | ||
lcores: Option<String>, | ||
#[arg(long, value_name = "PCI devices to probe")] | ||
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, value_name = "iova mode(va|pa)")] | ||
iova_mode: Option<String>, | ||
#[arg(long, value_name = "loglevel for a specific component")] | ||
daniel-noland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
log_level: Vec<String>, | ||
// other non-EAL params (NAT, routing, etc.) | ||
} | ||
impl CmdArgs { | ||
pub fn eal_params(&self) -> Vec<String> { | ||
let mut out = Vec::new(); | ||
/* hardcoded (always) */ | ||
out.push("--in-memory".to_string()); | ||
|
||
out.push("--main-lcore".to_owned()); | ||
out.push(self.main_lcore.to_string()); | ||
|
||
out.push("--lcores".to_string()); | ||
out.push( | ||
self.lcores | ||
.clone() | ||
.map_or_else(|| "2-4".to_owned(), |lcores| lcores.to_owned()), | ||
); | ||
|
||
/* IOVA mode */ | ||
out.push(format!( | ||
"--iova-mode={}", | ||
Fredi-raspall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&self | ||
.iova_mode | ||
.clone() | ||
.map_or_else(|| { "va".to_owned() }, |mode| mode.to_owned()) | ||
)); | ||
|
||
/* worker huge page stack size */ | ||
out.push(format!("--huge-worker-stack={}", self.huge_worker_stack)); | ||
|
||
/* --allow */ | ||
for a in self.allow.iter() { | ||
out.push("--allow".to_string()); | ||
out.push(a.to_owned()); | ||
} | ||
|
||
// To be removed | ||
if self.allow.len() == 0 { | ||
out.push("--allow".to_string()); | ||
out.push("0000:01:00.0,dv_flow_en=1".to_string()); | ||
Fredi-raspall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/* --log-level */ | ||
for level in self.log_level.iter() { | ||
out.push("--log-level".to_string()); | ||
out.push(level.to_owned()); | ||
} | ||
|
||
// To replace by log | ||
println!("DPDK EAL init params: {:#?}", out); | ||
|
||
out | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.