Commit 119ce5d4 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

kernel/wr-nic: use defines instead of hardcoded TS invalid bits, drop invalid…

kernel/wr-nic: use defines instead of hardcoded TS invalid bits, drop invalid timestamps instead of returning 0
parent ff9d1567
......@@ -352,8 +352,6 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
/* RX timestamping part */
hwts = skb_hwtstamps(skb);
wrn_ppsg_read_time(wrn, &counter_ppsg, &utc);
if(counter_ppsg < REFCLK_FREQ/4 && ts_r > 3*REFCLK_FREQ/4)
......@@ -372,10 +370,12 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
ts.tv_sec & 0x80000000 ? 1 :0);
/* If the timestamp was reported as incorrect, pass 0 instead */
if (r1 & (1 << 15)) /* FIXME: bit name possibly? */
hwts->hwtstamp = ns_to_ktime(0);
else
if (! (r1 & NIC_RX1_D1_TS_INCORRECT)) /* FIXME: bit name possibly? */
{
hwts = skb_hwtstamps(skb);
hwts->hwtstamp = timespec_to_ktime(ts);
}
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY;
dev->last_rx = jiffies;
......
/*
/*\
* Timestamping routines for WR Switch
*
* Copyright (C) 2010 CERN (www.cern.ch)
......@@ -37,7 +37,6 @@ void wrn_tstamp_find_skb(struct wrn_dev *wrn, int desc)
pr_debug("%s: found\n", __func__);
/* so we found the skb, do the timestamping magic */
hwts = skb_hwtstamps(skb);
wrn_ppsg_read_time(wrn, &counter_ppsg, &utc);
/* The timestamp nanoseconds value is closer to the end of previous second, but the UTC time
......@@ -48,11 +47,12 @@ void wrn_tstamp_find_skb(struct wrn_dev *wrn, int desc)
ts.tv_sec = (s32)utc & 0x7fffffff;
ts.tv_nsec = wrn->ts_buf[i].ts * NSEC_PER_TICK;
if (wrn->ts_buf[i].valid & TS_INVALID)
hwts->hwtstamp = ns_to_ktime(0);
else
if (! (wrn->ts_buf[i].valid & TS_INVALID))
{
hwts = skb_hwtstamps(skb);
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
skb_tstamp_tx(skb, hwts);
}
dev_kfree_skb_irq(skb);
/* release both the descriptor and the tstamp entry */
......@@ -61,11 +61,11 @@ void wrn_tstamp_find_skb(struct wrn_dev *wrn, int desc)
}
/* This function records the timestamp in a list -- called from interrupt */
static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg, u32 r2)
{
int port_id = TXTSU_TSF_R1_PID_R(idreg);
int frame_id = TXTSU_TSF_R1_FID_R(idreg);
int ts_invalid = 0 /* = ???(idreg) -- please fix this */ ;
int ts_incorrect = r2 & TXTSU_TSF_R2_INCORRECT;
struct skb_shared_hwtstamps *hwts;
struct timespec ts;
struct sk_buff *skb;
......@@ -83,7 +83,6 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
if (i < WRN_NR_DESC) {
/*printk("%s: found\n", __func__);*/
skb = wrn->skb_desc[i].skb;
hwts = skb_hwtstamps(skb);
wrn_ppsg_read_time(wrn, &counter_ppsg, &utc);
if(counter_ppsg < (tsval & 0xfffffff))
......@@ -91,11 +90,14 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
ts.tv_sec = (s32)utc & 0x7fffffff;
ts.tv_nsec = (tsval & 0xfffffff) * NSEC_PER_TICK;
if (ts_invalid)
hwts->hwtstamp = ns_to_ktime(0);
else
/* Provide the timestamp for the userland only if we're 100% sure about its correctness */
if (!ts_incorrect)
{
hwts = skb_hwtstamps(skb);
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
skb_tstamp_tx(skb, hwts);
}
dev_kfree_skb_irq(skb);
wrn->skb_desc[i].skb = 0;
return 0;
......@@ -114,7 +116,7 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
wrn->ts_buf[i].port_id = port_id;
wrn->ts_buf[i].frame_id = frame_id;
wrn->ts_buf[i].valid = TS_PRESENT;
if (invalid)
if (ts_incorrect)
wrn->ts_buf[i].valid |= TS_INVALID;
return 0;
}
......@@ -123,14 +125,15 @@ irqreturn_t wrn_tstamp_interrupt(int irq, void *dev_id)
{
struct wrn_dev *wrn = dev_id;
struct TXTSU_WB *regs = wrn->txtsu_regs;
u32 r0, r1;
u32 r0, r1, r2;
/* printk("%s: %i\n", __func__, __LINE__); */
/* FIXME: locking */
r0 = readl(&regs->TSF_R0);
r1 = readl(&regs->TSF_R1);
r2 = readl(&regs->TSF_R2);
if(record_tstamp(wrn, r0, r1) < 0) {
if(record_tstamp(wrn, r0, r1, r2) < 0) {
printk("%s: ENOMEM in the TS buffer. Disabling TX stamping.\n",
__func__);
writel(TXTSU_EIC_IER_NEMPTY, &wrn->txtsu_regs->EIC_IDR);
......
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