Line 831... |
Line 831... |
/* When packet is copied, we can check if this is the last "flushed" packet */
|
/* When packet is copied, we can check if this is the last "flushed" packet */
|
if (get_be_u16(&tmp_buf[2])==0xa5a6) {
|
if (get_be_u16(&tmp_buf[2])==0xa5a6) {
|
//Flushed packet, store its number and length (should it be protected with spinlock?)
|
//Flushed packet, store its number and length (should it be protected with spinlock?)
|
sd->last_pkt_num = packet_number;
|
sd->last_pkt_num = packet_number;
|
//Copy the length, truncating it from 64 bits
|
//Copy the length, truncating it from 64 bits
|
sd->last_pkt_len = (uint32_t) * (uint64_t *) &(sd->buffer[pkt_pos+USER_LEN-sizeof(uint64_t)]);
|
sd->last_pkt_len = get_be_u64(&(sd->buffer[pkt_pos+USER_LEN-sizeof(uint64_t)]));
|
//We have received the "flushed" buffer, mark that transmission is stopped
|
//We have received the "flushed" buffer, mark that transmission is stopped
|
sd->stopped_flag = 1;
|
sd->stopped_flag = 1;
|
//printk(KERN_INFO "set stopped flag");
|
//printk(KERN_INFO "set stopped flag");
|
}
|
}
|
/* We modify the number of the copied packet in the pkts array, to avoid
|
/* We modify the number of the copied packet in the pkts array, to avoid
|
Line 867... |
Line 867... |
if (((sd->head - sd->tail) & MY_BUF_LEN_MASK) >= sd->rx_wakeup_thr)
|
if (((sd->head - sd->tail) & MY_BUF_LEN_MASK) >= sd->rx_wakeup_thr)
|
wake_up_interruptible(&read_queue);
|
wake_up_interruptible(&read_queue);
|
} else {
|
} else {
|
//Flushed packet, set head right after the end of the packet
|
//Flushed packet, set head right after the end of the packet
|
write_lock_bh(&sd->ptrs_lock);
|
write_lock_bh(&sd->ptrs_lock);
|
sd->head = ((sd->last_nack_pkt-1)*USER_LEN+sd->last_pkt_len) & MY_BUF_LEN_MASK;
|
sd->head = ((sd->last_nack_pkt-1)*USER_LEN+8*sd->last_pkt_len) & MY_BUF_LEN_MASK;
|
//We have consumed the last, "flushed" buffer, so now we can set the eof flag
|
//We have consumed the last, "flushed" buffer, so now we can set the eof flag
|
sd-> eof_flag = 1;
|
sd-> eof_flag = 1;
|
//printk(KERN_ALERT "set eof flag!");
|
//printk(KERN_ALERT "set eof flag!");
|
//And we wake up the reading process
|
//And we wake up the reading process
|
wake_up_interruptible(&read_queue);
|
wake_up_interruptible(&read_queue);
|