-
Notifications
You must be signed in to change notification settings - Fork 237
transceivers: Implement double-polling for transceiver temperatures #2668
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: master
Are you sure you want to change the base?
Changes from all commits
12f2786
f08e458
439e9b0
755934d
8618c34
afaeaa4
3adcb7a
d1e0866
0c080db
ff00d97
7b824bd
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,9 +2,12 @@ | |||||||||||||||||||||||||||||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||||||||||||||||||||||||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| use core::sync::atomic::{AtomicU32, Ordering}; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| use crate::{Addr, FrontIOError, Reg}; | ||||||||||||||||||||||||||||||
| use drv_fpga_api::{FpgaError, FpgaUserDesign, ReadOp, WriteOp}; | ||||||||||||||||||||||||||||||
| use drv_transceivers_api::{ModuleStatus, NUM_PORTS}; | ||||||||||||||||||||||||||||||
| use ringbuf::Count; | ||||||||||||||||||||||||||||||
| use transceiver_messages::ModuleId; | ||||||||||||||||||||||||||||||
| use userlib::UnwrapLite; | ||||||||||||||||||||||||||||||
| use zerocopy::{ | ||||||||||||||||||||||||||||||
|
|
@@ -134,6 +137,24 @@ impl LogicalPort { | |||||||||||||||||||||||||||||
| PortLocation::from(*self) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /// Implement the ringbuf trait on LogicalPort to allow for per-port metrics | ||||||||||||||||||||||||||||||
| impl Count for LogicalPort { | ||||||||||||||||||||||||||||||
| type Counters = [AtomicU32; NUM_PORTS as usize]; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #[allow(clippy::declare_interior_mutable_const)] | ||||||||||||||||||||||||||||||
| const NEW_COUNTERS: Self::Counters = | ||||||||||||||||||||||||||||||
| [const { AtomicU32::new(0) }; NUM_PORTS as usize]; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| fn count(&self, counters: &Self::Counters) { | ||||||||||||||||||||||||||||||
| // This should never happen, but just in case. | ||||||||||||||||||||||||||||||
| let Some(ctr) = counters.get(self.0 as usize) else { | ||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
| ctr.fetch_add(1, Ordering::Relaxed); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+142
to
+156
Member
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. this is cute; I wonder if we might want the hubris/drv/psc-seq-server/src/main.rs Lines 390 to 403 in 0d1ba04
but that then requires some weirdish boilerplate for converting between the enum and integers if you also want to index arrays or whatever. very much not a blocker for this PR, but I wonder if we might throw together a little newtype-integer-counter derive or something that works like this. |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /// Represents a set of selected logical ports, i.e. a 32-bit bitmask | ||||||||||||||||||||||||||||||
| #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] | ||||||||||||||||||||||||||||||
| pub struct LogicalPortMask(pub u32); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
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.
counters trait?