Commit a0d2fba5 authored by Dimitris Lampridis's avatar Dimitris Lampridis Committed by Dimitris Lampridis

sw: rework WRTD attributes

parent fed05a7e
......@@ -29,14 +29,12 @@
class WrtdAlarm extends WrtdRepCap;
protected WrtdTstamp setup_time;
protected wrtd_event ev;
protected int repeat_count;
protected uint32_t period_ns;
function new ( string name = "" );
super.new ( name );
this.setup_time = new();
this.ev.ts = new();
this.ev.id = new();
clear();
......@@ -44,7 +42,6 @@ class WrtdAlarm extends WrtdRepCap;
function void clear ( );
super.clear();
this.setup_time.zero();
this.ev.ts.zero();
this.ev.id.clear();
this.ev.seq = 0;
......@@ -55,26 +52,24 @@ class WrtdAlarm extends WrtdRepCap;
function wrtd_data data_pack ( );
wrtd_data ret = new[`WRTD_ALRM_WORD_SIZE];
ret[0:2] = this.setup_time.data_pack();
ret[3:5] = this.ev.ts.data_pack();
ret[6:9] = this.ev.id.data_pack();
ret[10] = this.ev.seq;
ret[11] = this.ev.flags;
ret[12] = this.enabled;
ret[13] = this.repeat_count;
ret[14] = this.period_ns;
ret[0:2] = this.ev.ts.data_pack();
ret[3:6] = this.ev.id.data_pack();
ret[7] = this.ev.seq;
ret[8] = this.ev.flags;
ret[9] = this.enabled;
ret[10] = this.repeat_count;
ret[11] = this.period_ns;
return ret;
endfunction // data_pack
function void data_unpack ( wrtd_data data );
this.setup_time.data_unpack ( data[0:2] );
this.ev.ts.data_unpack ( data[3:5] );
this.ev.id.data_unpack ( data[6:9] );
this.ev.seq = data[10];
this.ev.flags = data[11];
this.enabled = data[12];
this.repeat_count = data[13];
this.period_ns = data[14];
this.ev.ts.data_unpack ( data[0:2] );
this.ev.id.data_unpack ( data[3:6] );
this.ev.seq = data[7];
this.ev.flags = data[8];
this.enabled = data[9];
this.repeat_count = data[10];
this.period_ns = data[11];
endfunction // data_unpack
endclass //WrtdAlarm
......
......@@ -37,8 +37,8 @@
`define WRTD_IO_MSG_WORD_SIZE 2
`define WRTD_CFG_MSG_WORD_SIZE 5
`define WRTD_ROOT_WORD_SIZE 12
`define WRTD_RULE_WORD_SIZE 40
`define WRTD_ALRM_WORD_SIZE 15
`define WRTD_RULE_WORD_SIZE 43
`define WRTD_ALRM_WORD_SIZE 12
`define WRTD_DEST_CPU_LOCAL 'hfe
`define WRTD_DEST_CH_NET 'hff
......@@ -83,6 +83,7 @@ typedef enum uint32_t {
typedef enum uint32_t {
WRTD_LOG_DISCARD_NO_SYNC = 1,
WRTD_LOG_DISCARD_HOLDOFF,
WRTD_LOG_DISCARD_TIMEOUT,
WRTD_LOG_DISCARD_OVERFLOW
} wrtd_log_dsc_reason;
......
......@@ -37,18 +37,21 @@ class WrtdRule extends WrtdRepCap;
protected uint32_t delay_ns;
protected uint32_t hold_off_ns;
protected uint32_t resync_period_ns;
protected uint32_t resync_delay_ns;
protected uint32_t resync_factor;
int hash_chain;
protected uint32_t rx_events;
protected WrtdTstamp rx_last;
protected uint32_t tx_events;
protected WrtdTstamp tx_last;
protected uint32_t lat_min_ns;
protected uint32_t lat_max_ns;
protected uint32_t lat_lo_ns;
protected uint32_t lat_hi_ns;
protected uint32_t lat_nbr;
protected uint32_t miss_holdoff;
protected uint32_t miss_late;
protected uint32_t miss_nosync;
protected uint32_t miss_overflow;
protected WrtdTstamp miss_last;
protected WrtdTstamp hold_off;
protected uint32_t seq;
......@@ -79,7 +82,7 @@ class WrtdRule extends WrtdRepCap;
this.delay_ns = 0;
this.hold_off_ns = 0;
this.resync_period_ns = 0;
this.resync_delay_ns = 0;
this.resync_factor = 0;
this.hash_chain = -1;
endfunction // clear
......@@ -96,21 +99,24 @@ class WrtdRule extends WrtdRepCap;
ret[14] = this.delay_ns;
ret[15] = this.hold_off_ns;
ret[16] = this.resync_period_ns;
ret[17] = this.resync_delay_ns;
ret[17] = this.resync_factor;
ret[18] = this.hash_chain;
ret[19] = this.rx_events;
ret[20:22] = this.rx_last.data_pack();
ret[23] = this.tx_events;
ret[24:26] = this.tx_last.data_pack();
ret[27] = this.lat_max_ns;
ret[28] = this.lat_lo_ns;
ret[29] = this.lat_hi_ns;
ret[30] = this.lat_nbr;
ret[31] = this.miss_holdoff;
ret[32] = this.miss_late;
ret[33:35] = this.miss_last.data_pack();
ret[36:38] = this.hold_off.data_pack();
ret[39] = this.seq;
ret[27] = this.lat_min_ns;
ret[28] = this.lat_max_ns;
ret[29] = this.lat_lo_ns;
ret[30] = this.lat_hi_ns;
ret[31] = this.lat_nbr;
ret[32] = this.miss_holdoff;
ret[33] = this.miss_late;
ret[34] = this.miss_nosync;
ret[35] = this.miss_overflow;
ret[36:38] = this.miss_last.data_pack();
ret[39:41] = this.hold_off.data_pack();
ret[42] = this.seq;
return ret;
endfunction // data_pack
......@@ -126,21 +132,24 @@ class WrtdRule extends WrtdRepCap;
this.delay_ns = data[14];
this.hold_off_ns = data[15];
this.resync_period_ns = data[16];
this.resync_delay_ns = data[17];
this.resync_factor = data[17];
this.hash_chain = data[18];
this.rx_events = data[19];
this.rx_last.data_unpack ( data[20:22] );
this.tx_events = data[23];
this.tx_last.data_unpack ( data[24:26] );
this.lat_max_ns = data[27];
this.lat_lo_ns = data[28];
this.lat_hi_ns = data[29];
this.lat_nbr = data[30];
this.miss_holdoff = data[31];
this.miss_late = data[32];
this.miss_last.data_unpack ( data[33:35] );
this.hold_off.data_unpack ( data[36:38] );
this.seq = data[39];
this.lat_min_ns = data[27];
this.lat_max_ns = data[28];
this.lat_lo_ns = data[29];
this.lat_hi_ns = data[30];
this.lat_nbr = data[31];
this.miss_holdoff = data[32];
this.miss_late = data[33];
this.miss_nosync = data[34];
this.miss_overflow = data[35];
this.miss_last.data_unpack ( data[36:38] );
this.hold_off.data_unpack ( data[39:41] );
this.seq = data[42];
endfunction // data_unpack
function string get_src ( );
......
......@@ -94,7 +94,8 @@ static void adcin_input(struct wrtd_adcin_dev *adcin)
ev.flags = 0;
wrtd_log(WRTD_LOG_MSG_EV_GENERATED,
WRTD_LOG_GENERATED_DEVICE + (i * 8), &ev, NULL);
WRTD_LOG_GENERATED_DEVICE + (i * 8),
NULL, &ev, NULL);
/* Pass to wrtd. */
wrtd_route_in(&ev);
......
......@@ -93,7 +93,7 @@ static void adcout_drop_trigger(struct wrtd_adcout_dev *dev,
/* Disarm the ADC output */
adcout_writel(dev, 0, ALT_TRIGIN_CTRL);
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, reason, ev, now);
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, reason, NULL, ev, now);
}
......@@ -127,7 +127,9 @@ static void adcout_output (struct wrtd_adcout_dev *dev)
}
} else {
/* Has been triggered. */
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED, WRTD_LOG_CONSUMED_DONE, ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED,
WRTD_LOG_CONSUMED_DONE,
NULL, ev, NULL);
adcout_out_queue_pop(q);
dev->idle = 1;
......@@ -153,7 +155,8 @@ static void adcout_output (struct wrtd_adcout_dev *dev)
adcout_writel(dev, ts->ns / 8, ALT_TRIGIN_CYCLES);
adcout_writel(dev, ALT_TRIGIN_CTRL_ENABLE, ALT_TRIGIN_CTRL);
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED, WRTD_LOG_CONSUMED_START, ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED, WRTD_LOG_CONSUMED_START,
NULL, ev, NULL);
ts_add2_ns (ts, 8000);
......@@ -166,21 +169,19 @@ static void adcout_output (struct wrtd_adcout_dev *dev)
dev->idle = 0;
}
static void adcout_local_output(struct wrtd_adcout_dev *dev,
struct wrtd_event *ev, unsigned ch)
static int adcout_local_output(struct wrtd_adcout_dev *dev,
struct wrtd_event *ev, unsigned ch)
{
struct wrtd_event *pq_ev;
pq_ev = adcout_out_queue_push(&dev->queue);
if (!pq_ev) {
/* overflow.
FIXME: stats ? */
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, WRTD_LOG_DISCARD_OVERFLOW,
ev, NULL);
return;
return -EOVERFLOW;
}
*pq_ev = *ev;
return 0;
}
static void adcout_init(struct wrtd_adcout_dev *dev)
......
......@@ -92,10 +92,9 @@ static inline int wr_sync_timeout(void)
#endif
}
static void wrtd_local_output(struct wrtd_event *ev, unsigned ch)
static int wrtd_local_output(struct wrtd_event *ev, unsigned ch)
{
adcout_local_output(&adcout0, ev, ch);
return;
return adcout_local_output(&adcout0, ev, ch);
}
static int wrtd_user_init(void)
......
......@@ -29,8 +29,8 @@ static int wr_link_up(void);
static int wr_time_locked(void);
static int wr_time_ready(void);
static void wr_enable_lock(int enable);
static int wrtd_local_output(struct wrtd_event *ev, unsigned ch);
static int wr_sync_timeout(void);
static void wrtd_local_output(struct wrtd_event *ev, unsigned ch);
static int wrtd_user_init(void);
static void wrtd_io(void);
......@@ -136,14 +136,13 @@ struct loopback_queue {
SMEM struct loopback_queue lqueues[NBR_CPUS];
static void wrtd_remote_output(struct wrtd_event *ev,
unsigned dest_cpu, unsigned ch)
static int wrtd_remote_output(struct wrtd_event *ev,
unsigned dest_cpu, unsigned ch)
{
volatile struct loopback_queue *q = &lqueues[dest_cpu];
if (q->count >= LOOPBACK_QUEUE_SIZE) {
/* FIXME: log. */
return;
if (q->count >= LOOPBACK_QUEUE_SIZE) {
return -EOVERFLOW;
}
/* Get lock. */
......@@ -158,8 +157,10 @@ static void wrtd_remote_output(struct wrtd_event *ev,
q->buf[q->write_idx].ev = *ev;
q->buf[q->write_idx].ch = ch;
q->write_idx = (q->write_idx + 1) & (LOOPBACK_QUEUE_SIZE - 1);
smem_atomic_add(&q->count, 1);
smem_atomic_add(&q->count, 1);
q->lock = 0;
return 0;
}
static void wrtd_recv_loopback(void)
......@@ -234,12 +235,35 @@ static void ts_now(struct wrtd_tstamp *now)
}
static void wrtd_log(uint32_t type, uint32_t reason,
struct wrtd_rule *rule,
const struct wrtd_event *ev,
const struct wrtd_tstamp *ts)
{
struct wrtd_log_entry *log;
struct trtl_fw_msg msg;
int ret;
struct wrtd_log_entry *log;
struct trtl_fw_msg msg;
struct wrtd_tstamp now;
int ret;
/* First, handle statistics */
if ((type == WRTD_LOG_MSG_EV_DISCARDED) && (rule != NULL)) {
rule->stat.miss_last = ev->ts;
switch (reason) {
case WRTD_LOG_DISCARD_NO_SYNC:
rule->stat.miss_nosync++;
break;
case WRTD_LOG_DISCARD_HOLDOFF:
rule->stat.miss_holdoff++;
break;
case WRTD_LOG_DISCARD_TIMEOUT:
rule->stat.miss_late++;
break;
case WRTD_LOG_DISCARD_OVERFLOW:
rule->stat.miss_overflow++;
break;
default:
break;
}
}
if (!(root.log_flags & (1 << type))) {
root.log_nbr_discarded++;
......@@ -252,7 +276,12 @@ static void wrtd_log(uint32_t type, uint32_t reason,
return;
}
mq_map_out_message(TRTL_HMQ, WRTD_HMQ, &msg);
if ( ts == NULL )
ts_now(&now);
else
now = *ts;
mq_map_out_message(TRTL_HMQ, WRTD_HMQ, &msg);
msg.header->flags = 0;
msg.header->msg_id = WRTD_ACTION_LOG;
......@@ -265,11 +294,10 @@ static void wrtd_log(uint32_t type, uint32_t reason,
log->event = *ev;
else
memset(&log->event, 0, sizeof(struct wrtd_event));
if (ts != NULL)
log->ts = *ts;
else
memset(&log->ts, 0, sizeof(struct wrtd_tstamp));
mq_send(TRTL_HMQ, WRTD_HMQ);
log->ts = now;
mq_send(TRTL_HMQ, WRTD_HMQ);
root.log_nbr_sent++;
}
......@@ -290,16 +318,14 @@ static void wrtd_init_tx(void)
rmq_bind_out(WRTD_RMQ, TRTL_EP_ETH, &addr);
}
static void wrtd_send_network(struct wrtd_event *ev)
static int wrtd_send_network(struct wrtd_event *ev)
{
int ret;
struct trtl_fw_msg fw_msg;
ret = mq_claim(TRTL_RMQ, WRTD_RMQ);
if (ret < 0) {
/* FIXME: log ? */
pr_error("RMQ full\n\r");
return;
return -EOVERFLOW;
}
mq_map_out_message(TRTL_RMQ, WRTD_RMQ, &fw_msg);
......@@ -325,9 +351,11 @@ static void wrtd_send_network(struct wrtd_event *ev)
msg->zero[1] = 0;
msg->pad[0] = 0;
mq_send(TRTL_RMQ, WRTD_RMQ);
mq_send(TRTL_RMQ, WRTD_RMQ);
wrtd_log(WRTD_LOG_MSG_EV_NETWORK, WRTD_LOG_NETWORK_TX, NULL, ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_NETWORK, WRTD_LOG_NETWORK_TX, ev, NULL);
return 0;
}
#endif
......@@ -346,9 +374,9 @@ static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
one. */
if (rule->conf.hold_off_ns) {
if (ts_cmp(&ev->ts, &rule->stat.hold_off) < 0) {
rule->stat.miss_holdoff++;
rule->stat.miss_last = ev->ts;
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, 0, ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED,
WRTD_LOG_DISCARD_HOLDOFF,
rule, ev, NULL);
return;
}
......@@ -396,8 +424,11 @@ static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
if (r != 0)
ts_add2_ns(&tev.ts, rule->conf.resync_period_ns - r);
tev.ts.frac = 0;
if (rule->conf.resync_factor)
ts_add2_ns(&tev.ts,
rule->conf.resync_period_ns *
rule->conf.resync_factor);
}
ts_add2_ns(&tev.ts, rule->conf.resync_delay_ns);
/* Check with current time. */
if (!rule->conf.send_late) {
......@@ -405,9 +436,9 @@ static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
|| (tev.ts.seconds == now.seconds
&& tev.ts.ns < now.ns)) {
/* Too late... */
rule->stat.miss_late++;
rule->stat.miss_last = ev->ts;
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, 0, ev, &now);
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED,
WRTD_LOG_DISCARD_TIMEOUT,
rule, ev, &now);
return;
}
}
......@@ -423,29 +454,45 @@ static void wrtd_route(struct wrtd_rule *rule, const struct wrtd_event *ev)
memcpy(tev.id, rule->conf.dest_id, WRTD_ID_LEN);
tev.seq = rule->stat.seq++;
/* Send. */
rule->stat.tx_events++;
rule->stat.tx_last = ev->ts;
uint32_t res = 0;
/* Check timing. */
if (!wr_is_timing_ok()) {
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED,
WRTD_LOG_DISCARD_NO_SYNC,
rule, ev, &now);
return;
}
/* Send. */
if (rule->conf.dest_ch == WRTD_DEST_CH_NET) {
#if WRTD_NET_TX > 0
wrtd_send_network(&tev);
res = wrtd_send_network(&tev);
#else
wrtd_remote_output
res = wrtd_remote_output
(&tev, rule->conf.dest_cpu, WRTD_DEST_CH_NET);
#endif
}
else {
if (rule->conf.dest_cpu != WRTD_DEST_CPU_LOCAL) {
#if NBR_CPUS > 1
wrtd_remote_output
res = wrtd_remote_output
(&tev, rule->conf.dest_cpu, rule->conf.dest_ch);
#endif
} else {
/* Local delivery. */
wrtd_local_output(&tev, rule->conf.dest_ch);
res = wrtd_local_output(&tev, rule->conf.dest_ch);
}
}
if (res == -EOVERFLOW) {
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED,
WRTD_LOG_DISCARD_OVERFLOW,
rule, ev, &now);
}
else if (res == 0) {
rule->stat.tx_events++;
rule->stat.tx_last = ev->ts;
}
}
#if WRTD_LOCAL_RX > 0 || WRTD_NET_RX > 0 || NBR_ALARMS > 0
......@@ -507,11 +554,10 @@ static void wrtd_recv_network(void)
mq_discard(TRTL_RMQ, WRTD_RMQ);
wrtd_log(WRTD_LOG_MSG_EV_NETWORK, WRTD_LOG_NETWORK_RX, &ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_NETWORK, WRTD_LOG_NETWORK_RX, NULL, &ev, NULL);
wrtd_route_in(&ev);
/* FIXME: counter ? */
}
#endif
......@@ -530,11 +576,11 @@ static void wrtd_alarms(void)
if (!al->enabled)
continue;
if (ts_cmp(&al->setup_time, &now) > 0)
if (ts_cmp(&al->event.ts, &now) > 0)
continue;
wrtd_log(WRTD_LOG_MSG_EV_GENERATED, WRTD_LOG_GENERATED_ALARM,
&al->event, &now);
NULL, &al->event, &now);
/* Trigger. */
wrtd_route_in(&al->event);
......@@ -553,7 +599,6 @@ static void wrtd_alarms(void)
continue;
}
ts_add2_ns(&al->event.ts, al->period_ns);
ts_add2_ns(&al->setup_time, al->period_ns);
}
}
#endif
......
......@@ -184,7 +184,7 @@ static void drop_trigger(struct wrtd_fd_channel *out,
/* Disarm the FD output */
fd_ch_writel(out, FD_DCR_MODE, FD_REG_DCR);
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, reason, ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, reason, NULL, ev, NULL);
}
......@@ -217,7 +217,8 @@ static void fd_output (struct wrtd_fd_dev *fd, unsigned channel)
} else {
/* Has been triggered. */
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED,
WRTD_LOG_CONSUMED_DONE, ev, NULL);
WRTD_LOG_CONSUMED_DONE,
NULL, ev, NULL);
pulse_queue_pop(q);
out->idle = 1;
......@@ -256,7 +257,8 @@ static void fd_output (struct wrtd_fd_dev *fd, unsigned channel)
fd_ch_writel(out, FD_DCR_MODE | FD_DCR_PG_ARM | FD_DCR_ENABLE,
FD_REG_DCR);
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED, WRTD_LOG_CONSUMED_START, ev, NULL);
wrtd_log(WRTD_LOG_MSG_EV_CONSUMED, WRTD_LOG_CONSUMED_START,
NULL, ev, NULL);
ts_add2_ns (ts, 8000);
......@@ -269,22 +271,20 @@ static void fd_output (struct wrtd_fd_dev *fd, unsigned channel)
out->idle = 0;
}
static void fd_local_output(struct wrtd_fd_dev *fd,
struct wrtd_event *ev, unsigned ch)
static int fd_local_output(struct wrtd_fd_dev *fd,
struct wrtd_event *ev, unsigned ch)
{
struct wrtd_fd_channel *out = &fd->channels[ch];
struct wrtd_event *pq_ev;
pq_ev = pulse_queue_push(&out->queue);
if (!pq_ev) {
/* overflow.
FIXME: stats ? */
wrtd_log(WRTD_LOG_MSG_EV_DISCARDED, WRTD_LOG_DISCARD_OVERFLOW,
ev, NULL);
return;
return -EOVERFLOW;
}
*pq_ev = *ev;
return 0;
}
static void fd_outputs(struct wrtd_fd_dev *fd)
......
......@@ -64,9 +64,9 @@ static inline int wr_sync_timeout(void)
#endif
}
static void wrtd_local_output(struct wrtd_event *ev, unsigned ch)
static int wrtd_local_output(struct wrtd_event *ev, unsigned ch)
{
fd_local_output(&fd0, ev, ch);
return fd_local_output(&fd0, ev, ch);
}
/**
......
......@@ -65,10 +65,10 @@ static inline int wr_sync_timeout(void)
#endif
}
static void wrtd_local_output(struct wrtd_event *ev, unsigned ch)
static int wrtd_local_output(struct wrtd_event *ev, unsigned ch)
{
/* No output. */
return;
return 0;
}
static int wrtd_user_init(void)
......
......@@ -274,7 +274,8 @@ static void tdc_input(struct wrtd_tdc_dev *tdc)
ev.flags = 0;
wrtd_log(WRTD_LOG_MSG_EV_GENERATED,
WRTD_LOG_GENERATED_DEVICE + (channel * 8), &ev, NULL);
WRTD_LOG_GENERATED_DEVICE + (channel * 8),
NULL, &ev, NULL);
/* Pass to wrtd. */
wrtd_route_in(&ev);
......
......@@ -85,7 +85,7 @@ struct wrtd_rule_config {
uint32_t hold_off_ns;
uint32_t resync_period_ns;
uint32_t resync_delay_ns;
uint32_t resync_factor;
/* Next rule id for the same hash; -1 for last. */
int32_t hash_chain;
......@@ -99,6 +99,7 @@ struct wrtd_rule_stats {
struct wrtd_tstamp tx_last;
/* Latency. */
uint32_t lat_min_ns;
uint32_t lat_max_ns;
uint32_t lat_lo_ns;
uint32_t lat_hi_ns;
......@@ -106,6 +107,8 @@ struct wrtd_rule_stats {
uint32_t miss_holdoff;
uint32_t miss_late;
uint32_t miss_nosync;
uint32_t miss_overflow;
struct wrtd_tstamp miss_last;
/* Events that occur before this time are discarded. */
......@@ -121,9 +124,6 @@ struct wrtd_rule {
};
struct wrtd_alarm {
/* Time when to generate the event. */
struct wrtd_tstamp setup_time;
/* Next time and id. */
struct wrtd_event event;
......@@ -256,6 +256,8 @@ enum wrtd_log_reason_type {
/* For DISCARDED: */
/* Not synchronized. */
WRTD_LOG_DISCARD_NO_SYNC = 1,
/* Hold-off violation. */
WRTD_LOG_DISCARD_HOLDOFF,
/* Timeout: event after time. */
WRTD_LOG_DISCARD_TIMEOUT,
/* No space in a queue. */
......
This diff is collapsed.
......@@ -7,6 +7,16 @@
#define WRTD_RETURN_IF_ERROR(status) if(status != WRTD_SUCCESS) return status
/* Add nanoseconds to an existing wrtd timestamp */
static inline void wrtd_ts_add_ns(struct wrtd_tstamp *ts, uint32_t ns)
{
ts->ns += ns;
while (ts->ns >= 1000000000) {
ts->ns -= 1000000000;
ts->seconds++;
}
}
/* Alarm when in user space. */
struct wrtd_lib_alarm {
/* CPU on which the alarm is. */
......@@ -136,7 +146,7 @@ enum wrtd_status wrtd_fill_rules(struct wrtd_dev *wrtd);
/* Count number of rules. */
enum wrtd_status wrtd_attr_get_rule_count(struct wrtd_dev *wrtd,
unsigned *value);
int32_t *value);
/* Reconfigure route tables and write-back rules. */
enum wrtd_status wrtd_reconfigure(struct wrtd_dev *wrtd);
......
......@@ -45,10 +45,12 @@ static enum wrtd_status wrtd_reconfigure_alloc_map(struct wrtd_dev *wrtd,
unsigned n;
unsigned i;
unsigned ch_in_idx, ch_out_idx;
int32_t nrules;
/* 1. Count number of rules. */
status = wrtd_attr_get_rule_count(wrtd, &map->nbr_rules);
status = wrtd_attr_get_rule_count(wrtd, &nrules);
WRTD_RETURN_IF_ERROR(status);
map->nbr_rules = nrules;
/* Count number of devices. */
n = 0;
......