-
Notifications
You must be signed in to change notification settings - Fork 36
[ChannelGenerator] Assign the channel only for circuit flow #1013
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
Conversation
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.
Could you document in the description and as a comment in the code what the assignment strategy is for packet routing (round robin) and why?
|
||
/// Returns its next usable producer channel. | ||
std::optional<uint8_t> getAndAssignProducerDMAChannel() { | ||
for (uint8_t i = 0; i < numProducerChannels; i++) { | ||
std::optional<uint8_t> getAndAssignProducerDMAChannel(bool isPacketFlow) { |
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.
getAndAssignProducerDMAChannel
indicates that a channel is retrieved and assigned. Not assigning it based on some internal condition will lead to confusion and potential bugs, so instead, I think we should have separate getDMAChannel
and assignChannel
(already exists) functions which can be called by a user (AssignChannels
) when appropriate. We can keep getAndAssignProducerDMAChannel
around if it is still useful and call getDMAChannel
and assignChannel
under the hood.
numConsumerChannels(numConsumerChannels) { | ||
assert(numProducerChannels > 0 && numConsumerChannels > 0 && | ||
"Invalid number of producer/consumer channels."); | ||
// Initialize to the last channel for round-robin usage. |
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.
I think it makes sense to have an AssignmentMode
similar to the ChannelBdIdGenerator
:
ChannelAssignmentMode {
FirstAvailable,
RoundRobin
}
Or if the logic differs quite a bit, use specialized child classes instead: RoundRobinChannelGenerator
, FirstAvailableChannelGenerator
.
DenseSet<uint8_t> assignedProducerChannels; | ||
DenseSet<uint8_t> assignedConsumerChannels; | ||
// Tracks the last used channel, for both circuit and packet flows. |
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.
There might be a bit of unclarity about what 'using' a DMA channel means, so I think 'lastRetrievedDMAChannel' might be a more clear name. And maybe document this as well.
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.
done
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.
LGTM
No description provided.