Commit bdb3da77 authored by Federico Vaga's avatar Federico Vaga

wrtd:*: optimize data structure size and alignment

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>


NOTE
This commit has been created by `git subtree` on the Mock Turtle repository
on tag mock-turtle-2.0

This commit will not compile
parent 4aafefc7
......@@ -236,7 +236,12 @@ struct wrtd_trig_id {
/**
* Trigger event
* Trigger event. It is shared between the user-space and the
* real time application. Those end-point use this structure to share
* information.
* It should have 32bit fields to avoid toubles with the muck turtle
* bit swapping. If not possible on user space you must fix the bit swapping
* manually where necessary.
*/
struct wrtd_trigger_entry {
struct wr_timestamp ts; /**< when it fired */
......@@ -417,11 +422,11 @@ struct wrtd_out_trigger {
#define ENTRY_FLAG_VALID (1 << 0)
struct wrtd_out_channel_stats {
unsigned int hits;
unsigned int miss_timeout;
unsigned int miss_deadtime;
unsigned int miss_overflow;
unsigned int miss_no_timing;
uint32_t hits;
uint32_t miss_timeout;
uint32_t miss_deadtime;
uint32_t miss_overflow;
uint32_t miss_no_timing;
struct wrtd_trigger_entry last_executed; /**< Last enqueued trigger
(i.e. the last one that
......@@ -433,17 +438,25 @@ struct wrtd_out_channel_stats {
struct wrtd_trigger_entry last_lost;
};
/**
* Channel configuration parameters. It is shared between the user-space and the
* real time application. Those end-point use this structure to share
* information.
* It should have 32bit fields to avoid toubles with the muck turtle
* bit swapping. If not possible on user space you must fix the bit swapping
* manually where necessary.
*/
struct wrtd_out_channel_config {
uint8_t idle; /**< Idle flag */
uint8_t state; /**< Arm state */
uint8_t mode; /**< Trigger mode */
uint8_t flags; /**< Flags (logging, etc) */
uint32_t state; /**< Arm state */
uint32_t mode; /**< Trigger mode */
uint32_t flags; /**< Flags (logging, etc) */
uint32_t log_level; /**< Current logging level */
uint32_t dead_time; /**< Dead time (8ns cycles) */
uint32_t width_cycles; /**< Pulse width (8ns cycles) */
};
struct wrtd_out_channel_private {
uint32_t idle; /**< Idle flag */
struct lrt_pulse_queue queue; /**< Output pulse queue */
struct lrt_output_rule *pending_trig; /**< Pending conditonal trigger */
struct wr_timestamp prev_pulse; /**< Last enqueued trigger + delay
......@@ -452,7 +465,7 @@ struct wrtd_out_channel_private {
struct wrtd_out_channel {
uint32_t base_addr;
int n;
uint32_t n;
struct wrtd_out_channel_stats stats;
struct wrtd_out_channel_config config;
struct wrtd_out_channel_private priv;
......
......@@ -379,7 +379,7 @@ void update_latency_stats (struct pulse_queue_entry *pq_ent)
void drop_trigger( struct wrtd_out_channel *out, struct pulse_queue_entry *pq_ent, struct lrt_pulse_queue *q, int reason)
{
out->config.idle = 1;
out->priv.idle = 1;
if(pulse_queue_empty(q))
return;
......@@ -414,7 +414,7 @@ void do_output (struct wrtd_out_channel *out)
uint32_t dcr = fd_ch_readl(out, FD_REG_DCR);
/* Check if the output has triggered */
if(!out->config.idle) {
if(!out->priv.idle) {
if( !wr_is_timing_ok() ) {
drop_trigger(out, pq_ent, q, WRTD_MISS_NO_WR);
}
......@@ -427,7 +427,7 @@ void do_output (struct wrtd_out_channel *out)
pq_ent->rule->hits ++;
pulse_queue_pop(q);
out->stats.hits++;
out->config.idle = 1;
out->priv.idle = 1;
out->config.flags |= WRTD_TRIGGERED;
if(out->config.state == OUT_ST_TEST_PENDING)
......@@ -477,7 +477,7 @@ void do_output (struct wrtd_out_channel *out)
/* Store the last programmed timestamp (+ some margin) and mark the output as busy */
out->stats.last_programmed = *ts;
out->config.idle = 0;
out->priv.idle = 0;
update_latency_stats (pq_ent);
}
......@@ -896,9 +896,10 @@ void init(void)
wrtd_out_channels[i].config.mode = WRTD_TRIGGER_MODE_AUTO;
wrtd_out_channels[i].priv.pending_trig = NULL;
wrtd_out_channels[i].config.state = OUT_ST_IDLE;
wrtd_out_channels[i].config.idle = 1;
wrtd_out_channels[i].priv.idle = 1;
wrtd_out_channels[i].config.dead_time = 80000 / 8; // 80 us
wrtd_out_channels[i].config.width_cycles = 1250; // 1us
pp_printf("mode %d %d\n", i , wrtd_out_channels[i].config.mode);
}
/* Triggers */
......@@ -916,7 +917,6 @@ void init(void)
for (i = 0, j = __WRTD_OUT_STRUCT_MAX; i < FD_HASH_ENTRIES; i++, j++) {
wrtd_out_structures[j].struct_ptr = &triggers[i];
wrtd_out_structures[j].len = sizeof(struct wrtd_out_trigger);
pp_printf("%d %d - %d\n", i , j, wrtd_out_structures[j].len);
}
pp_printf("rt-output firmware initialized.\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment