Ejemplo n.º 1
0
int
pfq_sock_tx_bind(struct pfq_sock *so, int tid, int ifindex, int qindex, struct
		 net_device *dev)
{
	size_t queue = so->opt.tx_num_async_queues;
	if (queue >= Q_MAX_TX_QUEUES)
		return -EPERM;

	so->opt.txq_async[queue].def_ifindex = ifindex;
	so->opt.txq_async[queue].def_queue = qindex;
	so->opt.txq_async[queue].def_dev = dev;
	so->opt.tx_num_async_queues++;

	smp_wmb();

	if (pfq_bind_tx_thread(tid, so, queue) < 0)
	{
		so->opt.txq_async[queue].def_ifindex = -1;
		so->opt.txq_async[queue].def_queue = -1;
		so->opt.txq_async[queue].def_dev = NULL;
		so->opt.tx_num_async_queues--;

		printk(KERN_INFO "[PFQ|%d] could not bind Tx[%d] thread: resource busy!\n", so->id, tid);
		return -EBUSY;
	}

	return 0;
}
Ejemplo n.º 2
0
Archivo: sock.c Proyecto: pfq/PFQ
int
pfq_sock_tx_bind(struct pfq_sock *so, int tid, int ifindex, int qindex)
{
	int queue = (int)so->txq_num_async;
	int err = 0;

	if (queue >= Q_MAX_TX_QUEUES) {
		printk(KERN_INFO "[PFQ|%d] could not bind Tx[%d] thread to queue %d (out of range)!\n", so->id, tid, queue);
		return -EPERM;
	}

	so->tx_async[queue].ifindex = ifindex;
	so->tx_async[queue].queue = qindex;
	so->txq_num_async++;

	smp_wmb();

	if ((err = pfq_bind_tx_thread(tid, so, queue)) < 0)
	{
		so->tx_async[queue].ifindex = -1;
		so->tx_async[queue].queue = -1;
		so->txq_num_async--;
		return err;
	}

	return 0;
}