标签:add setup header lis struct flags code 网卡 against
在bond初始化的时候,我们可以看到如下属性:
static void loopback_setup(struct net_device *dev) { dev->mtu = 64 * 1024; dev->hard_header_len = ETH_HLEN; /* 14 */ dev->addr_len = ETH_ALEN; /* 6 */ dev->type = ARPHRD_LOOPBACK; /* 0x0001*/ dev->flags = IFF_LOOPBACK; dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE; netif_keep_dst(dev); dev->hw_features = NETIF_F_GSO_SOFTWARE; dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SCTP_CRC | NETIF_F_HIGHDMA | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL | NETIF_F_VLAN_CHALLENGED | NETIF_F_LOOPBACK; dev->ethtool_ops = &loopback_ethtool_ops; dev->header_ops = ð_header_ops; dev->netdev_ops = &loopback_ops; dev->destructor = loopback_dev_free; }
NETIF_F_LLTX 属性代表的是,我们在发包的时候,不需要获取锁。
而对于非虚拟设备,如实际网卡,则这个属性一般是不设置的,也就是需要获取TX的锁。
不过,也有注释说后面的驱动最好不要用这个特性:
* LLTX driver (deprecated for hardware drivers) NETIF_F_LLTX should be set in drivers that implement their own locking in transmit path or don‘t need locking at all (e.g. software tunnels). In ndo_start_xmit, it is recommended to use a try_lock and return NETDEV_TX_LOCKED when the spin lock fails. The locking should also properly protect against other callbacks (the rules you need to find out). Don‘t use it for new drivers.
标签:add setup header lis struct flags code 网卡 against
原文地址:https://www.cnblogs.com/10087622blog/p/9571055.html