Exemplo n.º 1
0
static int vlan_dev_init(struct net_device *dev)
{
    struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;

    netif_carrier_off(dev);

    /* IFF_BROADCAST|IFF_MULTICAST; ??? */
    dev->flags  = real_dev->flags & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
                                      IFF_MASTER | IFF_SLAVE);
    dev->state  = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
                                      (1<<__LINK_STATE_DORMANT))) |
                  (1<<__LINK_STATE_PRESENT);

    dev->hw_features = NETIF_F_ALL_CSUM | NETIF_F_SG |
                       NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE |
                       NETIF_F_HIGHDMA | NETIF_F_SCTP_CSUM |
                       NETIF_F_ALL_FCOE;

    dev->features |= real_dev->vlan_features | NETIF_F_LLTX |
                     NETIF_F_GSO_SOFTWARE;
    dev->gso_max_size = real_dev->gso_max_size;
    if (dev->features & NETIF_F_VLAN_FEATURES)
        netdev_warn(real_dev, "VLAN features are set incorrectly.  Q-in-Q configurations may not work correctly.\n");

    dev->vlan_features = real_dev->vlan_features & ~NETIF_F_ALL_FCOE;

    /* ipv6 shared card related stuff */
    dev->dev_id = real_dev->dev_id;

    if (is_zero_ether_addr(dev->dev_addr))
        eth_hw_addr_inherit(dev, real_dev);
    if (is_zero_ether_addr(dev->broadcast))
        memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);

#if IS_ENABLED(CONFIG_FCOE)
    dev->fcoe_ddp_xid = real_dev->fcoe_ddp_xid;
#endif

    dev->needed_headroom = real_dev->needed_headroom;
    if (vlan_hw_offload_capable(real_dev->features,
                                vlan_dev_priv(dev)->vlan_proto)) {
        dev->header_ops      = &vlan_passthru_header_ops;
        dev->hard_header_len = real_dev->hard_header_len;
    } else {
        dev->header_ops      = &vlan_header_ops;
        dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
    }

    dev->netdev_ops = &vlan_netdev_ops;

    SET_NETDEV_DEVTYPE(dev, &vlan_type);

    vlan_dev_set_lockdep_class(dev, vlan_dev_get_lock_subclass(dev));

    vlan_dev_priv(dev)->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats);
    if (!vlan_dev_priv(dev)->vlan_pcpu_stats)
        return -ENOMEM;

    return 0;
}
Exemplo n.º 2
0
static void vlan_transfer_features(struct net_device *dev,
				   struct net_device *vlandev)
{
	struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);

	vlandev->gso_max_size = dev->gso_max_size;

	if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
		vlandev->hard_header_len = dev->hard_header_len;
	else
		vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN;

#if IS_ENABLED(CONFIG_FCOE)
	vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;
#endif

	netdev_update_features(vlandev);
}