Linux驱动开发:网络设备之DM9000驱动架构分析(2)

skb->reserve(skb, 2);                              //对齐

skb->dev = dev;

insw(ioaddr + RX_FRAME_PORT, skb_put(skb, length), length >> 1);        //读取硬件上接收到的数据

if(length & 1)

{

skb->data[length - 1] = inw(ioaddr + RX_FRAME_PORT);                      //并放入数据缓冲区

skb->protocol = eth_type_trans(skb, dev);                                                //解析收到数据包上层协议的类型

netif_rx(skb);                                                                                                   //将数据包上交给上层协议(ARP&IP)

dev->last_rx = jiffies;                                                                                     //记录接收时间戳

... ...

}

}

//14、关闭网卡

static int dm9000_stop(struct net_device *dev)

{

free_irq(dev->irq, dev);     //释放端口、IRQ等

... ...

netif_stop_queue(dev);      //停止设备传送包

}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywgjj.html