netif_wake_subqueue函数分析

/**
 *      netif_wake_subqueue - allow sending packets on subqueue
 *      @dev: network device
 *      @queue_index: sub queue index
 *
 * Resume individual transmit queue of a device with multiple transmit queues.
 */
 static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
{
        struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
#ifdef CONFIG_NETPOLL_TRAP
        if (netpoll_trap())
                return;
 #endif
        if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state))
                __netif_schedule(txq->qdisc);
}

<pre name="code" class="cpp">static inline
struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
                                         unsigned int index)
 {
         return &dev->_tx[index];
 }


 
 

设备发送队列_tx[0]的状态state的_QUEUE_STATE_XOFF置1,表示停止发送数据包;置0表示可以发送数据包。



函数__netif_schedule(txq->qdisc)代码如下:

void __netif_schedule(struct Qdisc *q)
{
	if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state))
		__netif_reschedule(q);
}
EXPORT_SYMBOL(__netif_schedule);


static inline void __netif_reschedule(struct Qdisc *q)
{
	struct softnet_data *sd;
	unsigned long flags;

	local_irq_save(flags);
	sd = &__get_cpu_var(softnet_data);
	q->next_sched = sd->output_queue;
	sd->output_queue = q;
	raise_softirq_irqoff(NET_TX_SOFTIRQ);
	local_irq_restore(flags);
}

发送队列的成员qdisc的 _QDISK_STATE_SCHED如果为1表示当前设备的发送队列尚未加入CPU的发送队列的尾部,

调用raise_softirq_irqoff(NET_TX_SOFTIRQ)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值