pci.c:
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/errno.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#define PCI_VENDOR_ID_DEMO 0X66
#define PCI_DEVICE_ID_DEMO 0X10
#define DEMO 0
#define NAME “YYZ”
#define YYZ_MODULE_NAME “YYZMODULE”
struct cdev cdev;
static int major;
static struct class *cls;
static struct net_device *eth_dev;
static int eth_tx(struct sk_buff *skb, struct net_device *dev)
{
netif_stop_queue(dev);
dev_alloc_skb(1000);//分配缓冲区
dev->trans_start = jiffies;//记录最后一次接受数据包的时间戳
dev->stats.tx_packets++;//统计发送包
dev->stats.tx_bytes+=skb->len;//统计发送字节
memcpy(dev->dev_addr,"\x01\x02\x03\x04\x05\x06",6);
dev->flags = IFF_UP;
dev_kfree_skb(skb)
简单的PCIe +虚拟网卡驱动
最新推荐文章于 2025-05-24 08:54:33 发布