示例#1
0
文件: dummy.c 项目: 274914765/C
static void dummy_setup(struct net_device *dev)
{
    /* Initialize the device structure. */
    dev->hard_start_xmit = dummy_xmit;
    dev->set_multicast_list = set_multicast_list;
    dev->set_mac_address = dummy_set_address;
    dev->destructor = free_netdev;

    /* Fill in device structure with ethernet-generic values. */
    ether_setup(dev);
    dev->tx_queue_len = 0;
    dev->change_mtu = NULL;
    dev->flags |= IFF_NOARP;
    dev->flags &= ~IFF_MULTICAST;
    random_ether_addr(dev->dev_addr);
}
示例#2
0
void vlan_setup(struct net_device *dev)
{
	ether_setup(dev);

	dev->priv_flags		|= IFF_802_1Q_VLAN;
	dev->priv_flags		&= ~IFF_XMIT_DST_RELEASE;
	dev->tx_queue_len	= 0;

	dev->netdev_ops		= &vlan_netdev_ops;
	dev->destructor		= free_netdev;
	dev->ethtool_ops	= &vlan_ethtool_ops;

	memset(dev->broadcast, 0, ETH_ALEN);
	if (!ve_is_super(get_exec_env()))
		dev->features |= NETIF_F_VIRTUAL;
}
示例#3
0
static int netx_eth_enable(struct net_device *ndev)
{
	struct netx_eth_priv *priv = netdev_priv(ndev);
	unsigned int mac4321, mac65;
	int running, i;

	ether_setup(ndev);

	ndev->open = netx_eth_open;
	ndev->stop = netx_eth_close;
	ndev->hard_start_xmit = netx_eth_hard_start_xmit;
	ndev->tx_timeout = netx_eth_timeout;
	ndev->watchdog_timeo = msecs_to_jiffies(5000);
	ndev->get_stats = netx_eth_query_statistics;
	ndev->set_multicast_list = netx_eth_set_multicast_list;

	priv->msg_enable       = NETIF_MSG_LINK;
	priv->mii.phy_id_mask  = 0x1f;
	priv->mii.reg_num_mask = 0x1f;
	priv->mii.force_media  = 0;
	priv->mii.full_duplex  = 0;
	priv->mii.dev	     = ndev;
	priv->mii.mdio_read    = netx_eth_phy_read;
	priv->mii.mdio_write   = netx_eth_phy_write;
	priv->mii.phy_id = INTERNAL_PHY_ADR + priv->id;

	running = xc_running(priv->xc);
	xc_stop(priv->xc);

	/* if the xc engine is already running, assume the bootloader has
	 * loaded the firmware for us
	 */
	if (running) {
		/* get Node Address from hardware */
		mac4321 = readl(priv->xpec_base +
			NETX_XPEC_RAM_START_OFS + ETH_MAC_4321);
		mac65 = readl(priv->xpec_base +
			NETX_XPEC_RAM_START_OFS + ETH_MAC_65);

		ndev->dev_addr[0] = mac4321 & 0xff;
		ndev->dev_addr[1] = (mac4321 >> 8) & 0xff;
		ndev->dev_addr[2] = (mac4321 >> 16) & 0xff;
		ndev->dev_addr[3] = (mac4321 >> 24) & 0xff;
		ndev->dev_addr[4] = mac65 & 0xff;
		ndev->dev_addr[5] = (mac65 >> 8) & 0xff;
	} else {
		if (xc_request_firmware(priv->xc)) {
示例#4
0
void vlan_setup(struct net_device *dev)
{
	ether_setup(dev);

	dev->priv_flags		|= IFF_802_1Q_VLAN;
	dev->tx_queue_len	= 0;

	dev->netdev_ops		= &vlan_netdev_ops;
	dev->destructor		= free_netdev;
	dev->ethtool_ops	= &vlan_ethtool_ops;

#if defined(CONFIG_MIPS_BRCM) && defined(CONFIG_BLOG)
	dev->put_stats = vlan_dev_update_stats;
	dev->clr_stats = vlan_dev_clear_stats;
#endif
	memset(dev->broadcast, 0, ETH_ALEN);
}
示例#5
0
static void __init rmnet_setup(struct net_device *dev)
{
    dev->open = rmnet_open;
    dev->stop = rmnet_stop;
    dev->hard_start_xmit = rmnet_xmit;
    dev->get_stats = rmnet_get_stats;
    dev->set_multicast_list = rmnet_set_multicast_list;
    dev->tx_timeout = rmnet_tx_timeout;

    dev->watchdog_timeo = 1000; /* 10 seconds? */

    ether_setup(dev);

    dev->change_mtu = 0; /* ??? */

    random_ether_addr(dev->dev_addr);
}
示例#6
0
文件: ifb.c 项目: ena30/snake-os
static void __init ifb_setup(struct net_device *dev)
{
	/* Initialize the device structure. */
	dev->get_stats = ifb_get_stats;
	dev->hard_start_xmit = ifb_xmit;
	dev->open = &ifb_open;
	dev->stop = &ifb_close;

	/* Fill in device structure with ethernet-generic values. */
	ether_setup(dev);
	dev->tx_queue_len = TX_Q_LIMIT;
	dev->change_mtu = NULL;
	dev->flags |= IFF_NOARP;
	dev->flags &= ~IFF_MULTICAST;
	SET_MODULE_OWNER(dev);
	random_ether_addr(dev->dev_addr);
}
示例#7
0
static void vboxNetAdpNetDevInit(struct net_device *pNetDev)
{
    PVBOXNETADPPRIV pPriv;

    ether_setup(pNetDev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    pNetDev->netdev_ops = &vboxNetAdpNetdevOps;
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
    pNetDev->open = vboxNetAdpLinuxOpen;
    pNetDev->stop = vboxNetAdpLinuxStop;
    pNetDev->hard_start_xmit = vboxNetAdpLinuxXmit;
    pNetDev->get_stats = vboxNetAdpLinuxGetStats;
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */

    pPriv = netdev_priv(pNetDev);
    memset(pPriv, 0, sizeof(*pPriv));
}
示例#8
0
/**
 * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data
 *
 * Called by alloc_netdev()
 */
void i2400m_netdev_setup(struct net_device *net_dev)
{
	d_fnstart(3, NULL, "(net_dev %p)\n", net_dev);
	ether_setup(net_dev);
	net_dev->mtu = I2400M_MAX_MTU;
	net_dev->tx_queue_len = I2400M_TX_QLEN;
	net_dev->features =
		  NETIF_F_VLAN_CHALLENGED
		| NETIF_F_HIGHDMA;
	net_dev->flags =
		IFF_NOARP		/* i2400m is apure IP device */
		& (~IFF_BROADCAST	/* i2400m is P2P */
		   & ~IFF_MULTICAST);
	net_dev->watchdog_timeo = I2400M_TX_TIMEOUT;
	net_dev->netdev_ops = &i2400m_netdev_ops;
	d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev);
}
示例#9
0
文件: dummy.c 项目: xricson/knoppix
static void __init dummy_setup(struct net_device *dev)
{
	/* Initialize the device structure. */
	dev->get_stats = dummy_get_stats;
	dev->hard_start_xmit = dummy_xmit;
	dev->set_multicast_list = set_multicast_list;
#ifdef CONFIG_NET_FASTROUTE
	dev->accept_fastpath = dummy_accept_fastpath;
#endif

	/* Fill in device structure with ethernet-generic values. */
	ether_setup(dev);
	dev->tx_queue_len = 0;
	dev->flags |= IFF_NOARP;
	dev->flags &= ~IFF_MULTICAST;
	SET_MODULE_OWNER(dev);
}
示例#10
0
static int __init
ramips_eth_probe(struct net_device *dev)
{
	struct raeth_priv *priv = netdev_priv(dev);

	BUG_ON(!priv->plat->reset_fe);
	priv->plat->reset_fe();
	net_srandom(jiffies);
	memcpy(dev->dev_addr, priv->plat->mac, ETH_ALEN);

	ether_setup(dev);
	dev->mtu = 1500;
	dev->watchdog_timeo = TX_TIMEOUT;
	spin_lock_init(&priv->page_lock);

	return 0;
}
static void __init rmnet_setup(struct net_device *dev)
{
	pr_info("msm_rmnet: %s\n",  __func__);

	/* Using Ethernet mode by default */
	dev->netdev_ops = &rmnet_ops_ether;
	ether_setup(dev);

	/* set this after calling ether_setup */
	dev->mtu = RMNET_DATA_LEN;
	dev->needed_headroom = HEADROOM_FOR_QOS;

	random_ether_addr(dev->dev_addr);

	dev->watchdog_timeo = 1000; /* 10 seconds? */
	pr_info("msm_rmnet: %s complete\n",  __func__);
}
示例#12
0
static int tap_dev_init(struct net_device *dev)
{
    ether_setup(dev);

    dev->open            = tap_dev_open;
    dev->hard_start_xmit = tap_dev_xmit;
    dev->get_stats       = tap_dev_get_stats;
    dev->change_mtu      = tap_dev_change_mtu;
    dev->set_mac_address = NULL;

    dev->mtu             = 1500;
    dev->flags           &= ~IFF_MULTICAST;

    SET_MODULE_OWNER(dev);

    return 0;
}
示例#13
0
static int ifxmips_mii_dev_init(struct net_device *dev)
{
	int i;
	struct ifxmips_mii_priv *priv;

	ether_setup(dev);
	printk(KERN_INFO "ifxmips_mii0: %s is up\n", dev->name);
	dev->open = ifxmips_ifxmips_mii_open;
	dev->stop = ifxmips_mii_release;
	dev->hard_start_xmit = ifxmips_mii_tx;
	dev->get_stats = ifxmips_get_stats;
	dev->tx_timeout = ifxmips_mii_tx_timeout;
	dev->watchdog_timeo = 10 * HZ;
	memset(dev->priv, 0, sizeof(struct ifxmips_mii_priv));
	priv = dev->priv;
	priv->dma_device = dma_device_reserve("PPE");
	if (!priv->dma_device) {
		BUG();
		return -ENODEV;
	}
	priv->dma_device->buffer_alloc = &ifxmips_etop_dma_buffer_alloc;
	priv->dma_device->buffer_free = &ifxmips_etop_dma_buffer_free;
	priv->dma_device->intr_handler = &dma_intr_handler;
	priv->dma_device->max_rx_chan_num = 4;

	for (i = 0; i < priv->dma_device->max_rx_chan_num; i++) {
		priv->dma_device->rx_chan[i]->packet_size = ETHERNET_PACKET_DMA_BUFFER_SIZE;
		priv->dma_device->rx_chan[i]->control = IFXMIPS_DMA_CH_ON;
	}

	for (i = 0; i < priv->dma_device->max_tx_chan_num; i++)
		if (i == 0)
			priv->dma_device->tx_chan[i]->control = IFXMIPS_DMA_CH_ON;
		else
			priv->dma_device->tx_chan[i]->control = IFXMIPS_DMA_CH_OFF;

	dma_device_register(priv->dma_device);

	printk(KERN_INFO "ifxmips_mii0: using mac=");
	for (i = 0; i < 6; i++) {
		dev->dev_addr[i] = mac_addr[i];
		printk("%02X%c", dev->dev_addr[i], (i == 5) ? ('\n') : (':'));
	}
	return 0;
}
示例#14
0
static void __init rmnet_setup(struct net_device *dev)
{
	dev->open = rmnet_open;
	dev->stop = rmnet_stop;
	dev->hard_start_xmit = rmnet_xmit;
	dev->get_stats = rmnet_get_stats;
	dev->set_multicast_list = rmnet_set_multicast_list;
	dev->tx_timeout = rmnet_tx_timeout;

	dev->watchdog_timeo = 20; /* ??? */

	ether_setup(dev);
    /*fixme : this is a workaround way to avoid mms cannot be sent normally in shenzhen */
    dev->mtu		= MMS_DATA_LEN;
	dev->change_mtu = 0; /* ??? */

	random_ether_addr(dev->dev_addr);
}
示例#15
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;
}
示例#16
0
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 void ifb_setup(struct net_device *dev)
{
	/* Initialize the device structure. */
	dev->destructor = free_netdev;
	dev->netdev_ops = &ifb_netdev_ops;

	/* Fill in device structure with ethernet-generic values. */
	ether_setup(dev);
	dev->tx_queue_len = TX_Q_LIMIT;

	dev->features |= IFB_FEATURES;
	dev->vlan_features |= IFB_FEATURES;

	dev->flags |= IFF_NOARP;
	dev->flags &= ~IFF_MULTICAST;
	dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
	random_ether_addr(dev->dev_addr);
}
示例#18
0
void vlan_setup(struct net_device *dev)
{
	ether_setup(dev);

	dev->priv_flags		|= IFF_802_1Q_VLAN | IFF_NO_QUEUE;
	dev->priv_flags		|= IFF_UNICAST_FLT;
	dev->priv_flags		&= ~IFF_TX_SKB_SHARING;
	netif_keep_dst(dev);

	dev->netdev_ops		= &vlan_netdev_ops;
	dev->destructor		= vlan_dev_free;
	dev->ethtool_ops	= &vlan_ethtool_ops;

	dev->min_mtu		= 0;
	dev->max_mtu		= ETH_MAX_MTU;

	eth_zero_addr(dev->broadcast);
}
示例#19
0
文件: netdev.c 项目: avagin/linux
static void nsim_setup(struct net_device *dev)
{
	ether_setup(dev);
	eth_hw_addr_random(dev);

	dev->tx_queue_len = 0;
	dev->flags |= IFF_NOARP;
	dev->flags &= ~IFF_MULTICAST;
	dev->priv_flags |= IFF_LIVE_ADDR_CHANGE |
			   IFF_NO_QUEUE;
	dev->features |= NETIF_F_HIGHDMA |
			 NETIF_F_SG |
			 NETIF_F_FRAGLIST |
			 NETIF_F_HW_CSUM |
			 NETIF_F_TSO;
	dev->hw_features |= NETIF_F_HW_TC;
	dev->max_mtu = ETH_MAX_MTU;
}
示例#20
0
/*
 * The init function (sometimes called probe).
 * It is invoked by register_netdev()
 */
int snull_init(struct net_device *dev)
{
#if 0
    /*
     * Make the usual checks: check_region(), probe irq, ...  -ENODEV
     * should be returned if no device found.  No resource should be
     * grabbed: this is done on open(). 
     */
#endif

    /* 
     * Then, assign other fields in dev, using ether_setup() and some
     * hand assignments
     */
    ether_setup(dev); /* assign some of the fields */

    dev->open            = snull_open;
    dev->stop            = snull_release;
    dev->set_config      = snull_config;
    dev->hard_start_xmit = snull_tx;
    dev->do_ioctl        = snull_ioctl;
    dev->get_stats       = snull_stats;
    dev->change_mtu      = snull_change_mtu;  
    dev->rebuild_header  = snull_rebuild_header;
    dev->hard_header     = snull_header;
#ifdef HAVE_TX_TIMEOUT
    dev->tx_timeout     = snull_tx_timeout;
    dev->watchdog_timeo = timeout;
#endif
    /* keep the default flags, just add NOARP */
    dev->flags           |= IFF_NOARP;
    dev->hard_header_cache = NULL;      /* Disable caching */

    /*
     * Then, allocate the priv field. This encloses the statistics
     * and a few private fields.
     */
    dev->priv = kmalloc(sizeof(struct snull_priv), GFP_KERNEL);
    if (dev->priv == NULL)
        return -ENOMEM;
    memset(dev->priv, 0, sizeof(struct snull_priv));
    spin_lock_init(& ((struct snull_priv *) dev->priv)->lock);
    return 0;
}
示例#21
0
文件: tun.c 项目: VTun/tun
/* Initialize net device */
int tun_net_init(struct device *dev)
{
   struct tun_struct *tun = (struct tun_struct *)dev->priv;
   
   DBG(KERN_INFO "%s: tun_net_init\n", tun->name);

   dev->open = tun_net_open;
   dev->hard_start_xmit = tun_net_xmit;
   dev->stop = tun_net_close;
   dev->get_stats = tun_net_stats;

   switch( tun->flags & TUN_TYPE_MASK ) {
      case TUN_TUN_DEV:
         /* Point-to-Point TUN Device */

	 dev->hard_header_len=0;
	 dev->addr_len=0;
	 dev->mtu = 1500;
 	 /* Type PPP seems most suitable */
	 dev->type = ARPHRD_PPP; 
	 dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
	 dev->tx_queue_len = 10;

         dev_init_buffers(dev);

	 break;
      case TUN_TAP_DEV:
   	 /* Ethernet TAP Device */
   	 
         dev->set_multicast_list = tun_net_mclist;

	 /* Generate Ethernet address 
	  * Should be random enough  */
   	 *(unsigned short *)dev->dev_addr = htons(0x00FF);
   	 *(unsigned long *)(dev->dev_addr + sizeof(short)) = 
		htonl( (long)((jiffies & 0x00ffffff)<<8) | (dev->base_addr+1) );

   	 ether_setup(dev);

	 break;
   }

   return 0;
}
示例#22
0
/* --------------------------------------------------------------------------
 * The initialization function: it is used to assign fields in the structure
 * Initializes the operation table and also the slave device to transmit the data 
 */
void vni_init(struct net_device *dev)
{
    struct net_device *slave;
    struct vni_private *priv; 

    ether_setup(dev); /* assign some of the fields as "generic ethernet" */
    memset(netdev_priv(dev), 0, sizeof(struct vni_private));
    
    dev->netdev_ops = &vni_net_device_ops;

    /* Assign random MAC address */
    random_ether_addr(dev->dev_addr);

    /* Hardcode the transmitting module to USB2 */
    /* interface name */
    priv = netdev_priv(dev);
    slave = __dev_get_by_name(&init_net, "usb2");
    if (!slave)
    {
         printk(" Slave Interface Doesn't exists , Returning\n");
         return;
    }
    if (slave->type != ARPHRD_ETHER && slave->type != ARPHRD_LOOPBACK)
    {
         printk("This is not compatible interface");
         return;

    }

    /* The interface is good, get hold of it */
    priv->priv_device = slave;
    if (slave->header_ops)
           dev->header_ops = &vni_header_ops;
    else
           dev->header_ops = NULL;

    /* also, and clone its IP, MAC and other information */
    memcpy(dev->dev_addr,  slave->dev_addr,  ETH_ALEN);
    memcpy(dev->broadcast, slave->broadcast, sizeof(slave->broadcast));

    /* Assign default value (no checks here) */
    priv->priv_mode = VNI_PASS;

}
示例#23
0
void br_dev_setup(struct net_device *dev)
{
	memset(dev->dev_addr, 0, ETH_ALEN);

	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->destructor = free_netdev;
	SET_MODULE_OWNER(dev);
	dev->stop = br_dev_stop;
	dev->accept_fastpath = br_dev_accept_fastpath;
	dev->tx_queue_len = 0;
	dev->set_mac_address = NULL;
	dev->priv_flags = IFF_EBRIDGE;
}
示例#24
0
文件: vrf.c 项目: 513855417/linux
static void vrf_setup(struct net_device *dev)
{
	ether_setup(dev);

	/* Initialize the device structure. */
	dev->netdev_ops = &vrf_netdev_ops;
	dev->l3mdev_ops = &vrf_l3mdev_ops;
	dev->ethtool_ops = &vrf_ethtool_ops;
	dev->destructor = free_netdev;

	/* Fill in device structure with ethernet-generic values. */
	eth_hw_addr_random(dev);

	/* don't acquire vrf device's netif_tx_lock when transmitting */
	dev->features |= NETIF_F_LLTX;

	/* don't allow vrf devices to change network namespaces. */
	dev->features |= NETIF_F_NETNS_LOCAL;
}
示例#25
0
struct device *
init_etherdev(struct device *dev, int sizeof_private, unsigned long *mem_startp)
{
	int new_device = 0;
	int i;

	if (dev == NULL) {
		int alloc_size = sizeof(struct device) + sizeof("eth%d   ")
			+ sizeof_private;
		if (mem_startp && *mem_startp ) {
			dev = (struct device *)*mem_startp;
			*mem_startp += alloc_size;
		} else
			dev = (struct device *)kmalloc(alloc_size, GFP_KERNEL);
		memset(dev, 0, alloc_size);
		if (sizeof_private)
			dev->priv = (void *) (dev + 1);
		dev->name = sizeof_private + (char *)(dev + 1);
		new_device = 1;
	}

	if (dev->name &&
		((dev->name[0] == '\0') || (dev->name[0] == ' '))) {
		for (i = 0; i < MAX_ETH_CARDS; ++i)
			if (ethdev_index[i] == NULL) {
				sprintf(dev->name, "eth%d", i);
				ethdev_index[i] = dev;
				break;
			}
	}

	ether_setup(dev); /* should this be called here? */
	
	if (new_device) {
		/* Append the device to the device queue. */
		struct device **old_devp = &dev_base;
		while ((*old_devp)->next)
			old_devp = & (*old_devp)->next;
		(*old_devp)->next = dev;
		dev->next = 0;
	}
	return dev;
}
示例#26
0
static int
eth_init(struct net_device *ndev)
{
    Debug((PRINT_PREFIX "eth_init\n"));

    ether_setup(ndev);
    ndev->open = eth_open;
    ndev->stop = eth_stop;
    ndev->hard_start_xmit = eth_hard_start_xmit;
    ndev->set_config = eth_set_config;
    ndev->get_stats = eth_get_stats;
    ndev->set_multicast_list = eth_set_multicast_list;
    ndev->set_mac_address = eth_set_mac_address;

    /* Assign default hardware ethernet address */
    eth_assign_def_addr(ndev);

    return 0;
}
示例#27
0
struct net_device *
_kc_alloc_etherdev(int sizeof_priv)
{
	struct net_device *dev;
	int alloc_size;

	alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 31;
	dev = kmalloc(alloc_size, GFP_KERNEL);
	if (!dev)
		return NULL;
	memset(dev, 0, alloc_size);

	if (sizeof_priv)
		dev->priv = (void *) (((unsigned long)(dev + 1) + 31) & ~31);
	dev->name[0] = '\0';
	ether_setup(dev);

	return dev;
}
示例#28
0
void bnep_net_setup(struct net_device *dev)
{

	memset(dev->broadcast, 0xff, ETH_ALEN);
	dev->addr_len = ETH_ALEN;

	ether_setup(dev);

	dev->open            = bnep_net_open;
	dev->stop            = bnep_net_close;
	dev->hard_start_xmit = bnep_net_xmit;
	dev->get_stats       = bnep_net_get_stats;
	dev->do_ioctl        = bnep_net_ioctl;
	dev->set_mac_address = bnep_net_set_mac_addr;
	dev->set_multicast_list = bnep_net_set_mc_list;

	dev->watchdog_timeo  = HZ * 2;
	dev->tx_timeout      = bnep_net_timeout;
}
示例#29
0
int
vnatvif_probe(struct net_device *dev)
{
    /*
     * Fetch debugging level from "irq" and reset "irq" to 0.
     * This way we don't have to use a global variable so we will be
     * self-contained.
     */
#ifdef DEBUG
    debug = dev->irq;
    dev->irq = 0;
#endif

    PRINTK4(debug, ("[%s:%d|vnatvif_probe]: { %s }\n", \
		    current->comm, current->pid, dev->name));

    memcpy(dev->dev_addr, "\xFE\xFE\x00\x00\x00\x00", 6);

    /*
     * Initialize the device structure.
     */
    if ((dev->priv = kmalloc(sizeof(struct vnatvif_priv), GFP_KERNEL))
	== NULL) return -ENOMEM;
    memset(dev->priv, 0, sizeof(struct vnatvif_priv));

    /*
     * Setup the generic properties
     */
    ether_setup(dev);

    /*
     * The rdr specific entries in the device structure.
     */
    dev->open = vnatvif_open;
    dev->hard_start_xmit = vnatvif_start_xmit;
    dev->stop = vnatvif_close;
    dev->get_stats = vnatvif_get_stats;

    dev->flags |= (IFF_NOARP | IFF_POINTOPOINT);
    dev->tx_queue_len = 0;

    return 0;
}
示例#30
0
文件: eth.c 项目: 32bitmicro/xvisor
struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
				      unsigned int rxqs)
{
	static int eth_num = 0;
	struct net_device *ndev = NULL;

	if (1 != txqs && 1 != rxqs) {
		vmm_lwarning("Warning: Multi-queue network is not supported "
			     "yet.");
	}
	ndev = alloc_etherdev(sizeof_priv);
	if (!ndev)
		return NULL;

	ether_setup(ndev);
	snprintf(ndev->name, sizeof (ndev->name), "eth%d", eth_num++);

	return ndev;
}