-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ComQueue queue ordering, drop mode, & command to reprioritize #4674
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
base: devel
Are you sure you want to change the base?
Changes from all commits
7fea326
a14624d
cc8de5e
093dfd4
249d58b
3cc8d9c
4d8ca15
55f8caf
8f9974b
01f99e0
5c0530e
df2368f
52222c9
56d8f4b
fc2e329
fc3cdd3
3093d14
9430e48
07628d6
e3405b0
ca8093a
02cf048
b8aaeb5
6fccfc9
b8aaef9
00f04d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ | |
| for (FwIndexType i = 0; i < static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->entries)); i++) { | ||
| this->entries[i].priority = 0; | ||
| this->entries[i].depth = 0; | ||
| this->entries[i].mode = Types::QUEUE_FIFO; | ||
| this->entries[i].overflowMode = Types::QUEUE_DROP_NEWEST; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -39,6 +41,8 @@ | |
| for (FwIndexType i = 0; i < TOTAL_PORT_COUNT; i++) { | ||
| this->m_throttle[i] = false; | ||
| } | ||
|
|
||
| static_assert(TOTAL_PORT_COUNT >= 1, "ComQueue must have more than one port"); | ||
| } | ||
|
|
||
| ComQueue ::~ComQueue() {} | ||
|
|
@@ -86,6 +90,8 @@ | |
| QueueMetadata& entry = this->m_prioritizedList[currentPriorityIndex]; | ||
| entry.priority = queueConfig.entries[entryIndex].priority; | ||
| entry.depth = queueConfig.entries[entryIndex].depth; | ||
| entry.mode = queueConfig.entries[entryIndex].mode; | ||
| entry.overflowMode = queueConfig.entries[entryIndex].overflowMode; | ||
| entry.index = entryIndex; | ||
| // Message size is determined by the type of object being stored, which in turn is determined by the | ||
| // index of the entry. Those lower than COM_PORT_COUNT are Fw::ComBuffers and those larger Fw::Buffer. | ||
|
|
@@ -119,7 +125,8 @@ | |
| if (allocationSize > 0) { | ||
| this->m_queues[this->m_prioritizedList[i].index].setup( | ||
| reinterpret_cast<U8*>(this->m_allocation) + allocationOffset, allocationSize, | ||
| this->m_prioritizedList[i].depth, this->m_prioritizedList[i].msgSize); | ||
| this->m_prioritizedList[i].depth, this->m_prioritizedList[i].msgSize, this->m_prioritizedList[i].mode, | ||
| this->m_prioritizedList[i].overflowMode); | ||
| } | ||
| allocationOffset += allocationSize; | ||
| } | ||
|
|
@@ -132,10 +139,16 @@ | |
| // Handler implementations for commands | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| void ComQueue ::FLUSH_QUEUE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::QueueType queueType, FwIndexType index) { | ||
| // Acquire the queue that we need to drain | ||
| FwIndexType queueIndex = | ||
| (queueType == QueueType::COM_QUEUE) ? index : static_cast<FwIndexType>(index + COM_PORT_COUNT); | ||
| FwIndexType queueIndex = this->getQueueNum(queueType, index); | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter queueType has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter index has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter queueType has not been checked.
|
||
|
|
||
| // Validate queue index | ||
| if (queueIndex < 0 || queueIndex >= TOTAL_PORT_COUNT) { | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR); | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter opCode has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter opCode has not been checked.
|
||
| return; | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter opCode has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter opCode has not been checked.
|
||
| } | ||
|
|
||
| this->drainQueue(queueIndex); | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | ||
| } | ||
|
|
@@ -145,8 +158,57 @@ | |
| this->drainQueue(i); | ||
| } | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | ||
| } | ||
|
|
||
| void ComQueue::SET_QUEUE_PRIORITY_cmdHandler(FwOpcodeType opCode, | ||
Check noticeCode scanning / CodeQL Long function without assertion
All functions of more than 10 lines should have at least one assertion.
Check noticeCode scanning / CodeQL Long function without assertion Note
All functions of more than 10 lines should have at least one assertion.
|
||
| U32 cmdSeq, | ||
| Svc::QueueType queueType, | ||
| FwIndexType index, | ||
| FwIndexType newPriority) { | ||
| // Acquire the queue we are to reprioritize | ||
| FwIndexType queueIndex = this->getQueueNum(queueType, index); | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter index has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter queueType has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter index has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter queueType has not been checked.
|
||
|
|
||
| // Validate queue index | ||
| if (queueIndex < 0 || queueIndex >= TOTAL_PORT_COUNT) { | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR); | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter opCode has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter opCode has not been checked.
|
||
| return; | ||
| } | ||
|
|
||
| // Validate priority range | ||
| if (newPriority < 0 || newPriority >= TOTAL_PORT_COUNT) { | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR); | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter opCode has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter cmdSeq has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter opCode has not been checked.
|
||
| return; | ||
| } | ||
|
|
||
| // Find our queue in the prioritized list & update the priority | ||
| for (FwIndexType prioIndex = 0; prioIndex < TOTAL_PORT_COUNT; prioIndex++) { | ||
| // If the port based index matches, then update | ||
| if (m_prioritizedList[prioIndex].index == queueIndex) { | ||
| m_prioritizedList[prioIndex].priority = newPriority; | ||
| break; // Since we shouldn't find more than one queue at this port index | ||
| } | ||
| } | ||
|
|
||
|
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. Should assert (static_assert) TOTAL_PORT_COUNT >= 1 |
||
| // Re-sort the prioritized list to maintain priority ordering | ||
| // Using simple bubble sort since TOTAL_PORT_COUNT is typically small | ||
| for (FwIndexType i = 0; i < TOTAL_PORT_COUNT - 1; i++) { | ||
| for (FwIndexType j = 0; j < TOTAL_PORT_COUNT - i - 1; j++) { | ||
| if (m_prioritizedList[j].priority > m_prioritizedList[j + 1].priority) { | ||
| // Swap metadata | ||
| QueueMetadata temp = m_prioritizedList[j]; | ||
| m_prioritizedList[j] = m_prioritizedList[j + 1]; | ||
| m_prioritizedList[j + 1] = temp; | ||
| } | ||
| } | ||
|
Comment on lines
195
to
202
Check warningCode scanning / CodeQL Unbounded loop
This loop does not have a fixed bound.
Comment on lines
+195
to
+202
Check warningCode scanning / CodeQL Unbounded loop Warning
This loop does not have a fixed bound.
|
||
| } | ||
|
|
||
| // Emit event for successful priority change | ||
| this->log_ACTIVITY_HI_QueuePriorityChanged(queueType, queueIndex, newPriority); | ||
|
|
||
| // Send command response | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Handler implementations for user-defined typed input ports | ||
| // ---------------------------------------------------------------------- | ||
|
|
@@ -251,24 +313,23 @@ | |
| static_cast<FwAssertArgType>(queueType), static_cast<FwAssertArgType>(queueNum)); | ||
| const FwIndexType portNum = | ||
| static_cast<FwIndexType>(queueNum - ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT)); | ||
| bool rvStatus = true; | ||
| FW_ASSERT(expectedSize == size, static_cast<FwAssertArgType>(size), static_cast<FwAssertArgType>(expectedSize)); | ||
| FW_ASSERT(portNum >= 0, static_cast<FwAssertArgType>(portNum)); | ||
| Fw::SerializeStatus status = this->m_queues[queueNum].enqueue(data, size); | ||
| if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT) { | ||
| if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT || status == Fw::FW_SERIALIZE_DISCARDED_EXISTING) { | ||
| if (!this->m_throttle[queueNum]) { | ||
| this->log_WARNING_HI_QueueOverflow(queueType, static_cast<U32>(portNum)); | ||
| this->log_WARNING_HI_QueueOverflow(queueType, portNum); | ||
| this->m_throttle[queueNum] = true; | ||
| } | ||
|
|
||
| rvStatus = false; | ||
| } | ||
|
|
||
| // When the component is already in READY state process the queue to send out the next available message immediately | ||
| if (this->m_state == READY) { | ||
| this->processQueue(); | ||
| } | ||
|
|
||
| return rvStatus; | ||
| // Check if the buffer was accepted or must be returned | ||
| return status != Fw::FW_SERIALIZE_NO_ROOM_LEFT; | ||
| } | ||
|
|
||
| void ComQueue::sendComBuffer(Fw::ComBuffer& comBuffer, FwIndexType queueIndex) { | ||
|
|
@@ -385,4 +446,9 @@ | |
| this->m_prioritizedList[priorityIndex - 1] = temp; | ||
| } | ||
| } | ||
|
|
||
| FwIndexType ComQueue::getQueueNum(Svc::QueueType queueType, FwIndexType portNum) { | ||
| // Acquire the queue that we need to drain | ||
| return static_cast<FwIndexType>(portNum + ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT)); | ||
Check warningCode scanning / CodeQL Unchecked function argument
This use of parameter portNum has not been checked.
Check warningCode scanning / CodeQL Unchecked function argument Warning
This use of parameter portNum has not been checked.
|
||
| } | ||
| } // end namespace Svc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| @ Flush a specific queue. This will discard all queued data in the specified queue removing it from eventual | ||
| @ downlink. Buffers requiring ownership return will be returned via the bufferReturnOut port. | ||
| async command FLUSH_QUEUE(queueType: QueueType @< The Queue data type | ||
| indexType: FwIndexType @< The index of the queue (within the supplied type) to flush | ||
| ) | ||
|
|
||
| @ Flush all queues. This will discard all queued data removing it from eventual downlink. Buffers requiring | ||
| @ ownership return will be returned via the bufferReturnOut port. | ||
| async command FLUSH_ALL_QUEUES() | ||
|
|
||
| @ Set the priority of a specific queue at runtime | ||
| async command SET_QUEUE_PRIORITY( | ||
| queueType: QueueType @< The Queue data type | ||
| indexType: FwIndexType @< The index of the queue (within the supplied type) to modify | ||
| newPriority: FwIndexType @< New priority value for the queue | ||
| ) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @ Queue overflow event | ||
| event QueueOverflow( | ||
| queueType: QueueType @< The Queue data type | ||
| index: FwIndexType @< index of overflowed queue | ||
| ) \ | ||
| severity warning high \ | ||
| format "The {} queue at index {} overflowed" | ||
|
|
||
| @ Queue priority changed event | ||
| event QueuePriorityChanged( | ||
| queueType: QueueType @< The Queue data type | ||
| indexType: FwIndexType @< The index of the queue (within the supplied type) that was modified | ||
| newPriority: FwIndexType @< New priority value | ||
| ) \ | ||
| severity activity high \ | ||
| format "{} {} priority changed to {}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @ Depth of queues of Fw::ComBuffer type | ||
| telemetry comQueueDepth: ComQueueDepth id 0 | ||
|
|
||
| @ Depth of queues of Fw::Buffer type | ||
| telemetry buffQueueDepth: BuffQueueDepth id 1 |
Check warning
Code scanning / CodeQL
Unchecked function argument