Lines Matching +full:eth +full:- +full:mac
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
28 #define DRIVER_NAME "uml-netdev"
56 err = -ENOMEM; in update_drop_skb()
80 skb = dev_alloc_skb(lp->max_packet); in uml_net_rx()
82 drop_skb->dev = dev; in uml_net_rx()
84 (*lp->read)(lp->fd, drop_skb, lp); in uml_net_rx()
85 dev->stats.rx_dropped++; in uml_net_rx()
89 skb->dev = dev; in uml_net_rx()
90 skb_put(skb, lp->max_packet); in uml_net_rx()
92 pkt_len = (*lp->read)(lp->fd, skb, lp); in uml_net_rx()
96 skb->protocol = (*lp->protocol)(skb); in uml_net_rx()
98 dev->stats.rx_bytes += skb->len; in uml_net_rx()
99 dev->stats.rx_packets++; in uml_net_rx()
112 dev_close(lp->dev); in uml_dev_close()
124 spin_lock(&lp->lock); in uml_net_interrupt()
129 dev->name, err); in uml_net_interrupt()
131 * again lp->lock. in uml_net_interrupt()
133 * same device, since it tests for (dev->flags & IFF_UP). So in uml_net_interrupt()
135 * Furthermore, the workqueue will not re-enqueue an already in uml_net_interrupt()
137 schedule_work(&lp->work); in uml_net_interrupt()
141 spin_unlock(&lp->lock); in uml_net_interrupt()
150 if (lp->fd >= 0) { in uml_net_open()
151 err = -ENXIO; in uml_net_open()
155 lp->fd = (*lp->open)(&lp->user); in uml_net_open()
156 if (lp->fd < 0) { in uml_net_open()
157 err = lp->fd; in uml_net_open()
161 err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt, in uml_net_open()
162 IRQF_SHARED, dev->name, dev); in uml_net_open()
165 err = -ENETUNREACH; in uml_net_open()
171 /* clear buffer - it can happen that the host side of the interface in uml_net_open()
178 list_add(&lp->list, &opened); in uml_net_open()
183 if (lp->close != NULL) (*lp->close)(lp->fd, &lp->user); in uml_net_open()
184 lp->fd = -1; in uml_net_open()
195 um_free_irq(dev->irq, dev); in uml_net_close()
196 if (lp->close != NULL) in uml_net_close()
197 (*lp->close)(lp->fd, &lp->user); in uml_net_close()
198 lp->fd = -1; in uml_net_close()
201 list_del(&lp->list); in uml_net_close()
215 spin_lock_irqsave(&lp->lock, flags); in uml_net_start_xmit()
217 len = (*lp->write)(lp->fd, skb, lp); in uml_net_start_xmit()
220 if (len == skb->len) { in uml_net_start_xmit()
221 dev->stats.tx_packets++; in uml_net_start_xmit()
222 dev->stats.tx_bytes += skb->len; in uml_net_start_xmit()
231 dev->stats.tx_dropped++; in uml_net_start_xmit()
238 spin_unlock_irqrestore(&lp->lock, flags); in uml_net_start_xmit()
259 disable_irq(dev->irq); in uml_net_poll_controller()
260 uml_net_interrupt(dev->irq, dev); in uml_net_poll_controller()
261 enable_irq(dev->irq); in uml_net_poll_controller()
268 strscpy(info->driver, DRIVER_NAME); in uml_net_get_drvinfo()
314 "the first byte of the MAC,\n"); in uml_net_setup_etheraddr()
324 "Choosing a random ethernet address for device %s\n", dev->name); in uml_net_setup_etheraddr()
340 struct net_device *netdev = device->dev; in net_device_release()
343 if (lp->remove != NULL) in net_device_release()
344 (*lp->remove)(&lp->user); in net_device_release()
345 list_del(&device->list); in net_device_release()
369 static void eth_configure(int n, void *init, char *mac, in eth_configure() argument
377 size = transport->private_size + sizeof(struct uml_net_private); in eth_configure()
389 "net_device for eth%d\n", n); in eth_configure()
393 INIT_LIST_HEAD(&device->list); in eth_configure()
394 device->index = n; in eth_configure()
400 snprintf(dev->name, sizeof(dev->name), "eth%d", n); in eth_configure()
402 uml_net_setup_etheraddr(dev, mac); in eth_configure()
404 printk(KERN_INFO "Netdevice %d (%pM) : ", n, dev->dev_addr); in eth_configure()
410 INIT_WORK(&lp->work, uml_dev_close); in eth_configure()
417 device->pdev.id = n; in eth_configure()
418 device->pdev.name = DRIVER_NAME; in eth_configure()
419 device->pdev.dev.release = net_device_release; in eth_configure()
420 dev_set_drvdata(&device->pdev.dev, device); in eth_configure()
421 if (platform_device_register(&device->pdev)) in eth_configure()
423 SET_NETDEV_DEV(dev,&device->pdev.dev); in eth_configure()
425 device->dev = dev; in eth_configure()
431 (*transport->kern->init)(dev, init); in eth_configure()
434 { .list = LIST_HEAD_INIT(lp->list), in eth_configure()
436 .fd = -1, in eth_configure()
437 .mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0}, in eth_configure()
438 .max_packet = transport->user->max_packet, in eth_configure()
439 .protocol = transport->kern->protocol, in eth_configure()
440 .open = transport->user->open, in eth_configure()
441 .close = transport->user->close, in eth_configure()
442 .remove = transport->user->remove, in eth_configure()
443 .read = transport->kern->read, in eth_configure()
444 .write = transport->kern->write, in eth_configure()
445 .add_address = transport->user->add_address, in eth_configure()
446 .delete_address = transport->user->delete_address }); in eth_configure()
448 spin_lock_init(&lp->lock); in eth_configure()
449 memcpy(lp->mac, dev->dev_addr, sizeof(lp->mac)); in eth_configure()
451 if ((transport->user->init != NULL) && in eth_configure()
452 ((*transport->user->init)(&lp->user, dev) != 0)) in eth_configure()
455 dev->mtu = transport->user->mtu; in eth_configure()
456 dev->netdev_ops = ¨_netdev_ops; in eth_configure()
457 dev->ethtool_ops = ¨_net_ethtool_ops; in eth_configure()
458 dev->watchdog_timeo = (HZ >> 1); in eth_configure()
459 dev->irq = UM_ETH_IRQ; in eth_configure()
461 err = update_drop_skb(lp->max_packet); in eth_configure()
472 list_add(&device->list, &devices); in eth_configure()
478 if (transport->user->remove != NULL) in eth_configure()
479 (*transport->user->remove)(&lp->user); in eth_configure()
481 platform_device_unregister(&device->pdev); in eth_configure()
497 if (device->index == n) in find_device()
510 int n, err = -EINVAL; in eth_parse()
547 static int check_transport(struct transport *transport, char *eth, int n, in check_transport() argument
552 len = strlen(transport->name); in check_transport()
553 if (strncmp(eth, transport->name, len)) in check_transport()
556 eth += len; in check_transport()
557 if (*eth == ',') in check_transport()
558 eth++; in check_transport()
559 else if (*eth != '\0') in check_transport()
562 *init_out = kmalloc(transport->setup_size, gfp_mask); in check_transport()
566 if (!transport->setup(eth, mac_out, *init_out)) { in check_transport()
576 struct eth_init *eth; in register_transport() local
578 char *mac = NULL; in register_transport() local
582 BUG_ON(!list_empty(&new->list)); in register_transport()
583 list_add(&new->list, &transports); in register_transport()
587 eth = list_entry(ele, struct eth_init, list); in register_transport()
588 match = check_transport(new, eth->init, eth->index, &init, in register_transport()
589 &mac, GFP_KERNEL); in register_transport()
593 eth_configure(eth->index, init, mac, new, GFP_KERNEL); in register_transport()
596 list_del(ð->list); in register_transport()
605 char *mac = NULL; in eth_setup_common() local
612 &mac, GFP_ATOMIC)) in eth_setup_common()
615 eth_configure(index, init, mac, transport, GFP_ATOMIC); in eth_setup_common()
634 printk(KERN_ERR "eth_setup - Couldn't parse '%s' : %s\n", in eth_setup()
644 INIT_LIST_HEAD(&new->list); in eth_setup()
645 new->index = n; in eth_setup()
646 new->init = str; in eth_setup()
648 list_add_tail(&new->list, ð_cmd_line); in eth_setup()
652 __setup("eth", eth_setup);
654 "eth[0-9]+=<transport>,<options>\n"
672 return -ENOMEM; in net_config()
687 return -1; in net_id()
703 return -ENODEV; in net_remove()
705 dev = device->dev; in net_remove()
707 if (lp->fd > 0) in net_remove()
708 return -EBUSY; in net_remove()
710 platform_device_unregister(&device->pdev); in net_remove()
717 .name = "eth",
729 struct net_device *dev = ifa->ifa_dev->dev; in uml_inetaddr_event()
734 if (dev->netdev_ops->ndo_open != uml_net_open) in uml_inetaddr_event()
742 proc = lp->add_address; in uml_inetaddr_event()
745 proc = lp->delete_address; in uml_inetaddr_event()
749 memcpy(addr_buf, &ifa->ifa_address, sizeof(addr_buf)); in uml_inetaddr_event()
750 memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf)); in uml_inetaddr_event()
751 (*proc)(addr_buf, netmask_buf, &lp->user); in uml_inetaddr_event()
777 ip = lp->dev->ip_ptr; in inet_register()
780 in = ip->ifa_list; in inet_register()
783 in = in->ifa_next; in inet_register()
811 um_free_irq(lp->dev->irq, lp->dev); in close_devices()
812 if ((lp->close != NULL) && (lp->fd >= 0)) in close_devices()
813 (*lp->close)(lp->fd, &lp->user); in close_devices()
814 if (lp->remove != NULL) in close_devices()
815 (*lp->remove)(&lp->user); in close_devices()
827 struct in_device *ip = dev->ip_ptr; in iter_addresses()
832 in = ip->ifa_list; in iter_addresses()
834 memcpy(address, &in->ifa_address, sizeof(address)); in iter_addresses()
835 memcpy(netmask, &in->ifa_mask, sizeof(netmask)); in iter_addresses()
837 in = in->ifa_next; in iter_addresses()
844 struct in_device *ip = dev->ip_ptr; in dev_netmask()
851 in = ip->ifa_list; in dev_netmask()
855 *mask_out = in->ifa_mask; in dev_netmask()
881 printk(KERN_ERR "tap_setup_common - Extra garbage on " in tap_setup_common()
891 return eth_type_trans(skb, skb->dev); in eth_protocol()