static int tc589_probe(struct pcmcia_device *link) { struct el3_private *lp; struct net_device *dev; dev_dbg(&link->dev, "3c589_attach()\n"); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); link->priv = dev; lp->p_dev = link; spin_lock_init(&lp->lock); link->resource[0]->end = 16; link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 1; dev->netdev_ops = &el3_netdev_ops; dev->watchdog_timeo = TX_TIMEOUT; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); return tc589_config(link); } /* tc589_attach */
int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]) { struct eth_dev *dev; struct net_device *net; int status; if (the_dev) return -EBUSY; net = alloc_etherdev(sizeof *dev); if (!net) return -ENOMEM; dev = netdev_priv(net); spin_lock_init(&dev->lock); spin_lock_init(&dev->req_lock); INIT_WORK(&dev->work, eth_work); INIT_LIST_HEAD(&dev->tx_reqs); INIT_LIST_HEAD(&dev->rx_reqs); skb_queue_head_init(&dev->rx_frames); dev->net = net; strcpy(net->name, "usb%d"); if (get_ether_addr(dev_addr, net->dev_addr)) dev_warn(&g->dev, "using random %s ethernet address\n", "self"); if (get_ether_addr(host_addr, dev->host_mac)) dev_warn(&g->dev, "using random %s ethernet address\n", "host"); if (ethaddr) memcpy(ethaddr, dev->host_mac, ETH_ALEN); net->netdev_ops = ð_netdev_ops; SET_ETHTOOL_OPS(net, &ops); netif_stop_queue(net); netif_carrier_off(net); dev->gadget = g; SET_NETDEV_DEV(net, &g->dev); status = register_netdev(net); if (status < 0) { dev_dbg(&g->dev, "register_netdev failed, %d\n", status); free_netdev(net); } else { INFO(dev, "MAC %pM\n", net->dev_addr); INFO(dev, "HOST MAC %pM\n", dev->host_mac); the_dev = dev; } return status; }
static void do_setup(struct net_device *netdev) { ether_setup(netdev); #ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops = &internal_dev_netdev_ops; #else netdev->get_stats = internal_dev_sys_stats; netdev->hard_start_xmit = internal_dev_xmit; netdev->open = internal_dev_open; netdev->stop = internal_dev_stop; netdev->set_mac_address = internal_dev_mac_addr; netdev->change_mtu = internal_dev_change_mtu; #endif netdev->priv_flags &= ~IFF_TX_SKB_SHARING; netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE; netdev->destructor = internal_dev_destructor; SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops); netdev->tx_queue_len = 0; netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) netdev->vlan_features = netdev->features; netdev->features |= NETIF_F_HW_VLAN_TX; #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) netdev->hw_features = netdev->features & ~NETIF_F_LLTX; #endif eth_hw_addr_random(netdev); }
static int nmclan_probe(struct pcmcia_device *link) { mace_private *lp; struct net_device *dev; dev_dbg(&link->dev, "nmclan_attach()\n"); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(mace_private)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); lp->p_dev = link; link->priv = dev; spin_lock_init(&lp->bank_lock); link->io.NumPorts1 = 32; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; link->io.IOAddrLines = 5; link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.Handler = mace_interrupt; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; lp->tx_free_frames=AM2150_MAX_TX_FRAMES; dev->netdev_ops = &mace_netdev_ops; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); dev->watchdog_timeo = TX_TIMEOUT; return nmclan_config(link); } /* nmclan_attach */
static void interface_setup(struct net_device *dev) { struct bat_priv *priv = netdev_priv(dev); ether_setup(dev); dev->netdev_ops = &bat_netdev_ops; dev->destructor = free_netdev; dev->tx_queue_len = 0; /** * can't call min_mtu, because the needed variables * have not been initialized yet */ dev->mtu = ETH_DATA_LEN; /* reserve more space in the skbuff for our header */ dev->hard_header_len = BAT_HEADER_LEN; /* generate random address */ eth_hw_addr_random(dev); SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); memset(priv, 0, sizeof(*priv)); }
static int nmclan_probe(struct pcmcia_device *link) { mace_private *lp; struct net_device *dev; dev_dbg(&link->dev, "nmclan_attach()\n"); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(mace_private)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); lp->p_dev = link; link->priv = dev; spin_lock_init(&lp->bank_lock); link->resource[0]->end = 32; link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; link->config_flags |= CONF_ENABLE_IRQ; link->config_index = 1; link->config_regs = PRESENT_OPTION; lp->tx_free_frames=AM2150_MAX_TX_FRAMES; dev->netdev_ops = &mace_netdev_ops; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); dev->watchdog_timeo = TX_TIMEOUT; return nmclan_config(link); } /* nmclan_attach */
static int fmvj18x_probe(struct pcmcia_device *link) { local_info_t *lp; struct net_device *dev; dev_dbg(&link->dev, "fmvj18x_attach()\n"); /* Make up a FMVJ18x specific data structure */ dev = alloc_etherdev(sizeof(local_info_t)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); link->priv = dev; lp->p_dev = link; lp->base = NULL; /* The io structure describes IO port mapping */ link->io.NumPorts1 = 32; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; link->io.IOAddrLines = 5; /* General socket configuration */ link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; dev->netdev_ops = &fjn_netdev_ops; dev->watchdog_timeo = TX_TIMEOUT; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); return fmvj18x_config(link); } /* fmvj18x_attach */
/** * gether_setup_name - initialize one ethernet-over-usb link * @g: gadget to associated with these links * @ethaddr: NULL, or a buffer in which the ethernet address of the * host side of the link is recorded * @netname: name for network device (for example, "usb") * Context: may sleep * * This sets up the single network link that may be exported by a * gadget driver using this framework. The link layer addresses are * set up using module parameters. * * Returns negative errno, or zero on success */ struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN], const char *netname) { struct eth_dev *dev; struct net_device *net; int status; net = alloc_etherdev(sizeof *dev); if (!net) return ERR_PTR(-ENOMEM); dev = netdev_priv(net); spin_lock_init(&dev->lock); spin_lock_init(&dev->req_lock); INIT_WORK(&dev->work, eth_work); INIT_LIST_HEAD(&dev->tx_reqs); INIT_LIST_HEAD(&dev->rx_reqs); skb_queue_head_init(&dev->rx_frames); /* network device setup */ dev->net = net; snprintf(net->name, sizeof(net->name), "%s%%d", netname); if (get_ether_addr(dev_addr, net->dev_addr)) dev_warn(&g->dev, "using random %s ethernet address\n", "self"); if (get_ether_addr(host_addr, dev->host_mac)) dev_warn(&g->dev, "using random %s ethernet address\n", "host"); if (ethaddr) memcpy(ethaddr, dev->host_mac, ETH_ALEN); net->netdev_ops = ð_netdev_ops; SET_ETHTOOL_OPS(net, &ops); dev->gadget = g; SET_NETDEV_DEV(net, &g->dev); SET_NETDEV_DEVTYPE(net, &gadget_type); status = register_netdev(net); if (status < 0) { dev_dbg(&g->dev, "register_netdev failed, %d\n", status); free_netdev(net); dev = ERR_PTR(status); } else { INFO(dev, "MAC %pM\n", net->dev_addr); INFO(dev, "HOST MAC %pM\n", dev->host_mac); /* two kinds of host-initiated state changes: * - iff DATA transfer is active, carrier is "on" * - tx queueing enabled if open *and* carrier is "on" */ netif_carrier_off(net); } return dev; }
void interface_setup(struct net_device *dev) { struct bat_priv *priv = netdev_priv(dev); char dev_addr[ETH_ALEN]; ether_setup(dev); #ifdef HAVE_NET_DEVICE_OPS dev->netdev_ops = &bat_netdev_ops; #else dev->open = interface_open; dev->stop = interface_release; dev->get_stats = interface_stats; dev->set_mac_address = interface_set_mac_addr; dev->change_mtu = interface_change_mtu; dev->hard_start_xmit = interface_tx; #endif dev->destructor = free_netdev; dev->mtu = hardif_min_mtu(); dev->hard_header_len = BAT_HEADER_LEN; /* reserve more space in the * skbuff for our header */ /* generate random address */ random_ether_addr(dev_addr); memcpy(dev->dev_addr, dev_addr, ETH_ALEN); SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); memset(priv, 0, sizeof(struct bat_priv)); }
static void loopback_construct(struct net_device *dev, struct net_device *lo, int loop_idx) { struct net_private *np = netdev_priv(dev); np->loopback_dev = lo; np->loop_idx = loop_idx; dev->open = loopback_open; dev->stop = loopback_close; dev->hard_start_xmit = loopback_start_xmit; dev->get_stats = loopback_get_stats; dev->set_multicast_list = loopback_set_multicast_list; dev->change_mtu = NULL; /* allow arbitrary mtu */ dev->tx_queue_len = 0; dev->features = (NETIF_F_HIGHDMA | NETIF_F_LLTX | NETIF_F_TSO | NETIF_F_SG | NETIF_F_IP_CSUM); SET_ETHTOOL_OPS(dev, &network_ethtool_ops); /* * We do not set a jumbo MTU on the interface. Otherwise the network * stack will try to send large packets that will get dropped by the * Ethernet bridge (unless the physical Ethernet interface is * configured to transfer jumbo packets). If a larger MTU is desired * then the system administrator can specify it using the 'ifconfig' * command. */ /*dev->mtu = 16*1024;*/ }
static int tc589_probe(struct pcmcia_device *link) { struct el3_private *lp; struct net_device *dev; DEBUG(0, "3c589_attach()\n"); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); link->priv = dev; lp->p_dev = link; spin_lock_init(&lp->lock); link->io.NumPorts1 = 16; link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &el3_interrupt; link->irq.Instance = dev; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 1; dev->netdev_ops = &el3_netdev_ops; dev->watchdog_timeo = TX_TIMEOUT; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); return tc589_config(link); } /* tc589_attach */
/** * gether_setup - initialize one ethernet-over-usb link * @g: gadget to associated with these links * @ethaddr: NULL, or a buffer in which the ethernet address of the * host side of the link is recorded * Context: may sleep * * This sets up the single network link that may be exported by a * gadget driver using this framework. The link layer addresses are * set up using module parameters. * * Returns negative errno, or zero on success */ int __init gether_setup(u8 ethaddr[ETH_ALEN]) { struct eth_dev *dev; struct net_device *net; int status; if (the_dev) return -EBUSY; net = alloc_etherdev(sizeof *dev); if (!net) return -ENOMEM; dev = netdev_priv(net); spin_lock_init(&dev->lock); spin_lock_init(&dev->req_lock); INIT_WORK(&dev->work, eth_work); INIT_LIST_HEAD(&dev->tx_reqs); INIT_LIST_HEAD(&dev->rx_reqs); /* network device setup */ dev->net = net; strcpy(net->name, "ld%d"); if (get_ether_addr(dev_addr, net->dev_addr)) printk("using random %s ethernet address\n", "self"); if (get_ether_addr(host_addr, dev->host_mac)) printk("using random %s ethernet address\n", "host"); if (ethaddr) memcpy(ethaddr, dev->host_mac, ETH_ALEN); net->netdev_ops = ð_netdev_ops; SET_ETHTOOL_OPS(net, &ops); /* two kinds of host-initiated state changes: * - iff DATA transfer is active, carrier is "on" * - tx queueing enabled if open *and* carrier is "on" */ netif_stop_queue(net); netif_carrier_off(net); // SET_NETDEV_DEV(net, &g->dev); status = register_netdev(net); if (status < 0) { printk("register_netdev failed, %d\n", status); free_netdev(net); } else { INFO(dev, "MAC %pM\n", net->dev_addr); INFO(dev, "HOST MAC %pM\n", dev->host_mac); the_dev = dev; } return status; }
/** * cvm_oct_common_init - per network device initialization * @dev: Device to initialize * * Returns Zero on success */ int cvm_oct_common_init(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); struct sockaddr sa; u64 mac = ((u64)(octeon_bootinfo->mac_addr_base[0] & 0xff) << 40) | ((u64)(octeon_bootinfo->mac_addr_base[1] & 0xff) << 32) | ((u64)(octeon_bootinfo->mac_addr_base[2] & 0xff) << 24) | ((u64)(octeon_bootinfo->mac_addr_base[3] & 0xff) << 16) | ((u64)(octeon_bootinfo->mac_addr_base[4] & 0xff) << 8) | (u64)(octeon_bootinfo->mac_addr_base[5] & 0xff); mac += cvm_oct_mac_addr_offset; sa.sa_data[0] = (mac >> 40) & 0xff; sa.sa_data[1] = (mac >> 32) & 0xff; sa.sa_data[2] = (mac >> 24) & 0xff; sa.sa_data[3] = (mac >> 16) & 0xff; sa.sa_data[4] = (mac >> 8) & 0xff; sa.sa_data[5] = mac & 0xff; if (cvm_oct_mac_addr_offset >= octeon_bootinfo->mac_addr_count) printk(KERN_DEBUG "%s: Using MAC outside of the assigned range:" " %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, sa.sa_data[0] & 0xff, sa.sa_data[1] & 0xff, sa.sa_data[2] & 0xff, sa.sa_data[3] & 0xff, sa.sa_data[4] & 0xff, sa.sa_data[5] & 0xff); cvm_oct_mac_addr_offset++; /* * Force the interface to use the POW send if always_use_pow * was specified or it is in the pow send list. */ if ((pow_send_group != -1) && (always_use_pow || strstr(pow_send_list, dev->name))) priv->queue = -1; if (priv->queue != -1) { dev->features |= NETIF_F_SG; if (USE_HW_TCPUDP_CHECKSUM) dev->features |= NETIF_F_IP_CSUM; } /* We do our own locking, Linux doesn't need to */ dev->features |= NETIF_F_LLTX; SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops); cvm_oct_phy_setup_device(dev); dev->netdev_ops->ndo_set_mac_address(dev, &sa); dev->netdev_ops->ndo_change_mtu(dev, dev->mtu); /* * Zero out stats for port so we won't mistakenly show * counters from the bootloader. */ memset(dev->netdev_ops->ndo_get_stats(dev), 0, sizeof(struct net_device_stats)); return 0; }
/** * gether_qc_setup_name - initialize one ethernet-over-usb link * @g: gadget to associated with these links * @ethaddr: NULL, or a buffer in which the ethernet address of the * host side of the link is recorded * @netname: name for network device (for example, "usb") * Context: may sleep * * This sets up the single network link that may be exported by a * gadget driver using this framework. The link layer addresses are * set up using module parameters. * * Returns negative errno, or zero on success */ int gether_qc_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN], const char *netname) { struct eth_qc_dev *dev; struct net_device *net; int status; if (qc_dev) return -EBUSY; net = alloc_etherdev(sizeof *dev); if (!net) return -ENOMEM; dev = netdev_priv(net); spin_lock_init(&dev->lock); /* network device setup */ dev->net = net; snprintf(net->name, sizeof(net->name), "%s%%d", netname); if (get_qc_ether_addr(qc_dev_addr, net->dev_addr)) dev_warn(&g->dev, "using random %s ethernet address\n", "self"); if (get_qc_ether_addr(qc_host_addr, dev->host_mac)) dev_warn(&g->dev, "using random %s ethernet address\n", "host"); if (ethaddr) memcpy(ethaddr, dev->host_mac, ETH_ALEN); net->netdev_ops = ð_qc_netdev_ops; SET_ETHTOOL_OPS(net, &qc_ethtool_ops); netif_carrier_off(net); dev->gadget = g; SET_NETDEV_DEV(net, &g->dev); SET_NETDEV_DEVTYPE(net, &qc_gadget_type); status = register_netdev(net); if (status < 0) { dev_dbg(&g->dev, "register_netdev failed, %d\n", status); free_netdev(net); } else { INFO(dev, "MAC %pM\n", net->dev_addr); INFO(dev, "HOST MAC %pM\n", dev->host_mac); qc_dev = dev; } return status; }
static int nmclan_attach(struct pcmcia_device *p_dev) { mace_private *lp; dev_link_t *link; struct net_device *dev; DEBUG(0, "nmclan_attach()\n"); DEBUG(1, "%s\n", rcsid); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(mace_private)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; spin_lock_init(&lp->bank_lock); link->io.NumPorts1 = 32; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; link->io.IOAddrLines = 5; link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &mace_interrupt; link->irq.Instance = dev; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; lp->tx_free_frames=AM2150_MAX_TX_FRAMES; SET_MODULE_OWNER(dev); dev->hard_start_xmit = &mace_start_xmit; dev->set_config = &mace_config; dev->get_stats = &mace_get_stats; dev->set_multicast_list = &set_multicast_list; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); dev->open = &mace_open; dev->stop = &mace_close; #ifdef HAVE_TX_TIMEOUT dev->tx_timeout = mace_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; #endif link->handle = p_dev; p_dev->instance = link; link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; nmclan_config(link); return 0; } /* nmclan_attach */
static int fmvj18x_attach(struct pcmcia_device *p_dev) { local_info_t *lp; dev_link_t *link; struct net_device *dev; DEBUG(0, "fmvj18x_attach()\n"); /* Make up a FMVJ18x specific data structure */ dev = alloc_etherdev(sizeof(local_info_t)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; /* The io structure describes IO port mapping */ link->io.NumPorts1 = 32; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; link->io.IOAddrLines = 5; /* Interrupt setup */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &fjn_interrupt; link->irq.Instance = dev; /* General socket configuration */ link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; /* The FMVJ18x specific entries in the device structure. */ SET_MODULE_OWNER(dev); dev->hard_start_xmit = &fjn_start_xmit; dev->set_config = &fjn_config; dev->get_stats = &fjn_get_stats; dev->set_multicast_list = &set_rx_mode; dev->open = &fjn_open; dev->stop = &fjn_close; #ifdef HAVE_TX_TIMEOUT dev->tx_timeout = fjn_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; #endif SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); link->handle = p_dev; p_dev->instance = link; link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fmvj18x_config(link); return 0; } /* fmvj18x_attach */
static int netvsc_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { struct net_device *net = NULL; struct net_device_context *net_device_ctx; struct netvsc_device_info device_info; int ret; net = alloc_etherdev(sizeof(struct net_device_context)); if (!net) return -ENOMEM; netif_carrier_off(net); net_device_ctx = netdev_priv(net); net_device_ctx->device_ctx = dev; hv_set_drvdata(dev, net); INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); INIT_WORK(&net_device_ctx->work, do_set_multicast); net->netdev_ops = &device_ops; net->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_TSO; SET_ETHTOOL_OPS(net, ðtool_ops); SET_NETDEV_DEV(net, &dev->device); /* Notify the netvsc driver of the new device */ device_info.ring_size = ring_size; ret = rndis_filter_device_add(dev, &device_info); if (ret != 0) { netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); free_netdev(net); hv_set_drvdata(dev, NULL); return ret; } memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); ret = register_netdev(net); if (ret != 0) { pr_err("Unable to register netdev.\n"); rndis_filter_device_remove(dev); free_netdev(net); } else { schedule_delayed_work(&net_device_ctx->dwork, 0); } return ret; }
void fe_set_ethtool_ops(struct net_device *netdev) { struct fe_priv *priv = netdev_priv(netdev); struct fe_soc_data *soc = priv->soc; if (soc->reg_table[FE_REG_FE_COUNTER_BASE]) { fe_ethtool_ops.get_strings = fe_get_strings; fe_ethtool_ops.get_sset_count = fe_get_sset_count; fe_ethtool_ops.get_ethtool_stats = fe_get_ethtool_stats; } SET_ETHTOOL_OPS(netdev, &fe_ethtool_ops); }
void br_dev_setup(struct net_device *dev) { random_ether_addr(dev->dev_addr); ether_setup(dev); dev->netdev_ops = &br_netdev_ops; dev->destructor = free_netdev; SET_ETHTOOL_OPS(dev, &br_ethtool_ops); dev->tx_queue_len = 0; dev->priv_flags = IFF_EBRIDGE; dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_GSO_MASK | NETIF_F_NO_CSUM | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL | NETIF_F_GSO; }
/** init of the network device */ static int switch_init(struct net_device *dev) { u64 retval; static int macVal=0; int i; /*printk("%s up\n",dev->name); */ // dev->open = ifx_eth_open; // dev->stop = ifx_eth_close; // dev->hard_start_xmit = ifx_start_xmit; // dev->do_ioctl = ifx_eth_ioctl; // dev->get_stats = ifx_get_stats; // dev->change_mtu = ifx_change_mtu; // dev->set_mac_address = ifx_set_mac_address; // dev->tx_timeout = ifx_tx_timeout; // dev->watchdog_timeo = IFX_TX_TIMEOUT; //#ifdef CONFIG_NAPI_ENABLED // dev->poll = switch_poll; // dev->weight = 64; //#endif SET_ETHTOOL_OPS(dev, &ifx_ethtool_ops); for ( i = 0, retval = 0; i < 6; i++ ) retval += dev->dev_addr[i]; if ( retval == 0 ) { /*read the mac address from the mac table and put them into the mac table.*/ for (i = 0, retval = 0; i < 6; i++) { retval +=my_ethaddr[i]; } /* if ethaddr not set in u-boot, then use default one */ if (retval == 0) { dev->dev_addr[0] = 0x00; dev->dev_addr[1] = 0x20; dev->dev_addr[2] = 0xda; dev->dev_addr[3] = 0x86; dev->dev_addr[4] = 0x23; dev->dev_addr[5] = 0x74 + macVal; } else { for (i = 0; i < 6; i++) { dev->dev_addr[i] = my_ethaddr[i]; } dev->dev_addr[5] += + macVal ; } macVal++; } return 0; }
/** * cvm_oct_common_init - per network device initialization * @dev: Device to initialize * * Returns Zero on success */ int cvm_oct_common_init(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); const u8 *mac = NULL; if (priv->of_node) mac = of_get_mac_address(priv->of_node); if (mac && is_valid_ether_addr(mac)) { memcpy(dev->dev_addr, mac, ETH_ALEN); dev->addr_assign_type &= ~NET_ADDR_RANDOM; } else { eth_hw_addr_random(dev); } /* * Force the interface to use the POW send if always_use_pow * was specified or it is in the pow send list. */ if ((pow_send_group != -1) && (always_use_pow || strstr(pow_send_list, dev->name))) priv->queue = -1; if (priv->queue != -1) { dev->features |= NETIF_F_SG; if (USE_HW_TCPUDP_CHECKSUM) dev->features |= NETIF_F_IP_CSUM; } /* We do our own locking, Linux doesn't need to */ dev->features |= NETIF_F_LLTX; SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops); cvm_oct_phy_setup_device(dev); cvm_oct_set_mac_filter(dev); dev->netdev_ops->ndo_change_mtu(dev, dev->mtu); /* * Zero out stats for port so we won't mistakenly show * counters from the bootloader. */ memset(dev->netdev_ops->ndo_get_stats(dev), 0, sizeof(struct net_device_stats)); return 0; }
/******************************************************************************* 函数名称 : sub_if_setup 功能描述 : 子接口初始化设置函数 输入参数 : sub_if_dev ---接口设备地址 输出参数 : 无 返回值 : 0 设置成功 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 王松波 修改目的 : 新增函数 修改日期 : 2010-09-16 ********************************************************************************/ static void sub_if_setup(struct net_device *sub_if_dev) { SET_MODULE_OWNER(sub_if_dev); ether_setup(sub_if_dev); SET_ETHTOOL_OPS(sub_if_dev, &sub_if_ethtool_ops); sub_if_dev->priv_flags = IFF_LAY3_SUB_INTERFACE; sub_if_dev->tx_queue_len = 0; sub_if_dev->change_mtu = sub_if_dev_change_mtu; sub_if_dev->open = sub_if_dev_open; sub_if_dev->stop = sub_if_dev_stop; sub_if_dev->set_mac_address = sub_if_dev_set_mac_address; sub_if_dev->set_multicast_list = sub_if_dev_set_multicast_list; sub_if_dev->destructor = if_dev_delete; sub_if_dev->do_ioctl = sub_if_dev_ioctl; sub_if_dev->hard_start_xmit = sub_if_dev_hard_start_xmit; }
static void do_setup(struct net_device *netdev) { ether_setup(netdev); netdev->netdev_ops = &internal_dev_netdev_ops; netdev->priv_flags &= ~IFF_TX_SKB_SHARING; netdev->destructor = internal_dev_destructor; SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops); netdev->tx_queue_len = 0; netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO; netdev->vlan_features = netdev->features; netdev->features |= NETIF_F_HW_VLAN_TX; random_ether_addr(netdev->dev_addr); }
static int tc589_probe(struct pcmcia_device *link) { struct el3_private *lp; struct net_device *dev; DEBUG(0, "3c589_attach()\n"); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) return -ENOMEM; lp = netdev_priv(dev); link->priv = dev; lp->p_dev = link; spin_lock_init(&lp->lock); link->io.NumPorts1 = 16; link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &el3_interrupt; link->irq.Instance = dev; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; /* The EL3-specific entries in the device structure. */ SET_MODULE_OWNER(dev); dev->hard_start_xmit = &el3_start_xmit; dev->set_config = &el3_config; dev->get_stats = &el3_get_stats; dev->set_multicast_list = &set_multicast_list; dev->open = &el3_open; dev->stop = &el3_close; #ifdef HAVE_TX_TIMEOUT dev->tx_timeout = el3_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; #endif SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); return tc589_config(link); } /* tc589_attach */
void br_dev_setup(struct net_device *dev) { random_ether_addr(dev->dev_addr); ether_setup(dev); dev->do_ioctl = br_dev_ioctl; dev->get_stats = br_dev_get_stats; dev->hard_start_xmit = br_dev_xmit; dev->open = br_dev_open; dev->set_multicast_list = br_dev_set_multicast_list; dev->change_mtu = br_change_mtu; dev->destructor = free_netdev; SET_ETHTOOL_OPS(dev, &br_ethtool_ops); dev->stop = br_dev_stop; dev->tx_queue_len = 0; dev->set_mac_address = br_set_mac_address; dev->priv_flags = IFF_EBRIDGE; dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_GSO_MASK | NETIF_F_NO_CSUM | NETIF_F_LLTX; }
static void do_setup(struct net_device *netdev) { ether_setup(netdev); netdev->netdev_ops = &internal_dev_netdev_ops; netdev->priv_flags &= ~IFF_TX_SKB_SHARING; netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE; netdev->destructor = internal_dev_destructor; SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops); netdev->tx_queue_len = 0; netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO; netdev->vlan_features = netdev->features; netdev->features |= NETIF_F_HW_VLAN_CTAG_TX; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) netdev->hw_features = netdev->features & ~NETIF_F_LLTX; #endif eth_hw_addr_random(netdev); }
/** * gether_setup - initialize one ethernet-over-usb link * @g: gadget to associated with these links * @ethaddr: NULL, or a buffer in which the ethernet address of the * host side of the link is recorded * Context: may sleep * * This sets up the single network link that may be exported by a * gadget driver using this framework. The link layer addresses are * set up using module parameters. * * Returns negative errno, or zero on success */ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]) { struct eth_dev *dev; struct net_device *net; int status; if (the_dev) return -EBUSY; net = alloc_etherdev(sizeof *dev); if (!net) return -ENOMEM; #ifdef CONFIG_USB_ANDROID_VERIZON /* verizon requirement : mtu size fix to 1428 */ net->mtu = 1428; #endif dev = netdev_priv(net); spin_lock_init(&dev->lock); spin_lock_init(&dev->req_lock); INIT_WORK(&dev->work, eth_work); INIT_LIST_HEAD(&dev->tx_reqs); INIT_LIST_HEAD(&dev->rx_reqs); skb_queue_head_init(&dev->rx_frames); /* network device setup */ dev->net = net; strcpy(net->name, "usb%d"); if (get_ether_addr(dev_addr, net->dev_addr)) dev_warn(&g->dev, "using random %s ethernet address\n", "self"); if (get_ether_addr(host_addr, dev->host_mac)) dev_warn(&g->dev, "using random %s ethernet address\n", "host"); if (ethaddr) memcpy(ethaddr, dev->host_mac, ETH_ALEN); net->netdev_ops = ð_netdev_ops; SET_ETHTOOL_OPS(net, &ops); /* two kinds of host-initiated state changes: * - iff DATA transfer is active, carrier is "on" * - tx queueing enabled if open *and* carrier is "on" */ netif_stop_queue(net); netif_carrier_off(net); dev->gadget = g; SET_NETDEV_DEV(net, &g->dev); SET_NETDEV_DEVTYPE(net, &gadget_type); status = register_netdev(net); if (status < 0) { dev_dbg(&g->dev, "register_netdev failed, %d\n", status); free_netdev(net); } else { the_dev = dev; } return status; }
void ixgbevf_set_ethtool_ops(struct net_device *netdev) { SET_ETHTOOL_OPS(netdev, &ixgbevf_ethtool_ops); }
void igbvf_set_ethtool_ops(struct net_device *netdev) { /* have to "undeclare" const on this struct to remove warnings */ SET_ETHTOOL_OPS(netdev, (struct ethtool_ops *)&igbvf_ethtool_ops); }
void ehea_set_ethtool_ops(struct net_device *netdev) { SET_ETHTOOL_OPS(netdev, &ehea_ethtool_ops); }