5,关闭网络设备
static int tg3_close(struct net_device *dev)
{
//停止网卡传输包
netif_stop_queue(dev);
netif_carrier_off(tp->dev);
//去除定时器
del_timer_sync(&tp->timer);
//释放收包和发包的缓冲区
tg3_free_rings(tp);
//释放中断
free_irq(dev->irq, dev);
}
6,硬件处理数据包发送
static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
len = (skb->len - skb->data_len);
//以DMA方式向网卡物理设备传输包。如果是wireless的话,需要根据802.11协议及硬件的规范从新填充
//硬件帧头,然后提交给硬件发送。
mapping = pci_map_single(tp->pdev, skb->data, len, PCI_DMA_TODEVICE);
tp->tx_buffers[entry].skb = skb;
pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping);
//硬件发送
tg3_set_txd(tp, entry, mapping, len, base_flags, mss_and_is_end);
//记录发包开始时间
dev->trans_start = jiffies;
}