示例#1
0
static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb)
#endif
{
	struct net_device_context *net_device_ctx = netdev_priv(ndev);
	struct netvsc_device *nvsc_dev = net_device_ctx->nvdev;
	struct sock *sk = skb->sk;
	int q_idx = sk_tx_queue_get(sk);

	if (q_idx < 0 || skb->ooo_okay ||
	    q_idx >= ndev->real_num_tx_queues) {
		u16 hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
		int new_idx;

		new_idx = nvsc_dev->send_table[hash]
			% nvsc_dev->num_chn;

		if (q_idx != new_idx && sk &&
		    sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache))
			sk_tx_queue_set(sk, new_idx);

		q_idx = new_idx;
	}

	if (unlikely(!nvsc_dev->chan_table[q_idx].channel))
		q_idx = 0;
	
	return q_idx;
}
示例#2
0
文件: odp_tx.c 项目: kalray/odp-mppa
u16 mpodp_select_queue(struct net_device *dev, struct sk_buff *skb
#if (LINUX_VERSION_CODE > KERNEL_VERSION (3, 13, 0))
		       , void *accel_priv, select_queue_fallback_t fallback
#endif
		       )
{
	int txq;

	txq = (skb_rx_queue_recorded(skb)
	       ? skb_get_rx_queue(skb)
	       : smp_processor_id());

	txq = txq % dev->real_num_tx_queues;

	return txq;

#if (LINUX_VERSION_CODE > KERNEL_VERSION (3, 13, 0))
	return fallback(dev, skb) % dev->real_num_tx_queues;
#else
	return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
#endif
}
示例#3
0
/*
 * Select queue for transmit.
 *
 * If a valid queue has already been assigned, then use that.
 * Otherwise compute tx queue based on hash and the send table.
 *
 * This is basically similar to default (__netdev_pick_tx) with the added step
 * of using the host send_table when no other queue has been assigned.
 *
 * TODO support XPS - but get_xps_queue not exported
 */
static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb,
			void *accel_priv, select_queue_fallback_t fallback)
{
	struct net_device_context *net_device_ctx = netdev_priv(ndev);
	unsigned int num_tx_queues = ndev->real_num_tx_queues;
	struct sock *sk = skb->sk;
	int q_idx = sk_tx_queue_get(sk);

	if (q_idx < 0 || skb->ooo_okay || q_idx >= num_tx_queues) {
		u16 hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
		int new_idx;

		new_idx = net_device_ctx->tx_send_table[hash] % num_tx_queues;

		if (q_idx != new_idx && sk &&
		    sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache))
			sk_tx_queue_set(sk, new_idx);

		q_idx = new_idx;
	}

	return q_idx;
}