关于usb网络net设备g_ether.ko数据的irq中断接收
static struct platform_driver udc_driver_2410 = {
.driver = {
.name = "s3c2410-usbgadget",
.owner = THIS_MODULE,
},
.probe = s3c2410_udc_probe,
.remove = s3c2410_udc_remove,
.suspend = s3c2410_udc_suspend,
.resume = s3c2410_udc_resume,
};
==> s3c2410_udc_probe
==> the_controller = udc; // 设置全局量
==> request_irq(IRQ_USBD, s3c2410_udc_irq, // irq数据处理func[luther.gliethttp]
IRQF_DISABLED, gadget_name, udc);
s3c2410_udc_probe
==> s3c2410_udc_irq
==> s3c2410_udc_handle_ep0
==> s3c2410_udc_handle_ep0_idle
==> dev->driver->setup(&dev->gadget, crq); // 这里dev就是request_irq中的参数udc即the_controller,这里dev->driver就是composite_driver
static struct usb_gadget_driver composite_driver下的setup方法composite_setup
composite_setup
只有当pc机向嵌入式设备的usb发出USB_REQ_SET_CONFIGURATION控制消息,
执行设备配置描述符时才会调用设置配置函数[luther.gliethttp]
set_config
==> f->set_alt(f, tmp, 0);就是geth_set_alt
看看f->set_alt什么时候注册上的
eth_driver.eth_bind
usb_add_config(cdev, ð_config_driver);
eth_config_driver.bind = eth_do_config;
eth_do_config
geth->port.func.set_alt = geth_set_alt;
==> geth_set_alt
==> gether_connect(&geth->port)
dev->port_usb = link; // 即link = &geth->port
alloc_requests(dev, link, qlen(dev->gadget));
// 如下为usb网卡的in和out数据收发端点各自申请n个req,添加到dev->tx_reqs和dev->rx_reqs上,这样
// 就保证了dev->tx_reqs和dev->rx_reqs至少有1个req存在[luther.gliethttp]
++==> prealloc(&dev->tx_reqs, link->in_ep, n); // 为in_ep端点申请n个req,s3c2410_ep_ops.s3c2410_udc_alloc_request
++==> prealloc(&dev->rx_reqs, link->out_ep, n);// 为out_ep端点申请n个req
etif_carrier_on(dev->net);
if (netif_running(dev->net))
eth_start(dev, GFP_ATOMIC);
static const struct net_device_ops eth_netdev_ops = {
.ndo_open = eth_open,
.ndo_stop = eth_stop,
.ndo_start_xmit = eth_start_xmit,
.ndo_change_mtu = ueth_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
gether_setup
==> net->netdev_ops = ð_netdev_ops; // 设置eth网卡的ops方法集
// 然后打开usb0网卡设备时
eth_open
==> eth_start或eth_work
==> rx_fill
==> rx_submit(dev, req, gfp_flags)
==> req->complete = rx_complete; // 等待usb数据到来[luther.gliethttp]
rx_complete
==> skb->protocol = eth_type_trans(skb, dev->net);
==> netif_rx(skb);
阅读(4037) | 评论(1) | 转发(0) |