Linux内核--从上向下分析驱动程序层
作者:网络转载 发布时间:[ 2013/1/7 10:35:40 ] 推荐标签:
其中的dev_tint()函数是将设备的所有缓存队列中的数据全部调用dev_queue_xmit()发送全部数据包。
/*
* This routine is called when an device driver (i.e. an
* interface) is ready to transmit a packet.
*/
//该函数功能:遍历设备的缓冲队列,对所有的数据包调用dev_queue_xmit()函数发送数据
void dev_tint(struct device *dev)
{
int i;
struct sk_buff *skb;
unsigned long flags;
save_flags(flags);
/*
* Work the queues in priority order
*/
for(i = 0;i < DEV_NUMBUFFS; i++)
{
/*
* Pull packets from the queue
*/
cli();
while((skb=skb_dequeue(&dev->buffs[i]))!=NULL)
{
/*
* Stop anyone freeing the buffer while we retransmit it
*/
skb_device_lock(skb);
restore_flags(flags);
/*
* Feed them to the output stage and if it fails
* indicate they re-queue at the front.
*/
dev_queue_xmit(skb,dev,-i - 1);//注意优先级的计算方式,在函数dev_queue_xmit()中优先级若<0则计算pri=-pri-1=-(-i-1)-1=i,
//这样做的目的是为了得到正确的where值,函数(dev_queue_xmit())中
/*
* If we can take no more then stop here.
*/
if (dev->tbusy)
return;
cli();
}
}
restore_flags(flags);
}

驱动层严格的说不属于内核网络栈的内容,和硬件关系密切,何况这种网卡硬件设备可能已经不用了,这里没有详细分析。
本文转自:http://blog.csdn.net/yming0221/article/details/7555870

sales@spasvo.com