Commit 7db35ea4 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Tomasz Wlostowski

kernel/wr_nic: drop timestamps marked as invalid (TO BE FIXED)

Please tom check and fix this, I have no bit nr for txtsu. Also, please
note that there's not flag for stamp-valid: you must detect 0 in userspace.
parent aa4b5b86
......@@ -371,7 +371,11 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
ts.tv_nsec & 0x7fffffff,
ts.tv_sec & 0x80000000 ? 1 :0);
hwts->hwtstamp = timespec_to_ktime(ts);
/* 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
hwts->hwtstamp = timespec_to_ktime(ts);
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY;
dev->last_rx = jiffies;
......
......@@ -48,7 +48,10 @@ 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;
hwts->hwtstamp = timespec_to_ktime(ts);
if (wrn->ts_buf[i].valid & TS_INVALID)
hwts->hwtstamp = ns_to_ktime(0);
else
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
dev_kfree_skb_irq(skb);
......@@ -62,6 +65,7 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
{
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 */ ;
struct skb_shared_hwtstamps *hwts;
struct timespec ts;
struct sk_buff *skb;
......@@ -87,13 +91,16 @@ 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;
hwts->hwtstamp = timespec_to_ktime(ts);
if (ts_invalid)
hwts->hwtstamp = ns_to_ktime(0);
else
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
dev_kfree_skb_irq(skb);
wrn->skb_desc[i].skb = 0;
return 0;
}
/* Otherwise, save it to the list */
/* Otherwise, save it to the list, in an empty slot */
for(i = 0; i < WRN_TS_BUF_SIZE; i++)
if(!wrn->ts_buf[i].valid)
break;
......@@ -106,7 +113,9 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
wrn->ts_buf[i].ts = tsval;
wrn->ts_buf[i].port_id = port_id;
wrn->ts_buf[i].frame_id = frame_id;
wrn->ts_buf[i].valid = 1;
wrn->ts_buf[i].valid = TS_PRESENT;
if (invalid)
wrn->ts_buf[i].valid |= TS_INVALID;
return 0;
}
......
......@@ -53,6 +53,9 @@ struct wrn_tx_tstamp {
u16 frame_id;
u32 ts;
};
/* bits for "valid" field */
#define TS_PRESENT 1
#define TS_INVALID 2 /* as reported by hw: we return 0 as timestamp */
/* We must remember both skb and id for each pending descriptor */
struct wrn_desc_pending {
......
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