Example #1
0
int hfc_fifo_get(struct hfc_chan_simplex *chan,
		void *data, int size)
{
	int available_bytes;

	/*
	 * Some useless statistic
	 */
	chan->bytes += size;

	available_bytes = hfc_fifo_used_rx(chan);

	if (available_bytes < size && !chan->fifo_underrun++) {
		/*
		 * print the warning only once
		 */
		printk(KERN_WARNING hfc_DRIVER_PREFIX
			"card %d: "
			"chan %s: "
			"RX FIFO not enough (%d) bytes to receive!\n",
			chan->chan->card->cardnum,
			chan->chan->name,
			available_bytes);
		return -1;
	}

	hfc_fifo_mem_read(chan, *Z2_F2(chan), data, size);
	*Z2_F2(chan) = Z_inc(chan, *Z2_F2(chan), size);
	return available_bytes - size;
}
Example #2
0
static ssize_t hfc_sys_chan_read(
	struct visdn_leg *visdn_leg,
	void *buf, size_t count)
{
	struct hfc_sys_chan *chan = to_sys_chan(visdn_leg->chan);
	struct hfc_card *card = chan->port->card;
	int copied_octets;
	int available_octets;

	hfc_card_lock(card);

	hfc_fifo_select(&chan->rx_fifo);

	available_octets = hfc_fifo_used_rx(&chan->rx_fifo);

	copied_octets = available_octets < count ? available_octets : count;

	if (available_octets > chan->rx_fifo.stats_max)
		chan->rx_fifo.stats_max = available_octets;

	if (available_octets - copied_octets < chan->rx_fifo.stats_min)
		chan->rx_fifo.stats_min = available_octets - copied_octets;

	chan->rx_fifo.stats_cycles++;

	hfc_fifo_mem_read(&chan->rx_fifo, buf, copied_octets);

	hfc_card_unlock(card);

	return copied_octets;
}
Example #3
0
void hfc_fifo_drop_frame(struct hfc_chan_simplex *chan)
{
	int available_bytes;
	u16 newz2;

	if (*chan->f1 == *chan->f2) {
		/*
		 * nothing received, strange eh?
		 */
		printk(KERN_WARNING hfc_DRIVER_PREFIX
			"card %d: "
			"chan %s: "
			"skip_frame called with no frame in FIFO.\n",
			chan->chan->card->cardnum,
			chan->chan->name);

		return;
	}

	available_bytes = hfc_fifo_used_rx(chan) + 1;

	/*
	 * Calculate beginning of the next frame
	 */
	newz2 = Z_inc(chan, *Z2_F2(chan), available_bytes);

	*chan->f2 = F_inc(chan, *chan->f2, 1);

	/*
	 * Set Z2 for the next frame we're going to receive
	 */
	*Z2_F2(chan) = newz2;
}
Example #4
0
static ssize_t hfc_show_rx_fifo_used(
	struct visdn_chan *visdn_chan,
	struct visdn_chan_attribute *attr,
	char *buf)
{
	struct hfc_sys_chan *chan = to_sys_chan(visdn_chan);
	int fifo_used;

	hfc_card_lock(chan->port->card);
	hfc_fifo_select(&chan->rx_fifo);
	fifo_used = hfc_fifo_used_rx(&chan->rx_fifo);
	hfc_card_unlock(chan->port->card);

	return snprintf(buf, PAGE_SIZE, "%d\n", fifo_used);
}