-
Notifications
You must be signed in to change notification settings - Fork 722
Specify queue id as a configuration parameter #2009
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
Open
JasMetzger
wants to merge
8
commits into
seladb:dev
Choose a base branch
from
JasMetzger:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+74
−4
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c7b00f5
Configure queue id for XDP Device (socket)
fe735fe
Utility to find HW queues for device
db23ec3
Remove old check for queueid
a0906cf
Fix doxygen error
e6a1e9b
Fix doxygen error
7ab1f01
Merge branch 'dev' into dev
seladb a8d97bf
Formatting and bug
cb5e47e
Minor adjustments recommended
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
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 |
|---|---|---|
|
|
@@ -10,9 +10,11 @@ | |
| #include <net/if.h> | ||
| #include <sys/mman.h> | ||
| #include <unistd.h> | ||
| #include <dirent.h> | ||
| #include <vector> | ||
| #include <functional> | ||
| #include <algorithm> | ||
| #include <regex> | ||
| #include <poll.h> | ||
|
|
||
| namespace pcpp | ||
|
|
@@ -419,7 +421,7 @@ namespace pcpp | |
| xskConfig.xdp_flags = XDP_FLAGS_DRV_MODE; | ||
| } | ||
|
|
||
| int ret = xsk_socket__create(&socketInfo->xsk, m_InterfaceName.c_str(), 0, umemInfo->umem, &socketInfo->rx, | ||
| int ret = xsk_socket__create(&socketInfo->xsk, m_InterfaceName.c_str(), m_Config->queueId, umemInfo->umem, &socketInfo->rx, | ||
| &socketInfo->tx, &xskConfig); | ||
| if (ret) | ||
| { | ||
|
|
@@ -429,6 +431,7 @@ namespace pcpp | |
| } | ||
|
|
||
| m_SocketInfo = socketInfo; | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -449,6 +452,7 @@ namespace pcpp | |
| uint32_t rxSize = config.rxSize ? config.rxSize : XSK_RING_CONS__DEFAULT_NUM_DESCS; | ||
| uint32_t txSize = config.txSize ? config.txSize : XSK_RING_PROD__DEFAULT_NUM_DESCS; | ||
| uint32_t batchSize = config.rxTxBatchSize ? config.rxTxBatchSize : DEFAULT_BATCH_SIZE; | ||
| uint32_t qId = config.queueId; // default is zero | ||
|
|
||
| if (frameSize != getpagesize()) | ||
| { | ||
|
|
@@ -499,13 +503,21 @@ namespace pcpp | |
| return false; | ||
| } | ||
|
|
||
| unsigned int nhwqueues = getNumQueues(m_InterfaceName); | ||
| if (qId >= nhwqueues) | ||
| { | ||
| PCPP_LOG_ERROR("Queue Id (" << qId << ") must be less than the number hardware queues (" << nhwqueues << ") of device"); | ||
| return false; | ||
| } | ||
|
|
||
| config.umemNumFrames = numFrames; | ||
| config.umemFrameSize = frameSize; | ||
| config.fillRingSize = fillRingSize; | ||
| config.completionRingSize = completionRingSize; | ||
| config.rxSize = rxSize; | ||
| config.txSize = txSize; | ||
| config.rxTxBatchSize = batchSize; | ||
| config.queueId = qId; | ||
|
|
||
| return true; | ||
| } | ||
|
|
@@ -636,4 +648,36 @@ namespace pcpp | |
| return m_Stats; | ||
| } | ||
|
|
||
| uint32_t XdpDevice::getNumQueues(const std::string& iface, bool tx) | ||
| { | ||
| // returns number of hardware queues associated with the device | ||
| uint32_t rxtxqueues = 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can we rename this to |
||
| std::string prefix = tx ? "tx-" : "rx-"; | ||
| std::string path = "/sys/class/net/" + iface + "/queues/"; | ||
| DIR *dir = opendir(path.c_str()); | ||
|
|
||
| if(dir) | ||
| { | ||
| std::regex rxtx_regex("^" + prefix + "[0-9]+$"); | ||
|
|
||
| struct dirent* entry; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Curious why the |
||
| while((entry = readdir(dir)) != nullptr) | ||
| { | ||
| if(std::regex_match(entry->d_name, rxtx_regex)) | ||
| { | ||
| rxtxqueues++; | ||
| } | ||
| } | ||
|
|
||
| closedir(dir); | ||
| } | ||
|
|
||
| else | ||
| { | ||
| PCPP_LOG_ERROR("Error getting number of hardware queues from " << iface); | ||
| } | ||
|
|
||
| return rxtxqueues; | ||
| } | ||
|
|
||
| } // namespace pcpp | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this method can be marked as
const?